{/* Generated from dreamdb-core spec snapshot c63af5f16bfa1ce0c6a7cf8c58d3dfc1c5bf7022 by scripts/sync-spec-docs.mjs — do not edit. */}
# 0030 — Continuous indexed ingest and bounded maintenance

Status: **Initial #404 contract: indexed checkpoints (§6–7) and spatial path-copy
append.** The broader cost targets in §2 are not guarantees of existing payload
compaction or every index family. Builds on 0029 without broadening its base-only API.
Semantic search is the first implementation target. Lexical replacement #397
is not included implicitly.

## 1. Invariants

A dataset need not finish ingesting. A successful indexed publication names a
consistent snapshot: its vector Track, routing index, compressor/embedding
identity, exact-vector sources and any hot overlay agree. Readers pin that
snapshot for the duration of a query. Maintenance MUST NOT invalidate it.

Raw-media arrival and embedding publication are separate commits today. A raw
append MUST NOT be reported as searchable until its vectors are published.
Index lag MUST be represented by a source-bound application receipt/cursor, not
inferred from coverage end or count (gaps and out-of-order arrivals exist).
This draft does not invent an automatic embedding worker inside DreamDB.

Checkpoint MUST preserve current data and supported query capability; it MUST
NOT remove a runtime-required parent, lower rerank capability, substitute an
arbitrary source version, or flatten an unknown relation. Historical retention
and semantic lineage are distinct from dependencies used to read current data.
The existing edge form does not fully separate these meanings: until a safe
representation/transform is specified, refusal is required.

## 2. Cost model and budgets

Let N be live payload size, B live bucket descriptors, H version-history nodes
in the current container, D live runtime dependencies, Delta changed descriptors,
C touched cells, F active fields, and P index-directory page fanout.

Report separately:

- GET/HEAD/LIST/PUT count and bytes (metadata versus payload), cold and warm;
- peak memory including encoded output, in-flight requests and connector buffering;
- CAS retries, abandoned writes, elapsed time and concurrent query/append latency;
- active-container size, archive growth and total retained objects/bytes.

Targets, not current guarantees:

1. Metadata checkpoint: no bucket/vector/media payload GET or rewrite; no bucket
   LIST; no traversal of archived epochs. Work may inspect the current bounded
   container O(F + H + D). Any complete Track read proportional to B MUST be
   disclosed, budgeted and removed from the large-scale hot path before claiming
   delta-scalability. Payload integrity scanning is a separate operation.
2. Vector append: encode new vectors only; update the touched directory paths,
   targeting O(C log_P B + Delta) metadata work (shared paths counted once),
   rather than decode/sort/rewrite B descriptors each batch. Bounded batching
   balances request overhead with memory and publication latency.
3. Query: route to selected cells and bounded directory paths; do not scan an
   unbounded list of recent runs/deltas. Small maintenance writes must not cause
   unbounded query fanout.
4. Compaction: explicit bounded cells, input bytes, output bytes, requests and
   memory per task. It may read/rewrite selected payloads, never be smuggled into
   a metadata-only checkpoint. Oversize tasks return a resumable plan or an
   explicit refusal; no unlimited work hidden behind a threshold.

Each operation declares planned known costs and unknowns before mutation. A
budget exhausted before work completes leaves the old Ref readable. Timeouts
cannot promise no in-flight writes; such writes must remain unreachable until
the ordinary durability barrier and CAS succeed.

## 3. Publication and concurrency

Reuse 0029 frozen candidate, durable plan, archive tag and exact-target recovery.
Do not introduce another publisher. One Ref CAS is the linearization point;
readers see the complete old or complete new snapshot, not a mixture.

A background task operates on a pinned source. Initial implementation fails on
CAS conflict and retries only under an explicit retry/time/byte budget. Reusing
already content-addressed outputs is possible; merging a stale plan into a new
tip is NOT automatically safe. Any future disjoint-cell rebase must compare the
exact read set and model/Schema identity. Never regenerate expensive payloads
silently until CAS happens to succeed. A shared Ref is still a serialization
point; this proposal makes no linear multiwriter throughput promise.

No maintenance process is required for reading a published snapshot. A caller
or external scheduler may execute bounded tasks. Persistent distributed leases,
a cluster service and a second transaction system are not prerequisites.

## 4. Archive and capacity boundaries

Keeping all archive tags retains all prior epochs and their reachable objects.
Checkpoint alone does not bound total storage, tag count, or future GC work.
Retention policy, legal holds, active-reader protection and an incremental GC
root/reachability strategy must precede automated deletion; none is authorized
by this draft. Do not run a full-root mark sweep on every checkpoint.

The 1 MiB lineage-container cap remains unchanged. If indispensable live
dependencies alone exceed it, report the irreducible size and refuse. Paged
lineage would require its own versioned protocol, authenticated reachability,
reader/writer/GC support and migration; it is not implemented by ignoring the
cap or declaring all parents historical.

## 5. First admission target and gates

Target #400's actual configuration: IVF-cosine, compressed bucket records,
`rerank=true` with per-bucket VectorStorage, frame embeddings derived from a
VideoItem field. Preserve SI, compressor, embedding identity, sidecars and
existing layer declaration. Do not infer exact support from Schema alone.

