Skip to content

feat(packs): warn on low per-rule rewrite precision (UPT-65) - #198

Merged
lucasbraum merged 1 commit into
mainfrom
lucasbraum/upt-65-gate-minimum-precision-for-mechanical-rules-including-non
Oct 17, 2026
Merged

lucasbraum merged 1 commit into
mainfrom
lucasbraum/upt-65-gate-minimum-precision-for-mechanical-rules-including-non

Conversation

@lucasbraum

Copy link
Copy Markdown
Collaborator

Closes UPT-65 (warning phase only).

pack test now computes precision for every rule with a rewrite, breaking or not. The rule set is the same one the gate already calls mechanical (rewrite rules plus Pack.mechanical). Precision is real true positives (public repos) over those plus every scored false positive, the same counts the UPT-48 gate reads. A rule below RULE_PRECISION_WARNING (80%) is flagged in pack test output and in the new per-rule table in docs/compatibility.md. Warning only: no gate reason, no status change, no change to unexercised or to how any rule runs. Ground truth and existing thresholds are untouched.

verification.json gains mechanical (per-rule TP/FP) so the docs can read it. I added only that field to each record from a full local pack test run of all 17 packs. Every other field is left as it was, including the drift that was already there (joi and openai status, react and zod breaking tallies), so no --write silently changed a status.

Also: formatRecord now counts the comma after an inline list. Biome does, and unexercised is no longer the last key.

Current numbers (all rewrite rules)

Pack Rule Precision Real TP FP
ai instructions 100% 12 0
ai on-end 100% 7 0
ai on-step-end 100% 2 0
ai telemetry 100% 3 0
ai is-step-count 100% 9 0
ai full-stream 100% 12 0
ai total-usage 100% 2 0
ai removed-experimental-option 100% 1 0
joi validation-error-details 100% 108 0
lucide-react renamed-icons n/a 0 0 unexercised
next middleware-proxy 50% 1 1 below 80%
next lint-removal 100% 1 0
next stable-cache-exports 100% 3 0
openai named-path-params, delete-method, beta-chat, runner-renames, removed-modules, core-paths, request-options n/a 0 0 unexercised
react use-ref-argument 100% 5 0
react ref-callback-return 100% 1 0
react mutable-ref-object 100% 2 0
react-router dom-imports 8% 29 336 below 80%
redis renamed-exports 100% 2 0
redis scan-iterators, keep-alive, quit-disconnect, unstable-resp3 n/a 0 0 unexercised
@sentry/browser enable-logs 100% 1 0
@sentry/browser enable-metrics, renamed-exports, integration-names, streamed-span-wrapper n/a 0 0 unexercised
@sentry/nextjs with-sentry-config-import 100% 3 0
@sentry/nextjs build-options 100% 1 0
@sentry/nextjs enable-logs, enable-metrics, renamed-exports, integration-names, streamed-span-wrapper, http-integration-options n/a 0 0 unexercised
@sentry/react enable-logs, enable-metrics, renamed-exports, integration-names, streamed-span-wrapper n/a 0 0 unexercised
stripe api-version-unpinned 100% 5 0
stripe fixture-cast n/a 0 0 unexercised
typescript downlevel-iteration, module-keyword, import-assertions n/a 0 0 unexercised
vitest removed-entrypoints n/a 0 0 unexercised
zod record-key 100% 2 0
zod error-params 100% 15 0
zod string-format 100% 19 0
zod error-issues 100% 52 0
zod error-members n/a 0 0 unexercised

express and ioredis have no rewrite rules.

Proposed threshold: 80%

Every exercised rewrite is at 100% except two. The data has a wide gap between 8%/50% and 100%, so any cut from 51% to 100% gives the same result today. I propose 80%: it tolerates one FP in five, which leaves room for small-sample rules, and it still catches both outliers.

If this became a gate, these would switch to assisted:

  • react-router / dom-imports: 29 TP, 336 FP (335 in getlago/lago-front, 1 in Arize-ai/phoenix). These are deprecated react-router-dom import moves the real upgrades didn't make. It already rewrites only with --include-deprecated.
  • next / middleware-proxy: 1 TP, 1 FP (benshabbat/GamesForMyKids, deprecated). This is a small sample: one more real site would move it.

