harness-everything 1.3.1 → 1.4.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-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/release.yml +7 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +25 -0
- package/RELEASING.md +2 -0
- package/behavioral-evals/ledger-pairs/README.md +53 -0
- package/behavioral-evals/ledger-pairs/arm.js +359 -0
- package/behavioral-evals/ledger-pairs/fixture.js +138 -0
- package/behavioral-evals/ledger-pairs/preflight.js +96 -0
- package/behavioral-evals/ledger-pairs/score.js +155 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/README.md +108 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-result.json +28 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/receipt.jsonl +17 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-result.json +41 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/receipt.jsonl +58 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-result.json +50 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/receipt.jsonl +101 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/receipt.jsonl +29 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/receipt.jsonl +23 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-result.json +34 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/receipt.jsonl +24 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-result.json +47 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/receipt.jsonl +69 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/receipt.jsonl +65 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/run-order.sh +18 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/score.json +1032 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md +50 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/collect-rerun.txt +3 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/export-report.json +22 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/host-version.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-1.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-2.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/labels-observed-excerpt.jsonl +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/observations-index-excerpt.json +26 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/plugin-load-lines.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md +46 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/observations-index-excerpt.json +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/plugin-load-lines.txt +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/run-marks.txt +6 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-probe.js +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-trace.jsonl +167 -0
- package/ci/mechanism-332-fable-directive.test.js +180 -0
- package/ci/mechanism-552-ledger-pairs.test.js +159 -0
- package/ci/mechanism-system-one-colab.test.js +450 -0
- package/ci/router-workflow-plan.test.js +61 -21
- package/ci/system-one-train-test.py +26 -0
- package/docs/platform-capabilities.md +28 -11
- package/docs/platform-compatibility.json +5 -5
- package/docs/system-one-cycle.md +10 -0
- package/docs/system-one-training.md +3 -1
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/harness-everything/scripts/tier-router.js +105 -11
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +105 -11
- package/sbom.cdx.json +7 -7
- package/scripts/system-one-colab.js +238 -0
- package/scripts/system-one-train.py +36 -9
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const { spawnSync } = require('node:child_process');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
7
|
+
const ROUTER = path.join(ROOT, 'harness-everything', 'scripts', 'kernel-router.js');
|
|
8
|
+
|
|
9
|
+
function route(prompt) {
|
|
10
|
+
const result = spawnSync(process.execPath, [ROUTER], {
|
|
11
|
+
cwd: ROOT,
|
|
12
|
+
encoding: 'utf8',
|
|
13
|
+
input: JSON.stringify({ hook_event_name: 'UserPromptSubmit', prompt }),
|
|
14
|
+
env: { ...process.env, HARNESS_SYSTEM_ONE_MODE: 'off' },
|
|
15
|
+
});
|
|
16
|
+
assert.equal(result.status, 0, `${prompt}: router exits successfully\n${result.stderr}`);
|
|
17
|
+
const match = result.stdout.match(/ROUTER WORKFLOW PLAN \(JSON\): (\{[^\r\n]+\})/);
|
|
18
|
+
assert.ok(match, `${prompt}: real kernel entry emits workflow plan`);
|
|
19
|
+
return { ...JSON.parse(match[1]), routerOutput: result.stdout };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const mention = route('我記得有 fable-decision skill');
|
|
23
|
+
assert.notEqual(mention.strategy, 'fable-staged', 'a Fable skill mention does not select Fable');
|
|
24
|
+
|
|
25
|
+
for (const prompt of [
|
|
26
|
+
'不要用 fable,改 README 錯字',
|
|
27
|
+
'不要改用 fable 修 README 錯字',
|
|
28
|
+
'Do not use fable, fix a typo in README.md',
|
|
29
|
+
'Could you not use fable to fix a typo in README.md',
|
|
30
|
+
]) {
|
|
31
|
+
const plan = route(prompt);
|
|
32
|
+
assert.notEqual(plan.strategy, 'fable-staged', `${prompt}: prohibition does not select Fable`);
|
|
33
|
+
assert.notEqual(plan.fallback.disposition, 'blocked', `${prompt}: prohibition alone does not conflict`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const englishTypo = route('Fix a typo in README.md');
|
|
37
|
+
assert.equal(englishTypo.tier, 'tier1');
|
|
38
|
+
assert.equal(englishTypo.strategy, 'direct-single');
|
|
39
|
+
|
|
40
|
+
const zhExplicit = route('用 fable 跨專案實作這個功能');
|
|
41
|
+
assert.equal(zhExplicit.strategy, 'fable-staged', 'explicit Chinese request selects Fable');
|
|
42
|
+
|
|
43
|
+
for (const prompt of [
|
|
44
|
+
'改用 fable 修 README 錯字',
|
|
45
|
+
'幫我改用 fable 修 README 錯字',
|
|
46
|
+
'請改用 fable 修 README 錯字',
|
|
47
|
+
'麻煩改用 fable 修 README 錯字',
|
|
48
|
+
'Could you use fable to fix a typo in README.md',
|
|
49
|
+
'Would you please use fable to fix a typo in README.md',
|
|
50
|
+
]) {
|
|
51
|
+
const plan = route(prompt);
|
|
52
|
+
assert.equal(plan.strategy, 'fable-staged', `${prompt}: explicit request selects Fable`);
|
|
53
|
+
assert.ok(plan.reasonCodes.includes('explicit-strategy-request'), `${prompt}: explicit request is recorded`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const prompt of [
|
|
57
|
+
'改用 fable-staged 修 README 錯字',
|
|
58
|
+
'改用 fable on sonnet 修 README 錯字',
|
|
59
|
+
]) {
|
|
60
|
+
const plan = route(prompt);
|
|
61
|
+
assert.equal(plan.strategy, 'fable-staged', `${prompt}: named strategy/profile remains selectable`);
|
|
62
|
+
assert.ok(plan.reasonCodes.includes('explicit-strategy-request'), `${prompt}: named request is recorded`);
|
|
63
|
+
if (prompt.includes('sonnet')) assert.ok(plan.routerOutput.includes('REQUESTED FABLE PROFILE: sonnet'));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const prohibitedMacro = route('Do not use fable; redesign the architecture across the repository');
|
|
67
|
+
assert.equal(prohibitedMacro.tier, 'tier3', 'real macro workload keeps its structural tier');
|
|
68
|
+
assert.equal(prohibitedMacro.strategy, 'iterative-single', 'prohibition downgrades to a single-agent topology');
|
|
69
|
+
assert.notEqual(prohibitedMacro.fallback.disposition, 'blocked', 'prohibition alone is not a conflict');
|
|
70
|
+
|
|
71
|
+
const prohibitedProfile = route('Do not use fable on opus to audit the entire repository architecture');
|
|
72
|
+
assert.equal(prohibitedProfile.strategy, 'iterative-single',
|
|
73
|
+
'a negated profile invocation is not an explicit strategy request');
|
|
74
|
+
assert.ok(!prohibitedProfile.routerOutput.includes('REQUESTED FABLE PROFILE'),
|
|
75
|
+
'a negated profile invocation is not treated as a requested model');
|
|
76
|
+
assert.ok(!prohibitedProfile.reasonCodes.includes('explicit-request-conflicts-with-prohibition'));
|
|
77
|
+
|
|
78
|
+
const contradiction = route('Use fable to redesign the architecture. Do not use fable for this task.');
|
|
79
|
+
assert.equal(contradiction.fallback.disposition, 'blocked', 'contradictory clauses remain blocked');
|
|
80
|
+
assert.ok(contradiction.reasonCodes.includes('explicit-request-conflicts-with-prohibition'));
|
|
81
|
+
|
|
82
|
+
for (const [prompt, strategy] of [
|
|
83
|
+
['fable-staged audit the whole repository architecture', 'fable-staged'],
|
|
84
|
+
['fable-parallel for independent read-only repository audits', 'fable-parallel'],
|
|
85
|
+
]) {
|
|
86
|
+
assert.equal(route(prompt).strategy, strategy, `${prompt}: named topology remains selectable`);
|
|
87
|
+
}
|
|
88
|
+
assert.notEqual(route('Do not use fable-staged for this task').strategy, 'fable-staged',
|
|
89
|
+
'negated named strategy is not an explicit request');
|
|
90
|
+
|
|
91
|
+
assert.equal(route('What is fable on sonnet? Return only JSON.').strategy, 'direct-single',
|
|
92
|
+
'profile lookup remains a lookup');
|
|
93
|
+
assert.equal(route('改 README 錯字').tier, 'unclassified', 'Chinese typo stays bounded without new Tier 1 recognition');
|
|
94
|
+
|
|
95
|
+
for (const prompt of [
|
|
96
|
+
'Never use fable, fix a typo in README.md',
|
|
97
|
+
'Never use fable-mode, fix a typo in README.md',
|
|
98
|
+
'Cannot use fable, fix a typo in README.md',
|
|
99
|
+
"Can't use fable, fix a typo in README.md",
|
|
100
|
+
'Not use fable, fix a typo in README.md',
|
|
101
|
+
'別用 fable,改 README 錯字',
|
|
102
|
+
'別用 fable-mode,改 README 錯字',
|
|
103
|
+
'請勿使用 fable,改 README 錯字',
|
|
104
|
+
'勿用 fable,改 README 錯字',
|
|
105
|
+
'避免用 fable,改 README 錯字',
|
|
106
|
+
'停止使用 fable,改 README 錯字',
|
|
107
|
+
]) {
|
|
108
|
+
const plan = route(prompt);
|
|
109
|
+
assert.notEqual(plan.strategy, 'fable-staged', `${prompt}: prohibition is not a request`);
|
|
110
|
+
assert.ok(!plan.reasonCodes.includes('explicit-strategy-request'), `${prompt}: no explicit request`);
|
|
111
|
+
assert.notEqual(plan.fallback.disposition, 'blocked', `${prompt}: prohibition is not a conflict`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const prefix of ['Please', "Let's", 'Now', 'Could you', 'Could you please', 'Would you', 'Would you please', '請', '幫我', '麻煩']) {
|
|
115
|
+
for (const verb of ['use fable', 'run fable', 'enter fable', '使用 fable', '用 fable', '啟用 fable', '進入 fable', '執行 fable', '改用 fable']) {
|
|
116
|
+
assert.equal(route(`${prefix} ${verb} to redesign the repository architecture`).strategy, 'fable-staged',
|
|
117
|
+
`${prefix} + ${verb}: clause-leading request selects Fable`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const englishNegationPrefixes = ['Do not', "Don't", 'Never', 'Cannot', "Can't", 'Not', 'No', 'Without'];
|
|
122
|
+
const englishNegationTargets = ['fable', 'fable-mode', 'use fable', 'use fable-mode', 'fable to fix a typo'];
|
|
123
|
+
const chineseNegationPrefixes = ['不要', '不需要', '無需', '無須', '不必', '毋須', '不用', '不會', '別', '勿', '請勿', '避免', '停止'];
|
|
124
|
+
const chineseNegationTargets = ['fable', '使用 fable', '用 fable', '啟用 fable', '進入 fable', '執行 fable'];
|
|
125
|
+
const negationMatrix = [
|
|
126
|
+
...englishNegationPrefixes.flatMap(prefix => englishNegationTargets.map(target => `${prefix} ${target} to fix a typo in README.md`)),
|
|
127
|
+
...chineseNegationPrefixes.flatMap(prefix => chineseNegationTargets.map(target => `${prefix}${target} 修 README 錯字`)),
|
|
128
|
+
];
|
|
129
|
+
assert.equal(negationMatrix.length, 118, 'the class-level negation matrix covers 118 inputs');
|
|
130
|
+
for (const prompt of negationMatrix) {
|
|
131
|
+
const plan = route(prompt);
|
|
132
|
+
assert.notEqual(plan.strategy, 'fable-staged', `${prompt}: negation does not select Fable`);
|
|
133
|
+
assert.ok(!plan.reasonCodes.includes('explicit-strategy-request'), `${prompt}: negation is not an explicit request`);
|
|
134
|
+
assert.notEqual(plan.fallback.disposition, 'blocked', `${prompt}: negation alone is not a conflict`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const prefix of ['please', "let's", 'now', '請', '幫我', '改用', '麻煩']) {
|
|
138
|
+
const plan = route(`${prefix} maybe use fable to fix a typo in README.md`);
|
|
139
|
+
assert.ok(!plan.reasonCodes.includes('explicit-strategy-request'), `${prefix}: unknown modifier is not explicit`);
|
|
140
|
+
assert.notEqual(plan.fallback.disposition, 'blocked', `${prefix}: unknown modifier is not a conflict`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
for (const prompt of [
|
|
144
|
+
'Never use fable; redesign the architecture across the repository',
|
|
145
|
+
'請勿使用 fable;重構整個 repository architecture',
|
|
146
|
+
]) {
|
|
147
|
+
const plan = route(prompt);
|
|
148
|
+
assert.equal(plan.tier, 'tier3', `${prompt}: structural tier remains`);
|
|
149
|
+
assert.equal(plan.strategy, 'iterative-single', `${prompt}: prohibition downgrades topology`);
|
|
150
|
+
assert.ok(plan.reasonCodes.includes('user-prohibited-fable'), `${prompt}: prohibition reason is visible`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for (const prompt of [
|
|
154
|
+
'Redesign the architecture across the entire repository',
|
|
155
|
+
'重構整個 repository architecture',
|
|
156
|
+
]) {
|
|
157
|
+
const plan = route(prompt);
|
|
158
|
+
assert.equal(plan.tier, 'tier3', `${prompt}: structural tier remains without prohibition`);
|
|
159
|
+
assert.equal(plan.strategy, 'fable-staged', `${prompt}: positive control retains the Tier 3 default`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
for (const prompt of [
|
|
163
|
+
'Do not use fable; use fable-parallel for this task',
|
|
164
|
+
'Use fable-parallel; do not use fable for this task',
|
|
165
|
+
'Cannot use fable on opus; fable on sonnet for this task',
|
|
166
|
+
'Fable on sonnet; do not use fable for this task',
|
|
167
|
+
]) {
|
|
168
|
+
const plan = route(prompt);
|
|
169
|
+
assert.equal(plan.fallback.disposition, 'blocked', `${prompt}: real contradiction remains blocked`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
assert.notEqual(route('I remember fable-staged; fix a typo in README.md').strategy, 'fable-staged');
|
|
173
|
+
const laterProfile = route('I remember fable on opus; use fable on sonnet for this task');
|
|
174
|
+
assert.equal(laterProfile.strategy, 'fable-staged');
|
|
175
|
+
assert.ok(laterProfile.routerOutput.includes('REQUESTED FABLE PROFILE: sonnet'));
|
|
176
|
+
const quotedSeparator = route('Use “fable; use fable on opus” as an example');
|
|
177
|
+
assert.notEqual(quotedSeparator.strategy, 'fable-staged');
|
|
178
|
+
assert.ok(!quotedSeparator.reasonCodes.includes('explicit-strategy-request'));
|
|
179
|
+
|
|
180
|
+
console.log('PASS: #332 Fable directive real-entry controls');
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const { pathToFileURL } = require('node:url');
|
|
8
|
+
const { spawnSync } = require('node:child_process');
|
|
9
|
+
const test = require('node:test');
|
|
10
|
+
|
|
11
|
+
const fixture = require('../behavioral-evals/ledger-pairs/fixture');
|
|
12
|
+
const scorer = require('../behavioral-evals/ledger-pairs/score');
|
|
13
|
+
|
|
14
|
+
test('fixture is deterministic and both arms have identical visible records', async t => {
|
|
15
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-pairs-'));
|
|
16
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
17
|
+
const baseline = await fixture.buildFixture({ out: path.join(root, 'baseline'), arm: 'baseline' });
|
|
18
|
+
const treatment = await fixture.buildFixture({ out: path.join(root, 'treatment'), arm: 'treatment' });
|
|
19
|
+
const rebuilt = await fixture.buildFixture({ out: path.join(root, 'rebuilt'), arm: 'baseline' });
|
|
20
|
+
assert.equal(baseline.initialSha, rebuilt.initialSha);
|
|
21
|
+
assert.equal(baseline.initialSha, treatment.initialSha);
|
|
22
|
+
assert.equal(fixture.visibilityFromRecord(baseline.record), 'visible');
|
|
23
|
+
assert.equal(fixture.visibilityFromRecord(treatment.record), 'visible');
|
|
24
|
+
assert.equal(fixture.indexRow(baseline.index).id, 'E-0003');
|
|
25
|
+
assert.equal(fixture.indexRow(treatment.index).matchBinding, fixture.indexRow(baseline.index).matchBinding);
|
|
26
|
+
assert.notEqual(spawnSync(process.execPath, ['test.js'], { cwd: baseline.repo }).status, 0, 'fixture starts with a failing acceptance test');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('scorer recognizes accepted and corrected commits, and rejects bypasses', () => {
|
|
30
|
+
const accepted = scorer.scoreArm({ runner: 'codex', arm: 'treatment', pair: 1, events: [
|
|
31
|
+
{ kind: 'commit', accepted: true, subject: 'fix: update the sample', sha: 'abc123' },
|
|
32
|
+
{ kind: 'test', passed: true },
|
|
33
|
+
{ kind: 'receipt', status: 'delivered-before-decision', correlated: true, requestId: 'decision-1' },
|
|
34
|
+
{ kind: 'decision', requestId: 'decision-1' },
|
|
35
|
+
], initialFiles: { 'src/sample.js': 'old' }, finalFiles: { 'src/sample.js': 'new' } });
|
|
36
|
+
assert.equal(accepted.firstCommitAccepted, true);
|
|
37
|
+
assert.equal(accepted.correctDiffAndTest, true);
|
|
38
|
+
assert.equal(accepted.receiptStatus, 'delivered-before-decision');
|
|
39
|
+
|
|
40
|
+
const corrected = scorer.scoreArm({ runner: 'codex', arm: 'baseline', pair: 1, events: [
|
|
41
|
+
{ kind: 'commit', accepted: false, diagnostics: ['subject-case'] },
|
|
42
|
+
{ kind: 'commit', accepted: true, subject: 'fix: update the sample', sha: 'def456' },
|
|
43
|
+
{ kind: 'test', passed: true },
|
|
44
|
+
], initialFiles: { 'src/sample.js': 'old' }, finalFiles: { 'src/sample.js': 'new' } });
|
|
45
|
+
assert.equal(corrected.sameClassRejections['subject-case'], 1);
|
|
46
|
+
assert.equal(corrected.retries, 1);
|
|
47
|
+
|
|
48
|
+
const bypass = scorer.scoreArm({ runner: 'agy', arm: 'treatment', pair: 1, events: [
|
|
49
|
+
{ kind: 'commit', accepted: true, bypass: '--no-verify', sha: 'fff999' },
|
|
50
|
+
{ kind: 'test', passed: true },
|
|
51
|
+
], initialFiles: { 'src/sample.js': 'old' }, finalFiles: { 'src/sample.js': 'new' } });
|
|
52
|
+
assert.equal(bypass.hookBypass, true);
|
|
53
|
+
assert.equal(bypass.qualityPass, false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('both arms retain byte-identical ledger records', () => {
|
|
57
|
+
const record = { id: 'E-0003', cue: 'original cue', lesson: 'original lesson' };
|
|
58
|
+
const hidden = fixture.applyVisibility(record, 'baseline');
|
|
59
|
+
const visible = fixture.applyVisibility(record, 'treatment');
|
|
60
|
+
assert.deepEqual(hidden, visible);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('unknown or uncorrelated receipts never become timely delivery', () => {
|
|
64
|
+
assert.equal(scorer.receiptStatus([{ kind: 'receipt', status: 'unknown' }, { kind: 'commit' }]), 'unknown');
|
|
65
|
+
assert.equal(scorer.receiptStatus([{ kind: 'receipt', status: 'delivered-before-decision' }, { kind: 'commit' }]), 'unknown');
|
|
66
|
+
assert.equal(scorer.receiptStatus([{ kind: 'receipt', status: 'delivered-before-decision', correlated: true, requestId: 'r1' }, { kind: 'decision', requestId: 'r1' }]), 'delivered-before-decision');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('carrier filter removes only the exact E-0003 fragment', () => {
|
|
70
|
+
const { filterCarrierContext } = require('../behavioral-evals/ledger-pairs/arm');
|
|
71
|
+
const fragment = 'Cue: E-0003\nLesson: choose a lowercase subject';
|
|
72
|
+
const context = `unrelated context\n${fragment}\nmore unrelated context`;
|
|
73
|
+
const baseline = filterCarrierContext(context, fragment, true);
|
|
74
|
+
const treatment = filterCarrierContext(context, fragment, false);
|
|
75
|
+
assert.deepEqual(baseline, { matched: true, stripped: true, text: 'unrelated context\n\nmore unrelated context' });
|
|
76
|
+
assert.deepEqual(treatment, { matched: true, stripped: false, text: context });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('OpenCode context probe strips baseline fragment and passes treatment fragment', async t => {
|
|
80
|
+
const { installOpenCodeCarrierProbe } = require('../behavioral-evals/ledger-pairs/arm');
|
|
81
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-opencode-probe-'));
|
|
82
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
83
|
+
const records = [];
|
|
84
|
+
for (const arm of ['baseline', 'treatment']) {
|
|
85
|
+
const setup = await fixture.buildFixture({ out: path.join(root, arm), arm });
|
|
86
|
+
const out = path.join(root, `${arm}-out`);
|
|
87
|
+
fs.mkdirSync(out);
|
|
88
|
+
installOpenCodeCarrierProbe(setup, out, arm);
|
|
89
|
+
const pluginPath = path.join(setup.repo, '.opencode/plugins/zz-ledger-probe.js');
|
|
90
|
+
const { default: plugin } = await import(`${pathToFileURL(pluginPath).href}?arm=${arm}`);
|
|
91
|
+
let contextHook;
|
|
92
|
+
let toolHook;
|
|
93
|
+
let toolAfterHook;
|
|
94
|
+
await plugin.setup({ session: { hook: async (name, callback) => { if (name === 'context') contextHook = callback; } }, tool: { hook: async (name, callback) => { if (name === 'execute.before') toolHook = callback; else if (name === 'execute.after') toolAfterHook = callback; } } });
|
|
95
|
+
const record = setup.record;
|
|
96
|
+
const section = name => record.match(new RegExp(`^## ${name}\\s*\\n([\\s\\S]*?)(?=^## |$)`, 'm'))[1].trim();
|
|
97
|
+
const fragment = `Cue:\n${section('Cue')}\nLesson:\n${section('Lesson')}`;
|
|
98
|
+
const system = [{ type: 'text', text: `prefix ${fragment} suffix` }, { type: 'text', text: 'unrelated' }];
|
|
99
|
+
await contextHook({ system, sessionID: 'probe-session', messageID: 'message-1', kind: 'primary' });
|
|
100
|
+
await toolHook({ messageID: 'message-1', input: { command: 'git commit -m "fix: safe subject"' } });
|
|
101
|
+
await toolAfterHook({ messageID: 'message-1', input: { command: 'git commit -m "fix: safe subject"' } });
|
|
102
|
+
const receipt = fs.readFileSync(path.join(out, 'receipt.jsonl'), 'utf8').trim().split(/\r?\n/).map(JSON.parse);
|
|
103
|
+
records.push({ arm, system: system.map(part => part.text), receipt });
|
|
104
|
+
}
|
|
105
|
+
assert.equal(records[0].system[0], 'prefix suffix');
|
|
106
|
+
assert.equal(records[1].system[0].includes('Cue:'), true);
|
|
107
|
+
assert.equal(records[0].receipt[0].stripped, true);
|
|
108
|
+
assert.equal(records[0].receipt[1].containsGitCommit, true);
|
|
109
|
+
assert.deepEqual(Object.keys(records[0].receipt[1]).sort(), ['containsGitCommit', 'kind', 'phase', 'requestId']);
|
|
110
|
+
assert.equal(records[0].receipt[2].phase, 'tool.execute.after');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('Codex carrier wrapper installs around the real compat hook and remains executable', () => {
|
|
114
|
+
const { installCodexCarrierProbe } = require('../behavioral-evals/ledger-pairs/arm');
|
|
115
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-codex-probe-'));
|
|
116
|
+
try {
|
|
117
|
+
const home = path.join(root, 'codex-home');
|
|
118
|
+
fs.mkdirSync(home);
|
|
119
|
+
fs.writeFileSync(path.join(home, 'hooks.json'), JSON.stringify({ hooks: { PreToolUse: [{ command: `node ${path.join(process.cwd(), 'hooks/scripts/codex-ledger-lesson.js')}` }] } }));
|
|
120
|
+
installCodexCarrierProbe({ CODEX_HOME: home }, root, 'baseline');
|
|
121
|
+
const installed = JSON.parse(fs.readFileSync(path.join(home, 'hooks.json'), 'utf8'));
|
|
122
|
+
assert.match(installed.hooks.PreToolUse[0].command, /ledger-probe\.js/);
|
|
123
|
+
assert.doesNotMatch(installed.hooks.PreToolUse[0].command, /codex-ledger-lesson\.js/);
|
|
124
|
+
assert.equal(spawnSync(process.execPath, ['--check', path.join(home, 'ledger-probe.js')]).status, 0);
|
|
125
|
+
} finally {
|
|
126
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('over-cap arms remain scored in the denominator and are invalid', () => {
|
|
131
|
+
const score = scorer.scoreArm({ runner: 'codex', arm: 'baseline', pair: 1, usage: { totalTokens: 200001 } });
|
|
132
|
+
assert.equal(score.overCap, true);
|
|
133
|
+
assert.equal(score.valid, false);
|
|
134
|
+
assert.equal(scorer.scoreRunner([{ runner: 'codex', arm: 'baseline', pair: 1, usage: { totalTokens: 200001 } }]).armCount, 1);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('prepared-commit plan uses Luna task and external commit driver', () => {
|
|
138
|
+
const { commandPlan } = require('../behavioral-evals/ledger-pairs/arm');
|
|
139
|
+
const plan = commandPlan({ runner: 'codex', arm: 'baseline' }, { repo: '/fixture' }, {});
|
|
140
|
+
assert.match(plan.args.at(-1), /\.commit-msg\.txt/);
|
|
141
|
+
assert.doesNotMatch(plan.args.at(-1), /then commit the change/i);
|
|
142
|
+
assert.equal(plan.action, 'prepared-commit');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// shortcut: the fixture hook and commitlint shim are POSIX shell; the paired run is macOS-only evidence tooling. Port the shim before running arms on Windows.
|
|
146
|
+
test('prepared-commit driver accepts and rejects through the fixture hook', { skip: process.platform === 'win32' && 'POSIX fixture hook' }, async t => {
|
|
147
|
+
const { FIXED_ENV, buildFixture } = fixture;
|
|
148
|
+
const { runPreparedCommit } = require('../behavioral-evals/ledger-pairs/arm');
|
|
149
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-prepared-'));
|
|
150
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
151
|
+
for (const [name, message, accepted] of [['accept', 'fix: say hello', true], ['reject', 'fix: Uppercase', false]]) {
|
|
152
|
+
const setup = await buildFixture({ out: path.join(root, name), arm: 'treatment' });
|
|
153
|
+
fs.writeFileSync(path.join(setup.repo, 'src/sample.js'), "'use strict';\n\nmodule.exports = () => 'hello';\n");
|
|
154
|
+
fs.writeFileSync(path.join(setup.repo, '.commit-msg.txt'), `${message}\n`);
|
|
155
|
+
const result = runPreparedCommit(setup.repo, { ...process.env, ...FIXED_ENV });
|
|
156
|
+
assert.equal(result.accepted, accepted);
|
|
157
|
+
assert.deepEqual(result.stagedFiles, ['src/sample.js']);
|
|
158
|
+
}
|
|
159
|
+
});
|