carlos / platform Public

review: Astra round 1 findings for code-health-ratchet

READY AFTER FIXES; the four P2s fixed in 25bbea91.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 43dbb0be77f09a9570c5fc3087310e934ff0d0c9 parent 25bbea9
1 file changed, +74 −0
  • docs/superpowers/reviews/FINDINGS-code-health-ratchet-R1.md +74 −0
diff --git a/docs/superpowers/reviews/FINDINGS-code-health-ratchet-R1.md b/docs/superpowers/reviews/FINDINGS-code-health-ratchet-R1.md
new file mode 100644
index 000000000..a1ff60583
--- /dev/null
+++ b/docs/superpowers/reviews/FINDINGS-code-health-ratchet-R1.md
@@ -0,0 +1,74 @@
+Reviewed `5c03efedaa40b26b6b121515936aa9dcca1655ca` against `origin/main`, using Part 2 of the merged rev-3 plan and both plan-review findings files. The brief’s earlier tip differs only by the commit adding the brief.
+
+No P1 findings. Four P2 findings:
+
+1. **P2 — Multiple MOVE pairs can spend the same allowance repeatedly.**
+ [internal/codehealth/record_test.go:237](/home/paulca/amadan.net/carlos/platform-code-health-ratchet/internal/codehealth/record_test.go:237)
+
+ **Invariant:** the record command cannot increase the combined allowance through transfers.
+
+ Suppose the record allows three offences at A, while the code now has zero at A, two at B and two at C. With `MOVE='A:B;A:C'`, each pair independently passes `moved+left <= old.count`. The command then drops A and writes four offences across B and C.
+
+ `checkAgainstBase` correctly rejects this aggregate increase later, so CI protects the merge. The local command nevertheless violates its contract and writes a record CI will reject. Existing MOVE-command tests cover only one destination; the multiple-destination tests exercise the separate CI checker.
+
+ **Fix:** aggregate every destination’s allocation by original source before writing, preferably sharing the conservation check with `checkAgainstBase`. Add command-level fixtures for both a valid multi-destination split and an over-allocation.
+
+2. **P2 — Signature comparison misses aliases nested inside types.**
+ [internal/codehealth/scan_test.go:266](/home/paulca/amadan.net/carlos/platform-code-health-ratchet/internal/codehealth/scan_test.go:266)
+
+ **Invariant:** database classification follows identical method signatures regardless of type spelling.
+
+ For example:
+
+ ```go
+ type Row = sql.Row
+ type Queryer interface {
+ QueryRow(string, ...any) *Row
+ }
+ ```
+
+ This interface has the same `QueryRow` signature as `*sql.DB`, but `signatureString` produces a different result. `types.Unalias` unwraps only the outer type; here that is a pointer. `types.TypeString` retains the alias name inside it, so `*Row` differs from `*database/sql.Row`. A call through this interface escapes `db-no-context`.
+
+ **Fix:** normalize aliases recursively while preserving actual named-type identity, or compare signatures within a shared type universe. Add a fixture using an alias behind a pointer, including after a package move. Keep this correction in the centralized classifier; it belongs to the measurement-boundary family already identified in the plan reviews.
+
+3. **P2 — Function literals escape the function-length limit.**
+ [internal/codehealth/scan_test.go:385](/home/paulca/amadan.net/carlos/platform-code-health-ratchet/internal/codehealth/scan_test.go:385)
+
+ **Invariant:** a function exceeding 300 code lines is measured regardless of its declaration form.
+
+ Length measurement runs only for top-level `*ast.FuncDecl` nodes. A package-level `var run = func() { … }` containing 400 code lines gets no `func-lines` entry. If its file stays below 3,000 lines, neither length metric reports it. Converting a named function into this form also makes its existing function-length offence disappear.
+
+ The later AST walk visits the literal for call metrics but never measures its length. The line fixtures contain no function literals.
+
+ **Fix:** measure function literals with stable identities, including package-level function-valued variables and callbacks inside initializers. Add fixtures proving their lengths and comment exclusion.
+
+4. **P2 — Architecture-specific Linux code is excluded from every metric.**
+ [internal/codehealth/scan_test.go:348](/home/paulca/amadan.net/carlos/platform-code-health-ratchet/internal/codehealth/scan_test.go:348)
+
+ **Invariant:** supported Linux production code remains covered when its implementation becomes architecture-specific.
+
+ `archNeutral` deliberately discards architecture-suffixed files even when the active configuration compiles them. Consequently, new context-free database calls or host background contexts in an `_arm64.go` file pass without an allowance. Moving an existing implementation into architecture-specific files makes its offences disappear from the record.
+
+ Listing skipped files makes this visible, but does not enforce the plan’s Linux coverage. The plan explicitly excludes other operating systems; it does not exclude either supported Linux architecture.
+
+ **Fix:** scan explicit `linux/amd64` and `linux/arm64` configurations, deduplicating shared occurrences, and replace the fixture that expects architecture-specific code to be skipped with coverage fixtures for both architectures.
+
+The other departures are reasonable:
+
+- Splitting the scan and record comparison into steps 60 and 61 preserves both checks. Moving the expensive scan out of `10-gate` is explicitly permitted by the plan.
+- Partial transfers are a useful extension once finding 1 is fixed.
+- Requiring a changed `# raised:` reason prevents an old exception from silently authorizing another increase.
+- Refusing record updates while any site exceeds its allowance, and listing vanished sites as MOVE candidates, is appropriate.
+- Production-only database counting, test-inclusive length metrics, recursive `internal/host/...` coverage, and counting function references are defensible scope choices. Reference counting is conservative and catches seams such as `var exit = os.Exit`.
+
+The ordinary/tagged union and occurrence deduplication are implemented correctly for the covered files. Fixtures cover import aliases, test-package variants, generated files, the `!rootrunner` replacement, SQL receivers and narrow interfaces, package moves, and comment-free line counting. They lack the cases above.
+
+I found no additional source-level defect in step 61’s merge-base comparison, parent comparison for commits already on main, or initial-record exception. The local runner source confirms shallow initial clones, retained complete clones after deepening, and network access for jobs. A cold shallow-clone run and unauthenticated fetching from the deployed runner remain unverified.
+
+The AGENTS.md section names the correct checks. Its general deadline and context-propagation rules still require review beyond those checks: neither arbitrary context propagation nor explanatory comments are mechanically enforced. The branch is outside the root census: scanner implementation is test-only, fixtures are under `testdata`, and no root-linked production source changes.
+
+Validation: shell syntax and `git diff --check` passed. A read-only check confirmed the 2,213 record rows have valid field counts, positive allowances, unique identities and correct ordering. Targeted Go tests could not start because the sandbox refused creation of Go’s work directory under `$TMPDIR`. No files were edited, reviewers spawned, or full suites run.
+
+This implementation round has no P1, so review stops here under the repository rule. Apply the P2 fixes without reopening review.
+
+READY AFTER FIXES
\ No newline at end of file