@skathio/somi 4.0.1 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.copilot-extension/extension.json +1 -1
- package/.copilot-extension/marketplace.json +1 -1
- package/README.md +5 -4
- package/VERSION +1 -1
- package/agents/somi-coder.md +4 -228
- package/agents/somi-designer.md +4 -160
- package/agents/somi-discovery-analyst.md +4 -276
- package/agents/somi-flow.md +47 -0
- package/agents/somi-general.md +36 -0
- package/agents/somi-planner.md +4 -341
- package/agents/somi-reviewer.md +4 -199
- package/agents/somi.md +81 -253
- package/commands/adopt.md +6 -84
- package/commands/architecture-review.md +11 -86
- package/commands/atlas.md +10 -25
- package/commands/code-loop.md +10 -221
- package/commands/code-parallel.md +10 -151
- package/commands/code.md +9 -157
- package/commands/debug.md +9 -131
- package/commands/design.md +9 -160
- package/commands/discover.md +9 -194
- package/commands/impact.md +9 -25
- package/commands/incident.md +9 -39
- package/commands/plan-loop.md +9 -181
- package/commands/plan.md +9 -244
- package/commands/pr.md +10 -25
- package/commands/refactor-design.md +11 -89
- package/commands/refactor.md +11 -50
- package/commands/release-readiness.md +11 -70
- package/commands/review-panel.md +10 -141
- package/commands/review.md +11 -181
- package/commands/security-review.md +11 -75
- package/commands/ship-loop.md +9 -260
- package/commands/ship.md +9 -115
- package/commands/somi-config.md +11 -130
- package/commands/test-strategy.md +11 -75
- package/commands/upgrade.md +9 -72
- package/hooks/hooks.json +1 -1
- package/hooks/lib/common.mjs +8 -5
- package/hooks/pre-tool/block-dangerous-bash.mjs +1 -1
- package/hooks/pre-tool/block-secret-writes.mjs +5 -7
- package/hooks/pre-tool/guard-protected-paths.mjs +54 -34
- package/package.json +1 -1
- package/scripts/lib/cost-defaults.mjs +2 -0
- package/scripts/lib/escalation-facts.mjs +146 -0
- package/scripts/lib/escalation.mjs +129 -0
- package/scripts/lib/findings-ledger.mjs +241 -0
- package/scripts/lib/install-text.mjs +97 -0
- package/scripts/lib/loop-caps.mjs +140 -0
- package/scripts/lib/loop-diff.mjs +12 -70
- package/scripts/lib/loop-engine.mjs +227 -0
- package/scripts/lib/loop-escalate.mjs +49 -0
- package/scripts/lib/loop-exit.mjs +47 -0
- package/scripts/lib/loop-notes-compact.mjs +72 -0
- package/scripts/lib/loop-notes.mjs +282 -0
- package/scripts/lib/loop-review.mjs +355 -12
- package/scripts/lib/loop-state.mjs +44 -0
- package/scripts/lib/loop-step-close.mjs +75 -0
- package/scripts/lib/loop-step-kit.mjs +179 -0
- package/scripts/lib/loop-step-review.mjs +140 -0
- package/scripts/lib/loop-step-tool.mjs +89 -0
- package/scripts/lib/loop-step.mjs +303 -0
- package/scripts/lib/mcp-project-root.mjs +18 -7
- package/scripts/lib/path-facts.mjs +187 -0
- package/scripts/lib/path-safety.mjs +171 -0
- package/scripts/lib/run-card.mjs +73 -0
- package/scripts/size-budget-overrides.json +5 -13
- package/scripts/somi-card.mjs +39 -0
- package/scripts/somi-findings.mjs +56 -271
- package/scripts/somi-loop.mjs +84 -443
- package/scripts/somi-mcp.mjs +26 -95
- package/scripts/validate.sh +75 -57
- package/skills/flow-adopt/SKILL.md +92 -0
- package/skills/flow-architecture-review/SKILL.md +94 -0
- package/skills/flow-atlas/SKILL.md +34 -0
- package/skills/flow-code/SKILL.md +167 -0
- package/skills/flow-code-loop/SKILL.md +263 -0
- package/skills/flow-code-parallel/SKILL.md +160 -0
- package/skills/flow-debug/SKILL.md +141 -0
- package/skills/flow-design/SKILL.md +170 -0
- package/skills/flow-discover/SKILL.md +204 -0
- package/skills/flow-impact/SKILL.md +35 -0
- package/skills/flow-incident/SKILL.md +49 -0
- package/skills/flow-plan/SKILL.md +254 -0
- package/skills/flow-plan-loop/SKILL.md +254 -0
- package/skills/flow-pr/SKILL.md +34 -0
- package/skills/flow-refactor/SKILL.md +58 -0
- package/skills/flow-refactor-design/SKILL.md +97 -0
- package/skills/flow-release-readiness/SKILL.md +82 -0
- package/skills/flow-review/SKILL.md +193 -0
- package/skills/flow-review-panel/SKILL.md +154 -0
- package/skills/flow-security-review/SKILL.md +83 -0
- package/skills/flow-ship/SKILL.md +125 -0
- package/skills/flow-ship-loop/SKILL.md +274 -0
- package/skills/flow-somi-config/SKILL.md +142 -0
- package/skills/flow-status/SKILL.md +43 -0
- package/skills/flow-test-strategy/SKILL.md +83 -0
- package/skills/flow-upgrade/SKILL.md +82 -0
- package/skills/role-coder/SKILL.md +247 -0
- package/skills/role-designer/SKILL.md +172 -0
- package/skills/role-discovery-analyst/SKILL.md +288 -0
- package/skills/role-planner/SKILL.md +353 -0
- package/skills/role-reviewer/SKILL.md +218 -0
- package/skills/somi-checkpoint/SKILL.md +95 -0
- package/skills/somi-dispatch/SKILL.md +14 -14
- package/skills/somi-routing/SKILL.md +6 -2
- package/tests/hooks/cases/block-secret-writes.json +6 -1
- package/tests/hooks/cases/guard-protected-paths.json +44 -2
- package/tests/hooks/run.sh +21 -0
- package/tests/scripts/checkpoint-gate.sh +2 -2
- package/tests/scripts/cost-defaults.sh +2 -0
- package/tests/scripts/dispatch-line-gate.sh +4 -4
- package/tests/scripts/dispatch-reference-gate.sh +14 -14
- package/tests/scripts/escalation.sh +409 -0
- package/tests/scripts/eval-runner.sh +8 -7
- package/tests/scripts/fact-sheet.sh +296 -0
- package/tests/scripts/goldens/somi-loop.json +2 -2
- package/tests/scripts/lib/dispatch-reference-gate.mjs +14 -5
- package/tests/scripts/lib/escalation-facts-tests.mjs +140 -0
- package/tests/scripts/lib/escalation-tests.mjs +154 -0
- package/tests/scripts/lib/findings-ledger-tests.mjs +118 -0
- package/tests/scripts/lib/loop-engine-tests.mjs +287 -0
- package/tests/scripts/lib/loop-escalate-tests.mjs +356 -0
- package/tests/scripts/lib/loop-flow-gate.mjs +173 -0
- package/tests/scripts/lib/loop-notes-tests.mjs +384 -0
- package/tests/scripts/lib/loop-step-cli-tests.mjs +156 -0
- package/tests/scripts/lib/loop-step-close-tests.mjs +351 -0
- package/tests/scripts/lib/loop-step-lenient-tests.mjs +114 -0
- package/tests/scripts/lib/loop-step-state-tests.mjs +127 -0
- package/tests/scripts/lib/loop-step-tests.mjs +499 -0
- package/tests/scripts/lib/loop-step-unwritten-tests.mjs +55 -0
- package/tests/scripts/lib/path-facts-tests.mjs +198 -0
- package/tests/scripts/lib/path-safety-tests.mjs +201 -0
- package/tests/scripts/lib/run-suites.mjs +139 -0
- package/tests/scripts/lib/sizing-score-tests.mjs +210 -0
- package/tests/scripts/lib/sizing-set-tests.mjs +131 -0
- package/tests/scripts/lib/somi-mcp-loop-tests.mjs +226 -0
- package/tests/scripts/lib/somi-mcp-tests.mjs +21 -1
- package/tests/scripts/loop-engine.sh +22 -0
- package/tests/scripts/loop-flow-gate.sh +11 -0
- package/tests/scripts/review-panel-seats.sh +4 -4
- package/tests/scripts/run-card.sh +57 -0
- package/tests/scripts/run-suites.sh +74 -0
- package/tests/scripts/run.sh +11 -0
- package/tests/scripts/size-tier.sh +3 -3
- package/tests/scripts/somi-agent-dispatch-contract.sh +23 -3
- package/tests/scripts/somi-mcp.sh +1 -0
- package/tests/scripts/suite-plan.json +20 -0
|
@@ -100,13 +100,13 @@ else
|
|
|
100
100
|
bad "synthetic call-site cases: $unit_bad mismatch(es) -- see MISMATCH lines above"
|
|
101
101
|
fi
|
|
102
102
|
|
|
103
|
-
# --- fixture-level: a `cp -a` copy of the real
|
|
104
|
-
cp -a "$ROOT/
|
|
103
|
+
# --- fixture-level: a `cp -a` copy of the real skills/ + agents/ -------------------------------
|
|
104
|
+
cp -a "$ROOT/skills" "$TMP/skills"
|
|
105
105
|
cp -a "$ROOT/agents" "$TMP/agents"
|
|
106
106
|
|
|
107
107
|
# --- GREEN: the unmodified copy passes -----------------------------------------------------------
|
|
108
|
-
if out_green="$(node "$GATE" "$TMP/
|
|
109
|
-
ok "gate exits 0 against an unmodified cp -a copy of the real
|
|
108
|
+
if out_green="$(node "$GATE" "$TMP/skills" "$TMP/agents" 2>&1)"; then
|
|
109
|
+
ok "gate exits 0 against an unmodified cp -a copy of the real skills/ + agents/"
|
|
110
110
|
else
|
|
111
111
|
bad "gate exited non-zero against an unmodified copy (got: $out_green)"
|
|
112
112
|
fi
|
|
@@ -129,27 +129,27 @@ else
|
|
|
129
129
|
bad "expected at least 21 commands derived as starting an agent, got $checked_count -- the call-site pattern derivation may have regressed"
|
|
130
130
|
fi
|
|
131
131
|
|
|
132
|
-
# --- RED: removing
|
|
132
|
+
# --- RED: removing skills/flow-code/SKILL.md's dispatch reference must fail ------------------------------
|
|
133
133
|
# Strips BOTH satisfying tokens, not just one -- the gate now accepts either "skills/somi-dispatch"
|
|
134
134
|
# or "somi_resolve" (DISPATCH_REFERENCE_RE), so a fixture that only strips lines mentioning
|
|
135
135
|
# "somi-dispatch" would leave a bare "somi_resolve" mention behind and this RED case would no
|
|
136
136
|
# longer actually go red.
|
|
137
|
-
sed -i -E '/somi-dispatch|somi_resolve/d' "$TMP/
|
|
138
|
-
out_red="$(node "$GATE" "$TMP/
|
|
137
|
+
sed -i -E '/somi-dispatch|somi_resolve/d' "$TMP/skills/flow-code/SKILL.md"
|
|
138
|
+
out_red="$(node "$GATE" "$TMP/skills" "$TMP/agents" 2>&1)"; rc_red=$?
|
|
139
139
|
if [ "$rc_red" -eq 1 ]; then
|
|
140
|
-
ok "gate exits 1 once
|
|
140
|
+
ok "gate exits 1 once skills/flow-code/SKILL.md's dispatch reference is removed"
|
|
141
141
|
else
|
|
142
|
-
bad "gate did not exit 1 after removing
|
|
142
|
+
bad "gate did not exit 1 after removing skills/flow-code/SKILL.md's reference (rc=$rc_red, out=$out_red)"
|
|
143
143
|
fi
|
|
144
144
|
case "$out_red" in
|
|
145
|
-
*"MISSING DISPATCH REFERENCE: code.md"*) ok "gate names code.md as missing the dispatch reference" ;;
|
|
145
|
+
*"MISSING DISPATCH REFERENCE: flow-code/SKILL.md"*) ok "gate names code.md as missing the dispatch reference" ;;
|
|
146
146
|
*) bad "gate's output does not name code.md as missing the reference (got: $out_red)" ;;
|
|
147
147
|
esac
|
|
148
148
|
|
|
149
149
|
# --- RED fixture does not spuriously flag OTHER commands (only code.md was touched) --------------
|
|
150
150
|
case "$out_red" in
|
|
151
151
|
*"MISSING DISPATCH REFERENCE"*"MISSING DISPATCH REFERENCE"*)
|
|
152
|
-
bad "more than one command flagged missing -- only
|
|
152
|
+
bad "more than one command flagged missing -- only skills/flow-code/SKILL.md was modified (got: $out_red)" ;;
|
|
153
153
|
*)
|
|
154
154
|
ok "exactly one command (code.md) is flagged, not a spurious wider failure" ;;
|
|
155
155
|
esac
|
|
@@ -159,12 +159,12 @@ router_out="$(node --input-type=module -e '
|
|
|
159
159
|
import { agentStartedBy, agentNamesFrom } from "'"$GATE"'";
|
|
160
160
|
const names = agentNamesFrom("'"$TMP"'/agents");
|
|
161
161
|
import fs from "node:fs";
|
|
162
|
-
const text = fs.readFileSync("'"$TMP"'/
|
|
162
|
+
const text = fs.readFileSync("'"$TMP"'/skills/flow-ship/SKILL.md", "utf8");
|
|
163
163
|
console.log(agentStartedBy(text, names) === null ? "EXCLUDED" : "FALSE POSITIVE");
|
|
164
164
|
' 2>&1)"
|
|
165
165
|
case "$router_out" in
|
|
166
|
-
EXCLUDED) ok "
|
|
167
|
-
*) bad "
|
|
166
|
+
EXCLUDED) ok "skills/flow-ship/SKILL.md (a router -- Tasks other commands, never an agent) is correctly excluded" ;;
|
|
167
|
+
*) bad "skills/flow-ship/SKILL.md was NOT excluded (got: $router_out) -- a router must never be misdiagnosed as starting an agent" ;;
|
|
168
168
|
esac
|
|
169
169
|
|
|
170
170
|
bash "$ROOT/tests/scripts/review-panel-seats.sh" || fail=$((fail+1))
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Guards scripts/lib/escalation.mjs and escalation-facts.mjs. Runs each test lib, then proves the suite has teeth: every mutation of the module,
|
|
3
|
+
# applied to a scratch copy, must turn the test NAMED for it red (a mutant that fails some other way, or not at all, is
|
|
4
|
+
# a failure). Hermetic: temp tree only, no network, no model.
|
|
5
|
+
set -uo pipefail
|
|
6
|
+
umask 022
|
|
7
|
+
|
|
8
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
9
|
+
SELF="$ROOT/tests/scripts/escalation.sh"
|
|
10
|
+
TMP="$(mktemp -d)"
|
|
11
|
+
trap 'chmod -R u+rwx "$TMP" 2>/dev/null; rm -rf "$TMP"' EXIT
|
|
12
|
+
pass=0; fail=0
|
|
13
|
+
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
14
|
+
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
15
|
+
|
|
16
|
+
# run_suite <test lib> <module>: prints the suite's lines, folds its SUMMARY into the totals.
|
|
17
|
+
run_suite() {
|
|
18
|
+
local out rc total failed
|
|
19
|
+
out="$(node "$1" "$2" 2>&1)"; rc=$?
|
|
20
|
+
printf '%s\n' "$out" | grep -v '^SUMMARY'
|
|
21
|
+
total="$(printf '%s\n' "$out" | awk '/^SUMMARY/{print $2}')"; failed="$(printf '%s\n' "$out" | awk '/^SUMMARY/{print $3}')"
|
|
22
|
+
pass=$((pass + ${total:-0} - ${failed:-0})); fail=$((fail + ${failed:-1}))
|
|
23
|
+
[ "$rc" = 0 ] || [ "${failed:-1}" -gt 0 ] || fail=$((fail+1))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# mutate <test lib> <module> <label> <test it must break> <from> <to>: the first <from> in the module becomes <to>.
|
|
27
|
+
mutate() {
|
|
28
|
+
local lib="$1" mod="$2" label="$3" named="$4" mut="${MUT_OUT:-$TMP/mutant-$(basename "$2")}"
|
|
29
|
+
node -e "const fs=require('fs');const s=fs.readFileSync(process.argv[1],'utf8');const t=s.replace(process.argv[2],()=>process.argv[3]);if(t===s)process.exit(3);fs.writeFileSync(process.argv[4],t)" "$mod" "$5" "$6" "$mut"
|
|
30
|
+
if [ $? != 0 ]; then bad "mutation '$label' did not change the module (stale pattern)"; return; fi
|
|
31
|
+
local out; out="$(node "$lib" "$mut" 2>&1)"
|
|
32
|
+
if grep -qF -- " FAIL $named" <<<"$out"; then ok "mutation '$label' turns '$named' red"; else bad "mutation '$label' did not turn '$named' red"; fi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
echo "== escalation =="
|
|
36
|
+
ES="$ROOT/scripts/lib/escalation.mjs"; EST="$ROOT/tests/scripts/lib/escalation-tests.mjs"
|
|
37
|
+
unset SKIP_DOMAIN ESCALATE_ONLY ESCALATE_LIB MUT_OUT # inherited, these would skip checks, redirect the real runs or send every mutant to one file
|
|
38
|
+
# The self-checks at the end run this script up to here, asked for by an argument: nothing in the environment can stop a real run early.
|
|
39
|
+
[ "${1:-}" != --env-probe ] || { echo "env:${ESCALATE_ONLY+only}${ESCALATE_LIB+lib}${MUT_OUT+out}"; exit 0; }
|
|
40
|
+
run_suite "$EST" "$ES"
|
|
41
|
+
[ "${1:-}" != --first-suite ] || exit 0
|
|
42
|
+
|
|
43
|
+
T_EMPTY='an empty fact set seats only the reviewer'
|
|
44
|
+
T_SIZE='size_flag at the line and file edges'
|
|
45
|
+
T_WEAK='tests_weakened at net -19 and -20'
|
|
46
|
+
T_MOVED='a moved test (a delete plus an add'
|
|
47
|
+
T_TWK='tests_weakened raises security and seats the test strategist'
|
|
48
|
+
T_MOD='modules at 2 and 3, and one new top directory'
|
|
49
|
+
T_STRAT='the test strategist: a large test change'
|
|
50
|
+
T_PLAN='the plan and sdlc lenses follow their flags'
|
|
51
|
+
T_SENS='every sensitive class name raises security'
|
|
52
|
+
T_BOUND='every boundary class name raises security'
|
|
53
|
+
T_CONTRACT='a contract or ci class name raises no lens'
|
|
54
|
+
T_DENIED='a denied flag, or the deny_list class name'
|
|
55
|
+
T_HARD='hard-surface ids: manifest, lockfile'
|
|
56
|
+
T_SECLENS='the raising classes and reasons name security'
|
|
57
|
+
T_REFUSED='refused input returns the raising result'
|
|
58
|
+
T_REFALL='the refused result seats every lens'
|
|
59
|
+
T_INTERNAL='an unexpected error in the rules'
|
|
60
|
+
T_FROZEN='the registries and constants are frozen'
|
|
61
|
+
T_DOM='the monotonicity domain has 55,296 evaluations'
|
|
62
|
+
T_MONO='a fact moved one step up never turns off'
|
|
63
|
+
T_RMIN='review_min is null or security over the whole domain'
|
|
64
|
+
T_TOP='the refused result dominates every result'
|
|
65
|
+
T_REACHED='the internal-error test breaks the rules where it means to'
|
|
66
|
+
# The exhaustive checks cost about two seconds, so the mutants that do not name one of them skip them.
|
|
67
|
+
es() { local skip=mutant-run; case "$2" in "$T_DOM"*|"$T_MONO"*|"$T_RMIN"*|"$T_TOP"*) skip= ;; esac; SKIP_DOMAIN=$skip mutate "$EST" "$ES" "$@"; }
|
|
68
|
+
|
|
69
|
+
# the raise
|
|
70
|
+
es 'sensitive class names dropped from the raise' "$T_SENS" '...sensitive.filter((n) => n !== DENY).map((n) => `sensitive:${n}`),' ''
|
|
71
|
+
es 'boundary class names dropped from the raise' "$T_BOUND" '...boundary.filter((n) => n !== DENY).map((n) => `boundary:${n}`),' ''
|
|
72
|
+
es 'denied ignored' "$T_DENIED" "...when(denied, DENY), ...when(tests_weakened, 'tests_weakened')," "...when(tests_weakened, 'tests_weakened'),"
|
|
73
|
+
es 'the deny_list class name no longer reads as denied' "$T_DENIED" 'sensitive.includes(DENY) || boundary.includes(DENY)' 'false'
|
|
74
|
+
es 'tests_weakened ignored in the raise' "$T_TWK" "...when(denied, DENY), ...when(tests_weakened, 'tests_weakened')," '...when(denied, DENY),'
|
|
75
|
+
es 'security seat read from fewer reasons than the raise' "$T_SECLENS" "'somi-security-reviewer': reasons," "'somi-security-reviewer': reasons.slice(1),"
|
|
76
|
+
es 'review_min allowed to return another value' "$T_RMIN" "review_min: reasons.length > 0 ? 'security' : null," "review_min: reasons.length > 2 ? 'panel' : reasons.length > 0 ? 'security' : null,"
|
|
77
|
+
es 'the rules no longer call the method the internal-error test breaks' "$T_REACHED" $'...sensitive.filter((n) => n !== DENY).map((n) => `sensitive:${n}`),\n ...boundary.filter((n) => n !== DENY).map((n) => `boundary:${n}`),' $'...sensitive.flatMap((n) => (n === DENY ? [] : [`sensitive:${n}`])),\n ...boundary.flatMap((n) => (n === DENY ? [] : [`boundary:${n}`])),'
|
|
78
|
+
# tests_weakened
|
|
79
|
+
es 'the -20 edge moved' "$T_WEAK" '-net >= WEAKENED_NET_LINES' '-net > WEAKENED_NET_LINES'
|
|
80
|
+
es 'the net-loss constant changed' "$T_WEAK" 'WEAKENED_NET_LINES = 20' 'WEAKENED_NET_LINES = 21'
|
|
81
|
+
es 'a deleted test file no longer counts' "$T_WEAK" 'f.test_files_deleted >= 1 || ' ''
|
|
82
|
+
es 'the moved-test case flipped' "$T_MOVED" 'net < 0 &&' 'net <= 0 &&'
|
|
83
|
+
# size mark
|
|
84
|
+
es 'the line edge moved' "$T_SIZE" 'f.production_lines > SIZE_FLAG_LINES' 'f.production_lines >= SIZE_FLAG_LINES'
|
|
85
|
+
es 'the file edge moved' "$T_SIZE" 'f.production_files > SIZE_FLAG_FILES' 'f.production_files >= SIZE_FLAG_FILES'
|
|
86
|
+
es 'size raises a lens' "$T_SIZE" 'reasons = [' 'reasons = [...when(f.production_lines > SIZE_FLAG_LINES, "size"),'
|
|
87
|
+
# the lens rules
|
|
88
|
+
es 'the reviewer seat dropped' "$T_EMPTY" $'\'somi-reviewer\': [\'always\'],\n \'somi-security-reviewer\': reasons,' $'\'somi-reviewer\': [],\n \'somi-security-reviewer\': reasons,'
|
|
89
|
+
es 'the modules edge moved' "$T_MOD" 'f.modules > MAX_MODULES_SEAT' 'f.modules >= MAX_MODULES_SEAT'
|
|
90
|
+
es 'new top directories no longer seat architecture' "$T_MOD" "...when(f.new_top_dirs >= 1, 'new_top_dirs'), " ''
|
|
91
|
+
es 'a contract name no longer seats architecture' "$T_CONTRACT" '...contract.map((n) => `contract:${n}`), ' ''
|
|
92
|
+
es 'the large-test-change edge moved' "$T_STRAT" 'f.test_lines_added + f.test_lines_deleted >= LARGE_TEST_CHANGE' 'f.test_lines_added + f.test_lines_deleted > LARGE_TEST_CHANGE'
|
|
93
|
+
es 'untested production no longer seats the strategist' "$T_STRAT" "...when(f.production_lines >= UNTESTED_PRODUCTION_LINES && f.test_files_changed === 0, 'untested_production')," ''
|
|
94
|
+
es 'the untested-production edge moved' "$T_STRAT" 'f.production_lines >= UNTESTED_PRODUCTION_LINES' 'f.production_lines > UNTESTED_PRODUCTION_LINES'
|
|
95
|
+
es 'the plan-paths rule dropped' "$T_PLAN" "...when(f.plan_paths, 'plan_paths')" ''
|
|
96
|
+
es 'the work-item-paths rule dropped' "$T_PLAN" "...when(f.work_item_paths, 'work_item_paths')" ''
|
|
97
|
+
# hard surface
|
|
98
|
+
es 'contract names dropped from the hard surface' "$T_HARD" 'const hard = [...contract, ' 'const hard = ['
|
|
99
|
+
es 'migrations no longer a hard surface' "$T_HARD" "...when(sensitive.includes('migrations'), 'migration'), " ''
|
|
100
|
+
es 'the ci class name no longer a hard surface' "$T_HARD" 'ci.length > 0 || ' ''
|
|
101
|
+
# monotonicity
|
|
102
|
+
es 'a bigger diff turns the size mark off' "$T_MONO" 'f.production_lines > SIZE_FLAG_LINES || f.production_files > SIZE_FLAG_FILES' '(f.production_lines > SIZE_FLAG_LINES && f.production_files < 6) || (f.production_files > SIZE_FLAG_FILES && f.production_lines < 151)'
|
|
103
|
+
es 'many reasons turn the lens off' "$T_MONO" "review_min: reasons.length > 0 ? 'security' : null," "review_min: reasons.length > 0 && reasons.length < 4 ? 'security' : null,"
|
|
104
|
+
es 'a new top directory turns the module seat off' "$T_MONO" 'f.modules > MAX_MODULES_SEAT' '(f.modules > MAX_MODULES_SEAT && f.new_top_dirs < 1)'
|
|
105
|
+
es 'the refused result lacks a hard-surface id' "$T_TOP" 'hard_surface: [...HARD_SURFACE_IDS],' 'hard_surface: [],'
|
|
106
|
+
# refused input
|
|
107
|
+
es 'the refused result does not raise' "$T_REFUSED" "review_min: 'security',
|
|
108
|
+
reasons: [reason]," "review_min: null,
|
|
109
|
+
reasons: [reason],"
|
|
110
|
+
es 'a throw escapes' "$T_REFUSED" 'catch { return refused(REFUSED_REASON); }' 'catch (e) { throw e; }'
|
|
111
|
+
es 'an unreadable input is reported as an internal error' "$T_REFUSED" 'catch { return refused(REFUSED_REASON); }' 'catch { return refused(INTERNAL_REASON); }'
|
|
112
|
+
es 'an internal error is reported as unreadable input' "$T_INTERNAL" 'catch { return refused(INTERNAL_REASON); }' 'catch { return refused(REFUSED_REASON); }'
|
|
113
|
+
es 'an internal error escapes' "$T_INTERNAL" 'catch { return refused(INTERNAL_REASON); }' 'catch (e) { throw e; }'
|
|
114
|
+
es 'an accessor is read' "$T_REFUSED" "return d && 'value' in d ? d.value : refuse();" 'return d ? o[k] : refuse();'
|
|
115
|
+
es 'a negative count accepted' "$T_REFUSED" 'Number.isSafeInteger(v) && v >= 0' 'Number.isSafeInteger(v)'
|
|
116
|
+
es 'an unknown class name accepted' "$T_REFUSED" 'out.every((n) => allowed.includes(n)) ?' 'true ?'
|
|
117
|
+
es 'a non-plain object accepted' "$T_REFUSED" '[Object.prototype, null].includes(Object.getPrototypeOf(o))' 'true'
|
|
118
|
+
es 'a duplicate class name kept' "$T_SECLENS" '? [...new Set(out)].sort() :' '? out.sort() :'
|
|
119
|
+
es 'an unknown key accepted' "$T_REFUSED" 'have.length === want.length && ' ''
|
|
120
|
+
es 'the refused result seats fewer lenses' "$T_REFALL" 'seated(Object.fromEntries(SEATS.map((l) => [l, [reason]])))' "seated(Object.fromEntries(SEATS.map((l) => [l, l === 'somi-reviewer' ? ['always'] : []])))"
|
|
121
|
+
es 'the registries left mutable' "$T_FROZEN" '[k, Object.freeze(v)]' '[k, v]'
|
|
122
|
+
|
|
123
|
+
# A shrunk monotonicity domain must turn the suite red: the same lib with one value taken out, run on the real module.
|
|
124
|
+
shrunk="$TMP/escalation-tests-shrunk.mjs"
|
|
125
|
+
node -e "const fs=require('fs');const s=fs.readFileSync(process.argv[1],'utf8');const t=s.replace('[0, 150, 151], [0, 5, 6]','[0, 150], [0, 5, 6]');if(t===s)process.exit(3);fs.writeFileSync(process.argv[2],t)" "$EST" "$shrunk"
|
|
126
|
+
out="$(node "$shrunk" "$ES" 2>&1)"
|
|
127
|
+
if grep -qF -- " FAIL $T_DOM" <<<"$out"; then ok 'a shrunk monotonicity domain turns the count red'; else bad 'a shrunk monotonicity domain did not turn the count red'; fi
|
|
128
|
+
|
|
129
|
+
# A stray exported SKIP_DOMAIN must not turn the exhaustive checks off.
|
|
130
|
+
stray="$(SKIP_DOMAIN=1 node "$EST" "$ES" 2>&1)"
|
|
131
|
+
if grep -qF " ok $T_DOM" <<<"$stray" && ! grep -qF ' skip ' <<<"$stray"; then ok 'a stray exported SKIP_DOMAIN skips nothing'; else bad 'a stray exported SKIP_DOMAIN skipped a check'; fi
|
|
132
|
+
|
|
133
|
+
# ---- scripts/lib/escalation-facts.mjs ----
|
|
134
|
+
echo "== escalation facts =="
|
|
135
|
+
EF="$ROOT/scripts/lib/escalation-facts.mjs"; EFT="$ROOT/tests/scripts/lib/escalation-facts-tests.mjs"
|
|
136
|
+
ln -s "$ROOT/scripts/lib/path-facts.mjs" "$TMP/path-facts.mjs"; ln -s "$ROOT/scripts/lib/path-safety.mjs" "$TMP/path-safety.mjs"; ln -s "$ES" "$TMP/escalation.mjs" # a scratch copy imports its siblings
|
|
137
|
+
run_suite "$EFT" "$EF"
|
|
138
|
+
ef() { mutate "$EFT" "$EF" "$@"; }
|
|
139
|
+
TF_ROWS='a new 40-line file sizes nothing'; TF_DENY='a deleted .env, a renamed id_rsa'; TF_HARD='each hard-surface id comes from its path'; TF_CI='CI paths raise security as a sensitive name'
|
|
140
|
+
TF_WEAK='tests_weakened: a moved test'; TF_TOP='a top directory is new only when'; TF_IGN='planning churn under .somi is ignored'; TF_CFG='through the real loadConfig'; TF_PLAN='plan inputs: a plan directory'
|
|
141
|
+
TF_GUARD='the guard raises sensitive config on every row'; TF_UNPLAIN='a name with an empty, dot or dot-dot segment'; TF_SUM='a summed count past the safe integers'
|
|
142
|
+
TF_GROWN='a name that only passes the length cap once folded'; TF_ONLY='only undefined or the loadConfig shape is read'; TF_REF='a refused sensitive_paths key is noted'
|
|
143
|
+
TF_ALSO='the guard raises on a row among ordinary ones'; TF_QUIET='the guard is not wider than its names'
|
|
144
|
+
TF_FLIP='the config layers are read once'; TF_NOROW='a refused config shape raises sensitive config with no row'
|
|
145
|
+
TF_COVER='every degraded result covers a full read'
|
|
146
|
+
TF_GLOB='a glob list with a hole or past the cap'; TF_CLOCK='the clock is read once whatever the kept count'
|
|
147
|
+
TF_HOST='a path over the length cap, a control character'; TF_MANY='10,000 rows, a non-list'; TF_BOX='a time box that runs out returns the floor'
|
|
148
|
+
ef 'the contract class not mapped' "$TF_HARD" "const KINDS = ['sensitive', 'boundary', 'contract'];" "const KINDS = ['sensitive', 'boundary'];"
|
|
149
|
+
ef 'the boundary class not mapped' "$TF_ROWS" "const KINDS = ['sensitive', 'boundary', 'contract'];" "const KINDS = ['sensitive', 'contract'];"
|
|
150
|
+
ef 'CI routed only into classes.ci' "$TF_CI" 'sensitive: names(seen.sensitive),' "sensitive: names(new Set([...seen.sensitive].filter((n) => n !== 'ci'))),"
|
|
151
|
+
ef 'the ci list emptied' "$TF_CI" "ci: seen.sensitive.has('ci') ? ['ci'] : []" 'ci: []'
|
|
152
|
+
ef 'the status letter ignored for deleted tests' "$TF_WEAK" "if (r.status === 'D') f.test_files_deleted++;" 'f.test_files_deleted++;'
|
|
153
|
+
ef 'the status letter ignored for new directories' "$TF_TOP" "&& r.status === 'A'" ''
|
|
154
|
+
ef 'denied computed after the status filter' "$TF_DENY" 'f.denied ||= c.denied;' "f.denied ||= c.denied && r.status !== 'D';"
|
|
155
|
+
ef 'the production split ignored' '151 production lines flag the size mark' 'if (c.production) {' 'if (true) {'
|
|
156
|
+
ef 'the module count dropped' "$TF_TOP" 'modules.add(c.module);' ''
|
|
157
|
+
ef 'the .somi ignore removed' "$TF_IGN" "['.somi', '.claude'].includes(file.split('/')[0])" 'false'
|
|
158
|
+
ef 'an ignored row no longer floors a denied name' "$TF_IGN" 'f.denied ||= denyListed(r.file);' ';'
|
|
159
|
+
ef 'the quoted-name rule removed' 'a git-quoted name is an unusable row' "&& !r.file.startsWith('\"')" ''
|
|
160
|
+
ef 'the control-character check removed' "$TF_HOST" ' && !UNSAFE_CHARS.test(r.file)' ''
|
|
161
|
+
ef 'the path length check removed' "$TF_HOST" 'r.file.length > 0 && r.file.length <= MAX_PATH_CHARS' 'r.file.length > 0'
|
|
162
|
+
ef 'the row cap removed' "$TF_MANY" 'rows.length > MAX_ROWS' 'false'
|
|
163
|
+
ef 'the config not passed on' "$TF_CFG" 'classifyPaths(chunk.map((r) => r.file), config)' 'classifyPaths(chunk.map((r) => r.file))'
|
|
164
|
+
ef 'the time box removed' "$TF_BOX" 'if (Date.now() - start >= budget) return' 'if (false) return'
|
|
165
|
+
ef 'the time box returns the partial facts' "$TF_BOX" "return { facts: floor(plan), notes: ['time_box'] };" 'break;'
|
|
166
|
+
ef 'the floor lets test lines switch tests_weakened off' 'every degraded result covers a full read' 'test_lines_added: 0, test_files_changed: 0, ' ''
|
|
167
|
+
ef 'the chunk step skips a row' 'rows past the first chunk are read' 'at += CHUNK;' 'at += CHUNK + 1;'
|
|
168
|
+
ef 'the chunk loop stops after the first chunk' 'rows past the first chunk are read' 'at += CHUNK;' 'at += 1000;'
|
|
169
|
+
ef 'the clock is read only when a row is kept' "$TF_CLOCK" 'do { // the clock is read at least once, whatever the kept count' 'while (kept.length > 0 && at < kept.length) {'
|
|
170
|
+
ef 'a glob list read through slice again, holes kept' "$TF_GLOB" 'Array.from({ length: Math.min(v.length, MAX_GLOBS + 1) }, (_, i) => v[i])' 'Array.prototype.slice.call(v, 0, MAX_GLOBS + 1)'
|
|
171
|
+
ef 'a glob list capped at the limit, so one past it reads as within it' "$TF_GLOB" 'Math.min(v.length, MAX_GLOBS + 1)' 'Math.min(v.length, MAX_GLOBS)'
|
|
172
|
+
ef 'the guard reads the case as written' "$TF_GUARD" 'flatMap((s) => foldName(s).split(SEP))' 'flatMap((s) => s.split(SEP))'
|
|
173
|
+
ef 'the guard does not re-split a folded separator' "$TF_GUARD" 'foldName(s).split(SEP)' '[foldName(s)]'
|
|
174
|
+
ef 'the guard re-splits a folded separator on forward slashes only' "$TF_GUARD" 'foldName(s).split(SEP)' "foldName(s).split('/')"
|
|
175
|
+
ef 'the guard splits on forward slashes only' "$TF_GUARD" 'const SEP = /[\\/]/;' 'const SEP = /\//;'
|
|
176
|
+
ef 'the guard keeps trailing dots and spaces' "$TF_GUARD" '.map(trimDots);' ';'
|
|
177
|
+
ef 'the guard runs only on ignored rows' "$TF_GUARD" 'if (guarded(r.file)) seen' 'if (hidden(r.file) && guarded(r.file)) seen'
|
|
178
|
+
ef 'the guard reaches only a root .claude' "$TF_GUARD" "segs.includes('.claude') ||" "head === '.claude' ||"
|
|
179
|
+
ef 'the guard drops CLAUDE.local.md' "$TF_GUARD" "segs.includes('claude.local.md') || " ''
|
|
180
|
+
ef 'the guard drops a bare .claude' "$TF_GUARD" "segs.includes('.claude') ||" "(segs.includes('.claude') && second !== undefined) ||"
|
|
181
|
+
ef 'the guard drops a bare .somi' "$TF_GUARD" 'second === undefined || ' ''
|
|
182
|
+
ef 'the guard drops .somi/config.json' "$TF_GUARD" " || second === 'config.json'" ''
|
|
183
|
+
ef 'the plugins exemption restored' "$TF_GUARD" "segs.includes('.claude') ||" "(segs.includes('.claude') && segs.slice(1, 3).join('/') !== 'plugins/somi') ||"
|
|
184
|
+
ef 'the guard reaches only the first level of .claude' "$TF_GUARD" "segs.includes('.claude') ||" "(segs.includes('.claude') && segs.length < 3) ||"
|
|
185
|
+
ef 'the guard drops .somi/rules' "$TF_GUARD" " || second === 'rules'" ''
|
|
186
|
+
ef 'the guard drops .mcp.json' "$TF_GUARD" "|| segs.includes('.mcp.json')" ''
|
|
187
|
+
ef '.mcp.json guarded at the root only' "$TF_GUARD" "segs.includes('.mcp.json')" "head === '.mcp.json'"
|
|
188
|
+
ef 'a name that merely contains mcp.json guarded' "$TF_QUIET" "segs.includes('.mcp.json')" "segs.some((x) => x.includes('mcp.json'))"
|
|
189
|
+
ef 'the guard drops .vscode/mcp.json' "$TF_GUARD" "|| segs.some((s, i) => s === '.vscode' && segs[i + 1] === 'mcp.json')" ''
|
|
190
|
+
ef '.vscode/mcp.json guarded at the root only' "$TF_GUARD" "segs.some((s, i) => s === '.vscode' && segs[i + 1] === 'mcp.json')" "(head === '.vscode' && second === 'mcp.json')"
|
|
191
|
+
ef 'every file under .vscode guarded' "$TF_QUIET" "s === '.vscode' && segs[i + 1] === 'mcp.json'" "s === '.vscode'"
|
|
192
|
+
ef 'mcp.json guarded in any directory' "$TF_QUIET" "s === '.vscode' && segs[i + 1] === 'mcp.json'" "s === 'mcp.json'"
|
|
193
|
+
ef 'mcp.json guarded anywhere under .vscode' "$TF_QUIET" "segs[i + 1] === 'mcp.json'" "segs.slice(i + 1).includes('mcp.json')"
|
|
194
|
+
ef 'the guard drops CLAUDE.md' "$TF_GUARD" "segs.includes('claude.md') || " ''
|
|
195
|
+
ef 'the guard drops AGENTS.md' "$TF_GUARD" "segs.includes('agents.md') || " ''
|
|
196
|
+
ef 'CLAUDE.md guarded at the root only' "$TF_GUARD" "segs.includes('claude.md')" "head === 'claude.md'"
|
|
197
|
+
ef 'AGENTS.md guarded at the root only' "$TF_GUARD" "segs.includes('agents.md')" "head === 'agents.md'"
|
|
198
|
+
ef 'a name that merely contains claude.md guarded' "$TF_QUIET" "segs.includes('claude.md')" "segs.some((x) => x.includes('claude.md'))"
|
|
199
|
+
ef 'every .somi child guarded' "$TF_QUIET" "second === 'rules'" 'second !== undefined'
|
|
200
|
+
ef 'a guarded row dropped when it is not an exact ignored prefix' "$TF_ALSO" 'if (!hidden(r.file)) kept.push(r);' 'if (!hidden(r.file) && !guarded(r.file)) kept.push(r);'
|
|
201
|
+
ef 'a name that grows past the cap when folded accepted' "$TF_GROWN" ' && foldName(r.file).length <= MAX_PATH_CHARS' ''
|
|
202
|
+
ef 'an empty, dot or dot-dot segment accepted' "$TF_UNPLAIN" " && !pieces(r.file).includes('')" ''
|
|
203
|
+
ef 'a summed count past the safe integers kept' "$TF_SUM" 'if (!COUNTS.every((k) => count(f[k]))) return' 'if (false) return'
|
|
204
|
+
ef 'a refused sensitive_paths key adds nothing' "$TF_REF" "if (refused.includes('sensitive_paths')) seen.sensitive.add('config');" ''
|
|
205
|
+
ef 'a refused key is noted only when a row reaches the classifier' "$TF_REF" "const refused = classifyPaths([], config).refused;" "const refused = kept.length > 0 ? classifyPaths([], config).refused : [];"
|
|
206
|
+
ef 'a refused key not reported' "$TF_REF" "if (refused.length > 0) notes.add('config_refused');" ''
|
|
207
|
+
ef 'any config shape read' "$TF_ONLY" 'if (!plain(cfg)) return null;' 'if (!plain(cfg)) continue;'
|
|
208
|
+
ef 'a refused config shape not reported' "$TF_ONLY" "{ notes.add('config_refused'); seen.sensitive.add('config'); }" "{ seen.sensitive.add('config'); }"
|
|
209
|
+
ef 'a refused config shape adds nothing' "$TF_ONLY" "{ notes.add('config_refused'); seen.sensitive.add('config'); }" "{ notes.add('config_refused'); }"
|
|
210
|
+
ef 'a refused config shape adds nothing when no row is read' "$TF_NOROW" "{ notes.add('config_refused'); seen.sensitive.add('config'); }" "{ notes.add('config_refused'); if (rows.length > 0) seen.sensitive.add('config'); }"
|
|
211
|
+
ef 'the classifier reads the caller config again in each chunk' "$TF_FLIP" 'classifyPaths(chunk.map((r) => r.file), config)' 'classifyPaths(chunk.map((r) => r.file), opts.config)'
|
|
212
|
+
ef 'the layers are passed on without a copy' "$TF_FLIP" "layers.push({ sizing: { sensitive_paths: glist(once(sizing, 'sensitive_paths')), module_containers: glist(once(sizing, 'module_containers')) } });" 'layers.push(cfg);'
|
|
213
|
+
ef 'the time box starts after the preparation' 'the time box starts before the config' 'if (Date.now() - start >= budget) return' 'if (Date.now() - Date.now() >= budget) return'
|
|
214
|
+
ef 'the floor lets the new top directories switch off' "$TF_COVER" 'test_lines_added: 0, test_files_changed: 0, denied: true' 'test_lines_added: 0, test_files_changed: 0, new_top_dirs: 0, denied: true'
|
|
215
|
+
ef 'the floor counts a test file changed' "$TF_COVER" 'test_lines_added: 0, test_files_changed: 0, denied: true' 'test_lines_added: 0, test_files_changed: 1e9, denied: true'
|
|
216
|
+
ef 'an internal error without its note' 'an unexpected error is the floor' "notes: ['internal_error']" 'notes: []'
|
|
217
|
+
ef 'an unusable target no longer raises' "$TF_PLAN" "typeof target !== 'string' || target.length > MAX_PATH_CHARS || " ''
|
|
218
|
+
ef 'the plan-paths input ignored' 'plan and sdlc sources' 'plan_paths: given(planPaths)' 'plan_paths: false'
|
|
219
|
+
ef 'the slug input ignored' 'plan and sdlc sources' 'slug_given: given(slug)' 'slug_given: false'
|
|
220
|
+
|
|
221
|
+
# ---- scripts/lib/loop-escalate.mjs and the rows and steps it reads ----
|
|
222
|
+
echo "== loop escalation =="
|
|
223
|
+
LET="$ROOT/tests/scripts/lib/loop-escalate-tests.mjs"
|
|
224
|
+
run_suite "$LET" ""
|
|
225
|
+
lm_n=0
|
|
226
|
+
# lm <file in scripts/lib> <label> <test it must break> <from> <to>: the suite runs on a scratch copy of the whole directory with one file mutated.
|
|
227
|
+
# ESCALATE_ONLY=mutant-run:<check> makes the suite run only the section holding the check the mutation must break.
|
|
228
|
+
lm() { local d="$TMP/lib-$((++lm_n))"; cp -r "$ROOT/scripts/lib" "$d"; ESCALATE_LIB="$d" ESCALATE_ONLY="mutant-run:$3" MUT_OUT="$d/$1" mutate "$LET" "$d/$1" "$2" "$3" "$4" "$5"; }
|
|
229
|
+
TL_KEY='a clean 40-line new file has no escalation key'; TL_IDS='the escalation object holds ids only'; TL_RAN='a config file that cannot be parsed gives'; TL_POL='a new .claude/settings.json (untracked)'
|
|
230
|
+
lm loop-review.mjs 'the status letter not carried' 'treeRows carries git' 'const status = letters.get(file);' 'const status = undefined;'
|
|
231
|
+
lm loop-review.mjs 'the policy listing without untracked files' "$TL_POL" 'return [...changed, ...added, ...links, ...ignored];' 'return [...changed, ...links, ...ignored];'
|
|
232
|
+
lm loop-review.mjs 'the policy listing without tracked changes' 'a committed .claude/settings.json edited' 'return [...changed, ...added, ...links, ...ignored];' 'return [...added, ...links, ...ignored];'
|
|
233
|
+
lm loop-review.mjs 'the policy listing without .somi/rules' 'a new .somi/config.json and a new .somi/rules/x.md' "'.somi/config.json', '.somi/rules'" "'.somi/config.json'"
|
|
234
|
+
lm loop-review.mjs 'the policy listing in the repository top level terms' 'a project root in a subfolder' "'-z', '--no-renames', '--no-ext-diff', '--no-textconv', '--relative', '--ignore-submodules=none', '--end-of-options', from, '--', ...GUARDED" "'-z', '--no-renames', '--no-ext-diff', '--no-textconv', '--ignore-submodules=none', '--end-of-options', from, '--', ...GUARDED"
|
|
235
|
+
lm loop-review.mjs 'the policy listing without the submodule flag' 'guardedRows: the diff lists a hidden moved submodule itself' "'--relative', '--ignore-submodules=none', '--end-of-options', from, '--', ...GUARDED" "'--relative', '--end-of-options', from, '--', ...GUARDED"
|
|
236
|
+
lm loop-review.mjs 'the policy listing without gitlinks from the index' 'an unchanged submodule at .claude/hooks still raises' "'-z', '--', '.claude', '.somi']).filter((t) => t.startsWith('160000 '))" "'-z', '--', '.claude', '.somi']).filter((t) => false)"
|
|
237
|
+
lm loop-review.mjs 'the gitlink listing without the guarded paths' 'guardedRows: an unchanged gitlink under a guarded path is a G row' "'ls-files', '-s', '-z', '--', '.claude', '.somi'" "'ls-files', '-s', '-z'"
|
|
238
|
+
lm loop-review.mjs 'the gitlink listing without .somi' 'a gitlink exactly at .somi is a G row' "'-z', '--', '.claude', '.somi']" "'-z', '--', '.claude']"
|
|
239
|
+
lm loop-review.mjs 'a nested repository at .somi not looked for' 'a gitlink exactly at .somi is a G row' "if (present(path.join(root, '.somi', '.git')) && " 'if (false && '
|
|
240
|
+
lm loop-review.mjs 'a nested repository at .somi looked for in .claude' 'a gitlink exactly at .somi is a G row' "path.join(root, '.somi', '.git')" "path.join(root, '.claude', '.git')"
|
|
241
|
+
lm loop-review.mjs 'a nested repository at .somi added beside its gitlink row' 'a gitlink at .somi inside a nested repository is one row' " && !links.some((r) => r.file === '.somi')" ''
|
|
242
|
+
lm loop-review.mjs 'the ignored files not compared' 'a self-ignoring .claude/.gitignore with a new' 'if (before !== undefined) {' 'if (false) {'
|
|
243
|
+
lm loop-review.mjs 'a state without a snapshot read as empty' 'a state without a snapshot (a loop begun before this snapshot existed)' 'if (before !== undefined) {' 'if (true) { before ??= { over: false, files: {} };'
|
|
244
|
+
lm loop-review.mjs 'the ignored listing without the ignored flag' 'a self-ignoring .claude/.gitignore with a new' "'ls-files', '-o', '-i', '--exclude-standard'" "'ls-files', '-o', '--exclude-standard'"
|
|
245
|
+
lm loop-review.mjs 'a new ignored file not raised' 'a self-ignoring .claude/.gitignore with a new' '!Object.hasOwn(before.files, file) || before.files[file] !== hash' 'Object.hasOwn(before.files, file) && before.files[file] !== hash'
|
|
246
|
+
lm loop-review.mjs 'a changed ignored file not raised' 'an edit to an already-ignored .claude/settings.local.json' '!Object.hasOwn(before.files, file) || before.files[file] !== hash' '!Object.hasOwn(before.files, file)'
|
|
247
|
+
lm loop-review.mjs 'an unchanged ignored file raised' 'planning churn under .somi, and an ignored' '!Object.hasOwn(before.files, file) || before.files[file] !== hash' 'true'
|
|
248
|
+
lm loop-review.mjs 'an over snapshot not raised' 'a snapshot that is over, or not of the stored shape' '!plainSnapshot(before) || before.over || now.over' '!plainSnapshot(before) || now.over'
|
|
249
|
+
lm loop-review.mjs 'a stored snapshot of another shape trusted' 'a snapshot that is over, or not of the stored shape' '!plainSnapshot(before) || ' ''
|
|
250
|
+
TL_SNAP='every guarded name, new and ignored, at any depth'; TL_FOLD='an ignored policy folder or rules folder that is itself a link'; TL_DEL='a deleted ignored policy file is a D row'; TL_DEP='a file under a dependency folder is no row'
|
|
251
|
+
TL_BIG='a file over 1 MiB is read to its end'; TL_DIG='past 256 entries the snapshot is one digest'; TL_BYTES='past the byte bound a file is stood for'; TL_WT='a worktree or nested repository under an ignored folder'
|
|
252
|
+
TL_LNK='a link is hashed with its target when that is a regular file'; TL_LND='a link to a directory or to a FIFO'; TL_LINK='an ignored link is hashed by its target'
|
|
253
|
+
lm loop-review.mjs 'the ignored listing without the guarded names' 'an ignored build file outside the policy paths' "'-z', '--', ...IGNORED_SPECS]" "'-z']"
|
|
254
|
+
lm loop-review.mjs 'the ignored pathspecs case-sensitive' "$TL_SNAP" '`:(glob,icase)${p}`' '`:(glob)${p}`'
|
|
255
|
+
lm loop-review.mjs 'the ignored pathspecs without glob magic' "$TL_SNAP" '`:(glob,icase)${p}`' '`:(icase)${p}`'
|
|
256
|
+
lm loop-review.mjs 'the ignored listing without a .claude link' "$TL_FOLD" "'**/.claude', '**/.claude/**'" "'**/.claude/**'"
|
|
257
|
+
lm loop-review.mjs 'the ignored listing without files under .claude' "$TL_SNAP" "'**/.claude/**', " ''
|
|
258
|
+
lm loop-review.mjs 'the ignored listing without CLAUDE.md' "$TL_SNAP" "'**/claude.md', " ''
|
|
259
|
+
lm loop-review.mjs 'the ignored listing without CLAUDE.local.md' "$TL_SNAP" "'**/claude.local.md', " ''
|
|
260
|
+
lm loop-review.mjs 'the ignored listing without AGENTS.md' "$TL_SNAP" "'**/agents.md', " ''
|
|
261
|
+
lm loop-review.mjs 'the ignored listing without .mcp.json' "$TL_SNAP" "'**/.mcp.json', " ''
|
|
262
|
+
lm loop-review.mjs 'the ignored listing without .vscode/mcp.json' "$TL_SNAP" "'**/.vscode/mcp.json', " ''
|
|
263
|
+
lm loop-review.mjs 'the ignored listing without .somi/config.json' "$TL_DEL" "'.somi/config.json', '.somi/rules'].map" "'.somi/rules'].map"
|
|
264
|
+
lm loop-review.mjs 'the ignored listing without .somi/rules' "$TL_FOLD" ", '.somi/rules'].map" '].map'
|
|
265
|
+
lm loop-review.mjs 'dependency folders not left out' "$TL_DEP" '!dependency(t)' 'true'
|
|
266
|
+
lm loop-review.mjs 'node_modules not a dependency folder' "$TL_DEP" "'node_modules', " ''
|
|
267
|
+
lm loop-review.mjs 'vendor not a dependency folder' "$TL_DEP" "'vendor', " ''
|
|
268
|
+
lm loop-review.mjs 'bower_components not a dependency folder' "$TL_DEP" "'bower_components', " ''
|
|
269
|
+
lm loop-review.mjs '.venv not a dependency folder' "$TL_DEP" "'.venv', " ''
|
|
270
|
+
lm loop-review.mjs 'venv not a dependency folder' "$TL_DEP" "'venv', " ''
|
|
271
|
+
lm loop-review.mjs 'site-packages not a dependency folder' "$TL_DEP" ", 'site-packages'" ''
|
|
272
|
+
lm loop-review.mjs 'a dependency folder inside .claude left out' "$TL_DEP" 'if (/^\.(claude|somi)$/i.test(s)) return false;' ''
|
|
273
|
+
lm loop-review.mjs 'a dependency folder inside .somi left out' "$TL_DEP" '(claude|somi)' '(claude)'
|
|
274
|
+
lm loop-review.mjs 'a vanished ignored file not raised' "$TL_DEL" 'for (const file of Object.keys(before.files))' 'for (const file of [])'
|
|
275
|
+
lm loop-review.mjs 'a vanished ignored file raised as an edit' "$TL_DEL" "deleted: 0, status: 'D' }" "deleted: 0, status: 'M' }"
|
|
276
|
+
lm loop-review.mjs 'a file read to its first chunk only' "$TL_BIG" 'for (let n; budget.left >= 0' 'for (let n, k = 0; k++ < 1 && budget.left >= 0'
|
|
277
|
+
lm loop-review.mjs 'a size cap per file' "$TL_BIG" 'if (!st.isFile()) {' 'if (!st.isFile() || st.size > 1048576n) {'
|
|
278
|
+
lm loop-review.mjs 'the byte budget not spent' "$TL_BYTES" 'budget.left -= n;' ''
|
|
279
|
+
lm loop-review.mjs 'a file past the byte budget hashed as one read' "$TL_BYTES" 'return budget.left < 0 ? `s:${st.size}:${st.ctimeNs}` : h.digest' 'return h.digest'
|
|
280
|
+
lm loop-review.mjs 'the stand-in without the change time' "$TL_BYTES" ':${st.ctimeNs}`' '`'
|
|
281
|
+
lm loop-review.mjs 'the entry bound off by one' "$TL_DIG" 'names.length + dirs.length > MAX_IGNORED' 'names.length + dirs.length >= MAX_IGNORED'
|
|
282
|
+
lm loop-review.mjs 'a tree past the entry bound over' "$TL_DIG" '{ over: false, files: {}, digest: sha(' '{ over: true, files: {}, digest: sha('
|
|
283
|
+
lm loop-review.mjs 'the digest not compared' "$TL_DIG" 'else if (before.digest !== now.digest)' 'else if (false)'
|
|
284
|
+
lm loop-review.mjs 'a nested repository read as a file' "$TL_WT" "f.endsWith('/') ? 'd:' : entryHash(path.join(base, f), budget)" 'entryHash(path.join(base, f), budget)'
|
|
285
|
+
lm loop-review.mjs 'the slash kept on a nested repository' "$TL_WT" "files[f.replace(/\\/$/, '')]" 'files[f]'
|
|
286
|
+
# lmp: lm for a check that rests on a file mode, which root ignores: the check is skipped for root (loop-escalate-tests.mjs), so its mutant is too.
|
|
287
|
+
lmp() { if [ "$(id -u)" = 0 ]; then echo " skip mutation '$2' (root ignores file modes, so the check it breaks is skipped)"; else lm "$@"; fi; }
|
|
288
|
+
TL_VSC='a nested repository made under an ignored .vscode'; TL_LOOP='a link that loops, or runs through a file'; TL_EXACT='at the byte bound exactly'; TL_SHUT='a policy folder git cannot list'; TL_ADD='an untracked file in a folder git cannot list'
|
|
289
|
+
lmp loop-review.mjs 'an unreadable entry skipped' 'an entry that cannot be read is the over marker' '} catch { return OVER; }' '} catch { /* skipped */ }'
|
|
290
|
+
lm loop-review.mjs 'the exemption folder matched in any case' "$TL_DEP" '/^\.(claude|somi)$/i' '/^\.(claude|somi)$/'
|
|
291
|
+
lm loop-review.mjs 'the exemption folder matched at the end of a name' "$TL_DEP" '/^\.(claude|somi)$/i' '/\.(claude|somi)$/i'
|
|
292
|
+
lm loop-review.mjs 'a looping link an error' "$TL_LOOP" "['ENOENT', 'ELOOP', 'ENOTDIR']" "['ENOENT', 'ENOTDIR']"
|
|
293
|
+
lm loop-review.mjs 'a link through a file an error' "$TL_LOOP" "['ENOENT', 'ELOOP', 'ENOTDIR']" "['ENOENT', 'ELOOP']"
|
|
294
|
+
lm loop-review.mjs 'the byte budget spent to nothing still reads a file' "$TL_EXACT" 'for (let n; budget.left >= 0' 'for (let n; budget.left > 0'
|
|
295
|
+
lm loop-review.mjs 'a nested repository that appears or goes not one row' "$TL_VSC" 'if (ignored.some((r) => marker(now.files[r.file]) || marker(before.files[r.file])))' 'if (false)'
|
|
296
|
+
lm loop-review.mjs 'a nested repository that appears hides nothing' "$TL_VSC" 'marker(now.files[r.file]) || ' ''
|
|
297
|
+
lm loop-review.mjs 'a nested repository not a marker' "$TL_VSC" "v === 'd:' || " ''
|
|
298
|
+
TL_UNR='an unreadable ignored folder outside the policy paths'; TL_GOES='an unreadable ignored folder that goes'; TL_OPEN='a folder git cannot open that is, holds or lies under a policy name'; TL_SUBR='a project root in a subfolder names its unreadable folder'
|
|
299
|
+
TL_ONLYGIT='only the git warning line is an unopened directory'; TL_PARSE='the warning parser keeps the git lines'; TL_DIGU='an unreadable ignored folder with the listing past 256'
|
|
300
|
+
lmp loop-review.mjs 'the unopened-directory warning no refusal' "$TL_ADD" 'if (dirs.length) throw' 'if (false) throw'
|
|
301
|
+
lmp loop-review.mjs 'the refusal without the .gitignore way out' "$TL_ADD" ', remove it, or add it to .gitignore)' ', or remove it)'
|
|
302
|
+
lmp loop-review.mjs 'the ignored listing without the stderr check' "$TL_UNR" "stdio: ['ignore', 'pipe', 'pipe'], unlistable: true });" "stdio: ['ignore', 'pipe', 'pipe'] });"
|
|
303
|
+
lmp loop-review.mjs 'a policy folder git cannot open not the over marker' "$TL_SHUT" 'if (dirs.some(({ dir }) => POLICY_DIR.test(dir))) return OVER;' ''
|
|
304
|
+
lmp loop-review.mjs 'a policy folder git cannot open not the over marker (nested)' "$TL_OPEN" 'if (dirs.some(({ dir }) => POLICY_DIR.test(dir))) return OVER;' ''
|
|
305
|
+
lmp loop-review.mjs 'any folder git cannot open the over marker' "$TL_UNR" 'if (dirs.some(({ dir }) => POLICY_DIR.test(dir))) return OVER;' 'if (dirs.length) return OVER;'
|
|
306
|
+
lmp loop-review.mjs 'a .vscode folder git cannot open not a policy folder' "$TL_OPEN" '(claude|vscode)' '(claude)'
|
|
307
|
+
lmp loop-review.mjs 'a .claude folder git cannot open not a policy folder' "$TL_OPEN" '(claude|vscode)' '(vscode)'
|
|
308
|
+
lmp loop-review.mjs 'the .somi folder git cannot open not a policy folder' "$TL_OPEN" '|^\.somi(\/|$)/i' '/i'
|
|
309
|
+
lmp loop-review.mjs 'an unopened folder not an entry' "$TL_UNR" 'for (const { dir, why } of dirs)' 'for (const { dir, why } of [])'
|
|
310
|
+
lmp loop-review.mjs 'an unopened folder entry without its reason' "$TL_UNR" 'files[dir] = `u:${shown(why)}`' 'files[dir] = `u:`'
|
|
311
|
+
lmp loop-review.mjs 'an unopened folder entry not compared like a nested repository' "$TL_UNR" "v === 'd:' || v?.startsWith('u:') === true" "v === 'd:'"
|
|
312
|
+
lmp loop-review.mjs 'an unopened folder that goes raised as an edit only' "$TL_GOES" "|| v?.startsWith('u:') === true" '|| false'
|
|
313
|
+
lmp loop-review.mjs 'an unopened folder not counted toward the digest bound' "$TL_DIGU" 'names.length + dirs.length > MAX_IGNORED' 'names.length > MAX_IGNORED'
|
|
314
|
+
lmp loop-review.mjs 'an unopened folder named from the repository top' "$TL_SUBR" 'own !== '"''"' && dir.startsWith' 'false && dir.startsWith'
|
|
315
|
+
lmp loop-review.mjs 'an unopened folder kept with its slash' "$TL_UNR" ".replace(/\/$/, ''), why }));" ', why }));'
|
|
316
|
+
lm loop-review.mjs 'the warning matched anywhere in a line' "$TL_ONLYGIT" "/^warning: could not open directory '(.*)': (.*)$/gm" "/could not open directory '(.*)': (.*)$/gm"
|
|
317
|
+
lm loop-review.mjs 'the warning matched on the first line only' "$TL_PARSE" "(.*)$/gm;" "(.*)$/g;"
|
|
318
|
+
lm loop-review.mjs 'a vanished folder read as unopened' "$TL_PARSE" "m[2] !== 'No such file or directory'" 'true'
|
|
319
|
+
lmp loop-review.mjs 'the policy listings without the stderr check' "$TL_SHUT" "stdio: ['ignore', 'pipe', 'pipe'], unlistable: true }).split('\\0'); } catch (e) {" "stdio: ['ignore', 'pipe', 'pipe'] }).split('\\0'); } catch (e) {"
|
|
320
|
+
lmp loop-review.mjs 'the measured tree without the stderr check' "$TL_ADD" "stdio: ['ignore', 'ignore', 'pipe'], unlistable: true });" "stdio: ['ignore', 'ignore', 'pipe'] });"
|
|
321
|
+
lm loop-review.mjs 'a link read as its text only' "$TL_LNK" '${fileHash(full, true, budget)}`' '`'
|
|
322
|
+
lm loop-review.mjs 'a link not read' "$TL_LINK" '`l:${fs.readlinkSync(full)}:' '`l::'
|
|
323
|
+
lm loop-review.mjs 'a link followed' "$TL_LINK" 'if (!fs.lstatSync(full).isSymbolicLink())' 'if (true)'
|
|
324
|
+
lm loop-review.mjs 'a missing link target an error' "$TL_LNK" "['ENOENT', 'ELOOP', 'ENOTDIR']" '[]'
|
|
325
|
+
lm loop-review.mjs 'a link target that is no file an error' "$TL_LND" "if (follow) return 'special';" "if (follow) throw new Error('x');"
|
|
326
|
+
lm loop-review.mjs 'a link target opened with a wait' "$TL_LND" 'fs.constants.O_RDONLY | fs.constants.O_NONBLOCK | (follow' 'fs.constants.O_RDONLY | (follow'
|
|
327
|
+
lm loop-engine.mjs 'no snapshot taken at init' 'a self-ignoring .claude/.gitignore with a new' "if (loop === 'code') state.ignored_guarded = ignoredSnapshot(root);" 'if (false) state.ignored_guarded = ignoredSnapshot(root);'
|
|
328
|
+
lm loop-step.mjs 'the snapshot not handed to the escalation' 'an edit to an already-ignored .claude/settings.local.json' 'state.baseline_sha, state.ignored_guarded))' 'state.baseline_sha))'
|
|
329
|
+
lm loop-escalate.mjs 'the snapshot not handed to the policy rows' 'a root .gitignore that adds .claude/x' 'guardedRows(root, baseline, ignoredBefore)' 'guardedRows(root, baseline)'
|
|
330
|
+
lm loop-review.mjs 'the gitlink rows kept when the diff already lists the path' 'guardedRows: the diff lists a hidden moved submodule itself' ".filter((file) => !listed.has(file))" ''
|
|
331
|
+
lm loop-review.mjs 'the policy listing with renames on' 'a staged rename inside .claude' "'--raw', '--no-abbrev', '-z', '--no-renames'," "'--raw', '--no-abbrev', '-z',"
|
|
332
|
+
lm loop-review.mjs 'the policy listing of untracked files without the ignore rules' 'planning churn under .somi, and an ignored' "'ls-files', '-o', '--exclude-standard', '-z', '--', ...GUARDED" "'ls-files', '-o', '-z', '--', ...GUARDED"
|
|
333
|
+
lm loop-review.mjs 'a diff without the driver flags' 'every git diff the loop runs' "'--no-renames', '--no-ext-diff', '--no-textconv', '--relative', '--ignore-submodules=none', '--end-of-options', from, to" "'--no-renames', '--relative', '--ignore-submodules=none', '--end-of-options', from, to"
|
|
334
|
+
lm loop-diff.mjs 'the rows not returned' "$TL_KEY" 'return { total, weighted, outOfScope, rows };' 'return { total, weighted, outOfScope };'
|
|
335
|
+
lm escalation-facts.mjs 'the guard drops .mcp.json (loop level)' 'a new .mcp.json and a new .vscode/mcp.json' "|| segs.includes('.mcp.json')" ''
|
|
336
|
+
lm escalation-facts.mjs 'the guard drops .vscode/mcp.json (loop level)' 'a new .mcp.json and a new .vscode/mcp.json' "|| segs.some((s, i) => s === '.vscode' && segs[i + 1] === 'mcp.json')" ''
|
|
337
|
+
lm loop-escalate.mjs 'a failure swallowed as a run' "$TL_RAN" ' return { ran: false };' ' return { ran: true, reasons: [], size_flag: false, tests_weakened: false, hard_surface: [], notes: [] };'
|
|
338
|
+
lm loop-escalate.mjs 'the object emitted when empty' "$TL_KEY" '(e.ran === false || e.reasons.length > 0' '(true || e.reasons.length > 0'
|
|
339
|
+
lm loop-escalate.mjs 'a path leaked into the object' "$TL_IDS" 'reasons: ids(e.reasons),' 'reasons: [...ids(e.reasons), rows[0].file],'
|
|
340
|
+
lm loop-escalate.mjs 'the id shape not checked' 'the diary text reads stored state as untrusted' "|| !list.every((x) => typeof x === 'string' && ID.test(x))" ''
|
|
341
|
+
lm loop-escalate.mjs 'the policy rows not added' "$TL_POL" '[...rows, ...guardedRows(root, baseline, ignoredBefore)]' '[...rows]'
|
|
342
|
+
lm loop-escalate.mjs 'the merged config handed on' "$TL_KEY" 'loadConfig(root, env) }' 'loadConfig(root, env).config }'
|
|
343
|
+
lm loop-step.mjs 'the escalation not put in the response' "$TL_KEY" 'review_mode: review.mode, ...found,' 'review_mode: review.mode,'
|
|
344
|
+
lm loop-step-review.mjs 'the ids not put in the diary line' 'the pass' "\${diaryText(gate?.response?.escalation)}" ''
|
|
345
|
+
|
|
346
|
+
# The suite's filter and library swap hold only as ESCALATE_ONLY=mutant-run:<name> beside ESCALATE_LIB with the mutated file as the first argument,
|
|
347
|
+
# and a filter that matches no check fails the run.
|
|
348
|
+
# first_line <command...>: the first line it prints, waiting about 10 s at most; the run is stopped once it is out (a skip banner is that line when a filter took hold).
|
|
349
|
+
first_line() {
|
|
350
|
+
local out pid i=0; out="$(mktemp "$TMP/first.XXXXXX")"
|
|
351
|
+
TMPDIR="$TMP" "$@" >"$out" 2>&1 & pid=$!
|
|
352
|
+
until [ -s "$out" ] || ! kill -0 "$pid" 2>/dev/null || [ $((i++)) -ge "${FIRST_LINE_TICKS:-200}" ]; do sleep 0.05; done
|
|
353
|
+
kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null
|
|
354
|
+
head -n 1 "$out"
|
|
355
|
+
}
|
|
356
|
+
T_FIRST='== the report: what the loop says about its own diff, and what it leaves alone =='
|
|
357
|
+
TL_LATE='a repository-level diff.external and a textconv driver do not run'
|
|
358
|
+
# filter_ok <test lib>: it takes hold with the variables and the mutated file together, however late the named check is, and in no other case; a filter naming no check fails with that line.
|
|
359
|
+
filter_ok() {
|
|
360
|
+
local lib="$ROOT/scripts/lib" holds nothing_a nothing_b nothing_c nothing_d none rc
|
|
361
|
+
holds="$(ESCALATE_LIB="$lib" ESCALATE_ONLY="mutant-run:$TL_LATE" first_line node "$1" "$lib/loop-review.mjs")"
|
|
362
|
+
nothing_a="$(ESCALATE_ONLY="mutant-run:$TL_LATE" first_line node "$1" "$lib/loop-review.mjs")" # the variable alone
|
|
363
|
+
nothing_b="$(ESCALATE_LIB="$lib" ESCALATE_ONLY="$TL_LATE" first_line node "$1" "$lib/loop-review.mjs")" # without the prefix
|
|
364
|
+
nothing_c="$(ESCALATE_LIB="$lib" ESCALATE_ONLY="mutant-run:$TL_LATE" first_line node "$1")" # the pair exported by accident: no argument
|
|
365
|
+
nothing_d="$(ESCALATE_LIB="$lib" ESCALATE_ONLY="mutant-run:$TL_LATE" first_line node "$1" "$1")" # an argument outside the library
|
|
366
|
+
none="$(ESCALATE_LIB="$lib" ESCALATE_ONLY='mutant-run:no such check' node "$1" "$lib/loop-review.mjs" 2>&1)"; rc=$?
|
|
367
|
+
[ "$holds" = " skip every section but the one holding \"$TL_LATE\" (ESCALATE_ONLY=mutant-run:...)" ] && [ "$nothing_a" = "$T_FIRST" ] && [ "$nothing_b" = "$T_FIRST" ] && [ "$nothing_c" = "$T_FIRST" ] && [ "$nothing_d" = "$T_FIRST" ] \
|
|
368
|
+
&& [ "$rc" != 0 ] && grep -qxF ' FAIL no check matched the filter' <<<"$none"
|
|
369
|
+
}
|
|
370
|
+
if filter_ok "$LET"; then ok 'the suite filter needs ESCALATE_LIB, the exact prefix and the mutated file as the first argument, and a filter naming no check fails'; else bad 'the suite filter took hold without all three, never took hold, or a filter naming no check passed'; fi
|
|
371
|
+
# fm <label> <from> <to>: the same check on a scratch copy of the suite (beside a copy of scripts/lib) with one mutation; it must fail.
|
|
372
|
+
fm() {
|
|
373
|
+
local d="$TMP/fm-$((++lm_n))"; mkdir -p "$d/tests/scripts/lib"; cp -r "$ROOT/scripts" "$d/scripts"
|
|
374
|
+
node -e "const fs=require('fs');const s=fs.readFileSync(process.argv[1],'utf8');const t=s.replace(process.argv[2],()=>process.argv[3]);if(t===s)process.exit(3);fs.writeFileSync(process.argv[4],t)" "$LET" "$2" "$3" "$d/tests/scripts/lib/loop-escalate-tests.mjs"
|
|
375
|
+
if [ $? != 0 ]; then bad "mutation '$1' did not change the suite (stale pattern)"; return; fi
|
|
376
|
+
if filter_ok "$d/tests/scripts/lib/loop-escalate-tests.mjs"; then bad "mutation '$1' left the suite filter check green"; else ok "mutation '$1' turns the suite filter check red"; fi
|
|
377
|
+
}
|
|
378
|
+
fm 'any value filters' "process.env.ESCALATE_ONLY?.startsWith(FILTER)" "process.env.ESCALATE_ONLY"
|
|
379
|
+
fm 'the filter without ESCALATE_LIB' "process.env.ESCALATE_LIB !== undefined && " ''
|
|
380
|
+
fm 'the filter without the argument' "Boolean(process.argv[2]) && path.resolve(process.argv[2]).startsWith(path.resolve(process.env.ESCALATE_LIB) + path.sep)" 'true'
|
|
381
|
+
fm 'the argument not tied to the library' "path.resolve(process.argv[2]).startsWith(path.resolve(process.env.ESCALATE_LIB) + path.sep)" 'true'
|
|
382
|
+
fm 'the library swapped whatever the filter' 'const LIB = MUTANT ?' "const LIB = process.env.ESCALATE_LIB ?? (false ?"
|
|
383
|
+
fm 'the filter never holds' 'const ONLY = MUTANT ?' 'const ONLY = false ?'
|
|
384
|
+
fm 'a filter naming no check passes' 'if (ONLY !== null && pass + fail === 0)' 'if (false)'
|
|
385
|
+
# first_line gives up on a command that prints nothing: the function as written in a copy of this script, with 4 ticks, on a command that would wait 20 s.
|
|
386
|
+
fl_bound() { timeout 5 bash -c 'TMP=$1; eval "$(sed -n "/^first_line() {/,/^}/p" "$2")"; FIRST_LINE_TICKS=4 first_line sleep 20' _ "$TMP" "$1"; }
|
|
387
|
+
if fl_bound "$SELF"; then ok 'the first-line wait is bounded: a silent command is given up on'; else bad 'the first-line wait is not bounded'; fi
|
|
388
|
+
fb="$TMP/self-unbounded.sh"; sed 's/ || \[ \$((i++)) -ge "\${FIRST_LINE_TICKS:-200}" \]//' "$SELF" >"$fb"
|
|
389
|
+
if cmp -s "$SELF" "$fb"; then bad "mutation 'the first-line wait unbounded' did not change the script (stale pattern)"; elif fl_bound "$fb"; then bad "mutation 'the first-line wait unbounded' left the bound check green"; else ok "mutation 'the first-line wait unbounded' turns the bound check red"; fi
|
|
390
|
+
# The real runs start without the filter variables: this script, asked to stop where it unsets them (--env-probe) with them exported, says what is left.
|
|
391
|
+
probe() { ESCALATE_ONLY=x ESCALATE_LIB=y MUT_OUT=z bash "$1" --env-probe 2>&1 | tail -n 1; }
|
|
392
|
+
[ "$(probe "$SELF")" = 'env:' ] && ok 'the real runs start without an inherited ESCALATE_ONLY, ESCALATE_LIB or MUT_OUT' || bad 'the real runs inherit ESCALATE_ONLY, ESCALATE_LIB or MUT_OUT'
|
|
393
|
+
for left in ESCALATE_ONLY ESCALATE_LIB MUT_OUT; do
|
|
394
|
+
d="$TMP/probe-$left"; mkdir -p "$d/tests/scripts"
|
|
395
|
+
sed "/^unset /s/ $left\b//" "$SELF" >"$d/tests/scripts/escalation.sh"
|
|
396
|
+
if cmp -s "$SELF" "$d/tests/scripts/escalation.sh"; then bad "mutation 'unset without $left' did not change the script (stale pattern)"
|
|
397
|
+
elif [ "$(probe "$d/tests/scripts/escalation.sh")" = 'env:' ]; then bad "mutation 'unset without $left' left the probe green"; else ok "mutation 'unset without $left' turns the probe red"; fi
|
|
398
|
+
done
|
|
399
|
+
# A stray exported ESC_PROBE (the old trigger) must not stop a real run: the first suite runs in full (--first-suite stops the script after it).
|
|
400
|
+
stray() { local out; out="$(ESC_PROBE=1 TMPDIR="$TMP" bash "$1" --first-suite 2>&1)"; grep -qF " ok $T_EMPTY" <<<"$out"; }
|
|
401
|
+
d="$TMP/stray"; mkdir -p "$d/tests/scripts"; ln -s "$ROOT/tests/scripts/lib" "$d/tests/scripts/lib"; ln -s "$ROOT/scripts" "$d/scripts"
|
|
402
|
+
sed 's/^\[ "${1:-}" != --env-probe \] || /[ -z "${ESC_PROBE:-}" ] || /' "$SELF" >"$d/tests/scripts/escalation.sh"
|
|
403
|
+
if cmp -s "$SELF" "$d/tests/scripts/escalation.sh"; then bad "mutation 'the probe triggered by the environment' did not change the script (stale pattern)"
|
|
404
|
+
elif stray "$d/tests/scripts/escalation.sh"; then bad "mutation 'the probe triggered by the environment' left the stray-variable check green"; else ok "mutation 'the probe triggered by the environment' turns the stray-variable check red"; fi
|
|
405
|
+
if stray "$SELF"; then ok 'a stray exported ESC_PROBE still runs the full suite'; else bad 'a stray exported ESC_PROBE stopped the run'; fi
|
|
406
|
+
|
|
407
|
+
total=$((pass + fail))
|
|
408
|
+
echo "SUMMARY $total checks, $fail failed"
|
|
409
|
+
[ "$fail" = 0 ]
|
|
@@ -116,10 +116,11 @@ check "a path source records sha null" \
|
|
|
116
116
|
|
|
117
117
|
# --- --source resolution and worktree cleanup --------------------------------------------------
|
|
118
118
|
head_sha=$(git rev-parse HEAD)
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
|
|
119
|
+
# `git worktree list` is global state: a concurrent eval run, or another script in the parallel suite,
|
|
120
|
+
# can add or remove its own worktree during this test. So "this test leaks none" is checked as sets:
|
|
121
|
+
# a leak is a worktree present afterwards that was not there before.
|
|
122
|
+
wt_list() { git worktree list --porcelain | grep '^worktree .*somi-eval-src' | sort; }
|
|
123
|
+
wt_before=$(wt_list)
|
|
123
124
|
res=$( j "
|
|
124
125
|
const s = M.resolveSource('HEAD');
|
|
125
126
|
const fs = await import('node:fs');
|
|
@@ -129,7 +130,7 @@ res=$( j "
|
|
|
129
130
|
process.stdout.write(s.sha + '|' + had + '|' + gone);
|
|
130
131
|
")
|
|
131
132
|
check "--source HEAD checks out a worktree and cleans it up" "$res" "$head_sha|true|true"
|
|
132
|
-
check "this test leaks no worktree" "$(
|
|
133
|
+
check "this test leaks no worktree" "$(comm -13 <(printf '%s\n' "$wt_before" | grep . || true) <(wt_list) | grep -c . || true)" "0"
|
|
133
134
|
|
|
134
135
|
check "an unresolvable --source fails loudly" \
|
|
135
136
|
"$( j "try { M.resolveSource('no-such-ref-xyz'); process.stdout.write('NO THROW'); } catch (e) { process.stdout.write('threw'); }" )" \
|
|
@@ -2105,8 +2106,8 @@ BREACH_STATUSES=()
|
|
|
2105
2106
|
while IFS= read -r s; do
|
|
2106
2107
|
[[ "$s" =~ ^[A-Za-z0-9_-]+$ ]] && BREACH_STATUSES+=("$s")
|
|
2107
2108
|
done < <(cj "for (const s of M.CAP_BREACH_STATUSES) process.stdout.write(s + '\n');")
|
|
2108
|
-
DOC_STATUSES="$(grep -A1 'Loop status:' "$ROOT/
|
|
2109
|
-
check "the module's CAP_BREACH_STATUSES matches
|
|
2109
|
+
DOC_STATUSES="$(grep -A1 'Loop status:' "$ROOT/skills/flow-code-loop/SKILL.md" | grep -o '`[a-z-]*`' | tr -d '`' | grep -v '^done$' | sort)"
|
|
2110
|
+
check "the module's CAP_BREACH_STATUSES matches skills/flow-code-loop/SKILL.md's documented enum exactly (set-equality, not a count)" \
|
|
2110
2111
|
"$(printf '%s\n' ${BREACH_STATUSES[@]+"${BREACH_STATUSES[@]}"} | sort)" "${DOC_STATUSES:-<doc-derivation-empty>}"
|
|
2111
2112
|
for s in "${BREACH_STATUSES[@]}"; do
|
|
2112
2113
|
check "capBreached({status:'$s'}) is true (documented breach terminal)" \
|