ā test(sarathi): hooks/autofix.ts has no surviving mutant (#490)
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_monitoranswers, a foregroundgh pr create,get_status); - what changes the list, and seeing the
set_monitortool; - 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:
| Where | Change | Why it is the same |
|---|---|---|
fromUrl, prUrls | a prOf(match) helper; prUrls reads its own match instead of matching match[0] again | PR_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. |
runsPrCreate | takes unknown and checks for a string itself | Its callers passed '' for a non-string command, which never matches PR_CREATE. |
readRows | no line.trim() === '' skip | JSON.parse refuses a blank line, and its catch already skips one. |
fold | a 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. |
addOpened | a putOpened(file, url, source, clock) helper, which autofixCommand also uses | The same row and the same refusal of a URL that names no PR. autofixCommand no longer reparses the URL to print it. |
bashFacts, runsInBackground | pass the raw command to runsPrCreate | See 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. |
getStatusFacts | an ended(state) helper; a failed parse falls through; otherBoundPrs is read only when it is a list | Undefined status is refused by isRecord on the next line. A missing list yields no facts either way. |
news | known keeps only a PR's state and reason | Only those two decide whether a fact changes the PR. A reason left undefined compares like one never given. |
hasSetMonitor | no path === '' check; a failed line parse falls through | readFileSync('') fails, and its catch returns false. An entry left undefined is skipped by isRecord. |
hasSetMonitor | reads entries and addedNames only when each is a list | The same answer as reading an empty list. |
warning | when? with no default | It tests only when === 'opened', so undefined words the wrap-up text, as 'wrap_up' did. |
warn | when === 'wrap_up' ? WRAP_UP : 'gh pr create' | when is one of the two, so the same source either way. |
respond | no isRecord(parsed) check | Any 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 ''. |
respond | drops !post before the Bash warning | factsOf gives Bash facts only on PostToolUse, and an event with no facts has already returned. |
autofixCommand | flag values come off the loop's own iterator; no ?? '' on the session | The same flags and errors. listFile(undefined) refuses a missing session, just as it refused ''. |
| exports | runsInBackground, keepRaw and start are exported for the suite | Nothing else imports them. |
| the script entry | an exported start(script, moduleUrl, stdin, write, deps), called once at module level | It 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