plan: code health rev 2, answering Astra round 1
Ratchet no longer fails on decreases and refuses raises against the merge base; site records for "no new ones" rules; type-based database metric; code-only line counts; production deadlines and console request cancellation move ahead of structure; corrected figures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+263
−43
docs/superpowers/plans/2026-11-16-go-code-health.md+112 −43docs/superpowers/reviews/FINDINGS-code-health-plan-R1.md+80 −0docs/superpowers/reviews/REVIEW-BRIEF-code-health-plan-R2.md+71 −0
CI cancelled — superseded by a newer push — run details
diff --git a/docs/superpowers/plans/2026-11-16-go-code-health.md b/docs/superpowers/plans/2026-11-16-go-code-health.md| index ea3e327e3..6a1a6028b 100644 |
| --- a/docs/superpowers/plans/2026-11-16-go-code-health.md |
| +++ b/docs/superpowers/plans/2026-11-16-go-code-health.md |
| @@ -1,6 +1,6 @@ |
| # Go code health: fix, hold, improve |
| -Status: draft for Paul, 2026-11-16. Backlog and audit reports: amadan |
| +Status: draft rev 2 for Paul, 2026-11-16 (Astra round 1 answered). Backlog and audit reports: amadan |
| discussion #1123. First batch merged the same day (958ff2e, b064b14, |
| 0374ac2). |
| @@ -13,9 +13,12 @@ growing (a 162k-line console package, 1,200-line functions, 999 |
| closed the worst deadlines and two gate holes. |
| Fixing the current list once is not enough. Between the audit (5b6d5374) |
| -and the recheck (c4b44c34), eight days apart, the CLI gained 45 |
| -`log.Fatal` calls, tests gained 147 sleeps, and the three longest |
| -functions each grew by 100 to 200 lines. So the plan has three parts: |
| +and the recheck (c4b44c34), eight days apart, by rough text counts the CLI |
| +gained about 45 `log.Fatal` mentions and tests about 147 `time.Sleep` |
| +mentions, and two of the three longest functions grew by 130 to 160 lines |
| +(`handleAPIInstanceCreate` 1,081 to 1,242, `runAgent` 1,090 to 1,222; |
| +`Reconcile` 1,255 to 1,275). These are grep estimates; the scanner in |
| +Part 2 sets the real baseline. So the plan has three parts: |
| 1. **Fix** what is known, in small reviewed branches. |
| 2. **Hold** every gain with a check in CI, so nothing that was fixed comes |
| @@ -47,13 +50,30 @@ functions each grew by 100 to 200 lines. So the plan has three parts: |
| | `audit-bugs-2` | ledger verify timeout and `{}` HEAD panic (cli.go); system update decode errors (system.go); "ops" substring match (console/ownership.go); #1141 subdomain lost race; silent capacity page (host/haplacement.go); escrow alerts matched by string prefix (activator/escrow.go) | yes | |
| | `audit-console-shutdown` | console drains HTTP and its workers on SIGTERM before releasing the policy lease, so rolls stop dropping requests | no (console) | |
| | `audit-govulncheck` | `50-govulncheck` CI step with an explicit, dated exception file; GO-2026-6859 listed under the 1.26.10 pin (#897, #904) | no | |
| -| `audit-edge-test-sleeps` | about 13 s of fixed sleeps in edge tests replaced through the seams that exist (`Edge.watchTick`, a seam for `holderHeaderSuspectAfter`) | no (tests) | |
| +| `audit-edge-test-sleeps` | about 13 s of fixed sleeps in edge tests replaced through the seams that exist (`Edge.watchTick`) and one new one (`holderHeaderSuspectAfter` becomes a variable a test can shrink, at the same value) | yes: the new seam changes internal/edge production code | |
| Plus the one-line AGENTS.md fix: its sandbox note recommends a GOCACHE |
| path the machine policy bans (rides `audit-bugs-2`). |
| -### Batch 3: close the follow-ups |
| - |
| +Batch 2 keeps the edge test-sleep branch because it was already under way |
| +and is small; from batch 3 on, production deadline gaps come before test |
| +speed. |
| + |
| +### Batch 3: production deadlines first, then the follow-ups |
| + |
| +In this order: |
| + |
| +- **Console request cancellation, in place.** Request handlers call store |
| + methods without their request context (for example |
| + internal/console/oppeople.go:102, :127), on a store with one connection |
| + (store.go:122), so an abandoned request keeps its place in the queue. |
| + Thread the request context through the store methods those handlers use, |
| + starting with the busiest request paths; no package move needed. |
| +- **The remaining unbounded production calls:** the edge prober's dial |
| + (internal/edge/upstreamdial.go:16); host `systemctl`/`journalctl` calls |
| + with no timeout (internal/host/systemunits.go:327, unitsettle.go:75, and |
| + the loops adoptLoop, fastConvergeLoop, statusLoop, configSync/configGen) |
| + through one bounded helper with a guard test. |
| - #1143: credential clients get the body bound; an explicit buildable |
| client stays the caller's; the AWS client guard catches field |
| assignment and option callbacks. |
| @@ -75,16 +95,18 @@ path the machine policy bans (rides `audit-bugs-2`). |
| In this order, because each makes the next cheaper: |
| 1. **Census `moved` class** in `census-propose`: a pure file move carries |
| - its disposition instead of reading as a removal plus a new unit. Every |
| - split below in the root binary's graph depends on it. |
| + its disposition, its reviewer approval and its J4 witness obligations |
| + instead of reading as a removal plus a new unit. It is a dependency only |
| + of the relocations below that move files inside the root binary's graph |
| + (2, and any host split); console work (3 to 5) is outside the root |
| + census and does not wait for it. |
| 2. **Leaf package for the S3 `Store` interface** out of |
| `internal/release` (67 importers, all linking the registry and SQLite |
| today). |
| 3. **Leaf package for the names console takes from activator and edge**, |
| so the console stops linking 78k lines it barely uses. |
| -4. **Console request contexts**: request-path queries first (459 |
| - context-free calls on one SQLite connection; an abandoned request |
| - keeps its place in the queue). |
| +4. **Console request contexts, the rest**: after batch 3's request paths, |
| + the remaining store calls, held by the ratchet's database metric. |
| 5. **Console split, staged**: widen the 15 package-directory source guards |
| first, then `consoledb` (the Store), then billing, alerts, operator |
| pages, architecture view and PDF, one at a time. |
| @@ -96,29 +118,67 @@ In this order, because each makes the next cheaper: |
| ### A code-health ratchet in CI |
| -A test-only package (`internal/codehealth`, outside the census because |
| -nothing links it) measures the tree with `go/parser` and compares it with |
| -a checked-in record, `.amadan/code-health.tsv`, one line per metric and |
| -package. The same shape as Rastrillo's `.rastrillo/code.txt`: the records |
| -start at today's numbers and only go down. |
| - |
| -- A count above its record fails the gate and names the new offences. |
| -- A count below its record also fails, and prints the lower number to |
| - commit, so a gain is locked in the branch that made it. |
| - `make code-health-record` rewrites the file. |
| -- A metric's record reaching zero turns it into a plain guard. |
| - |
| -Metrics at the start (numbers from c4b44c34, to be re-measured): |
| - |
| -| Metric | Today | |
| -|---|---| |
| -| `log.Fatal` and `os.Exit` in root-package production files | 999, 120 | |
| -| `time.Sleep` in tests, per package | 1,019 total | |
| -| context-free `db.Query`/`QueryRow`/`Exec` in internal/console | 459 | |
| -| functions over 300 lines, by name, with their length (no new ones; listed ones may only shrink) | list | |
| -| files over 3,000 lines, same rule | list | |
| -| packages importing internal/release | 67 | |
| -| `context.Background()`/`TODO()` in internal/host production code | to measure | |
| +A test-only package, `internal/codehealth`, scans the tree once per gate |
| +run and compares it with a checked-in record, `.amadan/code-health.tsv`. |
| +It is outside the census: the census scope comes from the root binary's |
| +production dependencies, and nothing links a test-only package. The idea |
| +is Rastrillo's `.rastrillo/code.txt` (offences recorded when the gate |
| +began, records only go down), adapted for many parallel branches. |
| + |
| +**Two kinds of record.** |
| + |
| +- **Sites**, for rules that say "no new ones": each existing offence is |
| + recorded by identity (package, enclosing function, callee) with a count. |
| + A new site, or a higher count at an existing one, fails the gate even if |
| + an old one was removed elsewhere, so removing one offence never pays for |
| + another. Moving code within a package keeps the identity. A rename or a |
| + move to another package goes through `make code-health-record |
| + MOVE=<old>:<new>`, which carries the existing allowance across and can |
| + never increase it; the reviewer sees the transfer in the diff. |
| +- **Totals**, for trends with no "no new ones" rule (packages importing |
| + internal/release, say): a number per metric and package. |
| + |
| +**What fails, and what does not.** |
| + |
| +- An offence above its record fails the gate and names the site. |
| +- A count below its record does not fail. The gate prints the lower |
| + number. So two branches that each remove a different sleep both pass, |
| + and main after both merges passes too (it is simply below its record). |
| +- `make code-health-record` only lowers records and drops sites that are |
| + gone. It cannot add a site or raise a number. Adding or raising needs a |
| + hand edit with a `# raised: <reason>` comment on the line. |
| +- A separate CI step compares `.amadan/code-health.tsv` with the merge |
| + base's copy (fetching main if the runner lacks it) and fails on any |
| + added site or raised number without that comment, so a raise is always |
| + a visible, reviewed decision. |
| +- Records drift below the code only when nobody runs the lowering |
| + command; the monthly pass catches that (Part 3). |
| + |
| +**How it measures.** With type information (`golang.org/x/tools/go/packages`, |
| +already a dependency), not text, for the root module and `launchctx`, |
| +under `GOOS=linux` with the gate's tags (`rootrunner`, |
| +`carlos_cutover_witness`). Generated files (`// Code generated`) and |
| +`testdata` are skipped. Import aliases are resolved by type, so |
| +`log.Fatal` under another name still counts. Each metric has fixture |
| +tests showing what it counts and what it ignores. Its run time is measured |
| +on CI before it joins the gate; if it is slow it runs as its own CI step. |
| + |
| +**Metrics at the start.** The scanner sets the real numbers; these are |
| +grep estimates from c4b44c34. |
| + |
| +| Metric | Kind | Estimate | |
| +|---|---|---| |
| +| `log.Fatal*` and `os.Exit` calls in root-package production files | sites | about 999 and 120 mentions | |
| +| `time.Sleep` calls in test files | sites | about 1,019 mentions | |
| +| database operations without a context: methods `Query`, `QueryRow`, `Exec`, `Prepare`, `Begin` on `*sql.DB`, `*sql.Tx`, `*sql.Conn`, and any interface or type in the module that offers the `...Context` form of the same method (e.g. console's `sqlQueryer`), in every package, so moving code into a new package (e.g. `consoledb`) does not hide them | sites | 459 in console via `s.db` alone; more with `tx` and interfaces | |
| +| functions over 300 lines, counting only lines with code (blank and comment-only lines excluded) | sites (function, length) | 3 over 1,000 today | |
| +| files over 3,000 lines, same counting | sites (file, length) | to measure | |
| +| packages importing internal/release | total | 67 | |
| +| `context.Background()`/`TODO()` in internal/host production code | sites | to measure | |
| + |
| +Line metrics count code, not comments, so adding a safety explanation |
| +never fails the gate and deleting comments never counts as a gain. Their |
| +physical length is printed as a report only. |
| ### Guards that already hold a line |
| @@ -142,22 +202,31 @@ ratchet that enforces it: |
| - New tests wait on a signal or a seam, not `time.Sleep`. |
| - Errors are compared with `errors.Is`/`errors.As` and wrapped with `%w` |
| when a caller might branch on them; never match `err.Error()` text. |
| -- A function past 300 lines, or a file past 3,000, is split by concern in |
| - the branch that would grow it. |
| +- A function past 300 lines of code, or a file past 3,000 (comments and |
| + blank lines not counted), is split by concern in the branch that would |
| + grow it; deleting comments to fit is not a split. |
| ## Part 3: improve |
| ### Monthly health pass (first Monday of the month) |
| -One session, read-only, under an hour of agent time: |
| - |
| -1. Re-measure the ratchet and staticcheck with every check on (S, ST, |
| - QF, U1000 included) and govulncheck; post the numbers on a standing |
| - discussion, with the change since last month. |
| -2. Lower any records that fell and were not locked in. |
| +One session, bounded (one scanner run, one staticcheck run with every |
| +check on, one govulncheck run, at `nice`, on cached builds), reporting |
| +only: |
| + |
| +1. Post the numbers on a standing discussion with the change since last |
| + month: the ratchet, staticcheck with every check on (S, ST, QF, U1000 |
| + included), govulncheck. |
| +2. Where main is below its records, open one small branch that runs |
| + `make code-health-record` (lowering only), reviewed like any other. |
| + Anything above its record on main is a broken invariant: file it as an |
| + Issue at once. |
| 3. Pick the next two or three items from the backlog for the month and |
| post them for Paul's go. |
| +Its cost is measured on the first run and stated in the post; if it |
| +exceeds an hour of agent time, the pass is cut down, not the rules. |
| + |
| ### Quarterly audit, one slice at a time |
| Each quarter, one read-only Fable auditor takes one slice (console; host |
diff --git a/docs/superpowers/reviews/FINDINGS-code-health-plan-R1.md b/docs/superpowers/reviews/FINDINGS-code-health-plan-R1.md| new file mode 100644 |
| index 000000000..a54b710c7 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/FINDINGS-code-health-plan-R1.md |
| @@ -0,0 +1,80 @@ |
| +Reviewed round 1 at `7977edd904c8dcabfccc2fdda5a417d6b295db5e`, against local baseline `c4b44c34`. No files changed; no builds, tests, or subagents run. Discussion #1123 was inaccessible because network access is blocked, so its reports and external issue claims remain unverified. |
| + |
| +1. **P1 — Part 2: the ratchet does not protect gains across merges or record regeneration.** |
| + **Invariant: an accepted baseline cannot increase, and merged code must match it.** |
| + |
| + [Plan lines 99–108](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:99) specify comparison against the branch’s own record and a command that rewrites it. They specify neither comparison with an accepted baseline nor integration handling. |
| + |
| + Two branches can each remove a different sleep, changing the same record from 100 to 99. Both pass independently. Git can merge their identical record edits without conflict, leaving 98 sleeps against a record of 99: the required decrease check then fails on main. The repository explicitly gates the branch tip and checks main afterward ([AGENTS.md:185](/home/paulca/amadan.net/carlos/platform-code-health-plan/AGENTS.md:185)). Separately, rewriting the record upward would satisfy the described equality check. |
| + |
| + **Fix:** define a lower-only update command, reject unauthorized baseline increases against the accepted base, and specify how combined changes are regenerated and gated before landing. Include the two-independent-decreases scenario in the ratchet’s acceptance checks. |
| + |
| +2. **P2 — Part 2: aggregate counts cannot enforce the proposed rules for new code.** |
| + **Invariant: removing an old offence must not authorize a new one.** |
| + |
| + The record is per metric/package ([plan:101](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:101)), while the rules prohibit new CLI fatalities and new test sleeps ([plan:141](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:141)). Removing one old call and adding one elsewhere passes the count check. Counts alone also cannot identify the “new offences” promised at line 105. |
| + |
| + Package splits create another problem: existing sleeps transferred into a new package become new offences there, despite no increase overall. Allowing unrestricted initial records would instead permit evasion. |
| + |
| + **Fix:** distinguish aggregate trend metrics from site-level prohibitions. Record grandfathered sites where “no new ones” is intended, and define reviewed identity transfers for moves, renames and package splits without increasing the inherited allowance. |
| + |
| +3. **P2 — Part 2: the database metric lacks a reliable measurement boundary.** |
| + **Invariant: the metric follows database operations, regardless of receiver spelling or package placement.** |
| + |
| + [Plan:117](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:117) names `db.Query`/`QueryRow`/`Exec`. Existing calls also use `tx` and a `sqlQueryer` interface: [billingpayments_store.go:72](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/billingpayments_store.go:72), [line 88](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/billingpayments_store.go:88), and [line 176](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/billingpayments_store.go:176). `Begin()` at line 170 is another context-free database operation. |
| + |
| + A receiver-name scan misses these; an unrestricted selector-name scan counts unrelated APIs. Limiting coverage to `internal/console` also makes the proposed `consoledb` extraction appear to fix calls merely by moving them. |
| + |
| + **Fix:** define the database types/interfaces and operations covered, including transaction acquisition. Use type information or a documented conservative syntax rule with fixtures covering these existing forms. Carry coverage into extracted packages. Specify import-alias handling, build-tag coverage and generated/fixture exclusions for the scanner generally. |
| + |
| +4. **P2 — Batch ordering: request cancellation is unnecessarily behind structural work.** |
| + **Invariant: operational fixes should not wait for unrelated dependency cleanup.** |
| + |
| + [Plan:75–87](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:75) puts console request contexts after the census extension and two package extractions. The current connection limit is indeed one ([store.go:122](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/store.go:122)); request handlers call store methods without passing their request context ([oppeople.go:102](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/oppeople.go:102), [line 127](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/oppeople.go:127)). Those paths can be improved in place. |
| + |
| + Batch 3 also contains existing unbounded production calls—[upstreamdial.go:16](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/edge/upstreamdial.go:16), [systemunits.go:327](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/host/systemunits.go:327), and [unitsettle.go:75](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/host/unitsettle.go:75)—while batch 2 includes test-speed cleanup. |
| + |
| + **Fix:** bring a bounded request-cancellation slice forward, and prioritize the remaining production deadline gaps ahead of sleep cleanup. Make `moved` a dependency of relocations that require it, not of every structural or cancellation change. |
| + |
| +5. **P2 — Batch 2: the edge sleep branch is incorrectly labelled census-free.** |
| + **Invariant: production test seams retain the normal census review.** |
| + |
| + [Plan:50](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:50) proposes a seam for `holderHeaderSuspectAfter` but labels the branch “no (tests).” The constant and timer construction are production code at [forwardha.go:509–521](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/edge/forwardha.go:509). Changing them changes the production envelope; the scanner fingerprints whole in-scope files ([census_scope_test.go:182](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/provision/census_scope_test.go:182)). |
| + |
| + **Fix:** mark the branch census-required if it adds that seam, with the normal independent approval. Retain “no” only for a strictly test-file-only implementation. |
| + |
| +6. **P2 — Part 2: physical-line ratchets reward deleting useful explanation.** |
| + **Invariant: readability and safety documentation must not be sacrificed to satisfy a size metric.** |
| + |
| + [Plan:118–119](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:118) allows oversized functions/files only to shrink, and [line 145](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:145) requires splitting a growing one. Adding a safety explanation to an unchanged oversized function would fail, while deleting comments would count as improvement. This codebase puts meaningful authority explanations immediately beside implementation, for example [apiinstances.go:1573](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/apiinstances.go:1573). |
| + |
| + **Fix:** exclude blank and comment-only lines from the blocking metric. Keep physical length as a report, and require meaningful decomposition rather than accepting comment removal as structural improvement. |
| + |
| +7. **P2 — Introduction and metric table: some quantitative claims are inaccurate or lack a counting definition.** |
| + **Invariant: baseline comparisons use the same reproducible measurement.** |
| + |
| + [Plan:16–18](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:16) says all three longest functions grew by 100–200 lines. Comparing function-body spans at the two named commits gives: |
| + |
| + | Function | `5b6d5374` | `c4b44c34` | Growth | |
| + |---|---:|---:|---:| |
| + | `Reconcile` | 1,255 | 1,275 | 20 | |
| + | `handleAPIInstanceCreate` | 1,081 | 1,242 | 161 | |
| + | `runAgent` | 1,090 | 1,222 | 132 | |
| + |
| + Current declarations are at [reconcile.go:1460](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/provision/reconcile.go:1460), [apiinstances.go:1578](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/console/apiinstances.go:1578), and [agent.go:275](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/host/agent.go:275). |
| + |
| + The stated 999 fatalities and 1,019 sleeps reproduce literal text-occurrence counts, which include non-call text; [cli.go:49](/home/paulca/amadan.net/carlos/platform-code-health-plan/cli.go:49) is one such comment. |
| + |
| + **Fix:** correct the growth claim and label historical text counts as estimates. Generate the authoritative baseline with the final scanner and record its scope and counting definitions. |
| + |
| +8. **P3 — Monthly pass: “read-only” conflicts with lowering records.** |
| + |
| + [Plan:152–157](/home/paulca/amadan.net/carlos/platform-code-health-plan/docs/superpowers/plans/2026-11-16-go-code-health.md:152) promises a read-only session, then directs it to lower records. Under a functioning exact-match ratchet, an unlocked decrease on main is also a gate failure to investigate. |
| + |
| + **Fix:** make the pass report discrepancies and propose a separate reviewed repair branch. Treat unexplained drift as a failed invariant. |
| + |
| +The test-only `internal/codehealth` package is outside the census as proposed: scope derives from production dependency files, not test imports ([census_scope_test.go:43–79](/home/paulca/amadan.net/carlos/platform-code-health-plan/internal/provision/census_scope_test.go:43)). A single parsing pass is a reasonable approach, but gate runtime remains unmeasured. |
| + |
| +The monthly and quarterly cadence does not itself contradict the stopping rules; the plan explicitly retains them. Keep each audit and verification bounded, reuse existing caches, and measure scanner cost before claiming the hour budget. A `moved` design must preserve dispositions, reviewer approval and J4 witness obligations; current removal handling is not a safe substitute for that contract. |
| + |
| +NOT READY |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/REVIEW-BRIEF-code-health-plan-R2.md b/docs/superpowers/reviews/REVIEW-BRIEF-code-health-plan-R2.md| new file mode 100644 |
| index 000000000..2dbd5490d |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/REVIEW-BRIEF-code-health-plan-R2.md |
| @@ -0,0 +1,71 @@ |
| +# Review brief: plan docs/superpowers/plans/2026-11-16-go-code-health.md, round 2 of 3 |
| + |
| +Repo carlos/platform, branch `code-health-plan` (tip named in the reviewer's prompt). |
| +Under review: `docs/superpowers/plans/2026-11-16-go-code-health.md`. |
| +Authorities: AGENTS.md on main ("Stopping rules", "The census", "Build & |
| +test"). Context: amadan discussion #1123 (audit backlog, reports, and the |
| +recheck table against c4b44c34). |
| + |
| +You are an independent reviewer. This is a plan for keeping the Go code |
| +healthy over time, not a feature. Check it against the code and the repo's |
| +rules. |
| + |
| +## What to check |
| + |
| +1. The code-health ratchet (Part 2): is the design sound? A test-only |
| + package `internal/codehealth` parsing the tree with go/parser and |
| + comparing against `.amadan/code-health.tsv`; failing on increase and |
| + also on decrease (forcing the record down in the same branch). Will it |
| + be stable across parallel branches (merge conflicts in the record), fast |
| + enough for the gate, and outside the census as claimed? Are the chosen |
| + metrics measurable reliably, and do they track something that matters? |
| + Is any metric gameable in a way that makes code worse? |
| +2. Batch ordering: is anything in batch 3 or 4 more urgent than batch 2? |
| + Does the census `moved` class really need to come first for the |
| + structural work? |
| +3. The AGENTS.md rules: each enforceable as stated, and none contradicting |
| + existing AGENTS.md rules or the stopping rules? |
| +4. The monthly pass and quarterly audit: realistic in cost, and do they |
| + respect the stopping rules (no review spirals) and the shared-machine |
| + CPU budget? |
| +5. Anything missing that a strong Go team would hold the line on (for this |
| + codebase specifically), with evidence. |
| +6. Factual claims (counts, commits, file:line) against main at c4b44c34. |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: round 1, Astra, `docs/superpowers/reviews/FINDINGS-code-health-plan-R1.md` |
| +(NOT READY: one P1, six P2s, one P3). The plan is now rev 2. |
| + |
| +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. |
| + |
| +Rev 2 answers: the ratchet no longer fails on a decrease (so parallel |
| +decreases merge cleanly), the record command only lowers, a separate CI |
| +step refuses raised numbers or added sites against the merge base unless |
| +the line carries a `# raised:` reason; "no new ones" rules are site |
| +records (package, enclosing function, callee) with explicit MOVE transfers |
| +that cannot increase an allowance; the database metric is type-based and |
| +covers DB/Tx/Conn and interfaces with Context forms, in every package; |
| +line metrics count code lines only; batch 3 now leads with console request |
| +cancellation in place and the remaining production deadline gaps; `moved` |
| +is a dependency only of root-graph relocations; the edge sleep branch is |
| +marked census-touching; the growth figures are corrected and labelled as |
| +grep estimates; the monthly pass reports and lowers records only through |
| +a reviewed branch. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not work, or contradicts a repo rule. Blocks. |
| +- **P2**: wrong or missing. Fixed without reopening this review. |
| +- **P3**: clarity or polish. Follow-up list only. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3, each with the section, the problem, evidence |
| +(file:line, verified), and a concrete fix. End with exactly one verdict: |
| +READY, READY AFTER FIXES, or NOT READY. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run builds or tests. |