Skip to main content

Architecture

FactLane is a local governed-memory service for MCP agents. Its stored records support a decision but do not supersede the user's current instructions, repository state, or a live authoritative source. The system keeps the transport, authorization, fact lifecycle, and storage boundaries separate.

Request path​

Local MCP host / trusted launcher
-> immutable host and write-context bindings
-> stdio MCP gateway (five tools)
-> scope, identity and authority checks
-> memory adapter / bounded retrieval routing
-> local embedding provider + SQLite-vec storage

MemoryGateway receives the five operations: memory_search, memory_get, memory_store, memory_update, and memory_status. It rejects unsupported transports and caller-supplied host identity claims. MemoryAdapter owns request validation, freshness, permissions, contradiction handling, retrieval budgets, and revision policy; TruthRouter selects bounded search behavior inside the adapter. The backend supplies SQLite connections and SQLite-vec primitives, not FactLane's authorization decisions.

The public server boundary converts governed AdapterError failures into the ordinary MCP result shape with status=BLOCKED, stable error_code, safe message, empty results, and trusted audit metadata. This conversion exists only at the public server boundary; direct gateway/adapter callers still receive AdapterError, and unexpected exceptions remain MCP transport errors rather than being relabeled as governed outcomes.

The server supports local stdio only. Codex and Hermes are tested host integrations, but the dispatch path is not specific to either. Another client that supports command-launched stdio MCP may use the same executable; it is not automatically a separately qualified host. Launcher identity is not operating-system or cryptographic attestation.

Scope and trusted identity​

The public contract defines five scopes:

ScopeIdentity requirement
GLOBAL_USERNo project/workflow identity.
PROJECTAn exact project_id.
WORKFLOWExact project_id and workflow_id.
TOOL_ENVIRONMENTAn exact agent_id.
CROSS_PROJECT_WORKFLOWAll project, worktree, workflow, and agent identity keys must be absent.

When the trusted launcher supplies current-context identities, the gateway inserts applicable missing values for PROJECT, WORKFLOW, and TOOL_ENVIRONMENT. A conflicting explicit value fails with BOUND_CONTEXT_IDENTITY_MISMATCH; the original request is not rewritten. GLOBAL_USER and CROSS_PROJECT_WORKFLOW do not inherit bound identities. The latter scope is for workflow rules that apply across projects, not a query that searches every project in turn.

Contributions, verification, and revisions​

A normal process starts with --write-profile read-only unless the launcher grants another profile. delegated-candidate permits an agent to submit a bounded CANDIDATE with source provenance, a freshness policy, and an idempotency key. It does not permit that agent to mint VALIDATED_CURRENT by asserting a verifier identity in its request.

That runtime grant is separate from content consent. Candidate content is eligible for submission only after an explicit user remember/store request or an agent proposal that the user explicitly authorizes. Content consent does not change the launcher profile or grant verifier authority.

Promotion is a distinct memory_update operation: a trusted verifier uses REVERIFY, the expected revision, and the exact Candidate expected_record_id. Storage contract v3 keeps contribution_origin separate from verification and preserves it on promotion. The verifier is recorded separately; an older record is not silently rewritten as if it had been contributed by the verifier. REVERIFY also preserves contradiction identity: the fact, scope, memory type, and subject remain the same logical memory. Identity-bearing assertions must match the existing record; semantic reclassification uses REPLACE.

Revision changes use transaction-local compare-and-swap. A stale independent writer receives VERSION_CONFLICT. For a Candidate promotion, exact scope, logical memory, parent record, revision, lifecycle, and contradiction checks occur inside the same SQLite transaction. Duplicate or retried requests are resolved through the governed idempotency rules; an idempotency key from a more privileged request is not an authorization token.

Storage contract v3 also blocks stale or untrusted writers from inserting, updating, or deleting governed adapter/lifecycle state. The trusted writer capability is connection-local; lifecycle event history is append-only for ordinary governed writes and lifecycle-operation state has a separate Recovery-only decision path. Global idempotency spans ordinary adapter writes and Owner lifecycle operations so the same key cannot silently mean two different mutations.

Owner control plane​

The normal MCP surface remains exactly five tools. Direct Owner lifecycle work is coordinated by OwnerControlService, which provides bounded inventory/detail, conflict review, health/retention inspection, REVOKE/REJECT, contradiction resolution, reverification/replacement, manual freshness recheck, and readmission without expanding normal-agent authority.

The packaged factlane-owner CLI creates the service under a trusted owner-current launcher context. Scope and launcher identity come from CLI arguments; mutation JSON cannot override them. Every mutation is revision/idempotency protected, and operations that can affect a contradiction group require the exact observed Group CAS token.

