@holmes-lab/holmes-kit 0.40.0 → 0.40.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/CHANGELOG.md +234 -0
- package/README.md +70 -4
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/index.js +25 -19
- package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
- package/dist/holmes/cli/interactive-prompt.js +98 -16
- package/dist/holmes/config/config.d.ts +17 -0
- package/dist/holmes/config/config.js +13 -1
- package/dist/holmes/governance/autonomy.d.ts +7 -0
- package/dist/holmes/governance/autonomy.js +36 -5
- package/dist/holmes/governance/push-gate-runner.d.ts +2 -0
- package/dist/holmes/governance/push-gate-runner.js +40 -3
- package/dist/holmes/governance/push-gate.d.ts +13 -2
- package/dist/holmes/governance/push-gate.js +106 -14
- package/dist/holmes/guardrail/advisory-line.d.ts +102 -0
- package/dist/holmes/guardrail/advisory-line.js +718 -0
- package/dist/holmes/guardrail/impact-gate.d.ts +6 -0
- package/dist/holmes/guardrail/impact-gate.js +32 -5
- package/dist/holmes/hooks/pre-tool-use.d.ts +11 -0
- package/dist/holmes/hooks/pre-tool-use.js +44 -5
- package/dist/holmes/hooks/session-start.js +17 -1
- package/dist/holmes/mcp/handlers/maintenance-analysis.d.ts +13 -0
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
- package/dist/holmes/mcp/handlers/test-execution.d.ts +470 -3
- package/dist/holmes/mcp/handlers/test-execution.js +199 -21
- package/dist/holmes/mcp/handlers.d.ts +468 -3
- package/dist/holmes/mcp/handlers.js +5 -1
- package/dist/holmes/mcp/maintenance-analyze.d.ts +5 -0
- package/dist/holmes/mcp/maintenance-analyze.js +4 -2
- package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
- package/dist/holmes/mcp/maintenance-evidence.js +4 -1
- package/dist/holmes/mcp/tool-schemas.js +13 -7
- package/dist/holmes/project/baseline.d.ts +15 -2
- package/dist/holmes/project/baseline.js +11 -6
- package/dist/holmes/project/bounded-io.d.ts +1 -0
- package/dist/holmes/project/bounded-io.js +4 -2
- package/dist/holmes/project/change-source.d.ts +4 -0
- package/dist/holmes/project/change-source.js +13 -5
- package/dist/holmes/project/root.js +3 -1
- package/dist/holmes/review/evidence-mode.d.ts +21 -0
- package/dist/holmes/review/evidence-mode.js +33 -0
- package/dist/holmes/review/head-worktree.d.ts +55 -0
- package/dist/holmes/review/head-worktree.js +329 -0
- package/dist/holmes/review/mrp.js +13 -3
- package/dist/holmes/review/run-provenance.d.ts +45 -0
- package/dist/holmes/review/run-provenance.js +314 -0
- package/dist/holmes/review/test-evidence.d.ts +174 -0
- package/dist/holmes/review/test-evidence.js +330 -2
- package/dist/holmes/review/test-reports.d.ts +94 -0
- package/dist/holmes/review/test-reports.js +382 -0
- package/dist/holmes/review/test-runner.d.ts +176 -65
- package/dist/holmes/review/test-runner.js +531 -316
- package/dist/holmes/review/test-units.d.ts +159 -0
- package/dist/holmes/review/test-units.js +814 -0
- package/package.json +1 -1
- package/playbooks/publish/PLAYBOOK.md +2 -1
|
@@ -33,15 +33,258 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.EVIDENCE_FILE = void 0;
|
|
36
|
+
exports.SCOPED_EVIDENCE_FILE = exports.EVIDENCE_FILE = void 0;
|
|
37
|
+
exports.coverageVerdict = coverageVerdict;
|
|
38
|
+
exports.idleUnits = idleUnits;
|
|
39
|
+
exports.noTestableCode = noTestableCode;
|
|
40
|
+
exports.recordShapeProblem = recordShapeProblem;
|
|
41
|
+
exports.idleEcosystems = idleEcosystems;
|
|
42
|
+
exports.attemptVerdict = attemptVerdict;
|
|
43
|
+
exports.pushEvidenceVerdict = pushEvidenceVerdict;
|
|
44
|
+
exports.pushEvidenceProblem = pushEvidenceProblem;
|
|
45
|
+
exports.isPushEvidence = isPushEvidence;
|
|
46
|
+
exports.isFullEvidence = isFullEvidence;
|
|
47
|
+
exports.evidenceKind = evidenceKind;
|
|
37
48
|
exports.computeExecutedByAspec = computeExecutedByAspec;
|
|
38
49
|
exports.isFresh = isFresh;
|
|
39
50
|
exports.writeTestEvidence = writeTestEvidence;
|
|
51
|
+
exports.removeTestEvidence = removeTestEvidence;
|
|
52
|
+
exports.voidTestEvidence = voidTestEvidence;
|
|
40
53
|
exports.readTestEvidence = readTestEvidence;
|
|
41
|
-
|
|
54
|
+
exports.writeScopedEvidence = writeScopedEvidence;
|
|
55
|
+
exports.readScopedEvidence = readScopedEvidence;
|
|
56
|
+
exports.testEvidenceState = testEvidenceState;
|
|
57
|
+
exports.scopedEvidenceState = scopedEvidenceState;
|
|
58
|
+
// @implements A-SPEC-102.1, A-SPEC-734, A-SPEC-466.2, A-SPEC-466.3, A-SPEC-466.6, A-SPEC-128.2, A-SPEC-128.4, A-SPEC-128.5, A-SPEC-128.6, A-SPEC-128.7, A-SPEC-128.8, A-SPEC-128.9, A-SPEC-128.10, A-SPEC-128.12, A-SPEC-128.13
|
|
42
59
|
const fs = __importStar(require("node:fs"));
|
|
43
60
|
const path = __importStar(require("node:path"));
|
|
44
61
|
const bounded_io_1 = require("../project/bounded-io");
|
|
62
|
+
const evidence_mode_1 = require("./evidence-mode");
|
|
63
|
+
/**
|
|
64
|
+
* @implements A-SPEC-128.10 — I3 and R2 read from a record, in that order: detected tests the runners did not report
|
|
65
|
+
* (`collect`), then build roots whose code saw no executed test (`fix-tests`, naming a missing build file).
|
|
66
|
+
*/
|
|
67
|
+
function coverageVerdict(r) {
|
|
68
|
+
const missing = isStringArray(r.notExecuted) ? r.notExecuted : [];
|
|
69
|
+
if (missing.length > 0) {
|
|
70
|
+
const shown = missing.slice(0, 5).join(', ') + (missing.length > 5 ? ` (+${missing.length - 5})` : '');
|
|
71
|
+
return { problem: `these test files did not run: ${shown} — make the runner collect them (its configuration), or, if they are not the project's, exclude them with .gitignore or ax.config.json testRun.excludeDirs`, act: 'collect' };
|
|
72
|
+
}
|
|
73
|
+
const untested = Array.isArray(r.untestedCode) ? r.untestedCode.filter((g) => g && typeof g === 'object') : [];
|
|
74
|
+
if (untested.length > 0) {
|
|
75
|
+
const named = untested.map((g) => {
|
|
76
|
+
const where = typeof g.root === 'string' && g.root !== '' ? g.root : '(root)';
|
|
77
|
+
if (typeof g.missingBuildFile === 'string')
|
|
78
|
+
return `${where}: no ${g.missingBuildFile} — add the build file and tests`;
|
|
79
|
+
// @implements A-SPEC-128.13 (L2) — a root that holds test files is not told to write them
|
|
80
|
+
return isCount(g.testFiles) && g.testFiles > 0
|
|
81
|
+
? `${where}: ${g.testFiles} test file(s) here, none executed and credited — fix them so the runner runs them`
|
|
82
|
+
: `${where}: code with no executed test — write tests`;
|
|
83
|
+
}).join('; ');
|
|
84
|
+
return { problem: `${named} — 고칠 것은 시험입니다`, act: 'fix-tests' };
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
/** @implements A-SPEC-128.9 — the units of a record that ran no test (each unit must run at least one). */
|
|
89
|
+
function idleUnits(r) {
|
|
90
|
+
if (!Array.isArray(r.units))
|
|
91
|
+
return [];
|
|
92
|
+
return r.units
|
|
93
|
+
.filter((u) => u && typeof u === 'object' && !(isCount(u.testsRun) && u.testsRun >= 1) && typeof u.environment !== 'string')
|
|
94
|
+
.map((u) => `${String(u.ecosystem)}${u.dir ? ` @ ${String(u.dir)}` : ''}`);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @implements A-SPEC-128.9 — E2: a full attempt at `head` that ran nothing, has no unit and counts no implementation code
|
|
98
|
+
* — nothing is testable (owner decision 1, corrected 2026-11-06: README, settings, docs only). Allowed with a record.
|
|
99
|
+
*/
|
|
100
|
+
function noTestableCode(s, head) {
|
|
101
|
+
if (!s || s.mode !== 'full-attempt' || s.head !== head || s.judged === false)
|
|
102
|
+
return false;
|
|
103
|
+
// @implements A-SPEC-128.12 — a run that names an environment (a configuration outside the 0.40.x surface, whose
|
|
104
|
+
// units are not started) is never "nothing to test": a cargo crate whose only code holds its tests passed here
|
|
105
|
+
// @implements A-SPEC-128.13 — and only with no test file at all: rust, java or go tests under no build root of their
|
|
106
|
+
// language held no unit and no code, and passed as "nothing to test" (A H4)
|
|
107
|
+
return Array.isArray(s.units) && s.units.length === 0 && s.implementationCount === 0 && s.testFileCount === 0
|
|
108
|
+
&& (s.ranWith === undefined || (isStringArray(s.ranWith) && s.ranWith.length === 0))
|
|
109
|
+
&& !(Array.isArray(s.environment) && s.environment.length > 0);
|
|
110
|
+
}
|
|
111
|
+
const isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === 'string');
|
|
112
|
+
const isPlainObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) && Object.getPrototypeOf(v) === Object.prototype;
|
|
113
|
+
const isCount = (n) => typeof n === 'number' && Number.isInteger(n) && n >= 0;
|
|
114
|
+
/**
|
|
115
|
+
* @implements A-SPEC-128.7 — fail-closed shape: a field that is present with the wrong shape is named. A string `detected`
|
|
116
|
+
* passed the predicate as "nothing detected", and a string `missing` threw inside the gate, which exited 0 (A L1, B M1).
|
|
117
|
+
*/
|
|
118
|
+
function recordShapeProblem(r, opts) {
|
|
119
|
+
if (opts.requireDetected ? !isStringArray(r.detected) : r.detected !== undefined && !isStringArray(r.detected)) {
|
|
120
|
+
return `detected ${JSON.stringify(r.detected) ?? 'absent'} is not a list of ecosystem names`;
|
|
121
|
+
}
|
|
122
|
+
if (r.missing !== undefined && !isStringArray(r.missing))
|
|
123
|
+
return `missing ${JSON.stringify(r.missing)} is not a list of ecosystem names`;
|
|
124
|
+
if (r.failedBy !== undefined && !isStringArray(r.failedBy))
|
|
125
|
+
return `failedBy ${JSON.stringify(r.failedBy)} is not a list of ecosystem names`;
|
|
126
|
+
if (r.testsRunBy !== undefined) {
|
|
127
|
+
if (!isPlainObject(r.testsRunBy))
|
|
128
|
+
return `testsRunBy ${JSON.stringify(r.testsRunBy)} is not an object of counts`;
|
|
129
|
+
const bad = Object.entries(r.testsRunBy).find(([, n]) => !isCount(n));
|
|
130
|
+
if (bad)
|
|
131
|
+
return `testsRunBy.${bad[0]} ${JSON.stringify(bad[1])} is not a count`;
|
|
132
|
+
const sum = Object.values(r.testsRunBy).reduce((a, b) => a + b, 0);
|
|
133
|
+
if (typeof r.testsRun === 'number' && r.testsRun !== sum)
|
|
134
|
+
return `testsRun ${r.testsRun} ≠ the sum of testsRunBy (${sum})`;
|
|
135
|
+
}
|
|
136
|
+
if (r.detectedBy !== undefined && !(isPlainObject(r.detectedBy) && Object.values(r.detectedBy).every((p) => typeof p === 'string'))) {
|
|
137
|
+
return 'detectedBy is not an object of paths';
|
|
138
|
+
}
|
|
139
|
+
for (const k of ['notRun', 'notDetected', 'units', 'environment', 'notExecuted', 'untestedCode'])
|
|
140
|
+
if (r[k] !== undefined && !Array.isArray(r[k]))
|
|
141
|
+
return `${k} is not a list`;
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
/** @implements A-SPEC-128.7 — the detected ecosystems that ran no test: one reading for the predicate, the writer and the gate. */
|
|
145
|
+
function idleEcosystems(r) {
|
|
146
|
+
const by = isPlainObject(r.testsRunBy) ? r.testsRunBy : {};
|
|
147
|
+
return (isStringArray(r.detected) ? r.detected : []).filter((eco) => !(isCount(by[eco]) && by[eco] >= 1));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @implements A-SPEC-128.7 — ecosystems that ran nothing or ran red, named with where each was found.
|
|
151
|
+
* @implements A-SPEC-128.8 — always `fix-tests` (D1): a red is a red whichever tree ran it, and whether a tree is the
|
|
152
|
+
* project's is the user's to declare (excludeDirs), never the gate's to suggest. The tree is the root's by build roots
|
|
153
|
+
* (D2), so what is named here is something the root's runner ran.
|
|
154
|
+
*/
|
|
155
|
+
function ecosystemVerdict(ecos, detectedBy, what) {
|
|
156
|
+
const where = ecos.map((eco) => (isPlainObject(detectedBy) && typeof detectedBy[eco] === 'string' ? `${eco} (${detectedBy[eco]})` : eco));
|
|
157
|
+
return { problem: `${where.join(', ')} ${what} — 고칠 것은 시험입니다`, act: 'fix-tests' };
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @implements A-SPEC-128.7 — a failed full attempt, read wherever it lies (scoped-evidence, or test-evidence it voided in
|
|
161
|
+
* place). Its words follow I2: a stopped run → a larger budget; a red or idle ecosystem → its owner's act; another head
|
|
162
|
+
* → that head named.
|
|
163
|
+
*/
|
|
164
|
+
function attemptVerdict(s, head) {
|
|
165
|
+
const shape = recordShapeProblem(s, { requireDetected: false });
|
|
166
|
+
if (shape)
|
|
167
|
+
return { problem: `the full-attempt record is malformed: ${shape}`, act: 'rerun' };
|
|
168
|
+
const at = typeof s.head === 'string' && s.head !== head ? ` (attempt at head ${s.head.slice(0, 7)}, not the push head ${head.slice(0, 7)})` : '';
|
|
169
|
+
// @implements A-SPEC-128.8 — the run that counts is at the pushed head: check it out there (A M3)
|
|
170
|
+
if (at)
|
|
171
|
+
return { problem: `only a full attempt at another head${at} — check out ${head.slice(0, 7)} and run the full call there`, act: 'rerun' };
|
|
172
|
+
if (s.judged === false) {
|
|
173
|
+
const t = isCount(s.timeoutMinutes) ? s.timeoutMinutes : evidence_mode_1.FULL_RUN_DEFAULT_MINUTES;
|
|
174
|
+
// @implements A-SPEC-128.9 — E4: at the ceiling no larger budget exists; the suite or the owner decides (never an
|
|
175
|
+
// exclusion: following "narrow it with excludeDirs" hid a red suite, review 07:47 A H1)
|
|
176
|
+
if (t >= evidence_mode_1.RUN_MINUTES_CEILING) {
|
|
177
|
+
return { problem: `the full attempt was stopped at the ${evidence_mode_1.RUN_MINUTES_CEILING}-minute ceiling — 실행 환경 문제입니다: split the suite so it finishes within the ceiling, or ask the owner how this repository is verified`, act: 'environment' };
|
|
178
|
+
}
|
|
179
|
+
// @implements A-SPEC-128.8 — the same builder as the test_run answer's nextCall
|
|
180
|
+
return { problem: `the full attempt was stopped at its budget and not judged — next: ${(0, evidence_mode_1.nextFullCall)(t, isCount(s.workers) ? s.workers : undefined)}`, act: 'rerun' };
|
|
181
|
+
}
|
|
182
|
+
const detected = isStringArray(s.detected) ? s.detected : [];
|
|
183
|
+
// @implements A-SPEC-128.9 — E4: a unit whose runner is missing cannot be cleared by a test change or a re-run here
|
|
184
|
+
const env = Array.isArray(s.environment) ? s.environment.filter((e) => e && typeof e === 'object') : [];
|
|
185
|
+
if (s.passed !== true) {
|
|
186
|
+
if (env.length > 0) {
|
|
187
|
+
const named = env.map((e) => `${String(e.ecosystem)}${e.dir ? ` @ ${String(e.dir)}` : ''}: ${String(e.reason)}`).join('; ');
|
|
188
|
+
// @implements A-SPEC-128.12 — the reason is named as the run gave it: a missing runner, an unreadable output, a
|
|
189
|
+
// configuration outside the 0.40.x surface, an excluded tree's test that ran, a sparse or changed work tree
|
|
190
|
+
return { problem: `실행 환경 문제입니다 — ${named}; 이 상태에서는 증빙할 수 없습니다: 사유대로 고친 뒤(러너 설치, 설정, 커밋) full 호출을 다시 하거나 오너에게 묻습니다`, act: 'environment' };
|
|
191
|
+
}
|
|
192
|
+
// @implements A-SPEC-128.10 — a red is always fix-tests; where a build root ran nothing, its words say what is missing
|
|
193
|
+
// (a build file, or tests) — a red that ran nothing is the code without tests, not a failing test
|
|
194
|
+
const red = coverageVerdict({ untestedCode: s.untestedCode });
|
|
195
|
+
if (red)
|
|
196
|
+
return red;
|
|
197
|
+
const failed = isStringArray(s.failedBy) ? s.failedBy : [];
|
|
198
|
+
if (failed.length > 0)
|
|
199
|
+
return ecosystemVerdict(failed, s.detectedBy, 'ran red');
|
|
200
|
+
if (detected.length === 0 && s.testsRun === 0) {
|
|
201
|
+
return { problem: '프로젝트에 실행할 시험이 없습니다 (implementation code without tests, testsRun 0) — 고칠 것은 시험입니다: write tests for it', act: 'fix-tests' };
|
|
202
|
+
}
|
|
203
|
+
return { problem: 'a red full run (passed: false) — 고칠 것은 시험입니다', act: 'fix-tests' };
|
|
204
|
+
}
|
|
205
|
+
// @implements A-SPEC-128.10 — a green run is evidence only if it ran what exists (I3) and tested every build root (R2)
|
|
206
|
+
const coverage = coverageVerdict(s);
|
|
207
|
+
if (coverage)
|
|
208
|
+
return coverage;
|
|
209
|
+
// @implements A-SPEC-128.9 — every unit must run a test: a unit that ran none is code without running tests
|
|
210
|
+
const idle = idleUnits(s);
|
|
211
|
+
if (idle.length > 0)
|
|
212
|
+
return { problem: `${idle.join(', ')} ran no test — 고칠 것은 시험입니다 (all skipped, none collected, or no tests written)`, act: 'fix-tests' };
|
|
213
|
+
const missing = isStringArray(s.missing) && s.missing.length > 0 ? s.missing : idleEcosystems(s);
|
|
214
|
+
if (missing.length > 0)
|
|
215
|
+
return ecosystemVerdict(missing, s.detectedBy, 'ran no test (testsRunBy)');
|
|
216
|
+
return { problem: 'a full attempt, not evidence', act: 'rerun' };
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @implements A-SPEC-128.6 — THE push-evidence predicate: the writer (whether to write test-evidence), the push gate and
|
|
220
|
+
* the merge-ready package all read it. Null when `r` is push evidence for `head`; otherwise the first failing condition,
|
|
221
|
+
* in words a refusal can carry. A summed count hid an ecosystem that ran nothing (review 2026-11-05 20:34, A H1).
|
|
222
|
+
* @implements A-SPEC-128.7 — with the act that clears it (I2), and fail-closed on shape.
|
|
223
|
+
*/
|
|
224
|
+
function pushEvidenceVerdict(r, head) {
|
|
225
|
+
if (!r)
|
|
226
|
+
return { problem: 'no record', act: 'rerun' };
|
|
227
|
+
// @implements A-SPEC-128.7 — an attempt that voided the evidence in place is read as the attempt it is
|
|
228
|
+
if (r.mode === 'full-attempt')
|
|
229
|
+
return attemptVerdict(r, head);
|
|
230
|
+
if (!isFullEvidence(r))
|
|
231
|
+
return { problem: `not a full run (${evidenceKind(r)})`, act: 'rerun' };
|
|
232
|
+
if (r.head !== head) {
|
|
233
|
+
// @implements A-SPEC-128.8 — the evidence is per head: the pushed head is checked out and run (A M3)
|
|
234
|
+
return { problem: `head ${String(r.head ?? '').slice(0, 7)} ≠ push head ${head.slice(0, 7)} — check out ${head.slice(0, 7)} and run the full call there; push several branches one at a time`, act: 'rerun' };
|
|
235
|
+
}
|
|
236
|
+
if (r.passed !== true)
|
|
237
|
+
return { problem: 'a red run (passed: false) — 고칠 것은 시험입니다', act: 'fix-tests' };
|
|
238
|
+
// @implements A-SPEC-128.13 — W6: only a run of HEAD itself (its clean worktree) is evidence for a commit; a record from
|
|
239
|
+
// the work tree (before 128.13) may have run files the commit does not hold. A tree with no commit (head '') has no
|
|
240
|
+
// worktree to run and is never pushed; its full run still records its baseline (REQ-128).
|
|
241
|
+
if (head !== '' && r.ranIn !== 'head-worktree') {
|
|
242
|
+
return { problem: "not a run of HEAD's own worktree (a full run before 0.40.x 128.13 ran the work tree) — run the full call again", act: 'rerun' };
|
|
243
|
+
}
|
|
244
|
+
if (r.testsRun === undefined)
|
|
245
|
+
return { problem: 'testsRun absent', act: 'rerun' };
|
|
246
|
+
if (r.testsRun === 0) {
|
|
247
|
+
return isStringArray(r.ranWith) && r.ranWith.length > 0
|
|
248
|
+
? { problem: `testsRun 0 — ${r.ranWith.join(', ')} ran but executed no test — 고칠 것은 시험입니다`, act: 'fix-tests' }
|
|
249
|
+
: { problem: 'testsRun 0 — no ecosystem ran', act: 'rerun' };
|
|
250
|
+
}
|
|
251
|
+
if (typeof r.testsRun !== 'number' || !Number.isInteger(r.testsRun) || r.testsRun < 1)
|
|
252
|
+
return { problem: `testsRun ${String(r.testsRun)} is not an integer of at least 1`, act: 'rerun' };
|
|
253
|
+
if (!r.testsRunBy)
|
|
254
|
+
return { problem: 'testsRunBy absent', act: 'rerun' };
|
|
255
|
+
const shape = recordShapeProblem(r, { requireDetected: true });
|
|
256
|
+
if (shape)
|
|
257
|
+
return { problem: shape, act: 'rerun' };
|
|
258
|
+
const idle = idleEcosystems(r);
|
|
259
|
+
if (idle.length > 0)
|
|
260
|
+
return ecosystemVerdict(idle, r.detectedBy, 'ran no test (testsRunBy)');
|
|
261
|
+
// @implements A-SPEC-128.9 — per unit too: a module that ran no test hides behind another unit of its ecosystem
|
|
262
|
+
const idleU = idleUnits(r);
|
|
263
|
+
if (idleU.length > 0)
|
|
264
|
+
return { problem: `${idleU.join(', ')} ran no test — 고칠 것은 시험입니다`, act: 'fix-tests' };
|
|
265
|
+
// @implements A-SPEC-128.10 — I3, R2
|
|
266
|
+
return coverageVerdict(r);
|
|
267
|
+
}
|
|
268
|
+
/** @implements A-SPEC-128.6 — the predicate's words; @implements A-SPEC-128.7 — the verdict's problem. */
|
|
269
|
+
function pushEvidenceProblem(r, head) {
|
|
270
|
+
return pushEvidenceVerdict(r, head)?.problem ?? null;
|
|
271
|
+
}
|
|
272
|
+
/** @implements A-SPEC-128.6 — `pushEvidenceProblem(...) === null`. */
|
|
273
|
+
function isPushEvidence(r, head) {
|
|
274
|
+
return pushEvidenceVerdict(r, head) === null;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @implements A-SPEC-128.2 — what counts as full evidence, in one place: a run whose mode AND tier were full. A record
|
|
278
|
+
* without a mode (written before 128.2, when a scoped green could land here) is not full evidence.
|
|
279
|
+
* @implements A-SPEC-128.4 — the write side decides with this same predicate, over the shared token.
|
|
280
|
+
*/
|
|
281
|
+
function isFullEvidence(ev) {
|
|
282
|
+
return !!ev && ev.mode === evidence_mode_1.FULL_MODE && ev.tier === evidence_mode_1.FULL_MODE;
|
|
283
|
+
}
|
|
284
|
+
/** The words a refusal uses for a record that is not full evidence: its tier and mode, `absent` when it has none. */
|
|
285
|
+
function evidenceKind(ev) {
|
|
286
|
+
return `tier ${typeof ev.tier === 'string' ? ev.tier : 'absent'}, mode ${typeof ev.mode === 'string' ? ev.mode : 'absent'}`;
|
|
287
|
+
}
|
|
45
288
|
/** Map per-test-file executed counts onto the A-SPECs those files @implement (pure). */
|
|
46
289
|
function computeExecutedByAspec(executedByFile, testAnchors) {
|
|
47
290
|
const out = {};
|
|
@@ -67,6 +310,36 @@ function writeTestEvidence(root, ev) {
|
|
|
67
310
|
return false;
|
|
68
311
|
} // evidence recording must never break a run
|
|
69
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* @implements A-SPEC-128.6 — a newer failed full attempt supersedes older evidence: the writer removes it, so the gate's
|
|
315
|
+
* newest observation is the attempt (a green-then-red at one head passed the gate before, review 2026-11-05 20:34).
|
|
316
|
+
*/
|
|
317
|
+
function removeTestEvidence(root) {
|
|
318
|
+
try {
|
|
319
|
+
fs.rmSync(path.join(root, exports.EVIDENCE_FILE), { force: true });
|
|
320
|
+
}
|
|
321
|
+
catch { /* nothing to remove */ }
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* @implements A-SPEC-128.7 — void the older test-evidence after an attempt, so it can never stand beside it. With the
|
|
325
|
+
* attempt written, the evidence is removed; when it cannot be removed, or the attempt could not be written (nothing else
|
|
326
|
+
* would record the red run), the attempt is written over test-evidence in place — a record that is not full evidence.
|
|
327
|
+
* A read-only ledger directory left a green record standing after a red run (review 2026-11-06 00:16, A M2).
|
|
328
|
+
* True when no full evidence stands afterwards.
|
|
329
|
+
*/
|
|
330
|
+
function voidTestEvidence(root, attemptRecord, attemptWritten) {
|
|
331
|
+
const file = path.join(root, exports.EVIDENCE_FILE);
|
|
332
|
+
if (attemptWritten) {
|
|
333
|
+
removeTestEvidence(root);
|
|
334
|
+
if (!fs.existsSync(file))
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
try {
|
|
338
|
+
fs.writeFileSync(file, JSON.stringify(attemptRecord, null, 2), 'utf8');
|
|
339
|
+
}
|
|
340
|
+
catch { /* read back below */ }
|
|
341
|
+
return !isFullEvidence(readTestEvidence(root));
|
|
342
|
+
}
|
|
70
343
|
function readTestEvidence(root) {
|
|
71
344
|
try {
|
|
72
345
|
const ev = JSON.parse((0, bounded_io_1.readRegularTextSync)(path.join(root, exports.EVIDENCE_FILE)));
|
|
@@ -76,3 +349,58 @@ function readTestEvidence(root) {
|
|
|
76
349
|
return undefined;
|
|
77
350
|
}
|
|
78
351
|
}
|
|
352
|
+
exports.SCOPED_EVIDENCE_FILE = path.join('.ax', 'ledger', 'scoped-evidence.json');
|
|
353
|
+
/** @implements A-SPEC-128.2 — fail-open like writeTestEvidence: recording never breaks a run. */
|
|
354
|
+
function writeScopedEvidence(root, ev) {
|
|
355
|
+
try {
|
|
356
|
+
const file = path.join(root, exports.SCOPED_EVIDENCE_FILE);
|
|
357
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
358
|
+
fs.writeFileSync(file, JSON.stringify(ev, null, 2), 'utf8');
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/** @implements A-SPEC-128.2 — the scoped record's own reader; a missing or unreadable record is absent. */
|
|
366
|
+
function readScopedEvidence(root) {
|
|
367
|
+
try {
|
|
368
|
+
const ev = JSON.parse((0, bounded_io_1.readRegularTextSync)(path.join(root, exports.SCOPED_EVIDENCE_FILE)));
|
|
369
|
+
return ev && typeof ev === 'object' && typeof ev.head === 'string' && (ev.mode === 'scoped' || ev.mode === 'full-attempt') ? ev : undefined;
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* @implements A-SPEC-128.5 — the same three states for test-evidence: a file that exists but is not a record is a run
|
|
377
|
+
* history the push gate cannot read, so it refuses rather than taking the unrun pass (decided 2026-11-05 19:58).
|
|
378
|
+
*/
|
|
379
|
+
function testEvidenceState(root) {
|
|
380
|
+
const evidence = readTestEvidence(root);
|
|
381
|
+
if (evidence)
|
|
382
|
+
return { state: 'valid', evidence };
|
|
383
|
+
let present = false;
|
|
384
|
+
try {
|
|
385
|
+
fs.lstatSync(path.join(root, exports.EVIDENCE_FILE));
|
|
386
|
+
present = true;
|
|
387
|
+
}
|
|
388
|
+
catch { /* absent */ }
|
|
389
|
+
return { state: present ? 'unreadable' : 'absent' };
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* @implements A-SPEC-128.4 — absent, valid, or present but not a record. A file that exists is a run history even when it
|
|
393
|
+
* cannot be read, so the push gate refuses on `unreadable` rather than taking the unrun pass.
|
|
394
|
+
*/
|
|
395
|
+
function scopedEvidenceState(root) {
|
|
396
|
+
const evidence = readScopedEvidence(root);
|
|
397
|
+
if (evidence)
|
|
398
|
+
return { state: 'valid', evidence };
|
|
399
|
+
let present = false;
|
|
400
|
+
try {
|
|
401
|
+
fs.lstatSync(path.join(root, exports.SCOPED_EVIDENCE_FILE));
|
|
402
|
+
present = true;
|
|
403
|
+
}
|
|
404
|
+
catch { /* absent */ }
|
|
405
|
+
return { state: present ? 'unreadable' : 'absent' };
|
|
406
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Written under A-SPEC-137.1.
|
|
3
|
+
* Executed-test counts per Go package from `go test -json` output. A test is EXECUTED when a NAMED
|
|
4
|
+
* test (`Test` present) reaches `Action: 'pass'` or `'fail'` — a skip does not count (matching the
|
|
5
|
+
* jest/pytest rule), and a package-level result (no `Test`) is not a test case. Non-JSON lines (go
|
|
6
|
+
* interleaves build output) are ignored. Pure; empty/garbage input yields `{}` rather than throwing.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseGoTestJson(out: string): Record<string, number>;
|
|
9
|
+
/**
|
|
10
|
+
* Written under A-SPEC-128.12 (S2/S6), moved here by A-SPEC-128.13 (SRP): a unit's report without the tests it reported
|
|
11
|
+
* under its excluded trees (`ignore`, unit-relative; a tree ends in `/`), and the root-relative names of those that ran
|
|
12
|
+
* red. Counts are recomputed from what is kept, so an excluded green neither counts nor credits code.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withoutExcluded<R extends {
|
|
15
|
+
passed: boolean;
|
|
16
|
+
executed: Record<string, number>;
|
|
17
|
+
outcomes?: Record<string, TestOutcome>;
|
|
18
|
+
testsRun?: number;
|
|
19
|
+
reported?: string[];
|
|
20
|
+
}>(raw: R, ignore: readonly string[], dir: string): {
|
|
21
|
+
r: R;
|
|
22
|
+
excludedRed: string[];
|
|
23
|
+
};
|
|
24
|
+
/** A-SPEC-128.13 T1: the named tests `go test -json` reported as failed, whatever the process's exit code. */
|
|
25
|
+
export declare function goFailedTests(out: string): string[];
|
|
26
|
+
/**
|
|
27
|
+
* A-SPEC-128.13 T1: whether a jest `--json` report holds a failure — a failed test, a suite that could not run, or a
|
|
28
|
+
* failed result — whatever the process's exit code (`testFailureExitCode: 0` exits 0 over a red).
|
|
29
|
+
*/
|
|
30
|
+
export declare function jestReportFailed(report: string): boolean;
|
|
31
|
+
/** Written under A-SPEC-128.11 (P5): the packages in `go test -json` output where a named test passed, failed or skipped. */
|
|
32
|
+
export declare function goPackagesWithTestEvents(out: string): Set<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Parse jest --json output into per-file EXECUTED case counts. This is the execution-proof upgrade
|
|
35
|
+
* over the syntactic countTestCases lower bound: a case only appears here if jest actually ran it
|
|
36
|
+
* (pending/skipped assertions are excluded), so `if(false){it(…)}`, aliasing, and other syntactic
|
|
37
|
+
* fabrications cannot produce evidence. Returns {} for unparseable output (caller falls back).
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseExecutedCounts(stdout: string, cwd: string): Record<string, number>;
|
|
40
|
+
/**
|
|
41
|
+
* Written under A-SPEC-534.1.
|
|
42
|
+
* Per-file test outcome for RED-first evidence (REQ-534). `red-assertion` is a REAL red — a case ran
|
|
43
|
+
* and its assertion failed; `red-error` is a file that could not run its cases (load/collection/import
|
|
44
|
+
* error), which ART-8 (534.2) must NOT accept as a valid RED; `green` ran and all assertions passed.
|
|
45
|
+
*/
|
|
46
|
+
export type TestOutcome = 'red-assertion' | 'red-error' | 'green';
|
|
47
|
+
/**
|
|
48
|
+
* Written under A-SPEC-534.1.
|
|
49
|
+
* Classify each jest-executed file into red-assertion | red-error | green from `jest --json` stdout.
|
|
50
|
+
* Pure; unparseable/empty input → {} (same fail-soft convention as parseExecutedCounts).
|
|
51
|
+
*
|
|
52
|
+
* A failed assertion anywhere in a file wins (`red-assertion`) — that is a real red. A file that ran
|
|
53
|
+
* NO assertions but errored (testExecError, or status 'failed' with an empty assertion list — a
|
|
54
|
+
* load/collection/import failure) is `red-error`, which ART-8 must not accept as a valid RED. A file
|
|
55
|
+
* that executed ≥1 assertion with none failing is `green`. A file that only pended/skipped carries no
|
|
56
|
+
* evidence and is omitted entirely.
|
|
57
|
+
*/
|
|
58
|
+
export declare function classifyJestOutcomes(stdout: string, cwd: string): Record<string, TestOutcome>;
|
|
59
|
+
/**
|
|
60
|
+
* Parse pytest's built-in JUnit XML into per-file EXECUTED case counts — the pytest analogue of
|
|
61
|
+
* parseExecutedCounts. `--junit-xml` ships with pytest core, so this needs no plugin, and it is the
|
|
62
|
+
* only pytest output that is both machine-readable and per-file.
|
|
63
|
+
*
|
|
64
|
+
* A `<testcase>` counts as executed unless it carries `<skipped>`, matching the jest rule where
|
|
65
|
+
* pending/skipped assertions are excluded. Errors and failures DO count: they executed.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseJUnitXmlCounts(xml: string, ext?: string): Record<string, number>;
|
|
68
|
+
/**
|
|
69
|
+
* Written under A-SPEC-647.
|
|
70
|
+
* Per-file RED-first outcome from the same JUnit XML `parseJUnitXmlCounts` reads. Measured 2026-09-14
|
|
71
|
+
* in an external pytest project: a ranged test_run executed the anchored case and recorded NOTHING,
|
|
72
|
+
* because classification was jest-only — a Python project could never produce the red-assertion→green
|
|
73
|
+
* sequence ART-8 reads. `<error>` (collection/import/setup) is a red-error, `<failure>` (an assertion)
|
|
74
|
+
* a red-assertion, executed cases without either are green; a file with only skipped cases says nothing.
|
|
75
|
+
*/
|
|
76
|
+
export declare function parseJUnitXmlOutcomes(xml: string, ext?: string): Record<string, TestOutcome>;
|
|
77
|
+
/** Written under A-SPEC-128.10: the files a JUnit report names, skipped cases included (what the runner collected). */
|
|
78
|
+
export declare function parseJUnitXmlFiles(xml: string): string[];
|
|
79
|
+
/**
|
|
80
|
+
* Written under A-SPEC-128.11 (P3): the first well-shaped JSON block in a runner's output, or null. A block starts on a
|
|
81
|
+
* line beginning with `{` or `[` and ends on a line ending with `}` or `]`; it counts only when `accept` holds. The
|
|
82
|
+
* user's own console output (a config logging `[dotenv] …` or `{…}`) is never mistaken for the runner's, and nothing is
|
|
83
|
+
* defaulted.
|
|
84
|
+
*/
|
|
85
|
+
export declare function wellShapedJson<T>(out: string, accept: (v: unknown) => v is T): T | null;
|
|
86
|
+
/** S2/S7: `jest --showConfig`'s document — an object with a `configs` array. */
|
|
87
|
+
export declare const isJestConfig: (v: unknown) => v is {
|
|
88
|
+
configs: unknown[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Written under A-SPEC-128.11 (P3): jest's `--json` report, from its `--outputFile` when jest wrote one, else from a
|
|
92
|
+
* well-shaped document on stdout (an object with a `testResults` array). Null when neither reads.
|
|
93
|
+
*/
|
|
94
|
+
export declare function readJestReport(file: string | null, stdout: string): string | null;
|