ā test(sarathi): worktree/lifecycle.ts has no surviving mutant (#493)
Slice: #493
pnpm exec agnipariksha --lane sarathi --files packages/sarathi/src/worktree/lifecycle.ts --no-reuse now ends with 922 killed of 922: no Survived and no NoCoverage mutant. The pre-push gate judged it on a clean tree.
Before. lifecycle.ts and lifecycle.test.ts are unchanged from 9b535c2 to today's main. The inventory left 231: 199 in the lines this slice first named and 32 in lines 595ā673 (https://github.com/veda-hq/veda/issues/494). The gate judges the whole file, so neither part can pass alone. By Alok's yes of 2026-11-24, a file split across slices goes as one pull request under its first slice: this one covers the whole of lifecycle.ts, and the slice's issue now says so. https://github.com/veda-hq/veda/issues/494 closes as covered once this merges.
Tests. lifecycle.test.ts gains three suites:
- "the lifecycle, part by part" tests each helper in-process: runProgram's env and messages,
git's trailing newline, ancestor, the cloud check, within, real, the providers, receipt shapes, writeReceipt, launchBranch, husky shims, the compile cache, tmpChildren and ignoredArtifacts. - "the lifecycle against real git, case by case" covers inspect with
MERGE_HEADandREVERT_HEAD, begin's blockers and env,REMOTE's anchors, each PR-proof refusal, a merge commit missing from main, a repeat retirement, a worktree that changes during inspection, another worktree taking the branch, and the lock case by case. Further cases cover validBranch's exact ref and quiet stderr, an origin without.git, and a retired receipt read on a branch. - "the lifecycle command line, case by case" reads parseArgs's results and usage word for word. It also covers begin's and retire's refusals of an empty
--branchand a missing or non-positive--pr, the host lifecycleMain is given or builds, and which failures it answers as JSON.
The tests assert literal values and build their fixtures inside their own it.
Rewrites. Each one keeps today's behaviour:
| Where | Change | Why it is the same |
|---|---|---|
runProgram | stdio: 'pipe' for ['ignore', 'pipe', 'pipe'] | stdout and stderr were piped already. stdin becomes a pipe that execFileSync closes at once, so a child that reads it sees end of input, as it did with 'ignore'. |
within | drops rel === '' | For the folder itself, relative gives '', which passes the other three tests. |
readReceipt | the shape check moves out of the parse's try, as Object(state).version !== 1; the catch holds only a fail-open note | The same message for each refusal. A receipt that cannot be read or parsed leaves no state, and Object(undefined), like Object() of null, a number, a string or a list, has no version of 1. |
readReceipt | String(readFileSync(path)) for 'utf8' | Buffer#toString() decodes UTF-8. |
writeReceipt | the temp name keeps the UUID's dashes | The name is only renamed over the receipt; nothing matches it. |
launchBranch | receiptIsCurrent(state, current) ? state : {} | receiptIsCurrent is true for an empty receipt, which names no phase, so the old Object.keys(state).length > 0 guard picked the same side. |
huskyShim | String(parts[2]), no !== undefined | It is read only when parts.length === 3, so the third part exists. |
sharedLink | resolves inside the try, compares after it | The same calls, in the same order; within does not throw. |
exclusive | a takeOver() closure; one throw | It blocks in the same two cases: a holder that is alive or not a pid, and a second take() that fails. |
exclusive | the holder's pid is read as String(readFileSync(owner)) for 'utf8' | Buffer#toString() decodes UTF-8. |
mergeProof | String(match[1..3]) for destructuring defaults | REMOTE's three groups are mandatory, so they always match. |
mergeProof | the proof is set inside the try and checked after it | It is the same conditions and the same message. An answer that is not JSON, or has no PR's shape, still blocks. |
retire | update-ref <ref> <tip> '' for an all-zero old value | git's update-ref takes an empty old value, like all zeros, to mean the ref must not exist yet. |
retire | String(successor) for successor ?? '' | When the tip is not contained, successor was named or made, and checked by validBranch, a few lines above. |
retire | cat-file -e runs through the host's git instead of its own execFileSync | The same env and cwd. The host pipes the output and drops it, and a failure is still caught as "not here", which fetches the PR ref. Its limit is the host's 60 s instead of 30 s, and the host also sets GIT_OPTIONAL_LOCKS=0, which a read such as cat-file never needs. |
archiveCheck | splits on /\s/ and compares remote[0] alone | ls-remote --exit-code answers one <sha>\trefs/heads/main line, its newline stripped. rev-parse answers a sha or throws, so an empty first field never matches. |
lifecycleMain | the probe host takes DEFAULT_SETTINGS | They are the same values, and the probe only runs git rev-parse --show-toplevel, which no setting changes. |
Equivalent mutants. None listed: every mutant is killed.
Released nothing and bumped no version.
š¤ Generated with Claude Code
Summary by cubic
Kills all 922 mutants in packages/sarathi/src/worktree/lifecycle.ts, so agnipariksha ends with no surviving or uncovered mutant; the slice covers the whole file and closes issue #494 on merge.
Tests
- Adds three suites to
lifecycle.test.ts: helpers in-process, the lifecycle against real git fixtures, and the command line. - Tests assert literal values and build their own fixtures.
Refactors
- Rewrites parts of
lifecycle.tsto state each check once, keeping today's behavior:runProgram'sstdiobecomespipe,readReceiptandmergeProofcheck shape outside the parse's catch,retireasks the host about the merged head and creates its recovery ref with an empty old value, andlifecycleMain's probe uses the default settings.