Skip to content

Latest commit

 

History

History
111 lines (98 loc) · 7.65 KB

architecture.md

File metadata and controls

111 lines (98 loc) · 7.65 KB

Architecture

The substrate is the asset; the model is an interchangeable client. Everything below follows from taking that sentence seriously: if memory is infrastructure, it deserves the rigor of infrastructure: retrieval quality, versioning, deletion, security, and one access boundary.

                        ┌───────────────────────────────────────────────┐
 ingested content  ──►  │  DUAL REPRESENTATION                          │
 (docs, decisions,      │   embeddings (fuzzy recall) ·                 │
  session notes)        │   entity/relation graph (explicit structure)  │
                        └───────────────┬───────────────────────────────┘
                                        │
                        ┌───────────────▼───────────────────────────────┐
                        │  STORE (system of record)                     │◄─┐
                        │   supersede · as-of reads                     │  │
                        │   purge (vectors included)                    │  │
                        │   append-only audit the database enforces     │  │
                        └───────────────┬───────────────────────────────┘  │
                                        │                                  │
                        ┌───────────────▼───────────────────────────────┐  │
 query ───────────────► │  RETRIEVAL PIPELINE                           │  │
                        │   hybrid (vector+full-text, tunable blend)    │  │
                        │   → multi-query fusion (RRF)                  │  │
                        │   → cross-encoder rerank                      │  │
                        │   → entity-anchored partition (graph)         │  │
                        │   → per-consumer profiles                     │  │
                        └───────────────┬───────────────────────────────┘  │
        ┌───────────────┐               │                                  │
        │ EVAL GATE     │◄──────────────┤  changes beat baseline.lock      │
        │ golden set    │               │  or they don't ship              │
        └───────────────┘               │                                  │
                        ┌───────────────▼───────────────────────────────┐  │
 any agent, any model ► │  GATEWAY (MCP): read tools only,              │  │
                        │  per-caller scoping at the boundary           │  │
                        └───────────────┬───────────────────────────────┘  │
                                        │  query log (gap detection)       │
                        ┌───────────────▼───────────────────────────────┐  │
                        │  RESEARCH LOOP (operator-run)                 │  │
                        │  gap → search → cite → write back             │  │
                        │  quarantined until vet() promotes it          ├──┘
                        └───────────────────────────────────────────────┘
   PORTABILITY: every external call (LLM · search · rerank · embeddings)
   behind an adapter. The embedder is pinned per corpus, deliberately.

Why each layer exists

Dual representation (src/acs/ingest/). Vector search answers "what is like this?"; the graph answers "what relates to this, and how?". "CHG-4568 supersedes CHG-4561" is not a similarity question: no embedding distance encodes it. Both representations grow from the same content in the same transaction, and entity resolution keeps the graph from fragmenting into near-duplicate nodes.

The graph is not only a second thing to query. It feeds back into the first: the last retrieval stage asks it which candidates are bound to the entity the query names, and reorders on the answer (ADR-007). That is the dual representation earning its keep twice.

Retrieval pipeline (src/acs/retrieval/). The standard retrieval shape: retrieve wide and cheap, fuse, rerank narrow and expensive, then let the graph correct the one thing a topical reranker is structurally bad at, which is telling two similarly-worded entities apart. It's composed of small stages because small stages are individually testable, individually swappable, and individually blameable when the benchmark moves. Per-consumer profiles are data, not code; a new consumer is a config entry.

Eval gate (eval/). Retrieval "improvements" that were never measured are guesses. A golden set over the seeded corpus, recall@k and MRR per ablation stage, a locked baseline, and CI that fails below it. All published numbers are ablation deltas on the synthetic corpus. Deltas are honest; absolute quality claims from synthetic data would not be.

Versioning + deletion (src/acs/store/). Memory is a system of record: superseded, never overwritten; readable as-of any past moment; and genuinely deletable: a purge removes the embeddings too, behind an append-only audit that the database itself refuses to mutate. This layer is most of the distance between "a RAG demo" and "infrastructure."

Gateway (src/acs/gateway/). One door, MCP-shaped, read-only (by tool surface and by database role), with per-caller scoping enforced at the boundary. This is the thesis made literal: models are interchangeable because they all reach memory the same way.

Research loop (src/acs/research/). The substrate can only serve what was written down; the loop finds where retrieval runs thin and fills the gap: cited, quarantined, and treating everything it fetches as data, never instructions.

Scale paths (named, not hidden)

Deliberate scope cuts, with the production move for each:

  • Exact vector search → an ANN index (HNSW/IVFFlat) once the corpus is large enough that exact scan hurts; at reference scale a tuned index would be decoration. (That move also types the vector column to a fixed dimension, a natural companion to the re-index that any embedder rotation already is.)
  • Paragraph chunking → semantic/recursive chunking when document structure gets messy.
  • Rule-based extraction → a model-backed extractor behind a new seam, once fuzzier extraction is worth its nondeterminism. The LLM interface in adapters/base.py deliberately offers query rephrasing and nothing else, because nothing in the reference consumes free-form generation, so this is an interface to add rather than an implementation to swap.
  • Name/alias entity resolution → embedding-based clustering for harder merge decisions.
  • Demo token registry → a secret store behind the same resolve_scope boundary.