āœ… test(sarathi): worktree/lifecycle.ts has no surviving mutant (#493)

Merged
AT
4d ago
+748-38

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_HEAD and REVERT_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 --branch and 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:

WhereChangeWhy it is the same
runProgramstdio: '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'.
withindrops rel === ''For the folder itself, relative gives '', which passes the other three tests.
readReceiptthe shape check moves out of the parse's try, as Object(state).version !== 1; the catch holds only a fail-open noteThe 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.
readReceiptString(readFileSync(path)) for 'utf8'Buffer#toString() decodes UTF-8.
writeReceiptthe temp name keeps the UUID's dashesThe name is only renamed over the receipt; nothing matches it.
launchBranchreceiptIsCurrent(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.
huskyShimString(parts[2]), no !== undefinedIt is read only when parts.length === 3, so the third part exists.
sharedLinkresolves inside the try, compares after itThe same calls, in the same order; within does not throw.
exclusivea takeOver() closure; one throwIt blocks in the same two cases: a holder that is alive or not a pid, and a second take() that fails.
exclusivethe holder's pid is read as String(readFileSync(owner)) for 'utf8'Buffer#toString() decodes UTF-8.
mergeProofString(match[1..3]) for destructuring defaultsREMOTE's three groups are mandatory, so they always match.
mergeProofthe proof is set inside the try and checked after itIt is the same conditions and the same message. An answer that is not JSON, or has no PR's shape, still blocks.
retireupdate-ref <ref> <tip> '' for an all-zero old valuegit's update-ref takes an empty old value, like all zeros, to mean the ref must not exist yet.
retireString(successor) for successor ?? ''When the tip is not contained, successor was named or made, and checked by validBranch, a few lines above.
retirecat-file -e runs through the host's git instead of its own execFileSyncThe 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.
archiveChecksplits on /\s/ and compares remote[0] alonels-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.
lifecycleMainthe probe host takes DEFAULT_SETTINGSThey 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.ts to state each check once, keeping today's behavior: runProgram's stdio becomes pipe, readReceipt and mergeProof check shape outside the parse's catch, retire asks the host about the merged head and creates its recovery ref with an empty old value, and lifecycleMain's probe uses the default settings.