carlos / platform Public

db forward plan 3: census overlay (PROPOSED), 9B8 layer, test weights

The root-read overlay plan14-root-reads-db-region-forward-3 loads last,
after static-redirects: the worker's holdAndSend and verifyLTX and the
CLI's dbPullForward, fileSink.chunk and openDBPull at J4; ServeWorker and
dbQueryForward re-frozen with the pull appended; four envelopes re-pinned;
seal 6efe4eab. 9B8: admitDBRead re-digested, still nonrecord. Every row
rev3=PROPOSED-db-region-forward-3, for the census owner on #280.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev cc77ca956c667f7b25dd34ab6c2fca8ab8147288 parent 8fc3789
6 files changed, +132 −1
  • .amadan/test-weights.tsv +4 −0
  • docs/superpowers/notes/census-proposal-db-region-forward-3.md +62 −0
  • internal/provision/db_region_forward_3_census_test.go +28 −0
  • internal/provision/plan14_root_reads_test.go +17 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-db-region-forward-3.tsv +20 −0

CI passed — run details

diff --git a/.amadan/test-weights.tsv b/.amadan/test-weights.tsv
index 5a4a098fc..6241b5499 100644
--- a/.amadan/test-weights.tsv
+++ b/.amadan/test-weights.tsv
@@ -10,6 +10,7 @@ github.com/carlosframework/platform/internal/console TestClaimDeleteRetryWhilePa
github.com/carlosframework/platform/internal/console TestClaimProbeRunnerDetectsAHollowRequest 3.2
github.com/carlosframework/platform/internal/console TestDBReadEachTenantGetsItsOwnRows 3.2
github.com/carlosframework/platform/internal/console TestDBReadSlowRelayEndsAtTheBound 3.0
+github.com/carlosframework/platform/internal/console TestDBReadPullStreamsTheFiles 2.8
github.com/carlosframework/platform/internal/console TestClaimPurgeMailRecordRefusesBeforeEffects 2.5
github.com/carlosframework/platform/internal/console TestDBReadStalledStoreKeepsTheStreamAndItsBound 2.5
github.com/carlosframework/platform/internal/console TestDBReadEndedDuringAdmissionWritesOnlyTheCancel 2.4
@@ -39,6 +40,9 @@ github.com/carlosframework/platform/internal/console TestDBReadRequestBoundClamp
github.com/carlosframework/platform TestDBForwardPrintsNothingForABadAnswer 67.0
github.com/carlosframework/platform TestDBForwardLongRequestThroughTheEdge 44.5
github.com/carlosframework/platform TestDBForwardThroughTheBackhaulHop 44.1
+github.com/carlosframework/platform TestDBForwardPullParityThroughTheCLI 4.8
github.com/carlosframework/platform TestDBForwardParityThroughTheCLI 4.6
+github.com/carlosframework/platform TestDBForwardPullInterruptedLeavesNothing 2.1
github.com/carlosframework/platform TestDBForwardMixedVersions 1.9
+github.com/carlosframework/platform TestDBForwardPullSavesNothingForABadAnswer 1.8
github.com/carlosframework/platform TestDBForwardRefusesSQLThatIsNotUTF8 1.0
diff --git a/docs/superpowers/notes/census-proposal-db-region-forward-3.md b/docs/superpowers/notes/census-proposal-db-region-forward-3.md
new file mode 100644
index 000000000..65e980eb8
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-db-region-forward-3.md
@@ -0,0 +1,62 @@
+# Census: db region forward, plan 3 (`carlos db pull` and `pull --at` for an instance in another region)
+
+Status: PROPOSED. Every row carries `rev3=PROPOSED-db-region-forward-3`; the
+ruling, `census-ruling-db-region-forward-3`, is asked of the census owner on
+#280.
+
+The branch is `db-region-forward-3`, cut from amadan `main` at 0d9e81dc. It
+builds plan 3 of `docs/superpowers/specs/2026-10-22-db-region-forward-design.md`
+(rev 7): the box's worker holds a pull's planned LTX files, verifies their
+checksums and sends them back after the agent's check B; the agent seals them
+as the `ltx` stream in 1 MiB chunks, with the plan in the summary; the console
+forwards and audits the new op; the CLI spools the sealed chunks to a private
+directory, checks the file list, the count and the SHA-256, restores locally
+with `dbdoor.RestoreLocal` and saves the copy with today's `copyOut`. The
+box never restores for a pull.
+
+It adds one root-read overlay,
+`internal/provision/testdata/plan14-root-reads-db-region-forward-3.tsv`,
+loaded last in `TestPlan14RootReadCensus`, after `static-redirects` (the
+overlay main loads last at 0d9e81dc). Its record-write entry is layered on
+`plans3aWriteCensusInventory` in
+`internal/provision/db_region_forward_3_census_test.go`.
+
+## Root reads
+
+Executing identities, named once:
+
+- **the worker**: `carlos system db-worker` under `carlos-dbread@.service`, a
+ DynamicUser with no network, its own PrivateTmp, `/data` and `/etc/carlos`
+ hidden.
+- **the CLI**: `carlos db pull` on a person's machine, as the person.
+
+The scanner names no agent, console or host unit: the agent's pull branch in
+`attempt`, `NewAgent`'s `MaxPull`, the console's op check and audit detail,
+and `CARLOS_DB_PULL_MAX_BYTES` in `dbReadsSettings` make no read it counts
+(plan 1's R8 again).
+
+| unit | change | executing identity | proposed disposition |
+|---|---|---|---|
+| `internal/dbreads/worker.go` `holdAndSend` | new: opens each planned LTX file it received and verified, in its own private `/var/tmp`, after check B, and copies it back over its socket | the worker | legacy, accepted-legacy, J4 (`root-input`, as `receiveFile`) |
+| `internal/dbreads/worker.go` `verifyLTX` | new: opens one received LTX file and decodes it whole to check its checksums, before ready | the worker | legacy, accepted-legacy, J4 |
+| `internal/dbreads/worker.go` `ServeWorker` | changed: accepts a pull header and hands it to `holdAndSend` after the same bounded receive; the `Stat` is unchanged | the worker | re-frozen at `census-ruling-db-region-forward-1` with this change appended |
+| `dbforward.go` `dbPullForward` | new: the same bounded 64 KiB read of a refused reads-route answer as `dbQueryForward` (`io.ReadAll` over the response body, not a file); creates and removes the pull's private 0700 directory | the CLI | legacy, accepted-legacy, J4 (main's footing for `db.go`'s units) |
+| `dbforward.go` `fileSink.chunk` | new: reads back one sealed chunk it spooled itself, 0600 in that directory, admitted by the chunk bound before it was written | the CLI | legacy, accepted-legacy, J4 |
+| `dbforward.go` `openDBPull` | new: creates each planned LTX file exclusively (`O_EXCL`, 0600) in that directory, only after the whole file list is checked; then restores, checks and removes them | the CLI | legacy, accepted-legacy, J4 |
+| `dbforward.go` `dbQueryForward` | changed: keeps its chunks in a `memSink` and opens them after `readDBForward` returns the result; the same bounded refusal read | the CLI | re-frozen at `census-ruling-db-region-forward-2` with this change appended |
+
+Envelopes re-pinned: `.`, `internal/console`, `internal/dbreads`,
+`internal/host`. Frozen declarations are added, so the seal moves:
+static-redirects' `65857c29…` is checked first, the new seal is
+`6efe4eab71e7ff5c3de38449d6c8a837ac13ade0f242dfb4094e699e252b1293`.
+
+## Record writes (9B8)
+
+`internal/console/apidbforward.go` `Server.admitDBRead` is re-digested and
+stays `nonrecord`: it admits a pull beside a query and audits it with its own
+detail; its writes are the same conditional creates under `db-reads/` in the
+deployment bucket. No write site is added.
+
+## Unchanged
+
+Claim routes (no new route: a pull uses plan 2's reads route), `go.mod`.
diff --git a/internal/provision/db_region_forward_3_census_test.go b/internal/provision/db_region_forward_3_census_test.go
new file mode 100644
index 000000000..c25308668
--- /dev/null
+++ b/internal/provision/db_region_forward_3_census_test.go
@@ -0,0 +1,28 @@
+package provision
+
+// Record-write census entries for db region forward plan 3 (carlos db
+// pull), layered on plans3aWriteCensusInventory (main's last at 0d9e81dc).
+// PROPOSED-db-region-forward-3, asked of the census owner on #280
+// (docs/superpowers/notes/census-proposal-db-region-forward-3.md).
+// admitDBRead now admits a pull beside a query and audits it with its own
+// detail; its writes are the same conditional creates under db-reads/ in
+// the deployment bucket (the request, the queue entry), never an instance
+// or sidecar record: still nonrecord. No write site is added.
+func dbRegionForward3WriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), plans3aWriteCensusInventory()...)
+ replacements := []censusEntry{
+ {"internal/console/apidbforward.go", "Server.admitDBRead", "nonrecord", "sel:Put", "3f657a9ad3b11512944ad557573bd59adf257e3fd3fe9cad9fc10a974658328b"},
+ }
+ for _, r := range replacements {
+ found := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ entries = append(entries, r)
+ }
+ }
+ return entries
+}
diff --git a/internal/provision/plan14_root_reads_test.go b/internal/provision/plan14_root_reads_test.go
index a38913fe7..681de7f51 100644
--- a/internal/provision/plan14_root_reads_test.go
+++ b/internal/provision/plan14_root_reads_test.go
@@ -1423,6 +1423,23 @@ func TestPlan14RootReadCensus(t *testing.T) {
t.Fatal(err)
}
seal = "65857c29501dc7676f52921bea79d08217542ecb1d775c67d20a3460c851d831"
+ // Census overlay db-region-forward-3 (db region forward plan 3: carlos
+ // db pull and pull --at for an instance in another region), loaded last,
+ // after static-redirects. PROPOSED-db-region-forward-3, asked of the
+ // census owner on #280
+ // (docs/superpowers/notes/census-proposal-db-region-forward-3.md). The
+ // worker's pull units (holdAndSend, verifyLTX) are accepted legacy at J4
+ // inside its sandbox, the CLI's (dbPullForward, fileSink.chunk,
+ // openDBPull) at J4 as the person; ServeWorker and dbQueryForward are
+ // re-frozen with the pull appended. Frozen declarations are added, so
+ // the seal moves; static-redirects' is checked first.
+ if errs := checkRootReadLegacy(inv, seal); len(errs) != 0 {
+ t.Fatal(errs)
+ }
+ if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-db-region-forward-3.tsv"), &inv, true); err != nil {
+ t.Fatal(err)
+ }
+ seal = "6efe4eab71e7ff5c3de38449d6c8a837ac13ade0f242dfb4094e699e252b1293"
errs := append(compareRootReads(got, inv), checkRootReadLegacy(inv, seal)...)
errs = append(errs, checkRootReadDeclarations(got, inv)...)
if len(errs) > 0 {
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 389ad2e5c..525edfb2c 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := plans3aWriteCensusInventory()
+ inventory := dbRegionForward3WriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))
diff --git a/internal/provision/testdata/plan14-root-reads-db-region-forward-3.tsv b/internal/provision/testdata/plan14-root-reads-db-region-forward-3.tsv
new file mode 100644
index 000000000..9f69afe9e
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-db-region-forward-3.tsv
@@ -0,0 +1,20 @@
+# Census overlay db-region-forward-3 (db region forward plan 3: carlos db pull and pull --at for an instance in another region; spec docs/superpowers/specs/2026-10-22-db-region-forward-design.md rev 7, §6, §13), loaded LAST in TestPlan14RootReadCensus, after static-redirects, the overlay main loads last at 0d9e81dc. Every row carries rev3=PROPOSED-db-region-forward-3; the ruling is asked of the census owner on #280 (docs/superpowers/notes/census-proposal-db-region-forward-3.md).
+# The scanner names two new worker units (holdAndSend, verifyLTX: the pull's hold mode, inside the db-read worker's sandbox, over the files the agent sent), three new CLI units (dbPullForward, fileSink.chunk, openDBPull: the pull's spool, its file replica, as the person), and two changed legacy units (ServeWorker, dbQueryForward), re-frozen at their accepted dispositions with plan 3's change appended. No agent, console or host unit is named: the agent's pull, the console's forward of it and CARLOS_DB_PULL_MAX_BYTES add no read the scanner sees. Frozen declarations are added, so the seal moves; static-redirects' is checked first. Envelopes . (the CLI), internal/console, internal/dbreads and internal/host are re-pinned.
+@legacy 02f174af82d98de108a656a2261b87f92eadeed7fce6a5d0ccfac036de88c31f internal/dbreads/worker.go ServeWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-db-region-forward-1;basis=root-input (J4); the db-read worker (carlos system db-worker, carlos-dbread@.service, a DynamicUser with no network, PrivateTmp, /data and /etc/carlos hidden): new, stats the copy it restored in its own private /var/tmp for the restored-size cap; reads only the files the agent sent and its own scratch; round 1: it refuses, before writing anything, a plan whose restored-size cap exceeds its own LimitFSIZE or whose files total more than twice that cap;rev3=PROPOSED-db-region-forward-3;basis=accepts a pull header beside a query's and hands a pull, after the same bounded receive, to holdAndSend before any restore; the Stat is unchanged, now reached by a query only; no read added file:Stat@2768 d4635af9ef7c0ec6f66c5f8a3332ceb652c9215f2fc611d7f885cb661e853f11
+internal/dbreads/worker.go ServeWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-db-region-forward-1;basis=root-input (J4); the db-read worker (carlos system db-worker, carlos-dbread@.service, a DynamicUser with no network, PrivateTmp, /data and /etc/carlos hidden): new, stats the copy it restored in its own private /var/tmp for the restored-size cap; reads only the files the agent sent and its own scratch; round 1: it refuses, before writing anything, a plan whose restored-size cap exceeds its own LimitFSIZE or whose files total more than twice that cap;rev3=PROPOSED-db-region-forward-3;basis=accepts a pull header beside a query's and hands a pull, after the same bounded receive, to holdAndSend before any restore; the Stat is unchanged, now reached by a query only; no read added file:Stat@2768 d4635af9ef7c0ec6f66c5f8a3332ceb652c9215f2fc611d7f885cb661e853f11
+@legacy 68e35c406e1749a6de5685dbea327c426042ed7ffb9866e9e80ed03f87d4f5c3 internal/dbreads/worker.go holdAndSend legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4); the db-read worker (carlos system db-worker, carlos-dbread@.service, a DynamicUser with no network, PrivateTmp, /data and /etc/carlos hidden): new (plan 3, a pull), opens each planned LTX file it received and verified, in its own private /var/tmp, once check B has passed, and copies it back to the agent over its socket; reads only the files the agent sent and its own scratch; decides nothing for root file:Open@934 4ef666b878d68adb0bcd17f359a4e4142681618ee5836d495f3d266e9b4d1e23
+internal/dbreads/worker.go holdAndSend legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4); the db-read worker (carlos system db-worker, carlos-dbread@.service, a DynamicUser with no network, PrivateTmp, /data and /etc/carlos hidden): new (plan 3, a pull), opens each planned LTX file it received and verified, in its own private /var/tmp, once check B has passed, and copies it back to the agent over its socket; reads only the files the agent sent and its own scratch; decides nothing for root file:Open@934 4ef666b878d68adb0bcd17f359a4e4142681618ee5836d495f3d266e9b4d1e23
+@legacy 35856d353c251596e131cc5a7fe821231d0fa5ea3201f83200120b5a0a9b21d6 internal/dbreads/worker.go verifyLTX legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4); the db-read worker (carlos system db-worker, carlos-dbread@.service, a DynamicUser with no network, PrivateTmp, /data and /etc/carlos hidden): new (plan 3, a pull), opens one planned LTX file it received, in its own private /var/tmp, and decodes it whole to check its LTX checksums before ready (the worker's decode of tenant bytes, as its restore is); reads only the files the agent sent and its own scratch file:Open@47 46773a72349f2d6d7c8935c252e9946ee67bb7563d33bbfd714aac52c6dbf66b
+internal/dbreads/worker.go verifyLTX legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4); the db-read worker (carlos system db-worker, carlos-dbread@.service, a DynamicUser with no network, PrivateTmp, /data and /etc/carlos hidden): new (plan 3, a pull), opens one planned LTX file it received, in its own private /var/tmp, and decodes it whole to check its LTX checksums before ready (the worker's decode of tenant bytes, as its restore is); reads only the files the agent sent and its own scratch file:Open@47 46773a72349f2d6d7c8935c252e9946ee67bb7563d33bbfd714aac52c6dbf66b
+@legacy 582d4130f874a145585e8c7abee8c4ead54293b5a32e4bacb1562895f4433fcc dbforward.go dbQueryForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-db-region-forward-2;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new, reads at most 64 KiB of a refused reads-route answer from the console (io.ReadAll over the HTTP response body, not a file) to print the console's own sentence; decides nothing for root;rev3=PROPOSED-db-region-forward-3;basis=keeps its chunks in a memSink and opens them with openDBForward after readDBForward returns the result, the same bytes and checks as before; the same bounded refusal read; no read added file:ReadAll@1371 757573f0b60a4b2e4eafdef63b4d1157363768dcbc9354e1317f52e886394dc8
+dbforward.go dbQueryForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-db-region-forward-2;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new, reads at most 64 KiB of a refused reads-route answer from the console (io.ReadAll over the HTTP response body, not a file) to print the console's own sentence; decides nothing for root;rev3=PROPOSED-db-region-forward-3;basis=keeps its chunks in a memSink and opens them with openDBForward after readDBForward returns the result, the same bytes and checks as before; the same bounded refusal read; no read added file:ReadAll@1371 757573f0b60a4b2e4eafdef63b4d1157363768dcbc9354e1317f52e886394dc8
+@legacy f4ce27cf5207cac6b448fcd23923bda9694cafd2055e26167764547d4a057b88 dbforward.go dbPullForward legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (plan 3), reads at most 64 KiB of a refused reads-route answer from the console (io.ReadAll over the HTTP response body, not a file) to print the console's own sentence, as dbQueryForward does; creates the pull's one private 0700 directory under the system temp dir and removes it on every path but success, where db.go's dbPull removes it after copyOut; decides nothing for root file:ReadAll@939 9f9d794b2d34a5613098f39edc8aa2e1d572a95ef41baa6c621173b3911833d2
+dbforward.go dbPullForward legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (plan 3), reads at most 64 KiB of a refused reads-route answer from the console (io.ReadAll over the HTTP response body, not a file) to print the console's own sentence, as dbQueryForward does; creates the pull's one private 0700 directory under the system temp dir and removes it on every path but success, where db.go's dbPull removes it after copyOut; decides nothing for root file:ReadAll@939 9f9d794b2d34a5613098f39edc8aa2e1d572a95ef41baa6c621173b3911833d2
+@legacy b08da594b8cc5ffff9f892eb77f448c0b150afa83fa88ff0a2987ba0d1c83343 dbforward.go fileSink.chunk legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (plan 3), reads back one sealed chunk it spooled itself, 0600 in the pull's private 0700 directory under the system temp dir, each admitted by the chunk bound before it was written; the bytes open only with the CLI's own ephemeral key; decides nothing for root file:ReadFile@58 6a1f96c3ac25abc41412246cb50d6412d61fd91fcd1e7ba9d8ef6be6c97d6e8b
+dbforward.go fileSink.chunk legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (plan 3), reads back one sealed chunk it spooled itself, 0600 in the pull's private 0700 directory under the system temp dir, each admitted by the chunk bound before it was written; the bytes open only with the CLI's own ephemeral key; decides nothing for root file:ReadFile@58 6a1f96c3ac25abc41412246cb50d6412d61fd91fcd1e7ba9d8ef6be6c97d6e8b
+@legacy 13ff116a4e18fdfd46205a5661add0c97f459e71fdfae2f4f0b936c34a4d6d51 dbforward.go openDBPull legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (plan 3), creates each planned LTX file exclusively (O_EXCL, 0600) as a litestream file replica in the pull's private 0700 directory, only after the summary's whole file list has been checked, from chunks opened with the CLI's own key; then restores and checks them with dbdoor.RestoreLocal and removes them; the count and SHA-256 are checked before the restore; decides nothing for root file:OpenFile@1714 e61aef9e9dba0dff860c5ba8807727ac02ac91860efbf56e8800a1e37bc94465
+dbforward.go openDBPull legacy accepted-legacy accepted-legacy;rev3=PROPOSED-db-region-forward-3;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (plan 3), creates each planned LTX file exclusively (O_EXCL, 0600) as a litestream file replica in the pull's private 0700 directory, only after the summary's whole file list has been checked, from chunks opened with the CLI's own key; then restores and checks them with dbdoor.RestoreLocal and removes them; the count and SHA-256 are checked before the restore; decides nothing for root file:OpenFile@1714 e61aef9e9dba0dff860c5ba8807727ac02ac91860efbf56e8800a1e37bc94465
+@coverage . b50e1f75fab969ae1886b77628bf3dab8bd0640fcd2fbfb0e864626f7b86de64
+@coverage internal/console 26cf0c3057f4df152cb5064ba192263a5d9604f7c17614e4e422927b2bafae09
+@coverage internal/dbreads c1c9a9ab5d1dcf7962f94328fd48bca56208f1342f2689f61f038001b3a7ce9d
+@coverage internal/host 218f8d6a50eb852a22424236fa89427b4b5509e08fd956ce778d95bc5a63c9a0