oficina / equipo Public

S1 progress: the security round; budgets follow measured sizes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c30ba4f14aa646b66e994391e3da2ae5dba04b12 parent 02b73bd
2 files changed, +66 −3
  • .rastrillo/budgets.txt +3 −3
  • docs/superpowers/plans/S1-METERED-PROGRESS.md +63 −0

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 63d2c179..96ebab20 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -34,7 +34,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s;
-size internal/runner/thin 19028 10609 The thin runner: steps, link, coordinator, Mac worker, previews, publication, merges and metered connections. Measured 19028 source and 10609 test lines.
+size internal/runner/thin 19096 10750 The thin runner: steps, link, coordinator, Mac worker, previews, publication, merges and metered connections. Measured 19096 source and 10750 test lines.
time internal/thintest 180s Contract tests for Mac runners, transitions and the thin core share one instance harness; loaded CI needs 180s.
time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s).
@@ -49,7 +49,7 @@ perf GET /api/v1/notebook skip Thin v1 person API: bearer-only JSON for devices;
perf GET /api/v1/thinking skip Thin v1 person API: bearer-only JSON for devices; the browser reads thinking words on /settings/thinking.
perf GET /api/v1/tasks skip Thin v1 person API: bearer-only JSON for devices; the browser reads tasks through /tasks.
perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads a task through /tasks/{id}.
-size internal/equipo/chat 17095 - The instance store: tasks, steps, cards, merge authority, housekeeping, triage, placement and metered connections. Measured 17095 source lines.
+size internal/equipo/chat 17118 - The instance store: tasks, steps, cards, merge authority, housekeeping, triage, placement and metered connections. Measured 17118 source lines.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
@@ -62,5 +62,5 @@ perf GET /conversation/attachments/{id}/preview skip Composer attachments: an im
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
size internal/headless - 9387 End-to-end scenarios through a real runner and instance, plus browser drives. Measured 9387 test lines.
-size internal/thintest - 16982 Thin v1 contract and page tests; one package keeps one instance harness. Measured 16982 test lines.
+size internal/thintest - 17020 Thin v1 contract and page tests; one package keeps one instance harness. Measured 17020 test lines.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
diff --git a/docs/superpowers/plans/S1-METERED-PROGRESS.md b/docs/superpowers/plans/S1-METERED-PROGRESS.md
index 8b5037ba..4158145c 100644
--- a/docs/superpowers/plans/S1-METERED-PROGRESS.md
+++ b/docs/superpowers/plans/S1-METERED-PROGRESS.md
@@ -279,6 +279,69 @@ provider, key or sign-in was used.
- `work.ask.held.spend_unknown`: Waiting: its connection’s spend is unknown. Check it, then Resume
- `chat.connections.metered.key_failed`: That did not go through. Paste the key again.
+## Security round (Astra, read-only, on 789cb8d)
+
+Verdict NOT READY, nine findings, all mechanical; each fixed with a test
+written first and a mutation observed:
+
+1. Admission before registration (`meter.go`): `Meter.Admit` registers
+ the attempt as running before its admission commits, so `Recover`
+ never sees the claim without it.
+ `TestMeteredRecoverBetweenAdmissionAndLaunch` runs `Recover` in the
+ window after the commit.
+2. A repeated holder (`ledger.go`): a holder already claiming the slot
+ gets `Claimed` and a hold, never leave to launch; the Meter refuses a
+ holder already running in its process too.
+ `TestMeteredDuplicateHolderRunsOnce`.
+3. Sign-out during a probe (`apikey.go`): the sign-out retires the
+ connection (nothing more admitted), waits for the slot (proving an
+ ended attempt with `Recover`), so the probe's charge or spend_unknown
+ commits, and `metered.Remove` refuses while the slot is held.
+ `TestMeteredRetireWaitsForTheSlot`, `TestAPIKeySignOutDuringAProbe`.
+4. Frame binding (`apikey.go`, `ledger.go`): API-key homes take a random,
+ never reused name (`tensorx-<12 chars>`); the metered record keeps the
+ instance's connection id; Budget and Resume check the frame id first,
+ then the runner name, the connection id and the person, in one
+ transaction; the ledger's updates name the connection too.
+ `TestMeteredBindingNamesTheConnection`, `TestAPIKeyConnectionRoundTrip`.
+5. The probe's transport (`connect/apikey.go`): `connect.SafeClient`, no
+ ambient proxy, the host resolved once and every answer required to be
+ public (`egress.PublicAddress`, now exported), the connection made to
+ the resolved address, TLS verified for the host name, no redirect
+ followed, answers capped at 1 MiB. `TestAPIClientTransport`; the
+ runner's tests use the same transport with loopback allowed.
+6. The answering model (`connect/apikey.go`): the probe reads the model
+ the provider says answered; another model is `ErrModelMismatch`, no
+ proof, and the usage row is that model's (unpriced: spend unknown).
+ `TestAPIClientModelsAndProbe`, `TestAPIKeyProbeAnsweredByAnotherModel`.
+7. Downgrade (`wire/runners.go`): below 12 an API-key attempt's report
+ (its provider, the `api_key` and `model` prompts, `key_refused`,
+ `no_priced_model`) and a question with a hold reason are refused, not
+ translated. `TestEncodeBelowProtocol12AgainstFrozenSchemas` decodes
+ what is still sent into frozen pre-12 shapes and value sets.
+8. Authority (`chat/metered.go`): `TestMeteredWritesCheckPersonAndRoster`
+ (another person, and a roster check failing between authentication
+ and the write, change nothing) and the contract test's teammate and
+ removed-owner requests.
+9. Audit (`chat/metered.go`): `connection.budget` (id@revision),
+ `connection.resume` (id@pause) and `connection.limit_confirmed` /
+ `connection.payg_off_confirmed` (id@provider) are appended in the
+ write's transaction, credential-free.
+
+Mutations observed:
+
+- F1: the attempt registered as running only after its admission commits -> TestMeteredRecoverBetweenAdmissionAndLaunch (the slot was released between the admission and the launch)
+- F2: the ledger let a claiming holder in again -> TestMeteredDuplicateHolderRunsOnce (a claimed holder admitted again); with the in-process reservation also off, the same holder ran twice
+- F3: a retiring connection admitted with its slot free -> TestMeteredRetireWaitsForTheSlot; Remove with the slot held -> same test (removed with its slot held)
+- F4: budget and Resume not bound to the connection -> TestMeteredBindingNamesTheConnection (another connection's budget applied; its resume consumed)
+- F3 (runner): the sign-out deleted the record without waiting for the slot -> TestAPIKeySignOutDuringAProbe (removed while its probe ran); the sign-out without retiring -> same test (never retiring)
+- F4 (runner): a consumed budget frame applied again -> TestAPIKeyConnectionRoundTrip (budget {4 4 rev 8}); API-key homes from nextHome -> same test (the runner name "tensorx-1" was reused); the runner's binding check alone off -> still held by the ledger's connection check (layered)
+- F5: unsafe answers allowed -> TestAPIClientTransport (link-local dialed); the default transport -> same test; redirects followed -> same test; an ambient proxy -> same test
+- F6: the answering model ignored by the check -> TestAPIClientModelsAndProbe and TestAPIKeyProbeAnsweredByAnotherModel (made a connection on another model's answer); the row priced under the selected model -> TestAPIKeyProbeAnsweredByAnotherModel (no spend unknown)
+- F7: an API-key attempt's report sent below 12 -> TestEncodeBelowProtocol12AgainstFrozenSchemas (a pre-12 instance cannot read a tensorx report); the new reasons sent -> same test (no_priced_model); hold reasons on a failed answer sent -> same test (spend_unknown)
+- F8: connections looked up without the person -> TestMeteredWritesCheckPersonAndRoster (another person's model) and TestContractMeteredConnection (a teammate's model pick: 409); the roster check left out of SetBudget -> TestMeteredWritesCheckPersonAndRoster (a removed person's budget)
+- F9: the budget's or the Resume's audit left out -> TestMeteredWritesCheckPersonAndRoster (audits)
+
## Copy: delegated review (Astra, 2026-11-12)
The 33 strings went through Astra as the copy-review gate (Paul's