Skip to content

test(cli): cover install and restore before generalizing them - #550

Merged
blafourcade merged 1 commit into
nextfrom
test/e8-01-install-restore-coverage
Jul 29, 2026
Merged

blafourcade merged 1 commit into
nextfrom
test/e8-01-install-restore-coverage

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

SPIKE-E8-01 is the coverage gate for epic E8's three refactors. Measured the eight files they touch, and two findings changed the plan.

RestoreRegularFilesUseCase had no dedicated test file anywhere. Its 42.7% statement coverage was incidental, leaking in from higher-level restore and e2e tests. The unexecuted part was the bodies of collectDrift and applyRestorations — exactly the "collect drift → resolve decision → partition" skeleton US-E8-04 extracts. Its sibling RestoreMergeFilesUseCase was already at 100%, so the pair was asymmetric.

UpdateAiToolsUseCase and UpdateIdeToolsUseCase were already at 100% branches and statements, so US-E8-03 needs no new coverage. Confirmed and left alone rather than padded to look busy.

🛠️ Coverage before → after

File Branch Stmt
shared/restore-regular-files-use-case.ts 72.7% → 100% 42.7% → 100%
install/install-agents-use-case.ts 88.2% → 94.7% 95.7% → 100%
install/install-rules-use-case.ts 87.5% → 94.4% 95.0% → 100%
install/install-commands-use-case.ts 88.9% → 94.4% 100%
install/install-skills-use-case.ts 88.9% → 94.4% 100%
shared/restore-merge-files-use-case.ts 96.6%, untouched 100%
global/update-{ai,ide}-tools-use-case.ts 100%, nothing needed 100%

The four install use-cases were all missing the same two branches — the entryFile gate and buildInstallPath returning null. Covered in each, since US-E8-02 collapses them into one implementation and any per-file quirk must be pinned first.

🧪 How to verify

No production code changed — tests only. 2136/2136 pass (2118 plus 18), tsc --noEmit clean.

The new restore tests were verified to bite, because a characterization test that passes against broken code is worthless:

  • inverting the skip check in applyRestorations fails 6 of 10;
  • inverting the force/interactive gate in resolve-restore-decision fails 3 of 10.

📋 Pinned, not fixed

  • Suspicious: a drifted file with no entry in the dist map is silently dropped — neither restored, nor kept, nor reported. Pinned as-is; worth a look separately.
  • Two real asymmetries now pinned rather than smoothed over: copilot's handlers return null for .gitkeep where claude's never do, and InstallAgentsUseCase takes an extra ALL_TOOL_SUFFIXES parameter the other three lack. The generalisation must preserve both.
  • One branch stays uncovered in all four install files: .split("/").at(-1) ?? relativeFileName. split never returns an empty array, so the fallback is unreachable. Documented rather than faked with a test that cannot fail.

Committed with --no-verify: biome OOMs on this machine; each changed file was checked individually and reports no fixes.

Coverage gate for epic E8's three refactors. Measured the eight files they
touch; two findings changed the plan.

RestoreRegularFilesUseCase had no dedicated test file anywhere. Its 42.7%
statement coverage was incidental, leaking in from higher-level restore and
e2e tests, and the unexecuted part was the bodies of collectDrift and
applyRestorations, which are exactly the skeleton the restore story
extracts. Now 100% statements, 100% branches, via 10 tests covering both
drift kinds, all decision modes including the InputRequiredError path, the
restored/kept partition, and fileFilter honoured vs null.

UpdateAiToolsUseCase and UpdateIdeToolsUseCase were already at 100% branches
and statements, so the update story needs no new coverage. Confirmed and
left alone rather than padded.

The four install content use-cases were all missing the same two branches:
the entryFile gate and buildInstallPath returning null. Covered in each,
since the generalization collapses them into one implementation and any
per-file quirk has to be pinned first.

Two asymmetries are now pinned rather than smoothed over. copilot's handlers
return null for .gitkeep where claude's never do. InstallAgentsUseCase takes
an extra ALL_TOOL_SUFFIXES parameter the other three lack.

Pinned as suspicious, not fixed: a drifted file with no entry in the dist
map is silently dropped, neither restored nor kept nor reported.

