harness-everything 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +16 -0
- package/CHANGELOG.md +8 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/README.md +57 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/candidates.json +22802 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/labels.json +131 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/oracle.json +362 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/rows.json +648 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/sample.json +215 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/select.js +127 -0
- package/ci/mechanism-349-ci-change-scope.test.js +69 -1
- package/ci/mechanism-548-bigint-identity.test.js +1 -1
- package/ci/mechanism-571-fit-guard.test.js +165 -0
- package/ci/mechanism-571-nll-labels.test.js +79 -0
- package/ci/mechanism-system-one-curves.test.js +11 -5
- package/ci/mechanism-system-one-cycle.test.js +73 -0
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/system-one/layer.py +11 -1
- 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/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/layer.py +11 -1
- package/sbom.cdx.json +7 -7
- package/scripts/system-one-curves.js +72 -15
- package/scripts/system-one-cycle/evaluate.js +25 -13
- package/scripts/system-one-cycle/train.js +67 -25
- 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();
|
|
@@ -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 })) {
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const crypto = require('node:crypto');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const os = require('node:os');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { runGuarded, fitLayerStage, validateFitStage } = require('../scripts/system-one-cycle/train');
|
|
9
|
+
const { trainerCatalogs } = require('../scripts/system-one-cycle/package');
|
|
10
|
+
const { test } = require('node:test');
|
|
11
|
+
|
|
12
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
13
|
+
const sha256 = file => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
14
|
+
|
|
15
|
+
function makeFixture(t) {
|
|
16
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 's571b-fit-guard-'));
|
|
17
|
+
const runDir = path.join(dataDir, 'training', 'runs', 'guarded', 'tier');
|
|
18
|
+
const bundle = path.join(dataDir, 'training', 'v1');
|
|
19
|
+
const runner = path.join(dataDir, 'fake-fitter.js');
|
|
20
|
+
const sentinelDir = path.join(dataDir, 'guard-invocations');
|
|
21
|
+
fs.mkdirSync(runDir, { recursive: true });
|
|
22
|
+
fs.mkdirSync(bundle, { recursive: true });
|
|
23
|
+
fs.mkdirSync(sentinelDir);
|
|
24
|
+
t.after(() => fs.rmSync(dataDir, { recursive: true, force: true }));
|
|
25
|
+
|
|
26
|
+
const catalog = trainerCatalogs().tier;
|
|
27
|
+
const prompts = path.join(bundle, 'prompts.jsonl');
|
|
28
|
+
const labels = path.join(bundle, 'labels.jsonl');
|
|
29
|
+
fs.writeFileSync(prompts, '{"id":"validation-tier","text":"fixture"}\n');
|
|
30
|
+
fs.writeFileSync(labels, '{"id":"validation-tier","gold":"tier2"}\n');
|
|
31
|
+
fs.writeFileSync(path.join(runDir, 'harness-routing-v1.safetensors'), 'fixture-weights');
|
|
32
|
+
fs.writeFileSync(path.join(runDir, 'harness-routing-v1.json'), '{"context_tokens":1024}\n');
|
|
33
|
+
fs.writeFileSync(path.join(runDir, 'val-scores.jsonl'), `${JSON.stringify({ id: 'validation-tier', gold: 'tier2',
|
|
34
|
+
scores: Object.fromEntries(catalog.map(id => [id, id === 'tier2' ? 0.9 : 0.1])) })}\n`);
|
|
35
|
+
const report = { schemaVersion: 1, task: 'tier', target: 'label', catalog, counts: { train: 1, validation: 1 },
|
|
36
|
+
datasets: { 'prompts.jsonl': sha256(prompts), 'labels.jsonl': sha256(labels) }, config: { context_tokens: 1024 },
|
|
37
|
+
bestEpoch: 1, history: [], device: 'cpu', torch: 'fixture' };
|
|
38
|
+
fs.writeFileSync(path.join(runDir, 'train-report.json'), JSON.stringify(report));
|
|
39
|
+
fs.writeFileSync(path.join(runDir, 'resource-guard.json'), JSON.stringify({ schemaVersion: 1, exitCode: 0,
|
|
40
|
+
killedForLimit: false, monitorFailed: false, peakRssMb: 1, maxRssMb: 64, threads: 2 }));
|
|
41
|
+
|
|
42
|
+
fs.writeFileSync(runner, `#!/usr/bin/env node
|
|
43
|
+
'use strict';
|
|
44
|
+
const fs = require('node:fs');
|
|
45
|
+
const path = require('node:path');
|
|
46
|
+
const args = process.argv.slice(2);
|
|
47
|
+
const value = name => args[args.indexOf(name) + 1];
|
|
48
|
+
const runDir = value('--run-dir');
|
|
49
|
+
const task = value('--task');
|
|
50
|
+
const dataDir = value('--data-dir');
|
|
51
|
+
const holdout = value('--holdout');
|
|
52
|
+
const marker = process.env.S571B_SENTINEL;
|
|
53
|
+
const mode = process.env.S571B_MODE;
|
|
54
|
+
if (!marker || !runDir || task !== 'tier' || !dataDir || !holdout) process.exit(21);
|
|
55
|
+
fs.writeFileSync(marker, 'guard reached\\n');
|
|
56
|
+
const json = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
57
|
+
const hash = file => require('node:crypto').createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
58
|
+
const report = json(path.join(runDir, 'train-report.json'));
|
|
59
|
+
const scoreFile = path.join(runDir, 'val-scores.jsonl');
|
|
60
|
+
const outcome = { schemaVersion: 1, task, outcome: 'keep-base', oofScoreSpace: null,
|
|
61
|
+
datasetSha256: report.datasets, trainerReportSha256: hash(path.join(runDir, 'train-report.json')),
|
|
62
|
+
holdoutSha256: hash(holdout), checkpointSha256: hash(path.join(runDir, 'harness-routing-v1.safetensors')),
|
|
63
|
+
checkpointConfigSha256: hash(path.join(runDir, 'harness-routing-v1.json')),
|
|
64
|
+
validationIds: [JSON.parse(fs.readFileSync(scoreFile, 'utf8')).id], calibrationInput: 'val-scores.jsonl',
|
|
65
|
+
calibrationInputSha256: hash(scoreFile), calibrationSha256: 'pending' };
|
|
66
|
+
fs.writeFileSync(path.join(runDir, 'layer-outcome.json'), JSON.stringify(outcome));
|
|
67
|
+
if (mode === 'exit') process.exit(7);
|
|
68
|
+
if (mode === 'limit' || mode === 'monitor') setInterval(() => {}, 1000);
|
|
69
|
+
`);
|
|
70
|
+
fs.chmodSync(runner, 0o700);
|
|
71
|
+
|
|
72
|
+
return { dataDir, runDir, runner, sentinelDir, outcomeFile: path.join(runDir, 'layer-outcome.json') };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
test('fitLayerStage uses the RSS guard, removes failed outcomes, and permits guarded retries', async t => {
|
|
76
|
+
const fixture = makeFixture(t);
|
|
77
|
+
const priorPython = process.env.PYTHON;
|
|
78
|
+
const priorMode = process.env.S571B_MODE;
|
|
79
|
+
const priorSentinel = process.env.S571B_SENTINEL;
|
|
80
|
+
process.env.PYTHON = process.execPath;
|
|
81
|
+
const guardResults = [];
|
|
82
|
+
let call = 0;
|
|
83
|
+
const run = async (command, args, limits) => {
|
|
84
|
+
assert.equal(command, process.execPath);
|
|
85
|
+
assert.equal(args[0], path.join(ROOT, 'scripts', 'system-one-fit-layer.py'),
|
|
86
|
+
'the fitter path must reach the existing guard call');
|
|
87
|
+
assert.equal(limits.maxRssMb, 24);
|
|
88
|
+
assert.equal(limits.threads, 2);
|
|
89
|
+
const marker = path.join(fixture.sentinelDir, `${++call}.reached`);
|
|
90
|
+
process.env.S571B_SENTINEL = marker;
|
|
91
|
+
const result = await runGuarded(process.execPath, [fixture.runner, ...args.slice(1)], {
|
|
92
|
+
...limits,
|
|
93
|
+
pollMs: 20,
|
|
94
|
+
rssReader: () => {
|
|
95
|
+
if (!fs.existsSync(marker)) return 0;
|
|
96
|
+
if (process.env.S571B_MODE === 'monitor') throw new Error('fixture monitor failure');
|
|
97
|
+
return process.env.S571B_MODE === 'limit' ? 25 : 0;
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
guardResults.push(result);
|
|
101
|
+
assert.equal(fs.readFileSync(marker, 'utf8'), 'guard reached\n', 'path-specific sentinel proves fake fitter ran');
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
for (const [mode, expected] of [
|
|
107
|
+
['limit', /exceeded the 24 MB RSS limit/],
|
|
108
|
+
['monitor', /RSS monitoring failed/],
|
|
109
|
+
['exit', /system-one-fit-layer\.py failed \(7\)/],
|
|
110
|
+
]) {
|
|
111
|
+
process.env.S571B_MODE = mode;
|
|
112
|
+
fs.rmSync(fixture.outcomeFile, { force: true });
|
|
113
|
+
const failedCall = call + 1;
|
|
114
|
+
await assert.rejects(() => fitLayerStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier',
|
|
115
|
+
maxRssMb: 24, threads: 2, run }), expected);
|
|
116
|
+
assert.ok(fs.existsSync(path.join(fixture.sentinelDir, `${failedCall}.reached`)), `${mode} reached the fake fitter`);
|
|
117
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(fixture.outcomeFile, 'utf8')),
|
|
118
|
+
{ schemaVersion: 0, task: 'tier', failedFit: true }, `${mode} must leave only an invalid failure marker`);
|
|
119
|
+
assert.throws(() => validateFitStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier' }), /fit outcome.*stale/i);
|
|
120
|
+
const failedGuard = guardResults.at(-1);
|
|
121
|
+
if (mode === 'limit') {
|
|
122
|
+
assert.equal(failedGuard.killedForLimit, true);
|
|
123
|
+
assert.ok(failedGuard.signal || failedGuard.exitCode !== 0, 'limit kill must be proven by process exit');
|
|
124
|
+
} else if (mode === 'monitor') {
|
|
125
|
+
assert.equal(failedGuard.monitorFailed, true);
|
|
126
|
+
assert.ok(failedGuard.signal || failedGuard.exitCode !== 0, 'monitor kill must be proven by process exit');
|
|
127
|
+
} else assert.equal(failedGuard.exitCode, 7);
|
|
128
|
+
|
|
129
|
+
process.env.S571B_MODE = 'success';
|
|
130
|
+
const retryCall = call + 1;
|
|
131
|
+
const outcome = await fitLayerStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier',
|
|
132
|
+
maxRssMb: 24, threads: 2, run });
|
|
133
|
+
assert.ok(fs.existsSync(path.join(fixture.sentinelDir, `${retryCall}.reached`)), 'retry must execute the fitter');
|
|
134
|
+
assert.equal(outcome.outcome, 'keep-base');
|
|
135
|
+
const retryGuard = guardResults.at(-1);
|
|
136
|
+
assert.equal(retryGuard.exitCode, 0);
|
|
137
|
+
assert.equal(retryGuard.killedForLimit, false);
|
|
138
|
+
assert.equal(retryGuard.monitorFailed, false);
|
|
139
|
+
assert.doesNotThrow(() => validateFitStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier' }));
|
|
140
|
+
fs.rmSync(fixture.outcomeFile);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
process.env.S571B_MODE = 'success';
|
|
144
|
+
await fitLayerStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier', maxRssMb: 24, threads: 2, run });
|
|
145
|
+
const stale = JSON.parse(fs.readFileSync(fixture.outcomeFile, 'utf8'));
|
|
146
|
+
stale.checkpointConfigSha256 = '0'.repeat(64);
|
|
147
|
+
fs.writeFileSync(fixture.outcomeFile, JSON.stringify(stale));
|
|
148
|
+
process.env.S571B_MODE = 'exit';
|
|
149
|
+
await assert.rejects(() => fitLayerStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier',
|
|
150
|
+
maxRssMb: 24, threads: 2, run }), /system-one-fit-layer\.py failed \(7\)/);
|
|
151
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(fixture.outcomeFile, 'utf8')),
|
|
152
|
+
{ schemaVersion: 0, task: 'tier', failedFit: true }, 'a failed refit must not restore an older stale outcome');
|
|
153
|
+
assert.throws(() => validateFitStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier' }), /fit outcome.*stale/i);
|
|
154
|
+
process.env.S571B_MODE = 'success';
|
|
155
|
+
const retryCall = call + 1;
|
|
156
|
+
const retry = await fitLayerStage({ dataDir: fixture.dataDir, runDir: fixture.runDir, task: 'tier',
|
|
157
|
+
maxRssMb: 24, threads: 2, run });
|
|
158
|
+
assert.ok(fs.existsSync(path.join(fixture.sentinelDir, `${retryCall}.reached`)), 'stale-outcome retry must execute the fitter');
|
|
159
|
+
assert.equal(retry.outcome, 'keep-base');
|
|
160
|
+
} finally {
|
|
161
|
+
if (priorPython === undefined) delete process.env.PYTHON; else process.env.PYTHON = priorPython;
|
|
162
|
+
if (priorMode === undefined) delete process.env.S571B_MODE; else process.env.S571B_MODE = priorMode;
|
|
163
|
+
if (priorSentinel === undefined) delete process.env.S571B_SENTINEL; else process.env.S571B_SENTINEL = priorSentinel;
|
|
164
|
+
}
|
|
165
|
+
});
|