@kirill.konshin/lint 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/rules/github.md +3 -1
- package/rules/gitlab.md +2 -5
- package/rules/nx.md +1 -0
- package/skills/lint-github/SKILL.md +214 -42
- package/skills/lint-gitlab/SKILL.md +24 -0
- package/skills/spec-tools/SKILL.md +1 -1
- package/skills/spec-tools/references/contract.md +34 -10
- package/skills/spec-tools/references/gitlab.md +4 -3
- package/skills/spec-tools/references/rules/common.md +20 -10
- package/skills/spec-tools/references/rules/spec-verify-judge.md +9 -8
- package/skills/spec-tools/references/rules/spec-verify.md +7 -3
- package/skills/spec-tools/scripts/cli.js +418 -257
- package/skills/spec-verify/SKILL.md +10 -10
|
@@ -6830,7 +6830,7 @@ function checkData(text, schema) {
|
|
|
6830
6830
|
validate(doc.toJS({ maxAliasCount: -1 }), schema, "", errors);
|
|
6831
6831
|
return errors;
|
|
6832
6832
|
}
|
|
6833
|
-
var import_dist$1, toYaml, readData, parseErrors, MAX_ERRORS, checkFile, str, optStr, strings, optStrings, CONFIDENCE,
|
|
6833
|
+
var import_dist$1, toYaml, readData, parseErrors, MAX_ERRORS, checkFile, str, optStr, strings, optStrings, CONFIDENCE, SEVERITY, READER_FINDINGS, JUDGE_VERDICT, STEWARD_FINDINGS, STEWARD_VERDICT, REVIEW_REPORT;
|
|
6834
6834
|
var init_data = __esmMin((() => {
|
|
6835
6835
|
import_dist$1 = require_dist();
|
|
6836
6836
|
toYaml = (data) => (0, import_dist$1.stringify)(data, {
|
|
@@ -6860,13 +6860,10 @@ var init_data = __esmMin((() => {
|
|
|
6860
6860
|
min: 0,
|
|
6861
6861
|
max: 100
|
|
6862
6862
|
};
|
|
6863
|
-
|
|
6864
|
-
type: "
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
"WARN",
|
|
6868
|
-
"INFO"
|
|
6869
|
-
]
|
|
6863
|
+
SEVERITY = {
|
|
6864
|
+
type: "integer",
|
|
6865
|
+
min: 0,
|
|
6866
|
+
max: 100
|
|
6870
6867
|
};
|
|
6871
6868
|
READER_FINDINGS = {
|
|
6872
6869
|
type: "object",
|
|
@@ -6886,7 +6883,7 @@ var init_data = __esmMin((() => {
|
|
|
6886
6883
|
type: "object",
|
|
6887
6884
|
fields: {
|
|
6888
6885
|
kind: str,
|
|
6889
|
-
|
|
6886
|
+
readerSeverity: SEVERITY,
|
|
6890
6887
|
where: str,
|
|
6891
6888
|
detail: str,
|
|
6892
6889
|
readerConfidence: CONFIDENCE,
|
|
@@ -6919,13 +6916,10 @@ var init_data = __esmMin((() => {
|
|
|
6919
6916
|
JUDGE_VERDICT = {
|
|
6920
6917
|
type: "object",
|
|
6921
6918
|
fields: {
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
values: ["confirmed", "warn"]
|
|
6925
|
-
},
|
|
6919
|
+
judgeSeverity: SEVERITY,
|
|
6920
|
+
judgeConfidence: CONFIDENCE,
|
|
6926
6921
|
reason: str,
|
|
6927
|
-
scenario: optStr
|
|
6928
|
-
judgeConfidence: CONFIDENCE
|
|
6922
|
+
scenario: optStr
|
|
6929
6923
|
}
|
|
6930
6924
|
};
|
|
6931
6925
|
STEWARD_FINDINGS = {
|
|
@@ -6996,7 +6990,7 @@ var init_data = __esmMin((() => {
|
|
|
6996
6990
|
items: {
|
|
6997
6991
|
type: "object",
|
|
6998
6992
|
fields: {
|
|
6999
|
-
|
|
6993
|
+
readerSeverity: SEVERITY,
|
|
7000
6994
|
where: str,
|
|
7001
6995
|
detail: str,
|
|
7002
6996
|
readerConfidence: CONFIDENCE,
|
|
@@ -7880,7 +7874,7 @@ function loadCorpus(root, { name = path.basename(root), specsDir = DEFAULT_SPECS
|
|
|
7880
7874
|
specsDir,
|
|
7881
7875
|
capabilities: walkSpecs(path.join(root, specsDir)).map((p) => {
|
|
7882
7876
|
const file = path.relative(root, p).split(path.sep).join("/");
|
|
7883
|
-
return parseSpec(fs.readFileSync(p, "utf8"), file, capabilityOf$
|
|
7877
|
+
return parseSpec(fs.readFileSync(p, "utf8"), file, capabilityOf$2(specsDir, file));
|
|
7884
7878
|
})
|
|
7885
7879
|
};
|
|
7886
7880
|
}
|
|
@@ -7892,10 +7886,10 @@ function loadCorpusAt(root, ref, { name = path.basename(root), specsDir = DEFAUL
|
|
|
7892
7886
|
name,
|
|
7893
7887
|
path: root,
|
|
7894
7888
|
specsDir,
|
|
7895
|
-
capabilities: files.map((file) => parseSpec(texts.get(file) ?? "", file, capabilityOf$
|
|
7889
|
+
capabilities: files.map((file) => parseSpec(texts.get(file) ?? "", file, capabilityOf$2(specsDir, file)))
|
|
7896
7890
|
};
|
|
7897
7891
|
}
|
|
7898
|
-
var DEFAULT_SPECS_DIR, DEFAULT_MARKERS, ADVISORY, KNOWN_GAP, RETIRED, MARKER, INLINE_MARKER, STEP, LABELS, QUOTES, capabilityOf$
|
|
7892
|
+
var DEFAULT_SPECS_DIR, DEFAULT_MARKERS, ADVISORY, KNOWN_GAP, RETIRED, MARKER, INLINE_MARKER, STEP, LABELS, QUOTES, capabilityOf$2, allRequirements, gapExempts;
|
|
7899
7893
|
var init_corpus = __esmMin((() => {
|
|
7900
7894
|
init_git();
|
|
7901
7895
|
init_util();
|
|
@@ -7920,7 +7914,7 @@ var init_corpus = __esmMin((() => {
|
|
|
7920
7914
|
`_…_`,
|
|
7921
7915
|
`*…*`
|
|
7922
7916
|
];
|
|
7923
|
-
capabilityOf$
|
|
7917
|
+
capabilityOf$2 = (specsDir, file) => path.relative(specsDir, path.dirname(file)).split(path.sep).join("/");
|
|
7924
7918
|
allRequirements = (corpus) => corpus.capabilities.flatMap((c) => c.requirements);
|
|
7925
7919
|
gapExempts = (r, s) => r.gaps.some((g) => g.exempts.includes(s.slug));
|
|
7926
7920
|
}));
|
|
@@ -8519,7 +8513,7 @@ var init_coverage = __esmMin((() => {
|
|
|
8519
8513
|
*/
|
|
8520
8514
|
/** The non-test source files of a repository, read once, comments blanked for searching. */
|
|
8521
8515
|
function sourceIndex(root) {
|
|
8522
|
-
return (listFiles(root) ?? []).filter(
|
|
8516
|
+
return (listFiles(root) ?? []).filter(isSource).flatMap((file) => {
|
|
8523
8517
|
try {
|
|
8524
8518
|
const raw = fs.readFileSync(path.join(root, file), "utf8");
|
|
8525
8519
|
return raw.length < 4e5 && !raw.includes("\0") ? [{
|
|
@@ -8622,7 +8616,8 @@ function evidenceModel(corpus, citations, sources) {
|
|
|
8622
8616
|
file: c.file,
|
|
8623
8617
|
line: c.line,
|
|
8624
8618
|
anchor: c.anchor,
|
|
8625
|
-
kind: c.kind === "doc" ? "doc" : "code"
|
|
8619
|
+
kind: c.kind === "doc" ? "doc" : "code",
|
|
8620
|
+
window: c.window
|
|
8626
8621
|
})),
|
|
8627
8622
|
terms: searchTerms(r).map((term) => ({
|
|
8628
8623
|
term,
|
|
@@ -8636,7 +8631,7 @@ function evidenceModel(corpus, citations, sources) {
|
|
|
8636
8631
|
})
|
|
8637
8632
|
};
|
|
8638
8633
|
}
|
|
8639
|
-
var SOURCE_EXT, SOURCE_SKIP, COMMON$1, searchTerms, termPattern;
|
|
8634
|
+
var SOURCE_EXT, SOURCE_SKIP, COMMON$1, isSource, searchTerms, termPattern;
|
|
8640
8635
|
var init_evidence = __esmMin((() => {
|
|
8641
8636
|
init_citations();
|
|
8642
8637
|
init_corpus();
|
|
@@ -8658,6 +8653,7 @@ var init_evidence = __esmMin((() => {
|
|
|
8658
8653
|
"name",
|
|
8659
8654
|
"type"
|
|
8660
8655
|
]);
|
|
8656
|
+
isSource = (file) => SOURCE_EXT.test(file) && !SOURCE_SKIP.test(file) && !isTestFile(file);
|
|
8661
8657
|
searchTerms = (r) => [...new Set(codeTokens(r.block))].filter((t) => t.length >= 3 && /^[\w$.@/:<>-]+$/.test(t) && !COMMON$1.has(t.toLowerCase()));
|
|
8662
8658
|
termPattern = (term) => new RegExp(`${/^[\w$]/.test(term) ? "(?<![\\w$])" : ""}${term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}${/[\w$]$/.test(term) ? "(?![\\w$])" : ""}`, "g");
|
|
8663
8659
|
}));
|
|
@@ -8688,7 +8684,7 @@ function findingEntry(f) {
|
|
|
8688
8684
|
...optional("area", f.area),
|
|
8689
8685
|
layer: f.layer,
|
|
8690
8686
|
...optional("criteria", f.criteria),
|
|
8691
|
-
...optional("confidence", confidenceOf
|
|
8687
|
+
...optional("confidence", confidenceOf(f)),
|
|
8692
8688
|
...f.needsHumanIntent ? { needsHumanIntent: true } : {},
|
|
8693
8689
|
rule: {
|
|
8694
8690
|
text: f.quote,
|
|
@@ -8704,7 +8700,7 @@ function findingEntry(f) {
|
|
|
8704
8700
|
}
|
|
8705
8701
|
/** A theme as a review entry: its rules as a list; its confidence the lowest of its members'. */
|
|
8706
8702
|
function themeEntry(t, area) {
|
|
8707
|
-
const confidences = t.members.map(confidenceOf
|
|
8703
|
+
const confidences = t.members.map(confidenceOf).filter((c) => c !== void 0);
|
|
8708
8704
|
return {
|
|
8709
8705
|
theme: t.title,
|
|
8710
8706
|
...optional("area", area),
|
|
@@ -8916,7 +8912,7 @@ function reviewCli(argv, roots) {
|
|
|
8916
8912
|
process.stderr.write("usage: spec-tools steward review render|status|verify|lint <file>\n");
|
|
8917
8913
|
return 2;
|
|
8918
8914
|
}
|
|
8919
|
-
var import_dist, RESPONSE_STATES, location, confidenceOf
|
|
8915
|
+
var import_dist, RESPONSE_STATES, location, confidenceOf, optional, parseLocation, rulesOf;
|
|
8920
8916
|
var init_review = __esmMin((() => {
|
|
8921
8917
|
import_dist = require_dist();
|
|
8922
8918
|
init_data();
|
|
@@ -8930,7 +8926,7 @@ var init_review = __esmMin((() => {
|
|
|
8930
8926
|
"rejected-with-comment"
|
|
8931
8927
|
];
|
|
8932
8928
|
location = (f) => `${f.repo} ${f.file}:${f.line}`;
|
|
8933
|
-
confidenceOf
|
|
8929
|
+
confidenceOf = (f) => f.judgeConfidence ?? f.readerConfidence;
|
|
8934
8930
|
optional = (key, value) => value === void 0 || Array.isArray(value) && !value.length ? {} : { [key]: value };
|
|
8935
8931
|
parseLocation = (loc) => {
|
|
8936
8932
|
const m = /^`?([\w-]+)\s+([^`\s]+):(\d+)`?$/.exec(loc.trim());
|
|
@@ -9228,7 +9224,7 @@ function hookFindings(root, rel, specsDir = DEFAULT_SPECS_DIR) {
|
|
|
9228
9224
|
if (!fs.existsSync(abs)) return [];
|
|
9229
9225
|
const text = fs.readFileSync(abs, "utf8");
|
|
9230
9226
|
if (rel.startsWith(`${specsDir}/`) && rel.endsWith("/spec.md")) {
|
|
9231
|
-
const cap = capabilityOf$
|
|
9227
|
+
const cap = capabilityOf$2(specsDir, rel);
|
|
9232
9228
|
const head = {
|
|
9233
9229
|
name: "",
|
|
9234
9230
|
path: root,
|
|
@@ -9268,7 +9264,7 @@ function hookFindings(root, rel, specsDir = DEFAULT_SPECS_DIR) {
|
|
|
9268
9264
|
name: "",
|
|
9269
9265
|
path: root,
|
|
9270
9266
|
specsDir,
|
|
9271
|
-
capabilities: [...new Set(citations.filter((c) => c.resolves).map((c) => c.target))].map((f) => parseSpec(fs.readFileSync(path.join(root, f), "utf8"), f, capabilityOf$
|
|
9267
|
+
capabilities: [...new Set(citations.filter((c) => c.resolves).map((c) => c.target))].map((f) => parseSpec(fs.readFileSync(path.join(root, f), "utf8"), f, capabilityOf$2(specsDir, f)))
|
|
9272
9268
|
}, citations, { files: /* @__PURE__ */ new Set([rel]) }).filter((f) => isTestFile(rel) ? [
|
|
9273
9269
|
"dangling-citation",
|
|
9274
9270
|
"textual-test",
|
|
@@ -10182,7 +10178,7 @@ function main$4(argv = [], env = process.env) {
|
|
|
10182
10178
|
fs$1.writeFileSync(path$1.join(root(), DIFF_FILE), text);
|
|
10183
10179
|
return text;
|
|
10184
10180
|
}
|
|
10185
|
-
var id, body, capabilityOf, capabilityMoves, fence, where;
|
|
10181
|
+
var id, body, capabilityOf$1, capabilityMoves, fence, where;
|
|
10186
10182
|
var init_specDiff = __esmMin((() => {
|
|
10187
10183
|
init_changeGates();
|
|
10188
10184
|
init_ci();
|
|
@@ -10190,10 +10186,10 @@ var init_specDiff = __esmMin((() => {
|
|
|
10190
10186
|
init_repo();
|
|
10191
10187
|
id = (r) => `${r.file}#${r.slug}`;
|
|
10192
10188
|
body = (r) => normalizeBlock(r.block.split("\n").slice(1).join("\n"));
|
|
10193
|
-
capabilityOf = (file) => path$1.dirname(file).replace(/^openspec\/specs\//, "");
|
|
10189
|
+
capabilityOf$1 = (file) => path$1.dirname(file).replace(/^openspec\/specs\//, "");
|
|
10194
10190
|
capabilityMoves = (moves) => [...moves].map(([from, to]) => ({
|
|
10195
|
-
from: capabilityOf(from),
|
|
10196
|
-
to: capabilityOf(to)
|
|
10191
|
+
from: capabilityOf$1(from),
|
|
10192
|
+
to: capabilityOf$1(to)
|
|
10197
10193
|
}));
|
|
10198
10194
|
fence = (block) => [
|
|
10199
10195
|
"```markdown",
|
|
@@ -10538,7 +10534,7 @@ function renderRequirement(r, ctx, relatedInFull = false, quoted) {
|
|
|
10538
10534
|
};
|
|
10539
10535
|
}
|
|
10540
10536
|
/** A capability's evidence file opens with this: what it is, and the capability's Purpose. */
|
|
10541
|
-
function capabilityHeader(capability, ctx, sliced) {
|
|
10537
|
+
function capabilityHeader(capability, ctx, sliced, affected) {
|
|
10542
10538
|
const file = ctx.all.find((r) => r.capability === capability)?.file ?? `openspec/specs/${capability}/spec.md`;
|
|
10543
10539
|
const specLines = ctx.read(file) ?? [];
|
|
10544
10540
|
const purposeStart = specLines.findIndex((l) => l.startsWith("## Purpose"));
|
|
@@ -10549,6 +10545,7 @@ function capabilityHeader(capability, ctx, sliced) {
|
|
|
10549
10545
|
source: file,
|
|
10550
10546
|
note: `Generated by spec-tools scope from ${file} and spec-steward's evidence model. Line numbers are the files' own. Every requirement is here as written, with the tests bound to it, the source lines where its own terms occur (comments stripped), and its related requirements. Judge from this file. Open a source only where an excerpt has a window, or where you must confirm a term occurrence.`,
|
|
10551
10547
|
...sliced ? { sliced: "This capability is larger than one reader holds. Its evidence is cut between its requirements: this file carries some of them, and its other files carry the rest." } : {},
|
|
10548
|
+
...affected ? { affected: "This run judges the affected set of a change. This capability is in it only in part: the file carries the requirements that the change reaches. Its other requirements are not in this run." } : {},
|
|
10552
10549
|
...purpose ? { purpose } : {}
|
|
10553
10550
|
};
|
|
10554
10551
|
}
|
|
@@ -10557,11 +10554,13 @@ function capabilityHeader(capability, ctx, sliced) {
|
|
|
10557
10554
|
* otherwise cut between its requirements in their spec order — a file closes before the requirement that would take
|
|
10558
10555
|
* it past `PART_BYTES`, so none is larger unless one requirement alone is, and each repeats the header and Purpose and
|
|
10559
10556
|
* quotes its own excerpts. A function of the evidence alone: every job that reads the scope sees the same cut.
|
|
10557
|
+
* With `only`, the capability carries just those of its requirements, and its header says so when that is not all.
|
|
10560
10558
|
*/
|
|
10561
|
-
function renderCapability(capability, ctx) {
|
|
10562
|
-
const
|
|
10559
|
+
function renderCapability(capability, ctx, only) {
|
|
10560
|
+
const all = ctx.all.filter((r) => r.capability === capability);
|
|
10561
|
+
const own = only ? all.filter((r) => only.has(idOf(r))) : all;
|
|
10563
10562
|
const cut = (sliced) => {
|
|
10564
|
-
const header = capabilityHeader(capability, ctx, sliced);
|
|
10563
|
+
const header = capabilityHeader(capability, ctx, sliced, own.length < all.length);
|
|
10565
10564
|
const textOf = (requirements) => toYaml({
|
|
10566
10565
|
...header,
|
|
10567
10566
|
requirements
|
|
@@ -10601,18 +10600,20 @@ function renderCapability(capability, ctx) {
|
|
|
10601
10600
|
* its related requirements quoted IN FULL, so one reader can judge the edit against the rest before it
|
|
10602
10601
|
* is handed back — the file `spec-tools changed` writes and the audit's focused mode judges.
|
|
10603
10602
|
*/
|
|
10604
|
-
function renderChanged(touched, ctx, base = "HEAD") {
|
|
10603
|
+
function renderChanged(touched, ctx, base = "HEAD", by = "") {
|
|
10604
|
+
const settings = by ? ` (${by})` : "";
|
|
10605
10605
|
return toYaml({
|
|
10606
10606
|
base,
|
|
10607
|
-
note: touched.length ? `Generated by spec-tools changed from the diff against ${base}: ${touched.length} requirement(s) in scope. These are the requirements the diff changed or a touched delta names, the requirements
|
|
10607
|
+
note: touched.length ? `Generated by spec-tools changed from the diff against ${base}${settings}: ${touched.length} requirement(s) in scope. These are the requirements the diff changed or a touched delta names, the requirements a changed line reaches through a bound test, a citation or one of their terms, the requirements related to these, and the capabilities the unit adds. Judge each against its bound tests, where its terms occur, and its related requirements, quoted in full.` : `Generated by spec-tools changed: nothing in scope against ${base}${settings}.`,
|
|
10608
10608
|
requirements: touched.map((r) => renderRequirement(r, ctx, true))
|
|
10609
10609
|
});
|
|
10610
10610
|
}
|
|
10611
10611
|
/**
|
|
10612
10612
|
* Writes each capability's evidence files and `units.yaml`; returns each file with its weight — `<capability>.yaml` for
|
|
10613
|
-
* a capability whole, `<capability>.<k>.yaml` for its k-th slice.
|
|
10613
|
+
* a capability whole, `<capability>.<k>.yaml` for its k-th slice. With `only`, the files and `units.yaml` carry just
|
|
10614
|
+
* those requirements: the affected set.
|
|
10614
10615
|
*/
|
|
10615
|
-
function writeParts(capabilities, all = requirementsOf(loadEvidence())) {
|
|
10616
|
+
function writeParts(capabilities, all = requirementsOf(loadEvidence()), only) {
|
|
10616
10617
|
const ctx = contextOf(all);
|
|
10617
10618
|
const dir = path$1.join(root(), PARTS_DIR);
|
|
10618
10619
|
if (fs$1.existsSync(dir)) {
|
|
@@ -10620,10 +10621,10 @@ function writeParts(capabilities, all = requirementsOf(loadEvidence())) {
|
|
|
10620
10621
|
}
|
|
10621
10622
|
fs$1.mkdirSync(path$1.join(dir, "findings"), { recursive: true });
|
|
10622
10623
|
const units = {};
|
|
10623
|
-
for (const r of all) if (capabilities.includes(r.capability)) units[idOf(r)] = r.advisory ? { advisory: true } : {};
|
|
10624
|
+
for (const r of all) if (capabilities.includes(r.capability) && (!only || only.has(idOf(r)))) units[idOf(r)] = r.advisory ? { advisory: true } : {};
|
|
10624
10625
|
writeData(path$1.join(root(), UNITS_FILE), units);
|
|
10625
10626
|
return capabilities.flatMap((capability) => {
|
|
10626
|
-
const slices = renderCapability(capability, ctx);
|
|
10627
|
+
const slices = renderCapability(capability, ctx, only);
|
|
10627
10628
|
return slices.map(({ requirements, text }, k) => {
|
|
10628
10629
|
const file = `${PARTS_DIR}/${capability}${slices.length > 1 ? `.${k + 1}` : ""}.yaml`;
|
|
10629
10630
|
fs$1.mkdirSync(path$1.dirname(path$1.join(root(), file)), { recursive: true });
|
|
@@ -10671,38 +10672,79 @@ var init_auditParts = __esmMin((() => {
|
|
|
10671
10672
|
//#endregion
|
|
10672
10673
|
//#region spec-tools/src/auditChanged.ts
|
|
10673
10674
|
var auditChanged_exports = /* @__PURE__ */ __exportAll({
|
|
10675
|
+
AFFECTED_DEFAULTS: () => AFFECTED_DEFAULTS,
|
|
10676
|
+
AFFECTED_UNITS: () => AFFECTED_UNITS,
|
|
10674
10677
|
CHANGED_FILE: () => CHANGED_FILE,
|
|
10678
|
+
affectedOptions: () => affectedOptions,
|
|
10675
10679
|
affectedScope: () => affectedScope,
|
|
10676
10680
|
deltaBlocks: () => deltaBlocks,
|
|
10677
10681
|
deltaRequirements: () => deltaRequirements,
|
|
10682
|
+
describeOptions: () => describeOptions,
|
|
10683
|
+
grow: () => grow,
|
|
10678
10684
|
hunksOf: () => hunksOf,
|
|
10679
10685
|
main: () => main$3,
|
|
10680
10686
|
reachedBy: () => reachedBy,
|
|
10681
|
-
requirementsTouched: () => requirementsTouched
|
|
10687
|
+
requirementsTouched: () => requirementsTouched,
|
|
10688
|
+
touches: () => touches
|
|
10682
10689
|
});
|
|
10683
|
-
/** The
|
|
10690
|
+
/** The affected set's three variables, validated; an unset or empty one takes its default. */
|
|
10691
|
+
function affectedOptions(env = process.env) {
|
|
10692
|
+
const count = (name, fallback, also = "") => {
|
|
10693
|
+
const value = env[name];
|
|
10694
|
+
if (!value) return fallback;
|
|
10695
|
+
if (!/^\d+$/.test(value)) throw new Error(`${name} must be a whole number of 0 or more${also}, not "${value}"`);
|
|
10696
|
+
return Number(value);
|
|
10697
|
+
};
|
|
10698
|
+
const unit = env.AUDIT_AFFECTED_UNIT || AFFECTED_DEFAULTS.unit;
|
|
10699
|
+
if (!AFFECTED_UNITS.includes(unit)) throw new Error(`AUDIT_AFFECTED_UNIT must be one of ${AFFECTED_UNITS.join(", ")}, not "${unit}"`);
|
|
10700
|
+
return {
|
|
10701
|
+
context: env.AUDIT_AFFECTED_CONTEXT === "file" ? "file" : count("AUDIT_AFFECTED_CONTEXT", AFFECTED_DEFAULTS.context, ", or \"file\""),
|
|
10702
|
+
hops: count("AUDIT_AFFECTED_HOPS", AFFECTED_DEFAULTS.hops),
|
|
10703
|
+
unit
|
|
10704
|
+
};
|
|
10705
|
+
}
|
|
10706
|
+
/**
|
|
10707
|
+
* Every hunk of a unified diff, per file — the new lines a change touched and the old lines it removed. A deleted
|
|
10708
|
+
* file's hunks are under its old path.
|
|
10709
|
+
*/
|
|
10684
10710
|
function hunksOf(diff) {
|
|
10685
10711
|
const hunks = [];
|
|
10712
|
+
let from = "";
|
|
10686
10713
|
let file = "";
|
|
10714
|
+
let header = true;
|
|
10687
10715
|
for (const line of diff.split("\n")) {
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10716
|
+
if (line.startsWith("diff --git ")) {
|
|
10717
|
+
[from, file, header] = [
|
|
10718
|
+
"",
|
|
10719
|
+
"",
|
|
10720
|
+
true
|
|
10721
|
+
];
|
|
10691
10722
|
continue;
|
|
10692
10723
|
}
|
|
10693
10724
|
const h = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(line);
|
|
10694
|
-
if (h
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10725
|
+
if (h) {
|
|
10726
|
+
header = false;
|
|
10727
|
+
if (file) hunks.push({
|
|
10728
|
+
file,
|
|
10729
|
+
start: Number(h[1]),
|
|
10730
|
+
count: h[2] === void 0 ? 1 : Number(h[2]),
|
|
10731
|
+
removed: []
|
|
10732
|
+
});
|
|
10733
|
+
continue;
|
|
10734
|
+
}
|
|
10735
|
+
if (header) {
|
|
10736
|
+
const old = /^--- (?:a\/(.+)|\/dev\/null)$/.exec(line);
|
|
10737
|
+
if (old) from = old[1] ?? "";
|
|
10738
|
+
const now = /^\+\+\+ (?:b\/(.+)|\/dev\/null)$/.exec(line);
|
|
10739
|
+
if (now) file = now[1] ?? from;
|
|
10740
|
+
} else if (line.startsWith("-")) hunks.at(-1)?.removed.push(line.slice(1));
|
|
10699
10741
|
}
|
|
10700
10742
|
return hunks;
|
|
10701
10743
|
}
|
|
10702
10744
|
/** The requirements whose blocks a hunk overlaps; a deleted-only hunk (count 0) touches the block at its line. */
|
|
10703
10745
|
function requirementsTouched(hunks, all) {
|
|
10704
10746
|
const touched = [];
|
|
10705
|
-
for (const r of all) if (hunks
|
|
10747
|
+
for (const r of all) if (touches(hunks, r.file, r.line, r.endLine) && !touched.includes(r)) touched.push(r);
|
|
10706
10748
|
return touched;
|
|
10707
10749
|
}
|
|
10708
10750
|
/** A delta file's requirement blocks by operation; a RENAMED entry is named by its FROM heading and has no block. */
|
|
@@ -10761,30 +10803,52 @@ function deltaRequirements(deltaText, capability, all) {
|
|
|
10761
10803
|
return [...out];
|
|
10762
10804
|
}
|
|
10763
10805
|
/**
|
|
10764
|
-
* The requirements a
|
|
10765
|
-
*
|
|
10766
|
-
*
|
|
10806
|
+
* The requirements a diff's changed lines reach, each line widened by `context`: those with a binding (a test, type
|
|
10807
|
+
* assertion, lint entry or check) or a citation whose window a changed line falls in — a test binding's window is
|
|
10808
|
+
* its test block, any other's the lines from the citation on — and those with a distinctive term on a changed line
|
|
10809
|
+
* of a source file, or on a line a source file lost, so deleting the code behind a requirement still reaches it.
|
|
10767
10810
|
*/
|
|
10768
|
-
function reachedBy(
|
|
10811
|
+
function reachedBy(hunks, all, context = AFFECTED_DEFAULTS.context) {
|
|
10769
10812
|
const distinctive = distinctiveTerms(all);
|
|
10770
|
-
|
|
10813
|
+
const removed = hunks.filter((h) => h.removed.length && isSource(h.file)).map((h) => stripComments(h.file, h.removed.join("\n"))).join("\n");
|
|
10814
|
+
const lost = /* @__PURE__ */ new Map();
|
|
10815
|
+
const wasRemoved = (term) => lost.get(term) ?? lost.set(term, termPattern(term).test(removed)).get(term);
|
|
10816
|
+
const inWindow = (c) => touches(hunks, c.file, c.window[0], c.window[1], context);
|
|
10817
|
+
return all.filter((r) => r.bindings.some(inWindow) || r.pointers.some(inWindow) || r.terms.some((t) => distinctive.has(t.term) && (t.hits.some((h) => touches(hunks, h.file, h.line, h.line, context)) || wasRemoved(t.term))));
|
|
10771
10818
|
}
|
|
10772
10819
|
/**
|
|
10773
|
-
*
|
|
10774
|
-
*
|
|
10820
|
+
* Stages EXPAND and UNIT over a seed: each hop adds the related requirements of the set so far; then `edited` adds
|
|
10821
|
+
* every requirement of each capability the diff edits, and `capability` every requirement of each capability in the
|
|
10822
|
+
* set or edited. The seed comes first, in its order.
|
|
10775
10823
|
*/
|
|
10776
|
-
function
|
|
10824
|
+
function grow(seed, all, edited, options) {
|
|
10777
10825
|
const byId = new Map(all.map((r) => [idOf(r), r]));
|
|
10826
|
+
const set = new Map(seed.map((r) => [idOf(r), r]));
|
|
10827
|
+
for (let hop = 0; hop < options.hops; hop++) for (const r of [...set.values()]) for (const { id } of r.related) {
|
|
10828
|
+
const other = byId.get(id);
|
|
10829
|
+
if (other) set.set(id, other);
|
|
10830
|
+
}
|
|
10831
|
+
const whole = new Set(options.unit === "capability" ? [...edited, ...[...set.values()].map((r) => r.capability)] : edited);
|
|
10832
|
+
if (options.unit !== "requirement") {
|
|
10833
|
+
for (const r of all) if (whole.has(r.capability)) set.set(idOf(r), r);
|
|
10834
|
+
}
|
|
10835
|
+
return [...set.values()];
|
|
10836
|
+
}
|
|
10837
|
+
/** The affected set against a base, built in the three stages the module names. */
|
|
10838
|
+
function affectedScope(base, all = requirementsOf(loadEvidence()), options = affectedOptions()) {
|
|
10778
10839
|
const set = /* @__PURE__ */ new Map();
|
|
10779
10840
|
const add = (r) => set.set(idOf(r), r);
|
|
10780
|
-
|
|
10841
|
+
const specHunks = hunksOf(git$1([
|
|
10781
10842
|
"diff",
|
|
10782
10843
|
"-M",
|
|
10783
10844
|
"--unified=0",
|
|
10784
10845
|
base,
|
|
10785
10846
|
"--",
|
|
10786
10847
|
"openspec/specs"
|
|
10787
|
-
]))
|
|
10848
|
+
]));
|
|
10849
|
+
for (const r of requirementsTouched(specHunks, all)) add(r);
|
|
10850
|
+
const known = new Set(all.map((r) => r.capability));
|
|
10851
|
+
const edited = [...new Set(specHunks.map((h) => capabilityOf(h.file)))].filter((c) => !!c && known.has(c)).sort();
|
|
10788
10852
|
const synced = new Set(syncedUnarchivedChanges().map((s) => s.split(" — ")[0]));
|
|
10789
10853
|
for (const change of touchedOpenChanges(base).filter((c) => !synced.has(c))) {
|
|
10790
10854
|
const specs = path$1.join(root(), "openspec/changes", change, "specs");
|
|
@@ -10798,44 +10862,64 @@ function affectedScope(base, all = requirementsOf(loadEvidence())) {
|
|
|
10798
10862
|
for (const r of deltaRequirements(fs$1.readFileSync(delta, "utf8"), capability, all)) add(r);
|
|
10799
10863
|
}
|
|
10800
10864
|
}
|
|
10801
|
-
const
|
|
10802
|
-
"diff",
|
|
10803
|
-
"--name-only",
|
|
10804
|
-
base
|
|
10805
|
-
]).split("\n"), ...git$1([
|
|
10865
|
+
const untracked = git$1([
|
|
10806
10866
|
"ls-files",
|
|
10807
10867
|
"--others",
|
|
10808
10868
|
"--exclude-standard"
|
|
10809
|
-
]).split("\n")
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
}
|
|
10869
|
+
]).split("\n").filter(Boolean).map((file) => ({
|
|
10870
|
+
file,
|
|
10871
|
+
start: 1,
|
|
10872
|
+
count: Number.MAX_SAFE_INTEGER,
|
|
10873
|
+
removed: []
|
|
10874
|
+
}));
|
|
10875
|
+
for (const r of reachedBy([...hunksOf(git$1([
|
|
10876
|
+
"diff",
|
|
10877
|
+
"--unified=0",
|
|
10878
|
+
base
|
|
10879
|
+
])), ...untracked], all, options.context)) add(r);
|
|
10880
|
+
const requirements = grow([...set.values()], all, edited, options);
|
|
10815
10881
|
return {
|
|
10816
10882
|
base,
|
|
10817
|
-
requirements
|
|
10818
|
-
capabilities: [...new Set(
|
|
10883
|
+
requirements,
|
|
10884
|
+
capabilities: [...new Set(requirements.map((r) => r.capability))].sort(),
|
|
10885
|
+
edited,
|
|
10886
|
+
options
|
|
10819
10887
|
};
|
|
10820
10888
|
}
|
|
10821
10889
|
function main$3(env = process.env) {
|
|
10822
10890
|
const base = diffBase(env);
|
|
10823
10891
|
const all = requirementsOf(loadEvidence());
|
|
10824
|
-
const scope = affectedScope(base, all);
|
|
10825
|
-
const text = renderChanged(scope.requirements, contextOf(all), base);
|
|
10892
|
+
const scope = affectedScope(base, all, affectedOptions(env));
|
|
10893
|
+
const text = renderChanged(scope.requirements, contextOf(all), base, describeOptions(scope.options));
|
|
10826
10894
|
fs$1.mkdirSync(path$1.join(root(), PARTS_DIR), { recursive: true });
|
|
10827
10895
|
fs$1.writeFileSync(path$1.join(root(), CHANGED_FILE), text);
|
|
10828
|
-
|
|
10896
|
+
const by = describeOptions(scope.options);
|
|
10897
|
+
return scope.requirements.length ? `${scope.requirements.length} requirement(s) in scope against ${base} (${by}) → ${CHANGED_FILE}:\n${scope.requirements.map((r) => `- ${idOf(r)}`).join("\n")}\n` : `Nothing in scope against ${base} (${by}); ${CHANGED_FILE} says so.\n`;
|
|
10829
10898
|
}
|
|
10830
|
-
var CHANGED_FILE, codeSpans;
|
|
10899
|
+
var CHANGED_FILE, AFFECTED_UNITS, AFFECTED_DEFAULTS, describeOptions, touches, codeSpans, capabilityOf;
|
|
10831
10900
|
var init_auditChanged = __esmMin((() => {
|
|
10832
10901
|
init_auditParts();
|
|
10833
10902
|
init_changeGates();
|
|
10834
10903
|
init_ci();
|
|
10835
10904
|
init_files();
|
|
10836
10905
|
init_repo();
|
|
10906
|
+
init_evidence();
|
|
10907
|
+
init_scan();
|
|
10837
10908
|
CHANGED_FILE = `${PARTS_DIR}/changed.yaml`;
|
|
10909
|
+
AFFECTED_UNITS = [
|
|
10910
|
+
"requirement",
|
|
10911
|
+
"edited",
|
|
10912
|
+
"capability"
|
|
10913
|
+
];
|
|
10914
|
+
AFFECTED_DEFAULTS = {
|
|
10915
|
+
context: 3,
|
|
10916
|
+
hops: 1,
|
|
10917
|
+
unit: "edited"
|
|
10918
|
+
};
|
|
10919
|
+
describeOptions = (o) => `AUDIT_AFFECTED_CONTEXT=${o.context}, AUDIT_AFFECTED_HOPS=${o.hops}, AUDIT_AFFECTED_UNIT=${o.unit}`;
|
|
10920
|
+
touches = (hunks, file, from, to, context = 0) => hunks.some((h) => h.file === file && (context === "file" || h.start - context <= to && h.start + Math.max(h.count, 1) - 1 + context >= from));
|
|
10838
10921
|
codeSpans = (text) => new Set([...text.matchAll(/`([^`\n]+)`/g)].map((m) => m[1].trim()));
|
|
10922
|
+
capabilityOf = (file) => /^openspec\/specs\/(.+)\/spec\.md$/.exec(file)?.[1];
|
|
10839
10923
|
}));
|
|
10840
10924
|
//#endregion
|
|
10841
10925
|
//#region spec-tools/src/tier.ts
|
|
@@ -10930,8 +11014,8 @@ var init_rules = __esmMin((() => {
|
|
|
10930
11014
|
"Write the file as YAML. Write each key in this style:",
|
|
10931
11015
|
"- Prose (detail, reason, scenario, whatsWrong, proposed): a literal block, `key: |`, with the text indented on the next lines.",
|
|
10932
11016
|
"- Quoted source text (quotes[].text, quote): a stripped literal block, `text: |-`, with the line as it is written in the source.",
|
|
10933
|
-
"- Ids, paths, kinds,
|
|
10934
|
-
"- Numbers (line, part, reader, readerConfidence, judgeConfidence): plain integers.",
|
|
11017
|
+
"- Ids, paths, kinds, verdicts and layers (where, file, kind, verdict, layer, themeKey): double-quoted strings.",
|
|
11018
|
+
"- Numbers (line, part, reader, readerSeverity, readerConfidence, judgeSeverity, judgeConfidence): plain integers.",
|
|
10935
11019
|
"- Lists of ids (judged, capabilities, sound, evidence): block lists of double-quoted strings.",
|
|
10936
11020
|
"- Booleans (needsHumanIntent): true or false.",
|
|
10937
11021
|
"When you stop, the tool checks the file and sends any errors back to you."
|
|
@@ -11286,7 +11370,7 @@ function renderScope(parts, kind = "all", detail) {
|
|
|
11286
11370
|
"",
|
|
11287
11371
|
"## Parts",
|
|
11288
11372
|
"",
|
|
11289
|
-
`Every part's worker judges its evidence files under \`${PARTS_DIR}/\` — a capability whole,
|
|
11373
|
+
`Every part's worker judges its evidence files under \`${PARTS_DIR}/\` — a capability whole, a capability cut between its requirements, or the requirements of a capability that the affected set holds — for every check: the specification against itself (2, 3) and the code against it (1, 4, 5).`,
|
|
11290
11374
|
""
|
|
11291
11375
|
];
|
|
11292
11376
|
lines.push(`1 independent readers per part, each writing its own findings file; the merge unions what they found.`, "");
|
|
@@ -11306,16 +11390,17 @@ function main$2(env = process.env, audit = "spec-verify") {
|
|
|
11306
11390
|
const kind = modeFor(env);
|
|
11307
11391
|
const model = loadEvidence();
|
|
11308
11392
|
const all = requirementsOf(model);
|
|
11309
|
-
const affected = kind === "affected" ? affectedScope(diffBase(env), all) : void 0;
|
|
11393
|
+
const affected = kind === "affected" ? affectedScope(diffBase(env), all, affectedOptions(env)) : void 0;
|
|
11310
11394
|
const corpus = [...new Set(all.map((r) => r.capability))].sort();
|
|
11311
|
-
const capabilityParts = partition(writeParts(affected ? affected.capabilities : corpus, all), audit, (Number(env.AUDIT_JOBS) || 1) * (Number(env.AUDIT_SLOTS) || 1));
|
|
11395
|
+
const capabilityParts = partition(writeParts(affected ? affected.capabilities : corpus, all, affected ? new Set(affected.requirements.map(idOf)) : void 0), audit, (Number(env.AUDIT_JOBS) || 1) * (Number(env.AUDIT_SLOTS) || 1));
|
|
11312
11396
|
const parts = audit === "spec-steward" ? [...capabilityParts, ...sweepUnits(model, capabilityParts.length)] : capabilityParts;
|
|
11313
|
-
const report = renderScope(parts, kind, affected ? `The affected set against \`${affected.base}
|
|
11397
|
+
const report = renderScope(parts, kind, affected ? `The affected set against \`${affected.base}\` (${describeOptions(affected.options)}): ${affected.requirements.length} requirements in ${affected.capabilities.length} capabilities — the ones the diff changed or a touched delta names, the ones a changed line reaches through a bound test, a citation or one of their terms, the requirements related to these, and the capabilities the unit adds — with cross-capability checks against the corpus the evidence quotes.` : void 0);
|
|
11314
11398
|
const data = {
|
|
11315
11399
|
scope: kind,
|
|
11316
11400
|
...affected ? {
|
|
11317
11401
|
base: affected.base,
|
|
11318
|
-
capabilities: affected.capabilities
|
|
11402
|
+
capabilities: affected.capabilities,
|
|
11403
|
+
affected: affected.options
|
|
11319
11404
|
} : {},
|
|
11320
11405
|
readers: 1,
|
|
11321
11406
|
parts
|
|
@@ -11338,6 +11423,71 @@ var init_auditScope = __esmMin((() => {
|
|
|
11338
11423
|
kb = (bytes) => `${Math.max(1, Math.round(bytes / 1024))} KB`;
|
|
11339
11424
|
}));
|
|
11340
11425
|
//#endregion
|
|
11426
|
+
//#region spec-tools/src/severity.ts
|
|
11427
|
+
/** The thresholds from the variables, validated; an unset or empty one takes its default. */
|
|
11428
|
+
function thresholds(env = process.env) {
|
|
11429
|
+
const score = (name, fallback) => {
|
|
11430
|
+
const value = env[name];
|
|
11431
|
+
if (!value) return fallback;
|
|
11432
|
+
if (!/^\d+$/.test(value) || Number(value) > 100) throw new Error(`${name} must be a whole number from 0 to 100, not "${value}"`);
|
|
11433
|
+
return Number(value);
|
|
11434
|
+
};
|
|
11435
|
+
const numbers = env.AUDIT_JUDGE_READER_NUMBERS || THRESHOLDS.judgeReaderNumbers;
|
|
11436
|
+
if (numbers !== "hide" && numbers !== "show") throw new Error(`AUDIT_JUDGE_READER_NUMBERS must be hide or show, not "${numbers}"`);
|
|
11437
|
+
const t = {
|
|
11438
|
+
warn: score("AUDIT_SEVERITY_WARN", THRESHOLDS.warn),
|
|
11439
|
+
error: score("AUDIT_SEVERITY_ERROR", THRESHOLDS.error),
|
|
11440
|
+
sure: score("AUDIT_CONFIDENCE_SURE", THRESHOLDS.sure),
|
|
11441
|
+
blocking: score("AUDIT_CONFIDENCE_BLOCKING", THRESHOLDS.blocking),
|
|
11442
|
+
ignoreGap: score("AUDIT_CONFIDENCE_IGNORE_GAP", THRESHOLDS.ignoreGap),
|
|
11443
|
+
judgeFrom: score("AUDIT_JUDGE_FROM", THRESHOLDS.judgeFrom),
|
|
11444
|
+
judgeMinConfidence: score("AUDIT_JUDGE_MIN_CONFIDENCE", THRESHOLDS.judgeMinConfidence),
|
|
11445
|
+
judgeReaderNumbers: numbers
|
|
11446
|
+
};
|
|
11447
|
+
if (t.warn >= t.error) throw new Error(`AUDIT_SEVERITY_WARN (${t.warn}) must be below AUDIT_SEVERITY_ERROR (${t.error})`);
|
|
11448
|
+
if (t.sure > t.blocking) throw new Error(`AUDIT_CONFIDENCE_SURE (${t.sure}) must not be above AUDIT_CONFIDENCE_BLOCKING (${t.blocking})`);
|
|
11449
|
+
return t;
|
|
11450
|
+
}
|
|
11451
|
+
/** One or two readings fused into one; with one reading, that reading. A severity gap up to `ignoreGap` costs nothing. */
|
|
11452
|
+
function fuse(readings, ignoreGap = THRESHOLDS.ignoreGap) {
|
|
11453
|
+
const uncertainty = readings.map((r) => Math.max(1, 100 - r.confidence));
|
|
11454
|
+
const weight = uncertainty.reduce((sum, u) => sum + 1 / u, 0);
|
|
11455
|
+
const severity = readings.reduce((sum, r, i) => sum + r.severity / uncertainty[i], 0) / weight;
|
|
11456
|
+
const severities = readings.map((r) => r.severity);
|
|
11457
|
+
const gap = Math.max(0, Math.max(...severities) - Math.min(...severities) - ignoreGap);
|
|
11458
|
+
const confidence = 100 - Math.min(...uncertainty) - gap / 2;
|
|
11459
|
+
return {
|
|
11460
|
+
severity: Math.round(severity),
|
|
11461
|
+
confidence: Math.round(Math.min(100, Math.max(0, confidence)))
|
|
11462
|
+
};
|
|
11463
|
+
}
|
|
11464
|
+
/** The findings the judge reads, and how many each gate held back: severe but unsure, and below the severity. */
|
|
11465
|
+
function judgeGate(findings, t) {
|
|
11466
|
+
const severe = findings.filter((f) => f.severity >= t.judgeFrom);
|
|
11467
|
+
const judged = severe.filter((f) => isJudged(f, t));
|
|
11468
|
+
return {
|
|
11469
|
+
judged,
|
|
11470
|
+
unsure: severe.length - judged.length,
|
|
11471
|
+
mild: findings.length - severe.length
|
|
11472
|
+
};
|
|
11473
|
+
}
|
|
11474
|
+
var THRESHOLDS, describeThresholds, tierOf$1, isJudged;
|
|
11475
|
+
var init_severity = __esmMin((() => {
|
|
11476
|
+
THRESHOLDS = {
|
|
11477
|
+
warn: 40,
|
|
11478
|
+
error: 70,
|
|
11479
|
+
sure: 70,
|
|
11480
|
+
blocking: 80,
|
|
11481
|
+
ignoreGap: 20,
|
|
11482
|
+
judgeFrom: 70,
|
|
11483
|
+
judgeMinConfidence: 60,
|
|
11484
|
+
judgeReaderNumbers: "hide"
|
|
11485
|
+
};
|
|
11486
|
+
describeThresholds = (t) => `WARN from severity ${t.warn}, ERROR from ${t.error} above ${t.sure}% confidence, FAIL above ${t.blocking}%; a severity gap up to ${t.ignoreGap} between readings costs no confidence`;
|
|
11487
|
+
tierOf$1 = (r, t) => r.severity >= t.error && r.confidence > t.sure ? "ERROR" : r.severity >= t.warn ? "WARN" : "INFO";
|
|
11488
|
+
isJudged = (r, t) => r.severity >= t.judgeFrom && r.confidence >= t.judgeMinConfidence;
|
|
11489
|
+
}));
|
|
11490
|
+
//#endregion
|
|
11341
11491
|
//#region spec-tools/src/workers.ts
|
|
11342
11492
|
/**
|
|
11343
11493
|
* The specification audit's fan-out, deterministic: headless `claude --print` workers started from here — no
|
|
@@ -11352,8 +11502,9 @@ var init_auditScope = __esmMin((() => {
|
|
|
11352
11502
|
* each job works its share out from the scope alone. Then the merge.
|
|
11353
11503
|
* 2. complete One worker per part the merge left short — the `short` list of `.spec-audit/spec-verify.yaml` — over
|
|
11354
11504
|
* exactly those items, writing the part's next reader file. Nothing already judged is judged twice.
|
|
11355
|
-
* 3. verify One judge per
|
|
11356
|
-
*
|
|
11505
|
+
* 3. verify One judge per finding severe and sure enough (`severity.ts` `judgeGate`), over that finding alone,
|
|
11506
|
+
* giving its own severity and confidence, on AUDIT_MODEL_VERIFY. Then the last merge, which fuses the
|
|
11507
|
+
* two readings, and whose verdict gates.
|
|
11357
11508
|
*
|
|
11358
11509
|
* A worker writes its findings file and nothing else. The tool checks that file against its schema as soon as the
|
|
11359
11510
|
* worker stops (`data.ts`), and sends the errors back to the same worker session to correct, at most `CORRECTIONS`
|
|
@@ -11367,6 +11518,7 @@ var init_auditScope = __esmMin((() => {
|
|
|
11367
11518
|
var workers_exports = /* @__PURE__ */ __exportAll({
|
|
11368
11519
|
CORRECTIONS: () => 2,
|
|
11369
11520
|
EARLY_FAILURE_MS: () => EARLY_FAILURE_MS,
|
|
11521
|
+
START_RETRY_DELAY: () => "30s",
|
|
11370
11522
|
TOOLS: () => TOOLS,
|
|
11371
11523
|
brief: () => brief,
|
|
11372
11524
|
briefComplete: () => briefComplete,
|
|
@@ -11521,8 +11673,8 @@ async function runClaude(run, wrote, budget, env, cwd) {
|
|
|
11521
11673
|
};
|
|
11522
11674
|
}
|
|
11523
11675
|
/**
|
|
11524
|
-
* One worker, retried once
|
|
11525
|
-
* nothing. Without the retry its part waits for the completion pass, after the whole reading.
|
|
11676
|
+
* One worker, retried once after a short delay when it failed to start: a non-zero exit within `EARLY_FAILURE_MS` that
|
|
11677
|
+
* wrote nothing. Without the retry its part waits for the completion pass, after the whole reading.
|
|
11526
11678
|
*/
|
|
11527
11679
|
async function runOnce(run, wrote, budget, env, cwd) {
|
|
11528
11680
|
const started = Date.now();
|
|
@@ -11531,7 +11683,8 @@ async function runOnce(run, wrote, budget, env, cwd) {
|
|
|
11531
11683
|
...first,
|
|
11532
11684
|
retried: false
|
|
11533
11685
|
};
|
|
11534
|
-
|
|
11686
|
+
const delay = duration(env.AUDIT_START_RETRY_DELAY || "30s");
|
|
11687
|
+
await new Promise((resolve) => setTimeout(resolve, delay + Math.random() * delay / 3));
|
|
11535
11688
|
return {
|
|
11536
11689
|
...await runClaude({
|
|
11537
11690
|
...run,
|
|
@@ -11638,7 +11791,7 @@ async function workers(pass, { audit = "spec-verify", context, env = process.env
|
|
|
11638
11791
|
const first = await runOnce(run, () => fs$1.existsSync(full), budget, env, cwd);
|
|
11639
11792
|
const check = await checked(run, first, file, kind.verdictSchema, kind.canEdit, budget, env, cwd);
|
|
11640
11793
|
const v = check.errors.length ? void 0 : tryReadData(full);
|
|
11641
|
-
const wrote = v ? `${v.verdict}${v.judgeConfidence !== void 0 ? ` (${v.judgeConfidence}%)` : ""} — ${String(v.reason).trim()}` : fs$1.existsSync(full) ? "invalid verdict file" : "no verdict file";
|
|
11794
|
+
const wrote = v ? `${v.verdict ?? `severity ${v.judgeSeverity}`}${v.judgeConfidence !== void 0 ? ` (${v.judgeConfidence}%)` : ""} — ${String(v.reason).trim()}` : fs$1.existsSync(full) ? "invalid verdict file" : "no verdict file";
|
|
11642
11795
|
log(`[${clock()}] verifier ${k} finished in ${Math.round((Date.now() - started) / 1e3)}s — ${check.status} — ${wrote}${checkNote(check, first.retried)}`);
|
|
11643
11796
|
};
|
|
11644
11797
|
const unchanged = () => {
|
|
@@ -11655,7 +11808,8 @@ async function workers(pass, { audit = "spec-verify", context, env = process.env
|
|
|
11655
11808
|
if (pass === "verify") {
|
|
11656
11809
|
for (const f of fs$1.readdirSync(findings)) if (/^(verdict-.*\.yaml|verifier-.*\.(jsonl|err|result\.yaml))$/.test(f)) fs$1.rmSync(path$1.join(findings, f));
|
|
11657
11810
|
fs$1.writeFileSync(path$1.join(cwd, files.verified), "");
|
|
11658
|
-
const targets = kind.targets(report, partOf);
|
|
11811
|
+
const { list: targets, note } = kind.targets(report, partOf, env);
|
|
11812
|
+
if (note) log(`spec-tools workers: ${note}`);
|
|
11659
11813
|
if (!targets.length) {
|
|
11660
11814
|
log(`spec-tools workers: nothing to verify — ${kind.none}`);
|
|
11661
11815
|
return 0;
|
|
@@ -11700,13 +11854,14 @@ async function workers(pass, { audit = "spec-verify", context, env = process.env
|
|
|
11700
11854
|
if (code === 0) log("spec-tools workers: done");
|
|
11701
11855
|
return code;
|
|
11702
11856
|
}
|
|
11703
|
-
var TOOLS, STEWARD_TOOLS, OUTPUTS, EARLY_FAILURE_MS,
|
|
11857
|
+
var TOOLS, STEWARD_TOOLS, OUTPUTS, EARLY_FAILURE_MS, cgroupLimit, cgroupPeak, gb, memoryLine, shareOf, TOOL_RULE, SKILL, loadSkill, brief, briefComplete, briefVerify, KINDS, clock, checkNote;
|
|
11704
11858
|
var init_workers = __esmMin((() => {
|
|
11705
11859
|
init_ci();
|
|
11706
11860
|
init_data();
|
|
11707
11861
|
init_files();
|
|
11708
11862
|
init_repo();
|
|
11709
11863
|
init_rules();
|
|
11864
|
+
init_severity();
|
|
11710
11865
|
init_skillsDir();
|
|
11711
11866
|
init_stewardAudit();
|
|
11712
11867
|
init_tier();
|
|
@@ -11714,7 +11869,6 @@ var init_workers = __esmMin((() => {
|
|
|
11714
11869
|
STEWARD_TOOLS = "Skill,Bash(git:git diff*|git log*|git show*),Read,Glob,Grep,Write";
|
|
11715
11870
|
OUTPUTS = new RegExp(`^${AUDIT_DIR.replace(".", "\\.")}/`);
|
|
11716
11871
|
EARLY_FAILURE_MS = 6e4;
|
|
11717
|
-
RETRY_DELAY_MS = 3e3;
|
|
11718
11872
|
cgroupLimit = () => cgroupBytes(["/sys/fs/cgroup/memory.max", "/sys/fs/cgroup/memory/memory.limit_in_bytes"]);
|
|
11719
11873
|
cgroupPeak = () => cgroupBytes(["/sys/fs/cgroup/memory.peak", "/sys/fs/cgroup/memory/memory.max_usage_in_bytes"]);
|
|
11720
11874
|
gb = (bytes) => `${(bytes / 1024 ** 3).toFixed(2)} GB`;
|
|
@@ -11740,7 +11894,7 @@ Judge checks 1–5 over every requirement of the part. ${TOOL_RULE}
|
|
|
11740
11894
|
|
|
11741
11895
|
${KEY_STYLE}
|
|
11742
11896
|
|
|
11743
|
-
Write the findings file at the path above. Then return one line: the path and your counts per
|
|
11897
|
+
Write the findings file at the path above. Then return one line: the path and your counts per band (ERROR, WARN, INFO).
|
|
11744
11898
|
`;
|
|
11745
11899
|
briefComplete = (p, short, reader, file, repo) => {
|
|
11746
11900
|
const ids = short.requirementIds.length ? short.requirementIds.join("\n") : "(none)";
|
|
@@ -11764,12 +11918,16 @@ The coverage map names only the checks this brief names. The judged list names o
|
|
|
11764
11918
|
|
|
11765
11919
|
${KEY_STYLE}
|
|
11766
11920
|
|
|
11767
|
-
Write the findings file at the path above. Then return one line: the path and your counts per
|
|
11921
|
+
Write the findings file at the path above. Then return one line: the path and your counts per band (ERROR, WARN, INFO).
|
|
11768
11922
|
`;
|
|
11769
11923
|
};
|
|
11770
|
-
briefVerify = (f, p, file, repo) => {
|
|
11771
|
-
const { kind, where, detail, readerConfidence, quotes } = f;
|
|
11772
|
-
|
|
11924
|
+
briefVerify = (f, p, file, repo, t = THRESHOLDS) => {
|
|
11925
|
+
const { kind, where, detail, readerSeverity, readerConfidence, quotes } = f;
|
|
11926
|
+
const numbers = t.judgeReaderNumbers === "show" ? {
|
|
11927
|
+
readerSeverity,
|
|
11928
|
+
readerConfidence
|
|
11929
|
+
} : {};
|
|
11930
|
+
return `You are the judge for ONE finding of the spec-verify audit in repo ${repo}. The reader rated it severe.${f.cap ? "" : " The tool found its quotes at their lines."} Give your own reading of it: its severity and your confidence.
|
|
11773
11931
|
|
|
11774
11932
|
These are your judging rules.
|
|
11775
11933
|
|
|
@@ -11784,22 +11942,22 @@ ${toYaml({
|
|
|
11784
11942
|
kind,
|
|
11785
11943
|
where,
|
|
11786
11944
|
detail,
|
|
11787
|
-
|
|
11945
|
+
...numbers,
|
|
11788
11946
|
quotes
|
|
11789
11947
|
})}
|
|
11790
11948
|
Read, with the Read and Grep tools only: the requirement's block in the part's evidence files (${p?.files.join(", ") ?? `.spec-audit/parts/`}), the quoted sources and the code near them. Other commands are denied and only cost a turn.
|
|
11791
11949
|
|
|
11792
11950
|
Write this YAML to ${file} with the Write tool, and nothing else:
|
|
11793
|
-
|
|
11951
|
+
judgeSeverity: an integer from 0 to 100 on the severity scale of your rules (0 when the finding is not true)
|
|
11952
|
+
judgeConfidence: an integer from 0 to 100
|
|
11794
11953
|
reason: |
|
|
11795
|
-
|
|
11954
|
+
why this severity: the production effect, or the statement that is not true
|
|
11796
11955
|
scenario: |
|
|
11797
|
-
|
|
11798
|
-
judgeConfidence: an integer from 0 to 100
|
|
11956
|
+
required when judgeSeverity is ${t.error} or more: the production scenario in one sentence
|
|
11799
11957
|
|
|
11800
11958
|
${KEY_STYLE}
|
|
11801
11959
|
|
|
11802
|
-
Then return one line: the path and
|
|
11960
|
+
Then return one line: the path and your severity.
|
|
11803
11961
|
`;
|
|
11804
11962
|
};
|
|
11805
11963
|
KINDS = {
|
|
@@ -11813,11 +11971,18 @@ Then return one line: the path and the verdict.
|
|
|
11813
11971
|
briefComplete,
|
|
11814
11972
|
findingsSchema: READER_FINDINGS,
|
|
11815
11973
|
verdictSchema: JUDGE_VERDICT,
|
|
11816
|
-
targets: (data, partOf
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11974
|
+
targets: (data, partOf, env) => {
|
|
11975
|
+
const t = thresholds(env);
|
|
11976
|
+
const { judged, unsure, mild } = judgeGate(data.findings, t);
|
|
11977
|
+
return {
|
|
11978
|
+
list: judged.map((f) => ({
|
|
11979
|
+
label: f.where,
|
|
11980
|
+
brief: (file, repo) => briefVerify(f, partOf(f.part), file, repo, t)
|
|
11981
|
+
})),
|
|
11982
|
+
note: `judge gate: severity ${t.judgeFrom} or more and reader confidence ${t.judgeMinConfidence}% or more — ${unsure} severe finding(s) held back as unsure, ${mild} below the severity`
|
|
11983
|
+
};
|
|
11984
|
+
},
|
|
11985
|
+
none: "no finding is severe and sure enough for the judge"
|
|
11821
11986
|
},
|
|
11822
11987
|
"spec-steward": {
|
|
11823
11988
|
files: AUDIT_FILES["spec-steward"],
|
|
@@ -11829,10 +11994,10 @@ Then return one line: the path and the verdict.
|
|
|
11829
11994
|
briefComplete: briefComplete$1,
|
|
11830
11995
|
findingsSchema: STEWARD_FINDINGS,
|
|
11831
11996
|
verdictSchema: STEWARD_VERDICT,
|
|
11832
|
-
targets: (data) => data.candidates.map((c) => ({
|
|
11997
|
+
targets: (data) => ({ list: data.candidates.map((c) => ({
|
|
11833
11998
|
label: `${c.file}:${c.line}`,
|
|
11834
11999
|
brief: (file, repo) => briefVerify$1(c, file, repo)
|
|
11835
|
-
})),
|
|
12000
|
+
})) }),
|
|
11836
12001
|
none: "no finding stands"
|
|
11837
12002
|
}
|
|
11838
12003
|
};
|
|
@@ -11842,18 +12007,16 @@ Then return one line: the path and the verdict.
|
|
|
11842
12007
|
//#endregion
|
|
11843
12008
|
//#region spec-tools/src/auditReport.ts
|
|
11844
12009
|
var auditReport_exports = /* @__PURE__ */ __exportAll({
|
|
11845
|
-
BLOCKING: () => 80,
|
|
11846
12010
|
CHECKS: () => CHECKS,
|
|
11847
12011
|
ERROR_CLASS: () => ERROR_CLASS,
|
|
11848
12012
|
INFO_CLASS: () => INFO_CLASS,
|
|
11849
12013
|
MERGE_FILE: () => MERGE_FILE,
|
|
11850
|
-
SURE: () => 70,
|
|
11851
12014
|
VERDICT_FILE: () => VERDICT_FILE,
|
|
11852
12015
|
WARN_CLASS: () => WARN_CLASS,
|
|
11853
12016
|
applyVerdicts: () => applyVerdicts,
|
|
12017
|
+
capOf: () => capOf,
|
|
11854
12018
|
cli: () => cli,
|
|
11855
12019
|
commitReader: () => commitReader,
|
|
11856
|
-
confidenceOfError: () => confidenceOfError,
|
|
11857
12020
|
coverageEntry: () => coverageEntry,
|
|
11858
12021
|
dedupe: () => dedupe,
|
|
11859
12022
|
exitCodeFor: () => exitCodeFor,
|
|
@@ -11905,64 +12068,65 @@ function quoteFound(quote, lines) {
|
|
|
11905
12068
|
return false;
|
|
11906
12069
|
}
|
|
11907
12070
|
/**
|
|
11908
|
-
* The
|
|
11909
|
-
*
|
|
11910
|
-
*
|
|
11911
|
-
*
|
|
11912
|
-
*
|
|
11913
|
-
* note, never invented into a failure.
|
|
12071
|
+
* The highest severity a finding can reach, and why, from deterministic rules alone: INFO-class kinds and kinds the
|
|
12072
|
+
* contract does not name stay below the WARN band; a WARN-class kind (a specification defect) and a finding against an
|
|
12073
|
+
* ⚠️ Advisory requirement stay below the ERROR band; and an ERROR-class kind reaches the ERROR band only when at least
|
|
12074
|
+
* two of its quotes — both sides, from the repository — are found at their lines. The lowest cap that applies wins;
|
|
12075
|
+
* none applies to a proved ERROR-class finding.
|
|
11914
12076
|
*/
|
|
11915
|
-
function
|
|
11916
|
-
const graded = gradeKind(finding, part, read);
|
|
11917
|
-
if (graded.tier !== "ERROR" || !advisory?.has(unitOf(finding.where))) return graded;
|
|
11918
|
-
return {
|
|
11919
|
-
...graded,
|
|
11920
|
-
tier: "WARN",
|
|
11921
|
-
regraded: "the requirement is ⚠️ Advisory: a finding against it is at most WARN"
|
|
11922
|
-
};
|
|
11923
|
-
}
|
|
11924
|
-
function gradeKind(finding, part, read) {
|
|
12077
|
+
function capOf(finding, read, advisory, t = THRESHOLDS) {
|
|
11925
12078
|
const kind = finding.kind;
|
|
11926
12079
|
if (INFO_CLASS.includes(kind)) return {
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
12080
|
+
severity: t.warn - 1,
|
|
12081
|
+
reason: `${kind} is INFO-class`
|
|
12082
|
+
};
|
|
12083
|
+
if (!ERROR_CLASS.includes(kind) && !WARN_CLASS.includes(kind)) return {
|
|
12084
|
+
severity: t.warn - 1,
|
|
12085
|
+
reason: `kind \`${kind}\` is not in the contract's list`
|
|
11931
12086
|
};
|
|
11932
12087
|
if (WARN_CLASS.includes(kind)) return {
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
part,
|
|
11936
|
-
regraded: finding.tier === "ERROR" ? `${kind} is a specification defect: WARN at most` : void 0
|
|
12088
|
+
severity: t.error - 1,
|
|
12089
|
+
reason: `${kind} is a specification defect: WARN at most`
|
|
11937
12090
|
};
|
|
11938
|
-
if (
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
part,
|
|
11942
|
-
regraded: `kind \`${kind}\` is not in the contract's list`
|
|
11943
|
-
};
|
|
11944
|
-
if (finding.tier !== "ERROR") return {
|
|
11945
|
-
...finding,
|
|
11946
|
-
part
|
|
12091
|
+
if (advisory?.has(unitOf(finding.where))) return {
|
|
12092
|
+
severity: t.error - 1,
|
|
12093
|
+
reason: "the requirement is ⚠️ Advisory: a finding against it is at most WARN"
|
|
11947
12094
|
};
|
|
11948
12095
|
const quotes = (finding.quotes ?? []).filter((q) => !isForeign(q.file));
|
|
11949
|
-
const missing = quotes.filter((q) => !quoteFound(q, read(q.file)));
|
|
11950
12096
|
if (quotes.length < 2) return {
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
part,
|
|
11954
|
-
regraded: "ERROR needs both sides quoted from the sources; fewer than two such quotes"
|
|
12097
|
+
severity: t.error - 1,
|
|
12098
|
+
reason: "ERROR needs both sides quoted from the sources; fewer than two such quotes"
|
|
11955
12099
|
};
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
12100
|
+
const missing = quotes.filter((q) => !quoteFound(q, read(q.file)));
|
|
12101
|
+
if (missing.length) return {
|
|
12102
|
+
severity: t.error - 1,
|
|
12103
|
+
reason: `re-proof failed: not found at ${missing.map((q) => `\`${q.file}:${q.line}\``).join(", ")}`
|
|
12104
|
+
};
|
|
12105
|
+
}
|
|
12106
|
+
/** A reading under a cap, its tier, and the cap's reason when the cap lowered it. */
|
|
12107
|
+
function graded(reading, cap, t) {
|
|
12108
|
+
const severity = cap ? Math.min(reading.severity, cap.severity) : reading.severity;
|
|
12109
|
+
const at = {
|
|
12110
|
+
severity,
|
|
12111
|
+
confidence: reading.confidence
|
|
12112
|
+
};
|
|
12113
|
+
return {
|
|
12114
|
+
...at,
|
|
12115
|
+
tier: tierOf$1(at, t),
|
|
12116
|
+
...cap && severity < reading.severity ? { regraded: cap.reason } : {}
|
|
11961
12117
|
};
|
|
12118
|
+
}
|
|
12119
|
+
/** A reader's finding, graded: its reading under its cap, and the tier the thresholds give it. */
|
|
12120
|
+
function grade(finding, part, read, advisory, t = THRESHOLDS) {
|
|
12121
|
+
const cap = capOf(finding, read, advisory, t);
|
|
11962
12122
|
return {
|
|
11963
12123
|
...finding,
|
|
11964
|
-
|
|
11965
|
-
|
|
12124
|
+
part,
|
|
12125
|
+
...cap ? { cap } : {},
|
|
12126
|
+
...graded({
|
|
12127
|
+
severity: finding.readerSeverity,
|
|
12128
|
+
confidence: finding.readerConfidence
|
|
12129
|
+
}, cap, t)
|
|
11966
12130
|
};
|
|
11967
12131
|
}
|
|
11968
12132
|
/**
|
|
@@ -11977,9 +12141,12 @@ function partCoverage(readers) {
|
|
|
11977
12141
|
note: "no findings file"
|
|
11978
12142
|
};
|
|
11979
12143
|
}
|
|
11980
|
-
/**
|
|
12144
|
+
/**
|
|
12145
|
+
* What a part's readers claimed of their own coverage of a check, when they claimed less than full. A claim is what a
|
|
12146
|
+
* reader wrote: a check its coverage map leaves out (a completion reader names only the checks of its brief) is none.
|
|
12147
|
+
*/
|
|
11981
12148
|
function readerClaims(readers, check) {
|
|
11982
|
-
return readers.filter((r) => r !== void 0).map((r) => coverageEntry(r.coverage
|
|
12149
|
+
return readers.filter((r) => r?.coverage?.[check] !== void 0).map((r) => coverageEntry(r.coverage[check])).filter((e) => e.status !== "full").map((e) => `${e.status}${e.note ? `: ${e.note}` : ""}`);
|
|
11983
12150
|
}
|
|
11984
12151
|
/**
|
|
11985
12152
|
* The requirements of a part no reader listed as judged. A reader's claim of full coverage is only as
|
|
@@ -12030,13 +12197,8 @@ function shortList(parts, expected) {
|
|
|
12030
12197
|
const ids = expected.get(n) ?? [];
|
|
12031
12198
|
const requirementIds = ids.length ? unjudged(readers, ids) : [];
|
|
12032
12199
|
const checks = {};
|
|
12033
|
-
const
|
|
12034
|
-
for (const check of Object.keys(CHECKS)) {
|
|
12035
|
-
const entry = partCoverage(readers);
|
|
12036
|
-
const claims = readerClaims(readers, check);
|
|
12037
|
-
if (entry.status !== "full") checks[check] = `${entry.status}${entry.note ? `: ${entry.note}` : ""}`;
|
|
12038
|
-
else if (claims.length && claims.length === present) checks[check] = claims[0];
|
|
12039
|
-
}
|
|
12200
|
+
const entry = partCoverage(readers);
|
|
12201
|
+
if (entry.status !== "full") for (const check of Object.keys(CHECKS)) checks[check] = `${entry.status}${entry.note ? `: ${entry.note}` : ""}`;
|
|
12040
12202
|
if (requirementIds.length || Object.keys(checks).length) out.push({
|
|
12041
12203
|
part: n,
|
|
12042
12204
|
requirementIds,
|
|
@@ -12058,7 +12220,7 @@ function readerFiles(listed, present, part) {
|
|
|
12058
12220
|
/**
|
|
12059
12221
|
* Two readers of one part report the same defect in their own words; it is one finding. Two
|
|
12060
12222
|
* findings are the same when they share a kind and a quoted `file:line`, or a kind and a `where`;
|
|
12061
|
-
* the
|
|
12223
|
+
* the more severe twin, after its cap, stands.
|
|
12062
12224
|
*/
|
|
12063
12225
|
function dedupe(findings) {
|
|
12064
12226
|
const kept = [];
|
|
@@ -12066,50 +12228,46 @@ function dedupe(findings) {
|
|
|
12066
12228
|
for (const f of findings) {
|
|
12067
12229
|
const at = kept.findIndex((k) => k.kind === f.kind && (normalize(k.where) === normalize(f.where) || sameQuote(k, f)));
|
|
12068
12230
|
if (at === -1) kept.push(f);
|
|
12069
|
-
else if (
|
|
12231
|
+
else if (f.severity > kept[at].severity) kept[at] = f;
|
|
12070
12232
|
}
|
|
12071
12233
|
return kept;
|
|
12072
12234
|
}
|
|
12073
12235
|
/**
|
|
12074
|
-
* The verification pass's answers, applied.
|
|
12075
|
-
* finding alone — the judge — which
|
|
12076
|
-
*
|
|
12077
|
-
*
|
|
12078
|
-
*
|
|
12079
|
-
*
|
|
12080
|
-
*
|
|
12081
|
-
*
|
|
12236
|
+
* The verification pass's answers, applied. A finding the reader rated severe and sure enough (`isJudged`) is put to
|
|
12237
|
+
* one more reader over that finding alone — the judge — which gives its own severity and confidence; the two readings
|
|
12238
|
+
* are fused (`fuse`), the finding's cap applies again, and the thresholds give the tier. A judge reading in the ERROR
|
|
12239
|
+
* band with no production scenario caps the finding below that band. A finding the pass never reached (no verdict
|
|
12240
|
+
* written although the pass ran) keeps the reader's reading, which is an ERROR only above `sure`; without the pass,
|
|
12241
|
+
* nothing changes. A verdict answers the judged finding at its position: `verdict-<k>.yaml` is the k-th judged finding
|
|
12242
|
+
* of the merge the verification pass started from, and the merge after it, over the same findings files, lists the
|
|
12243
|
+
* same findings in the same order.
|
|
12082
12244
|
*/
|
|
12083
|
-
function applyVerdicts(findings, verdicts, ran) {
|
|
12245
|
+
function applyVerdicts(findings, verdicts, ran, t = THRESHOLDS) {
|
|
12084
12246
|
let k = 0;
|
|
12085
12247
|
return findings.map((f) => {
|
|
12086
|
-
if (f
|
|
12248
|
+
if (!isJudged(f, t)) return f;
|
|
12087
12249
|
const v = verdicts.get(++k);
|
|
12088
12250
|
if (!v) {
|
|
12089
12251
|
if (!ran) return f;
|
|
12090
|
-
|
|
12091
|
-
return reader > 70 ? {
|
|
12092
|
-
...f,
|
|
12093
|
-
verified: `unverified — no verdict was written; the reader is ${reader}% sure`
|
|
12094
|
-
} : {
|
|
12252
|
+
return {
|
|
12095
12253
|
...f,
|
|
12096
|
-
|
|
12097
|
-
verified: `unverified — no verdict was written, and the reader is only ${reader}% sure`
|
|
12254
|
+
verified: `unverified — no verdict was written; the reader's severity ${f.severity} at ${f.confidence}% stands`
|
|
12098
12255
|
};
|
|
12099
12256
|
}
|
|
12100
|
-
const
|
|
12257
|
+
const cap = v.judgeSeverity >= t.error && !v.scenario?.trim() && (f.cap?.severity ?? 100) >= t.error ? {
|
|
12258
|
+
severity: t.error - 1,
|
|
12259
|
+
reason: "the judge gave an ERROR-band severity with no production scenario"
|
|
12260
|
+
} : f.cap;
|
|
12261
|
+
return {
|
|
12101
12262
|
...f,
|
|
12263
|
+
judgeSeverity: v.judgeSeverity,
|
|
12102
12264
|
judgeConfidence: v.judgeConfidence,
|
|
12103
|
-
...v.scenario ? { scenario: v.scenario } : {}
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
return {
|
|
12110
|
-
...judged,
|
|
12111
|
-
tier: "WARN",
|
|
12112
|
-
verified: v.verdict === "confirmed" ? `confirmed, but the judge is only ${v.judgeConfidence}% sure — ${v.reason}` : `not confirmed — ${v.reason}`
|
|
12265
|
+
...v.scenario ? { scenario: v.scenario } : {},
|
|
12266
|
+
...graded(fuse([f, {
|
|
12267
|
+
severity: v.judgeSeverity,
|
|
12268
|
+
confidence: v.judgeConfidence
|
|
12269
|
+
}], t.ignoreGap), cap, t),
|
|
12270
|
+
verified: `judge: severity ${v.judgeSeverity} at ${v.judgeConfidence}% — ${v.reason}`
|
|
12113
12271
|
};
|
|
12114
12272
|
});
|
|
12115
12273
|
}
|
|
@@ -12124,7 +12282,7 @@ function readVerdicts(problems) {
|
|
|
12124
12282
|
const text = fs$1.readFileSync(path$1.join(dir, name), "utf8");
|
|
12125
12283
|
const errors = checkData(text, JUDGE_VERDICT);
|
|
12126
12284
|
if (errors.length) {
|
|
12127
|
-
problems.push(`\`${FINDINGS_DIR}/${name}\` is not a valid verdict: ${errors.join("; ")} — its
|
|
12285
|
+
problems.push(`\`${FINDINGS_DIR}/${name}\` is not a valid verdict: ${errors.join("; ")} — its finding counts as unverified.`);
|
|
12128
12286
|
continue;
|
|
12129
12287
|
}
|
|
12130
12288
|
out.set(Number(k), parseData(text));
|
|
@@ -12132,15 +12290,15 @@ function readVerdicts(problems) {
|
|
|
12132
12290
|
return out;
|
|
12133
12291
|
}
|
|
12134
12292
|
/**
|
|
12135
|
-
* The verdict: FAIL when an ERROR stands above `
|
|
12136
|
-
* none stands but a check fell short; PASS otherwise.
|
|
12293
|
+
* The verdict: FAIL when an ERROR stands at a confidence above `blocking`; ADVISORY when ERRORs stand, none above it;
|
|
12294
|
+
* INCOMPLETE when none stands but a check fell short; PASS otherwise.
|
|
12137
12295
|
*/
|
|
12138
|
-
function verdict(findings, coverage) {
|
|
12296
|
+
function verdict(findings, coverage, t = THRESHOLDS) {
|
|
12139
12297
|
const standing = findings.filter((f) => f.tier === "ERROR");
|
|
12140
12298
|
const errors = standing.length;
|
|
12141
12299
|
const warnings = findings.filter((f) => f.tier === "WARN").length;
|
|
12142
12300
|
const incomplete = Object.values(coverage).some((c) => c.status !== "full");
|
|
12143
|
-
const state = standing.some((f) =>
|
|
12301
|
+
const state = standing.some((f) => f.confidence > t.blocking) ? "FAIL" : errors > 0 ? "ADVISORY" : incomplete ? "INCOMPLETE" : "PASS";
|
|
12144
12302
|
return {
|
|
12145
12303
|
state,
|
|
12146
12304
|
errors,
|
|
@@ -12152,18 +12310,20 @@ function verdict(findings, coverage) {
|
|
|
12152
12310
|
* The developer's report: the verdict, what errored and what drifted — one line each — the INFO findings as counts,
|
|
12153
12311
|
* and the checks that fell short. Quotes, full details and INFO findings are in `.spec-audit/spec-verify.yaml`.
|
|
12154
12312
|
*/
|
|
12155
|
-
function render(scopeHeader, findings, coverage, problems) {
|
|
12313
|
+
function render(scopeHeader, findings, coverage, problems, t = THRESHOLDS) {
|
|
12156
12314
|
const out = [
|
|
12157
|
-
verdict(findings, coverage).line,
|
|
12315
|
+
verdict(findings, coverage, t).line,
|
|
12158
12316
|
"",
|
|
12159
12317
|
...scopeHeader,
|
|
12318
|
+
"",
|
|
12319
|
+
`Graded by: ${describeThresholds(t)}.`,
|
|
12160
12320
|
""
|
|
12161
12321
|
];
|
|
12162
12322
|
if (problems.length) out.push("## Problems with the workers' output", "", ...problems.map((p) => `- ${p}`), "");
|
|
12163
12323
|
const sections = [
|
|
12164
|
-
[`Errors that fail the run —
|
|
12165
|
-
[`Advisory errors —
|
|
12166
|
-
[
|
|
12324
|
+
[`Errors that fail the run — severity ${t.error} or more, confidence above ${t.blocking}%`, (f) => f.tier === "ERROR" && f.confidence > t.blocking],
|
|
12325
|
+
[`Advisory errors — severity ${t.error} or more, confidence above ${t.sure}%, at ${t.blocking}% or lower`, (f) => f.tier === "ERROR" && f.confidence <= t.blocking],
|
|
12326
|
+
[`Warnings — severity ${t.warn} or more, or severe but not sure enough for an ERROR`, (f) => f.tier === "WARN"]
|
|
12167
12327
|
];
|
|
12168
12328
|
for (const [title, belongs] of sections) {
|
|
12169
12329
|
const items = findings.filter(belongs).sort((a, b) => a.kind.localeCompare(b.kind) || a.where.localeCompare(b.where));
|
|
@@ -12202,7 +12362,8 @@ function scopeHeader(scope) {
|
|
|
12202
12362
|
`Every capability under \`openspec/specs/\`, in ${scope.parts.length} parts.`
|
|
12203
12363
|
];
|
|
12204
12364
|
}
|
|
12205
|
-
function main$1(read = commitReader) {
|
|
12365
|
+
function main$1(read = commitReader, env = process.env) {
|
|
12366
|
+
const t = thresholds(env);
|
|
12206
12367
|
const units = tryReadData(path$1.join(root(), UNITS_FILE)) ?? {};
|
|
12207
12368
|
const advisory = new Set(Object.entries(units).flatMap(([id, u]) => u.advisory ? [id] : []));
|
|
12208
12369
|
const scopePath = path$1.join(root(), SCOPE_FILE);
|
|
@@ -12237,20 +12398,21 @@ function main$1(read = commitReader) {
|
|
|
12237
12398
|
const present = fs$1.existsSync(dir) ? fs$1.readdirSync(dir).map((f) => `${FINDINGS_DIR}/${f}`) : [];
|
|
12238
12399
|
for (let n = 1; n <= expected; n++) parts.set(n, readPart(readerFiles(scope?.parts[n - 1]?.findings ?? defaults(n), present, n), n));
|
|
12239
12400
|
const findings = applyVerdicts(dedupe([...parts.values()].flatMap((readers) => readers.flatMap((p, index) => p ? p.findings.map((f) => ({
|
|
12240
|
-
...grade(f, p.part, read, advisory),
|
|
12401
|
+
...grade(f, p.part, read, advisory, t),
|
|
12241
12402
|
reader: index + 1
|
|
12242
|
-
})) : []))), readVerdicts(problems), fs$1.existsSync(path$1.join(root(), VERIFIED_MARKER)));
|
|
12403
|
+
})) : []))), readVerdicts(problems), fs$1.existsSync(path$1.join(root(), VERIFIED_MARKER)), t);
|
|
12243
12404
|
const expectedIds = new Map((scope?.parts ?? []).map((p) => [p.part, p.requirementIds ?? []]));
|
|
12244
12405
|
const coverage = mergeCoverage(parts, expectedIds);
|
|
12245
|
-
const report = render(header, findings, coverage, problems);
|
|
12406
|
+
const report = render(header, findings, coverage, problems, t);
|
|
12246
12407
|
fs$1.mkdirSync(path$1.dirname(path$1.join(root(), REPORT_FILE)), { recursive: true });
|
|
12247
12408
|
fs$1.writeFileSync(path$1.join(root(), REPORT_FILE), report);
|
|
12248
|
-
const v = verdict(findings, coverage);
|
|
12409
|
+
const v = verdict(findings, coverage, t);
|
|
12249
12410
|
const data = {
|
|
12250
12411
|
verdict: v.line,
|
|
12251
12412
|
state: v.state,
|
|
12252
12413
|
errors: v.errors,
|
|
12253
12414
|
warnings: v.warnings,
|
|
12415
|
+
thresholds: t,
|
|
12254
12416
|
findings,
|
|
12255
12417
|
short: shortList(parts, expectedIds)
|
|
12256
12418
|
};
|
|
@@ -12266,14 +12428,14 @@ function cli(argv) {
|
|
|
12266
12428
|
process.stdout.write(line + "\n");
|
|
12267
12429
|
return argv.includes("--gate") ? exitCodeFor(line.split(" ")[0]) : 0;
|
|
12268
12430
|
}
|
|
12269
|
-
var MERGE_FILE, VERDICT_FILE,
|
|
12431
|
+
var MERGE_FILE, VERDICT_FILE, ERROR_CLASS, WARN_CLASS, INFO_CLASS, CHECKS, normalize, isForeign, gitReader, commitReader, worktreeReader, rank, exitCodeFor, unitOf, firstSentence, readingOf, findingLine;
|
|
12270
12432
|
var init_auditReport = __esmMin((() => {
|
|
12271
12433
|
init_data();
|
|
12272
12434
|
init_files();
|
|
12273
12435
|
init_repo();
|
|
12436
|
+
init_severity();
|
|
12274
12437
|
MERGE_FILE = /^merge-\d+\.yaml$/;
|
|
12275
12438
|
VERDICT_FILE = /^verdict-(\d+)\.yaml$/;
|
|
12276
|
-
confidenceOfError = (f) => f.judgeConfidence ?? f.readerConfidence ?? 0;
|
|
12277
12439
|
ERROR_CLASS = ["code-mismatch", "undeclared-gap"];
|
|
12278
12440
|
WARN_CLASS = ["conflict"];
|
|
12279
12441
|
INFO_CLASS = ["spec-dup", "untested"];
|
|
@@ -12315,11 +12477,6 @@ var init_auditReport = __esmMin((() => {
|
|
|
12315
12477
|
sampled: 1,
|
|
12316
12478
|
"not-run": 2
|
|
12317
12479
|
};
|
|
12318
|
-
tierRank = {
|
|
12319
|
-
ERROR: 0,
|
|
12320
|
-
WARN: 1,
|
|
12321
|
-
INFO: 2
|
|
12322
|
-
};
|
|
12323
12480
|
exitCodeFor = (state) => ({
|
|
12324
12481
|
FAIL: 1,
|
|
12325
12482
|
ADVISORY: 77,
|
|
@@ -12331,18 +12488,17 @@ var init_auditReport = __esmMin((() => {
|
|
|
12331
12488
|
const end = flat.search(/[.!?](\s|$)/);
|
|
12332
12489
|
return end === -1 ? flat : flat.slice(0, end + 1);
|
|
12333
12490
|
};
|
|
12334
|
-
|
|
12491
|
+
readingOf = (f) => `severity ${f.severity} at ${f.confidence}% (reader ${f.readerSeverity} at ${f.readerConfidence}%${f.judgeSeverity !== void 0 ? `, judge ${f.judgeSeverity} at ${f.judgeConfidence}%` : ""})`;
|
|
12335
12492
|
findingLine = (f) => {
|
|
12336
12493
|
const [requirement, at] = f.where.split(" / ");
|
|
12337
12494
|
const place = at ?? (f.quotes?.[0] ? `${f.quotes[0].file}:${f.quotes[0].line}` : void 0);
|
|
12338
|
-
const confidence = confidenceOf(f);
|
|
12339
12495
|
return [
|
|
12340
12496
|
`- \`${f.kind}\``,
|
|
12341
12497
|
place ? ` \`${place}\`` : "",
|
|
12342
12498
|
` — \`${requirement}\``,
|
|
12343
12499
|
` — ${firstSentence(f.detail)}`,
|
|
12344
12500
|
f.tier === "ERROR" && f.scenario ? ` — **In production:** ${normalize(f.scenario)}` : "",
|
|
12345
|
-
|
|
12501
|
+
` — ${readingOf(f)}`,
|
|
12346
12502
|
f.regraded ? ` — _${f.regraded}_` : "",
|
|
12347
12503
|
f.verified ? ` — _${f.verified}_` : ""
|
|
12348
12504
|
].join("");
|
|
@@ -12353,7 +12509,7 @@ var init_auditReport = __esmMin((() => {
|
|
|
12353
12509
|
/**
|
|
12354
12510
|
* `spec-tools audit`: the CI sequence — the evidence model, scope, then the passes and merges in the order `workers.ts`
|
|
12355
12511
|
* describes — run by default from a DETACHED worktree of HEAD, so what is judged is exactly the commit CI judges: an
|
|
12356
|
-
* uncommitted edit, or a stale `.spec-audit/` in the working tree, cannot leak into the run, and
|
|
12512
|
+
* uncommitted edit, or a stale `.spec-audit/` in the working tree, cannot leak into the run, and each ERROR-band finding's
|
|
12357
12513
|
* quotes are re-proved against HEAD. The install is the working tree's (`node_modules` is linked in), and the run's
|
|
12358
12514
|
* outputs — evidence model, scope, evidence, findings, the merged report — come back to the working tree.
|
|
12359
12515
|
* `--here` runs on the working tree instead, uncommitted edits included, and re-proves quotes against it.
|
|
@@ -12583,8 +12739,9 @@ var init_run = __esmMin((() => {
|
|
|
12583
12739
|
* so the report's own verdict is the only signal that the REVIEW passed — without this a review job is a publisher, not
|
|
12584
12740
|
* a gate. The spec-verify merge's data (`.spec-audit/spec-verify.yaml`) carries its verdict as `verdict`. A
|
|
12585
12741
|
* skill-driven review writes a review report (`data.ts` `REVIEW_REPORT`), and its verdict is computed here, mechanically,
|
|
12586
|
-
* never taken from the model:
|
|
12587
|
-
*
|
|
12742
|
+
* never taken from the model: each finding's severity and confidence get their tier by the same thresholds as the
|
|
12743
|
+
* spec-verify merge (`severity.ts`) — one reading, no judge — and the review is INCOMPLETE when its coverage says so.
|
|
12744
|
+
* The Markdown report for people is rendered beside it.
|
|
12588
12745
|
*
|
|
12589
12746
|
* Exit codes: 0 PASS; 1 FAIL on a gating run, or no verdict; 77 FAIL on an advisory run (the job fails, a pipeline that
|
|
12590
12747
|
* allows 77 continues); 3 INCOMPLETE — no ERROR stands but a check was sampled or skipped, so the review cannot say what
|
|
@@ -12599,14 +12756,14 @@ var verdict_exports = /* @__PURE__ */ __exportAll({
|
|
|
12599
12756
|
verdictOf: () => verdictOf
|
|
12600
12757
|
});
|
|
12601
12758
|
/**
|
|
12602
|
-
* A review report's verdict, from its findings and coverage alone: FAIL when an ERROR stands above
|
|
12603
|
-
* ADVISORY when ERRORs stand and none is above it, INCOMPLETE when the coverage says so, PASS otherwise.
|
|
12759
|
+
* A review report's verdict, from its findings and coverage alone: FAIL when an ERROR stands at a confidence above
|
|
12760
|
+
* `blocking`, ADVISORY when ERRORs stand and none is above it, INCOMPLETE when the coverage says so, PASS otherwise.
|
|
12604
12761
|
*/
|
|
12605
|
-
function reviewVerdict(report) {
|
|
12606
|
-
const tiers = report.findings.map(tierOf);
|
|
12607
|
-
const errors = tiers.filter((
|
|
12608
|
-
const warnings = tiers.filter((
|
|
12609
|
-
const state = report.findings.some((f) => tierOf(f) === "ERROR" && f.readerConfidence >
|
|
12762
|
+
function reviewVerdict(report, t = THRESHOLDS) {
|
|
12763
|
+
const tiers = report.findings.map((f) => tierOf(f, t));
|
|
12764
|
+
const errors = tiers.filter((tier) => tier === "ERROR").length;
|
|
12765
|
+
const warnings = tiers.filter((tier) => tier === "WARN").length;
|
|
12766
|
+
const state = report.findings.some((f) => tierOf(f, t) === "ERROR" && f.readerConfidence > t.blocking) ? "FAIL" : errors > 0 ? "ADVISORY" : report.coverage.complete ? "PASS" : "INCOMPLETE";
|
|
12610
12767
|
return {
|
|
12611
12768
|
state,
|
|
12612
12769
|
errors,
|
|
@@ -12614,30 +12771,25 @@ function reviewVerdict(report) {
|
|
|
12614
12771
|
line: `${state} (${errors} errors, ${warnings} warnings)`
|
|
12615
12772
|
};
|
|
12616
12773
|
}
|
|
12617
|
-
/** The Markdown report for people: the verdict line first, then one table row per finding,
|
|
12618
|
-
function renderReview(report) {
|
|
12619
|
-
const v = reviewVerdict(report);
|
|
12774
|
+
/** The Markdown report for people: the verdict line first, then one table row per finding, the most severe first. */
|
|
12775
|
+
function renderReview(report, t = THRESHOLDS) {
|
|
12776
|
+
const v = reviewVerdict(report, t);
|
|
12620
12777
|
const extra = [...new Set(report.findings.flatMap((f) => Object.keys(f.fields ?? {})))];
|
|
12621
|
-
const
|
|
12622
|
-
ERROR: 0,
|
|
12623
|
-
WARN: 1,
|
|
12624
|
-
INFO: 2
|
|
12625
|
-
};
|
|
12626
|
-
const rows = [...report.findings].sort((a, b) => order[tierOf(a)] - order[tierOf(b)]);
|
|
12778
|
+
const rows = [...report.findings].sort((a, b) => b.readerSeverity - a.readerSeverity);
|
|
12627
12779
|
const out = [v.line, ""];
|
|
12628
12780
|
if (report.title) out.push(`# ${report.title}`, "");
|
|
12629
|
-
if (rows.length) out.push(`| Tier | Where | ${extra.map((k) => `${k} | `).join("")}What it does | Confidence |`, `| --- | --- | ${extra.map(() => "--- | ").join("")}--- | --- |`, ...rows.map((f) => `| ${tierOf(f
|
|
12781
|
+
if (rows.length) out.push(`| Tier | Where | ${extra.map((k) => `${k} | `).join("")}What it does | Severity | Confidence |`, `| --- | --- | ${extra.map(() => "--- | ").join("")}--- | --- | --- |`, ...rows.map((f) => `| ${tierOf(f, t)} | \`${cell(f.where)}\` | ${extra.map((k) => `${cell(f.fields?.[k] ?? "")} | `).join("")}${cell(f.detail)} | ${f.readerSeverity} | ${f.readerConfidence}% |`), "");
|
|
12630
12782
|
else out.push("_No findings._", "");
|
|
12631
12783
|
out.push("## Coverage", "", report.coverage.complete ? "Complete." : "Not complete.", "");
|
|
12632
12784
|
if (report.coverage.notes) out.push(report.coverage.notes.trim(), "");
|
|
12633
12785
|
return out.join("\n");
|
|
12634
12786
|
}
|
|
12635
12787
|
/** The verdict a report states or earns, or null when it has none. */
|
|
12636
|
-
function verdictOf(file, text) {
|
|
12788
|
+
function verdictOf(file, text, t = THRESHOLDS) {
|
|
12637
12789
|
if (/\.ya?ml$/.test(file)) {
|
|
12638
12790
|
const data = readData(file);
|
|
12639
12791
|
if (typeof data.verdict === "string") return STATE.exec(data.verdict)?.[0] ?? null;
|
|
12640
|
-
return Array.isArray(data.findings) && data.coverage ? reviewVerdict(data).state : null;
|
|
12792
|
+
return Array.isArray(data.findings) && data.coverage ? reviewVerdict(data, t).state : null;
|
|
12641
12793
|
}
|
|
12642
12794
|
return STATE.exec(text)?.[0] ?? null;
|
|
12643
12795
|
}
|
|
@@ -12650,33 +12802,37 @@ function exitFor(verdict, advisory) {
|
|
|
12650
12802
|
return 1;
|
|
12651
12803
|
}
|
|
12652
12804
|
/** `spec-tools verdict <report> [--advisory]`: a review report's Markdown is rendered beside it, then gated. */
|
|
12653
|
-
function gate(file, advisory) {
|
|
12805
|
+
function gate(file, advisory, env = process.env) {
|
|
12806
|
+
const t = thresholds(env);
|
|
12654
12807
|
if (!fs$1.existsSync(file)) {
|
|
12655
12808
|
console.error(`ERROR: ${file} was not written — the review did not complete.`);
|
|
12656
12809
|
return 1;
|
|
12657
12810
|
}
|
|
12658
12811
|
if (/\.ya?ml$/.test(file)) {
|
|
12659
12812
|
const data = readData(file);
|
|
12660
|
-
if (typeof data.verdict !== "string" && Array.isArray(data.findings) && data.coverage) fs$1.writeFileSync(file.replace(/\.ya?ml$/, ".md"), renderReview(data));
|
|
12813
|
+
if (typeof data.verdict !== "string" && Array.isArray(data.findings) && data.coverage) fs$1.writeFileSync(file.replace(/\.ya?ml$/, ".md"), renderReview(data, t));
|
|
12661
12814
|
}
|
|
12662
|
-
const verdict = verdictOf(file, fs$1.readFileSync(file, "utf8"));
|
|
12815
|
+
const verdict = verdictOf(file, fs$1.readFileSync(file, "utf8"), t);
|
|
12663
12816
|
if (!verdict) {
|
|
12664
12817
|
console.error(`ERROR: no verdict (PASS / FAIL / INCOMPLETE) found in ${file}.`);
|
|
12665
12818
|
return 1;
|
|
12666
12819
|
}
|
|
12667
12820
|
console.log(`verdict: ${verdict}`);
|
|
12668
12821
|
const code = exitFor(verdict, advisory);
|
|
12669
|
-
if (code === 77) console.error(verdict.startsWith("ADVISORY") ? `ERROR findings in ${file}, none above
|
|
12822
|
+
if (code === 77) console.error(verdict.startsWith("ADVISORY") ? `ERROR findings in ${file}, none above ${t.blocking}% confidence: advisory — the job fails, the pipeline continues.` : `ERROR findings in ${file}; an advisory run: the job fails, the pipeline continues.`);
|
|
12670
12823
|
else if (code === 1) console.error(`ERROR findings in ${file} — see it in this job's artifacts.`);
|
|
12671
12824
|
else if (code === 3) console.error(`INCOMPLETE: the review did not cover its whole scope — see the coverage in ${file}.`);
|
|
12672
12825
|
return code;
|
|
12673
12826
|
}
|
|
12674
12827
|
var STATE, tierOf, cell;
|
|
12675
12828
|
var init_verdict = __esmMin((() => {
|
|
12676
|
-
init_auditReport();
|
|
12677
12829
|
init_data();
|
|
12830
|
+
init_severity();
|
|
12678
12831
|
STATE = /^(PASS|FAIL|ADVISORY|INCOMPLETE)\S*/m;
|
|
12679
|
-
tierOf = (f
|
|
12832
|
+
tierOf = (f, t = THRESHOLDS) => tierOf$1({
|
|
12833
|
+
severity: f.readerSeverity,
|
|
12834
|
+
confidence: f.readerConfidence
|
|
12835
|
+
}, t);
|
|
12680
12836
|
cell = (s) => String(s ?? "").replace(/\s+/g, " ").trim().replace(/\|/g, "\\|");
|
|
12681
12837
|
}));
|
|
12682
12838
|
//#endregion
|
|
@@ -12727,7 +12883,8 @@ function comment(reviews, env = process.env) {
|
|
|
12727
12883
|
const diff = read(DIFF_FILE);
|
|
12728
12884
|
if (diff !== void 0) out.push(`Specification diff — ${diff.split("\n")[0]}: ${reports(DIFF_FILE.replace(/\.md$/, ""))}`, "");
|
|
12729
12885
|
const gating = env.AUDIT_GATING || "gating";
|
|
12730
|
-
|
|
12886
|
+
const t = thresholds(env);
|
|
12887
|
+
out.push(`This was ${gating === "advisory" ? "an advisory" : "a gating"} run (${env.AUDIT_RUN || "unknown"}, scope ${env.AUDIT_SCOPE || "corpus"}, judged by ${env.AUDIT_MODEL_VERIFY || "unknown"}). Each finding has a severity and a confidence, from the reader and from its judge, fused into one pair. An ERROR is a demonstrated defect with a production effect: severity ${t.error} or more, at a confidence above ${t.sure}%. An ERROR above ${t.blocking}% fails a gating run (FAIL); ERRORs at ${t.blocking}% or lower are ADVISORY and, like any ERROR on an advisory run, mark the job failed (exit 77) without stopping the pipeline; an INCOMPLETE review — one that left part of its scope unjudged — fails its job with exit code 3. WARN and INFO are published for triage.${id && url ? ` Pipeline [#${id}](${url}).` : ""}`);
|
|
12731
12888
|
const text = out.join("\n") + "\n";
|
|
12732
12889
|
fs$1.mkdirSync(path$1.dirname(COMMENT_FILE), { recursive: true });
|
|
12733
12890
|
fs$1.writeFileSync(COMMENT_FILE, text);
|
|
@@ -12737,6 +12894,7 @@ var MARKS, read;
|
|
|
12737
12894
|
var init_comment = __esmMin((() => {
|
|
12738
12895
|
init_ci();
|
|
12739
12896
|
init_files();
|
|
12897
|
+
init_severity();
|
|
12740
12898
|
MARKS = {
|
|
12741
12899
|
PASS: "✅ OK",
|
|
12742
12900
|
INCOMPLETE: "❌ Incomplete",
|
|
@@ -14612,6 +14770,9 @@ async function main() {
|
|
|
14612
14770
|
console.error(`spec-tools: unknown or incomplete command ${[command, ...argv].join(" ") || "(none)"}`);
|
|
14613
14771
|
return 2;
|
|
14614
14772
|
}
|
|
14615
|
-
process.exitCode = await main()
|
|
14773
|
+
process.exitCode = await main().catch((error) => {
|
|
14774
|
+
console.error(`spec-tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
14775
|
+
return 2;
|
|
14776
|
+
});
|
|
14616
14777
|
//#endregion
|
|
14617
14778
|
export {};
|