✅ test(sarathi): services' file.ts, main.ts and 3 more have no surviving mutant (#492)
Slice: #492
pnpm exec agnipariksha --lane sarathi --files <the five services files> --no-reuse is the slice's bar: no Survived and no NoCoverage mutant. The five files total over the pre-push gate's 1000-line cut-off for the lane, so CI's required Mutation check judges this pull request.
Before. fixture-root.ts, reaper.ts and runner.ts are unchanged since 9b535c2, where the inventory left 54 in them. file.ts and main.ts changed on main since then. Re-measured on main (a828ae5), they had 45 left: 44 survived, 1 with no coverage. A hand probe of every one of those mutants against its owning suite now kills it, or the rewrite below removed it.
Tests. Each file's owning suite gains cases:
file.test.ts: the services file's refusals word for word, the regex anchors, ports and published entries.main.test.ts: the usage text for no action or a flag, the checkout lookup through the given env, git's stderr kept quiet, and a configured action.fixture-root.test.ts: the owner file,psthrough an injected runner.reaper.test.ts: the roots each project hashes to.runner.test.ts: the config's first write and upgrade, ports, the filled command, and the main-checkout check through the given env.
They assert literal values, and each builds its fixture inside its own test.
One test runs only off root. "a first config that cannot be written for a reason other than a peer's is an error" causes the refusal with chmod 0o500, and root writes through that. No root-proof failure reaches the same branch. storedConfig reads the path before the write and throws on anything but ENOENT, so a directory (EISDIR) or a file as parent (ENOTDIR) fails before the write. A dangling link reads as ENOENT, but then the write gets EEXIST, which is the peer branch. So the assertion runs if (process.getuid?.() !== 0), as runner.test.ts:366 on main already does, with no { skip }.
Rewrites. Each one keeps today's behaviour:
| File | Change | Why it is the same |
|---|---|---|
file.ts | isPort drops typeof value === 'number' | Number.isInteger is false for every non-number. |
file.ts | placeholders reads match[1] as string for match[1] ?? '' | The pattern's one group takes part in every match. |
file.ts | loadServicesFile decodes with String(readFileSync(path)) | Buffer#toString() decodes UTF-8. |
file.ts | ServicesError drops code = 'SERVICES' | A design call: nothing reads it. sarathi ships only its CLI, which prints error.message, and no code in the package reads a code of ServicesError. Pinning the string in a test would pin a value nobody observes. |
main.ts | git's toplevel runs with stdio: 'pipe' | It is the same output, and git reads no stdin. A test catches its stderr staying off the hook's. |
fixture-root.ts | processStatus takes an injectable run (default execFileSync), and its catch falls through to undefined | It is the same ps call and answer, and tests drive the runner. |
fixture-root.ts | the owner file's pid and createdAt are checked by Number.isInteger and Number.isFinite alone, and the file is decoded with String() | Both are false for every non-number. A null owner file throws at the destructure, into the same catch. |
reaper.ts | serviceRootState returns early for a missing root; a project's root is set under projectName(settings.project, root) | The root is found only when it hashes to project, so the key is the same. A missing project finds no root. |
reaper.ts | dockerRunning's catch falls through to return false | It gives the same answer. |
runner.ts | validPort drops typeof port === 'number' | Number.isInteger is false for every non-number. |
runner.ts | one filledEnvironment(file, values, names) for the services and for web, reading file.environment[name] as string | Each name is one the parsed file's environment holds: its own keys, or web's names, which the parser checks against it. |
runner.ts | serviceConfig takes a stored config as allocated when its web port matches, without serverPort !== 0 | validConfig allows a server port of 0 only with a web port of 0, and a parsed file's webPort is a port, 1 or more. |
runner.ts | runWith answers code ?? 1 | Node gives the exit code, or else the signal that ended the command, never neither. A signal ends it with 1, as before. |
runner.ts | assertMainCheckout reads each path through one revParse | It is the same two git calls, compared trimmed. |
runner.ts | fill is exported for its test; the stored-config read's fallback holds only its comment | The fallback returns undefined either way. |
runner.ts | services reads file.server once into server | It is the same refusal for a missing server command, and the same steps. |
Mutants that waited. CI judged every mutant killed but refused the lane twice (https://github.com/veda-hq/veda/issues/584). Each mutant that really hangs spends a full three-minute timeout retry, and five of those run out the pass's 15 minutes. A hand probe found nine, and the gate's own run seven more. All but compose's three now end in seconds, or in about a minute at most (0db53ae, 105c587):
| Mutant | Now |
|---|---|
bindAndRelease: 'listening' or 'close' emptied, close() or the finally body removed, listen()'s wait | bindAndRelease awaits the listen through its callback and, while listening, closes through promisify(close). No event name is left to empty, and a skipped close leaves the port bound, which a second real probe catches. Same calls, same answers: a failed bind still rejects with its error, and a bound one is closed before the probe returns. |
applicationPort: attempt < 20 forced true, += 1 to -= 1 | It counts twenty tries with Array(20).keys(), so no changed bound can loop forever. |
runWith: 'exit' emptied | The suite bounds each block at 60 s, not 300 s. The slowest block takes about 10 s, so the bound stays under Stryker's own limit for the file. |
| any case that fails with a server still listening | The suite closes every server a case started once its cases are done, so the file ends. |
lock waits (from the gate's own run, 105c587): 'config-lock' or 'lock' emptied, withLock's acquire try or its finally emptied | A start, a config upgrade and down take optional LockOptions from ServicesIo and hand them to withLock. The default is today's whole-start wait. The suite's io polls every 5 ms for at most 100 tries, so a lock a mutant leaves held fails its case in half a second, not in minutes. One case holds each of the three locks until the waiter's first pause, which shows every wait goes through the io's options. Direct withLock holders in the suite take one attempt: they acquire at once, and one that cannot no longer polls on after its case. main.test.ts drives servicesMain end to end, and a runner.ts mutant runs there too, so its io passes the same short wait, and its blocks are bounded at 60 s (cd7c7a5). |
still hang: compose's 'close' emptied, its close handler or its promise executor emptied | Each leaves the compose call pending while other cases' waits keep the file open. compose must keep spawn (its stdin is /dev/null, which execFile cannot give), so its event stays. Three retries fit the 15-minute pass. |
Equivalent mutants. None listed: each one found was killed, or removed by a rewrite above.
Released nothing and bumped no version.
🤖 Generated with Claude Code