carlos / platform Public

census: db-region-forward-2 overlay (PROPOSED), 9B8 entries (plan 2, Task 14)

Loaded last, after db-region-forward-1. Seal fc738548... to ca596f96...
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 813f1ef5dc3745b1a3843895d9b6496ca3c18358 parent 425a168
5 files changed, +148 −1
  • docs/superpowers/notes/census-proposal-db-region-forward-2.md +79 −0
  • internal/provision/db_region_forward_2_census_test.go +32 −0
  • internal/provision/plan14_root_reads_test.go +18 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-db-region-forward-2.tsv +18 −0
diff --git a/docs/superpowers/notes/census-proposal-db-region-forward-2.md b/docs/superpowers/notes/census-proposal-db-region-forward-2.md
new file mode 100644
index 000000000..6fb2edfe3
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-db-region-forward-2.md
@@ -0,0 +1,79 @@
+# Census: db region forward, plan 2 (the console and CLI for `carlos db query` and `query --at`)
+
+Status: PROPOSED, for the census owner's ruling on #280. Every row carries
+`rev3=PROPOSED-db-region-forward-2`.
+
+The branch is `db-region-forward-2`, cut from amadan `main` at 13e2f75f
+(plan 1, cd55508a, plus its nudge-flake fix). It builds plan 2 of
+`docs/superpowers/specs/2026-10-22-db-region-forward-design.md` (rev 6):
+the list door's forward marker, the one reads route
+(`POST /api/cli/apps/{account}/{app}/db/{host}/reads`) with its admission
+and its streamed relay of the box's sealed answer, `CARLOS_DB_FORWARD`,
+`console.NewHTTPServer`, the CLI's buffered forwarded query, and the
+`db-reads/` lifecycle rule in the `deployment-buckets` module (prepared, not
+applied). A console with `CARLOS_DB_FORWARD` unset answers byte-identically
+to main.
+
+It adds one root-read overlay,
+`internal/provision/testdata/plan14-root-reads-db-region-forward-2.tsv`,
+loaded last in `TestPlan14RootReadCensus`, after `db-region-forward-1` (the
+overlay main loads last at 13e2f75f). Its record-write entries are layered
+on `dbRegionForward1WriteCensusInventory` in
+`internal/provision/db_region_forward_2_census_test.go`.
+
+## Root reads
+
+Executing identities, named once:
+
+- **the console**: `cmd/console serve` under `console.service`, user
+ `carlos-console`. The root carlos binary does not link `internal/console`.
+- **the CLI**: `carlos db query` on a person's machine, as the person.
+
+The scanner names fewer units than the plan listed. The reads route's own
+units (`handleAPIDBRead`, `admitDBRead`, `streamDBRead`, `dbLineWriter`,
+`dbfCall`, `readDBResult`, `cancelDBRead`, `announceDBRead`, `dbResidency`,
+`dbForwardEvidence`) and `NewHTTPServer` make no read the scanner counts
+(their store calls are `release.Store` methods, the record-write census's
+business), so they have no rows: an inventory row with no scanned read is
+stale. Plan 1's census found the same (its ruling R8).
+
+| unit | change | executing identity | proposed disposition |
+|---|---|---|---|
+| `dbforward.go` `dbQueryForward` | new: reads at most 64 KiB of a refused reads-route answer (`io.ReadAll` over the HTTP response body, not a file) to print the console's sentence | the CLI | legacy, accepted-legacy, J4 (`basis=root-input`, main's footing for `db.go`'s units) |
+| `cmd/console/main.go` `serve` | changed: parses `CARLOS_DB_FORWARD` into `Config.DBForward`; builds its `http.Server` with `console.NewHTTPServer` (the same two timeouts). The same three `/data` literals at the same offsets | the console | re-frozen at main's disposition (`PROPOSED-scan-demand-revival`, `PROPOSED-email-signin`) with this change appended |
+| `internal/console/server.go` `NewServer` | changed: sets the forwarded read's open-read limits (`dbReads`) and timing (`dbf`); no goroutine, no store call. The one data-literal is the logs/data route pattern, moved | the console | re-frozen at main's disposition with this change appended |
+| `internal/dbdoor/client.go` `doorError` | changed: decodes the forward marker's three additive fields beside `error`, from the same bounded 64 KiB read | the CLI | re-frozen at main's `J4` `root-input` with this change appended |
+| `infra/modules/deployment-buckets/main.tf` `external` | changed: the two `db-reads/` lifecycle rules beside `geoip-noncurrent` | an external unit (OpenTofu, applied only on Paul's approval of `docs/superpowers/notes/db-reads-lifecycle-approval.md`) | re-frozen at main's `J4` `root-input` with this change appended |
+
+Envelopes re-pinned: `.`, `cmd/console`, `infra/modules/deployment-buckets`,
+`internal/console`, `internal/dbdoor`, `internal/dbreads`.
+
+Seal: `fc73854854f9e75d122ebd0eacf330d126201aa9d5c4295c634cc1c204a9168d`
+(db-region-forward-1, checked first) to
+`ca596f96df517344fdc64b5833d2476f1ed9b553ea48f51f46d699fb4d33b1a4`.
+
+## Record writes (9B8)
+
+| site | class | why |
+|---|---|---|
+| `internal/console/authcli.go` `Server.registerCLIRoutes` | key-site, re-digested | one more route line: the reads route |
+| `internal/console/server.go` `NewServer` | key-site, re-digested | the read limits and timing set beside the db door's |
+| `internal/console/apidbforward.go` `Server.admitDBRead` | nonrecord, new | `request.json` and the queue entry: conditional creates under `db-reads/` in the deployment bucket |
+| `internal/console/apidbforward.go` `Server.cancelDBRead` | nonrecord, new | `cancel`: a conditional create under `db-reads/` |
+
+No record writer is added and there is no `Delete` site. The serial bump in
+`announceDBRead` goes through `release.BumpSerial`, which the census already
+classifies.
+
+## Claim routes
+
+`route POST /api/cli/apps/{account}/{app}/db/{host}/reads` joins
+`internal/console/testdata/claim-routes.txt`. The claim invariant census
+gets it as a refused fixture: a host-claim console never signs a forwarded
+read (`dbForwardSigner`), so the route reads the record and answers main's
+residency sentence, writing nothing (spec §6, §9.1). Its message is in
+`claimUnsupported` with that reason.
+
+## go.mod
+
+Unchanged.
diff --git a/internal/provision/db_region_forward_2_census_test.go b/internal/provision/db_region_forward_2_census_test.go
new file mode 100644
index 000000000..631db8860
--- /dev/null
+++ b/internal/provision/db_region_forward_2_census_test.go
@@ -0,0 +1,32 @@
+package provision
+
+// Record-write census entries for db region forward plan 2, layered on
+// dbRegionForward1WriteCensusInventory. PROPOSED-db-region-forward-2, asked
+// of the census owner on #280
+// (docs/superpowers/notes/census-proposal-db-region-forward-2.md). The reads
+// route is one more key-site line in registerCLIRoutes, and NewServer sets
+// the forwarded read's limits and timing beside the db door's; the request,
+// the queue entry and cancel are conditional creates under db-reads/ in the
+// deployment bucket (admitDBRead, cancelDBRead), never an instance or
+// sidecar record: nonrecord. There is no Delete site.
+func dbRegionForward2WriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), dbRegionForward1WriteCensusInventory()...)
+ replacements := []censusEntry{
+ {"internal/console/authcli.go", "Server.registerCLIRoutes", "key-site", "lit:instances,lit:sidecars", "35d3200c17e185d556104b3e2662f3ceea3c862b0b4baeeb9c40753db63a7a2e"},
+ {"internal/console/server.go", "NewServer", "key-site", "lit:instances", "7493342296b6dfa6bc6d2e68e3789fad49e400dbb32a012cee09e215089aa473"},
+ {"internal/console/apidbforward.go", "Server.admitDBRead", "nonrecord", "sel:Put", "27cbe008957792627127820cb496cf939c3d546661dd90eed8141653fb185a45"},
+ {"internal/console/apidbforward.go", "Server.cancelDBRead", "nonrecord", "sel:Put", "6d98027ee782321cfbc7cb2c45cf856b959b2c4cd27d95dfbb8a5753fdfbd3a8"},
+ }
+ 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 c1e64fef2..2a0cbb1d0 100644
--- a/internal/provision/plan14_root_reads_test.go
+++ b/internal/provision/plan14_root_reads_test.go
@@ -1342,6 +1342,24 @@ func TestPlan14RootReadCensus(t *testing.T) {
t.Fatal(err)
}
seal = "fc73854854f9e75d122ebd0eacf330d126201aa9d5c4295c634cc1c204a9168d"
+ // Census overlay db-region-forward-2 (db region forward plan 2: the
+ // console and CLI for carlos db query and query --at), loaded last,
+ // after db-region-forward-1. PROPOSED-db-region-forward-2, asked of the
+ // census owner on #280
+ // (docs/superpowers/notes/census-proposal-db-region-forward-2.md). The
+ // CLI's read of a refused reads-route answer (dbforward.go
+ // dbQueryForward) is accepted legacy at J4 as main's db.go units are;
+ // cmd/console serve, NewServer, dbdoor doorError and the
+ // deployment-buckets module are re-frozen at main's disposition with
+ // this branch's change appended. Frozen declarations change, so the
+ // seal moves; db-region-forward-1's 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-2.tsv"), &inv, true); err != nil {
+ t.Fatal(err)
+ }
+ seal = "ca596f96df517344fdc64b5833d2476f1ed9b553ea48f51f46d699fb4d33b1a4"
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 34ddd94bf..b714ac32f 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 := dbRegionForward1WriteCensusInventory()
+ inventory := dbRegionForward2WriteCensusInventory()
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-2.tsv b/internal/provision/testdata/plan14-root-reads-db-region-forward-2.tsv
new file mode 100644
index 000000000..1ac427a1c
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-db-region-forward-2.tsv
@@ -0,0 +1,18 @@
+# Census overlay db-region-forward-2 (db region forward plan 2: the console and CLI for carlos db query and query --at; spec docs/superpowers/specs/2026-10-22-db-region-forward-design.md rev 6, §13), loaded LAST in TestPlan14RootReadCensus, after db-region-forward-1, the overlay main loads last at 13e2f75f. Every row carries rev3=PROPOSED-db-region-forward-2; the ruling is asked of the census owner on #280 (docs/superpowers/notes/census-proposal-db-region-forward-2.md).
+# The scanner names one new read (dbforward.go dbQueryForward, the CLI reading a refused reads-route answer) and four changed legacy units (cmd/console serve, NewServer, dbdoor doorError, the deployment-buckets module). None of the reads route's own units (handleAPIDBRead, admitDBRead, streamDBRead, the line writer, dbfCall, readDBResult, cancelDBRead, announceDBRead, dbResidency, dbForwardEvidence, NewHTTPServer) is named by the scanner, so they have no rows: an inventory row with no scanned read is stale. The changed units are re-frozen at main's disposition with this branch's change appended. Frozen declarations change, so the seal moves; db-region-forward-1's is checked first.
+@legacy d3ce97034a9a2ad5746d1a3cf8b4c4e2f1603b70708f9f8167d1350f58440c92 dbforward.go dbQueryForward legacy accepted-legacy accepted-legacy;rev3=PROPOSED-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 file:ReadAll@1371 f91b8efa4589dda452e7f0afd24ae36ede82d6ca1c2f538d04ae286dd9785f9c
+dbforward.go dbQueryForward legacy accepted-legacy accepted-legacy;rev3=PROPOSED-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 file:ReadAll@1371 f91b8efa4589dda452e7f0afd24ae36ede82d6ca1c2f538d04ae286dd9785f9c
+@legacy 67879a5435dacee9d32e08607fe3c2c6b8be9fa2f81132bf66a3876ab1cdcfee cmd/console/main.go serve legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console service wires the optional callback signer and starts the claim-guarded queue worker. The same three data path literals move; it does not add a privileged reader.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=passes CARLOS_CONSOLE_NAME to NewServer as Config.ConsoleName, the name the console's emails use; the same three /data literals at the same offsets; no read added;rev3=PROPOSED-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=parses CARLOS_DB_FORWARD (dbForward) into Config.DBForward and builds its http.Server with console.NewHTTPServer, the same two timeouts; the same three /data literals at the same offsets; no read added data-literal@4077,data-literal@5178,data-literal@5415 e2c7a3f4e5f6ca220f61c243c48da683ae6ef32dfe46346963e6531510d02f84
+cmd/console/main.go serve legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console service wires the optional callback signer and starts the claim-guarded queue worker. The same three data path literals move; it does not add a privileged reader.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=passes CARLOS_CONSOLE_NAME to NewServer as Config.ConsoleName, the name the console's emails use; the same three /data literals at the same offsets; no read added;rev3=PROPOSED-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=parses CARLOS_DB_FORWARD (dbForward) into Config.DBForward and builds its http.Server with console.NewHTTPServer, the same two timeouts; the same three /data literals at the same offsets; no read added data-literal@4077,data-literal@5178,data-literal@5415 e2c7a3f4e5f6ca220f61c243c48da683ae6ef32dfe46346963e6531510d02f84
+@legacy 8448ea3c95a06a702a6be759bbfb986567e52a29306e75818937bec7c4cc78ed internal/console/server.go NewServer legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console construction adds queue and notification state. The existing logs/data route literal moves; it is not a filesystem read.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets consoleNameCfg from Config.ConsoleName and the challengeSem send bound, and registers the four /auth/email routes; no goroutine; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=PROPOSED-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets the forwarded db read's open-read limits (dbReads, held by each read's request) and its timing (dbf); no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit data-literal@9622 7493342296b6dfa6bc6d2e68e3789fad49e400dbb32a012cee09e215089aa473
+internal/console/server.go NewServer legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console construction adds queue and notification state. The existing logs/data route literal moves; it is not a filesystem read.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets consoleNameCfg from Config.ConsoleName and the challengeSem send bound, and registers the four /auth/email routes; no goroutine; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=PROPOSED-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets the forwarded db read's open-read limits (dbReads, held by each read's request) and its timing (dbf); no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit data-literal@9622 7493342296b6dfa6bc6d2e68e3789fad49e400dbb32a012cee09e215089aa473
+@legacy b9ec7272b4410e0a23099768d93977adafe22a171642422a6e41d49a316ef332 internal/dbdoor/client.go doorError legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-db-region-forward-2;identity=the carlos CLI on a person's machine, as the person;basis=decodes the db region forward marker's three additive fields (forward, region, forward_ops) beside error, from the same bounded 64 KiB read of a refusal body; no read added file:ReadAll@54 ece2358548f5a71233da653f300a0fe02259ba8e6ee8ece13817c9c9de40311a
+internal/dbdoor/client.go doorError legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-db-region-forward-2;identity=the carlos CLI on a person's machine, as the person;basis=decodes the db region forward marker's three additive fields (forward, region, forward_ops) beside error, from the same bounded 64 KiB read of a refusal body; no read added file:ReadAll@54 ece2358548f5a71233da653f300a0fe02259ba8e6ee8ece13817c9c9de40311a
+@legacy a0a9258029ec2d96a4fdbc7d6b5b301fb268186ddb528cd882463e4342aa2fbf infra/modules/deployment-buckets/main.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change file:external@0 a37eced3f29fd23ca8a98192bc1b0cf03cfec3506bd24b7e5a2361bd339fe66a
+infra/modules/deployment-buckets/main.tf external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-db-region-forward-2;basis=the db-reads/ lifecycle rules (db region forward spec §5.7, J4): two rules beside geoip-noncurrent on the deployment bucket's lifecycle configuration, prepared and not applied until Paul approves docs/superpowers/notes/db-reads-lifecycle-approval.md; no read, no IAM change file:external@0 a37eced3f29fd23ca8a98192bc1b0cf03cfec3506bd24b7e5a2361bd339fe66a
+@coverage . c6984920eb0d780daa5b38c27d02687837712d889571317d0079a49518755220
+@coverage cmd/console 1385008c7209c029e8bc8f965a61ccff409bd601b6ca7b371279a28de6354fa8
+@coverage infra/modules/deployment-buckets 5bcd66547eff581fe8d7d6a1b828cb057ecc5aa2cbed728104bc1b0a5e88b8f8
+@coverage internal/console 03f2cec85ec8da130ddf0f2767aaa53268936f501fd282c002543d6dad562c35
+@coverage internal/dbdoor 0a454a4ba2d1c49b6aa73ad2ecbfa63b31e2e5ae8f7e17705760392145fbce34
+@coverage internal/dbreads 90d668e0638c8e4e4d2345deb0204243d8a6e893c8b53d09d0ec0bc25d7d772d