Public: anyone can read this; the crew can change it.
The database keeps what it needs: deploy_pull, event and machine_sample have… #11978
This pull covers only the size-reporting half of item 4. The retention rules, space give-back and index diet are not built, and the issue should be split before they are.
stopped parked by the crew deploy d63fc7a
4 earlier comments
This pull covers only the size-reporting half of item 4. The retention rules, space give-back and index diet are not built, and the issue should be split before they are.
What changed
- New
src/system/db_size.ts:dbSize(db, dataDir)returns the size offorge.db, the write-ahead log, the free pages inside the file, and whether the file is past the 2 GiB Bun can map (MMAP_CAP_BYTES). /systemhas a new "Database" block that shows these figures. ThesystemMCP tool returns the same asdb.- A
db-sizeneed now fires insrc/kernel/vitals.tswhen the file passes the mmap cap, and links to/system. test/disk-marks.test.tscovers the need by making a sparse file past the cap.test/system-parts.test.tsnow expects the new "Database" heading.
What I did not do
- Size by table and index: the top-ten view is missing. This SQLite build has no
dbstat, so it needs per-table row counts and estimated bytes, or a different measure. - Growth per day: not built, so the vitals need fires only on the mmap cap, not on a growth rate.
- Retention rules (item 1): nothing for
deploy_pull,eventormachine_sample. This includes the nightly batched job, the admin settings, and the test proving the rebuild from git. - Giving space back (item 2): no incremental vacuum or
VACUUM INTOyet, and so no choice between them. - Index diet (item 3): the list of 396 indexes and which queries use them is not produced. No index is dropped.
- Production copy: none of this was checked against a copy of production, so "under 2 GiB" and "each batch holds the write lock under 50 ms" are unmeasured.
I suggest four child issues, one run each, in this order:
- Size by table and index, plus growth per day.
- Retention for
machine_sample(the simplest rule), with the nightly batching harness and incremental vacuum. - Retention for
eventanddeploy_pull. - The index diet.
Checks
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tsare clean.test/disk-marks.test.tsandtest/system-parts.test.tspass.- The system and MCP test files passed after the heading fix, except for
test/system-parts.test.ts, which I re-ran separately. scripts/fast.tssaid the diff is too broad to name (exit 2), so I ran only these files, not the full suite.
Try it: open /system as an admin and read "Database". Or call the system tool and read db.
I found nothing in my change to fix, and I pushed nothing.
- The preview is healthy. https://lab--11978--forge-trevato-apps.open-platform.sh/ answers 200 in about 0.34 s.
- The log shows no error. The excerpt you sent is routine output (process counts, SQL timings), with no stack trace or failing test.
- "No tests declared, none run" is not a bug.
forge.jsonhas no app-level test command (apphas onlyrun,healthandlooks). The tests live undercheck(fast,run,verify), and the forge runs those on the push. - My own checks passed before the first push.
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tswere clean, and the tests I ran passed. - Not run: the full suite. The system and MCP files had one failing test, the heading list in
test/system-parts.test.ts, which I fixed. A broader failure may exist that I haven't seen. If thecheckverdict on #11978 comes back red, send me that log and I'll fix it.
The scope is unchanged from the pull description: only the database size reporting is done. The retention rules, vacuum, index diet and size by table still need splitting into separate issues.
The forge's database size is now on /system and in the system tool. Vitals raises a need when the file passes Bun's 2 GiB map. I merged the latest main and pushed to re-run the check.
The last check failed because the forge kept going away during the test run, four times over, not because a test failed. Every test shown in that log passed (195 pass, 0 fail), and nothing in my diff starts a process or takes the forge down. I changed no code to fix it. The merge pulled in main's newer commits, including its fixes for red full-suite runs. I did not reproduce the failure here, so I can't say what made the forge go away.
Before pushing I ran bun scripts/gate.ts and bun x tsc --noEmit, both clean. I also ran test/disk-marks.test.ts and test/system-parts.test.ts, which pass (16 tests). I did not run the full suite here, since the forge's check does that.
What changed
- A new module,
src/system/db_size.ts, reads the database's file size, its write-ahead log and its free pages. /systemhas a "Database" block showing the three figures.- The
systemtool returns the same figures asdb. - Vitals raises a
db-sizeneed, linking to/system, when the file is past 2 GiB.
Left out: bytes per table. This SQLite is built without dbstat, so there is nothing to read them from.
To try it: open /system and read the Database block.
This pull covers only the size-reporting half of item 4. The retention rules, space give-back and index diet are not built, and the issue should be split before they are.
What changed
src/system/db_size.ts:dbSize(db, dataDir)returns the size offorge.db, the write-ahead log, the free pages inside the file, and whether the file is past the 2 GiB Bun can map (MMAP_CAP_BYTES)./systemhas a new "Database" block that shows these figures. ThesystemMCP tool returns the same asdb.db-sizeneed now fires insrc/kernel/vitals.tswhen the file passes the mmap cap, and links to/system.test/disk-marks.test.tscovers the need by making a sparse file past the cap.test/system-parts.test.tsnow expects the new "Database" heading.What I did not do
dbstat, so it needs per-table row counts and estimated bytes, or a different measure.deploy_pull,eventormachine_sample. This includes the nightly batched job, the admin settings, and the test proving the rebuild from git.VACUUM INTOyet, and so no choice between them.I suggest four child issues, one run each, in this order:
machine_sample(the simplest rule), with the nightly batching harness and incremental vacuum.eventanddeploy_pull.Checks
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tsare clean.test/disk-marks.test.tsandtest/system-parts.test.tspass.test/system-parts.test.ts, which I re-ran separately.scripts/fast.tssaid the diff is too broad to name (exit 2), so I ran only these files, not the full suite.Try it: open
/systemas an admin and read "Database". Or call thesystemtool and readdb.Closes #11973