Public: anyone can read this; the crew can change it.
The database keeps what it needs: deploy_pull, event and machine_sample have… #11973
Pull #11978 was closed · 3 runs
2 earlier comments · 1 event
Parked by the crew: the check stayed red through 2 automatic tries (pull #11974 closed; its branch mason/11973-the-database-keeps-what-it-needs-deploy at 5812900b14f6 keeps the work so far). Planner: split this smaller, or rewrite what done looks like; a person can also say what to try.
try 1: AGENTS.md, docs/features/retention.md, scripts/index-diet.ts, scripts/sql-tap.ts, src/boards/ring.ts, src/boards/sampler.ts, src/core/capacity.ts, src/c… try 2: scripts/header-width-allow.json, scripts/index-diet.ts, scripts/sql-tap.ts, src/boards/ring.ts, src/core/capacity.ts, src/core/carried.ts, src/core/rete… try 3: docs/design/attention-budget.json, src/actions/capacity.ts, src/maintain/duties/retention.ts, src/system/db_size.ts, src/web/pages/system.ts, test/capac… try 4: src/system/db_size.ts
Parked by the crew: the check stayed red through 2 automatic tries (pull #11978 closed; its branch scout/11973-the-database-keeps-what-it-needs-deploy at d63fc7a21ee8 keeps the work so far).
Parked twice since a person last spoke here, so it is the planner's now. Every reason:
- the check stayed red through 2 automatic tries (pull #11974 closed; its branch
mason/11973-the-database-keeps-what-it-needs-deployat 5812900b14f6 keeps the work so far) - the check stayed red through 2 automatic tries (pull #11978 closed; its branch
scout/11973-the-database-keeps-what-it-needs-deployat d63fc7a21ee8 keeps the work so far)
The planner splits it, replaces it with a fresh issue, or defers it; a person can also say what to try. Nothing starts here until then, and the board lists it.
try 1: src/http/mcp/tools/system.ts, src/kernel/vitals.ts, src/system/db_size.ts, src/web/pages/system.ts, test/disk-marks.test.ts, test/system-parts.test.ts try 2: docs/MCP.md, docs/features/estimates.md, docs/features/packs.md, docs/features/ssh-first-ask.md, scripts/pack.ts, src/actions/estimates.ts, src/actions/…
Split: one rule per table, each pruning in capped batches: #12007 (machine_sample), #12008 (event), #12009 (deploy_pull, with the rebuild-from-git test first). Then #12010 (the size table on /system, the system tool's kind "size", and the vitals need) and #12011 (index diet). Giving the space back without a long lock (incremental vacuum or VACUUM INTO at hand-over) comes next, once #12007-#12009 land. It was left out only because a plan holds 12 items.
The database keeps what it needs: deploy_pull, event and machine_sample have a retention rule, and the forge reports its own size by table
Measured on a copy of production (2026-11-13): forge.db is 4.56 GB, too big for Bun's 2 GiB mmap cap, so scans cost a read per page. Payload is about 1.9 GB and the rest is 396 indexes. The three largest tables are bookkeeping, not anyone's work:
deploy_pull9.9M rows / 906 MB (its own header says it is an index over git and can be rebuilt),event2.4M rows / 578 MB,machine_sample2.0M rows / 174 MB. For comparisonrunis 124k rows / 44 MB andcomment47 MB. The owner's words: "the original vision was bun + sqlite and we've gotten very bloated", and tonight the forge's one thread was blocked most of every minute.Build:
deploy_pullkeeps rows for deploys of the last N days and whatever a live or sleeping app still needs, the rest is rebuilt on demand from git (prove the rebuild path with a test first);eventkeeps everything a feed, an audit view or a replay cursor can still reach (say which readers need what age) and drops or rolls up the rest;machine_samplekeeps raw samples for 48 h, then one row per 5 minutes for 30 days, then one per hour. Defaults in constants, overridable in admin settings, shown on /system.VACUUM INTOa new file at a release hand-over), not a blocking VACUUM on the live handle. State which and why.systemtool show the top ten tables and indexes by bytes and rows, the file size, and growth per day; a vitals need fires when the file grows faster than a set rate or passes the mmap cap, so this is never found by a profiler again.Done when: on a copy of production the three rules bring the file under 2 GiB with every test green and every page that reads those tables showing the same answers for the ages it promises; the size table is on /system; the nightly job's batches each hold the write lock under 50 ms.