The packaged factlane-owner-webui launcher is another presentation layer over the same service. Its server binds exactly to 127.0.0.1 and one immutable scope. Startup prints the bound origin and a short-lived one-use bootstrap token. That token is accepted only through the X-FactLane-Bootstrap header on /owner/bootstrap; URL credentials are rejected and the UI does not persist the bootstrap token in localStorage. A successful exchange consumes the token, establishes an HttpOnly; SameSite=Strict authenticated session, and returns the CSRF token used by later mutations. The WebUI is not an HTTP MCP transport and does not add a sixth MCP tool.

The WebUI exposes operator views for Overview, Current, Candidates, Conflicts, Needs Review, History, and System Health. Record and conflict views expose only the governed actions valid for the observed state, including REVERIFY, REPLACE, REVOKE, REJECT, manual recheck, readmission, and conflict resolution. Mutations remain bound to the trusted launcher scope, exact record revision, idempotency key, and the displayed contradiction-group CAS token where required.

For on_change freshness, FactLane stores a recheck contract but does not run a source watcher. An Owner manual recheck supplies fresh observation evidence; changed, unavailable, indeterminate, stale, or mismatched evidence blocks renewed eligibility. REVOKED and REJECTED are logical terminal states. Readmission can create a governed successor for an eligible REVOKED logical memory after new verification and CAS checks; it is distinct from restoring database bytes and cannot recreate content removed by sensitive-memory Recovery.

Retrieval and history​

CURRENT retrieval admits only eligible VALIDATED_CURRENT facts within the exact scope. For keyword search, the lifecycle filter precedes SQL limits. For semantic search, sqlite-vec KNN constrains eligible row IDs **inside the vector query before k **. Otherwise, many closer unverified Candidates could fill the top results and conceal a farther validated fact.

After CURRENT semantic/hybrid candidates pass lifecycle and freshness checks, the adapter selects the highest-ranked candidate from distinct stored provenance sources before filling remaining slots with repeated-source candidates. This reduces same-document crowding without changing stored scores: the top eligible result is preserved, and the selected set is emitted in its original relevance order. After the top result, an unseen source can therefore occupy a slot ahead of a higher-scored repeat from the same source; this is the deliberate diversity tradeoff rather than a score rewrite. Exact, keyword-only, and REVIEW_HISTORY retrieval bypass this diversity step.

REVIEW_HISTORY exposes past revisions and Candidates for explicit inspection. Atomic compaction can retain a historical record without its original vector. If semantic or hybrid history is consequently incomplete, the result reports degradation=HISTORY_SEMANTIC_PARTIAL. When output also exceeds its result budget, budget.truncated=true preserves the independent truncation signal; an ordinary budget-only truncation reports BUDGET_EXCEEDED.

Storage and runtime compatibility​

FactLane uses a pinned mcp-memory-service backend for reusable SQLite/SQLite-vec mechanics, connection locking, bounded busy retries, WAL initialization, and connection-related primitives. FactLane owns higher-level schema/transaction and authority semantics. It does not assume a Python version proves SQLite feature support.

The linked SQLite runtime must be 3.42.0+. SQLiteVecEngine.open() rejects an older runtime before database creation or opening, with BACKEND_COMPATIBILITY_MISMATCH. The floor covers sqlite-vec's eligible-row IN behavior and the FTS5 secure-delete feature required by sensitive-memory recovery. That operator also performs an independent feature probe before mutation.

Embedding calls use an EmbeddingProvider contract. The currently shipped provider is Ollama over loopback HTTP; provider version, model family, capability, dimension, context, and input-size checks fail closed. Potentially blocking provider calls are offloaded from the asyncio event loop. No cloud embedding provider or automatic external fallback is shipped. See the environment policy for built-in profiles and exact prerequisites.

Vector-space compatibility treats semantic identity separately from runtime provenance. Semantic identity binds model identity/family, source and output dimensions, document/query prefixes, normalization, distance metric, projection revision, and FactLane's embedding-compatibility revision. Observed Ollama version and model digest remain runtime provenance; they are recorded on the binding and the per-record digest is preserved rather than retroactively rewritten. A runtime change may therefore be accepted only when the semantic identity still matches and a qualified, integrity-bound cross-space anchor proves direct old-vector/new-vector compatibility.

For the packaged embeddinggemma-300m-768 legacy compatibility path, a successful proof performs a metadata-only migration: existing vectors and adapter-record embedding provenance remain byte-for-byte and value-for-value unchanged, while revisioned compatibility metadata and the stale-writer fence are committed atomically. Missing, unknown, mixed, or incompatible legacy identity remains UNPROVEN/INCOMPATIBLE: memory_get, EXACT, KEYWORD, and read-only status remain available, but SEMANTIC, HYBRID, writes, and vector-mutating maintenance fail closed. FactLane does not apply an automatic rotation/projection repair and does not automatically re-embed durable facts; re-embedding is a separate explicit maintenance/migration boundary.

Maintenance and incident recovery​

memory_status provides bounded, read-only capacity and retention observations. Manual housekeeping compacts eligible superseded material through an atomic path while preserving current authority and logical history. It is not an automatic retention daemon, full backup facility, or sensitive-content erase operation.

Sensitive-memory incident recovery lives in a trusted local operator, outside MemoryGateway and the five MCP tools. It requires explicit authorization, exact target/database binding, maintenance quiescence, known schema and propagation, supported SQLite and verified FTS5 capabilities. A pre-commit failure rolls back; post-commit sealing failure leaves a durable database-resident recovery interlock that blocks ordinary runtime startup across process restarts until verified recovery completes. Local purge does not prove erasure from external copies or physical media. See Security.

Runtime/recovery exclusion is cooperative and process-independent on supported POSIX hosts: ordinary SQLiteVecEngine instances resolve their database path once, acquire a shared advisory flock on that database inode before backend initialization, and retain it until backend closure is proven. Recovery acquires the corresponding exclusive inode lock before its first quiescence check. During sealing it also locks the sanitized replacement inode before os.replace(), then retains both the retired old-inode lock and the promoted new-inode lock through the operator-owned postflight. Hard-link aliases therefore converge on the same kernel lock identity, and promotion never exposes an unlocked replacement inode. A new runtime attach during recovery receives MAINTENANCE_IN_PROGRESS. The operator's own postflight engine uses an internal, exact-inode capability derived from the still-live exclusive lease.

If postflight cleanup cannot prove its SQLite handle closed, including task cancellation, recovery keeps all process-owned exclusive inode leases retained fail-closed instead of reopening normal service. Process exit releases those descriptors; the sealing-incomplete state still requires operator reconciliation.

The exclusion guarantee is bounded to supported local POSIX filesystems with reliable flock semantics; sensitive-memory recovery maintenance remains unsupported on Windows and on unvalidated network/FUSE locking behavior. Native Windows x64/AMD64 is supported for normal import/startup, stdio MCP, SQLite WAL/busy/CAS, process concurrency, durability, and valid Windows paths. That normal-runtime support does not add a Windows sensitive-Recovery implementation or a Windows storage-migration maintenance claim: maintenance that depends on the POSIX fcntl/flock exclusion contract fails closed before mutation when that capability is unavailable. The recovery exclusion boundary is cooperative, not a defense against arbitrary raw filesystem replacement by a privileged external process, so the independent quiescence inventory/full-stop procedure is still part of recovery. No Windows ARM64 support claim is made.

Storage migration boundary​

The Python package/runtime and the durable database are related but distinct compatibility surfaces. Installing a newer package does not itself migrate a database, and successful package replacement does not prove that an older runtime can safely reopen state touched by a newer release. A release that changes stored schema or data semantics must provide an explicit migration contract, post-migration verification, and any supported rollback/restore path.

Ordinary service opens storage contract v3. An exact storage-v2 database is detected but not silently upgraded; normal startup fails closed with MIGRATION_REQUIRED. The explicit factlane-migrate-storage-v3 migrate operator requires an exact v2 database and lineage, creates and integrity-checks a pre-v3 backup, applies v3 schema/fences transactionally, then verifies the result as v3. Rollback of that migration is restoration of the verified pre-v3 backup through factlane-migrate-storage-v3 restore; package rollback alone is not a durable-data rollback path. Exact release identity and release-specific transition procedures live in Release operations.

Qualification boundary​

The supported local runtime boundary is Python 3.11+, linked SQLite 3.42.0+, SQLite/SQLite-vec, command-launched stdio MCP with exactly five public tools, and supported local Ollama embeddings. The normal runtime is qualified on native Windows x64/AMD64 as described above; sensitive-memory Recovery and storage-v2-to-v3 migration/restore remain POSIX-maintenance capabilities because they depend on the documented fcntl/flock exclusion contract.

Qualification covers default read-only authority, Candidate-only delegated contribution, verifier promotion, governed Owner lifecycle operations, WAL/busy handling, cross-process CAS/concurrency, fresh-process durability, backup/restore compatibility, configured host startup, production-derived retrieval, and fail-closed SQLite capacity behavior. It remains a bounded support statement rather than a claim about every client, filesystem, workload, or deployment scale.

That evidence does not establish support for every MCP client, arbitrary filesystem, production-scale ingestion pattern, unlimited-duration load, or every language mix. Source-diverse CURRENT semantic/hybrid selection reduces one known document-crowding mechanism, but semantic relevance — including Arabic/mixed-language ranking — remains workload-specific. FactLane is a fact store, not a transcript archive or raw document crawler.