usage-attribution-390: Astra review brief, round 1; census overlay
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+131
−0
docs/superpowers/reviews/CODEX-REVIEW-BRIEF-usage-attribution-390.md+131 −0
CI failed — run details
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-usage-attribution-390.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-usage-attribution-390.md| new file mode 100644 |
| index 000000000..42aca29b7 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-usage-attribution-390.md |
| @@ -0,0 +1,131 @@ |
| +# Review brief: branch usage-attribution-390 (#390), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `usage-attribution-390`, commit 902e12c9312e5cfbff3a5a0cf961defd6ce8ef11 (the code; this brief is committed on top). |
| +Under review: the diff `origin/main...usage-attribution-390` (merge base |
| +78c23655). |
| +Authorities, all on main: discussion #390 and its proposal reply |
| +(`AMADAN_HOME=~/.amadan-agent amadan discuss show carlos/platform 390` if you |
| +can reach it; otherwise this brief carries what matters), and |
| +`docs/superpowers/notes/remote-instance-metrics.md` (the box's tenant tag on |
| +live samples). Do not review against unmerged branches. |
| + |
| +You are an independent reviewer. Read the diff, then the code it names, and |
| +check every claim against that code. This is billing code: statements feed |
| +the economics page and the (dormant) plan caps. |
| + |
| +## The change in one paragraph |
| + |
| +Statements (`statementsPass`, hourly, create-or-replace for the month to |
| +date), the census (`censusPass`, daily, create-only), the economics page |
| +(`buildEconomicsView`) and `carlos status --instances` used to attribute |
| +every box's sampled units against the console box's own registry, so an |
| +instance on another box was charged to the ops account, and the month's |
| +re-sweep moved a moved instance's earlier hours to ops. Now |
| +`internal/console/usageattrib.go` attributes each reading: stamped |
| +console-box unit; non-instance unit = platform (ops); live reading tagged by |
| +its box = the tag; the host's instance or sidecar record if it existed when |
| +the hour began (a host some record names is decided by its records alone); |
| +for a host with no record, the sampling box's fresh report, then the console |
| +box's route (console's own box only); otherwise counted against no account |
| +and logged. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul, #390, 2026-10-26: "Build the fix; October self-corrects". No |
| + backfill of stored statements or census days. The first statements pass |
| + after release rewrites the open month. |
| +- Readings whose tenant cannot be established are counted nowhere and |
| + logged, never charged to ops (the brief that started this branch). |
| +- Day rollups carry no tenant tag (remote-instance-metrics note, "Mixed |
| + fleet"), and changing the box to roll tags into hours is out of scope (it |
| + would need a box release). The tag is used only on the live view. |
| +- Cap check done before the switch: on flagship the console has no |
| + `CARLOS_PLAN_CATALOG` or `CARLOS_BILLING` set and no `control/plans.json` |
| + marker exists, so plans are off and no awake-hours cap can trip. |
| + |
| +## What to check |
| + |
| +1. **Attribution key (fault family: tenant identity of usage).** In |
| + `usageAttribution.attribute` and `recordsFor`: can any reading reach an |
| + account that did not run it? Walk: a hostname reused across accounts in |
| + the month (predecessor's record deleted, successor's created); the hour |
| + containing the successor's creation; same-account recreation; a move |
| + (record keeps `created_at`, region changes, the source box drops the |
| + route); a deleted instance; a sidecar's synthetic host |
| + (`provision.SidecarHost`); a record with zero `created_at`; two records |
| + naming one host. |
| +2. **Fallbacks for hosts with no record**: `appFacts.tenantOn` |
| + (`remoteinstances.go`) and the console-box route. They carry no time |
| + bound. Is that an attribution of a sample whose tenant cannot be |
| + established? Say what a bound would need, if anything is possible. |
| +3. **Platform versus instance**: `instanceHost` treats only |
| + `carlos-exec@<host>` and `carlos-app@<host>.service` as instances. |
| + Anything else (including stamped units on other boxes) is platform |
| + overhead, as on main. Is any tenant unit that main attributed correctly |
| + now lost? |
| +4. **Write-pass failure behaviour**: `passAttribution` refuses on a missing |
| + registry or unreadable records; `censusPass` refuses too (create-only). |
| + Unreadable record hosts (`unreadable`) attribute nothing. Is there a |
| + path that writes a statement or census day from a partial read? |
| +5. **Census**: records (minus Trash and customer-fleet placements) plus |
| + console-box routes no record covers, one per host. Does this over- or |
| + under-count `apps` (feeds `app_months`) against what main intended? |
| +6. **Read path**: `loadAttributionForEconomics` warnings and the fleet |
| + meters' one-banner rule in `buildEconomicsView`. |
| +7. **Live view**: `handleAPIStatusInstances` with `latestOwner` |
| + (`metricsview.go`) and the new `Unattributed` row; the CLI printer in |
| + `status_instances.go`. |
| +8. **Request budget** (memory: S3 requests cost money; no new per-box |
| + polling): records come through `recordWalkStore` (the change-index view |
| + when armed); box reports only when a host has no record, through the |
| + 60 s cache; one sidecar record GET per sidecar host per pass. Unarmed |
| + deployments walk the records once per statements pass, census pass, |
| + economics build and status request. Is that acceptable or a P2? |
| +9. **Tests** (`usageattrib_test.go`): production-wired through the real |
| + create/delete doors, both boxes' real reconcile and reports, and the box's |
| + own `metrics.RollupHour`/`UpsertRollup`. The move test re-homes the record |
| + with `provision.SetRecordRegion` rather than the box-driven move protocol. |
| + Mutations run (all killed): no created_at bound; bound on hour end; |
| + records keyed wrong; box reports before records; console-box route for |
| + any box; unknown charged to ops; live tag ignored; census ignores records; |
| + unknown host treated as platform. Is a material behaviour untested? |
| +10. **Census**: `docs/superpowers/notes/census-proposal-usage-attribution-390.md`. |
| + No unit changed; the root package's envelope (`.`) is re-pinned because |
| + `status_instances.go` (the CLI printer) changed. Give a verdict on the |
| + envelope: does anything in the root package's change let root open, run, |
| + query or follow something it did not before, from a path or input a |
| + tenant, an app or a box agent can create, write or name? |
| + |
| +## 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). Then the census verdict for envelope `.` (approve or reject, citing |
| +lines read). 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. |
| + |
| +In round 3, a NOT READY also says whether the P1s share one cause, and |
| +whether refusing the case up front or cutting the feature would remove |
| +them. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. |