harness-everything 1.5.0 → 1.5.2

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.
Files changed (36) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +16 -0
  4. package/CHANGELOG.md +15 -0
  5. package/benchmarks/results/error-ledger-oracle-484-pilot/README.md +57 -0
  6. package/benchmarks/results/error-ledger-oracle-484-pilot/candidates.json +22802 -0
  7. package/benchmarks/results/error-ledger-oracle-484-pilot/labels.json +131 -0
  8. package/benchmarks/results/error-ledger-oracle-484-pilot/oracle.json +362 -0
  9. package/benchmarks/results/error-ledger-oracle-484-pilot/rows.json +648 -0
  10. package/benchmarks/results/error-ledger-oracle-484-pilot/sample.json +215 -0
  11. package/benchmarks/results/error-ledger-oracle-484-pilot/select.js +127 -0
  12. package/ci/mechanism-332-fable-directive.test.js +98 -2
  13. package/ci/mechanism-349-ci-change-scope.test.js +69 -1
  14. package/ci/mechanism-548-bigint-identity.test.js +1 -1
  15. package/ci/mechanism-571-fit-guard.test.js +165 -0
  16. package/ci/mechanism-571-nll-labels.test.js +79 -0
  17. package/ci/mechanism-report-writer.test.js +17 -0
  18. package/ci/mechanism-system-one-curves.test.js +11 -5
  19. package/ci/mechanism-system-one-cycle.test.js +73 -0
  20. package/harness-everything/SKILL.md +1 -1
  21. package/harness-everything/scripts/system-one/layer.py +11 -1
  22. package/harness-everything/scripts/tier-router.js +27 -12
  23. package/opencode-plugin/plugin.json +1 -1
  24. package/package.json +1 -1
  25. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  26. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  27. package/plugins/harness-everything/plugin.json +1 -1
  28. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  29. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/layer.py +11 -1
  30. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +27 -12
  31. package/sbom.cdx.json +7 -7
  32. package/scripts/report-writer.js +1 -1
  33. package/scripts/system-one-curves.js +72 -15
  34. package/scripts/system-one-cycle/evaluate.js +25 -13
  35. package/scripts/system-one-cycle/train.js +67 -25
  36. package/scripts/system-one-fit-layer.py +11 -1
