✅ test(kavach): bash_guard.py lines 458–669 have no cosmic-ray survivor
Slice 42 of the mutation sweep (#466): cosmic-ray 8.9.0 leaves no survivor on bash_guard.py's lines that were 458–669 at 9b535c2, and none is listed as an equivalent.
Measured first
On main, bash_guard.py changed since 9b535c2 only by #755 (#507, which kept every line in place). Measured on #507's branch, which #755 has since merged: 492 mutants, 300 killed, 137 survived, 23 on lines no test ran (Branches.blend's variable loop, in_pipeline's pipe before the command, the depth counters' ) paths), and 32 timed out. Most timeouts were index loops that a mutant stops in place. The rest were module-level set unions, whose mutants run every test module that imports the guard.
On this branch, the same code is lines 458–666: 284 mutants, all killed. No survivor, timeout, capped run or uncovered line. Proof on Linux, with the gate's caps: draft veda-hq/veda#756 (never merges), run 46377602462.
Tests
In tests/test_bash_guard.py, the walker's helpers and Branches are called directly. Each is called in a child that loads bash_guard.py as the guard does and runs a snippet in its globals, on literal token lists.
command_head,at_command_start,assignment_only,is_argument(wrappers such astime,!andbuiltinstart no command of their own),in_pipeline(a pipe before the command, after it, and a pipe in a later command that does not count),runs_conditionally,list_end,first_orandbackground_end(nested and unbalanced parentheses, the end bound, a later&past a terminator), and wherecommand_env's scan starts.Branches:note,restart,blendandafter, each on an entry holding a directory, a stack and three variables.noteandblendsee an unchanged state and each kind of change: the directory, an unresolved one, a shorter and a longer stack, and variables added, changed and removed.- The unchanged values are equal objects built at run time, so
iscannot stand in for==.
Rewrites that keep behaviour
- Loops.
command_head,assignment_only,is_argument,in_pipeline,runs_conditionally,list_end,first_orandbackground_endwalk withforover arange,next(...),itertools.dropwhileoritertools.takewhile, not awhilewith a hand-moved index. Each returns what it did, and no mutant can stall one. - Sets.
TRACKED_ENV,COMMAND_LEADERSandLIST_ENDSare built with*unpacking instead of|of disjoint sets, where^gave the same set.WORD_STARTSis a comprehension overCOMMAND_LEADERS, which already holdsif,whileanduntil. - Depth. The three depth counters read
not depthfordepth == 0. The depth never goes below 0 there, so<=gave the same answer. command_env's start isiless the words since the last command leader, counted withtakewhile. The oldleaders[-1] + 1also worked as+ 0, since the leader token itself is never an assignment orenv.bash_guard.pyimportsitertools.
Lines move here: the slice's code is now lines 458–666, and what follows sits four lines earlier (9b535c2's line 671 is now 667). #509 to #512 map their ranges by the text at their ends.
Where each line is judged
The CI gate (kavach Python mutation) judges the rewritten lines.
Built on main after #755 (#507) merged.
Cubic's review allowance is used up until 9 December 2026, so its check reports neutral; Alok said to keep merging sweep pull requests without it until then.
Slice: #508
🤖 Generated with Claude Code
Summary by cubic
Rewrites the command-walker helpers and Branches in bash_guard.py so the mutation sweep finds no survivors there, and adds direct tests for them.
- Index loops (
command_head,assignment_only,is_argument,in_pipeline,runs_conditionally,list_end,first_or,background_end,command_env's start) are nowforloops or iterator functions, so no mutant can stall them. TRACKED_ENV,COMMAND_LEADERS, andLIST_ENDSuse unpacking instead of disjoint set unions;WORD_STARTSis a comprehension overCOMMAND_LEADERS.- New tests call each helper and
Branchesdirectly on literal token lists in a child that loads the module as the guard does.