No pack's status would change: both packs stay verified, because neither FP is breaking.

Tests

  • contract.test.ts: a low-precision rule is flagged and the pack stays verified.
  • pack.test.ts: per-rule rewrite lines and the warning are printed, and the run still passes.
  • docs-packs.test.ts: the matrix carries the rewrite table and the README doesn't.
  • pnpm docs:packs --check and biome check . are clean. The core pack tests pass. In the CLI suite only the telemetry-sender and third-party-notices tests fail, which also fail locally on main.

🤖 Generated with Claude Code

pack test computes each mechanical rule's precision (real true positives
against scored false positives), prints it, and flags rules below
RULE_PRECISION_WARNING (80%). Warning only: no status or run mode changes.
verification.json records the counts (mechanical); docs/compatibility.md
lists them per rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
@lucasbraum
lucasbraum merged commit 4c3dc23 into main Oct 17, 2026
28 checks passed
lucasbraum added a commit that referenced this pull request Oct 17, 2026
…sing on UPT-65

pack test --write on the rebased branch, ground truth unchanged: both
records gain the per-rule `mechanical` counts #198 added (browser
enable-logs 2/0; react enable-logs 4/0, integration-names 0/1, which the
UPT-65 warning flags below 80%). Statuses, tallies and truth digests are
the same as before the rebase. docs/compatibility.md regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
lucasbraum added a commit that referenced this pull request Oct 17, 2026
…87) (#201)

Fixes UPT-87.

## Reconciliation first
The committed `verification.json` said 69% (89 TP / 40 FN). A fresh
local `pack test react --offline` measures **107 TP / 22 FN (83%)**, and
CI's `pack react` job on 4c3dc23 measures the same numbers (artifact
`pack-test-react` of run 39009240360). So it is a stale record, not the
environment: #198 left the react tally as it was (its message says so),
and the scorer changed in #143 and #155 after the record was written.

## Reach, then rules (22 breaking misses)
| cause | misses |
|---|---|
| reached; the compiler reports at the use site, truth marks the
`RefObject<T>` declaration (`ref-object-nullable`) | 16 |
| `global-jsx-namespace` with no finding in the file | 4 |
| `generic` in dev-docs | 2 |

Most of the 16 declarations use the global `React.RefObject` with no
react import, so `detect` never read them.

## Change
- `ref-object-nullable` gets a syntax-tree `detect`: `RefObject<T>` /
`React.RefObject<T>` where `T` is an element type or a type parameter
bounded by one, has no `null`, and is not a cast.
- The pack also reads every project file containing `RefObject<` (same
pattern as the ai pack, UPT-33).
- Near-miss fixtures: `| null`, `RefObject<number>`, a cast. A cast is
excluded because it would be a breaking false positive at
`TldrawUiContextualToolbar.tsx:56` (truth lists :55, not :56); :55 stays
missed.
- `verification.json`, README and `docs/compatibility.md` regenerated.

## Before / after (same pinned ground truth, not touched)
| | before (measured) | after |
|---|---|---|
| breaking recall | 83% (107/129) | **94.6% (122/129)** |
| breaking FP | 0 | 0 |
| unverified FP | 8 | 8 |
| `ref-object-nullable` | 38 TP / 16 FN | 53 TP / 1 FN |
| other rules | unchanged | unchanged |

Pack stays verified; thresholds untouched.

## Remaining 7 misses
- `dev-docs/src/pages/index.tsx:1`,
`dev-docs/src/components/Homepage/index.tsx:1` (excalidraw): its
tsconfig says it is not used in compilation.
- `examples/excalidraw/with-nextjs/src/app/page.tsx:19`: a separate
example package, outside the analyzed program.
- `apps/dotcom/client/tsconfig.json:15` (tldraw): a config file; truth
marks the cause, no diagnostic lands there.
- `ButtonIconCycle.tsx:23`, `apps/examples/src/ExampleWrapper.tsx:111`:
global-JSX sites with no finding in the file; **not investigated beyond
that**.
- `TldrawUiContextualToolbar.tsx:55`: the cast, see above.

Suspect truth entries to review (not changed): :55 vs :56 above are the
same cast, one listed and one not.

Core tests pass (`pnpm test` in `packages/core`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Lucas Braum <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant