Repository navigation
fix(refactoring): Extract Method plans that would not compile are completed or refused - #4378
Conversation
…y call, and TS spans a property guard narrows are refused A Fix first step for a staged plan whose first helper takes the shared parameter object showed only the helper header and call, so the call named a variable and a type that exist nowhere. The step now carries the object's declaration, the line building it and the plan's notes; a plan missing either is not offered. A TypeScript span reading a property narrowed by a test above or around it (if (!tc.result) continue;) lost that narrowing in the helper, and no parameter type restores it. Such spans, and staged splits holding one, are refused with property_narrowed.
…n outer declaration Measured on two re-scored indexes, served plans still broke when an enclosing if or an assert narrowed a value, when a module-level name was narrowed, when the span held an assert the code after it relies on, and when it assigned a name declared outside it. Those spans are refused (narrowing_lost, outer_declaration); a parameter narrowed by an enclosing test gets the existing type-as-narrowed note, and an output declared before the span gets a note to declare it in the helper.
|
🔍 1 thing to check
➖ Health of changed files: 8.56 → 8.55 (-0.01; structure -0.02)
Coverage: 3 uncovered changed linesPatch coverage 98.6% (217 of 220 changed executable lines covered)
Report from this run for 🧾 Evidence: 1 to look at, 6 not known
AI review is paused: this repository reached its monthly spending limit. Bot settings 📊 See the full report for this PR Settings and updatesUpdated 2026-10-22 03:24 UTC, since the last push: health 8.5 to 8.6, 5 findings gone |
…PR touches grows past the bar
What
Two Extract Method plans that Fix first hands out would not compile if applied as written:
assemble_test_impact) whose first helper takes a shared parameter object: the Fix first step showed the helper header and call only, so the call namedctxand_AssembleTestImpactContext, which exist nowhere.extractSources) lifting a loop body afterif (tc.status !== "done" || !tc.result) continue;: the helper takestc, and the narrowing oftc.resultdoes not survive into it, soresult.resultsand the host's laterresult.targetsstop type-checking.How
notes. A step whose helper takes the parameter object shows the object's declaration above the helper and the line building it above the call. A plan missing either is not offered as a Fix first step. The agent prompt fences multi-line code and prints the notes, and the card lists them.assertthe code after it relies on, and a span assigning a name declared outside it that it neither takes nor returns. One refused stage refuses the whole staged split. Reasons are recorded asnarrowing_lostandouter_declaration.ifor anassertgets the existing "type it as narrowed" note. An output declared before the span gets a note to declare it in the helper.Verification
Bar, set before measuring: re-plan every open Extract Method plan on a copy of our own index and on one held-out corpus (Zulip), blind-label at least 30 changed plans with opaque ids for "would this compile and preserve behaviour", and offer 0 broken plans afterwards.
assemble_test_impactstep applied by hand as now served: its 13 tests pass.extractSourcesas served before failedtscwith TS18048 and is now refused.test_uninstall_cmd.py). UI vitest andtscpass, and the generated HTTP types check passes.HEALTH_ANALYZER_VERSION is not bumped: it was already bumped once since v0.58.0.