@v11g/agents-rock 1.0.7 → 1.0.8
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/package.json +1 -1
- package/plugins/reasoning/.claude-plugin/plugin.json +1 -1
- package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/names-closest-available.md +5 -6
- package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/no-improvised-levels.md +4 -6
- package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/skill-fired.md +1 -1
- package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/states-unavailable.md +4 -5
- package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/systemic-design-fired.md +10 -0
- package/plugins/reasoning/evals/guardrail-unavailable-framework/prompt.md +2 -2
- package/plugins/reasoning/evals/ps-interview-first-question/graders/look-in-present.md +10 -0
- package/plugins/reasoning/evals/ps-interview-first-question/graders/no-fixed-exits.md +11 -0
- package/plugins/reasoning/evals/ps-interview-first-question/graders/options-from-input.md +15 -0
- package/plugins/reasoning/evals/ps-interview-first-question/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/ps-interview-first-question/graders/source-hint.md +11 -0
- package/plugins/reasoning/evals/ps-interview-first-question/graders/targets-gap.md +13 -0
- package/plugins/reasoning/evals/ps-interview-first-question/prompt.md +8 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/graders/look-in-present.md +10 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/graders/no-fixed-exits.md +11 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/graders/options-from-input.md +11 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/graders/source-hint.md +11 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/graders/targets-gap.md +15 -0
- package/plugins/reasoning/evals/ps-interview-five-whys/prompt.md +8 -0
- package/plugins/reasoning/evals/ps-router-handoff/graders/no-reselection.md +11 -0
- package/plugins/reasoning/evals/ps-router-handoff/graders/runs-rca.md +8 -0
- package/plugins/reasoning/evals/ps-router-handoff/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/ps-router-handoff/prompt.md +11 -0
- package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/routing-classify-only/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/no-unavailability-claim.md +10 -0
- package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/routing-simple-null-pointer/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/routing-thin-input-provisional/graders/confidence-single-word.md +10 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/dates-traced.md +15 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/interventions-cite-entries.md +12 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/owners-from-input.md +8 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/plan-steps-complete.md +21 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/selects-systemic-design.md +12 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/sd-default-selection/graders/systemic-design-fired.md +10 -0
- package/plugins/reasoning/evals/sd-default-selection/prompt.md +11 -0
- package/plugins/reasoning/evals/sd-named-framework-software/graders/names-no-skill.md +11 -0
- package/plugins/reasoning/evals/sd-named-framework-software/graders/no-systemic-block.md +10 -0
- package/plugins/reasoning/evals/sd-named-framework-software/graders/systemic-design-fired.md +10 -0
- package/plugins/reasoning/evals/sd-named-framework-software/prompt.md +8 -0
- package/plugins/reasoning/evals/sd-not-software/graders/no-systemic-block.md +10 -0
- package/plugins/reasoning/evals/sd-not-software/graders/says-out-of-scope.md +10 -0
- package/plugins/reasoning/evals/sd-not-software/prompt.md +8 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/first-question-targets-model.md +11 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/look-in-present.md +10 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/model-gap-blocks-stop.md +14 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/model-in-assumptions.md +13 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/no-fixed-exits.md +11 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/sd-raw-input/graders/systemic-design-fired.md +10 -0
- package/plugins/reasoning/evals/sd-raw-input/prompt.md +8 -0
- package/plugins/reasoning/evals/sd-theory-of-change/graders/links-carry-assumptions.md +9 -0
- package/plugins/reasoning/evals/sd-theory-of-change/graders/no-dates.md +8 -0
- package/plugins/reasoning/evals/sd-theory-of-change/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/sd-theory-of-change/graders/systemic-design-fired.md +10 -0
- package/plugins/reasoning/evals/sd-theory-of-change/graders/toc-block.md +10 -0
- package/plugins/reasoning/evals/sd-theory-of-change/prompt.md +8 -0
- package/plugins/reasoning/evals/sd-three-horizons/graders/dates-are-assumptions.md +11 -0
- package/plugins/reasoning/evals/sd-three-horizons/graders/owners-are-roles.md +8 -0
- package/plugins/reasoning/evals/sd-three-horizons/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/sd-three-horizons/graders/systemic-design-fired.md +10 -0
- package/plugins/reasoning/evals/sd-three-horizons/graders/three-horizons-block.md +10 -0
- package/plugins/reasoning/evals/sd-three-horizons/prompt.md +9 -0
- package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/edges-carry-support-labels.md +2 -2
- package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/no-invented-delays.md +7 -4
- package/plugins/reasoning/evals/st-interview-first-question/graders/look-in-present.md +10 -0
- package/plugins/reasoning/evals/st-interview-first-question/graders/no-fixed-exits.md +11 -0
- package/plugins/reasoning/evals/st-interview-first-question/graders/options-from-input.md +11 -0
- package/plugins/reasoning/evals/st-interview-first-question/graders/skill-fired.md +7 -0
- package/plugins/reasoning/evals/st-interview-first-question/graders/source-hint.md +11 -0
- package/plugins/reasoning/evals/st-interview-first-question/graders/targets-gap.md +13 -0
- package/plugins/reasoning/evals/st-interview-first-question/prompt.md +8 -0
- package/plugins/reasoning/evals/st-selection-boundary/graders/one-block-only.md +9 -6
- package/plugins/reasoning/skills/problem-router/SKILL.md +7 -11
- package/plugins/reasoning/skills/problem-router/references/contract.md +6 -0
- package/plugins/reasoning/skills/problem-solving/README.md +4 -0
- package/plugins/reasoning/skills/problem-solving/SKILL.md +13 -3
- package/plugins/reasoning/skills/problem-solving/references/contract.md +6 -0
- package/plugins/reasoning/skills/problem-solving/references/interview.md +66 -0
- package/plugins/reasoning/skills/systemic-design/README.md +42 -0
- package/plugins/reasoning/skills/systemic-design/SKILL.md +182 -0
- package/plugins/reasoning/skills/systemic-design/frameworks/systemic-design.md +39 -0
- package/plugins/reasoning/skills/systemic-design/frameworks/theory-of-change.md +34 -0
- package/plugins/reasoning/skills/systemic-design/frameworks/three-horizons.md +28 -0
- package/plugins/reasoning/skills/systemic-design/references/contract.md +110 -0
- package/plugins/reasoning/skills/systemic-design/references/interview.md +66 -0
- package/plugins/reasoning/skills/systems-thinking/README.md +10 -6
- package/plugins/reasoning/skills/systems-thinking/SKILL.md +16 -6
- package/plugins/reasoning/skills/systems-thinking/frameworks/causal-loop.md +5 -2
- package/plugins/reasoning/skills/systems-thinking/frameworks/leverage-points.md +1 -1
- package/plugins/reasoning/skills/systems-thinking/frameworks/system-map.md +4 -5
- package/plugins/reasoning/skills/systems-thinking/references/contract.md +6 -0
- package/plugins/reasoning/skills/systems-thinking/references/interview.md +66 -0
- package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +3 -2
- package/plugins/solution-architect/skills/analyze-requirements/references/rewriting.md +108 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/drift.mjs +64 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/drift.mjs +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/git-diff.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/state.mjs +52 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/record.mjs +87 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/drift-cli.test.mjs +178 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/drift.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/git-diff.test.mjs +62 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/record-cli.test.mjs +136 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rerun-safety.test.mjs +53 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rewriting.test.mjs +80 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/state.test.mjs +123 -0
- package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/names-owning-skill.md +0 -9
- package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/states-systemic-design-unavailable.md +0 -15
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { classify, changedSections } from '../lib/drift.mjs';
|
|
4
|
+
import { hashText, sectionHashes } from '../lib/state.mjs';
|
|
5
|
+
|
|
6
|
+
const BODY = '# Doc\n\nbody\n';
|
|
7
|
+
const entryFor = (text) => ({ hash: hashText(text) });
|
|
8
|
+
|
|
9
|
+
// A file the skill has never written is never overwritten and never questioned.
|
|
10
|
+
// This is what makes the first run against a hand-written package safe.
|
|
11
|
+
test('a file with no entry is untracked, never ours', () => {
|
|
12
|
+
assert.equal(classify(undefined, BODY), 'untracked');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// The other half of "no entry": a file this run means to create has no entry
|
|
16
|
+
// either. Calling it untracked would tell the agent never to write it, and no
|
|
17
|
+
// new ADR or companion could ever be added after run 1.
|
|
18
|
+
test('a file with no entry and nothing on disk is new, safe to write', () => {
|
|
19
|
+
assert.equal(classify(undefined, null), 'new');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('a matching hash is unchanged', () => {
|
|
23
|
+
assert.equal(classify(entryFor(BODY), BODY), 'unchanged');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('a differing hash is drifted', () => {
|
|
27
|
+
assert.equal(classify(entryFor(BODY), '# Doc\n\nedited\n'), 'drifted');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Deleting a generated file can be deliberate. Recreating it silently would
|
|
31
|
+
// undo a decision nobody was asked about.
|
|
32
|
+
test('a tracked file missing from disk is reported, not recreated', () => {
|
|
33
|
+
assert.equal(classify(entryFor(BODY), null), 'missing');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// decisions.md already rules: an accepted ADR is superseded, never rewritten.
|
|
37
|
+
// The status in state is what lets a run tell an accepted record from a
|
|
38
|
+
// proposed draft it is free to regenerate.
|
|
39
|
+
test('an accepted ADR is locked whatever its hash says', () => {
|
|
40
|
+
assert.equal(classify({ hash: hashText(BODY), status: 'accepted' }, BODY), 'locked');
|
|
41
|
+
assert.equal(classify({ hash: 'sha256:stale', status: 'accepted' }, BODY), 'locked');
|
|
42
|
+
assert.equal(classify({ hash: 'sha256:stale', status: 'proposed' }, BODY), 'drifted');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// The ordinary way an ADR becomes accepted: we wrote it `proposed`, a person
|
|
46
|
+
// accepted it afterwards. State still says `proposed`, so reading state alone
|
|
47
|
+
// offers "overwrite it" for a record the spec says can only be superseded.
|
|
48
|
+
const ADR = '# ADR 0001: Use Stripe\n\n## Status\n\nAccepted\n\n## Context\n\nc\n';
|
|
49
|
+
|
|
50
|
+
test('an ADR accepted on disk is locked whatever state recorded', () => {
|
|
51
|
+
assert.equal(classify({ hash: hashText(ADR), status: 'proposed' }, ADR), 'locked');
|
|
52
|
+
assert.equal(classify({ hash: 'sha256:stale', status: 'proposed' }, ADR), 'locked');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('a document with no status falls back to the recorded one', () => {
|
|
56
|
+
assert.equal(classify({ hash: 'sha256:stale', status: 'accepted' }, BODY), 'locked');
|
|
57
|
+
assert.equal(classify({ hash: 'sha256:stale', status: 'proposed' }, BODY), 'drifted');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const ARCH = '## 1 Goals and Scope\n\na\n\n## 13 Quality Requirements and SLOs\n\nb\n';
|
|
61
|
+
|
|
62
|
+
test('changed sections are named, ascending', () => {
|
|
63
|
+
const entry = { hash: hashText(ARCH), sections: sectionHashes(ARCH) };
|
|
64
|
+
assert.deepEqual(changedSections(entry, ARCH.replace('\nb\n', '\nedited\n')), ['13']);
|
|
65
|
+
assert.deepEqual(changedSections(entry, ARCH), []);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// A section deleted wholesale is a change the reader most needs to see.
|
|
69
|
+
test('a removed section counts as changed', () => {
|
|
70
|
+
const entry = { hash: hashText(ARCH), sections: sectionHashes(ARCH) };
|
|
71
|
+
assert.deepEqual(changedSections(entry, '## 1 Goals and Scope\n\na\n'), ['13']);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('with no recorded sections every present section reads as changed', () => {
|
|
75
|
+
assert.deepEqual(changedSections({ hash: 'sha256:x' }, ARCH), ['1', '13']);
|
|
76
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { mkdtempSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { gitDiff } from '../lib/git-diff.mjs';
|
|
8
|
+
|
|
9
|
+
function repoWithCommit() {
|
|
10
|
+
const root = mkdtempSync(join(tmpdir(), 'rerun-safety-git-'));
|
|
11
|
+
const run = (...args) => execFileSync('git', args, { cwd: root, stdio: 'ignore' });
|
|
12
|
+
run('init', '-q');
|
|
13
|
+
run('config', 'user.email', 'test@example.com');
|
|
14
|
+
run('config', 'user.name', 'Test');
|
|
15
|
+
writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nbody\n');
|
|
16
|
+
run('add', 'ARCHITECTURE.md');
|
|
17
|
+
run('commit', '-qm', 'seed');
|
|
18
|
+
return root;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test('an uncommitted edit comes back as a diff', () => {
|
|
22
|
+
const root = repoWithCommit();
|
|
23
|
+
writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nedited\n');
|
|
24
|
+
const out = gitDiff({ root, file: 'ARCHITECTURE.md' });
|
|
25
|
+
assert.match(out, /^-body$/m);
|
|
26
|
+
assert.match(out, /^\+edited$/m);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Staging is not a decision about the document. Compared against the index a
|
|
30
|
+
// staged edit reads as clean, so the working tree has to be compared to HEAD.
|
|
31
|
+
test('a staged edit comes back as a diff', () => {
|
|
32
|
+
const root = repoWithCommit();
|
|
33
|
+
writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nedited\n');
|
|
34
|
+
execFileSync('git', ['add', 'ARCHITECTURE.md'], { cwd: root, stdio: 'ignore' });
|
|
35
|
+
const out = gitDiff({ root, file: 'ARCHITECTURE.md' });
|
|
36
|
+
assert.match(out, /^-body$/m);
|
|
37
|
+
assert.match(out, /^\+edited$/m);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// The file is committed, so `git diff` alone reports nothing. Diffing against
|
|
41
|
+
// the commit the state file recorded is what surfaces the change.
|
|
42
|
+
test('a committed edit is found by diffing against the recorded commit', () => {
|
|
43
|
+
const root = repoWithCommit();
|
|
44
|
+
const head = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
|
|
45
|
+
writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nedited\n');
|
|
46
|
+
execFileSync('git', ['commit', '-aqm', 'edit'], { cwd: root, stdio: 'ignore' });
|
|
47
|
+
assert.equal(gitDiff({ root, file: 'ARCHITECTURE.md' }), null);
|
|
48
|
+
assert.match(gitDiff({ root, file: 'ARCHITECTURE.md', since: head }), /^\+edited$/m);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Outside a repo the caller must fall back to section hashes, so this has to
|
|
52
|
+
// return null rather than throw.
|
|
53
|
+
test('no repository yields null, never an exception', () => {
|
|
54
|
+
const root = mkdtempSync(join(tmpdir(), 'rerun-safety-norepo-'));
|
|
55
|
+
writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n');
|
|
56
|
+
assert.equal(gitDiff({ root, file: 'ARCHITECTURE.md' }), null);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('an unchanged file yields null', () => {
|
|
60
|
+
const root = repoWithCommit();
|
|
61
|
+
assert.equal(gitDiff({ root, file: 'ARCHITECTURE.md' }), null);
|
|
62
|
+
});
|
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/record-cli.test.mjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { spawnSync, execFileSync } from 'node:child_process';
|
|
4
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
const BIN = 'plugins/solution-architect/skills/analyze-requirements/scripts';
|
|
9
|
+
const ARCH = `---
|
|
10
|
+
name: atlas
|
|
11
|
+
docVersion: 1.2.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Atlas Architecture
|
|
15
|
+
|
|
16
|
+
## 1 Goals and Scope
|
|
17
|
+
|
|
18
|
+
Assign jobs to drivers.
|
|
19
|
+
|
|
20
|
+
## 13 Quality Requirements and SLOs
|
|
21
|
+
|
|
22
|
+
p99 under 200 ms.
|
|
23
|
+
`;
|
|
24
|
+
const ADR = '# ADR 0001: Use Stripe\n\n## Status\n\nAccepted\n\n## Context\n\nCheckout needs a processor.\n';
|
|
25
|
+
const FILES = ['ARCHITECTURE.md', 'docs/adr/0001-stripe.md'];
|
|
26
|
+
|
|
27
|
+
function run(script, args) {
|
|
28
|
+
const { status, stdout, stderr } = spawnSync('node', [`${BIN}/${script}`, ...args], {
|
|
29
|
+
encoding: 'utf8',
|
|
30
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
31
|
+
});
|
|
32
|
+
return { code: status, stdout, stderr };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// What step 5 leaves on disk: the package, and nothing recorded about it yet.
|
|
36
|
+
function packageDir() {
|
|
37
|
+
const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-record-'));
|
|
38
|
+
mkdirSync(join(dir, 'docs', 'adr'), { recursive: true });
|
|
39
|
+
writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH);
|
|
40
|
+
writeFileSync(join(dir, 'docs', 'adr', '0001-stripe.md'), ADR);
|
|
41
|
+
return dir;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const record = (dir, files = FILES) => run('record.mjs', ['--state', join(dir, 'architecture-state.json'), '--files', ...files]);
|
|
45
|
+
const gate = (dir, files = FILES) => run('drift.mjs', ['--state', join(dir, 'architecture-state.json'), '--files', ...files]);
|
|
46
|
+
const stateOf = (dir) => JSON.parse(readFileSync(join(dir, 'architecture-state.json'), 'utf8'));
|
|
47
|
+
|
|
48
|
+
// The round trip the whole feature rests on: run 1 records, run 2 recognises
|
|
49
|
+
// its own output. Without the writer, run 2 sees no state at all.
|
|
50
|
+
test('a recorded package comes back unchanged', () => {
|
|
51
|
+
const dir = packageDir();
|
|
52
|
+
assert.equal(record(dir).code, 0);
|
|
53
|
+
const { code, stdout } = gate(dir, ['ARCHITECTURE.md']);
|
|
54
|
+
assert.equal(code, 0);
|
|
55
|
+
assert.match(stdout, /ARCHITECTURE\.md\s+unchanged/);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// The bug the branch exists for, with the writing end attached: before this
|
|
59
|
+
// script, run 1 recorded nothing and run 2 cleared the hand edit for overwrite.
|
|
60
|
+
test('recording is what makes a later hand edit report drifted', () => {
|
|
61
|
+
const dir = packageDir();
|
|
62
|
+
record(dir);
|
|
63
|
+
writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH.replace('200 ms', '150 ms'));
|
|
64
|
+
const { code, stdout } = gate(dir, ['ARCHITECTURE.md']);
|
|
65
|
+
assert.equal(code, 2);
|
|
66
|
+
assert.match(stdout, /ARCHITECTURE\.md\s+drifted/);
|
|
67
|
+
assert.match(stdout, /changed: §13/);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('the record carries every field the next run reads', () => {
|
|
71
|
+
const dir = packageDir();
|
|
72
|
+
record(dir);
|
|
73
|
+
const state = stateOf(dir);
|
|
74
|
+
assert.match(state._generated, /do not edit/);
|
|
75
|
+
assert.equal(state.revision, 1);
|
|
76
|
+
assert.match(state.updated, /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/);
|
|
77
|
+
assert.equal(state.docVersion, '1.2.0');
|
|
78
|
+
assert.equal(state.gitCommit, null, 'outside a repository there is no commit');
|
|
79
|
+
assert.deepEqual(Object.keys(state.files), FILES);
|
|
80
|
+
assert.match(state.files['ARCHITECTURE.md'].hash, /^sha256:[0-9a-f]{64}$/);
|
|
81
|
+
assert.deepEqual(Object.keys(state.files['ARCHITECTURE.md'].sections), ['1', '13']);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Only ARCHITECTURE.md has a spine to cut on; an ADR carries a status instead,
|
|
85
|
+
// and that status is what exempts it from being rewritten.
|
|
86
|
+
test('an ADR records the status its document declares', () => {
|
|
87
|
+
const dir = packageDir();
|
|
88
|
+
record(dir);
|
|
89
|
+
const entry = stateOf(dir).files['docs/adr/0001-stripe.md'];
|
|
90
|
+
assert.equal(entry.status, 'accepted');
|
|
91
|
+
assert.equal(entry.sections, undefined);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('each run bumps the revision and keeps earlier files recorded', () => {
|
|
95
|
+
const dir = packageDir();
|
|
96
|
+
record(dir);
|
|
97
|
+
assert.equal(record(dir, ['ARCHITECTURE.md']).code, 0);
|
|
98
|
+
const state = stateOf(dir);
|
|
99
|
+
assert.equal(state.revision, 2);
|
|
100
|
+
assert.deepEqual(Object.keys(state.files), FILES);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('inside a repository the commit is recorded', () => {
|
|
104
|
+
const dir = packageDir();
|
|
105
|
+
const git = (...args) => execFileSync('git', args, { cwd: dir, stdio: 'ignore' });
|
|
106
|
+
git('init', '-q');
|
|
107
|
+
git('config', 'user.email', 'test@example.com');
|
|
108
|
+
git('config', 'user.name', 'Test');
|
|
109
|
+
git('add', 'ARCHITECTURE.md');
|
|
110
|
+
git('commit', '-qm', 'seed');
|
|
111
|
+
record(dir);
|
|
112
|
+
assert.equal(stateOf(dir).gitCommit, execFileSync('git', ['rev-parse', 'HEAD'], { cwd: dir, encoding: 'utf8' }).trim());
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// The one record of what the last run wrote. Renaming over it resets the
|
|
116
|
+
// revision and takes the bytes with it; drift.mjs already refuses to treat a
|
|
117
|
+
// corrupt file as absent-and-forgotten, and the writer is where that rule can
|
|
118
|
+
// be enforced in code rather than prose.
|
|
119
|
+
test('a corrupt state file is refused, not overwritten', () => {
|
|
120
|
+
const dir = packageDir();
|
|
121
|
+
const statePath = join(dir, 'architecture-state.json');
|
|
122
|
+
writeFileSync(statePath, '{ not json');
|
|
123
|
+
const { code, stderr } = record(dir);
|
|
124
|
+
assert.notEqual(code, 0);
|
|
125
|
+
assert.match(stderr, /unreadable/);
|
|
126
|
+
assert.equal(readFileSync(statePath, 'utf8'), '{ not json', 'never deleted');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('recording nothing is a usage error', () => {
|
|
130
|
+
const dir = packageDir();
|
|
131
|
+
for (const argv of [['--files', 'ARCHITECTURE.md'], ['--state', join(dir, 'architecture-state.json')]]) {
|
|
132
|
+
const { code, stderr } = run('record.mjs', argv);
|
|
133
|
+
assert.equal(code, 1, argv.join(' '));
|
|
134
|
+
assert.match(stderr, /^usage:/m);
|
|
135
|
+
}
|
|
136
|
+
});
|
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rerun-safety.test.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { mkdtempSync, writeFileSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { hashText, sectionHashes, writeState } from '../lib/state.mjs';
|
|
8
|
+
|
|
9
|
+
const CLI = 'plugins/solution-architect/skills/analyze-requirements/scripts/drift.mjs';
|
|
10
|
+
|
|
11
|
+
const GENERATED = `## 1 Goals and Scope
|
|
12
|
+
|
|
13
|
+
Assign delivery jobs to drivers. \`stated\`
|
|
14
|
+
|
|
15
|
+
## 7 Runtime Behaviour
|
|
16
|
+
|
|
17
|
+
Job created → row written ready → worker claims it. \`stated\`
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
// The bug, end to end: run 1 writes and records, a person edits §7, run 2 must
|
|
21
|
+
// see it. Before this feature existed, run 2 overwrote it with no diff and no
|
|
22
|
+
// warning, and the edit was unrecoverable unless it had been committed.
|
|
23
|
+
test('a hand edit survives the next run', () => {
|
|
24
|
+
const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-regression-'));
|
|
25
|
+
const arch = join(dir, 'ARCHITECTURE.md');
|
|
26
|
+
const statePath = join(dir, 'architecture-state.json');
|
|
27
|
+
|
|
28
|
+
// Run 1 — the skill writes the package and records what it wrote, last.
|
|
29
|
+
writeFileSync(arch, GENERATED);
|
|
30
|
+
writeState(statePath, {
|
|
31
|
+
revision: 1,
|
|
32
|
+
gitCommit: null,
|
|
33
|
+
files: { 'ARCHITECTURE.md': { hash: hashText(GENERATED), sections: sectionHashes(GENERATED) } },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// A person rewrites §7 by hand.
|
|
37
|
+
const edited = GENERATED.replace('worker claims it', 'worker claims it under a 60 s lease');
|
|
38
|
+
writeFileSync(arch, edited);
|
|
39
|
+
|
|
40
|
+
// Run 2 — the pre-write gate.
|
|
41
|
+
let code = 0;
|
|
42
|
+
let stdout = '';
|
|
43
|
+
try {
|
|
44
|
+
stdout = execFileSync('node', [CLI, '--state', statePath, '--files', 'ARCHITECTURE.md'], { encoding: 'utf8' });
|
|
45
|
+
} catch (err) {
|
|
46
|
+
code = err.status;
|
|
47
|
+
stdout = err.stdout;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
assert.equal(code, 2, 'run 2 must stop rather than write');
|
|
51
|
+
assert.match(stdout, /changed: §7/);
|
|
52
|
+
assert.equal(readFileSync(arch, 'utf8'), edited, 'the edit must still be on disk');
|
|
53
|
+
});
|
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rewriting.test.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
const ref = (f) => readFileSync(new URL(`../../references/${f}`, import.meta.url), 'utf8');
|
|
6
|
+
const skill = () => readFileSync(new URL('../../SKILL.md', import.meta.url), 'utf8');
|
|
7
|
+
|
|
8
|
+
// The guarantee is the ordering: the question is asked before the first write,
|
|
9
|
+
// or not at all. A half-written package waiting on an answer is the failure
|
|
10
|
+
// this whole feature exists to prevent.
|
|
11
|
+
test('the discipline puts the question before the first write', () => {
|
|
12
|
+
const doc = ref('rewriting.md');
|
|
13
|
+
assert.match(doc, /before the first write/i);
|
|
14
|
+
assert.match(doc, /drift\.mjs/, 'the reference must name the script that reports drift');
|
|
15
|
+
assert.match(doc, /written last|write it last/i, 'the state file ordering must be stated');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Nothing writes the state file on its own. Without an instruction naming the
|
|
19
|
+
// tool, run 1 records nothing and run 2 has nothing to compare disk against —
|
|
20
|
+
// the gate reports a first run and the hand edit goes.
|
|
21
|
+
test('the discipline tells the run to record what it wrote', () => {
|
|
22
|
+
const doc = ref('rewriting.md');
|
|
23
|
+
assert.match(doc, /record\.mjs/, 'the reference must name the script that writes the state');
|
|
24
|
+
assert.match(doc, /--files/, 'and say which files go into it');
|
|
25
|
+
assert.match(doc, /"revision"/, 'the state file shape belongs in the reference once');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('the skill runs the recorder at the end of step 5', () => {
|
|
29
|
+
assert.match(skill(), /record\.mjs/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// The first run is the one where `untracked` matters — it is what stops a run
|
|
33
|
+
// pointed at a hand-written package from overwriting it. Prose that makes the
|
|
34
|
+
// gate conditional on a state file existing puts that verdict back out of
|
|
35
|
+
// reach, whatever the code does.
|
|
36
|
+
test('the gate is never conditional on a state file existing', () => {
|
|
37
|
+
const doc = ref('rewriting.md');
|
|
38
|
+
assert.match(doc, /gate[^.]*\bevery run\b/i, 'the reference must say the gate runs every run');
|
|
39
|
+
assert.doesNotMatch(doc, /gate[^.]*after\s+the\s+first/i, 'never "the gate runs after the first run"');
|
|
40
|
+
assert.doesNotMatch(skill(), /after\s+the\s+first[^.]*drift\.mjs|drift\.mjs[^.]*after\s+the\s+first/i);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// The hard rules are what an agent reads first and leans on hardest, so an
|
|
44
|
+
// unqualified "no entry means not ours" there outranks the verdict table: no
|
|
45
|
+
// ADR or companion could ever be created after run 1. Only a file that is
|
|
46
|
+
// actually on disk is someone else's.
|
|
47
|
+
test('the hard rule does not forbid creating a file that does not exist', () => {
|
|
48
|
+
const rule = skill().split('\n').find((l) => /^5\. /.test(l) && l.includes('architecture-state.json'));
|
|
49
|
+
assert.ok(rule, 'hard rule 5 must still be the one about the state file');
|
|
50
|
+
assert.doesNotMatch(rule, /a file with no entry[^;]*is not ours/i, 'no entry alone does not mean not ours');
|
|
51
|
+
assert.match(rule, /creat/i, 'the rule must leave room to create a file that does not exist yet');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// A hash cannot identify an author, and a message that claims it can is a lie
|
|
55
|
+
// the reader will believe.
|
|
56
|
+
test('the discipline never claims to know who edited a file', () => {
|
|
57
|
+
const doc = ref('rewriting.md');
|
|
58
|
+
assert.match(doc, /changed since|not.*who/i);
|
|
59
|
+
assert.doesNotMatch(doc, /you edited|the user edited/i);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Every verdict the gate can print needs a row, or the agent meets one with no
|
|
63
|
+
// instruction. `new` is the one that lets run 2 add a document at all.
|
|
64
|
+
test('the verdict table covers a file that does not exist yet', () => {
|
|
65
|
+
assert.match(ref('rewriting.md'), /\|\s*`new`\s*\|/);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('an accepted ADR is named as exempt', () => {
|
|
69
|
+
const doc = ref('rewriting.md');
|
|
70
|
+
assert.match(doc, /accepted/);
|
|
71
|
+
assert.match(doc, /supersed/i);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('the skill runs the gate before writing', () => {
|
|
75
|
+
assert.match(skill(), /drift\.mjs/, 'SKILL.md must call the gate in its flow');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('the reference stays inside the file-length limit', () => {
|
|
79
|
+
assert.ok(ref('rewriting.md').split('\n').length <= 200);
|
|
80
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { normalise, hashText, sectionHashes, readState, writeState } from '../lib/state.mjs';
|
|
4
|
+
import { mkdtempSync, writeFileSync, readFileSync, existsSync, readdirSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
// Line endings, trailing spaces and how many newlines a file ends with are
|
|
9
|
+
// editor artefacts. If they changed the hash, every run would report drift on
|
|
10
|
+
// files nobody touched, and people would learn to answer "overwrite" without
|
|
11
|
+
// reading — which is worse than having no guard at all.
|
|
12
|
+
test('editor artefacts hash the same', () => {
|
|
13
|
+
const base = '# Title\n\nbody\n';
|
|
14
|
+
for (const variant of ['# Title\r\n\r\nbody\r\n', '# Title\n\nbody \n', '# Title\n\nbody\n\n\n']) {
|
|
15
|
+
assert.equal(hashText(variant), hashText(base), JSON.stringify(variant));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// The other half of the same rule: normalisation must not be so eager that a
|
|
20
|
+
// real edit hashes as unchanged. That is the failure that loses data silently.
|
|
21
|
+
test('a real edit hashes differently', () => {
|
|
22
|
+
assert.notEqual(hashText('# Title\n\nbody\n'), hashText('# Title\n\nBody\n'));
|
|
23
|
+
assert.notEqual(hashText('| a | b |\n'), hashText('| a | b |\n'));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('normalise leaves exactly one trailing newline', () => {
|
|
27
|
+
assert.equal(normalise('a'), 'a\n');
|
|
28
|
+
assert.equal(normalise('a\n\n\n'), 'a\n');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('a hash is labelled with its algorithm', () => {
|
|
32
|
+
assert.match(hashText('x'), /^sha256:[0-9a-f]{64}$/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const ARCH = `---
|
|
36
|
+
name: atlas
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
# Atlas Architecture
|
|
40
|
+
|
|
41
|
+
## 1 Goals and Scope
|
|
42
|
+
|
|
43
|
+
Assign jobs to drivers.
|
|
44
|
+
|
|
45
|
+
## 13 Quality Requirements and SLOs
|
|
46
|
+
|
|
47
|
+
| scenario | measure | target | priority | src |
|
|
48
|
+
|---|---|---|---|---|
|
|
49
|
+
| peak checkout | p99 | 200 ms | must | stated |
|
|
50
|
+
|
|
51
|
+
## 16 Glossary
|
|
52
|
+
|
|
53
|
+
| term | meaning | src |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| job | one delivery | stated |
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
test('sections are keyed by their spine number', () => {
|
|
59
|
+
assert.deepEqual(Object.keys(sectionHashes(ARCH)), ['1', '13', '16']);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// The point of hashing per section: editing one must not move the others, or
|
|
63
|
+
// the fallback report names every section and tells the reader nothing.
|
|
64
|
+
test('editing one section moves only that section', () => {
|
|
65
|
+
const before = sectionHashes(ARCH);
|
|
66
|
+
const after = sectionHashes(ARCH.replace('200 ms', '150 ms'));
|
|
67
|
+
assert.equal(after['1'], before['1']);
|
|
68
|
+
assert.equal(after['16'], before['16']);
|
|
69
|
+
assert.notEqual(after['13'], before['13']);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Frontmatter and the H1 belong to no section. Folding them into section 1
|
|
73
|
+
// would report a driver change every time the document version is bumped.
|
|
74
|
+
test('content before the first numbered heading is in no section', () => {
|
|
75
|
+
const after = sectionHashes(ARCH.replace('name: atlas', 'name: atlas-2'));
|
|
76
|
+
assert.deepEqual(after, sectionHashes(ARCH));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const tmp = () => mkdtempSync(join(tmpdir(), 'rerun-safety-'));
|
|
80
|
+
|
|
81
|
+
test('state survives a round trip', () => {
|
|
82
|
+
const path = join(tmp(), 'architecture-state.json');
|
|
83
|
+
const state = { revision: 2, files: { 'ARCHITECTURE.md': { hash: 'sha256:aa' } } };
|
|
84
|
+
writeState(path, state);
|
|
85
|
+
assert.deepEqual(readState(path).state, state);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('an absent state file is not an error', () => {
|
|
89
|
+
assert.deepEqual(readState(join(tmp(), 'nope.json')), { state: null });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// A corrupt state file is the one case where deleting would be convenient and
|
|
93
|
+
// wrong: it is the only record of what the last run wrote.
|
|
94
|
+
test('a corrupt state file reads as absent, is reported, and is left alone', () => {
|
|
95
|
+
const path = join(tmp(), 'architecture-state.json');
|
|
96
|
+
writeFileSync(path, '{ not json');
|
|
97
|
+
const result = readState(path);
|
|
98
|
+
assert.equal(result.state, null);
|
|
99
|
+
assert.match(result.error, /unreadable/);
|
|
100
|
+
assert.equal(readFileSync(path, 'utf8'), '{ not json');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Written last and atomically: a crash must leave the previous revision intact
|
|
104
|
+
// rather than a half-written file that the next run would trust.
|
|
105
|
+
test('writing leaves no temp file behind', () => {
|
|
106
|
+
const dir = tmp();
|
|
107
|
+
const path = join(dir, 'architecture-state.json');
|
|
108
|
+
writeState(path, { revision: 1, files: {} });
|
|
109
|
+
assert.deepEqual(readdirSync(dir), ['architecture-state.json']);
|
|
110
|
+
assert.equal(existsSync(`${path}.tmp`), false);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// The crash case itself. A write that dies partway must leave revision 1
|
|
114
|
+
// readable — that is what lets the next run treat the half-written documents
|
|
115
|
+
// as drifted and ask about them, instead of trusting them.
|
|
116
|
+
test('a failed write leaves the previous revision intact', () => {
|
|
117
|
+
const path = join(tmp(), 'architecture-state.json');
|
|
118
|
+
writeState(path, { revision: 1, files: {} });
|
|
119
|
+
const circular = { revision: 2 };
|
|
120
|
+
circular.self = circular;
|
|
121
|
+
assert.throws(() => writeState(path, circular));
|
|
122
|
+
assert.equal(readState(path).state.revision, 1);
|
|
123
|
+
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: llm
|
|
3
|
-
weight: 1
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
PASS if the response states that `systemic-design` is not available in this
|
|
7
|
-
release, while treating `systems-thinking` as runnable now.
|
|
8
|
-
|
|
9
|
-
Accept any unavailability wording applied to `systemic-design`, in any tense
|
|
10
|
-
and with or without "yet": "not built", "not available", "does not exist",
|
|
11
|
-
"ships in a later release", or equivalent plain English.
|
|
12
|
-
|
|
13
|
-
FAIL if the response claims `systems-thinking` is also unavailable, or is
|
|
14
|
-
silent on `systemic-design`'s availability, or recommends `systemic-design`
|
|
15
|
-
as though it were runnable now.
|