✅ test(sarathi): worktree/settings.ts has no surviving mutant (#495)
Slice: #495
pnpm exec agnipariksha --lane sarathi --files packages/sarathi/src/worktree/settings.ts --no-reuse now ends with no Survived and no NoCoverage mutant. The pre-push gate judged settings.ts and lifecycle.ts together on a clean tree: 1238 killed of 1238.
Before. settings.ts changed on main since 9b535c2. Re-measured on main (a828ae5), it had 20 left, all survived.
Tests. settings.test.ts gains a suite, "worktree settings, rule by rule", that reads each rule word for word:
- the defaults;
- a worktree value that is no object, as a
SettingsErrornaming the file; - every unknown key, under the file and worktree;
- name, owner and cloud check only as strings;
- a package path only whole;
- a cleanup list with any entry outside the checkout.
The tests assert literal values and build their fixtures inside their own it.
Rewrites. Each one keeps today's behaviour:
| File | Change | Why it is the same |
|---|---|---|
settings.ts | SettingsError drops code = 'SETTINGS' | A design call: nothing read the value. Its only use was that lifecycleMain answers any error that has a code as a refusal. |
lifecycle.ts | lifecycleMain names SettingsError among the failures it answers as a refusal | This is the rewrite the line above forces. A settings file sarathi cannot use is still answered as { "blocked": … } with exit 2, as the code let it be before; "blocks on unreadable settings" shows it. Nothing else in sarathi reads an error's code to decide how to answer it. |
settings.ts | compiles falls through to return true after its catch | It gives the same answer: false for a pattern that does not compile, true otherwise. |
settings.ts | insidePath reads split('/')[0] as string, no ?. | split always gives a first part, if only ''. |
settings.ts | parseCleanup keeps primaryBuilt as checked, without filtering it again | Every entry passed insidePath a few lines above, or the list was refused. |
settings.ts | readSettings decodes with String(readFileSync(path)) | Buffer#toString() decodes UTF-8. |
A hand probe of every listed mutant, and of the ones the rewrites create, kills each against settings.test.ts, or lifecycle.test.ts for the new check.
Equivalent mutants. None listed: every mutant is killed.
Released nothing and bumped no version.
🤖 Generated with Claude Code
Summary by cubic
Removes every surviving mutant from worktree/settings.ts: mutation testing now kills 1238 of 1238 mutants on a clean tree.
- Adds a "rule by rule" suite in
settings.test.tsasserting defaults, non-object worktree values, unknown keys, string-only fields, whole package paths, and cleanup paths outside the checkout. - Rewrites six spots in
settings.tsto state each check once without changing behavior. - Drops
SettingsError's unusedcode;lifecycleMainnow namesSettingsErroramong the failures it answers as a refusal, so an unreadable settings file still blocks with exit 2.
Released nothing, bumped no version.