Skip to content

ADR-004: Local-First Architecture

Status: Accepted
Date: 2025-06-01
Authors: SpanForge Core Team

Context

Developers need SpanForge to work without an internet connection or a remote endpoint during development and testing. Requiring a live server for every test run slows CI and creates unnecessary external dependencies.

Decision

All services detect "local mode" when endpoint == "" (or is not set) and fall back to in-process implementations:

ServiceLocal Mode Behaviour
sf_piiPresidio-based local scanning
sf_auditFile-based JSONL append-only backend
sf_observeIn-memory span store; OTLP export skipped
sf_gateLocal YAML rule evaluation; subprocess gates still run
sf_alertIn-memory alert queue; no webhook/email delivery

Warning: In local mode, state is stored in-memory or in local files. It is not shared across processes and is lost on restart. See the In-Memory State guide for details.

Consequences

  • Positive: Zero external dependencies for basic operation.
  • Positive: Tests run without network access; no mocking of HTTP clients.
  • Negative: Feature parity between local and remote modes must be actively maintained.
  • Negative: In-memory spans/alerts are lost on process restart; production deployments must configure a real endpoint.

Alternatives Considered

AlternativeReason Rejected
Always require a remote endpointBreaks offline development; slow CI
Embedded SQLite for all local stateAdds a dependency; overkill for ephemeral dev data
Docker-compose test stack requiredToo heavy for unit tests; poor DX