@@ -0,0 +1,215 @@
1
+ {
2
+ "seed": 484,
3
+ "method": "proportional largest-remainder allocation per link group (15 path-linked, 15 unmatched); deterministic SHA-256(seed:stratum:candidateId) ranking within each stratum",
4
+ "reportPath": "candidates.json",
5
+ "reportSha256": "b70289fa09c00402b7ce211a18f2e338fba078ac545d75ced98f8142e527a6c0",
6
+ "populationTotal": 491,
7
+ "sampleTotal": 30,
8
+ "strata": [
9
+ {
10
+ "stratum": "path-linked × git",
11
+ "population": 33,
12
+ "sampled": 13
13
+ },
14
+ {
15
+ "stratum": "path-linked × doc",
16
+ "population": 4,
17
+ "sampled": 2
18
+ },
19
+ {
20
+ "stratum": "unmatched × git",
21
+ "population": 357,
22
+ "sampled": 12
23
+ },
24
+ {
25
+ "stratum": "unmatched × doc",
26
+ "population": 97,
27
+ "sampled": 3
28
+ }
29
+ ],
30
+ "selected": [
31
+ {
32
+ "candidateId": "45d051e778e4a8dd8708",
33
+ "stratum": "path-linked × git",
34
+ "linkedRecords": [
35
+ "E-0011"
36
+ ]
37
+ },
38
+ {
39
+ "candidateId": "478a08b6ba1dc1cf50d1",
40
+ "stratum": "path-linked × git",
41
+ "linkedRecords": [
42
+ "E-0008"
43
+ ]
44
+ },
45
+ {
46
+ "candidateId": "62cfa74becdfe79f89b5",
47
+ "stratum": "path-linked × git",
48
+ "linkedRecords": [
49
+ "E-0025"
50
+ ]
51
+ },
52
+ {
53
+ "candidateId": "69914bbebe41099cc716",
54
+ "stratum": "path-linked × git",
55
+ "linkedRecords": [
56
+ "E-0019"
57
+ ]
58
+ },
59
+ {
60
+ "candidateId": "6d6e5944548fb0a96f50",
61
+ "stratum": "path-linked × git",
62
+ "linkedRecords": [
63
+ "E-0018"
64
+ ]
65
+ },
66
+ {
67
+ "candidateId": "6f2e567c16cebeef896b",
68
+ "stratum": "path-linked × git",
69
+ "linkedRecords": [
70
+ "E-0015"
71
+ ]
72
+ },
73
+ {
74
+ "candidateId": "78ce8199ae9a54ce3a89",
75
+ "stratum": "path-linked × git",
76
+ "linkedRecords": [
77
+ "E-0027",
78
+ "E-0030"
79
+ ]
80
+ },
81
+ {
82
+ "candidateId": "8e9585a2d2ddb90bb769",
83
+ "stratum": "path-linked × git",
84
+ "linkedRecords": [
85
+ "E-0033"
86
+ ]
87
+ },
88
+ {
89
+ "candidateId": "9160683c3b0e52c21e10",
90
+ "stratum": "path-linked × git",
91
+ "linkedRecords": [
92
+ "E-0027",
93
+ "E-0028"
94
+ ]
95
+ },
96
+ {
97
+ "candidateId": "aa89e5143ab82b6916d4",
98
+ "stratum": "path-linked × git",
99
+ "linkedRecords": [
100
+ "E-0021"
101
+ ]
102
+ },
103
+ {
104
+ "candidateId": "beeb0fa4e47a37509580",
105
+ "stratum": "path-linked × git",
106
+ "linkedRecords": [
107
+ "E-0001",
108
+ "E-0005"
109
+ ]
110
+ },
111
+ {
112
+ "candidateId": "c984088a317ec58c3de8",
113
+ "stratum": "path-linked × git",
114
+ "linkedRecords": [
115
+ "E-0007"
116
+ ]
117
+ },
118
+ {
119
+ "candidateId": "e61a37c27572f5069b29",
120
+ "stratum": "path-linked × git",
121
+ "linkedRecords": [
122
+ "E-0011"
123
+ ]
124
+ },
125
+ {
126
+ "candidateId": "50ffd71f8ff5182e630b",
127
+ "stratum": "path-linked × doc",
128
+ "linkedRecords": [
129
+ "E-0005"
130
+ ]
131
+ },
132
+ {
133
+ "candidateId": "9da2bae6b84ba193e58b",
134
+ "stratum": "path-linked × doc",
135
+ "linkedRecords": [
136
+ "E-0005"
137
+ ]
138
+ },
139
+ {
140
+ "candidateId": "0c8f33d06ee587e50f40",
141
+ "stratum": "unmatched × git",
142
+ "linkedRecords": []
143
+ },
144
+ {
145
+ "candidateId": "1d2dcb41e9c9effe0153",
146
+ "stratum": "unmatched × git",
147
+ "linkedRecords": []
148
+ },
149
+ {
150
+ "candidateId": "4793e1ba321f1eaf61fc",
151
+ "stratum": "unmatched × git",
152
+ "linkedRecords": []
153
+ },
154
+ {
155
+ "candidateId": "4ed3a55659580a9cfacc",
156
+ "stratum": "unmatched × git",
157
+ "linkedRecords": []
158
+ },
159
+ {
160
+ "candidateId": "58867ac2fb868297d2ee",
161
+ "stratum": "unmatched × git",
162
+ "linkedRecords": []
163
+ },
164
+ {
165
+ "candidateId": "642fb0dce2c044d55dec",
166
+ "stratum": "unmatched × git",
167
+ "linkedRecords": []
168
+ },
169
+ {
170
+ "candidateId": "6f597dd3781996ac7163",
171
+ "stratum": "unmatched × git",
172
+ "linkedRecords": []
173
+ },
174
+ {
175
+ "candidateId": "6f7c48d023be8ad0c2a1",
176
+ "stratum": "unmatched × git",
177
+ "linkedRecords": []
178
+ },
179
+ {
180
+ "candidateId": "89a06536ca2df52ae75a",
181
+ "stratum": "unmatched × git",
182
+ "linkedRecords": []
183
+ },
184
+ {
185
+ "candidateId": "c51c52ee604590858cd3",
186
+ "stratum": "unmatched × git",
187
+ "linkedRecords": []
188
+ },
189
+ {
190
+ "candidateId": "d7f7d99b6733c0040302",
191
+ "stratum": "unmatched × git",
192
+ "linkedRecords": []
193
+ },
194
+ {
195
+ "candidateId": "f8bc9347d5d53dee97f2",
196
+ "stratum": "unmatched × git",
197
+ "linkedRecords": []
198
+ },
199
+ {
200
+ "candidateId": "9120f29cf0711398d4af",
201
+ "stratum": "unmatched × doc",
202
+ "linkedRecords": []
203
+ },
204
+ {
205
+ "candidateId": "b6311421eb778e728eb3",
206
+ "stratum": "unmatched × doc",
207
+ "linkedRecords": []
208
+ },
209
+ {
210
+ "candidateId": "e2a835a2fe9918dc86f1",
211
+ "stratum": "unmatched × doc",
212
+ "linkedRecords": []
213
+ }
214
+ ]
215
+ }
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const crypto = require('node:crypto');
5
+ const fs = require('node:fs');
6
+
7
+ const SEED = 484;
8
+ const REPORT_PATH = 'candidates.json';
9
+ const ORACLE_PATH = 'oracle-nolabels.json';
10
+ const OUT_PATH = 'sample.json';
11
+ const GROUP_TARGETS = { 'path-linked': 15, unmatched: 15 };
12
+
13
+ function sha256Hex(bufferOrString) {
14
+ return crypto.createHash('sha256').update(bufferOrString).digest('hex');
15
+ }
16
+
17
+ function allocateProportional(stratumCounts, totalTarget) {
18
+ const entries = Object.entries(stratumCounts).sort((a, b) => a[0].localeCompare(b[0]));
19
+ const totalPop = entries.reduce((sum, [, count]) => sum + count, 0);
20
+ if (totalPop <= totalTarget) {
21
+ return Object.fromEntries(entries.map(([k, count]) => [k, count]));
22
+ }
23
+ const exact = entries.map(([k, count]) => ({
24
+ key: k,
25
+ pop: count,
26
+ exact: (totalTarget * count) / totalPop
27
+ }));
28
+ const alloc = Object.fromEntries(exact.map(item => [item.key, Math.floor(item.exact)]));
29
+ let remaining = totalTarget - Object.values(alloc).reduce((a, b) => a + b, 0);
30
+ // Largest-remainder method, tie-breaking lexicographically by stratum key
31
+ const remainders = exact
32
+ .map(item => ({ key: item.key, rem: item.exact - Math.floor(item.exact), pop: item.pop }))
33
+ .sort((a, b) => (b.rem - a.rem) || a.key.localeCompare(b.key));
34
+ for (const item of remainders) {
35
+ if (remaining <= 0) break;
36
+ if (alloc[item.key] < item.pop) {
37
+ alloc[item.key] += 1;
38
+ remaining -= 1;
39
+ }
40
+ }
41
+ return alloc;
42
+ }
43
+
44
+ function main() {
45
+ const reportBytes = fs.readFileSync(REPORT_PATH);
46
+ const reportSha256 = sha256Hex(reportBytes);
47
+ const report = JSON.parse(reportBytes.toString('utf8'));
48
+ const oracle = JSON.parse(fs.readFileSync(ORACLE_PATH, 'utf8'));
49
+
50
+ const linkedByCandidate = new Map();
51
+ for (const rec of oracle.linked) {
52
+ for (const cid of rec.candidateIds) {
53
+ const list = linkedByCandidate.get(cid) || [];
54
+ list.push(rec.id);
55
+ linkedByCandidate.set(cid, list);
56
+ }
57
+ }
58
+ for (const list of linkedByCandidate.values()) list.sort();
59
+
60
+ const strata = {
61
+ 'path-linked × git': [],
62
+ 'path-linked × doc': [],
63
+ 'unmatched × git': [],
64
+ 'unmatched × doc': []
65
+ };
66
+
67
+ for (const candidate of report.candidates) {
68
+ const linkGroup = linkedByCandidate.has(candidate.id) ? 'path-linked' : 'unmatched';
69
+ const sourceTypes = [...new Set(candidate.sources.map(s => s.type))].sort();
70
+ if (sourceTypes.length !== 1 || !['git', 'doc'].includes(sourceTypes[0])) {
71
+ throw new Error(`Unexpected source types for ${candidate.id}: ${sourceTypes.join(',')}`);
72
+ }
73
+ const key = `${linkGroup} × ${sourceTypes[0]}`;
74
+ strata[key].push(candidate.id);
75
+ }
76
+
77
+ for (const ids of Object.values(strata)) ids.sort();
78
+
79
+ const pathLinkedAlloc = allocateProportional(
80
+ { 'path-linked × git': strata['path-linked × git'].length, 'path-linked × doc': strata['path-linked × doc'].length },
81
+ GROUP_TARGETS['path-linked']
82
+ );
83
+ const unmatchedAlloc = allocateProportional(
84
+ { 'unmatched × git': strata['unmatched × git'].length, 'unmatched × doc': strata['unmatched × doc'].length },
85
+ GROUP_TARGETS.unmatched
86
+ );
87
+ const targetByStratum = { ...pathLinkedAlloc, ...unmatchedAlloc };
88
+
89
+ const selected = [];
90
+ const stratumSummary = [];
91
+ for (const stratum of ['path-linked × git', 'path-linked × doc', 'unmatched × git', 'unmatched × doc']) {
92
+ const pool = strata[stratum];
93
+ const k = targetByStratum[stratum];
94
+ const ranked = pool
95
+ .map(id => ({ id, rank: sha256Hex(`${SEED}:${stratum}:${id}`) }))
96
+ .sort((a, b) => a.rank.localeCompare(b.rank) || a.id.localeCompare(b.id));
97
+ const chosen = ranked.slice(0, k).map(item => item.id).sort();
98
+ stratumSummary.push({
99
+ stratum,
100
+ population: pool.length,
101
+ sampled: chosen.length
102
+ });
103
+ for (const id of chosen) {
104
+ selected.push({
105
+ candidateId: id,
106
+ stratum,
107
+ linkedRecords: linkedByCandidate.get(id) || []
108
+ });
109
+ }
110
+ }
111
+
112
+ const output = {
113
+ seed: SEED,
114
+ method: 'proportional largest-remainder allocation per link group (15 path-linked, 15 unmatched); deterministic SHA-256(seed:stratum:candidateId) ranking within each stratum',
115
+ reportPath: REPORT_PATH,
116
+ reportSha256,
117
+ populationTotal: report.candidates.length,
118
+ sampleTotal: selected.length,
119
+ strata: stratumSummary,
120
+ selected
121
+ };
122
+
123
+ fs.writeFileSync(OUT_PATH, `${JSON.stringify(output, null, 2)}\n`);
124
+ process.stdout.write(`${JSON.stringify({ ok: true, out: OUT_PATH, strata: stratumSummary, sampleTotal: selected.length })}\n`);
125
+ }
126
+
127
+ main();
@@ -5,9 +5,14 @@ const path = require('node:path');
5
5
 
