How Incremental Projection Lets Vector, Keyword, and Graph Evolve Independently

Layered hashes, a delta planner, consumer cursors, and shadow projections together handle updates, failure recovery, and rollback.

On this page · 11 sections

Once an enterprise corpus reaches several hundred thousand chunks, “re-chunk, re-embed, and rebuild vector and graph in full every day” stops being merely slow. It also widens the blast radius: a failure in any stage leaves every store waiting, and it becomes hard to say how far deletes and retries actually got.

The current V3 fast lane in mt_rag uses event-driven incremental projection, that is, only what changed is pushed to each store as events:

  • Source changes first enter a durable journal.
  • Vector and graph produce independent deltas.
  • Qdrant, pgvector, and Neo4j each maintain their own consumer state.

Milvus currently produces only a dry-run report. It performs no real writes and does not advance a cursor. zvec still belongs to a separate build/comparison path. A failure blocks only the affected consumer; no other storage path gets to declare completion on its behalf.

The Short Version

  • A daily full rebuild is not just slow; it widens the blast radius. The V3 fast lane instead puts source changes into a durable journal first, and vector and graph each produce their own deltas.
  • Each destination maintains its own cursor: it advances only when the whole batch succeeds and the run is not a dry run, and a failure blocks only the affected consumer.
  • Deletes are more dangerous than inserts: the delete safety policy blocks mass deletes by default, and only an explicit override can bypass it.
  • Acceptance cannot be judged by exit code alone: only applied_valid sets applied=true.

Knowledge Map for This Article

Knowledge map of incremental projection: Source Pull flows through the Source Event Journal and projector into separate vector and graph delta journals, and each consumer cursor advances independently before delta validation; open the full-size SVG

The core concepts are the durable journal, at-least-once consumers, stable event identity, tombstones, independent cursors, projection validation, and the rollback boundary.

An Event Is a Fact About a Change, Not a Script Log

There are currently three kinds of events. Look at which fields give each one its identity:

Stream Operation Key identity
Source upsert / delete Source type, entity type/ID, revision, content/payload hash
Vector upsert_vector / upsert_payload / delete_point Stable point ID, embedding key, payload hash, source event ID
Graph Node/edge upsert/delete Stable item/edge ID, props hash, source event ID

Vector changes are classified further:

  • Only a change in the text hash or embedding key produces upsert_vector.
  • A metadata-only change uses upsert_payload.
  • An identical record produces no event at all.

A changed page timestamp or repository metadata therefore does not necessarily force an embedding to be recomputed.

A derived event ID is bound to the durable source_event_id, not to a transient projection run ID. When the same pending source event is replayed in a new run after a crash, the vector and graph events deduplicate. A genuinely new revision later on is still a different event, even if its content happens to return to an old value.

Why Code Projection Is Frozen Before Canonical State Is Promoted

Incremental code processing cannot read directly from a working tree that is still changing. The current flow computes the changed files from the durable previous revision and the current commit, and reads content from the recorded commit with git show <revision>:<path>.

build-code-projection first writes a content-addressed immutable artifact containing the rows needed for changed-file symbols, contracts, vectors, and graph. Only after that artifact is verified as complete does the flow promote canonical symbol state and write an applied marker. Once Neo4j has applied the events and graph lag is zero, it writes a separate graph-validated.json for that projection.

Code projection sequence: write and verify the immutable projection, promote Canonical SQLite transactionally, then send graph events to Neo4j and write the graph-validated marker when lag=0; open the full-size SVG

Wherever the process crashes, the next run replays the same artifact instead of reinterpreting a mutable working tree. Only when Git has already garbage-collected the old commit does the flow fall back to the full current tree, emitting tombstones, that is, delete markers, for canonical rows that no longer exist.

The Fast Lane and the Rich Lane Solve Different Kinds of Freshness

The daily fast lane handles only source events, code projection, source vector deltas, and source graph deltas. It generates bounded parent/child vectors for Jira, Confluence, attachments, repositories, and DDB, and generates vectors plus call/GraphQL/REST graph edges for changed symbols.

Only the rich lane runs the catalog, semantic enrichment, hierarchical chunking, the domain/impact/interface packs, and the full vector export.

The current rich parent/child export is on the order of ten gigabytes. In existing local runs, both hierarchical chunking and the full vector export take minutes, and the latter has been killed by the operating system several minutes in. The rich lane is therefore a maintenance task, not a daily freshness gate.

This trade-off means that “one symbol changed today” does not require rebuilding the whole enterprise corpus. It also admits a limitation: some aggregate transforms are not yet incremental at the entity level, so the global view in the rich projection may lag behind the fast lane.