One branch stays uncovered in all four install files:
\`.split("/").at(-1) ?? relativeFileName\`. split never returns an empty
array, so the fallback is unreachable. Documented rather than faked with a
test that cannot fail.

No production code changed. 2136/2136 pass (2118 plus 18), tsc clean.

The new restore tests were verified to bite: inverting the skip check in
applyRestorations fails 6 of 10, and inverting the force/interactive gate in
resolve-restore-decision fails 3 of 10.

--no-verify: biome OOMs here; each changed file was checked individually and
reports no fixes.

Co-Authored-By: Claude Opus 5 <[email protected]>
@blafourcade
blafourcade merged commit 5c78f4a into next Jul 29, 2026
14 checks passed
@blafourcade
blafourcade deleted the test/e8-01-install-restore-coverage branch July 29, 2026 04:07
blafourcade added a commit that referenced this pull request Jul 31, 2026
Coverage gate for epic E8's three refactors. Measured the eight files they
touch; two findings changed the plan.

RestoreRegularFilesUseCase had no dedicated test file anywhere. Its 42.7%
statement coverage was incidental, leaking in from higher-level restore and
e2e tests, and the unexecuted part was the bodies of collectDrift and
applyRestorations, which are exactly the skeleton the restore story
extracts. Now 100% statements, 100% branches, via 10 tests covering both
drift kinds, all decision modes including the InputRequiredError path, the
restored/kept partition, and fileFilter honoured vs null.

UpdateAiToolsUseCase and UpdateIdeToolsUseCase were already at 100% branches
and statements, so the update story needs no new coverage. Confirmed and
left alone rather than padded.

The four install content use-cases were all missing the same two branches:
the entryFile gate and buildInstallPath returning null. Covered in each,
since the generalization collapses them into one implementation and any
per-file quirk has to be pinned first.

Two asymmetries are now pinned rather than smoothed over. copilot's handlers
return null for .gitkeep where claude's never do. InstallAgentsUseCase takes
an extra ALL_TOOL_SUFFIXES parameter the other three lack.

Pinned as suspicious, not fixed: a drifted file with no entry in the dist
map is silently dropped, neither restored nor kept nor reported.

One branch stays uncovered in all four install files:
\`.split("/").at(-1) ?? relativeFileName\`. split never returns an empty
array, so the fallback is unreachable. Documented rather than faked with a
test that cannot fail.

No production code changed. 2136/2136 pass (2118 plus 18), tsc clean.

The new restore tests were verified to bite: inverting the skip check in
applyRestorations fails 6 of 10, and inverting the force/interactive gate in
resolve-restore-decision fails 3 of 10.

--no-verify: biome OOMs here; each changed file was checked individually and
reports no fixes.

Co-authored-by: Claude Opus 5 <[email protected]>
blafourcade added a commit that referenced this pull request Jul 31, 2026
Coverage gate for epic E8's three refactors. Measured the eight files they
touch; two findings changed the plan.

RestoreRegularFilesUseCase had no dedicated test file anywhere. Its 42.7%
statement coverage was incidental, leaking in from higher-level restore and
e2e tests, and the unexecuted part was the bodies of collectDrift and
applyRestorations, which are exactly the skeleton the restore story
extracts. Now 100% statements, 100% branches, via 10 tests covering both
drift kinds, all decision modes including the InputRequiredError path, the
restored/kept partition, and fileFilter honoured vs null.

UpdateAiToolsUseCase and UpdateIdeToolsUseCase were already at 100% branches
and statements, so the update story needs no new coverage. Confirmed and
left alone rather than padded.

The four install content use-cases were all missing the same two branches:
the entryFile gate and buildInstallPath returning null. Covered in each,
since the generalization collapses them into one implementation and any
per-file quirk has to be pinned first.

Two asymmetries are now pinned rather than smoothed over. copilot's handlers
return null for .gitkeep where claude's never do. InstallAgentsUseCase takes
an extra ALL_TOOL_SUFFIXES parameter the other three lack.

Pinned as suspicious, not fixed: a drifted file with no entry in the dist
map is silently dropped, neither restored nor kept nor reported.

One branch stays uncovered in all four install files:
\`.split("/").at(-1) ?? relativeFileName\`. split never returns an empty
array, so the fallback is unreachable. Documented rather than faked with a
test that cannot fail.

No production code changed. 2136/2136 pass (2118 plus 18), tsc clean.

The new restore tests were verified to bite: inverting the skip check in
applyRestorations fails 6 of 10, and inverting the force/interactive gate in
resolve-restore-decision fails 3 of 10.

--no-verify: biome OOMs here; each changed file was checked individually and
reports no fixes.

Co-authored-by: Claude Opus 5 <[email protected]>