GeezerVison is showing github.com — atlas staging tier: versioned schema, registry, aggregator with merge-on-close promotion into three-level core · Issue #5669 · developing-today/code
atlas staging tier: versioned schema, registry, aggregator with merge-on-close promotion into three-level core #5669DescriptionImplementation of §4 of the Scaler-era data architecture revision (design doc PR #5667, doc/2026-11-04T21-27-34Z_design_atlas_scaler_revision/).
Scope:
atlas_stage v1 schema DDL (items, chunks_raw, notes, kv, _schema_version) + one provisioning tool that creates a staging DB per work unit (queue task / session / epic / notes batch) and applies the schema.
- Registry (internal core tier): unit id → staging DB, owner, sensitivity level, state (open/closing/merged), schema version. (Design §6 proposes the registry be born as a TursoDB
--tursodb pilot DB once the account toggle is enabled — sequencing note, not a blocker for the libSQL version.)
- Aggregator (
fleet serve role, laptop): on unit close, embed new chunks with the resident Snowflake model, promote survivors into core in bounded batches (≤500 rows/txn), write the merge manifest (unit id, rows in/promoted, content hash), bump the core snapshot id per batch (consumed by the §3 result cache), branch the staging DB as archive, deregister. Partial periodic promotion for long-lived units (epics).
- Core stores per design: exactly three physical sensitivity levels (public / internal-default / secret — separate DBs + credentials); within a level, scan stores per corpus + one content store per level; reclassification = verified mechanical row move (counts + hash) with a manifest log entry.
- Session-close extraction hook as the canonical staging producer (sessions write staging only; core never sees session-rate writes).
Acceptance: an end-to-end demo unit (one session) flows staging → close → promotion → searchable in core with correct ceiling behavior per level; a reclassification move round-trips counts/hashes; promotion never holds a core writer > seconds (batch bound enforced); core DDL only via maintenance path. PBT/MBT per the testing doctrine (schema-version invariants, manifest hash oracle).
Design: #5667 §4 (+ §5 sizing, §6 pilot). Parent context: hatch-personal#21.
Acceptance criteria
-
atlas_stage v1 schema DDL exists (items, chunks_raw, notes, kv, _schema_version) and one provisioning tool creates a per-unit staging DB and applies it.
- Internal registry records unit id -> staging DB, owner, sensitivity level, state (open/closing/merged), and schema version, and is the lookup the aggregator uses.
- Aggregator promotion on unit close embeds new chunks, promotes survivors into core in bounded batches (<=500 rows/txn), writes a merge manifest (unit id, rows in/promoted, content hash), and bumps the core snapshot id per batch.
- Long-lived units (epics) get partial periodic promotion; closed units are branched as archive and deregistered.
- Behaviour matches design PR docs: Scaler-era Atlas/Turso data architecture revision #5667 section 4; deviations are recorded on this issue.
Activitydezren39 commented on Nov 4, 2026 Intake review
Intake by fleet monitor (repo-fleet-monitor), 2026-11-04 run. dezren39 commented on Nov 4, 2026 Drew approvals recorded (2026-11-04 ~17:10 CST):
- TursoDB preview pilot — APPROVED and executed. The turso CLI (v1.0.34) supports
db create --tursodb, so no dashboard toggle was needed. Two empty Turso-type pilot DBs now exist in group great-star-lord, labeled as pilots, no data migrated:
- Shared INTERNAL-tier embedding-cache DB — CONFIRMED by Drew ("yes, all of these things"), per revision §3.1. The pilot above is its first instance (TursoDB-type).
- Shadow-cost spike — TOP PRIORITY per Drew. Results are landing on dezren39/hatch-personal#20 and as a comment on PR docs: Scaler-era Atlas/Turso data architecture revision #5667 (headline: the 160,576 B/row is the index's honest fixed cost — 52× raw vector + 832 B — measured identical on fresh DBs; what production got wrong is the wedged/orphaned index state, not the size).
Engine note for this issue's staging design: production atlas is confirmed libSQL (sqld) by three independent signals (turso db show Type=SQLite + libsql:// URL + sqlite_version() 3.47.0, vs Type=Turso + turso:// + 3.50.4 on the pilots). TursoDB exists in this org only for DBs created with --tursodb. dezren39 commented on Nov 5, 2026 Core-tier shard restore — executed 2026-11-04 (per Drew's stop-and-redirect ruling, 18:24 CST)
The in-flight index rewrite was stopped (precondition verified here: laptop atlas-index-rewrite.service inactive; hosted shadow frozen at 28,760 across two reads ~5 min apart) and the corpus was restored into fresh shards. Production atlas was only ever read — untouched.
Engine + creation route (Drew ruling 18:28 CST: all new DBs are TursoDB)
- Standing creation route, identified from turso-cli source (
CreateDatabaseV3Body.use_tursodb) and verified empirically: POST https://api.turso.tech/v3/organizations/{org-UUID}/databases with {"name": ..., "group_id": ..., "use_tursodb": true}. The path org must be the org UUID — the slug returns "organization not found".
- Gate probe (
atlas-tursodb-probe, created via the API route): turso db show Type=Turso, sqlite_version() = 3.50.4 (libSQL = 3.47.0), F32_BLOB(768) accepted, vector_distance_cos scan top-10 identical to production on the same 200 real chunks.
- Scan path everywhere: plain SQL exact-cosine scan over
vec F32_BLOB(768), fan-out + merge. No libsql_vector_idx (TursoDB rejects the syntax; scan-over-shards is the design regardless). TursoDB's metric set for future corpora: cosine, dot product, L2, Jaccard — this corpus is cosine by design (source index metadata).
- Deviation recorded: FTS5 is unavailable on TursoDB ("Virtual tables are not supported in MVCC mode"), so the new scan stores carry no
chunks_fts. Keyword search stays on the libSQL monolith until the consumer work decides the FTS answer (see atlas core consumer wiring: fleet atlas-search fan-out over the TursoDB shard core (tier ceilings, merge, --expand hydration) #5755).
Shard map (tier → topic → shards; sessions atomic; ≤4,800 chunks/shard per §5.2)
Source: hosted atlas, 107,639 chunks = 107,639 vectors (all 3,072 B; 0 missing/orphan). Sensitivity → tier: secret-bearing → secret; personal + local-only → internal (default); public = none in this corpus.
| Shard(s) |
Chunks |
| atlas-core-internal-work-engineering-01..06 |
4,435 ×4, 4,434 ×2 |
| atlas-core-internal-personal-admin-01..04 |
4,360 ×3, 4,359 |
| atlas-core-internal-agent-tooling-01..04 |
3,866 ×4 |
| atlas-core-internal-models-and-plans-01..02 |
4,551 ×2 |
| atlas-core-internal-infra-nix-01..02 |
4,094 ×2 |
| atlas-core-internal-home-lab-01..02 |
4,070, 4,069 |
| atlas-core-internal-fleet-repos-01..03 |
3,458, 3,457 ×2 |
| atlas-core-internal-people-pets-01 |
4,502 |
| atlas-core-internal-security-01 |
3,489 |
| atlas-core-internal-media-01 |
1,607 |
| atlas-core-internal-cloudflare-01 |
1,250 |
| atlas-core-internal-misc-01 (finances+health+travel+unlabeled) |
841 |
| atlas-core-secret-main-01 |
638 |
Plus per-level content stores (§4.2): atlas-core-internal-content (sessions 18,235; messages 70,987) and atlas-core-secret-content (sessions 90; messages 564). (The content message load needed one idempotent resume: the first pass dropped at 84% on a transport disconnect — RemoteDisconnected escaping the HTTP client's retry filter — and a targeted second pass inserted only the missing ids to the exact counts above. Scan-shard loads were unaffected.) Every scan shard carries chunks + vec with DDL identical to source, plus an atlas_manifest self-description. Secret chunks exist only in the two secret DBs.
Verification (all independent of the loader's own counts)
- Per-shard chunk/vec counts == map expectations, 29/29 exact. Tier sums: internal 107,001, secret 638, total 107,639.
- Per-tier content-hash reconciliation: sorted-set SHA-256 of all content_hashes, source vs shards — internal MATCH, secret MATCH (no chunk lost, duplicated, or mis-tiered).
- Vector bytes: 60/60 random spot-checks byte-identical to source.
- Parity (held-out real queries, query chunk excluded): merged fan-out top-10 == production exact-scan top-10 on 5/5 internal queries and 2/2 secret queries (an early "False" on secret was a LIMIT artifact in the test harness — fan-out fetched top-10 including the excluded query row; corrected run: identical ids, identical order, max distance delta 8e-7).
- Latency (sandbox → us-east-1 HTTPS, network-inclusive, per-shard top-10 scan): 1.1–1.9 s at 3.5–4.5k rows — above the §5.2 libSQL-based budget; flagged for the consumer work (atlas core consumer wiring: fleet atlas-search fan-out over the TursoDB shard core (tier ceilings, merge, --expand hydration) #5755: re-measure from the laptop path; §5.5 replicas are the lever).
Corrections to the restore packet's premises (verified, second-sourced)
- The laptop local DB contributes zero chunks: its chunk content-hash set is identical to hosted (same sorted-set SHA-256). The "2,226 local-only + 90 secret-bearing laptop chunks" were hosted session counts; at chunk level everything already lived in the hosted source of record (6,941 local-only + 638 secret-bearing chunks, all restored above). The laptop DB holds no vectors/labels; its extra messages belong to unchunked sessions and are referenced by no chunk.
Leftovers
developing-today commented on Nov 5, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 17, 2026
🤖 Agent note · picked up (resume)
dezren39 commented on Nov 17, 2026
🤖 Agent note · parked
- Agent: repo-worker-code, lane code-i; task 19870
- PR: Add Atlas staging merge manifests #11317 is OPEN, mergeable, CodeRabbit SUCCESS; no review decision or merge SHA.
- Resume condition: review/merge state changes. Inspect PR fresh; do not reimplement.
dezren39 commented on Nov 17, 2026
🤖 Agent note · parked (acceptance gap identified)
- Agent: repo-worker-code, lane code-i (OpenChamber scheduled lane); task 19870.
- PR: Add Atlas staging merge manifests #11317 is OPEN,
MERGEABLE/CLEAN, only check CodeRabbit SUCCESS; no GitHub Actions runs on the branch; no review decision, no merge SHA. Diff is pkgs/atlas-search/crates/atlas-core/src/stage.rs (+207/−3) and pkgs/atlas-search/schema/stage_registry_v1.sql (+11).
- Local verification (
cd pkgs/atlas-search && cargo test -p atlas-core): all suites pass — 137 lib tests plus the integration suites, 0 failures.
- Acceptance gap (why this was not merged): the task's acceptance bullet 4 and the issue's criterion 4 require that, after a successful promotion, the unit is deregistered from the active registry and its staging DB is branched/retained as archive, with the manifest still retrievable. The PR writes
merge_manifests and moves staging_units.state to merged in one transaction, and merge_manifest() reads the record back — but it implements no archive branch and no deregistration; the unit stays in staging_units and the staging DB is not branched. Design §4.1 is explicit: manifest, then branch the staging DB as archive, then drop it from the active registry.
- Not reimplemented: the retained implementation is correct for the manifest half and the worktree is clean; this is a scope decision for follow-up, not a rewrite.
- Resume brief: either (a) extend the promotion path with the archive-branch + deregistration step and its tests (
promoted unit is no longer returned as an active registry entry while its manifest persists), or (b) get owner disposition that a retained merged registry row plus an intact staging DB satisfies "archived/deregistered" for this slice. Parked ~20 minutes pending that.
dezren39 commented on Nov 17, 2026 Slice 2 (merge manifest + promotion close-out) is on PR #11317 at 753d700. Parked while CodeRabbit runs. dezren39 commented on Nov 17, 2026 agent-note:v1
kind: done
task: 19870 (repo-worker-code, openchamber-scheduled-lane any-o)
outcome: pr_opened — PR #11317 carries the merge manifest and the promotion close-out (archive via VACUUM INTO to .archive, unit moved to merged and out of active states). Head 753d700. cargo test -p atlas-core passes (138 unit + integration suites). Not merged; left for owner review.
follow-up (minor, not blocking): branch_staging_db_as_archive docs say the previous archive is replaced only after the new snapshot is written, but the code removes the old archive before writing. Doc and code need reconciling in a follow-up.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|