A Cursor Is Each Destination's Own Proof of Completion

Each consumer reads a contiguous batch of events from its own cursor, that is, the event position it has processed up to:

  1. The cursor advances to through_sequence only when the whole batch succeeds and the run is not a dry run.
  2. An exception, a partial apply, a dry run, or a missing embedding never advances it.
  3. A failure records the event sequence, event ID, run ID, and error.
  4. The next attempt retries from the same cursor.
  5. Stores use stable IDs and idempotent upserts/deletes (that is, repeating them gives the same result), so operations that were written successfully but whose cursor was never committed can be replayed safely.

The vector stream also enforces ordering: a pending_embedding or missing_vector event blocks later events from being returned past it to the same consumer, which prevents the cursor from skipping over a vector that is not ready. Tombstones need no embedding and can enter the ready stream directly.

Deletes Are More Dangerous Than Inserts

The most dangerous bug in an incremental system is not a missing point. It is mistaking an incomplete source pull for a mass deletion. The current delete safety policy blocks by default when:

  • the delete count exceeds 1000; or
  • the previous scope has at least 20 entries and the delete ratio exceeds 25%.

A missing vector export input blocks tombstone computation; an empty graph input blocks graph deletes. Only an explicit recovery/large-delete override can bypass this, and only after source completeness has been checked by a human.

File add, modify, rename, and delete each produce explicit symbol and edge actions. Only an authoritative repository delete event may delete every row a repository owns. A repository that fails to appear in a partial discovery is never evidence of deletion.

Acceptance Cannot Be Judged by Exit Code Alone

Delta validation distinguishes five states:

  • blocked: a required artifact is missing, or embedding is blocked;
  • partial: an adapter report is missing, apply modes are mixed, or lag remains;
  • delta_valid: the delta is valid, but no adapter was requested;
  • dry_run_valid: every requested adapter's dry run is valid;
  • applied_valid: every requested adapter actually applied successfully and cursor lag is zero.

Only applied_valid sets applied=true. A process that exited without error, a finished source pull, or an updated Qdrant cannot prove completion on behalf of the Neo4j cursor.

Failure Modes and Trade-offs

Each row is one failure point: the middle column shows how the cursor replays, and the right column shows what that costs.

Failure point Cursor/replay behavior Trade-off
Store write succeeds, crash before cursor commit Replay stable-ID upserts/deletes Depends on idempotent destination operations
Missing embedding Blocks the vector stream; nothing passes that sequence Later ready events also wait, preserving order
Neo4j fails Graph cursor stays put; vector consumers can continue Stores are briefly at different versions, which the query gate must make visible
Source run has no changes No derived work is produced, but old backlog can still be consumed The journal becomes a retry queue; looking only at the latest run file is not enough
Mass tombstones Rejected by default; requires an explicit override A genuinely large delete needs a maintenance window
Rich projection is too heavy Daily runs use only the fast lane Aggregate/domain views converge more slowly

Verifiable Project Evidence

  • src/mt_rag/refresh/contracts.py: source/vector/graph events and stable identity.
  • src/mt_rag/refresh/journal.py: the SQLite journal, readiness, checkpoints, failures, and lag.
  • src/mt_rag/refresh/consumer.py: success-only cursor advance.
  • src/mt_rag/refresh/delta.py: vector change classification and delete safety.
  • src/mt_rag/refresh/code_projection.py: content-addressed projection and the applied/graph-validated markers.
  • src/mt_rag/refresh/source_vectors.py and source_graphs.py: fast-lane projection.
  • docs/03-reference/incremental-refresh-v3-event-design.md: the full transaction, consumer, and staged-enablement contract.

References

The real completion condition for incremental projection is not “this pipeline run finished.” It is that every enabled consumer can independently replay and validate from the same change facts, and state exactly how much lag it still has.

Related notes

  • 8 min readWriting

    Why a Local Immutable CAS Holds the Evidence Foundation

    Vector stores and graph databases are rebuildable projections; the CAS stores raw data, IR, and the CPG, and a Manifest Generation references those immutable objects.

  • 13 min readWriting

    LLM Runtime: Which Layer Should Own Rate Limits, Retries, and Routing

    Once the second business, the second provider, and the second tenant show up, calling the SDK directly is no longer enough. This piece covers the responsibility boundary of an LLM Runtime, multi-model routing, reliability under high concurrency, and how to choose an observability approach.

Working on something similar?

I'm always happy to compare notes on distributed systems, delivery, and applied AI.

[email protected]