@skathio/somi 4.0.0 → 4.1.0
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 +11 -5
- 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 +12 -124
- package/commands/test-strategy.md +11 -75
- package/commands/upgrade.md +9 -72
- package/hooks/hooks.json +1 -1
- package/hooks/lib/common.mjs +15 -13
- 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-cost-lowering.mjs +26 -11
- package/hooks/pre-tool/guard-protected-paths.mjs +54 -34
- package/hooks/session-start/ensure-default-config.mjs +34 -42
- package/package.json +1 -1
- package/scripts/lib/config-files.mjs +145 -0
- package/scripts/lib/cost-ceiling.mjs +29 -22
- 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 +226 -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 +278 -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 +301 -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-check.mjs +4 -3
- package/scripts/somi-config.mjs +113 -50
- package/scripts/somi-findings.mjs +56 -271
- package/scripts/somi-loop.mjs +77 -446
- package/scripts/somi-mcp.mjs +27 -96
- package/scripts/validate.sh +92 -54
- 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/cost-hardcap.sh +26 -17
- package/tests/scripts/dispatch-line-gate.sh +4 -4
- package/tests/scripts/dispatch-reference-gate.sh +14 -14
- package/tests/scripts/ensure-default-config.sh +4 -4
- 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/global-config.sh +167 -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 +371 -0
- package/tests/scripts/lib/loop-step-cli-tests.mjs +141 -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/site-roadmap-gate.mjs +64 -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/site-roadmap-gate.sh +76 -0
- package/tests/scripts/size-tier.sh +3 -3
- package/tests/scripts/somi-agent-dispatch-contract.sh +23 -3
- package/tests/scripts/somi-config.sh +9 -4
- package/tests/scripts/somi-mcp.sh +1 -0
- package/tests/scripts/suite-plan.json +20 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Drives the real server (scripts/somi-mcp.mjs) over stdio for the somi_loop tool in throwaway git repos: a clean pass, every gate
|
|
3
|
+
// of the matrix, the refusals, the root rules, the argument rules, interop with the CLI and the writes it may make.
|
|
4
|
+
// Invoked from tests/scripts/somi-mcp.sh. CLAUDE_PROJECT_DIR is always set explicitly (or cleared), so the host a run happens in cannot change a case.
|
|
5
|
+
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { chmodSync, existsSync, lstatSync, symlinkSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
13
|
+
import { McpClient } from './somi-mcp-client.mjs';
|
|
14
|
+
import { KINDS, NEXTS } from '../../../scripts/lib/loop-exit.mjs';
|
|
15
|
+
import { resolveProjectRoot } from '../../../scripts/lib/mcp-project-root.mjs';
|
|
16
|
+
import { LIMITS } from '../../../scripts/lib/loop-review.mjs';
|
|
17
|
+
import { callLoopStep } from '../../../scripts/lib/loop-step-tool.mjs';
|
|
18
|
+
|
|
19
|
+
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
|
|
20
|
+
let pass = 0; let fail = 0;
|
|
21
|
+
const check = (name, got, want) => {
|
|
22
|
+
if (isDeepStrictEqual(got, want)) { pass++; console.log(` ok ${name}`); } else { fail++; console.log(` FAIL ${name} (want ${JSON.stringify(want)}, got ${JSON.stringify(got)})`); }
|
|
23
|
+
};
|
|
24
|
+
const tmp = mkdtempSync(path.join(tmpdir(), 'somi-mcp-loop-'));
|
|
25
|
+
process.on('exit', () => rmSync(tmp, { recursive: true, force: true }));
|
|
26
|
+
const ROWS = '# Progress — p1\n\n## Iteration progress\n\n| Iteration | Title | Status | Reviewed | Last activity |\n|---|---|---|---|---|\n| 1.1 | one | not-started | — | — |\n';
|
|
27
|
+
const DIARY = '# Diary — p1\n\n> Spec: x\n\n---\n\n## 2026-10-28 10:00 — Plan\n\n**Category**: `note`\n**Phase**: 1\n\nbody\n\n---\n\n';
|
|
28
|
+
let n = 0;
|
|
29
|
+
function repo(slugs = ['p1']) {
|
|
30
|
+
const root = path.join(tmp, `r${n++}`); mkdirSync(root);
|
|
31
|
+
const git = (...a) => execFileSync('git', ['-C', root, '-c', 'user.name=t', '-c', 'user.email=t@t', ...a]);
|
|
32
|
+
git('init', '-q'); for (const f of ['a.js', 'b.js']) writeFileSync(path.join(root, f), '1\n'); git('add', '.'); git('commit', '-q', '-m', 'base');
|
|
33
|
+
for (const s of slugs) { mkdirSync(path.join(root, '.somi', 'plans', s, 'phases'), { recursive: true }); writeFileSync(path.join(root, '.somi', 'plans', s, 'diary.md'), DIARY); writeFileSync(path.join(root, '.somi', 'plans', s, 'progress.md'), ROWS); }
|
|
34
|
+
return root;
|
|
35
|
+
}
|
|
36
|
+
const file = (root, ...p) => path.join(root, ...p);
|
|
37
|
+
const diary = (root) => readFileSync(file(root, '.somi', 'plans', 'p1', 'diary.md'), 'utf8');
|
|
38
|
+
const entries = (root) => diary(root).split('\n').filter((l) => l.startsWith('## ')).length;
|
|
39
|
+
const state = (root) => JSON.parse(readFileSync(file(root, '.somi', 'somi-state', 'loop', 'p1.1.1.json'), 'utf8'));
|
|
40
|
+
// Every file under a directory with its hash: the "nothing was written" oracle.
|
|
41
|
+
const tree = (root) => Object.fromEntries(readdirSync(root, { recursive: true }).filter((f) => !f.startsWith('.git')).sort().map((f) => [f, lstatSync(path.join(root, f)).isFile() ? createHash('sha256').update(readFileSync(path.join(root, f))).digest('hex') : 'dir']));
|
|
42
|
+
const CAPS_OFF = { SOMI_CODE_LOOP_MAX_PASSES: '', SOMI_CODE_LOOP_DIFF_CAP: '', SOMI_PLAN_LOOP_MAX_PASSES: '', SOMI_GLOBAL_CONFIG: '' };
|
|
43
|
+
async function withClient(root, fn, { env = {}, roots } = {}) {
|
|
44
|
+
const client = new McpClient(path.join(ROOT, 'scripts', 'somi-mcp.mjs'), { env: { ...CAPS_OFF, CLAUDE_PROJECT_DIR: root ?? '', ...env } });
|
|
45
|
+
if (roots) client.rootsHandler = async () => roots;
|
|
46
|
+
try { await client.initialize(roots ? { roots: {} } : {}); return await fn(client); } finally { client.close(); }
|
|
47
|
+
}
|
|
48
|
+
const sizes = []; const seen = { next: new Set(), kind: new Set() };
|
|
49
|
+
async function step(c, name, args = {}) {
|
|
50
|
+
const r = await c.request('tools/call', { name: 'somi_loop', arguments: { step: name, slug: 'p1', iteration: '1.1', ...args } });
|
|
51
|
+
const text = r?.content?.[0]?.text ?? ''; sizes.push(Buffer.byteLength(text));
|
|
52
|
+
const got = JSON.parse(text); seen.next.add(got.next); for (const u of got.unwritten ?? []) seen.kind.add(u.kind);
|
|
53
|
+
return { err: r.isError === true, ...got };
|
|
54
|
+
}
|
|
55
|
+
const review = (v = 'approve', extra = {}) => ({ reviewers: ['somi-reviewer'], verdict: v, blockers: 0, majors: 0, review: 'r1.md', ...extra });
|
|
56
|
+
const MAJOR = { file: 'a.js', symbol: 'f', title: 'the same defect', severity: 'Major', confidence: 'High' };
|
|
57
|
+
const gate = (r) => [r.err, r.exit, r.stop_reason];
|
|
58
|
+
|
|
59
|
+
console.log('== somi_loop over MCP ==');
|
|
60
|
+
{
|
|
61
|
+
const root = repo();
|
|
62
|
+
await withClient(root, async (c) => {
|
|
63
|
+
const t = (await c.request('tools/list', {})).tools.find((x) => x.name === 'somi_loop');
|
|
64
|
+
check('tools/list: somi_loop requires step and slug; its description is at most 900 bytes and the whole definition at most 2850', [t.inputSchema.required, Buffer.byteLength(t.description) <= 900, Buffer.byteLength(JSON.stringify(t)) <= 2850], [['step', 'slug'], true, true]);
|
|
65
|
+
const o = await step(c, 'open', { files: ['a.js'] }); writeFileSync(file(root, 'a.js'), '1\n2\n3\n');
|
|
66
|
+
check('open starts pass 1: the run card is the brief, the caps are the defaults, the server wrote the diary and the row', [o.err, o.exit, o.pass, o.next, o.brief.startsWith('```somi-card'), o.caps, o.wrote], [false, 0, 1, 'task-coder', true, { max_passes: 3, diff_cap_lines: 400, severity_floor: 'Major' }, ['.somi/plans/p1/diary.md', '.somi/plans/p1/progress.md']]);
|
|
67
|
+
const cli = JSON.parse(execFileSync(process.execPath, [file(ROOT, 'scripts', 'somi-loop.mjs'), 'resume', '--slug', 'p1', '--iteration', '1.1'], { env: { ...process.env, ...CAPS_OFF, CLAUDE_PROJECT_DIR: root }, encoding: 'utf8' }));
|
|
68
|
+
check('init through the tool, resume through the CLI: the CLI reads the same running state', [cli.status, cli.pass, cli.iteration_files], ['running', 1, ['a.js']]);
|
|
69
|
+
const ac = await step(c, 'after-code', { agent: 'somi-coder' });
|
|
70
|
+
check('after-code records the coder and passes the diff gate', [ac.err, ac.exit, ac.next, ac.diff.cap, ac.changed], [false, 0, 'task-reviewer', 400, true]);
|
|
71
|
+
const ar = await step(c, 'after-review', review());
|
|
72
|
+
const cl = await step(c, 'close', { status: ar.close_args.status });
|
|
73
|
+
const row = readFileSync(file(root, '.somi', 'plans', 'p1', 'progress.md'), 'utf8').split('\n').find((l) => l.startsWith('| 1.1 |'));
|
|
74
|
+
check('after-review ends the loop clean, close writes it down: status done, the row is done, reviewed approve', [ar.next, cl.status, cl.next, state(root).status, / done /.test(row), / approve /.test(row)], ['close', 'done', 'summarise', 'done', true, true]);
|
|
75
|
+
const own = diary(root).split(/^(?=## )/m).slice(1, -1);
|
|
76
|
+
check('every entry the tool wrote carries the fixed provenance line and a note or blocker category', [own.length, own.every((e) => e.includes('\nWritten by the loop step engine; every field comes from stored loop state.\n') && /\*\*Category\*\*: `(note|blocker)`/.test(e))], [3, true]);
|
|
77
|
+
const before = tree(root); const again = await step(c, 'open', { files: ['a.js'] }); for (let i = 0; i < 9; i++) await step(c, 'status');
|
|
78
|
+
check('a finished loop is not restarted by the tool; ten more calls (status included) write nothing', [again.exit, again.stop_reason, again.next, tree(root)], [64, 'no-running-loop', 'ask-user', before]);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
console.log('== the gate matrix ==');
|
|
82
|
+
{
|
|
83
|
+
const root = repo(); writeFileSync(file(root, 'a.js'), '1\n2\n3\n');
|
|
84
|
+
await withClient(root, async (c) => {
|
|
85
|
+
await step(c, 'open', { files: ['a.js'], max_passes: 1 });
|
|
86
|
+
await step(c, 'after-code', { agent: 'somi-coder' });
|
|
87
|
+
const ar = await step(c, 'after-review', review('request-changes', { majors: 1, findings: [MAJOR] }));
|
|
88
|
+
const stop = await step(c, 'open');
|
|
89
|
+
check('exit 2: past the pass cap the result carries the gate (not an error), and the CLI command that re-runs it', [ar.next, ...gate(stop), stop.next, stop.cli], [ 'open', false, 2, 'max-passes-exceeded', 'close', 'node scripts/somi-loop.mjs pass --slug p1 --iteration 1.1 --max-passes <N>']);
|
|
90
|
+
});
|
|
91
|
+
const two = repo(); writeFileSync(file(two, 'a.js'), '1\n2\n3\n');
|
|
92
|
+
await withClient(two, async (c) => {
|
|
93
|
+
await step(c, 'open', { files: ['a.js'] }); await step(c, 'after-code', { agent: 'somi-coder' });
|
|
94
|
+
await step(c, 'after-review', review('request-changes', { majors: 1, findings: [MAJOR] })); await step(c, 'open'); await step(c, 'after-code', { agent: 'somi-coder' });
|
|
95
|
+
const br = await step(c, 'after-review', review('request-changes', { majors: 1, findings: [MAJOR] }));
|
|
96
|
+
check('exit 5: the same finding on consecutive passes trips the circuit breaker, as a result with stop_reason', [br.err, br.exit, br.stop_reason, br.next, br.close_args], [false, 5, 'circuit-breaker', 'close', { status: 'stopped-circuit-breaker' }]);
|
|
97
|
+
});
|
|
98
|
+
for (const [label, touch, want] of [['exit 3 with scope-expansion: lines outside the declared files', 'b.js', [false, 3, 'scope-expansion']], ['exit 3 without: lines inside the declared files', 'a.js', [false, 3, 'diff-cap-exceeded']]]) {
|
|
99
|
+
const r = repo();
|
|
100
|
+
await withClient(r, async (c) => {
|
|
101
|
+
await step(c, 'open', { files: ['a.js'], diff_cap: 5 }); writeFileSync(file(r, touch), `${'x\n'.repeat(20)}`);
|
|
102
|
+
const s = await step(c, 'after-code', { agent: 'somi-coder' });
|
|
103
|
+
check(label, [...gate(s), s.diff.weighted_lines > 5, s.cli.includes('--diff-cap <N>')], [...want, true, true]);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const timed = repo(); mkdirSync(file(timed, '.somi', 'somi-state', 'run'), { recursive: true }); writeFileSync(file(timed, '.somi', 'somi-state', 'run', 'p1.json'), JSON.stringify({ started: '2020-01-01T00:00:00Z', max_minutes: 1 }));
|
|
107
|
+
await withClient(timed, async (c) => check('exit 4: a run past its time budget stops the open', gate(await step(c, 'open', { files: ['a.js'] })), [false, 4, 'time-budget']));
|
|
108
|
+
const brief = repo(['p1', 'bo']); rmSync(file(brief, '.somi', 'plans', 'bo', 'phases'), { recursive: true }); writeFileSync(file(brief, '.somi', 'plans', 'bo', 'brief.md'), '# brief\n'); writeFileSync(file(brief, '.somi', 'plans', 'bo', 'progress.md'), ROWS);
|
|
109
|
+
await withClient(brief, async (c) => {
|
|
110
|
+
const b = await step(c, 'open', { slug: 'bo', files: ['a.js'] });
|
|
111
|
+
check('exit 64: a brief-only work item without its tier record is refused', [b.err, b.exit, /brief-only/.test(b.error)], [true, 64, true]);
|
|
112
|
+
const run = await step(c, 'open', { files: ['a.js'] });
|
|
113
|
+
const sentinel = await step(c, 'after-code', { agent: 'somi-no-such-agent' });
|
|
114
|
+
check('exit 65: an agent the resolver does not know', [sentinel.err, sentinel.exit], [true, 65]);
|
|
115
|
+
const snapshot = tree(brief);
|
|
116
|
+
const bads = await Promise.all([{ step: 'nope' }, { step: 'open', now: '2020-01-01T00:00' }, { step: 'open', reviewed: 'approve' }, { step: 'open', activity: 'x' }, { step: 'open', status: 'done' }, { step: 'open', failAfter: 'pass' }, { step: 'open', max_passes: 9 }, { step: 'open', diff_cap: 999 }, { step: 'open', slug: '../x' }, { step: 'status', iteration: '1.1/../x' }].map((a) => step(c, a.step, a)));
|
|
117
|
+
check('exit 64: an unknown step, a clock, a row field or a foreign field, a cap above the stored one, a traversal slug or iteration; nothing is written', [bads.map((x) => [x.err, x.exit]), tree(brief), run.pass], [bads.map(() => [true, 64]), snapshot, 1]);
|
|
118
|
+
});
|
|
119
|
+
const quota = repo();
|
|
120
|
+
await withClient(quota, async (c) => {
|
|
121
|
+
const first = await step(c, 'open', { files: ['a.js'] }); const n1 = entries(quota);
|
|
122
|
+
for (let i = 0; i < 10; i++) await step(c, 'open', { files: ['a.js'] });
|
|
123
|
+
check('a call repeated eleven times records one pass and one diary entry (replayed from the second call)', [first.replayed, (await step(c, 'open', { files: ['a.js'] })).replayed, entries(quota) === n1, state(quota).history.length, state(quota).pass], [false, true, true, 0, 1]);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
console.log('== the root and the environment ==');
|
|
127
|
+
{
|
|
128
|
+
const host = repo(); const other = repo(); const lone = repo();
|
|
129
|
+
await withClient(host, async (c) => {
|
|
130
|
+
const before = tree(other); const out = await step(c, 'open', { files: ['a.js'], project_dir: other });
|
|
131
|
+
check('a project_dir outside the host root is refused 64 and nothing is written there', [out.err, out.exit, /outside the host-supplied root/.test(out.error), tree(other)], [true, 64, true, before]);
|
|
132
|
+
const inside = path.join(host, 'sub'); mkdirSync(file(inside, '.somi', 'plans', 'p1', 'phases'), { recursive: true });
|
|
133
|
+
for (const [f, text] of [['diary.md', DIARY], ['progress.md', ROWS]]) writeFileSync(file(inside, '.somi', 'plans', 'p1', f), text);
|
|
134
|
+
const opened = await step(c, 'open', { files: ['a.js'], project_dir: inside }); const viaDir = await step(c, 'status', { project_dir: inside }); const viaHost = await step(c, 'status');
|
|
135
|
+
check('a project_dir inside the host root selects that project: the loop opened through it is found through it only', [opened.err, opened.pass, viaDir.pass, viaHost.exit, existsSync(file(inside, '.somi', 'somi-state', 'loop', 'p1.1.1.json')), existsSync(file(host, '.somi', 'somi-state'))], [false, 1, 1, 64, true, false]);
|
|
136
|
+
});
|
|
137
|
+
await withClient(host, async (c) => {
|
|
138
|
+
const w = await step(c, 'open', { files: ['a.js'] });
|
|
139
|
+
check('a server env cap is inert: the cap in force is the default, not SOMI_CODE_LOOP_MAX_PASSES=1', [w.err, w.caps.max_passes], [false, 3]);
|
|
140
|
+
}, { env: { SOMI_CODE_LOOP_MAX_PASSES: '1' } });
|
|
141
|
+
await withClient('', async (c) => {
|
|
142
|
+
const w = await step(c, 'open', { files: ['a.js'], project_dir: lone }); const snapshot = tree(lone);
|
|
143
|
+
const snapshot2 = tree(host); const r = await step(c, 'status', { project_dir: host });
|
|
144
|
+
check('no host root (no CLAUDE_PROJECT_DIR, no roots): a write step is refused 67 pointing at the CLI and creates nothing', [w.err, w.exit, /run the loop through the CLI/.test(w.error), tree(lone)], [true, 67, true, snapshot]);
|
|
145
|
+
check('no host root: status reads a project_dir and writes nothing', [r.err, r.pass, r.state.status, tree(host)], [false, 1, 'running', snapshot2]);
|
|
146
|
+
});
|
|
147
|
+
const a = repo(); const b = repo();
|
|
148
|
+
await withClient('', async (c) => {
|
|
149
|
+
const amb = await step(c, 'open', { files: ['a.js'] }); const sel = await step(c, 'open', { files: ['a.js'], project_dir: a });
|
|
150
|
+
check('two roots and no project_dir are refused as ambiguous (67); project_dir selects one of them', [amb.err, amb.exit, /ambiguous/.test(amb.error), sel.err, sel.pass, tree(b)['.somi/somi-state'] === undefined], [true, 67, true, false, 1, true]);
|
|
151
|
+
}, { roots: [a, b] });
|
|
152
|
+
}
|
|
153
|
+
console.log('== the files a model names, the writes that fail, the budget ==');
|
|
154
|
+
{
|
|
155
|
+
const root = repo();
|
|
156
|
+
await withClient(root, async (c) => {
|
|
157
|
+
const o = await step(c, 'open', { files: ['a.js', 'x<!--y.js', '.js'] });
|
|
158
|
+
check('a file name never reaches the diary (only a count does), so it cannot open a comment or an image there', [o.err, diary(root).includes('<!--'), diary(root).includes('![i]'), diary(root).includes('files in scope: 3')], [false, false, false, true]);
|
|
159
|
+
});
|
|
160
|
+
const ro = repo();
|
|
161
|
+
if (process.getuid?.() === 0) console.log(' skip a failed diary write is handed back as unwritten (running as root: a read-only directory is writable)');
|
|
162
|
+
else {
|
|
163
|
+
chmodSync(file(ro, '.somi', 'plans', 'p1'), 0o555);
|
|
164
|
+
await withClient(ro, async (c) => {
|
|
165
|
+
const w = await step(c, 'open', { files: ['a.js'] }); const again = await step(c, 'open', { files: ['a.js'] });
|
|
166
|
+
check('a diary write that failed is a normal result whose unwritten items name the file and the kind of record; a repeat replays it', [w.err, w.exit, w.unwritten.map((u) => [u.reason, u.file, u.kind]), again.replayed], [false, 0, [['write-failed', 'diary.md', 'diary-entry'], ['write-failed', 'progress.md', 'iteration-row']], true]);
|
|
167
|
+
});
|
|
168
|
+
chmodSync(file(ro, '.somi', 'plans', 'p1'), 0o755);
|
|
169
|
+
}
|
|
170
|
+
check(`every response in this file fit the 2.5 KB budget (largest ${Math.max(...sizes)} bytes)`, sizes.every((s) => s <= 2500), true);
|
|
171
|
+
const stub = repo(); const bare = tree(stub); const stubbed = await callLoopStep({ step: 'open', slug: 'p1', iteration: '1.1', files: ['a.js'] }, { resolveRoot: async () => ({ ok: true, root: stub }), env: {}, installRoot: ROOT });
|
|
172
|
+
check('a resolver result that does not say hosted is not taken as hosted: a write step is refused 67 and writes nothing', [stubbed.isError, JSON.parse(stubbed.text).exit, tree(stub)], [true, 67, bare]);
|
|
173
|
+
}
|
|
174
|
+
console.log('== one result shape, the root once, the environment, the state directory ==');
|
|
175
|
+
{
|
|
176
|
+
const r = repo(); const roots = repo(); const outside = repo();
|
|
177
|
+
await withClient(r, async (c) => {
|
|
178
|
+
await step(c, 'open', { files: ['a.js'] });
|
|
179
|
+
const a66 = await step(c, 'after-code', { agent: 'somi' });
|
|
180
|
+
writeFileSync(file(r, '.somi', 'config.json'), '{ not json');
|
|
181
|
+
const a67 = await step(c, 'after-code', { agent: 'somi-coder' });
|
|
182
|
+
check('exits 66 (agent somi) and 67 (a corrupt .somi/config.json) are refusals, in the one JSON shape with next and exit', [a66, a67].map((x) => [x.err, x.exit, x.ok, x.next, typeof x.error]), [[true, 66, false, null, 'string'], [true, 67, false, null, 'string']]);
|
|
183
|
+
});
|
|
184
|
+
await withClient('', async (c) => {
|
|
185
|
+
let asked = 0; c.rootsHandler = async () => (asked++ ? [] : [roots]);
|
|
186
|
+
const before = tree(outside); const out = await step(c, 'open', { files: ['a.js'], project_dir: outside });
|
|
187
|
+
check('the root is asked for once: a second roots/list that returns nothing cannot hand the root to project_dir', [out.err, out.exit, asked, tree(outside)], [true, 64, 1, before]);
|
|
188
|
+
}, { roots: true });
|
|
189
|
+
const rev = repo(); const gcfg = path.join(tmp, 'global.json'); writeFileSync(gcfg, '{"code_loop":{"max_passes":2}}');
|
|
190
|
+
await withClient(rev, async (c) => {
|
|
191
|
+
const o = await step(c, 'open', { files: ['a.js'] }); const ac = await step(c, 'after-code', { agent: 'somi-coder' });
|
|
192
|
+
check('the review mode, review scope and severity floor in the server env reach the loop, the diff-cap variable does not, and SOMI_GLOBAL_CONFIG does', [ac.review_mode, ac.next, ac.scope.scope, ac.scope.why, o.caps.severity_floor, o.caps.diff_cap_lines, o.caps.max_passes], ['security', 'task-reviewers', 'full', 'setting', 'Minor', 400, 2]);
|
|
193
|
+
}, { env: { SOMI_CODE_LOOP_REVIEW: 'security', SOMI_CODE_LOOP_REVIEW_SCOPE: 'full', SOMI_CODE_LOOP_SEVERITY_FLOOR: 'Minor', SOMI_CODE_LOOP_DIFF_CAP: '5', SOMI_GLOBAL_CONFIG: gcfg } });
|
|
194
|
+
const link = repo(); const away = path.join(tmp, 'away'); mkdirSync(away); mkdirSync(file(link, '.somi'), { recursive: true }); symlinkSync(away, file(link, '.somi', 'somi-state'));
|
|
195
|
+
await withClient(link, async (c) => {
|
|
196
|
+
const o = await step(c, 'open', { files: ['a.js'] });
|
|
197
|
+
check('a state directory that is a link is refused 64 before any write: the directory it points to stays empty', [o.err, o.exit, readdirSync(away)], [true, 64, []]);
|
|
198
|
+
});
|
|
199
|
+
const evil = repo(); const H = '<!--x-->  `c` [x](u) # > - ```';
|
|
200
|
+
await withClient(evil, async (c) => {
|
|
201
|
+
await step(c, 'open', { files: ['a.js', `${H}.js`.replace(/\s/g, '')] });
|
|
202
|
+
await step(c, 'after-code', { agent: 'somi-coder' });
|
|
203
|
+
const bad = await step(c, 'after-review', review('request-changes', { majors: 1, findings: [{ ...MAJOR, file: H, symbol: H, title: H }], reviewers: ['somi-reviewer', H] }));
|
|
204
|
+
const ar = await step(c, 'after-review', review('request-changes', { majors: 1, findings: [{ ...MAJOR, file: H, symbol: H, title: H }] }));
|
|
205
|
+
const cl = await step(c, 'close', { status: 'stopped-user-stop' });
|
|
206
|
+
const added = (diary(evil).split(DIARY.slice(DIARY.indexOf('## ')))[0] + readFileSync(file(evil, '.somi', 'plans', 'p1', 'progress.md'), 'utf8')).replace(/`(note|blocker)`/g, '');
|
|
207
|
+
check('hostile findings and a hostile reviewers entry run through open to close: refused or recorded, and diary.md and progress.md hold no markup from them', [bad.exit, ar.exit, cl.err, ['<!--', ''].filter((m) => added.includes(m))], [64, 0, false, []]);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
console.log('== a git that does not answer, and the words the results use ==');
|
|
211
|
+
{
|
|
212
|
+
const stuck = repo(); const fake = path.join(tmp, 'fakegit'); mkdirSync(fake); writeFileSync(path.join(fake, 'git'), '#!/bin/sh\nexec sleep 3\n', { mode: 0o755 });
|
|
213
|
+
const call = async (args) => { const r = await callLoopStep({ slug: 'p1', iteration: '1.1', ...args }, { resolveRoot: async () => ({ ok: true, root: stuck, hosted: true }), env: { SOMI_GLOBAL_CONFIG: '' }, installRoot: ROOT }); return { err: r.isError, ...JSON.parse(r.text) }; };
|
|
214
|
+
await call({ step: 'open', files: ['a.js'] });
|
|
215
|
+
const [real, limit] = [process.env.PATH, LIMITS.gitTimeoutMs]; process.env.PATH = `${fake}:${real}`; LIMITS.gitTimeoutMs = 300;
|
|
216
|
+
let ac; try { ac = await call({ step: 'after-code', agent: 'somi-coder' }); } finally { process.env.PATH = real; LIMITS.gitTimeoutMs = limit; }
|
|
217
|
+
check('a git that does not answer within the limit is a refusal (64 saying so), never a diff gate pass; no review is asked for', [ac.err, ac.exit, ac.next, /git did not answer within 0\.3 seconds/.test(ac.error)], [true, 64, null, true]);
|
|
218
|
+
check('every next and every unwritten kind this file saw is one the engine owns', [[...seen.next].filter((x) => x !== null && !NEXTS.includes(x)), [...seen.kind].filter((x) => x !== undefined && !KINDS.includes(x))], [[], []]);
|
|
219
|
+
}
|
|
220
|
+
{
|
|
221
|
+
const deep = path.join(tmp, 'y'.repeat(200), 'y'.repeat(200)); mkdirSync(deep, { recursive: true });
|
|
222
|
+
const refusals = [await resolveProjectRoot({ projectDirArg: `/${'x'.repeat(500)}` }), await resolveProjectRoot({ projectDirArg: 'x'.repeat(500) }), await resolveProjectRoot({ projectDirArg: deep, listRoots: async () => [`file://${repo()}`] })];
|
|
223
|
+
check('a long project_dir is echoed cut to 60 characters in each refusal text that shows it (missing, not absolute, outside the host root)', refusals.map((r) => [r.ok, r.code, r.message.length < 220, r.message.includes('x'.repeat(60)) || r.message.includes('y'.repeat(60))]), Array(3).fill([false, 64, true, false]));
|
|
224
|
+
}
|
|
225
|
+
console.log(`somi_loop tests: ${pass} ok, ${fail} failed`);
|
|
226
|
+
process.exit(fail ? 1 : 0);
|
|
@@ -13,6 +13,7 @@ import { tmpdir } from 'node:os';
|
|
|
13
13
|
import path from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
15
|
import { McpClient } from './somi-mcp-client.mjs';
|
|
16
|
+
import { installText } from '../../../scripts/lib/install-text.mjs';
|
|
16
17
|
|
|
17
18
|
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
|
|
18
19
|
const SERVER = path.join(ROOT, 'scripts', 'somi-mcp.mjs');
|
|
@@ -70,7 +71,7 @@ async function run() {
|
|
|
70
71
|
|
|
71
72
|
const list = await client.request('tools/list', {});
|
|
72
73
|
const names = (list.tools || []).map((t) => t.name).sort();
|
|
73
|
-
check('tools/list carries exactly somi_resolve, somi_agent_info, somi_command, somi_skill, somi_agent, somi_tier and
|
|
74
|
+
check('tools/list carries exactly somi_resolve, somi_agent_info, somi_command, somi_skill, somi_agent, somi_tier, somi_config and somi_loop', names, ['somi_agent', 'somi_agent_info', 'somi_command', 'somi_config', 'somi_loop', 'somi_resolve', 'somi_skill', 'somi_tier']);
|
|
74
75
|
|
|
75
76
|
const ping = await client.request('ping', {});
|
|
76
77
|
check('ping returns an empty result', ping, {});
|
|
@@ -422,6 +423,25 @@ async function run() {
|
|
|
422
423
|
check('m2: it is reported as the usual 64, not surfaced as an internal error', /\(exit 64\)/.test(toolText(r2)), true);
|
|
423
424
|
});
|
|
424
425
|
|
|
426
|
+
// --- install-text names: the unknown-name text, object-shaped names, a bounded name, and a read error that is not "missing" ---
|
|
427
|
+
await withClient({}, async (client) => {
|
|
428
|
+
await client.initialize();
|
|
429
|
+
const texts = [];
|
|
430
|
+
for (const [tool, name] of [['somi_command', 'no-such-command'], ['somi_skill', 'no-such-skill']]) texts.push(toolText(await toolCall(client, tool, { name })));
|
|
431
|
+
check('an unknown command and an unknown skill are 65 and say which kind and name', texts.map((t) => [/\(exit 65\)$/.test(t), t.includes(`unknown ${t.includes('somi-command') ? 'command' : 'skill'} "no-such-`)]), [[true, true], [true, true]]);
|
|
432
|
+
const objects = [];
|
|
433
|
+
for (const tool of ['somi_skill', 'somi_agent']) objects.push(await toolCall(client, tool, { name: { toString: null } }));
|
|
434
|
+
check('an object-shaped skill or agent name is a clean 64, not an internal error', objects.map((r) => [r.isError, /\(exit 64\)$/.test(toolText(r))]), [[true, true], [true, true]]);
|
|
435
|
+
const long = toolText(await toolCall(client, 'somi_skill', { name: 'a'.repeat(5000) }));
|
|
436
|
+
check('a name over 64 characters is a 64 whose text does not repeat it', [/\(exit 64\)$/.test(long), long.length < 200], [true, true]);
|
|
437
|
+
check('a name of exactly 64 characters passes the bound (and is unknown, 65)', /\(exit 65\)$/.test(toolText(await toolCall(client, 'somi_skill', { name: 'a'.repeat(64) }))), true);
|
|
438
|
+
});
|
|
439
|
+
{
|
|
440
|
+
const install = fresh(); mkdirSync(path.join(install, 'commands', 'x.md'), { recursive: true });
|
|
441
|
+
let code = null; try { installText('command', { name: 'x' }, { installRoot: install }); } catch (e) { code = e.code; }
|
|
442
|
+
check('a read error that is not "missing" (a directory at commands/x.md) is rethrown, never reported as an unknown command', code, 'EISDIR');
|
|
443
|
+
}
|
|
444
|
+
|
|
425
445
|
// --- M2: the SAME bad input produces the SAME code through the CLI and the MCP tool ----------
|
|
426
446
|
{
|
|
427
447
|
const badInputs = [
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# The loop engine's libraries (scripts/lib/loop-*.mjs), called in-process: cap resolution and every handler take
|
|
3
|
+
# their environment as a parameter and never read process.env (sentinels planted in it, global config included,
|
|
4
|
+
# are ignored), malformed caps are refused with exit 64, and the exit model is plain data (check-diff over the cap
|
|
5
|
+
# returns its JSON and code 3 in one result). scripts/lib/findings-ledger.mjs gets the same treatment: record's
|
|
6
|
+
# identity, breaker and no-write-on-bad-input behaviour, the resolve/reopen/open/get lifecycle, and no environment
|
|
7
|
+
# read. The composite steps (loop-step.mjs) and the notes writers have their own test files below, the last one the leniency toward a model's habits. The CLI's bytes
|
|
8
|
+
# are pinned separately by tests/scripts/run.sh and its goldens.
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
11
|
+
# Hermetic like scripts/validate.sh: the developer's global config must not reach the suite.
|
|
12
|
+
export SOMI_GLOBAL_CONFIG=""
|
|
13
|
+
node "$ROOT/tests/scripts/lib/loop-engine-tests.mjs"
|
|
14
|
+
node "$ROOT/tests/scripts/lib/findings-ledger-tests.mjs"
|
|
15
|
+
node "$ROOT/tests/scripts/lib/loop-notes-tests.mjs"
|
|
16
|
+
node "$ROOT/tests/scripts/lib/loop-step-tests.mjs"
|
|
17
|
+
node "$ROOT/tests/scripts/lib/loop-step-state-tests.mjs"
|
|
18
|
+
node "$ROOT/tests/scripts/lib/loop-step-close-tests.mjs"
|
|
19
|
+
node "$ROOT/tests/scripts/lib/loop-step-cli-tests.mjs"
|
|
20
|
+
node "$ROOT/tests/scripts/lib/loop-step-unwritten-tests.mjs"
|
|
21
|
+
node "$ROOT/tests/scripts/lib/loop-step-lenient-tests.mjs"
|
|
22
|
+
node "$ROOT/tests/scripts/lib/loop-escalate-tests.mjs"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Guards the shape of both loop flows' MCP path (calls per clean pass, no CLI step before the Host fallback, the engine's
|
|
3
|
+
# tokens, the safety rules, the size budget), proven red on mutated copies, with one real pass per flow through the
|
|
4
|
+
# server (tests/scripts/lib/loop-flow-gate.mjs). It fails unless the summary line printed.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
7
|
+
# Hermetic like scripts/validate.sh: the developer's global config must not reach the suite.
|
|
8
|
+
export SOMI_GLOBAL_CONFIG=""
|
|
9
|
+
out="$(node "$ROOT/tests/scripts/lib/loop-flow-gate.mjs")" || { printf '%s\n' "$out"; exit 1; }
|
|
10
|
+
printf '%s\n' "$out"
|
|
11
|
+
printf '%s\n' "$out" | grep -Eq '^loop flow shape: [1-9][0-9]* ok, 0 failed$'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Proves the lens membership validate.sh's write-discipline check DERIVES from
|
|
3
|
-
#
|
|
3
|
+
# skills/flow-review-panel/SKILL.md's table (same extraction regex) includes every seated review agent, and
|
|
4
4
|
# that the check goes RED in a `cp -a` copy when a seated agent loses its `## Write discipline`.
|
|
5
5
|
# Chained from dispatch-reference-gate.sh (validate.sh is at its size budget).
|
|
6
6
|
set -uo pipefail
|
|
@@ -8,7 +8,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
|
8
8
|
pass=0; fail=0
|
|
9
9
|
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
10
10
|
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
11
|
-
derive() { grep -oE '^\| *`[a-z][a-z0-9-]*`' "$1/
|
|
11
|
+
derive() { grep -oE '^\| *`[a-z][a-z0-9-]*`' "$1/skills/flow-review-panel/SKILL.md" | tr -d '|` ' | sort -u; }
|
|
12
12
|
|
|
13
13
|
echo "== review-panel seated-lens derivation =="
|
|
14
14
|
seated="$(derive "$ROOT")"
|
|
@@ -18,11 +18,11 @@ for a in somi-reviewer somi-security-reviewer somi-architecture-reviewer somi-te
|
|
|
18
18
|
done
|
|
19
19
|
# Each seated lens is also named in the parallel-start block, so a seat cannot exist without a start.
|
|
20
20
|
for a in $seated; do
|
|
21
|
-
grep -qE "^Task +$a " "$ROOT/
|
|
21
|
+
grep -qE "^Task +$a " "$ROOT/skills/flow-review-panel/SKILL.md" && ok "parallel start Tasks $a" || bad "parallel start does not Task $a"
|
|
22
22
|
done
|
|
23
23
|
|
|
24
24
|
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
|
25
|
-
cp -a "$ROOT/
|
|
25
|
+
mkdir -p "$TMP/skills"; cp -a "$ROOT/skills/flow-review-panel" "$TMP/skills/"; cp -a "$ROOT/agents" "$TMP/"
|
|
26
26
|
sed -i '/^## Write discipline/d' "$TMP/agents/somi-plan-reviewer.md"
|
|
27
27
|
red=0
|
|
28
28
|
for a in $(derive "$TMP"); do grep -q '^## Write discipline' "$TMP/agents/$a.md" || red=$((red+1)); done
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Guards scripts/somi-card.mjs and scripts/lib/run-card.mjs, the run card every agent of a code iteration is briefed
|
|
3
|
+
# with: it carries the facts it names and nothing from the loop's history (no verdicts, no findings: a reviewer must
|
|
4
|
+
# not learn what the coder thought), it is byte-identical across runs so repeated briefings share a prompt prefix,
|
|
5
|
+
# it stays small, its values are printable, and a missing loop state or a bad argument is a usage error.
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
8
|
+
CARD="$ROOT/scripts/somi-card.mjs"
|
|
9
|
+
pass=0; fail=0
|
|
10
|
+
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
11
|
+
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
12
|
+
check() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want $3, got $2)"; fi; }
|
|
13
|
+
has() { if grep -qF -- "$2" <<<"$3"; then ok "$1"; else bad "$1 (no '$2' in the card)"; fi; }
|
|
14
|
+
echo "== run card =="
|
|
15
|
+
|
|
16
|
+
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
|
17
|
+
P="$TMP/proj"; mkdir -p "$P/.somi/somi-state/loop" "$P/.somi/plans/rate-limit/phases"
|
|
18
|
+
printf '# spec\n' > "$P/.somi/plans/rate-limit/spec.md"
|
|
19
|
+
printf '# phase\n' > "$P/.somi/plans/rate-limit/phases/01-limiter.md"
|
|
20
|
+
printf '{"name":"p","scripts":{"test":"node --test"}}\n' > "$P/package.json"
|
|
21
|
+
state() { printf '{"slug":"rate-limit","loop":"code","iteration":"1.1","baseline_sha":"40186ed1cd531e5f7cb991aec8d939e475ee3a53","iteration_files":%s,"history":[{"pass":1,"verdict":"request-changes","note":"SECRET-REASONING"}],"status":"running"}\n' "$1" > "$P/.somi/somi-state/loop/rate-limit.1.1.json"; }
|
|
22
|
+
state '["src/limiter.mjs","test/limiter.test.mjs"]'
|
|
23
|
+
run() { (cd "$P" && CLAUDE_PROJECT_DIR="$P" node "$CARD" "$@"); }
|
|
24
|
+
|
|
25
|
+
out="$(run --slug rate-limit --iteration 1.1 --host copilot)"; check "a card prints for a loop that was initialised" "$?" "0"
|
|
26
|
+
has "it names the scripts directory" "scripts: $ROOT/scripts" "$out"
|
|
27
|
+
has "it names the project" "project_dir: $P" "$out"
|
|
28
|
+
has "it carries the host" "host: copilot" "$out"
|
|
29
|
+
has "it names the plan files to read, the phase file found by number" "read for the task: spec.md, phases/01-limiter.md" "$out"
|
|
30
|
+
has "it names the orchestrator-owned files" "written only by the orchestrator (agents never write them): progress.md, diary.md" "$out"
|
|
31
|
+
has "it lists the files in scope" "files in scope: src/limiter.mjs test/limiter.test.mjs" "$out"
|
|
32
|
+
has "it carries the baseline" "baseline: 40186ed1cd531e5f7cb991aec8d939e475ee3a53" "$out"
|
|
33
|
+
has "it names the test command from package.json" "tests: npm test" "$out"
|
|
34
|
+
check "it is fenced as data" "$(head -1 <<<"$out")" '```somi-card'
|
|
35
|
+
check "nothing from the loop history reaches it" "$(grep -c 'SECRET-REASONING\|request-changes' <<<"$out")" "0"
|
|
36
|
+
check "two runs print the same bytes" "$(run --slug rate-limit --iteration 1.1 --host copilot | sha256sum)" "$(sha256sum <<<"$out")"
|
|
37
|
+
check "it stays under 2 KiB" "$([ "$(printf '%s' "$out" | wc -c)" -le 2048 ] && echo yes)" "yes"
|
|
38
|
+
|
|
39
|
+
touch "$P/.somi/plans/rate-limit/brief.md"
|
|
40
|
+
has "a brief, when present, is in the read list" "read for the task: spec.md, phases/01-limiter.md, brief.md" "$(run --slug rate-limit --iteration 1.1 --host claude-code)"
|
|
41
|
+
state "$(node -e 'console.log(JSON.stringify(Array.from({length:25},(_, i)=>"src/f"+i+".mjs")))')"
|
|
42
|
+
has "more than 20 files are cut, with the rest counted" "(and 5 more in the phase file)" "$(run --slug rate-limit --iteration 1.1 --host claude-code)"
|
|
43
|
+
state '["src/a\u001b[31m.mjs","src/b.mjs"]'
|
|
44
|
+
check "control and bidi characters are removed from paths" "$(run --slug rate-limit --iteration 1.1 --host claude-code | grep '^files in scope' | LC_ALL=C grep -c $'[\x01-\x1f]\|\xe2\x80\xae')" "0"
|
|
45
|
+
state '["src/a```b.mjs","```"]'
|
|
46
|
+
check "a backtick in a file name cannot close the card's fence: the only fence lines are its own two" "$(run --slug rate-limit --iteration 1.1 --host claude-code | grep -c '```')" "2"
|
|
47
|
+
rm "$P/package.json"
|
|
48
|
+
has "no package.json test script: the card says so" "tests: not declared" "$(run --slug rate-limit --iteration 1.1 --host claude-code)"
|
|
49
|
+
|
|
50
|
+
run --slug rate-limit --iteration 2.1 --host claude-code >/dev/null 2>&1; check "no loop state is a usage error" "$?" "64"
|
|
51
|
+
run --slug ../x --iteration 1.1 --host claude-code >/dev/null 2>&1; check "a traversal slug is a usage error" "$?" "64"
|
|
52
|
+
run --slug rate-limit --iteration 1.1 --host vscode >/dev/null 2>&1; check "an unknown host is a usage error" "$?" "64"
|
|
53
|
+
run --slug rate-limit --iteration 1.1 >/dev/null 2>&1; check "a missing host is a usage error" "$?" "64"
|
|
54
|
+
run --slug rate-limit --iteration 1.1 --host claude-code --extra x >/dev/null 2>&1; check "an unknown argument is a usage error" "$?" "64"
|
|
55
|
+
|
|
56
|
+
echo "run card tests: $pass ok, $fail failed"
|
|
57
|
+
[ "$fail" -eq 0 ]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Guards tests/scripts/lib/run-suites.mjs, the parallel runner validate.sh starts its test scripts with: a failing
|
|
3
|
+
# script fails the run and is named; output is printed whole and in the order given, whatever the finish order;
|
|
4
|
+
# --jobs N really runs N at once and --jobs 1 runs one at a time, --alone runs a script with nothing beside it (proved by start/end markers, not by timing); and
|
|
5
|
+
# bad arguments are a usage error.
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
8
|
+
RUN="$ROOT/tests/scripts/lib/run-suites.mjs"
|
|
9
|
+
pass=0; fail=0
|
|
10
|
+
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
11
|
+
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
12
|
+
check() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want $3, got $2)"; fi; }
|
|
13
|
+
echo "== run-suites (parallel test runner) =="
|
|
14
|
+
unset SOMI_SUITE_SHARD SOMI_TEST_JOBS # set by a sharded or capped validate.sh run; each case below sets its own
|
|
15
|
+
|
|
16
|
+
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
|
17
|
+
cd "$TMP"
|
|
18
|
+
# a finishes last, b first; each logs its start and end to a shared marker file.
|
|
19
|
+
mk() { printf '#!/usr/bin/env bash\necho "start %s" >> marks\n%s\necho "end %s" >> marks\necho "out of %s"\nexit %s\n' "$1" "$2" "$1" "$1" "$3" > "$1.sh"; }
|
|
20
|
+
mk a 'sleep 0.6' 0
|
|
21
|
+
mk b ':' 0
|
|
22
|
+
mk c 'sleep 0.3; echo "to stderr" >&2' 3
|
|
23
|
+
|
|
24
|
+
: > marks; out="$(node "$RUN" --jobs 3 a.sh b.sh c.sh)"; rc=$?
|
|
25
|
+
check "a failing script fails the run" "$rc" "1"
|
|
26
|
+
check "the failure is named in the summary" "$(grep -c '^ FAILED: c.sh (exit 3)$' <<<"$out")" "1"
|
|
27
|
+
check "blocks print in the order given, not the finish order" "$(grep -oE '^==> [abc]\.sh$' <<<"$out" | tr '\n' ' ')" "==> a.sh ==> b.sh ==> c.sh "
|
|
28
|
+
check "each block carries its script's own output, stderr included" "$(sed -n '/^==> c.sh$/,/^ (/p' <<<"$out" | grep -cE '^(to stderr|out of c)$')" "2"
|
|
29
|
+
|
|
30
|
+
: > marks; out="$(node "$RUN" --jobs 1 a.sh b.sh)"; rc=$?
|
|
31
|
+
check "every script passing is exit 0" "$rc" "0"
|
|
32
|
+
check "--jobs 1 runs one at a time" "$(tr '\n' ' ' < marks)" "start a end a start b end b "
|
|
33
|
+
|
|
34
|
+
: > marks; out="$(SOMI_TEST_JOBS=1 node "$RUN" b.sh a.sh)"
|
|
35
|
+
check "SOMI_TEST_JOBS sets the default" "$(tr '\n' ' ' < marks)" "start b end b start a end a "
|
|
36
|
+
|
|
37
|
+
# Concurrency without timing: each barrier script waits (up to 10s) until all three have started.
|
|
38
|
+
for n in x y z; do mk "$n" 'for _ in $(seq 100); do [ "$(grep -c "^start" marks)" -ge 3 ] && break; sleep 0.1; done' 0; done
|
|
39
|
+
: > marks; node "$RUN" --jobs 3 x.sh y.sh z.sh >/dev/null
|
|
40
|
+
check "--jobs 3 runs three at once: all three start before any ends" "$(head -3 marks | grep -c '^start ')" "3"
|
|
41
|
+
|
|
42
|
+
# --alone: the alone script runs first and by itself; the pool starts only after it ends.
|
|
43
|
+
: > marks; out="$(node "$RUN" --jobs 3 --alone a.sh -- b.sh c.sh)"
|
|
44
|
+
check "--alone runs first, with nothing overlapping it" "$(head -2 marks | tr '\n' ' ')" "start a end a "
|
|
45
|
+
check "--alone prints its block first" "$(grep -oE '^==> [abc]\.sh$' <<<"$out" | head -1)" "==> a.sh"
|
|
46
|
+
node "$RUN" --alone >/dev/null 2>&1; check "--alone without a script is a usage error" "$?" "64"
|
|
47
|
+
|
|
48
|
+
# --plan / --shard: shards and `light` together run every script once; drift and bad plans are refused.
|
|
49
|
+
printf '{"alone":["a.sh"],"shards":{"h1":["b.sh"],"h2":["c.sh"]}}' > plan.json
|
|
50
|
+
ran() { : > marks; node "$RUN" --jobs 2 --plan plan.json "$@" -- a.sh b.sh c.sh x.sh >/dev/null 2>&1; grep '^start' marks | sed 's/^start //' | sort | tr '\n' ' '; }
|
|
51
|
+
check "--shard all runs every script" "$(ran --shard all)" "a b c x "
|
|
52
|
+
check "--shard light runs what no shard names (the alone script included)" "$(ran --shard light)" "a x "
|
|
53
|
+
check "--shard h1 runs that shard only" "$(ran --shard h1)" "b "
|
|
54
|
+
check "the shards and light together cover every script once" "$( { ran --shard light; ran --shard h1; ran --shard h2; } | tr ' ' '\n' | grep . | sort | tr '\n' ' ')" "a b c x "
|
|
55
|
+
check "SOMI_SUITE_SHARD picks the shard" "$(SOMI_SUITE_SHARD=h2 ran)" "c "
|
|
56
|
+
: > marks; SOMI_SUITE_SHARD=h2 node "$RUN" --jobs 2 b.sh x.sh >/dev/null 2>&1
|
|
57
|
+
check "SOMI_SUITE_SHARD is ignored without --plan (a sharded run's nested runner tests stay whole)" "$(grep '^start' marks | sed 's/^start //' | sort | tr '\n' ' ')" "b x "
|
|
58
|
+
sel() { node --input-type=module -e "import { selectShard } from '$RUN'; const r = selectShard(['a.sh','b.sh'], $1, '$2'); console.log(r.error ? 'error' : 'ok');"; }
|
|
59
|
+
check "a shard naming a script that was not given is refused" "$(sel '{alone:[],shards:{h:["gone.sh"]}}' h)" "error"
|
|
60
|
+
check "an alone script that was not given is refused" "$(sel '{alone:["gone.sh"],shards:{}}' all)" "error"
|
|
61
|
+
check "a script in two shards is refused" "$(sel '{alone:[],shards:{h:["a.sh"],k:["a.sh"]}}' h)" "error"
|
|
62
|
+
check "an unknown shard is refused" "$(sel '{alone:[],shards:{h:["a.sh"]}}' nope)" "error"
|
|
63
|
+
check "a shard named light is refused" "$(sel '{alone:[],shards:{light:["a.sh"]}}' all)" "error"
|
|
64
|
+
node "$RUN" --shard h1 a.sh >/dev/null 2>&1; check "--shard without --plan is a usage error" "$?" "64"
|
|
65
|
+
node "$RUN" --plan plan.json --shard nope -- a.sh b.sh c.sh >/dev/null 2>&1; check "an unknown shard on the command line is a usage error" "$?" "64"
|
|
66
|
+
|
|
67
|
+
node "$RUN" --jobs 0 a.sh >/dev/null 2>&1; check "--jobs 0 is a usage error" "$?" "64"
|
|
68
|
+
node "$RUN" --jobs x a.sh >/dev/null 2>&1; check "a non-numeric --jobs is a usage error" "$?" "64"
|
|
69
|
+
node "$RUN" >/dev/null 2>&1; check "no scripts is a usage error" "$?" "64"
|
|
70
|
+
node "$RUN" --bogus a.sh >/dev/null 2>&1; check "an unknown option is a usage error" "$?" "64"
|
|
71
|
+
node "$RUN" --jobs 2 missing.sh >/dev/null 2>&1; check "a missing script fails the run" "$?" "1"
|
|
72
|
+
|
|
73
|
+
echo "run-suites tests: $pass ok, $fail failed"
|
|
74
|
+
[ "$fail" -eq 0 ]
|
package/tests/scripts/run.sh
CHANGED
|
@@ -203,6 +203,17 @@ after2="$(node "$LOOP" check-diff --slug untracked --iteration 1.1 | jq .diff_li
|
|
|
203
203
|
check "check-diff: untracked .somi files stay excluded (F-220)" \
|
|
204
204
|
"$([[ "$after2" == "$after" ]]; echo $?)"
|
|
205
205
|
|
|
206
|
+
printf 'a\nb\nc\nd\n' > "src/é tab.txt" # untracked, non-ASCII and a tab in the name: git quotes it unless asked not to
|
|
207
|
+
out="$(node "$LOOP" check-diff --slug untracked --iteration 1.1)"
|
|
208
|
+
check "check-diff: an untracked file with a non-ASCII and tab name is counted and named, unquoted" \
|
|
209
|
+
"$([[ "$(jq -r .diff_lines <<<"$out")" == "$((after2 + 4))" ]] && jq -e '.out_of_scope | index("src/é\ttab.txt") != null' <<<"$out" >/dev/null; echo $?)"
|
|
210
|
+
rm -f "src/é tab.txt"
|
|
211
|
+
|
|
212
|
+
echo '*.dat -diff' > .gitattributes; seq 1 5000 > src/x.dat # untracked, and a -diff attribute makes git print it as binary
|
|
213
|
+
check "check-diff: an untracked 5000-line file hidden by a -diff attribute is counted (5001 with the attributes file)" \
|
|
214
|
+
"$([[ "$(node "$LOOP" check-diff --slug untracked --iteration 1.1 | jq .diff_lines)" == "$((after2 + 5001))" ]]; echo $?)"
|
|
215
|
+
rm -f .gitattributes src/x.dat
|
|
216
|
+
|
|
206
217
|
# --- somi-loop: record/finish/resume (session-death recovery) -------------------
|
|
207
218
|
node "$LOOP" record-pass --slug demo --iteration 1.1 --verdict request-changes --blockers 0 --majors 2 >/dev/null
|
|
208
219
|
out="$(node "$LOOP" resume --slug demo --iteration 1.1)"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Unit guard for tests/scripts/lib/site-roadmap-gate.mjs (the overview page's roadmap must cover every
|
|
3
|
+
# CHANGELOG release). Proved both ways against synthetic repos -- green on a consistent pair, red on
|
|
4
|
+
# each mismatch a release can produce -- rather than trusted because the real tree passes today.
|
|
5
|
+
set -uo pipefail
|
|
6
|
+
|
|
7
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
8
|
+
GATE="$ROOT/tests/scripts/lib/site-roadmap-gate.mjs"
|
|
9
|
+
|
|
10
|
+
pass=0; fail=0
|
|
11
|
+
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
12
|
+
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
13
|
+
|
|
14
|
+
echo "== site roadmap gate =="
|
|
15
|
+
|
|
16
|
+
TMP="$(mktemp -d)"
|
|
17
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
18
|
+
|
|
19
|
+
# mkrepo <dir> <changelog versions...> -- writes a CHANGELOG with one dated heading per version,
|
|
20
|
+
# newest first, plus an [Unreleased] heading the gate must skip.
|
|
21
|
+
mkrepo() {
|
|
22
|
+
local dir="$1"; shift
|
|
23
|
+
mkdir -p "$dir/site/src/content"
|
|
24
|
+
{ echo '# Changelog'; echo; echo '## [Unreleased]'; echo
|
|
25
|
+
for v in "$@"; do echo "## [$v] — 2026-01-01 — release $v"; echo; done; } > "$dir/CHANGELOG.md"
|
|
26
|
+
}
|
|
27
|
+
roadmap() { printf '%s\n' "$2" > "$1/site/src/content/roadmap.json"; }
|
|
28
|
+
|
|
29
|
+
# expect <name> <want-exit> <dir> [stderr-substring]
|
|
30
|
+
expect() {
|
|
31
|
+
local name="$1" want="$2" dir="$3" needle="${4:-}" out rc
|
|
32
|
+
out="$(node "$GATE" "$dir" 2>&1)"; rc=$?
|
|
33
|
+
if [ "$rc" -ne "$want" ]; then bad "$name -- expected exit $want, got $rc ($out)"; return; fi
|
|
34
|
+
if [ -n "$needle" ] && [[ "$out" != *"$needle"* ]]; then bad "$name -- output lacks '$needle' ($out)"; return; fi
|
|
35
|
+
ok "$name"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
GOOD='{"eras":[{"label":"a","entries":[{"version":"1.0.0","covers":["1.0.0","1.0.1"]},{"version":"1.1.0","covers":["1.1.0"]}]}]}'
|
|
39
|
+
|
|
40
|
+
R="$TMP/green"; mkrepo "$R" 1.1.0 1.0.1 1.0.0; roadmap "$R" "$GOOD"
|
|
41
|
+
expect "a roadmap covering every release passes" 0 "$R" "covers all 3 releases"
|
|
42
|
+
|
|
43
|
+
R="$TMP/new-release"; mkrepo "$R" 1.2.0 1.1.0 1.0.1 1.0.0; roadmap "$R" "$GOOD"
|
|
44
|
+
expect "a new CHANGELOG release missing from the roadmap fails" 1 "$R" "release 1.2.0 is missing"
|
|
45
|
+
expect " ...and the roadmap no longer ends at the latest release" 1 "$R" "not the latest release 1.2.0"
|
|
46
|
+
|
|
47
|
+
R="$TMP/twice"; mkrepo "$R" 1.1.0 1.0.1 1.0.0
|
|
48
|
+
roadmap "$R" '{"eras":[{"entries":[{"version":"1.0.0","covers":["1.0.0","1.0.1"]},{"version":"1.1.0","covers":["1.1.0","1.0.1"]}]}]}'
|
|
49
|
+
expect "a release covered by two entries fails" 1 "$R" "1.0.1 is covered twice"
|
|
50
|
+
|
|
51
|
+
R="$TMP/unknown"; mkrepo "$R" 1.1.0 1.0.1 1.0.0
|
|
52
|
+
roadmap "$R" '{"eras":[{"entries":[{"version":"1.0.0","covers":["1.0.0","1.0.1","0.9.0"]},{"version":"1.1.0","covers":["1.1.0"]}]}]}'
|
|
53
|
+
expect "a roadmap version the CHANGELOG lacks fails" 1 "$R" "0.9.0 is on the roadmap but not a release"
|
|
54
|
+
|
|
55
|
+
R="$TMP/own"; mkrepo "$R" 1.1.0 1.0.1 1.0.0
|
|
56
|
+
roadmap "$R" '{"eras":[{"entries":[{"version":"1.0.0","covers":["1.0.1"]},{"version":"1.1.0","covers":["1.1.0"]}]}]}'
|
|
57
|
+
expect "an entry whose covers omits its own version fails" 1 "$R" "does not list its own version"
|
|
58
|
+
|
|
59
|
+
R="$TMP/order"; mkrepo "$R" 1.1.0 1.0.1 1.0.0
|
|
60
|
+
roadmap "$R" '{"eras":[{"entries":[{"version":"1.1.0","covers":["1.1.0"]},{"version":"1.0.0","covers":["1.0.0","1.0.1"]}]}]}'
|
|
61
|
+
expect "a roadmap that does not end at the latest release fails" 1 "$R" "ends at 1.0.0"
|
|
62
|
+
|
|
63
|
+
R="$TMP/malformed"; mkrepo "$R" 1.0.0; roadmap "$R" '{"eras": [ broken'
|
|
64
|
+
expect "an unreadable roadmap exits 2" 2 "$R" "cannot read site/src/content/roadmap.json"
|
|
65
|
+
|
|
66
|
+
R="$TMP/no-eras"; mkrepo "$R" 1.0.0; roadmap "$R" '{"intro":"x"}'
|
|
67
|
+
expect "a roadmap without eras exits 2" 2 "$R" 'no "eras" list'
|
|
68
|
+
|
|
69
|
+
R="$TMP/no-releases"; mkdir -p "$R/site/src/content"; printf '# Changelog\n\n## [Unreleased]\n' > "$R/CHANGELOG.md"; roadmap "$R" "$GOOD"
|
|
70
|
+
expect "a CHANGELOG without dated releases exits 2" 2 "$R" "no release headings"
|
|
71
|
+
|
|
72
|
+
# site/ is not in the npm package (package.json `files`), so the real-tree case runs only in a checkout.
|
|
73
|
+
if [ -d "$ROOT/site" ]; then expect "the real tree passes" 0 "$ROOT"; else echo " (skipped: site/ not packaged)"; fi
|
|
74
|
+
|
|
75
|
+
echo " $pass passed, $fail failed"
|
|
76
|
+
[ "$fail" -eq 0 ]
|
|
@@ -521,9 +521,9 @@ drift_red "threshold row removed from the skill" skill "s.replace('| \`TRIVIAL_M
|
|
|
521
521
|
drift_red "threshold sentence pasted into the section" skill "s.replace('### Thresholds','Not security-sensitive: touches no auth, crypto, secrets, PII, or untrusted-input boundary.\n\n### Thresholds')"
|
|
522
522
|
drift_red "threshold label pasted into the section" skill "s.replace('### Thresholds','Cheap to reverse.\n\n### Thresholds')"
|
|
523
523
|
|
|
524
|
-
# ---- text guard:
|
|
524
|
+
# ---- text guard: skills/flow-ship-loop/SKILL.md points at the rubric and holds no copy of it ----
|
|
525
525
|
echo "== size tier: ship-loop text guard =="
|
|
526
|
-
SHIPGUARD="$ROOT/tests/scripts/lib/ship-loop-sizing-guard.mjs"; SHIP="$ROOT/
|
|
526
|
+
SHIPGUARD="$ROOT/tests/scripts/lib/ship-loop-sizing-guard.mjs"; SHIP="$ROOT/skills/flow-ship-loop/SKILL.md"
|
|
527
527
|
if d="$(node "$SHIPGUARD" "$SHIP" "$SKILL" 2>&1)"; then ok "ship-loop and skill agree: $d"; else bad "ship-loop text guard failed: $d"; fi
|
|
528
528
|
ship_red() { # $1 = label, $2 = node expression over `s` (ship-loop.md) returning the mutated text
|
|
529
529
|
node -e "const fs=require('fs');const s=fs.readFileSync(process.argv[1],'utf8');const t=($2);if(t===s){process.exit(3)}fs.writeFileSync(process.argv[2],t)" "$SHIP" "$TMP/ship.md" || { bad "ship-loop mutation '$1' did not apply"; return; }
|
|
@@ -543,7 +543,7 @@ ship_red "trivial-threshold label pasted" "s.replace('### Stage 0','Cheap to rev
|
|
|
543
543
|
|
|
544
544
|
# ---- text guard: /code and /code-loop accept a brief-only item only with the CLI's tier record ----
|
|
545
545
|
echo "== size tier: brief-only text guard =="
|
|
546
|
-
BRIEFGUARD="$ROOT/tests/scripts/lib/brief-only-guard.mjs"; CODE="$ROOT/
|
|
546
|
+
BRIEFGUARD="$ROOT/tests/scripts/lib/brief-only-guard.mjs"; CODE="$ROOT/skills/flow-code/SKILL.md"; LOOP="$ROOT/skills/flow-code-loop/SKILL.md"
|
|
547
547
|
if d="$(node "$BRIEFGUARD" "$CODE" "$LOOP" 2>&1)"; then ok "brief-only rule: $d"; else bad "brief-only text guard failed: $d"; fi
|
|
548
548
|
brief_red() { # $1 = label, $2 = which file (code|loop), $3 = node expression over `s`
|
|
549
549
|
local src="$CODE" a="$TMP/code.md" b="$LOOP"; [ "$2" = loop ] && { src="$LOOP"; a="$CODE"; b="$TMP/loop.md"; }
|