✅ test(sarathi): worktree/settings.ts has no surviving mutant (#495)

Merged
AT
3d ago
+56-7

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 SettingsError naming 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:

FileChangeWhy it is the same
settings.tsSettingsError 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.tslifecycleMain names SettingsError among the failures it answers as a refusalThis 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.tscompiles falls through to return true after its catchIt gives the same answer: false for a pattern that does not compile, true otherwise.
settings.tsinsidePath reads split('/')[0] as string, no ?.split always gives a first part, if only ''.
settings.tsparseCleanup keeps primaryBuilt as checked, without filtering it againEvery entry passed insidePath a few lines above, or the list was refused.
settings.tsreadSettings 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.ts asserting defaults, non-object worktree values, unknown keys, string-only fields, whole package paths, and cleanup paths outside the checkout.
  • Rewrites six spots in settings.ts to state each check once without changing behavior.
  • Drops SettingsError's unused code; lifecycleMain now names SettingsError among the failures it answers as a refusal, so an unreadable settings file still blocks with exit 2.

Released nothing, bumped no version.