Short answer: keep every document revision immutable, attach an explicit release scope to each chunk, and filter retrieval to the caller's target version before reranking. For a logistics SaaS, that rule matters more than the choice of vector index: a semantically similar answer from last quarter can create a wrong delivery promise.
The decision note
| Approach | Freshness behavior | Operational burden | Best fit |
|---|---|---|---|
| Replace chunks in place | Fast updates, weak history | Low | Disposable prototypes |
| Append immutable revisions | Exact replay and rollback | Medium | Internal engineering docs |
| Keep a lexical and vector index per release | Strong isolation | High | Regulated or long-lived releases |
I would start with immutable revisions plus metadata filters. It lets a one-person team ship weekly while preserving the evidence behind an answer. The trade-off is storage and index work: every edit creates new vectors, and a reindex job must eventually retire revisions that policy allows you to delete.
What should retrieval architecture do with versioned internal engineering documentation?
Treat a document identity and a document revision as different keys. The identity is stable (carrier-rate-limit); the revision includes the source commit, effective time, and release (2026-08-14, v3). A chunk inherits both values. Never infer version from text such as “latest.” Text drifts; metadata can be tested.
For each query, resolve the target release first. A production incident may need the deployed release, while a planning question needs the next release branch. Pass that scope into both lexical and vector retrieval, then rerank only candidates inside it. If no scope is supplied, choose a documented default and show it in the citation. Silent “latest” behavior is how stale runbooks sneak into an on-call answer. Make the scope visible in logs, too: when a support ticket arrives three weeks later, I want to replay the exact filter, candidate set, and citation instead of guessing which branch the bot saw.
I once assumed a nightly embedding job would make freshness automatic. It did not. A carrier policy changed at 09:10, the markdown changed at 09:12, and the index still surfaced the old chunk at lunch because the ingestion queue had no revision watermark. The fix was small: store source_hash, observed_at, and indexed_at, reject an update that moves the hash backward, and alert when the age delta crosses our service objective. That timestamp trio now travels with every citation.
A small ingestion contract that survives edits
The contract can stay boring. Boring is good when you own support.
type DocRevision = {
docId: string;
revisionId: string;
release: string;
sourceHash: string;
effectiveAt: string;
observedAt: string;
status: "draft" | "published" | "retired";
};
type Chunk = DocRevision & {
chunkId: string;
ordinal: number;
text: string;
};
function shouldIndex(next: DocRevision, current?: DocRevision): boolean {
return !current || next.sourceHash !== current.sourceHash;
}
Chunk boundaries should follow meaning: a carrier cutoff rule and its exception belong together. Keep a stable chunkId derived from revision and ordinal, not from an array position that changes after a heading is inserted. During deployment, publish the revision record before vectors; the query layer can then return “no indexed evidence yet” instead of mixing releases.
Track three clocks: source observation, successful indexing, and publication. Report p50 and p95 lag by repository and release. Also run a canary query for each changed page; the expected revision must appear, and a retired revision must not. This catches filters that compile but are never applied.
Track three clocks: source observation, successful indexing, and publication. Report p50 and p95 lag by repository and release. Also run a canary query for each changed page; the expected revision must appear, and a retired revision must not. This catches filters that compile but are never applied.
Freshness has a cost. Aggressive re-embedding burns compute and can increase latency during a release train. A two-stage path helps: lexical search finds exact identifiers such as RTE-204, vector search handles paraphrases, and reranking keeps the candidate set small. Your mileage may vary; the right lag target depends on how quickly a wrong answer can affect a shipment.
Latency is a budget, not a badge.
When is a simpler design the better choice?
In-place replacement is reasonable for a throwaway sandbox, a corpus with no rollback requirement, or docs whose consumers always read the source page directly. It is not suitable when incident review must reproduce an answer, when releases coexist, or when a deleted policy must stay excluded. Stick with immutable revisions until those requirements disappear; move to per-release indexes only when isolation outweighs the extra deployment and storage machinery.
The point is not a fashionable database. It is a testable contract between source control, ingestion, retrieval, and citations. That contract buys me revenue per hour: fewer emergency explanations, less bespoke cleanup, and more time to ship the next logistics feature.
Rollback deserves the same discipline as rollout. Keep the previous revision queryable, mark the new one as published only after its canary passes, and record the release pointer in the deploy event. If a parser change produces odd chunks, move the pointer back; do not mutate old vectors while an incident is active. That gives a small team a clear recovery step and an audit trail that explains why an answer changed. It also keeps cleanup asynchronous, so a rollback does not wait for a full re-embedding cycle.
Top comments (0)