Graph exact rerank uses a retained same-field raw source; generic same-field
edge deletion is forbidden. Hot overlays, graph freshness, tombstones, entity
indexes, encrypted forms and unknown extensions remain rejected until their
own runtime dependency contracts are handled. Rejecting one family must not be
presented as support for continuous indexed ingest in general.

Minimum direct acceptance: multiple append/index/query/checkpoint epochs using
public APIs, with anchors/scores and supported exact reads preserved, then a
further append and query. At a fixed changed-cell set, increase untouched bucket
metadata and measure directory I/O; no whole-Track rewrite claim without this
check. Use existing test/connectors/testbox, not a new evidence framework.

## 6. Indexed epochs: explicit origin claims

The existing format cannot both discard intermediate versions and preserve a
layer's ancestor declaration without inventing a new immediate derivation.
Indexed epochs therefore use a distinct CLOSED container `lineage-v5`:

```
{ form: "lineage-v5", active: [...], lineage: [...], edges: [...],
  origins: [{ child: BindingVersionRef, ancestor: BindingVersionRef }, ...] }
```

`edges` retain their existing exact-parent meaning. An `origins` record instead
declares that the exact ancestor binding is the structural origin of the child;
it explicitly does NOT claim an immediate computation or an exact rerank input.
The binding identities include timeline, field, modality and address. The same
child MUST NOT have both a derivation edge and an origin claim. Origin records
are strictly sorted by child then ancestor; endpoints must exist exactly once,
be distinct and share a timeline. A claimed child's role must be exactly
`layer-of:<ancestor-address>`. The combined relation is acyclic and determines
retained closure and role ancestry; origin claims themselves are NOT exposed as
exact-parent edges. GC/copy retain the ordinary `active ∪ lineage` bindings and
their objects, without visiting archived epochs to read the current snapshot.

The wire form is the compatibility boundary: old readers/writers reject v5,
never silently downgrade it. Initial v5 supports ordinary single-parent
append/compact/preservation. Backfill/entity-key form combinations and graph-merging
are explicitly refused until their combined semantics are specified. Pointer-only
fast-forward to an existing descendant does not combine graphs and is unchanged. Existing
v1/v2/v4 behavior is unchanged. This opt-in compatibility cost must be visible
in the checkpoint plan/SDK documentation.

The first indexed planner admits plain v1/v5 with base scalar/VideoItem and
IVF-cosine bucketed embeddings only; graph, hot overlays, text indexes and
unclassified metadata remain refused. It validates the hash-bound current
container, follows only its in-memory relation, and retains active bindings
verbatim. A layered embedding must reach its exact role-named base VideoItem
binding through same-field/same-modality vector supersessions, then its original
cross-field layer relation (or a previously validated origin claim). Checkpoint
copies that exact source binding and emits an origin claim, not a shortened
derivation edge. Required source versions remain retained even when no longer
active. Source field identity is never guessed from an address alone.

Old intermediate version edges stay in the tagged source epoch. The new root
has no Manifest parents; it carries no runtime reference to that archive, so
repeated checkpoints do not recursively reopen historical epochs. Ordinary
append thereafter records immediate version edges within the new epoch and
preserves the origin claim at its root. A later checkpoint resolves that claim
in the current container and emits the same origin identity for the new active
binding. Active role, Track addresses, coverage, registry and Schema do not
change. Retained origins are bounded by the active layer set, not ingest age.

The indexed operation reuses 0029's frozen bytes, durable plan, archive tag,
flush and CAS. It has a distinct `ingest-checkpoint/2` plan discriminator;
`/1` and the existing base-only planning API retain their restricted admission.
Apply reconstructs the selected transform from the pinned source and compares
exact bytes, including origins. A forged saved plan cannot invent a source.

Admission verifies bounded active/root metadata, not every bucket/sidecar.
Unchanged Track/index references preserve whatever exact data actually exists;
this is not a new integrity certification for imported or previously broken
data and does not turn a Schema rerank flag into proof of available vectors.
No whole-directory or vector scan is implicit in an indexed checkpoint.

## 7. Initial implementation and limits

Rust/Python expose `plan_indexed_ingest_checkpoint(storage_scope, archive_tag)`;
the saved bytes use the existing `apply_ingest_checkpoint` executor. All consumers
of the resulting Ref must support v5 before opting in. This operation does not
upgrade installed packages or switch a production Ref on its own.

Each retained/active Track root is admitted with HEAD, then a hash-verified exact
range GET. A root is limited to 4 MiB and their aggregate to 32 MiB per pass.
Missing lengths, excess budgets and unclassified storage fail before mutation.
These are byte limits, not claims that inline metadata is independent of B:
an inline root still costs O(B) up to its cap. New paged spatial directories use
small roots; checkpoint does not fetch their pages, SI/VC objects or sidecars.
Apply repeats admission against the pinned source before its durability barrier.

Spatial append uses existing IndexPage encodings, spatial-key ordering and
path-copy updates. Old time-partitioned directories whose spatial bounds overlap
out of order are readable but explicitly refused by path-copy append. Conversion
would require an explicitly budgeted O(B) metadata operation; it is not silently
attempted by this API. Oversized imported inline roots are likewise refused.

Existing `compact` is not a delta-bounded metadata operation: it still enumerates
the directory and builds the replacement directory. Its output remains paged,
and v5 origins survive it, but no new full-corpus compaction performance claim is
made. Checkpoint never invokes it. Selected-cell payload work, fragmentation,
reclustering, archive retention and total-storage growth remain separate costs.
