Repository navigation
chore(#810): delete two unreachable option fields; mutation-test the guard - #811
Merged
admarble merged 5 commits intoJul 26, 2026
Merged
Conversation
reuseWorktrees was declared in RunOptions with a behavior-promising doc
comment ("Reuse existing worktrees instead of creating new ones") but had
no CLI flag and no consumer in src/, bin/, or scripts/. The comment was the
only thing asserting the capability existed.
Decision: delete rather than implement. Unlike #795's --qa-gate, which
shipped in #133 and was documented in four places and so needed a
parseable-but-warning deprecation, nothing exposes this field to users. No
caller can be passing it, so removal breaks nothing and no deprecation
window is required. Implementing it instead would mean inventing "reuse"
semantics nobody has asked for, while worktreeIsolation already covers
isolation and the --force/resume paths from #760 cover the adjacent needs.
Verified independently rather than trusting the report: swept all 42
RunOptions fields counting non-types.ts references. reuseWorktrees was the
only one at zero. strictPreflight (1) and worktreeIsolation (2) looked
similar but are genuinely consumed at runtime. tsc passing with no other
edit is the proof of zero consumers -- any reader would have failed the
build.
One reference exists that is deliberately left alone:
__fixtures__/dependency-markers/issue-31.md quotes `--reuse-worktrees` in a
verbatim capture of issue #31's body, used as a parser fixture. It is not a
consumer -- it is evidence the flag was designed in #31 alongside
--merge-on-success and never landed. Editing it would corrupt the fixture.
Also records that experimentalTui is inert on purpose, so the next
dead-surface sweep does not delete a flag that is doing its job. Its doc
comment previously stated only the effect ("now a hidden no-op alias"),
never the intent; the sweep that produced this issue had to re-derive that
from scratch. The note now names the tests that pin it and contrasts it
with the field removed here: a flag deliberately kept parseable versus a
type field nobody could reach.
The new guard test asserts both properties. Its first draft matched a bare
\breuseWorktrees\b substring and failed immediately -- on the doc comment
above, which names the removed field in prose. Now anchored to a line-start
field declaration. Both assertions were verified to fail against the
pre-change types.ts and pass after, so the guard can actually detect the
regression it claims to.
Fixes #810
4 tasks
A second adversarial pass found the guard could stop guarding without
saying so -- the exact defect class this issue exists to remove.
The reintroduction check scanned `runOptionsBody()`, a brace-walked slice
of the interface. A stray `}` inside any doc comment in RunOptions closes
that walk early and returns a truncated body; a `reuseWorktrees` field
declared past the truncation point then reads as absent and the test goes
green. Constructed and confirmed, rather than reasoned about: with a
comment containing `{"ok":true}}` placed after experimentalTui and the
field reintroduced after that, the body shrank from ~5851 to 857 chars,
test 1 passed while the field was genuinely present, and test 2 -- whose
target still fell inside the fragment -- passed too. Both green, field
back.
Two changes:
- The reintroduction check now scans the whole file instead of the slice.
Scoping it to the interface bought nothing, because the line-anchored
pattern already cannot match prose, but it inherited the slice's failure
mode. A `reuseWorktrees` field declaration anywhere in types.ts is a
regression regardless of which interface holds it, so the narrower scan
was strictly worse: same detection, extra way to go blind.
- The brace-walk now refuses a body that terminates at an indented `}`.
The interface's real closing brace is at column 0, so an early stop
means a stray brace in a comment. It throws instead of returning a
fragment, which keeps the experimentalTui marker check (which does need
the slice) from silently inspecting a partial body.
Both prior probe scenarios are now caught. Falsifiability re-verified
after the change: both assertions still fail against the pre-change
types.ts and pass after, so the hardening did not defang them.
Refs #810
…vasions Swept every `*Options` interface in the repo rather than only `RunOptions`, since #810's premise -- a declared field whose doc comment promises behavior nothing implements -- is not specific to one interface. 48 interfaces, 243 fields, counting non-test source usage including each field's own module. Exactly two came back unused, and one was already known. `RenderOptions.alwaysRenderSummary` is the second instance. Its comment promised "renderSummary is rendered even if no issues were registered", and that capability does exist -- but it is delivered by `input.dryRun` on `SummaryRenderInput`, which is what actually gates the early return in `renderSummaryBlock` (run-renderer.ts:1441) and is wired from run-display.ts:201,208. The `RenderOptions` field was never read: all three renderer constructors destructure named fields, none retains `options`, and a repo-wide grep finds only the declaration. Same shape as `reuseWorktrees` -- an option describing behavior that arrived by another route -- so the same decision: delete. After removal the sweep reports exactly one unused field, `experimentalTui`, which is documented as inert on purpose. The guard hardening came out of mutation-testing the previous version. The line-anchored pattern `/^\s*reuseWorktrees\??\s*:/m` read as precise but silently missed four valid TypeScript spellings: `readonly reuseWorktrees?:`, `"reuseWorktrees"?:`, `reuseWorktrees ?:`, and a field sharing a line with its predecessor. Precision in the wrong dimension is a blind spot with a tidy regex. The real discriminator between a declaration and a prose mention is code vs. comment, not column position. Comments are now stripped up front, which lets the declaration pattern be permissive without any risk of matching the doc comment that names the removed field in prose -- the hole the very first draft fell into. Also hardened the marker check, which located `experimentalTui` by the exact string `experimentalTui?: boolean;`. That would have quietly stopped finding the declaration if the type were widened, a `readonly` added, or prettier rewrapped the line, and "declaration not found" would have been indistinguishable from "marker absent". It now matches by pattern and asserts the doc comment actually abuts the declaration, so a deleted comment cannot pass by borrowing the previous field's block. Verified by running the real suite against nine mutations of types.ts: eight fail as intended. The ninth -- dropping `(#810)` from "do not delete" -- still passes, correctly: the comment cites #810 again one sentence later, so the assertion holds for a real reason. Tightening it further would only over-fit to the current wording. Refs #810
Running the full suite surfaced a regression I introduced: three failures in scripts/qa/tautology-detector-cli.test.ts that pass on origin/main. Not a flake and not pre-existing -- the guard test added here trips the detector, which reported `"status":"blocking"` with this file at 100% tautological. The detector's rule is that an `it()` block should call a function imported from a source module. This file imports only node builtins, so `importedFunctions` is empty and every block reads as asserting on a local value. That default is right: a test that calls nothing usually proves nothing. It is wrong here specifically, because the invariant under test is a property of types.ts's source *text* and there is no runtime API for "does this interface still declare X" to call. First attempt was to move the comment-stripping into a function so the block had something to call. That did not satisfy the detector -- it wants an imported module, not a local helper -- but it is kept anyway, since it makes both tests open the same way, each calling the extractor it depends on. So this takes the documented exemption, `@tautology-skip`, which exists for exactly this case. Claiming it obliges proving the guard actually bites, so the pragma records how that was established rather than just asserting it: nine mutations of types.ts run against the real suite, eight failing as intended, the ninth an equivalent mutant that still passes for a real reason. The mutation run was repeated after this restructuring, with identical results, to confirm the exemption did not quietly defang anything. Worth noting for whoever touches the detector next: it extracted only one of this file's two `it()` blocks. Had it seen both, the ratio would have been 50% and fallen under the >50% blocking threshold on its own. The undercount is not caused by `*/` inside a regex literal (checked against a minimal reproduction), and it is not investigated further here -- it is the detector's bug, not this file's, and fixing it belongs in its own change. Full suite now: 194/194 files, 4098 passed. Refs #810
…eness Both found by a subagent re-tracing the justification I wrote for deleting `reuseWorktrees`, and both verified line by line before accepting. I had claimed worktree reuse was "unconditional default behavior". It is not. `ensureWorktree` reuses an existing worktree only when it is not stale, or is stale but has uncommitted changes or unpushed commits. A stale-and-clean worktree is force-removed and rebuilt -- `removeStaleWorktree` runs `git worktree remove --force`, then nulls the path so the create branch takes over. Reuse is the default; it is not unconditional. The deletion still stands, on narrower and more accurate grounds: `reuseWorktrees: true` would have been a no-op against reuse-by-default, and `reuseWorktrees: false` would have contradicted shipped behavior. What the overstatement papered over is that the one case where reuse is overridden -- stale-and-clean recreate -- has no opt-out today. If the field had ever meant "never recreate mine", that use case is genuinely unmet. It was never wired to anything, so deleting it removes no capability, but "redundant by construction" was too strong and is not what the code says. - worktree-manager.ts: the staleness comment called the threshold "(configurable threshold)" directly above a hardcoded `> 5`. It is not configurable, and the gap matters because that literal is what decides whether a clean worktree gets destroyed. Comment now says what the code does and notes why the literal is being left alone: making it configurable is a behavior change, not a comment fix. - qa/SKILL.md (all three mirrored copies): listed `worktreeIsolation` as "environment-controlled". It is not. `getEnvConfig` sets only qualityLoop, maxIterations, noSmartTests, testgen and securityReview, and no `--worktree-isolation` flag is registered, so the field is reachable only by a programmatic caller. The entry belongs in that list -- it genuinely needs no CLI registration -- but for the opposite reason to the one given. check-skill-sync: 42 synced, 0 diverged. Refs #810
admarble
deleted the
feature/810-chore-types-reuseworktrees-is-a-declared-but-u
branch
July 26, 2026 04:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RunOptions.reuseWorktrees— a field with a behavior-promising doc comment, no CLI flag, and no consumer (the original scope of chore(types): reuseWorktrees is a declared-but-unconsumed RunOptions field #810).RenderOptions.alwaysRenderSummary— a second instance of the same defect, found by sweeping every*Optionsinterface in the repo.experimentalTuiis inert on purpose, so the next sweep doesn't delete a flag that is doing its job.AC-1 Decision: delete, not implement
Unlike #795's
--qa-gate— which shipped in #133, was documented in four places, and so needed a parseable-but-warning deprecation — nothing exposesreuseWorktreesto users, so removal breaks nothing.The justification changed during review — and then had to be corrected.
My first reasoning was that
worktreeIsolationand the--force/resume paths covered the adjacent needs. Tracing the code showed both clauses were wrong:worktreeIsolationgates whether worktrees are provisioned at all and says nothing about reuse, and--forcenever touches worktrees (its only consumers are the state-guard bypass atrun-orchestrator.ts:710and lock takeover at:864).I then over-corrected, claiming reuse was "unconditional default behavior." That is also wrong.
ensureWorktreereuses an existing worktree unless it is stale and clean — in which caseremoveStaleWorktreerunsgit worktree remove --forceand rebuilds it. Reuse is the default; it is not unconditional.The accurate justification is narrower:
reuseWorktrees: truewould have been a no-op against reuse-by-default, andreuseWorktrees: falsewould have contradicted shipped behavior. The field could only ever be redundant or self-contradictory.What the overstatement papered over is worth stating plainly: the one case where reuse is overridden — stale-and-clean recreate — has no opt-out today. If
reuseWorktreeshad ever meant "never recreate mine," that use case is genuinely unmet. It was never wired to anything, so deleting it removes no capability, but the honest framing is "never reachable," not "already covered."Second instance of the same defect
The premise of #810 isn't specific to
RunOptions, so I swept every*Optionsinterface: 48 interfaces, 243 fields, counting non-test source usage including each field's own module. Exactly two came back unused.RenderOptions.alwaysRenderSummarypromised "renderSummary is rendered even if no issues were registered". That capability exists — but it's delivered byinput.dryRunonSummaryRenderInput, which actually gates the early return inrenderSummaryBlock(run-renderer.ts:1441), wired fromrun-display.ts:201,208. TheRenderOptionsfield was never read: all three renderer constructors destructure named fields, none retainsoptions, and a repo-wide grep finds only the declaration.After removal the sweep reports exactly one unused field —
experimentalTui, documented as intentional.The guard went through three rounds of self-inflicted holes
Each was found by testing the guard rather than reading it:
\breuseWorktrees\bsubstring and failed instantly — on the doc comment that names the removed field in prose. A guard that trips on any mention of what it guards can't survive its own rationale being written down.}in any doc comment terminated the brace-walk early, and a field declared past that point read as absent. Demonstrated: both tests green with the field genuinely present.readonly reuseWorktrees?:,"reuseWorktrees"?:,reuseWorktrees ?:, and a field sharing a line with its predecessor — all valid TypeScript. Precision in the wrong dimension is a blind spot with a tidy regex.The fix for (3) was recognising the real discriminator is code vs. comment, not column position. Comments are stripped up front, which lets the pattern be permissive without any risk of matching prose.
Mutation-tested against the real suite: nine edits to
types.ts— 8 fail as intended. The ninth is an equivalent mutant (dropping one of two#810mentions; the comment still cites it a sentence later).A regression I introduced, caught by the full suite
The guard test tripped the repo's own tautology detector (
"status":"blocking", 100%). Three failures intautology-detector-cli.test.tsthat pass onorigin/main— mine, not pre-existing.The detector wants
it()blocks to call a function imported from a source module; this file imports only node builtins, because the invariant under test is a property of source text with no runtime API to call. Took the documented@tautology-skipexemption, with the mutation evidence recorded in the pragma so the claim is checkable rather than asserted, and re-ran the mutations afterward to confirm the exemption didn't defang anything.Worth a separate look: CI passed at every commit, including while this was failing locally.
tautology-detector-cli.ts:43runsgit diff main...HEAD, andactions/checkoutdoesn't create a localmainref, so it throws into thecatchat:50and returns[]— the gate silently analyses zero files in CI. Not fixed here; it's the detector's bug and enforcing it repo-wide is its own change.AC Verification
tsc+ eslint both exit 0experimentalTuiis intentionally inerttypes.ts+ mutation-tested guardAC-4 note: the AC offered "a note in the boring-tech audit". No such document exists, and creating one to hold a single sentence would add exactly the dead surface this issue removes — so the note went to the declaration site (where a sweeper looks) and the other branch (grep-based guard) became a test.
Test plan
npm run build,npm run lint— cleanCHANGELOG: N/A — internal type surface, no runtime behavior, no user-visible change.
Fixes #810