āœ… test(sarathi): hooks/autofix.ts has no surviving mutant (#490)

Merged
AT
4d ago
+549-71

Slice: #490

pnpm exec agnipariksha --lane sarathi --files packages/sarathi/src/hooks/autofix.ts --no-reuse now ends with 775 killed of 775: no Survived and no NoCoverage mutant. The pre-push gate judged it on a clean tree.

Before. autofix.ts and autofix.test.ts are unchanged from 9b535c2 to today's main. The inventory left 147 there (133 survived, 14 with no coverage).

Tests. autofix.test.ts gains cases for:

  • the list file, and reading tool answers;
  • each fact a tool event gives (set_monitor answers, a foreground gh pr create, get_status);
  • what changes the list, and seeing the set_monitor tool;
  • the warnings' words, respond, and keeping the app's events;
  • sarathi autofix's refusals and answers;
  • the hook script in-process.

They assert literal values, and each builds its fixture inside its own it, under a temporary XDG_STATE_HOME.

Rewrites. Each one keeps today's behaviour:

WhereChangeWhy it is the same
fromUrl, prUrlsa prOf(match) helper; prUrls reads its own match instead of matching match[0] againPR_URL has only the g flag, so fromUrl's copy of it (rebuilt from .source) matches the same text, and a whole match always parses.
runsPrCreatetakes unknown and checks for a string itselfIts callers passed '' for a non-string command, which never matches PR_CREATE.
readRowsno line.trim() === '' skipJSON.parse refuses a blank line, and its catch already skips one.
folda second opened always sets { ...known, url }url above is the URL the PR already had when it had one, so the set changes only a missing URL, as before.
addOpeneda putOpened(file, url, source, clock) helper, which autofixCommand also usesThe same row and the same refusal of a URL that names no PR. autofixCommand no longer reparses the URL to print it.
bashFacts, runsInBackgroundpass the raw command to runsPrCreateSee runsPrCreate.
setMonitorFacts(match[3] as string).trim() for (match[3] ?? '').trim()Each refusal pattern (REFUSED, REFUSED_BEFORE, NOT_BOUND) has a mandatory third group, so it is always a string when the pattern matches.
getStatusFactsan ended(state) helper; a failed parse falls through; otherBoundPrs is read only when it is a listUndefined status is refused by isRecord on the next line. A missing list yields no facts either way.
newsknown keeps only a PR's state and reasonOnly those two decide whether a fact changes the PR. A reason left undefined compares like one never given.
hasSetMonitorno path === '' check; a failed line parse falls throughreadFileSync('') fails, and its catch returns false. An entry left undefined is skipped by isRecord.
hasSetMonitorreads entries and addedNames only when each is a listThe same answer as reading an empty list.
warningwhen? with no defaultIt tests only when === 'opened', so undefined words the wrap-up text, as 'wrap_up' did.
warnwhen === 'wrap_up' ? WRAP_UP : 'gh pr create'when is one of the two, so the same source either way.
respondno isRecord(parsed) checkAny non-object JSON value but null has no session_id, so listFile refuses it. Null throws at that first read, into the catch, which returns ''.
responddrops !post before the Bash warningfactsOf gives Bash facts only on PostToolUse, and an event with no facts has already returned.
autofixCommandflag values come off the loop's own iterator; no ?? '' on the sessionThe same flags and errors. listFile(undefined) refuses a missing session, just as it refused ''.
exportsrunsInBackground, keepRaw and start are exported for the suiteNothing else imports them.
the script entryan exported start(script, moduleUrl, stdin, write, deps), called once at module levelIt answers only when argv[1] is this file, as before. An empty path resolves to the working folder, never this file. One difference: a bad argv[1] is now an unhandled rejection of start's promise, not a throw at import; the process fails either way.

Equivalent mutants. None listed: every mutant is killed.

Guard. niyam Guard's skip mark matches two string literals the tests assert, (Warn-only: nothing is blocked.) and lower case only: ß; nothing is skipped. #490's Guards: section names autofix.test.ts, approved in https://github.com/veda-hq/veda/issues/490#issuecomment-7139309983.

Released nothing and bumped no version.

šŸ¤– Generated with Claude Code