Plan: apply Astra round 1 on the instance usage plan
One P1 (the parity row) and six P2s: the mint switch at the server, an unread history as pending, per-key prefetch bodies, error-returning CLI helpers, three missing witnesses, and the browser form left unchanged. Adds the round 2 brief.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+204
−27
docs/superpowers/plans/2026-11-29-instance-usage.md+87 −27docs/superpowers/plans/CODEX-FINDINGS-instance-usage-plan-R1.md+24 −0docs/superpowers/plans/CODEX-REVIEW-BRIEF-instance-usage-plan-R2.md+93 −0
CI cancelled — superseded by a newer push — run details
CI log
=== gate === go: downloading go1.26.10 (linux/arm64) go version go1.26.10 linux/arm64 opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1 tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz tofu: downloaded, digest verified aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip aws: downloaded, digest verified archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip archive: downloaded, digest verified installed in /tmp/carlos-opentofu-Ohz9DD .amadan/test-gate.sh go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0 go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0 go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5 go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0 go: downloading github.com/aws/smithy-go v1.28.1 go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e go: downloading golang.org/x/net v0.62.0 go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/prometheus/client_golang v1.17.0 go: downloading github.com/aws/aws-sdk-go-v2/service/sns v1.43.0 go: downloading golang.org/x/crypto v0.58.0 go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0 go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0 go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2 go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0 go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1 go: downloading golang.org/x/sys v0.49.0 go: downloading github.com/pion/logging v0.2.4 go: downloading github.com/pion/stun/v3 v3.1.5 go: downloading github.com/pion/turn/v4 v4.1.4 go: downloading github.com/pierrec/lz4/v4 v4.1.22 go: downloading github.com/aws/aws-sdk-go-v2/service/sesv2 v1.66.6 go: downloading github.com/cespare/xxhash/v2 v2.3.0 go: downloading github.com/prometheus/client_model v0.5.0 go: downloading github.com/prometheus/common v0.45.0 go: downloading github.com/prometheus/procfs v0.12.0 go: downloading google.golang.org/protobuf v1.36.10 go: downloading github.com/aws/aws-sdk-go-v2/service/ssm v1.74.0 go: downloading github.com/klauspost/compress v1.20.2 go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 go: downloading github.com/pion/dtls/v3 v3.1.4 go: downloading github.com/pion/transport/v4 v4.0.2 go: downloading github.com/wlynxg/anet v0.0.5 go: downloading golang.org/x/text v0.43.0 go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/klauspost/compress v1.20.2 go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0 go: downloading github.com/pierrec/lz4/v4 v4.1.22 go: downloading modernc.org/libc v1.74.1 go: downloading modernc.org/libc v1.74.1 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading modernc.org/mathutil v1.7.1 amadan: job cancelled — a newer push superseded it
Intent
diff --git a/docs/superpowers/plans/2026-11-29-instance-usage.md b/docs/superpowers/plans/2026-11-29-instance-usage.md| index a94e86785..502244428 100644 |
| --- a/docs/superpowers/plans/2026-11-29-instance-usage.md |
| +++ b/docs/superpowers/plans/2026-11-29-instance-usage.md |
| @@ -93,10 +93,10 @@ the spec's. Discussion: carlos/platform #1519. |
| | `internal/console/usagefrom.go` (new) | `@from`: write, hold, move on a break | |
| | `internal/console/apiusage.go` (new) | The route, its memo, its reads | |
| | `internal/console/usagedays.go` | `usageDayDate` learns the new family | |
| -| `internal/console/routedecls.go`, `config.go`, `cmd/console/main.go` | Switch, gate, door | |
| +| `internal/console/routedecls.go`, `server.go` (`Config`), `cmd/console/main.go` | Switch, gate, door | |
| | `internal/console/svcprincipal.go`, `apiservices.go`, `svcpage.go` | Mint and resolve rules for `usage` | |
| | `usage_cmd.go` (new), `commands.go` | `carlos usage` | |
| -| `parity/parity.tsv`, `parity/cli.tsv`, `docs/site/cli.md` | Parity row, CLI heading | |
| +| `parity/parity.tsv`, `parity/packages.tsv`, `parity/cli.tsv`, `docs/site/cli.md` | Parity row and its work package, CLI heading | |
| --- |
| @@ -109,7 +109,11 @@ The CLI's human output and the route's error sentences are user-facing |
| rows; a past month; no traffic yet; before `from`; history not active; |
| check pending; over the cap. Lead with the state (the app, the month, the |
| total), then the table. Check it at 80 columns. |
| -- [ ] **Step 2: Luna copy review.** Send every string (CLI output, CLI usage |
| + The browser services form does not change visibly: it never lists |
| + the usage role (Task 5), so there is no console screen to pass. |
| +- [ ] **Step 2: Luna copy review.** (The controller's brief, from the |
| + coordinator for Paul, sends copy to Luna; that is the copy gate here.) |
| + Send every string (CLI output, CLI usage |
| text, the route's 400/409/503 messages, the `docs/site/cli.md` section, |
| the mint refusals for `--role usage`) to Luna |
| (`codex exec -m gpt-6-luna ...`). Record the approved strings in |
| @@ -240,6 +244,11 @@ decide it once beside the synthetic route (`assetcatch.go:1159`). |
| under that host; a far alias delivery (request host != `a.Primary`) is |
| under the request host in `Rows` and `""` in `Instances`; a block with |
| `Primary == ""` is `""`. |
| + `TestDomainMovedMidHourSplitsAtCountTime` (edge level, the alias test |
| + harness in `internal/edge`): a custom domain attached to instance A is |
| + requested at 10:10, re-attached to instance B, requested at 10:40; the |
| + drain has one bucket under A's host and one under B's, same hour, and |
| + the old `Rows` keep keying by each served route's host as today. |
| - [ ] **Step 3: Race (T13)** `TestRecordConcurrentDrain`: 8 goroutines |
| Record while one drains in a loop; total requests across drains equals |
| the number recorded, for both maps. Started with `goTracked`-style |
| @@ -329,6 +338,10 @@ pattern the builder already uses for agent-side counters). |
| counted, the batch's other objects written, queue empties. |
| - `TestInstanceFlushSpanningResponse` (T6): one exchange recorded at |
| 00:00:05Z (started before midnight) is wholly in the new day. |
| + - `TestInstanceFlushAppsApart` (T9): one batch with apps P and Q on |
| + the same box and date writes two objects; P's holds only P's hosts, |
| + and a later batch with only Q's traffic leaves P's object's bytes |
| + unchanged. |
| - `TestInstanceFlushOffSwitch`: `usageFlush` with a nil flusher writes no |
| `usage/instances/` key and the same `usage/edge/` bytes. |
| - [ ] **Step 2: Randomized simulation (T5)** `TestInstanceFlushSimulation`: |
| @@ -374,7 +387,7 @@ pattern the builder already uses for agent-side counters). |
| ### Task 5: The switch, the role and the door's registration (Opus; per-task Astra review: security gate) |
| **Files:** Modify `internal/svcrole/svcrole.go` (+ tests), |
| -`internal/console/config.go` (Config field), `cmd/console/main.go` |
| +`internal/console/server.go` (Config field), `cmd/console/main.go` |
| (env), `internal/console/routedecls.go` (gate + declaration), |
| `internal/console/svcprincipal.go` (mint and resolve), `apiservices.go`, |
| `svcpage.go`, `services.go` (`roleNames` reads `svcrole.All()` already), |
| @@ -389,7 +402,7 @@ Usage Role = "usage" // catalogue order: after Platform, before Admin |
| // Allow panics on Usage, as on Run and Platform. |
| // console |
| -Config.InstanceUsage bool // CONSOLE_INSTANCE_USAGE == "true" |
| +Config.InstanceUsage bool // in server.go; CONSOLE_INSTANCE_USAGE == "true" |
| var gateInstanceUsage = &routeGate{"instance-usage", func(c Config) bool { return c.InstanceUsage }} // added to routeGates |
| {Pattern: "GET /api/cli/apps/{account}/{app}/usage", Kind: kindCLI, Gate: gateInstanceUsage, |
| Allow: svcrole.Exactly(svcrole.Usage, svcrole.Instance, svcrole.Operate, svcrole.Admin), |
| @@ -397,13 +410,23 @@ var gateInstanceUsage = &routeGate{"instance-usage", func(c Config) bool { retur |
| var ErrAccountScopedUsage, ErrUsageOff error // mint refusals, Task 0 copy |
| ``` |
| -Mint (the shared mint in `svcprincipal.go` ~455, so CLI and browser both |
| -get it): `Usage` with no app is `ErrAccountScopedUsage`; `Usage` with |
| -`!cfg.InstanceUsage` is `ErrUsageOff`. Resolve (~195): a `usage` row with |
| -no app fails closed (the Run rule's twin). `svcpage.go`: the role list |
| -skips `usage` while the switch is off; its refusal for a usage mint with |
| -no app uses the Task 0 sentence. `platform_credentials.go` must not mint |
| -it (check its allow-list; add a test if it is not already closed). |
| +Mint, in two places because the store has no config: |
| + |
| +- The store's mint (`claimRawNewServicePrincipalScoped`, |
| + `svcprincipal.go` ~430) keeps the app rule, the authority both doors |
| + share: `Usage` with no app is `ErrAccountScopedUsage`. |
| +- The switch is a server check, `func (s *Server) usageMintRefusal(role svcrole.Role) error` |
| + (returns `ErrUsageOff` for `Usage` while `!s.cfg.InstanceUsage`, nil |
| + otherwise), called by BOTH mint handlers before the store: the API door |
| + (`apiservices.go`) answers it as its other mint refusals, and the |
| + browser POST (`svcpage.go`) with the G2 sentence. |
| + |
| +Resolve (~195): a `usage` row with no app fails closed (the Run rule's |
| +twin). `svcpage.go`: the form's role list always skips `usage`, as it |
| +skips `platform` (usage credentials are minted with `carlos services`); |
| +a hand-made POST with `role=usage` still meets both checks above, with |
| +the G1 and G2 sentences. `platform_credentials.go` must not mint it |
| +(check its allow-list; add a test if it is not already closed). |
| - [ ] **Step 1: Failing tests:** |
| - svcrole: `TestAllowPanicsOnUsage`; `All()` includes `usage`; |
| @@ -417,11 +440,13 @@ it (check its allow-list; add a test if it is not already closed). |
| credential (extend the existing per-role loops to include `usage`). |
| - `TestUsageRouteGatedBySwitch`: switch off, the route 404s for a member; |
| on, it is registered. |
| - - `TestMintUsage`: no app refused; switch off refused; on with an app |
| + - `TestMintUsage`: no app refused; switch off refused, through the API |
| + door AND a direct browser POST (`role=usage`); on with an app |
| minted, and the credential reaches the usage door for its app only |
| (another app 404, byte-identical to an unknown app); its `doors` list |
| is exactly the usage door. |
| - `TestResolveUsageWithoutAppFailsClosed`. |
| + - `TestServicesFormNeverListsUsage` (switch on and off). |
| - `cmd/console`: `CONSOLE_INSTANCE_USAGE=true` sets the field; anything |
| else leaves it false. |
| - [ ] **Step 2: Run** `go test ./internal/svcrole ./internal/console ./cmd/console -run 'Usage|InstanceRole|Allow|Exactly|DoorIntent' -count=1`: FAIL. |
| @@ -440,7 +465,7 @@ it (check its allow-list; add a test if it is not already closed). |
| **Interfaces — Consumes:** Task 1 (`InstanceFrom`, `InstanceFromKey`, |
| `InstancesPrefix`, `ParseInstanceDayKey`, `DecodeInstanceDay`), Task 5 |
| (door, `Config.InstanceUsage`), `s.hostsCached()`, `s.usageDayReader(now)`, |
| -`readConcurrently`, `instanceGate`. **Produces:** |
| +`readConcurrentlyStatsFor`, `instanceGate`. **Produces:** |
| ```go |
| type usageFromVerdict struct { |
| @@ -470,10 +495,10 @@ const usageMemoTTL = time.Minute |
| `usageFromCheck` (spec §4), from the held state, never re-reading the |
| history: |
| -1. `st, verified := s.hostsCached()`. `s.cfg.HostClaim`, or `st.Mode` not |
| - active (incomplete, invalidated, or unread `""` after a failed read) is |
| - 409 "history not active". Active and `!verified` is 503 (pending), and |
| - touches nothing. |
| +1. `st, verified := s.hostsCached()`. `s.cfg.HostClaim`, or `st.Mode` |
| + incomplete or invalidated, is 409 "history not active". `st.Mode == ""` |
| + (unread: the start-up read failed and `LoadHostsMode` is retrying) and |
| + active-but-`!verified` are both 503 (pending), and touch nothing. |
| 2. Active and verified: if the held `@from` has `Activation.Equal(st.At)`, |
| ok. Otherwise read `InstanceFromKey`. Absent: create-only Put |
| `{From: firstOfNextMonth(now), Activation: st.At}`; on CAS conflict |
| @@ -494,7 +519,11 @@ past step 2, but a month whose start is before `From` is 409 with body |
| a plain key segment); for each box and each date from |
| `max(monthStart, From)` to `min(monthEnd - 1 day, today UTC)`, Get |
| `InstanceDayKey(box, date, acct.Sqid, app)` through |
| - `s.usageDayReader(now)` inside `readConcurrently`. |
| + `s.usageDayReader(now)` inside `readConcurrentlyStatsFor`, with a |
| + per-key dry body: the smallest valid `InstanceDay` for that key (v 1, |
| + its box, date, account and app, empty maps), as |
| + `readEdgesSnapshotConcurrently` does with `edgesDryBody` |
| + (`hotreads.go` ~405). Real bodies are still decoded with the key check. |
| - Absent: nothing. Any other error, a decode or key failure, or over the |
| read cap: the whole answer is 503 with `Retry-After: 60`, logged. |
| - Sum per host over boxes and dates; `""` is `unattributed`; `total` is |
| @@ -512,7 +541,13 @@ it as it keeps the others. |
| a pending-then-verified check leaves an existing `@from` unchanged; |
| a held state with a new `At` moves `From` to the month after now, never |
| back (old From later than that stays); two servers racing the create: |
| - one Put wins, both hold the same body (Review Focus 5). |
| + one Put wins, both hold the same body (Review Focus 5); |
| + `TestUsageFromUnreadIsPending`: the start-up read fails (mode `""`), the |
| + route is 503 and `@from` untouched; the read then succeeds and the check |
| + verifies: the existing `@from` is held unchanged; |
| + `TestUsageFromSelfInvalidation`: with `@from` held, `s.invalidateHosts` |
| + makes the route 409; a restart (`s.hosts.reset()`) reading active with a |
| + new `At` and verifying moves `From` to the month after now. |
| - [ ] **Step 2: Failing tests (T8)** `apiusage_test.go`: |
| `TestUsageMemoKeyedByAccount` (same app name in two accounts, two |
| answers); `TestUsagePendingAndBreakOnMemoHit` (after a 200, flip to |
| @@ -528,6 +563,9 @@ it as it keeps the others. |
| instance's host still listed, `""` in `unattributed`, `total` = both, |
| sorted); `TestUsagePreFromObjectsIgnored` (objects dated before `From` |
| on the same boxes never counted); `TestUsageLateWriteAfterSettle` |
| + `TestUsagePrefetchesEveryKey` (two boxes, three dates: the dry pass |
| + accepts every per-key body and the real reads are concurrent, per the |
| + prefetch stats; a real body naming another box is still a 503); |
| (Review Focus 4: a settled date read, then rewritten with more bytes; |
| same answer until the cache entry is `usageDayMaxAge` old, then the new |
| total, never the sum of both); `TestUsageDayDateKnowsInstances`. |
| @@ -548,10 +586,13 @@ it as it keeps the others. |
| its 409 `first_month` body. **Produces:** `rawErr("usage", cust, runUsage)`; |
| `func runUsage(args []string) error`. |
| -Flags: `--app`, `--month YYYY-MM`, `--account`, `--account-id`, `--console`, |
| -`--json` (the analytics command's helpers: `appFlag`, `consoleOption`, |
| -`requireAPISession`, `resolvedAccount`, `resolvedApp`; the session's GET |
| -helper). `--json` prints the route's body as received. Human output: the |
| +Flags: `--app` (required), `--month YYYY-MM`, `--account`, `--account-id`, |
| +`--console`, `--json`, on a `flag.ContinueOnError` FlagSet. Every helper |
| +must return an error: NOT `requireAPISession`, `resolvedAccount` or |
| +`resolvedApp`, which `log.Fatal`. Follow `release_pull.go` (~60-80): |
| +`resolveMode(consoleFlag)` (nil session is an error: API mode only), |
| +`apiAccount(acctRaw, acctIDRaw)`, and `sess.defaultAccount(ctx)` when no |
| +account is given; the session's `getJSON`. `--json` prints the route's body as received. Human output: the |
| Task 0 approved layout, bytes through the root package's existing |
| human-bytes formatter. A 409 with `first_month` prints the approved |
| "counting starts" line and exits 0; other non-2xx return an error with the |
| @@ -562,11 +603,15 @@ route's message. |
| totals line); `TestUsageJSONPassThrough`; `TestUsageBeforeStart` (409 |
| with `first_month` = `2027-01` prints the approved line); |
| `TestUsageRefusesBadMonth` (`--month 2027-1` errors before any request); |
| + `TestUsageErrorsReturn` (no `--app`, no session, an unknown flag, a |
| + default-account failure: each a returned error, no exit); |
| `approved_usage_copy_test.go` pins every approved string. |
| - [ ] **Step 2: Run** `go test . -run 'Usage|Parity|DocSite' -count=1`: FAIL. |
| -- [ ] **Step 3: Implement;** add the parity row |
| - (`usage observe gap usage GET /api/cli/apps/{account}/{app}/usage` with |
| - the note "A console view is later.", matching the table's columns); |
| +- [ ] **Step 3: Implement;** add the parity row in the observe block, |
| + CLI side only (API routes are never console members): |
| + `usage observe gap usage wp-instance-usage Bytes per instance; a console view is later.` |
| + and its package in `parity/packages.tsv`: |
| + `wp-instance-usage Usage by instance in the console ` (discussion empty); |
| `make parity-doc`; the cli.md section (approved copy). |
| - [ ] **Step 4: Run** `go test . ./internal/docsite -run 'Usage|Parity|CLI|DocSite' -count=1`: PASS. |
| - [ ] **Step 5: Commit** `cli: carlos usage, an app's bytes per instance this month`. |
| @@ -611,3 +656,18 @@ exported test seam. |
| - [ ] **Step 2:** Apply P2s; P3s to a follow-up list on the branch. |
| - [ ] **Step 3:** CI green on the tip; `amadan branch describe`; status on |
| #1519; report to the coordinator. No merge. |
| + |
| +## Review history |
| + |
| +**Round 1** (Astra, on `971f8bf03`, `CODEX-FINDINGS-instance-usage-plan-R1.md`): |
| +NOT READY, one P1 and six P2. Resolved in this revision: |
| + |
| +| Finding | Fault family | Resolution | |
| +|---|---|---| |
| +| 1 P1, the parity row breaks the parity rules | Parity-table validity | CLI side only, package `wp-instance-usage` added (Task 7) | |
| +| 2 P2, the store's mint cannot see the switch | Mint switch enforcement | App rule in the store; switch in `usageMintRefusal`, called by both handlers; tested on both doors; `Config` is in `server.go` (Task 5) | |
| +| 3 P2, an unread history read as a break | Unavailable vs broken history | Mode `""` is 503 and touches nothing; witness added (Task 6) | |
| +| 4 P2, one dry body for many keys | Prefetch discovery and key validation | `readConcurrentlyStatsFor` with a per-key dry body; witness added (Task 6) | |
| +| 5 P2, CLI helpers that `log.Fatal` | CLI error propagation | `release_pull.go`'s error-returning helpers, `ContinueOnError`; witness added (Task 7) | |
| +| 6 P2, missing witnesses T9, T11, T7 | Required regression coverage | `TestInstanceFlushAppsApart`, `TestDomainMovedMidHourSplitsAtCountTime`, `TestUsageFromSelfInvalidation` | |
| +| 7 P2, browser UX and user copy review | User-facing review gates | The form never lists `usage`, so no screen changes; the copy gate is Luna, as the controller's brief from the coordinator directs (declined in part) | |
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-instance-usage-plan-R1.md b/docs/superpowers/plans/CODEX-FINDINGS-instance-usage-plan-R1.md| new file mode 100644 |
| index 000000000..2c6e934e2 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-FINDINGS-instance-usage-plan-R1.md |
| @@ -0,0 +1,24 @@ |
| +Reviewed commit `971f8bf03fcf73ab248fe5f901e3e776d46cec34`. One P1 and six P2 findings. No files changed or test suites run. |
| + |
| +1. **P1 — Task 7: the prescribed parity row fails existing tests.** |
| + [Plan:567](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:567) puts both `usage` and its API route on a `gap` row, without a work package. A gap must have exactly one populated side and a known package ([rules.go:141](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/parity/rules.go:141)). API routes are also explicitly forbidden as console members ([parity_test.go:41](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/parity_test.go:41)). Implementing that row therefore fails both parity checks. **Fix:** retain `gap`, populate only the CLI column, and name a registered work package for the later console view. **Fault family:** parity-table validity. |
| + |
| +2. **P2 — Task 5: the shared mint cannot access the proposed switch.** |
| + [Plan:400](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:400) places the `!cfg.InstanceUsage` refusal in the shared mint. That function is a `*Store` method with no configuration argument ([svcprincipal.go:430](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/svcprincipal.go:430)); `Store` has no `cfg` field ([store.go:45](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/store.go:45)). The plan leaves the switch’s path to this authority check undefined. Hiding the browser option alone would still permit a direct POST. **Fix:** specify a shared server-level switch check used by both handlers, while retaining app-binding validation in the store, or explicitly wire the switch into the mint interface. Test both POST paths with the switch off. Also correct the file list: `Config` lives in [server.go:535](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/server.go:535), not `internal/console/config.go`. **Fault family:** mint switch enforcement. |
| + |
| +3. **P2 — Task 6: a failed initial history read is misclassified as a break.** |
| + [Plan:473](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:473) explicitly returns 409 for unread mode `""`. After an initial store-read failure, `LoadHostsMode` starts a background retry and leaves precisely that state ([hostsused.go:150](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/hostsused.go:150)). This is pending verification, not evidence of invalidation; the spec requires 503 while retrying. **Fix:** return 503 with `Retry-After: 60` for unread state, leave `@from` untouched, and test initial read failure followed by successful verification against an existing `@from`. **Fault family:** distinguishing unavailable history from broken history. |
| + |
| +4. **P2 — Task 6: the chosen concurrency helper cannot supply valid dry bodies for this decoder.** |
| + [Plan:493](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:493) specifies `readConcurrently`, while decoding must reject bodies that do not match each object’s key. That helper supplies one fixed dry body and requires the reader to accept it ([hotreads.go:314](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/hotreads.go:314)). Across multiple dates or boxes, the dry pass consequently stops on a mismatch; remaining real reads fall back to serial fetching ([hotreads.go:213](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/hotreads.go:213)). **Fix:** specify `readConcurrentlyStatsFor` with a per-key valid empty `InstanceDay`, following [the edges reader:413](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/internal/console/hotreads.go:413). Test that multiple keys are prefetched without weakening real-body validation. **Fault family:** prefetch discovery and key validation. |
| + |
| +5. **P2 — Task 7: the named CLI helpers terminate instead of returning errors.** |
| + [Plan:551](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:551) directs `runUsage` to use `requireAPISession`, `resolvedAccount` and `resolvedApp`. These call `log.Fatal` on failures ([instances_cli.go:312](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/instances_cli.go:312), [apimode.go:701](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/apimode.go:701), [apimode.go:721](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/apimode.go:721)). Session or default-resolution failures would exit the process despite the new command’s error-returning contract. **Fix:** specify error-returning resolution helpers and `flag.ContinueOnError`; test those failure paths through `runUsage`. **Fault family:** CLI error propagation. |
| + |
| +6. **P2 — Tasks 1, 2 and 6: several explicitly required witnesses are missing.** |
| + The planned tests cover object sizing, owner changes and changed activation timestamps, but omit T9’s other-app isolation, T11’s domain move within an hour, and T7’s actual self-invalidation/recovery path. Compare [Task 1:190](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:190), [Task 2:228](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:228) and [Task 6:508](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:508) with [spec T7–T11:517](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/specs/2026-11-29-instance-usage-design.md:517). Those regressions could pass every named test. **Fix:** add explicit witnesses for all three, including restart/reactivation after `invalidateHosts`. **Fault family:** required regression coverage. |
| + |
| +7. **P2 — Task 0: copy approval and browser UX coverage are incomplete.** |
| + [Plan:108](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/docs/superpowers/plans/2026-11-29-instance-usage.md:108) reviews terminal output and treats Luna’s strings as approved, although Task 5 changes the browser services form. [AGENTS.md:422](/home/paulca/.paseo/worktrees/03ai90xp/instance-usage/AGENTS.md:422) requires the browser UX pass in the kit at mobile/desktop widths and both themes. The applicable [copy-review skill:8](/home/paulca/.agents/skills/copy-review/SKILL.md:8) says, “The user reviews and rewrites every user-facing string before it ships.” Luna review alone does not satisfy that gate. **Fix:** include the services form’s usage-role and refusal states in the UX pass, then obtain user copy review before pinning the approved strings. **Fault family:** user-facing review gates. |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/plans/CODEX-REVIEW-BRIEF-instance-usage-plan-R2.md b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-instance-usage-plan-R2.md| new file mode 100644 |
| index 000000000..35c0b8c43 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-instance-usage-plan-R2.md |
| @@ -0,0 +1,93 @@ |
| +# Review brief: instance usage implementation plan, round 2 of 3 |
| + |
| +Repo carlos/platform, branch `instance-usage`, commit <see the prompt>. |
| +Under review: `docs/superpowers/plans/2026-11-29-instance-usage.md`. |
| +Authorities: `docs/superpowers/specs/2026-11-29-instance-usage-design.md` |
| +(revision 5, merged on main as 96731431a; reviewed in three Astra rounds, |
| +review closed) and AGENTS.md. Do not review against unmerged branches; if |
| +this work needs one, say so as a P1 and stop. |
| + |
| +You are an independent reviewer. Read the plan, then the spec and the code |
| +it names, and check every claim against that code. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul's ruling (spec §2, posted on discussion #1519, 2026-11-29): cut |
| + completeness. The route returns bytes counted so far as a lower bound, |
| + no complete claim, no partial=1, counting valid from the first whole UTC |
| + month after switch-on, one file per app. Report only mechanisms that fail |
| + to honour it. |
| +- The spec's design (identity = instance hostname, the family's keys, the |
| + role shape, the route's shape) is reviewed and closed. Review whether the |
| + PLAN implements it faithfully and buildably, not the design itself. |
| + |
| +## What to check |
| + |
| +1. Spec coverage: every requirement R1-R7, decision D1-D8 and test T1-T13 |
| + has a task that implements and tests it. |
| +2. Exactly-once (spec §5): does Task 3's queue algorithm and `writePart` |
| + guarantee at most once per batch and object, at least once while queued, |
| + ordering per object, markers kept forever, and the drop horizon as a |
| + limit on starting writes? Name any interleaving that double counts. |
| +3. `@from` (spec §4, Task 6): does `usageFromCheck` move `from` only on a |
| + real break and only forward, leave it untouched on a pending or retried |
| + start-up check, and read the console's hostname history correctly |
| + (`internal/console/hostsused.go` `hostsCached`, `hostsActive`, |
| + `invalidateHosts`, `provision.HostsState.At`)? Is `RunUsageFrom` enough |
| + to write `@from` on switch-on day with no route call? |
| +4. Authority (Task 5): is the usage role truly confined to one door, and is |
| + every mint path (CLI services door, browser services page, platform |
| + credentials) covered? Check `internal/svcrole/svcrole.go`, |
| + `internal/console/svcprincipal.go`, `apiservices.go`, `svcpage.go`, |
| + `platform_credentials.go`, `svcroutes_test.go`. |
| +5. The meter (Task 2): the three callers (`internal/edge/edge.go` ~2771, |
| + `demo_traffic.go` ~217, `assetcatch.go` ~1159-1177), the far catch's |
| + primary rule, and that the old `usage/edge/` family is byte-identical. |
| +6. The cache (`internal/console/usagedays.go`): is the plan's change to |
| + `usageDayDate` and the route's use of `usageDayReader` correct for keys |
| + whose last segment is not a date? |
| +7. Buildability: names, signatures and file paths that do not exist or |
| + conflict with the code; tests that cannot be written as described; |
| + AGENTS.md rules (census, parity, docsite, code health, race, copy). |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: round 1, `docs/superpowers/plans/CODEX-FINDINGS-instance-usage-plan-R1.md` |
| +(one P1, six P2). The plan's "Review history" section says how each was |
| +handled. Finding 7's call for the user's own copy review is declined: the |
| +operator's brief for this branch names Luna (gpt-6-luna) as the copy |
| +gate; raise it again only with new evidence. |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or |
| +not. Carry every unresolved or partly resolved finding forward at its |
| +current severity, then add new findings. The verdict covers everything |
| +outstanding, earlier rounds included. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. |