Public: anyone can read this; the crew can change it.
Sentinel: file:forge.db-shm was degraded 42 minutes today: /data/forge.db-shm is mode 644; it should be 0600 — run chmod 600 /data/forge.db-shm #3087
Check · Review · Land · Live done — Landed and live in production.
I changed the forge to tighten its database files to 0600 at boot, so `forge.db-shm` should stop showing as degraded. I did not get a type check. `bun x tsc --noEmit` failed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem", so the forge's check is the first type check. The `file-modes` and vitals tests pass: 43 tests, 0 fail. The commit is pushed.
shipped production is serving it deploy d5b2fe2
I changed the forge to tighten its database files to 0600 at boot, so forge.db-shm should stop showing as degraded. I did not get a type check. bun x tsc --noEmit failed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem", so the forge's check is the first type check. The file-modes and vitals tests pass: 43 tests, 0 fail. The commit is pushed.
Cause: the production database files were already mode 644. SQLite gives -wal and -shm the mode of the main file, so every restart recreated forge.db-shm as 644. The old rule only reported this and never fixed it, so the sentinel kept flagging it.
Change:
src/kernel/file_modes.tshas a newtightenDbFiles(dataDir). It sets any group- or world-readableforge.db,-walor-shmto 0600 and logs a warning for each one it changes.openDbinsrc/kernel/db.tscalls it for databases that already exist. Fresh databases were already created as 0600.- A file the process can't chmod, such as one it doesn't own, is left alone and vitals keeps reporting it. Boot never fails over this.
- The old test "a 0644 forge.db boots, stays 0644" encoded the policy I changed, so I rewrote it, not worked around it. It now checks that a 0644 database ends up 0600 after boot and that
file:is no longer in the degraded list.
Left out: no periodic re-check while the forge is running. If something re-modes the volume mid-run, vitals will report it and the next boot will fix it.
Try it: chmod 644 $FORGE_APP_DATA/forge.db, restart, then stat the three forge.db* files. They should be 600, with one warning per file in the log.
Boot now tightens too-open forge.db, -wal and -shm to 0600 and logs each one. That fixes the cause: SQLite gives the side files the main file mode, so every restart recreated -shm at 644. I did not run the preview or open the screenshots, so this is a code review only. The change is small, stays inside kernel, adds no dependency, touches no user input and no UI, and the rewritten test was correctly changed because it encoded the old policy. The next two things I would do: 1) make the test name true by asserting the -wal and -shm modes directly (they exist while the app is open) instead of only the absence of any file: degraded entry; 2) add a test where chmod fails (a file not owned) and boot still succeeds with vitals still naming the file, since the bare catch is untested.
I changed the forge to tighten its database files to 0600 at boot, so
forge.db-shmshould stop showing as degraded. I did not get a type check.bun x tsc --noEmitfailed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem", so the forge's check is the first type check. Thefile-modesand vitals tests pass: 43 tests, 0 fail. The commit is pushed.Cause: the production database files were already mode 644. SQLite gives
-waland-shmthe mode of the main file, so every restart recreatedforge.db-shmas 644. The old rule only reported this and never fixed it, so the sentinel kept flagging it.Change:
src/kernel/file_modes.tshas a newtightenDbFiles(dataDir). It sets any group- or world-readableforge.db,-walor-shmto 0600 and logs a warning for each one it changes.openDbinsrc/kernel/db.tscalls it for databases that already exist. Fresh databases were already created as 0600.file:is no longer in the degraded list.Left out: no periodic re-check while the forge is running. If something re-modes the volume mid-run, vitals will report it and the next boot will fix it.
Try it:
chmod 644 $FORGE_APP_DATA/forge.db, restart, thenstatthe threeforge.db*files. They should be 600, with one warning per file in the log.Closes #3084