6
6
  const ROOT = path.resolve(__dirname, '..');
7
7
  const ROUTER = path.join(ROOT, 'harness-everything', 'scripts', 'kernel-router.js');
8
+ const PACKAGED_ROUTER = path.join(ROOT, 'plugins', 'harness-everything', 'skills', 'harness-everything', 'scripts', 'kernel-router.js');
9
+ const ROUTERS = [
10
+ ['source', ROUTER],
11
+ ['packaged', PACKAGED_ROUTER],
12
+ ];
8
13
 
9
- function route(prompt) {
10
- const result = spawnSync(process.execPath, [ROUTER], {
14
+ function route(prompt, router = ROUTER) {
15
+ const result = spawnSync(process.execPath, [router], {
11
16
  cwd: ROOT,
12
17
  encoding: 'utf8',
13
18
  input: JSON.stringify({ hook_event_name: 'UserPromptSubmit', prompt }),
@@ -177,4 +182,95 @@ const quotedSeparator = route('Use “fable; use fable on opus” as an example'
177
182
  assert.notEqual(quotedSeparator.strategy, 'fable-staged');
178
183
  assert.ok(!quotedSeparator.reasonCodes.includes('explicit-strategy-request'));
179
184
 
185
+ const quotedFableExamples = [
186
+ '用「fable; use fable on opus」當例子說明',
187
+ '使用「fable; use fable on opus」作為範例',
188
+ '用『fable; use fable on opus』當例子說明',
189
+ 'Use 「fable; use fable on opus」 as an example',
190
+ 'Use 《fable; use fable on opus》 as an example',
191
+ ];
192
+ const polarityCases = [
193
+ {
194
+ prompt: '不要改用 fable 重構整個 repository architecture',
195
+ tier: 'tier3',
196
+ strategy: 'iterative-single',
197
+ },
198
+ {
199
+ prompt: 'Do not switch to fable; redesign the architecture across the repository',
200
+ tier: 'tier3',
201
+ strategy: 'iterative-single',
202
+ },
203
+ ];
204
+ const contradictionCases = [
205
+ '不要改用 fable;改用 fable-staged 做這個任務',
206
+ '改用 fable-staged 做這個任務;不要改用 fable',
207
+ 'Do not switch to fable; use fable-staged for this task',
208
+ 'Use fable-staged for this task; do not switch to fable',
209
+ 'Do not use fable; use fable-staged for this task',
210
+ ];
211
+
212
+ for (const [name, router] of ROUTERS) {
213
+ const quotedProhibitionWithOuterRequest = route('用「不要使用 fable」當例子說明;改用 fable-staged 重構整個 repository architecture', router);
214
+ assert.equal(quotedProhibitionWithOuterRequest.strategy, 'fable-staged', `${name}: quoted prohibition is data and the real outer request selects Fable`);
215
+ assert.ok(quotedProhibitionWithOuterRequest.reasonCodes.includes('explicit-strategy-request'), `${name}: outer request is explicit`);
216
+ assert.notEqual(quotedProhibitionWithOuterRequest.fallback.disposition, 'blocked', `${name}: quoted prohibition does not conflict with the outer request`);
217
+
218
+ const quoteBoundaryDoesNotJoin = route('Do not "example" fable; use fable-staged for this task', router);
219
+ assert.equal(quoteBoundaryDoesNotJoin.strategy, 'fable-staged', `${name}: excluding a quote does not join text into a false prohibition`);
220
+ assert.notEqual(quoteBoundaryDoesNotJoin.fallback.disposition, 'blocked', `${name}: quote removal does not manufacture a conflict`);
221
+
222
+ const unquotedContradiction = route('不要使用 fable;改用 fable-staged 重構整個 repository architecture', router);
223
+ assert.equal(unquotedContradiction.fallback.disposition, 'blocked', `${name}: unquoted prohibition still conflicts`);
224
+ assert.ok(unquotedContradiction.reasonCodes.includes('explicit-request-conflicts-with-prohibition'), `${name}: unquoted conflict is recorded`);
225
+
226
+ for (const prompt of quotedFableExamples) {
227
+ const plan = route(prompt, router);
228
+ assert.ok(!String(plan.strategy).startsWith('fable-'), `${name}: ${prompt}: quoted text selects no Fable strategy`);
229
+ assert.ok(!plan.reasonCodes.includes('explicit-strategy-request'), `${name}: ${prompt}: quoted text is not an explicit request`);
230
+ assert.ok(!plan.routerOutput.includes('REQUESTED FABLE PROFILE'), `${name}: ${prompt}: quoted profile is not requested`);
231
+ }
232
+
233
+ const quotedAndUnquoted = route('Use 「fable; use fable on opus」 as an example; use fable-staged for this task', router);
234
+ assert.equal(quotedAndUnquoted.strategy, 'fable-staged', `${name}: unquoted directive still selects Fable`);
235
+ assert.ok(quotedAndUnquoted.reasonCodes.includes('explicit-strategy-request'), `${name}: unquoted directive is explicit`);
236
+ assert.ok(!quotedAndUnquoted.routerOutput.includes('REQUESTED FABLE PROFILE'), `${name}: quoted profile stays data`);
237
+
238
+ for (const verb of ['use', 'run', 'enter', 'switch to']) {
239
+ const affirmative = route(`${verb} fable for this task`, router);
240
+ assert.equal(affirmative.strategy, 'fable-staged', `${name}: ${verb} is an affirmative directive`);
241
+ assert.ok(affirmative.reasonCodes.includes('explicit-strategy-request'), `${name}: ${verb} is recorded as explicit`);
242
+ const prohibited = route(`Do not ${verb} fable; redesign the repository architecture`, router);
243
+ assert.equal(prohibited.strategy, 'iterative-single', `${name}: do not ${verb} fable downgrades the topology`);
244
+ assert.ok(prohibited.reasonCodes.includes('user-prohibited-fable'), `${name}: do not ${verb} fable is a prohibition`);
245
+ }
246
+
247
+ for (const verb of ['使用', '用', '啟用', '進入', '執行', '改用']) {
248
+ const affirmative = route(`${verb} fable 做這個任務`, router);
249
+ assert.equal(affirmative.strategy, 'fable-staged', `${name}: ${verb} is an affirmative directive`);
250
+ assert.ok(affirmative.reasonCodes.includes('explicit-strategy-request'), `${name}: ${verb} is recorded as explicit`);
251
+ const prohibited = route(`不要${verb} fable 重構整個 repository architecture`, router);
252
+ assert.equal(prohibited.strategy, 'iterative-single', `${name}: 不要${verb} fable downgrades the topology`);
253
+ assert.ok(prohibited.reasonCodes.includes('user-prohibited-fable'), `${name}: 不要${verb} fable is a prohibition`);
254
+ }
255
+
256
+ for (const { prompt, tier, strategy } of polarityCases) {
257
+ const plan = route(prompt, router);
258
+ assert.equal(plan.tier, tier, `${name}: ${prompt}: structural tier remains`);
259
+ assert.equal(plan.strategy, strategy, `${name}: ${prompt}: prohibition selects a single-agent topology`);
260
+ assert.ok(plan.reasonCodes.includes('user-prohibited-fable'), `${name}: ${prompt}: prohibition is recorded`);
261
+ }
262
+
263
+ for (const prompt of contradictionCases) {
264
+ const plan = route(prompt, router);
265
+ assert.equal(plan.fallback.disposition, 'blocked', `${name}: ${prompt}: contradiction is blocked`);
266
+ assert.ok(plan.reasonCodes.includes('explicit-request-conflicts-with-prohibition'), `${name}: ${prompt}: conflict is recorded`);
267
+ }
268
+
269
+ const existingChineseControl = route('不要使用 fable 重構整個 repository architecture', router);
270
+ assert.equal(existingChineseControl.strategy, 'iterative-single', `${name}: existing prohibition control downgrades`);
271
+ assert.ok(existingChineseControl.reasonCodes.includes('user-prohibited-fable'));
272
+ const quotedControl = route('Use “fable; use fable on opus” as an example', router);
273
+ assert.ok(!String(quotedControl.strategy).startsWith('fable-'), `${name}: paired curly-quote control stays non-Fable`);
274
+ }
275
+
180
276
  console.log('PASS: #332 Fable directive real-entry controls');
@@ -12,7 +12,14 @@ const { classifyPaths, classifyChangeSet } = require('../scripts/ci-change-scope
12
12
  const ROOT = path.resolve(__dirname, '..');
13
13
  const SCRIPT = path.join(ROOT, 'scripts', 'ci-change-scope.js');
14
14
  const CHANGE_SCOPE_JOB = 'ci-change-scope';
15
+ const SELF_REGRESSION_GATE = 'self-regression-gate';
15
16
  const SELF_REGRESSION_IF = "${{ !cancelled() && (needs.ci-change-scope.result != 'success' || needs.ci-change-scope.outputs.scope != 'docs-only') }}";
17
+ const SELF_REGRESSION_GATE_RUN = [
18
+ "printf 'self-regression=%s\\nci-change-scope=%s scope=%s\\n' \"$SELF_REGRESSION_RESULT\" \"$CI_CHANGE_SCOPE_RESULT\" \"$CI_CHANGE_SCOPE\"",
19
+ "if [ \"$SELF_REGRESSION_RESULT\" = 'success' ]; then exit 0; fi",
20
+ "if [ \"$SELF_REGRESSION_RESULT\" = 'skipped' ] && [ \"$CI_CHANGE_SCOPE_RESULT\" = 'success' ] && [ \"$CI_CHANGE_SCOPE\" = 'docs-only' ]; then exit 0; fi",
21
+ 'exit 1',
22
+ ].join('\n') + '\n';
16
23
 
17
24
  function nulPaths(paths) {
18
25
  return paths.length ? Buffer.from(`${paths.join('\0')}\0`) : Buffer.alloc(0);
@@ -46,6 +53,12 @@ function shouldRunSelfRegression(workflowCancelled, result, scope) {
46
53
  return !workflowCancelled && (result !== 'success' || scope !== 'docs-only');
47
54
  }
48
55
 
56
+ function shouldPassSelfRegressionGate(selfRegressionResult, classifierResult, scope) {
57
+ return selfRegressionResult === 'success' || (
58
+ selfRegressionResult === 'skipped' && classifierResult === 'success' && scope === 'docs-only'
59
+ );
60
+ }
61
+
49
62
  // Assert the intended scope-gating invariants against parsed workflow documents.
50
63
  // Taking documents (not git history or whole-file text) keeps unrelated CI edits
51
64
  // green and lets the oracle be replayed against mutated copies of the YAML.
@@ -53,8 +66,10 @@ function assertScopeGating({ ci, release, governance }) {
53
66
  const jobs = ci.jobs;
54
67
  const classifier = jobs[CHANGE_SCOPE_JOB];
55
68
  const selfRegression = jobs['self-regression'];
69
+ const selfRegressionGate = jobs[SELF_REGRESSION_GATE];
56
70
  assert.ok(classifier, 'the ci-change-scope job exists');
57
71
  assert.ok(selfRegression, 'the self-regression job exists');
72
+ assert.ok(selfRegressionGate, 'the self-regression aggregate gate exists');
58
73
 
59
74
  // Every dependency chain that could inherit the docs-only skip has a first
60
75
  // job that needs the classifier or self-regression.
@@ -62,6 +77,15 @@ function assertScopeGating({ ci, release, governance }) {
62
77
  // Match needs.job and needs['job'] references while skipping quoted strings.
63
78
  const needsReference = /'(?:[^']|'')*'|(?<![\w.-])needs\s*(?:\.\s*([\w-]+)|\[\s*'([\w-]+)'\s*\])/gi;
64
79
  for (const [jobId, job] of Object.entries(jobs)) {
80
+ if (jobId === SELF_REGRESSION_GATE) {
81
+ // The aggregate gate is the one named consumer allowed to depend on
82
+ // scope-gated jobs; its own condition must run it even after skips.
83
+ assert.deepEqual(job.needs, [CHANGE_SCOPE_JOB, 'self-regression']);
84
+ assert.equal(job.if, '${{ always() }}');
85
+ assert.equal(job['runs-on'], 'ubuntu-latest');
86
+ assert.ok(!String(job.if).includes('scope'), 'the aggregate gate itself is not scope-gated');
87
+ continue;
88
+ }
65
89
  if (scopeJobs.includes(jobId)) continue;
66
90
  const needs = Array.isArray(job.needs) ? job.needs : [job.needs];
67
91
  for (const scopeJob of scopeJobs) {
@@ -96,6 +120,15 @@ function assertScopeGating({ ci, release, governance }) {
96
120
  assert.ok(selfRegression.if.includes('!cancelled()'), 'workflow cancellation must disable self-regression');
97
121
  assert.ok(!selfRegression.if.includes('always()'), 'always() keeps self-regression eligible during cancellation');
98
122
 
123
+ const gateStep = selfRegressionGate.steps?.find(step => step.name === 'Aggregate self-regression result');
124
+ assert.ok(gateStep, 'the aggregate gate makes one explicit decision');
125
+ assert.deepEqual(gateStep.env, {
126
+ SELF_REGRESSION_RESULT: '${{ needs.self-regression.result }}',
127
+ CI_CHANGE_SCOPE_RESULT: '${{ needs.ci-change-scope.result }}',
128
+ CI_CHANGE_SCOPE: '${{ needs.ci-change-scope.outputs.scope }}',
129
+ });
130
+ assert.equal(gateStep.run, SELF_REGRESSION_GATE_RUN, 'the shell gate implements the aggregate decision using env inputs');
131
+
99
132
  // The three-OS matrix stays complete.
100
133
  assert.equal(selfRegression.strategy['fail-fast'], false);
101
134
  assert.deepEqual(selfRegression.strategy.matrix.os, ['ubuntu-latest', 'windows-latest', 'macos-latest']);
@@ -286,6 +319,22 @@ test('the workflow gates only self-regression and fails open on every uncertain
286
319
  assert.equal(classifyChangeSet('push', 'a'.repeat(40), 'b'.repeat(40), { runGit: unusedGitForWorkflow }), 'full');
287
320
  });
288
321
 
322
+ test('the aggregate status passes only for a successful matrix or a successful docs-only skip', () => {
323
+ const cases = [
324
+ ['successful matrix with code changes', 'success', 'success', 'code', true],
325
+ ['successful matrix when classifier is skipped on push', 'success', 'skipped', undefined, true],
326
+ ['skipped matrix after successful docs-only classification', 'skipped', 'success', 'docs-only', true],
327
+ ['skipped matrix after code classification', 'skipped', 'success', 'code', false],
328
+ ['skipped matrix when classifier is skipped', 'skipped', 'skipped', undefined, false],
329
+ ['skipped matrix when classifier fails', 'skipped', 'failure', undefined, false],
330
+ ['failed matrix', 'failure', 'success', 'docs-only', false],
331
+ ['cancelled matrix', 'cancelled', 'success', 'docs-only', false],
332
+ ];
333
+ for (const [label, matrix, classifier, scope, expected] of cases) {
334
+ assert.equal(shouldPassSelfRegressionGate(matrix, classifier, scope), expected, label);
335
+ }
336
+ });
337
+
289
338
  test('the oracle accepts jobs with independent conditions and dependencies', () => {
290
339
  const workflows = readScopeWorkflows();
291
340
  const jobs = workflows.ci.jobs;
@@ -333,10 +382,29 @@ test('the oracle retains the existing scope-gating invariants', () => {
333
382
  }
334
383
  });
335
384
 
385
+ test('the oracle rejects mutations that could make the aggregate required check skip or pass falsely', () => {
386
+ for (const [mutate, expected] of [
387
+ [({ ci }) => { delete ci.jobs[SELF_REGRESSION_GATE].if; }, /always\(\)/],
388
+ [({ ci }) => { ci.jobs[SELF_REGRESSION_GATE].needs = ['self-regression']; }, /deep-equal/],
389
+ [({ ci }) => {
390
+ ci.jobs[SELF_REGRESSION_GATE].steps.find(step => step.name === 'Aggregate self-regression result').run = [
391
+ "printf 'self-regression=%s\\nci-change-scope=%s scope=%s\\n' \"$SELF_REGRESSION_RESULT\" \"$CI_CHANGE_SCOPE_RESULT\" \"$CI_CHANGE_SCOPE\"",
392
+ "if [ \"$SELF_REGRESSION_RESULT\" = 'success' ]; then exit 0; fi",
393
+ "if [ \"$SELF_REGRESSION_RESULT\" = 'skipped' ]; then exit 0; fi",
394
+ 'exit 1',
395
+ ].join('\n');
396
+ }, /implements the aggregate decision/],
397
+ ]) {
398
+ const workflows = readScopeWorkflows();
399
+ mutate(workflows);
400
+ assert.throws(() => assertScopeGating(workflows), expected);
401
+ }
402
+ });
403
+
336
404
  function unusedGitForWorkflow() {
337
405
  throw new Error('the release caller is a push/dispatch, so no PR diff may authorize a skip');
338
406
  }
339
407
 
340
408
  // Exported so the in-report mutant harness can replay the same oracle against
341
409
  // parsed copies of the workflow documents without registering these tests.
342
- module.exports = { assertScopeGating };
410
+ module.exports = { assertScopeGating, shouldPassSelfRegressionGate };
@@ -249,7 +249,7 @@ test('548 errors-sync detects a swapped index whose 64-bit ino collides as Numbe
249
249
  // --- Guard: every non-test JS `.ino` access must originate from a `{ bigint: true }` stat call ---
250
250
 
251
251
  const STAT_METHODS = new Set(['statSync', 'lstatSync', 'fstatSync']);
252
- const EXCLUDED_DIRS = new Set(['.git', '.w', 'node_modules', 'ci', 'evals', 'benchmarks', 'behavioral-evals']);
252
+ const EXCLUDED_DIRS = new Set(['.git', '.worktrees', '.w', 'node_modules', 'ci', 'evals', 'benchmarks', 'behavioral-evals']);
253
253
 
254
254
  function listNonTestJsFiles(dir, out = []) {
255
255
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {