From d57bbb361c8b3b9768e93ed7458b42463acb60e9 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 12:02:19 -0600 Subject: [PATCH 1/3] atlas: report the AMD corpus census by store role --- .../book/operations/backup-and-census.md | 32 +-- pkgs/atlas-search/book/operations/faq.md | 2 +- pkgs/atlas-search/tools/atlas_census.py | 226 ++++++++++++++++++ .../tools/tests/test_atlas_census.py | 131 ++++++++++ 4 files changed, 376 insertions(+), 15 deletions(-) create mode 100644 pkgs/atlas-search/tools/atlas_census.py create mode 100644 pkgs/atlas-search/tools/tests/test_atlas_census.py diff --git a/pkgs/atlas-search/book/operations/backup-and-census.md b/pkgs/atlas-search/book/operations/backup-and-census.md index 7b33d8032d..54218441bd 100644 --- a/pkgs/atlas-search/book/operations/backup-and-census.md +++ b/pkgs/atlas-search/book/operations/backup-and-census.md @@ -2,7 +2,7 @@ Source: `nixos/home/laptop-backups.nix` and `nixos/home/atlas-backup.sh`, the schedule registry row in `doc/fleet-schedule-registry.md`, and the census statement in the Atlas program investigation record `doc/2026-11-23T12-06-51Z_design_atlas_program_investigation/` under https://github.com/developing-today/code/blob/main/nixos/home/laptop-backups.nix — provenance only; this chapter is complete without following it. -Two different questions get confused under the word "backup": is the corpus recoverable if the laptop store is lost, and how big is the corpus right now? The first has a landed, scheduled answer. The second has a frozen answer from 2026-10-31 and an honest caveat. This chapter keeps them separate. +Atlas tracks backup completion, corpus row counts and publication freshness separately. Each observation below identifies the store or service and the date. ## The backup: `atlas-backup` @@ -51,7 +51,7 @@ Issue **#3125** is the provenance and occurrence-registry issue. Its census does > Last verified census (2026-10-31, on #3125): **18,325 sessions / 122,124 messages / 107,639 chunks.** -The store that census describes is the canonical store on the laptop — the `atlas.db` above **plus 29 topic shards**. Its sensitivity split, from the same record, cross-checks the total exactly: +The October record also describes 29 topic shards of that corpus. Shard copies must be reconciled separately from the canonical count. Its sensitivity split, from the same record, cross-checks the total exactly: | Tier | Shards | Chunks | |---|---|---| @@ -60,23 +60,27 @@ The store that census describes is the canonical store on the laptop — the `at | Public | 0 | 0 | | **Total** | **29** | **107,639** | -Zero public-tier shards is a stated fact of the v1 record, not a gap in the table. Any chapter, dashboard, or answer that quotes 18,325 / 122,124 / 107,639 must date it **2026-10-31** — see [FAQ](faq.md). +The split above belongs to the October snapshot. -### The unrecounted monolith +### November 23 AMD observation -Later records describe a **~7.3 GB monolith without a verified recount**. Both halves of that sentence matter. The store has grown since October — ingest, however manual, did not stop — and no fresh verified census has been taken. The 7.3 GB is a size observation, not a count: it cannot be turned into sessions, messages, or chunks by arithmetic, and this book does not try. +Separate SQLite read transactions on November 23, 2026 counted physical table rows in these local stores. A repeat read of the canonical database at 17:57:15 UTC reproduced the 17:56:17 UTC result. Sizes are observed database-file bytes. -### How a fresh census would be taken +| Local store | Sessions | Messages | Chunks | File bytes | SQLite schema version | +|---|---:|---:|---:|---:|---:| +| Canonical `~/atlas/turso-atlas/data/atlas.db` | 18,325 | 122,115 | 107,439 | 1,492,127,744 | 14 | +| Dated publish-source file `atlas-publish-v2-2026-10-31.db` in the same directory | 18,325 | 122,124 | 107,639 | 1,704,194,048 | 12 | -A fresh census is an early deliverable of the Atlas programme (#13241), and its shape is fixed by what made the October one trustworthy: +The canonical table counts differ from the October record by 0 sessions, −9 messages and −200 chunks. The census cannot determine which changes produced those differences. At 17:58:34 UTC, the canonical CAS registry contained 24,184 rows and 12,092 distinct hashes. The named Snowflake vector table was absent from both files. The dated file contained 107,639 rows in its legacy BGE table. These observations describe only the two selected files. The 7.3 GB database in PR #12028 was rebuilt from a Turso export. -1. Count the canonical store directly: sessions, messages, and chunks in `~/atlas/turso-atlas/data/atlas.db`. -2. Count every shard: each shard carries an `atlas_manifest` with an `expected_chunks` value, checked against an actual `COUNT(*)` of its chunks — a manifest that disagrees with its own store is a finding, not a number. -3. Split the result by tier (public / internal / secret) so the split cross-checks the total, as the October split does. -4. Date it, name the store it was taken from, and publish it in the same place the October census is quoted from — a design or programme record — so the next reader finds one canonical statement, not a scatter of counts. +On the same day the laptop service returned healthy with its embedder ready. Its health response supplied no publication generation or source watermark. Proving Fleet or Worker freshness requires tracing an authorized source revision through promotion and a scoped publication to the consumer. -Until that runs, there is no newer number to quote, from any source. +The backup timer was active and waiting. Its November 23 backup service run timed out after 90 minutes (04:58:04–06:28:04 Central). That run supplies no completed backup receipt. Verify a matching digest and destination receipt before relying on a particular copy. No backup or restore was triggered by the census. See #10304 for the existing backup investigation. -### Why consumers still see the October counts +### Repeat the measurement -Because nothing downstream recounts. Consumers — the service, the Worker, the CLIs — search the **published** store, and the publish consumers see is the October publish: ingestion today is manual and script-driven (the recurring sweep runner, #7969, is unbuilt; the ingest scripts still live outside the repo, with migration #5670 open), and no recount-and-republish pass has landed since. The counts are therefore not stale by accident or by caching — they are the counts of the corpus as published, frozen at the last verified census, while the underlying store has grown past them uncounted. The Worker cache's indefinite retention (#6805) is a separate staleness story, covered in [Troubleshooting](troubleshooting.md); even a perfectly fresh cache would still be answering over the October-published corpus. +From the repository root, run `python3 pkgs/atlas-search/tools/atlas_census.py` on the laptop. Pass `--canonical PATH` to select a different canonical-shaped database. For each approved scan shard, add `--shard PATH`; for each per-tier hydration store, add `--content-store PATH`. Use `--seconds-per-store N` to bound each read (default 20 seconds). + +The JSON report identifies inputs by role and ordinal. It measures each store in its own read-only transaction with WAL visibility, counts recognized tables, and distinguishes an empty table from a missing required table or an inapplicable one. A scan shard needs the expected manifest markers and a matching expected chunk count. Exit 1 means at least one requested store could not be counted and validated. Keep the path-to-ordinal mapping on the laptop. When reconciling shards against a generation, use its authorized inventory and count every required store before reporting coverage. + +The runtime may need a compatible native read-only libSQL reader for schemas the local SQLite implementation cannot open. A failed read supplies no row count. Keep revisions, policy and the consumer's published generation with each freshness receipt. diff --git a/pkgs/atlas-search/book/operations/faq.md b/pkgs/atlas-search/book/operations/faq.md index e7257294f3..cdad8e64a7 100644 --- a/pkgs/atlas-search/book/operations/faq.md +++ b/pkgs/atlas-search/book/operations/faq.md @@ -26,7 +26,7 @@ Because the D1 hot cache is not wired into the request path. The flag (only the ### Is the corpus current? -The corpus you can search is current as of its last publish — and the last **verified census is frozen at 2026-10-31: 18,325 sessions / 122,124 messages / 107,639 chunks** (#3125). The underlying store has since grown to a ~7.3 GB monolith with no verified recount, and ingestion is still manual and script-driven, so no newer count exists to quote and no consumer recounts on your behalf. A fresh census is an early programme deliverable; how one would be taken, and why the October numbers are the ones consumers still see, is in [Backup, restore and the census](backup-and-census.md). Treat any undated Atlas size claim — including one in an older chapter or design — as that October snapshot until a dated replacement exists. +The November 23, 2026 read of the canonical laptop file counted **18,325 sessions, 122,115 messages and 107,439 chunks**. The dated October publish-source file still had **18,325 / 122,124 / 107,639** in a separate read that day. The serving generation and source watermark require a consumer-scoped check. See [Backup, restore and the census](backup-and-census.md). ### Can ID search Atlas today? diff --git a/pkgs/atlas-search/tools/atlas_census.py b/pkgs/atlas-search/tools/atlas_census.py new file mode 100644 index 0000000000..3b093f19b1 --- /dev/null +++ b/pkgs/atlas-search/tools/atlas_census.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python3 +"""Take aggregate SQLite counts on the Atlas laptop. Requires Python 3.9+. + +Usage: atlas_census.py [--canonical PATH] [--shard PATH ...] [--content-store PATH ...] + [--seconds-per-store N] +Repeat --shard or --content-store for each additional store. + +Reads the canonical database by default. Supply --shard PATH once per approved +scan shard, and --content-store PATH once per separately approved content store. +The report labels stores by role and argument position. Keep the path-to-position +mapping on the laptop. Exit 0 means the required tables for all requested roles +were counted, 1 means partial or unsuccessful, and 2 means invalid input. +""" + +import argparse +from datetime import datetime, timezone +import json +import multiprocessing +from pathlib import Path +import sqlite3 +import sys +from time import monotonic + + +# The profile comes from the operator's explicit source selection. Missing role +# markers mean incomplete evidence. Never guess a role from filenames or data. +PROFILES = { + "canonical": { + "required": ("sessions", "messages", "chunks"), + "optional": ("cas_registry", "chunk_occurrences", "vec_snowflake_m_v2_768_f32", + "vec_bge_small_384_f32"), + }, + "scan_shard": { + "required": ("atlas_manifest", "chunks", "vec_snowflake_m_v2_768_f32"), + "optional": ("chunk_occurrences",), + }, + "content_store": { + "required": ("sessions", "messages"), + "optional": (), + }, +} +TABLES = tuple(dict.fromkeys( + table for profile in PROFILES.values() + for names in profile.values() for table in names +)) + + +def utc_now(): + return datetime.now(timezone.utc).isoformat(timespec="milliseconds") + + +class SafeParser(argparse.ArgumentParser): + def error(self, message): + self.exit(2, "Invalid census arguments. See --help.\n") + + +def file_size(path): + try: + return path.stat().st_size + except OSError: + return None + + +def inspect_store(path, seconds, role): + path = path.expanduser().resolve(strict=True) + if not path.is_file(): + return {"status": "not_a_file"} + deadline = monotonic() + seconds + database = sqlite3.connect( + path.as_uri() + "?mode=ro", uri=True, timeout=min(seconds, 1.0) + ) + try: + database.execute("PRAGMA query_only=ON") + database.execute("PRAGMA trusted_schema=OFF") + database.set_progress_handler(lambda: int(monotonic() >= deadline), 1000) + database.execute("BEGIN") + version = database.execute("PRAGMA schema_version").fetchone()[0] + user_version = database.execute("PRAGMA user_version").fetchone()[0] + profile = PROFILES[role] + counts = {} + dispositions = {} + for table in TABLES: + if table not in profile["required"] and table not in profile["optional"]: + counts[table] = None + dispositions[table] = "not_applicable" + continue + entry = database.execute( + "SELECT type FROM sqlite_master WHERE name = ?", (table,) + ).fetchone() + if entry is None or entry[0] != "table": + counts[table] = None + dispositions[table] = ( + "required_table_missing" if table in profile["required"] + else "optional_table_absent" + ) + continue + # The identifier comes exclusively from the constants above. + counts[table] = database.execute( + f'SELECT COUNT(*) FROM "{table}"' + ).fetchone()[0] + dispositions[table] = "counted" + status = ( + "ok" if all(counts[x] is not None for x in profile["required"]) + else "required_table_missing" + ) + if role == "scan_shard" and status == "ok": + # Return only the count of required keys, never manifest values. + matched = database.execute( + 'SELECT COUNT(DISTINCT "key") FROM atlas_manifest ' + 'WHERE "key" IN (?, ?, ?) AND value IS NOT NULL ' + 'AND length(value) > 0', ("shard", "embedding_model", "expected_chunks") + ).fetchone()[0] + if matched != 3: + status = "shard_manifest_incomplete" + if role == "scan_shard" and status == "ok": + expected = database.execute( + "SELECT value FROM atlas_manifest WHERE key = 'expected_chunks'" + ).fetchone()[0] + if str(expected) != str(counts["chunks"]): + status = "shard_manifest_count_mismatch" + database.rollback() + finally: + database.close() + return { + "status": status, + "sqlite_schema_version": version, + "sqlite_user_version": user_version, + "snapshot_row_counts": counts, + "table_dispositions": dispositions, + "db_bytes_after_snapshot": file_size(path), + "wal_bytes_after_snapshot": file_size(Path(str(path) + "-wal")), + } + + +def count_and_send(path, seconds, role, sender): + try: + result = inspect_store(path, seconds, role) + except FileNotFoundError: + result = {"status": "file_missing"} + except PermissionError: + result = {"status": "access_denied"} + except sqlite3.Error as error: + # SQLite codes are optional on older Python builds. Do not print exception + # messages: they may include paths or database-specific identifiers. + code = getattr(error, "sqlite_errorcode", 0) or 0 + result = {"status": { + 5: "database_busy", 6: "database_locked", 9: "interrupted", + 14: "open_failed", 26: "unrecognized_database", + }.get(code & 255, "sqlite_error")} + except Exception: + result = {"status": "unavailable"} + try: + sender.send(result) + finally: + sender.close() + + +def bounded_count(ctx, path, seconds, role): + # A SQL progress callback alone cannot bound a single long sqlite opcode. + receiver, sender = ctx.Pipe(duplex=False) + worker = ctx.Process(target=count_and_send, args=(path, seconds, role, sender)) + try: + worker.start() + sender.close() + if not receiver.poll(seconds): + return {"status": "deadline_exceeded"} + try: + return receiver.recv() + except EOFError: + return {"status": "worker_failed"} + finally: + receiver.close() + sender.close() + if worker.pid is not None: + worker.join(timeout=0.1) + if worker.is_alive(): + worker.kill() + worker.join(timeout=1) + + +def main(): + parser = SafeParser(description=__doc__, allow_abbrev=False) + parser.add_argument("--canonical", type=Path, + default=Path("~/atlas/turso-atlas/data/atlas.db")) + parser.add_argument("--shard", type=Path, action="append", default=[], + help="Explicit authorized scan shard, in local ledger order") + parser.add_argument("--content-store", type=Path, action="append", default=[], + help="Explicit authorized content store, in local ledger order") + parser.add_argument("--seconds-per-store", type=int, default=20, + help="Maximum worker wait per store, from 1 to 120 seconds") + args = parser.parse_args() + if not 1 <= args.seconds_per_store <= 120: + parser.error("invalid deadline") + ctx = multiprocessing.get_context("spawn") + report = { + "format": "atlas-census/v1", + "started_at_utc": utc_now(), + "route": "local_sqlite_readonly", + "snapshot_scope": "one read transaction per store", + "size_scope": "best-effort filesystem observations after each read transaction", + "null_count": "see role-specific table_dispositions", + "null_size": "unavailable or absent", + "freshness": "ingest and published watermarks were not measured", + "identity_scope": "per-store physical rows, including retained revisions or tombstones", + "stores": [], + } + targets = [("canonical", args.canonical)] + targets.extend(("scan_shard", path) for path in args.shard) + targets.extend(("content_store", path) for path in args.content_store) + for index, (role, path) in enumerate(targets): + store = {"role": role, "ordinal": index, "started_at_utc": utc_now()} + try: + store.update(bounded_count(ctx, path, args.seconds_per_store, role)) + except Exception: + store["status"] = "worker_failed" + store["finished_at_utc"] = utc_now() + report["stores"].append(store) + report["finished_at_utc"] = utc_now() + report["complete_required_counts"] = all(s["status"] == "ok" for s in report["stores"]) + print(json.dumps(report, indent=2)) + return 0 if report["complete_required_counts"] else 1 + + +if __name__ == "__main__": + sys.exit(main()) + diff --git a/pkgs/atlas-search/tools/tests/test_atlas_census.py b/pkgs/atlas-search/tools/tests/test_atlas_census.py new file mode 100644 index 0000000000..da5178577b --- /dev/null +++ b/pkgs/atlas-search/tools/tests/test_atlas_census.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 +"""Oracle: counts and store profiles in synthetic databases, including a WAL-only row.""" + +import json +from pathlib import Path +import sqlite3 +import subprocess +import sys +import tempfile +import unittest + + +SCRIPT = Path(__file__).resolve().parents[1] / "atlas_census.py" +SECRET_SENTINEL = "SYNTHETIC_ATLAS_PAYLOAD_MUST_STAY_LOCAL" +VECTOR_TABLE = "vec_snowflake_m_v2_768_f32" + + +class CensusSmokeTest(unittest.TestCase): + def setUp(self): + directory = tempfile.TemporaryDirectory(prefix="atlas-private-fixture-") + self.addCleanup(directory.cleanup) + self.root = Path(directory.name) + + def run_census(self, *arguments, expected_code): + result = subprocess.run( + [sys.executable, str(SCRIPT), *map(str, arguments)], + capture_output=True, text=True, timeout=90, check=False, + ) + for output in (result.stdout, result.stderr): + self.assertNotIn(SECRET_SENTINEL, output) + self.assertNotIn(str(self.root), output) + self.assertEqual(result.returncode, expected_code, result.stderr) + self.assertEqual(result.stderr, "") + return json.loads(result.stdout) + + def create_database(self, name, schema): + path = self.root / name + connection = sqlite3.connect(path) + try: + connection.executescript(schema) + connection.commit() + finally: + connection.close() + return path + + def test_three_store_profiles_and_committed_wal(self): + canonical = self.create_database("canonical.db", """ + CREATE TABLE sessions (id INTEGER PRIMARY KEY, title TEXT); + CREATE TABLE messages (id INTEGER PRIMARY KEY); + CREATE TABLE chunks (id INTEGER PRIMARY KEY); + INSERT INTO sessions VALUES (1, 'initial row'); + """) + shard = self.create_database("private-shard.db", f""" + CREATE TABLE chunks (id INTEGER PRIMARY KEY); + CREATE TABLE {VECTOR_TABLE} (chunk_id INTEGER PRIMARY KEY, vec BLOB); + CREATE TABLE atlas_manifest (key TEXT PRIMARY KEY, value TEXT); + INSERT INTO atlas_manifest VALUES ('shard', 'synthetic'), + ('embedding_model', 'synthetic'), ('expected_chunks', '0'); + """) + content = self.create_database("private-content.db", """ + CREATE TABLE sessions (id INTEGER PRIMARY KEY); + CREATE TABLE messages (id INTEGER PRIMARY KEY); + INSERT INTO messages VALUES (1); + """) + + writer = sqlite3.connect(canonical) + try: + self.assertEqual(writer.execute("PRAGMA journal_mode=WAL").fetchone(), ("wal",)) + writer.execute("PRAGMA wal_autocheckpoint=0") + writer.execute("PRAGMA wal_checkpoint(TRUNCATE)").fetchone() + writer.execute("INSERT INTO sessions VALUES (?, ?)", (2, SECRET_SENTINEL)) + writer.commit() + self.assertGreater(Path(str(canonical) + "-wal").stat().st_size, 0) + # This fixture intentionally reads *only* the known checkpointed + # base so the control cannot see the second, WAL-resident session. + base = sqlite3.connect(canonical.as_uri() + "?immutable=1", uri=True) + try: + self.assertEqual(base.execute("SELECT COUNT(*) FROM sessions").fetchone(), (1,)) + finally: + base.close() + report = self.run_census( + "--canonical", canonical, "--shard", shard, + "--content-store", content, expected_code=0, + ) + finally: + writer.close() + + self.assertTrue(report["complete_required_counts"]) + main, scan, hydration = report["stores"] + self.assertEqual([s["role"] for s in report["stores"]], + ["canonical", "scan_shard", "content_store"]) + self.assertEqual([s["status"] for s in report["stores"]], ["ok"] * 3) + self.assertEqual(main["snapshot_row_counts"]["sessions"], 2) + self.assertEqual(main["snapshot_row_counts"]["chunks"], 0) + self.assertEqual(main["table_dispositions"]["chunks"], "counted") + self.assertIsNone(main["snapshot_row_counts"][VECTOR_TABLE]) + self.assertEqual(main["table_dispositions"][VECTOR_TABLE], "optional_table_absent") + self.assertEqual(scan["snapshot_row_counts"][VECTOR_TABLE], 0) + self.assertEqual(scan["table_dispositions"]["sessions"], "not_applicable") + self.assertEqual(hydration["snapshot_row_counts"]["messages"], 1) + self.assertEqual(hydration["table_dispositions"]["chunks"], "not_applicable") + with sqlite3.connect(shard) as changed: + changed.execute("UPDATE atlas_manifest SET value='4' WHERE key='expected_chunks'") + mismatch = self.run_census("--canonical", canonical, "--shard", shard, expected_code=1) + self.assertEqual(mismatch["stores"][1]["status"], "shard_manifest_count_mismatch") + + def test_missing_table_missing_path_and_non_file(self): + partial = self.create_database("partial.db", """ + CREATE TABLE sessions (id INTEGER PRIMARY KEY); + CREATE TABLE messages (id INTEGER PRIMARY KEY); + """) + absent = self.root / "absent.db" + directory = self.root / "a-directory" + directory.mkdir() + report = self.run_census( + "--canonical", partial, "--shard", absent, + "--content-store", directory, expected_code=1, + ) + self.assertFalse(report["complete_required_counts"]) + self.assertEqual([s["status"] for s in report["stores"]], + ["required_table_missing", "file_missing", "not_a_file"]) + self.assertEqual(report["stores"][0]["table_dispositions"]["chunks"], + "required_table_missing") + self.assertIsNone(report["stores"][0]["snapshot_row_counts"]["chunks"]) + self.assertFalse(absent.exists()) + self.assertFalse(list(self.root.glob("absent.db-*"))) + + +if __name__ == "__main__": + unittest.main() + From eca7be3f69f263c2d67e804d34cf12262d6dd671 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 12:04:46 -0600 Subject: [PATCH 2/3] atlas: align census references and record local backup receipt --- .../book/concepts/corpus-and-provenance.md | 11 ++++------- pkgs/atlas-search/book/concepts/ingest.md | 2 +- pkgs/atlas-search/book/design/automatic-ingest.md | 2 +- pkgs/atlas-search/book/index.md | 15 ++++++--------- .../book/operations/backup-and-census.md | 2 +- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/pkgs/atlas-search/book/concepts/corpus-and-provenance.md b/pkgs/atlas-search/book/concepts/corpus-and-provenance.md index b0cc21aa0d..5408284a92 100644 --- a/pkgs/atlas-search/book/concepts/corpus-and-provenance.md +++ b/pkgs/atlas-search/book/concepts/corpus-and-provenance.md @@ -218,13 +218,10 @@ of personal-client text were at that point held back from Turso by policy. That same day the hold-back was lifted: everything in canonical publishes, and privacy moved to query-time classification filters instead. -Since then the store has grown without a recount. Later records (2026-11-12) -describe the Turso monolith as about **7.3 GB** over the same 107,639 chunks -plus the 29 topic shards, and state in terms that the canonical counts are -frozen at the 2026-10-31 publish while the monolith grew *without a verified -recount*. Read every number in the table above as "true on 2026-10-31", not -as today's count; a fresh verified census is an open deliverable of the -Atlas programme. For scale, the laptop's `~/atlas/` directory overall was +The November 23 canonical count was 18,325 sessions, 122,115 messages and 107,439 chunks. +The dated publish-source file still held the October table counts above. +See [Backup, restore and the census](../operations/backup-and-census.md) for the +store roles, read times and repeatable count procedure. For scale, the laptop's `~/atlas/` directory overall was 12 GB at the census date, hash-verified to contain no consequential byte-identical duplicates — it is distinct versions and working sets, so no cleanup windfall exists there. diff --git a/pkgs/atlas-search/book/concepts/ingest.md b/pkgs/atlas-search/book/concepts/ingest.md index 1982f72aa6..49c7e1dae1 100644 --- a/pkgs/atlas-search/book/concepts/ingest.md +++ b/pkgs/atlas-search/book/concepts/ingest.md @@ -14,7 +14,7 @@ The production corpus was built, and is still extended, by scripts that live out 4. **Publish.** A copy of the hot index — keyword index plus the current-best vectors — is pushed to the hosted Turso database as distribution. The full store stays on the laptop; the hosted copy never holds the only copy of anything. 5. **Access.** Agents search through the surfaces in [The service and the Worker](service-and-worker.md), not by writing SQL against the corpus. -The operational facts: ingestion is run by hand, or by an agent lane invoking the scripts. There is no ingest schedule; the only Atlas schedule on the laptop is the daily backup timer. Corpus counts are therefore a snapshot — last verified at the 2026-10-31 publish, as [The corpus: provenance and content addressing](corpus-and-provenance.md) records — with no verified recount of later growth. The migration moving these scripts into this repository is issue #5670, still open: the Python search reference and evaluation tooling have landed in-repo; the ingest-side scripts have not. Anything describing Atlas ingest as a running service is describing the design in [Design: automatic ingest of all sources](../design/automatic-ingest.md), not today's system. +The operational facts: ingestion is run by hand, or by an agent lane invoking the scripts. There is no ingest schedule; the only Atlas schedule on the laptop is the daily backup timer. The latest local census and the separate dated publish-source counts are recorded in [Backup, restore and the census](../operations/backup-and-census.md). The migration moving these scripts into this repository is issue #5670, still open: the Python search reference and evaluation tooling have landed in-repo; the ingest-side scripts have not. Anything describing Atlas ingest as a running service is describing the design in [Design: automatic ingest of all sources](../design/automatic-ingest.md), not today's system. ## Staging: one small database per unit of work diff --git a/pkgs/atlas-search/book/design/automatic-ingest.md b/pkgs/atlas-search/book/design/automatic-ingest.md index 253d56ddba..843161565b 100644 --- a/pkgs/atlas-search/book/design/automatic-ingest.md +++ b/pkgs/atlas-search/book/design/automatic-ingest.md @@ -102,7 +102,7 @@ A purge that removes a chunk from the vector store but leaves it findable by ful Grounding, so the design above is never mistaken for the present: - **Ingestion today is manual and script-driven.** The only Atlas schedule on the laptop is the daily backup timer. The ingest scripts still live outside the code repo (#5670 migration open), and the recurring sweep runner is unbuilt (#7969: a runner core exists in atlas-core, but it creates and enables no schedule — cadence is an operator decision gated on the owner's go-ahead). -- **The production pipeline is the older five-step shape** — collect, normalize, index, publish, access — driven by `atlas-ingest.py` with per-client adapters, normalizing conversations into one local database that is the durable asset, building the FTS and vector indexes from it, and publishing a hot copy to Turso as distribution. Corpus counts consumers see are frozen at the 2026-10-31 census — 18,325 sessions, 122,124 messages, 107,639 chunks, in a monolith plus 29 topic shards (28 internal shards holding 107,001 chunks and 1 secret shard holding 638 chunks; zero public-tier shards) — while the store has since grown without a verified recount. +- **The production pipeline is the older five-step shape** — collect, normalize, index, publish, access — driven by `atlas-ingest.py` with per-client adapters, normalizing conversations into one local database that is the durable asset, building the FTS and vector indexes from it, and publishing a hot copy to Turso as distribution. Canonical and publication counts belong to different stores. The November 23 local comparison is in [Backup, restore and the census](../operations/backup-and-census.md). - **GitHub comments are the one completed new source.** Extraction and the ingestion writer landed (#6023, #10688); GitHub objects, commits, files, and continuous delta have not. - **The staging foundation is built.** Per-unit staging databases with a versioned schema, a staging-unit registry, classification-at-staging with boundary-safe chunking, the batch gate's audit record and state machine (#7709, the record half of #6057), and a one-shot embed-at-promotion command all exist in atlas-core. What does not exist is the standing machinery around them: the aggregator as a service, the session-close extraction hook, and the gate's stage checks beyond the record they write into are later slices, not running code. - **Traces are already a corpus source.** Atlas's own query traces, statistics, and weekly reports are ingested as a statistics-and-reports source class inside atlas-core. That is the one place where something like automatic ingest — system output flowing back into the corpus by construction — already happens. diff --git a/pkgs/atlas-search/book/index.md b/pkgs/atlas-search/book/index.md index 8042076fe0..73d4cfbc1a 100644 --- a/pkgs/atlas-search/book/index.md +++ b/pkgs/atlas-search/book/index.md @@ -22,15 +22,12 @@ so re-ingesting the same material adds nothing twice. Each session is classified with a kind, topics, and projects, and each chunk carries an effective sensitivity (its own, falling back to its session's label). -The last verified census is a frozen snapshot, and this book dates it -wherever it is quoted: on **2026-10-31** the corpus held **18,325 sessions / -122,124 messages / 107,639 chunks**. Physically, that census is now a local -canonical database plus **29 topic shards**: 28 internal shards holding -107,001 chunks and 1 secret shard holding 638 chunks, with zero public-tier -shards. Later records describe a monolith of about 7.3 GB without a verified -recount, so the store has grown since the census; the counts above are the -last verified ones, not a live count. The full treatment is in -[The corpus: provenance and content addressing](concepts/corpus-and-provenance.md). +On **2026-11-23** the canonical laptop database contained **18,325 sessions, +122,115 messages and 107,439 chunks**. A separate read of the October 31 +publish-source file returned 18,325 sessions, 122,124 messages and 107,639 +chunks. Each count belongs to the selected local file; the live service and +Worker require separate publication receipts. +[Backup, restore and the census](operations/backup-and-census.md). Two properties define the system, and both are enforced before ranking, never after: diff --git a/pkgs/atlas-search/book/operations/backup-and-census.md b/pkgs/atlas-search/book/operations/backup-and-census.md index 54218441bd..60812ff83c 100644 --- a/pkgs/atlas-search/book/operations/backup-and-census.md +++ b/pkgs/atlas-search/book/operations/backup-and-census.md @@ -75,7 +75,7 @@ The canonical table counts differ from the October record by 0 sessions, −9 me On the same day the laptop service returned healthy with its embedder ready. Its health response supplied no publication generation or source watermark. Proving Fleet or Worker freshness requires tracing an authorized source revision through promotion and a scoped publication to the consumer. -The backup timer was active and waiting. Its November 23 backup service run timed out after 90 minutes (04:58:04–06:28:04 Central). That run supplies no completed backup receipt. Verify a matching digest and destination receipt before relying on a particular copy. No backup or restore was triggered by the census. See #10304 for the existing backup investigation. +The backup timer was active and waiting. Its November 23 backup service run timed out after 90 minutes (04:58:04–06:28:04 Central). The local dated gzip (491,721,304 bytes) and its manifest were present. The manifest recorded 18,325 sessions, 122,115 messages and 107,439 chunks, matching the live count. The November 15 local manifest recorded 18,325, 122,118 and 107,505 respectively. The ledger contained no November 23 completion and offsite copies were not independently verified. Verify a matching digest and destination receipt before relying on a particular copy. No backup or restore was triggered by the census. See #10304 for the existing backup investigation. ### Repeat the measurement From 8b0c5bf78906866e7576742db29a544b712e14d1 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 12:10:23 -0600 Subject: [PATCH 3/3] atlas: compare the serving origin with both laptop stores --- pkgs/atlas-search/book/operations/backup-and-census.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/atlas-search/book/operations/backup-and-census.md b/pkgs/atlas-search/book/operations/backup-and-census.md index 60812ff83c..57166d05ef 100644 --- a/pkgs/atlas-search/book/operations/backup-and-census.md +++ b/pkgs/atlas-search/book/operations/backup-and-census.md @@ -73,6 +73,8 @@ Separate SQLite read transactions on November 23, 2026 counted physical table ro The canonical table counts differ from the October record by 0 sessions, −9 messages and −200 chunks. The census cannot determine which changes produced those differences. At 17:58:34 UTC, the canonical CAS registry contained 24,184 rows and 12,092 distinct hashes. The named Snowflake vector table was absent from both files. The dated file contained 107,639 rows in its legacy BGE table. These observations describe only the two selected files. The 7.3 GB database in PR #12028 was rebuilt from a Turso export. +At 18:08:56–18:08:58 UTC, one read-only statement against the configured Turso logical database `atlas` counted **18,325 sessions, 71,551 messages and 107,639 chunks**. The three scalar subqueries used `COUNT(*)` on `sessions`, `messages` and `chunks`. This hosted database had 50,564 fewer message rows and 200 more chunk rows than the canonical file. The identical chunk counts in the hosted database and dated file do not establish that every row or revision matches. + On the same day the laptop service returned healthy with its embedder ready. Its health response supplied no publication generation or source watermark. Proving Fleet or Worker freshness requires tracing an authorized source revision through promotion and a scoped publication to the consumer. The backup timer was active and waiting. Its November 23 backup service run timed out after 90 minutes (04:58:04–06:28:04 Central). The local dated gzip (491,721,304 bytes) and its manifest were present. The manifest recorded 18,325 sessions, 122,115 messages and 107,439 chunks, matching the live count. The November 15 local manifest recorded 18,325, 122,118 and 107,505 respectively. The ledger contained no November 23 completion and offsite copies were not independently verified. Verify a matching digest and destination receipt before relying on a particular copy. No backup or restore was triggered by the census. See #10304 for the existing backup investigation.