@mstar-harness/cli 3.9.1 → 3.9.3
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/dist/mstar-harness.js +354 -36
- package/package.json +1 -1
package/dist/mstar-harness.js
CHANGED
|
@@ -2888,12 +2888,18 @@ var REQUIRED_FIELDS = [
|
|
|
2888
2888
|
{ key: "delegation", label: "Delegation", code: "delegation" },
|
|
2889
2889
|
{ key: "taskCategory", label: "Task category", code: "task-category" }
|
|
2890
2890
|
];
|
|
2891
|
+
var REVIEW_SEAT_ROLES = ["qc-specialist", "qc-specialist-2", "qc-specialist-3", "code-reviewer", "qa-engineer"];
|
|
2892
|
+
var BUDGET_LABELS = ["Budget (review / QC seats)", "Budget"];
|
|
2893
|
+
var RETURN_SHAPE_LABELS = ["Return shape (review / QC seats)", "Return shape"];
|
|
2891
2894
|
function violation2(severity, code, message, fix) {
|
|
2892
2895
|
return { ok: false, severity, code, message, fix };
|
|
2893
2896
|
}
|
|
2897
|
+
function describeAbsence(value) {
|
|
2898
|
+
return value === undefined ? "the field is absent" : value === "" ? "the field is empty" : value.trim().toLowerCase() === "n/a" ? 'the value is "N/A"' : undefined;
|
|
2899
|
+
}
|
|
2894
2900
|
function parseAssignmentFields(assignmentText) {
|
|
2895
2901
|
const fields = {};
|
|
2896
|
-
for (const line of assignmentText.split(/\r?\n/)) {
|
|
2902
|
+
for (const line of assignmentHeaderRegion(assignmentText).split(/\r?\n/)) {
|
|
2897
2903
|
const match = line.match(/^[ \t]*(?:[-*][ \t]+)?\*\*\s*([^*:]+?)\s*\*\*\s*:\s*(.*)$/) ?? line.match(/^[ \t]*(?:[-*][ \t]+)?([A-Za-z][A-Za-z -]*?)\s*:\s*(.*)$/);
|
|
2898
2904
|
if (!match)
|
|
2899
2905
|
continue;
|
|
@@ -2908,9 +2914,18 @@ function parseAssignmentFields(assignmentText) {
|
|
|
2908
2914
|
fields.workingBranch = value;
|
|
2909
2915
|
else if (label === "Branch policy")
|
|
2910
2916
|
fields.branchPolicy = value;
|
|
2917
|
+
else if (BUDGET_LABELS.includes(label))
|
|
2918
|
+
fields.budget = value;
|
|
2919
|
+
else if (RETURN_SHAPE_LABELS.includes(label))
|
|
2920
|
+
fields.returnShape = value;
|
|
2911
2921
|
}
|
|
2912
2922
|
return fields;
|
|
2913
2923
|
}
|
|
2924
|
+
var ASSIGNMENT_BODY_START_RE = /^(?:#{1,6}[ \t]+Task\b|-{3,}[ \t]*$|#[ \t])/m;
|
|
2925
|
+
function assignmentHeaderRegion(assignmentText) {
|
|
2926
|
+
const marker = assignmentText.match(ASSIGNMENT_BODY_START_RE);
|
|
2927
|
+
return marker !== null ? assignmentText.slice(0, marker.index) : assignmentText;
|
|
2928
|
+
}
|
|
2914
2929
|
function requireField(violations, value, label, code) {
|
|
2915
2930
|
if (value === undefined) {
|
|
2916
2931
|
const v = violation2("high", `assignment.field.missing-${code}`, `missing required Assignment field: ${label}`, `add "**${label}**: <value>" to the Assignment`);
|
|
@@ -2970,6 +2985,33 @@ function validateAssignmentFields(assignmentText, opts = {}) {
|
|
|
2970
2985
|
for (const { key, label, code } of REQUIRED_FIELDS) {
|
|
2971
2986
|
requireField(violations, fields[key], label, code);
|
|
2972
2987
|
}
|
|
2988
|
+
const role = (fields.executeAs ?? "").trim().replace(/^@/, "").toLowerCase().split(/\s+/)[0] ?? "";
|
|
2989
|
+
const reviewSeat = REVIEW_SEAT_ROLES.includes(role);
|
|
2990
|
+
const category = (fields.taskCategory ?? "").replace(/^[*_`"'\s]+/, "").toLowerCase();
|
|
2991
|
+
const auditRound = /^audit(?![A-Za-z0-9])/.test(category);
|
|
2992
|
+
if (reviewSeat || auditRound) {
|
|
2993
|
+
const subject = reviewSeat ? `review seat "${role}"` : `audit round (Task category: ${category})`;
|
|
2994
|
+
const boundingFields = [
|
|
2995
|
+
{
|
|
2996
|
+
code: "assignment.field.budget-missing",
|
|
2997
|
+
label: "Budget",
|
|
2998
|
+
fix: `add "**Budget (review / QC seats)**: <cap> \u2014 may only tighten the default in mstar-harness-core \u00a7 \u5b9a\u5411\u6267\u884c\u4e0e\u9a8c\u8bc1\u8fb9\u754c, never loosen it"`,
|
|
2999
|
+
value: fields.budget
|
|
3000
|
+
},
|
|
3001
|
+
{
|
|
3002
|
+
code: "assignment.field.return-shape-missing",
|
|
3003
|
+
label: "Return shape",
|
|
3004
|
+
fix: `add "**Return shape (review / QC seats)**: <what the seat returns and how it stops \u2014 verdict + findings shape; a clean round returns findings: [] explicitly>"`,
|
|
3005
|
+
value: fields.returnShape
|
|
3006
|
+
}
|
|
3007
|
+
];
|
|
3008
|
+
for (const field of boundingFields) {
|
|
3009
|
+
const missing = describeAbsence(field.value);
|
|
3010
|
+
if (missing === undefined)
|
|
3011
|
+
continue;
|
|
3012
|
+
violations.push(violation2("high", field.code, `${subject} must declare a round ${field.label} \u2014 ${missing}`, field.fix));
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
2973
3015
|
if (writable) {
|
|
2974
3016
|
const workingPresent = fields.workingBranch !== undefined && fields.workingBranch !== "";
|
|
2975
3017
|
const policyPresent = fields.branchPolicy !== undefined && fields.branchPolicy !== "";
|
|
@@ -4059,7 +4101,9 @@ function findingsCleanupGate(register, planId, opts) {
|
|
|
4059
4101
|
const id = typeof entry.id === "string" ? entry.id : "<unnamed>";
|
|
4060
4102
|
const label = `R#${id}`;
|
|
4061
4103
|
if (mode === "zero-residual") {
|
|
4062
|
-
if (entry.severity === "
|
|
4104
|
+
if (normalizeSeverity(entry.severity) === "critical") {
|
|
4105
|
+
violations.push(violation6("high", "findings.zero-residual-critical", `${label}: unresolved critical blocks approval under zero-residual \u2014 fix now or close via explicit risk acceptance`));
|
|
4106
|
+
} else if (entry.severity === "nit") {
|
|
4063
4107
|
violations.push(violation6("medium", "findings.zero-residual-nit", `${label}: style-only nits must be fixed in-session or dropped \u2014 never left open under zero-residual`));
|
|
4064
4108
|
} else if (entry.decision === "risk-accepted" || entry.lifecycle === "waived") {
|
|
4065
4109
|
violations.push(violation6("medium", "findings.zero-residual-risk-accepted", `${label}: waived/risk-accepted findings must be closed/archived, not left open under zero-residual`));
|
|
@@ -7174,6 +7218,51 @@ function findEphemeralCitations(skillText) {
|
|
|
7174
7218
|
}
|
|
7175
7219
|
return citations;
|
|
7176
7220
|
}
|
|
7221
|
+
var DATED_SLUG_TOKEN_SOURCE = "\\b20\\d{6}-[a-z0-9][a-z0-9-]*\\b(?!\\.\\d)";
|
|
7222
|
+
var DATED_SLUG_TOKEN_RE = new RegExp(DATED_SLUG_TOKEN_SOURCE, "g");
|
|
7223
|
+
var HARNESS_PATH_RE = /\.(?:mstar|agents)\/[^\s<>{}\[\]"'\*\?]+/g;
|
|
7224
|
+
var SDD_DEEPLINK_PREFIX_RE = /^\.(?:mstar|agents)\/sdd(?:\/|$)/;
|
|
7225
|
+
var TRAILING_SENTENCE_PUNCT_RE = /[.,;:!?]+$/;
|
|
7226
|
+
function isExampleSlug(token) {
|
|
7227
|
+
return token.split("-").includes("example");
|
|
7228
|
+
}
|
|
7229
|
+
function qualifyingDatedToken(text) {
|
|
7230
|
+
for (const m of text.matchAll(DATED_SLUG_TOKEN_RE)) {
|
|
7231
|
+
if (!isExampleSlug(m[0]))
|
|
7232
|
+
return m[0];
|
|
7233
|
+
}
|
|
7234
|
+
return null;
|
|
7235
|
+
}
|
|
7236
|
+
function findProvenanceCitations(text) {
|
|
7237
|
+
const citations = [];
|
|
7238
|
+
const lines = text.split(/\r?\n/);
|
|
7239
|
+
for (let i = 0;i < lines.length; i++) {
|
|
7240
|
+
const found = [];
|
|
7241
|
+
const pathRanges = [];
|
|
7242
|
+
for (const m of lines[i].matchAll(HARNESS_PATH_RE)) {
|
|
7243
|
+
const start = m.index;
|
|
7244
|
+
pathRanges.push([start, start + m[0].length]);
|
|
7245
|
+
if (SDD_DEEPLINK_PREFIX_RE.test(m[0]))
|
|
7246
|
+
continue;
|
|
7247
|
+
if (qualifyingDatedToken(m[0]) !== null) {
|
|
7248
|
+
found.push({ index: start, match: m[0], kind: "harness-path" });
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7251
|
+
const inPath = (index) => pathRanges.some(([from, to]) => index >= from && index < to);
|
|
7252
|
+
for (const m of lines[i].matchAll(DATED_SLUG_TOKEN_RE)) {
|
|
7253
|
+
if (inPath(m.index))
|
|
7254
|
+
continue;
|
|
7255
|
+
if (isExampleSlug(m[0]))
|
|
7256
|
+
continue;
|
|
7257
|
+
found.push({ index: m.index, match: m[0], kind: "plan-id" });
|
|
7258
|
+
}
|
|
7259
|
+
found.sort((a, b) => a.index - b.index);
|
|
7260
|
+
for (const f of found) {
|
|
7261
|
+
citations.push({ line: i + 1, match: f.match.replace(TRAILING_SENTENCE_PUNCT_RE, ""), kind: f.kind });
|
|
7262
|
+
}
|
|
7263
|
+
}
|
|
7264
|
+
return citations;
|
|
7265
|
+
}
|
|
7177
7266
|
var TEST_FILE_PATH_RE = /[\w./-]+\.(?:test|spec)\.[a-z0-9]+/i;
|
|
7178
7267
|
var TEST_FILE_PHRASE_RE = /\btest file(?:s|\(s\))?\s*:[ \t]*(.+)/i;
|
|
7179
7268
|
var COMMAND_PROMPT_RE = /^\s*[$>]\s*\S/;
|
|
@@ -8392,6 +8481,202 @@ function resolvePrReviewTier(input) {
|
|
|
8392
8481
|
return "quick";
|
|
8393
8482
|
return "default";
|
|
8394
8483
|
}
|
|
8484
|
+
var QC_VERDICTS = ["Approve", "Request Changes", "Needs Discussion", "Unconfirmed"];
|
|
8485
|
+
var REPORT_FIELDS = ["report_kind", "reviewer", "reviewer_index", "plan_id", "verdict", "generated_at"];
|
|
8486
|
+
var REPORT_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
8487
|
+
var REPORT_SEVERITIES = ["Critical", "Warning", "Suggestion", "Unconfirmed"];
|
|
8488
|
+
var BODY_VERDICT_RE = /^[ \t]*(?:[-*+][ \t]+)?(?:#{1,6}[ \t]+)?[*_\s]*Verdict[*_\s]*:[ \t]*(.*)$/i;
|
|
8489
|
+
var VERDICT_DECORATION_RE = /^[*_`"'\s~]+/;
|
|
8490
|
+
var TRUNCATED_COVERAGE_RE = /^[ \t]*(?:[-*+][ \t]+)?(?:\*\*)?Truncated coverage(?:\*\*)?[ \t]*:/;
|
|
8491
|
+
var EMPTY_SECTION_RE = /^(?:\(none\)|none(?![A-Za-z])|\uff08?\u65e0\uff09?)/i;
|
|
8492
|
+
var LIST_ITEM_RE = /^(?:[-*][ \t]+|\d+[.)][ \t]+)(.*)$/;
|
|
8493
|
+
function sectionRange(lines, heading) {
|
|
8494
|
+
const start = lines.findIndex((line) => {
|
|
8495
|
+
const m = /^(#{1,6})[ \t]+(.*?)[ \t]*$/.exec(line);
|
|
8496
|
+
return m !== null && m[1].length === 2 && m[2] === heading;
|
|
8497
|
+
});
|
|
8498
|
+
if (start < 0)
|
|
8499
|
+
return;
|
|
8500
|
+
let end = lines.length;
|
|
8501
|
+
for (let i = start + 1;i < lines.length; i++) {
|
|
8502
|
+
if (/^##[ \t]/.test(lines[i])) {
|
|
8503
|
+
end = i;
|
|
8504
|
+
break;
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
return [start + 1, end];
|
|
8508
|
+
}
|
|
8509
|
+
function bodyLines(lines) {
|
|
8510
|
+
if (lines[0]?.trim() !== "---")
|
|
8511
|
+
return lines;
|
|
8512
|
+
for (let i = 1;i < lines.length; i++) {
|
|
8513
|
+
if (lines[i].trim() === "---")
|
|
8514
|
+
return lines.slice(i + 1);
|
|
8515
|
+
}
|
|
8516
|
+
return lines;
|
|
8517
|
+
}
|
|
8518
|
+
function linesUnclosedFence(text) {
|
|
8519
|
+
const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
8520
|
+
if (lines.length === 0 || lines[0].trim() !== "---")
|
|
8521
|
+
return false;
|
|
8522
|
+
return !lines.slice(1).some((line) => line.trim() === "---");
|
|
8523
|
+
}
|
|
8524
|
+
function tableCells(line) {
|
|
8525
|
+
const trimmed = line.trim();
|
|
8526
|
+
if (!trimmed.startsWith("|") || !trimmed.endsWith("|"))
|
|
8527
|
+
return;
|
|
8528
|
+
const cells = trimmed.slice(1, -1).split("|").map((cell) => cell.trim());
|
|
8529
|
+
return cells.length >= 2 ? cells : undefined;
|
|
8530
|
+
}
|
|
8531
|
+
function namesSeverity(text, severity) {
|
|
8532
|
+
const index = text.indexOf(severity);
|
|
8533
|
+
if (index < 0)
|
|
8534
|
+
return false;
|
|
8535
|
+
return !/[A-Za-z]/.test(text.charAt(index - 1)) && !/[A-Za-z]/.test(text.charAt(index + severity.length));
|
|
8536
|
+
}
|
|
8537
|
+
function summaryCounts(lines) {
|
|
8538
|
+
const counts = {};
|
|
8539
|
+
const range = sectionRange(lines, "Summary");
|
|
8540
|
+
if (range === undefined)
|
|
8541
|
+
return counts;
|
|
8542
|
+
for (let i = range[0];i < range[1]; i++) {
|
|
8543
|
+
const cells = tableCells(lines[i]);
|
|
8544
|
+
if (cells === undefined)
|
|
8545
|
+
continue;
|
|
8546
|
+
const values = cells.slice(1).map((cell) => /(\d+)/.exec(cell)?.[1]);
|
|
8547
|
+
const tail = values.filter((digits) => digits !== undefined).pop();
|
|
8548
|
+
if (tail === undefined)
|
|
8549
|
+
continue;
|
|
8550
|
+
for (const severity of REPORT_SEVERITIES) {
|
|
8551
|
+
if (!namesSeverity(cells[0], severity))
|
|
8552
|
+
continue;
|
|
8553
|
+
counts[severity] = Number(tail);
|
|
8554
|
+
}
|
|
8555
|
+
}
|
|
8556
|
+
return counts;
|
|
8557
|
+
}
|
|
8558
|
+
function findingsCounts(lines) {
|
|
8559
|
+
const counts = {};
|
|
8560
|
+
const range = sectionRange(lines, "Findings");
|
|
8561
|
+
if (range === undefined)
|
|
8562
|
+
return counts;
|
|
8563
|
+
let current;
|
|
8564
|
+
for (let i = range[0];i < range[1]; i++) {
|
|
8565
|
+
const line = lines[i];
|
|
8566
|
+
const heading = /^###[ \t]+(.*?)[ \t]*$/.exec(line);
|
|
8567
|
+
if (heading !== null) {
|
|
8568
|
+
current = REPORT_SEVERITIES.find((severity) => namesSeverity(heading[1], severity));
|
|
8569
|
+
if (current !== undefined && counts[current] === undefined)
|
|
8570
|
+
counts[current] = 0;
|
|
8571
|
+
continue;
|
|
8572
|
+
}
|
|
8573
|
+
if (current === undefined)
|
|
8574
|
+
continue;
|
|
8575
|
+
const item = LIST_ITEM_RE.exec(line);
|
|
8576
|
+
if (item === null || EMPTY_SECTION_RE.test(item[1].trim()))
|
|
8577
|
+
continue;
|
|
8578
|
+
counts[current] = (counts[current] ?? 0) + 1;
|
|
8579
|
+
}
|
|
8580
|
+
return counts;
|
|
8581
|
+
}
|
|
8582
|
+
function bodyVerdictPhrase(lines) {
|
|
8583
|
+
let phrase;
|
|
8584
|
+
for (const line of bodyLines(lines)) {
|
|
8585
|
+
const m = BODY_VERDICT_RE.exec(line);
|
|
8586
|
+
if (m === null)
|
|
8587
|
+
continue;
|
|
8588
|
+
const text = m[1].trim().replace(VERDICT_DECORATION_RE, "");
|
|
8589
|
+
phrase = text.split(/\s+/)[0] ?? "";
|
|
8590
|
+
for (const verdict of [...QC_VERDICTS].sort((a, b) => b.length - a.length)) {
|
|
8591
|
+
if (!text.startsWith(verdict))
|
|
8592
|
+
continue;
|
|
8593
|
+
const next = text.charAt(verdict.length);
|
|
8594
|
+
if (next === "" || !/[A-Za-z0-9]/.test(next)) {
|
|
8595
|
+
phrase = verdict;
|
|
8596
|
+
break;
|
|
8597
|
+
}
|
|
8598
|
+
}
|
|
8599
|
+
}
|
|
8600
|
+
return phrase;
|
|
8601
|
+
}
|
|
8602
|
+
function violation16(severity, code, message, fix) {
|
|
8603
|
+
return { ok: false, severity, code, message, fix };
|
|
8604
|
+
}
|
|
8605
|
+
function validateQcReport(text) {
|
|
8606
|
+
const violations = [];
|
|
8607
|
+
if (lines_missing_fence(text)) {
|
|
8608
|
+
return {
|
|
8609
|
+
ok: false,
|
|
8610
|
+
violations: [
|
|
8611
|
+
violation16("high", "qcreview.report.missing-frontmatter", "no `---` fenced frontmatter found - a QC seat report must open with the machine-readable frontmatter block (report-template.md \u00a7 Frontmatter)", "open the report with `---` and the fields `report_kind: qc` / `reviewer` / `reviewer_index` / `plan_id` / `verdict` / `generated_at`")
|
|
8612
|
+
]
|
|
8613
|
+
};
|
|
8614
|
+
}
|
|
8615
|
+
const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
8616
|
+
if (linesUnclosedFence(text)) {
|
|
8617
|
+
return {
|
|
8618
|
+
ok: false,
|
|
8619
|
+
violations: [
|
|
8620
|
+
violation16("high", "qcreview.report.unclosed-frontmatter", "the frontmatter `---` fence is never closed - every line after it is read as frontmatter, so the report body is not part of the document", "add a closing `---` line after the last frontmatter key (report-template.md \u00a7 Frontmatter)")
|
|
8621
|
+
]
|
|
8622
|
+
};
|
|
8623
|
+
}
|
|
8624
|
+
const { doc } = parseReportFrontmatter(text);
|
|
8625
|
+
for (const field of REPORT_FIELDS) {
|
|
8626
|
+
const value = doc[field];
|
|
8627
|
+
if (value === undefined || value.trim() === "") {
|
|
8628
|
+
violations.push(violation16("medium", `qcreview.report.missing-${field}`, `missing required frontmatter field: ${field}`, `add "${field}: <value>" to the frontmatter block (report-template.md \u00a7 Frontmatter)`));
|
|
8629
|
+
}
|
|
8630
|
+
}
|
|
8631
|
+
const reportKind = doc.report_kind?.trim() ?? "";
|
|
8632
|
+
if (reportKind !== "" && reportKind !== "qc") {
|
|
8633
|
+
violations.push(violation16("medium", "qcreview.report.invalid-report-kind", `report_kind "${reportKind}" is not "qc"`, "use `report_kind: qc` for a QC seat report (a PM consolidated report is not a seat report)"));
|
|
8634
|
+
}
|
|
8635
|
+
const frontmatterVerdict = doc.verdict?.trim() ?? "";
|
|
8636
|
+
const frontmatterVerdictIsValid = QC_VERDICTS.includes(frontmatterVerdict);
|
|
8637
|
+
if (frontmatterVerdict !== "" && !frontmatterVerdictIsValid) {
|
|
8638
|
+
violations.push(violation16("medium", "qcreview.report.invalid-verdict", `frontmatter verdict "${frontmatterVerdict}" is not one of ${JSON.stringify(QC_VERDICTS)}`, `use one of: ${QC_VERDICTS.join(" | ")} - the vocabulary is verbatim (report-template.md \u00a7 Report body template)`));
|
|
8639
|
+
}
|
|
8640
|
+
const generatedAt = doc.generated_at?.trim() ?? "";
|
|
8641
|
+
if (generatedAt !== "" && !REPORT_DATE_RE.test(generatedAt)) {
|
|
8642
|
+
violations.push(violation16("medium", "qcreview.report.invalid-generated-at", `generated_at "${generatedAt}" must be a calendar date (YYYY-MM-DD)`, 'write `generated_at: "YYYY-MM-DD"` (report-template.md \u00a7 Frontmatter)'));
|
|
8643
|
+
}
|
|
8644
|
+
const bodyPhrase = bodyVerdictPhrase(lines);
|
|
8645
|
+
const bodyPhraseIsValid = bodyPhrase !== undefined && QC_VERDICTS.includes(bodyPhrase);
|
|
8646
|
+
if (bodyPhrase === undefined) {
|
|
8647
|
+
violations.push(violation16("high", "qcreview.report.missing-body-verdict", "the report body carries no verdict line (`**Verdict**: <verdict>` or `## Verdict: <verdict>`)", `add a body verdict line using one of: ${QC_VERDICTS.join(" | ")}`));
|
|
8648
|
+
} else if (!bodyPhraseIsValid) {
|
|
8649
|
+
violations.push(violation16("high", "qcreview.report.verdict-mismatch", bodyPhrase === "" ? `the body verdict line is empty - expected one of ${JSON.stringify(QC_VERDICTS)}` : `body verdict "${bodyPhrase}" is not one of ${JSON.stringify(QC_VERDICTS)}`, `start the verdict line with one of: ${QC_VERDICTS.join(" | ")}`));
|
|
8650
|
+
} else if (frontmatterVerdictIsValid && bodyPhrase !== frontmatterVerdict) {
|
|
8651
|
+
violations.push(violation16("high", "qcreview.report.verdict-mismatch", `body verdict "${bodyPhrase}" does not match the frontmatter verdict "${frontmatterVerdict}"`, "make the frontmatter verdict and the body verdict line agree on the same final verdict"));
|
|
8652
|
+
}
|
|
8653
|
+
const summary = summaryCounts(lines);
|
|
8654
|
+
const findings = findingsCounts(lines);
|
|
8655
|
+
for (const severity of REPORT_SEVERITIES) {
|
|
8656
|
+
const claimed = summary[severity];
|
|
8657
|
+
const counted = findings[severity];
|
|
8658
|
+
if (claimed === undefined || counted === undefined || claimed === counted)
|
|
8659
|
+
continue;
|
|
8660
|
+
violations.push(violation16("high", "qcreview.report.summary-count-mismatch", `## Summary ${severity} count ${claimed} does not match the ${counted} top-level entr${counted === 1 ? "y" : "ies"} under ## Findings (\u00a7 ${severity})`, `recount \u00a7 ${severity} and update the ## Summary row - one top-level entry per finding, detail lines indented (report-template.md \u00a7 Findings)`));
|
|
8661
|
+
}
|
|
8662
|
+
const effectiveVerdict = frontmatterVerdictIsValid ? frontmatterVerdict : bodyPhraseIsValid ? bodyPhrase : undefined;
|
|
8663
|
+
if (effectiveVerdict !== undefined) {
|
|
8664
|
+
const critical = summary.Critical;
|
|
8665
|
+
const warning = summary.Warning;
|
|
8666
|
+
const blocking = (critical ?? 0) + (warning ?? 0);
|
|
8667
|
+
if (effectiveVerdict === "Approve" && blocking > 0) {
|
|
8668
|
+
violations.push(violation16("high", "qcreview.report.verdict-contradicts-counts", `verdict "Approve" with ${blocking} Critical/Warning finding(s) in ## Summary (Critical ${critical ?? 0}, Warning ${warning ?? 0})`, 'do not Approve with open Critical/Warning findings - close them or use "Request Changes" / "Needs Discussion"'));
|
|
8669
|
+
}
|
|
8670
|
+
const unconfirmed = summary.Unconfirmed;
|
|
8671
|
+
if (unconfirmed !== undefined && unconfirmed > 0 && effectiveVerdict !== "Unconfirmed") {
|
|
8672
|
+
violations.push(violation16("high", "qcreview.report.verdict-contradicts-counts", `verdict "${effectiveVerdict}" with ${unconfirmed} Unconfirmed finding(s) in ## Summary - a failed evidence channel transmits as "Unconfirmed" (mstar-review-qc \u00a7 \u5e2d\u4f4d\u9884\u7b97\u4e0e\u622a\u65ad)`, 'set the verdict to "Unconfirmed" or re-establish the evidence channel before converging'));
|
|
8673
|
+
}
|
|
8674
|
+
if (effectiveVerdict === "Unconfirmed" && lines.some((line) => TRUNCATED_COVERAGE_RE.test(line))) {
|
|
8675
|
+
violations.push(violation16("high", "qcreview.report.truncation-verdict", 'the report declares `Truncated coverage:` but carries the verdict "Unconfirmed" - a budget/scope cut is not a failed evidence channel', 'keep the verdict earned for the reviewed scope and reserve "Unconfirmed" for a failed evidence channel'));
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8678
|
+
return { ok: violations.length === 0, violations };
|
|
8679
|
+
}
|
|
8395
8680
|
|
|
8396
8681
|
// src/index.ts
|
|
8397
8682
|
import { execFileSync as execFileSync11 } from "child_process";
|
|
@@ -13406,6 +13691,8 @@ var AUDIT_EFFORTS2 = ["XS", "S", "M", "L", "XL"];
|
|
|
13406
13691
|
var AUDIT_RISKS2 = ["LOW", "MED", "HIGH"];
|
|
13407
13692
|
var AUDIT_CONFIDENCES2 = ["HIGH", "MED", "LOW"];
|
|
13408
13693
|
var WALK_SKIP_DIRS2 = new Set(["node_modules", ".git", "dist"]);
|
|
13694
|
+
var DATED_SLUG_TOKEN_SOURCE2 = "\\b20\\d{6}-[a-z0-9][a-z0-9-]*\\b(?!\\.\\d)";
|
|
13695
|
+
var DATED_SLUG_TOKEN_RE2 = new RegExp(DATED_SLUG_TOKEN_SOURCE2, "g");
|
|
13409
13696
|
var PR_REVIEW_TIER_BUDGETS2 = Object.freeze({
|
|
13410
13697
|
quick: Object.freeze({ wallClockMinutes: 5, maxSeats: 1, perSeatFindingsCap: 5, evidenceTokensCap: 600, fileOpenCap: 12 }),
|
|
13411
13698
|
default: Object.freeze({ wallClockMinutes: 10, maxSeats: 2, perSeatFindingsCap: 6, evidenceTokensCap: 900, fileOpenCap: 20 }),
|
|
@@ -14509,16 +14796,16 @@ async function captureSddEvidence(request, argv) {
|
|
|
14509
14796
|
const resolved = resolveSddExecutionContext2(validatedRequest.context);
|
|
14510
14797
|
const cwdGate = checkSddAction2(resolved, { kind: "source", cwd: process.cwd() });
|
|
14511
14798
|
if (!cwdGate.ok) {
|
|
14512
|
-
throw gateError(`sdd evidence capture refused: ${cwdGate.violations.map((
|
|
14799
|
+
throw gateError(`sdd evidence capture refused: ${cwdGate.violations.map((violation17) => `${violation17.code}: ${violation17.message}`).join("; ")}`);
|
|
14513
14800
|
}
|
|
14514
14801
|
const launchGate = checkSddAction2(resolved, { kind: "launch", cwd: process.cwd() });
|
|
14515
14802
|
if (!launchGate.ok) {
|
|
14516
|
-
throw gateError(`sdd evidence capture refused: ${launchGate.violations.map((
|
|
14803
|
+
throw gateError(`sdd evidence capture refused: ${launchGate.violations.map((violation17) => `${violation17.code}: ${violation17.message}`).join("; ")}`);
|
|
14517
14804
|
}
|
|
14518
14805
|
const evidenceDir = join13(resolved.sddDir, "evidence");
|
|
14519
14806
|
const artifactGate = checkSddAction2(resolved, { kind: "artifact", cwd: process.cwd(), target: evidenceDir });
|
|
14520
14807
|
if (!artifactGate.ok) {
|
|
14521
|
-
throw gateError(`sdd evidence capture refused: ${artifactGate.violations.map((
|
|
14808
|
+
throw gateError(`sdd evidence capture refused: ${artifactGate.violations.map((violation17) => `${violation17.code}: ${violation17.message}`).join("; ")}`);
|
|
14522
14809
|
}
|
|
14523
14810
|
const runId = randomUUID3();
|
|
14524
14811
|
const runDir = join13(evidenceDir, runId);
|
|
@@ -14603,7 +14890,7 @@ async function captureSddEvidence(request, argv) {
|
|
|
14603
14890
|
record.state = "finished";
|
|
14604
14891
|
const selfGate = validateSddEvidenceRecord(record);
|
|
14605
14892
|
if (!selfGate.ok) {
|
|
14606
|
-
throw new Error(`evidence finalization produced an invalid record for ${runDir}: ${selfGate.violations.map((
|
|
14893
|
+
throw new Error(`evidence finalization produced an invalid record for ${runDir}: ${selfGate.violations.map((violation17) => `${violation17.code}: ${violation17.message}`).join("; ")}`);
|
|
14607
14894
|
}
|
|
14608
14895
|
try {
|
|
14609
14896
|
writeRecordAtomic(resolved.sddDir, runDir, recordPath, record);
|
|
@@ -14822,16 +15109,16 @@ function validatePlannedDocs(plan) {
|
|
|
14822
15109
|
for (const snapshot of plan.snapshots) {
|
|
14823
15110
|
const gate3 = validateWorkflowSnapshot2(snapshot.data);
|
|
14824
15111
|
if (!gate3.ok) {
|
|
14825
|
-
for (const
|
|
14826
|
-
warnings.push(`[${
|
|
15112
|
+
for (const violation17 of gate3.violations) {
|
|
15113
|
+
warnings.push(`[${violation17.severity}] ${violation17.code}: ${violation17.message} (planned snapshot ${snapshot.file})`);
|
|
14827
15114
|
}
|
|
14828
15115
|
}
|
|
14829
15116
|
}
|
|
14830
15117
|
if (plan.register !== null) {
|
|
14831
15118
|
const gate3 = validateProjectRegister2(plan.register.data);
|
|
14832
15119
|
if (!gate3.ok) {
|
|
14833
|
-
for (const
|
|
14834
|
-
warnings.push(`[${
|
|
15120
|
+
for (const violation17 of gate3.violations) {
|
|
15121
|
+
warnings.push(`[${violation17.severity}] ${violation17.code}: ${violation17.message} (planned register ${plan.register.file})`);
|
|
14835
15122
|
}
|
|
14836
15123
|
}
|
|
14837
15124
|
}
|
|
@@ -17774,10 +18061,10 @@ function resolveStatusFilePath(pathArg) {
|
|
|
17774
18061
|
return path15.join(harnessDir, "status.json");
|
|
17775
18062
|
}
|
|
17776
18063
|
function printViolationList(violations) {
|
|
17777
|
-
for (const
|
|
17778
|
-
console.error(` - [${
|
|
17779
|
-
if (
|
|
17780
|
-
console.error(` fix: ${
|
|
18064
|
+
for (const violation17 of violations) {
|
|
18065
|
+
console.error(` - [${violation17.severity}] ${violation17.code}: ${violation17.message}`);
|
|
18066
|
+
if (violation17.fix)
|
|
18067
|
+
console.error(` fix: ${violation17.fix}`);
|
|
17781
18068
|
}
|
|
17782
18069
|
}
|
|
17783
18070
|
function readSnapshotForCheck(snapshotPath) {
|
|
@@ -18154,10 +18441,10 @@ function verifyLeaseRow(row, planId, snapshotPath) {
|
|
|
18154
18441
|
}
|
|
18155
18442
|
const count = result.violations.length;
|
|
18156
18443
|
console.error(import_picocolors3.default.red(`${snapshotPath}: FAIL plan ${planId} (${count} violation${count === 1 ? "" : "s"})`));
|
|
18157
|
-
for (const
|
|
18158
|
-
console.error(` - [${
|
|
18159
|
-
if (
|
|
18160
|
-
console.error(` fix: ${
|
|
18444
|
+
for (const violation17 of result.violations) {
|
|
18445
|
+
console.error(` - [${violation17.severity}] ${violation17.code}: ${violation17.message}`);
|
|
18446
|
+
if (violation17.fix)
|
|
18447
|
+
console.error(` fix: ${violation17.fix}`);
|
|
18161
18448
|
}
|
|
18162
18449
|
process.exitCode = 1;
|
|
18163
18450
|
}
|
|
@@ -18339,10 +18626,10 @@ function printChecklist(label, gate3) {
|
|
|
18339
18626
|
}
|
|
18340
18627
|
const count = gate3.violations.length;
|
|
18341
18628
|
console.error(import_picocolors3.default.red(`${label}: FAIL (${count} violation${count === 1 ? "" : "s"})`));
|
|
18342
|
-
for (const
|
|
18343
|
-
console.error(` - [${
|
|
18344
|
-
if (
|
|
18345
|
-
console.error(` fix: ${
|
|
18629
|
+
for (const violation17 of gate3.violations) {
|
|
18630
|
+
console.error(` - [${violation17.severity}] ${violation17.code}: ${violation17.message}`);
|
|
18631
|
+
if (violation17.fix)
|
|
18632
|
+
console.error(` fix: ${violation17.fix}`);
|
|
18346
18633
|
}
|
|
18347
18634
|
}
|
|
18348
18635
|
iterationCommand.command("gate").description("Evaluate the phase-transition gate: prints the transition (phase-2-execute / phase-3-close / phase-4-pr-delivery) " + "plus the \xA73.1 entry and \xA73.5 exit checklists. Exit 1 when the gate verdict fails \u2014 during the Phase-3 window " + "(transition: phase-3-close) exit 1 is EXPECTED until the \xA73.4 close items (status: completed + end_date) are " + "written: the exit checklist gates Phase 4, not the Phase-3 entry. " + "--phase 6 switches to the post-merge close local-state gate (terminal snapshot, no dangling lease, root " + "status.json entry unregistered); it needs no --compass. Exit 0 pass, 1 gate fail/error, 2 usage").requiredOption("--workflow <id>", "Workflow id whose snapshot is evaluated").option("--compass <path>", "delivery-compass.md path (Phase 2\u20135 transition form; not read by --phase 6)").option("--phase <n>", "Gate form: 6 evaluates the post-merge close local-state gate (no --compass needed); omit for the Phase 2\u20135 transition form").option("--harness <path>", "Harness dir override (default: resolved {HARNESS_DIR})").option("--branch <branch>", "Current branch probe (exit \xA73.5 item 5)").option("--integration <branch>", "Spec integration branch probe (exit \xA73.5 item 5)").option("--target <branch>", "PR base branch probe (exit \xA73.5 item 6)").action((options) => {
|
|
@@ -18399,10 +18686,10 @@ iterationCommand.command("push-cadence").description("\xA75.1a push-cadence prob
|
|
|
18399
18686
|
}
|
|
18400
18687
|
const count = result.violations.length;
|
|
18401
18688
|
console.error(import_picocolors3.default.red(`push blocked (${count} violation${count === 1 ? "" : "s"})`));
|
|
18402
|
-
for (const
|
|
18403
|
-
console.error(` - [${
|
|
18404
|
-
if (
|
|
18405
|
-
console.error(` fix: ${
|
|
18689
|
+
for (const violation17 of result.violations) {
|
|
18690
|
+
console.error(` - [${violation17.severity}] ${violation17.code}: ${violation17.message}`);
|
|
18691
|
+
if (violation17.fix)
|
|
18692
|
+
console.error(` fix: ${violation17.fix}`);
|
|
18406
18693
|
}
|
|
18407
18694
|
process.exitCode = 1;
|
|
18408
18695
|
});
|
|
@@ -18809,7 +19096,7 @@ function cleanupProbe(input) {
|
|
|
18809
19096
|
read = readWorkflowSnapshot(dir);
|
|
18810
19097
|
} catch (error) {
|
|
18811
19098
|
if (error instanceof WorkflowSnapshotValidationError) {
|
|
18812
|
-
const detail = error.violations.map((
|
|
19099
|
+
const detail = error.violations.map((violation17) => `${violation17.code}: ${violation17.message}`).join("; ");
|
|
18813
19100
|
const doc = JSON.parse(fs12.readFileSync(snapshotPath, "utf8"));
|
|
18814
19101
|
snapshots.push(cleanupDegradeSiblingSnapshot(doc, entry.name));
|
|
18815
19102
|
console.error(import_picocolors3.default.yellow(`worktree cleanup: note: sibling snapshot ${snapshotPath} is invalid (${detail}) \u2014 its protective declarations are kept in degraded form`));
|
|
@@ -19126,6 +19413,10 @@ var LINT_CODE_EXTENSIONS = {
|
|
|
19126
19413
|
".kt": true,
|
|
19127
19414
|
".swift": true
|
|
19128
19415
|
};
|
|
19416
|
+
var PROVENANCE_LINT_EXTENSIONS = {
|
|
19417
|
+
".md": true,
|
|
19418
|
+
".ts": true
|
|
19419
|
+
};
|
|
19129
19420
|
function lintTargetType(filePath) {
|
|
19130
19421
|
const base = path15.basename(filePath);
|
|
19131
19422
|
if (base === "STRATEGY.md")
|
|
@@ -19143,7 +19434,7 @@ function lintTargetType(filePath) {
|
|
|
19143
19434
|
return "code";
|
|
19144
19435
|
return null;
|
|
19145
19436
|
}
|
|
19146
|
-
function collectLintTargets(dir) {
|
|
19437
|
+
function collectLintTargets(dir, accept = (file) => lintTargetType(file) !== null) {
|
|
19147
19438
|
const targets = [];
|
|
19148
19439
|
const visit = (current) => {
|
|
19149
19440
|
for (const entry of fs12.readdirSync(current, { withFileTypes: true })) {
|
|
@@ -19153,7 +19444,7 @@ function collectLintTargets(dir) {
|
|
|
19153
19444
|
if (entry.isDirectory()) {
|
|
19154
19445
|
if (LINT_SKIP_DIRS[entry.name] !== true)
|
|
19155
19446
|
visit(child + path15.sep);
|
|
19156
|
-
} else if (entry.isFile() &&
|
|
19447
|
+
} else if (entry.isFile() && accept(child)) {
|
|
19157
19448
|
targets.push(child);
|
|
19158
19449
|
}
|
|
19159
19450
|
}
|
|
@@ -19198,20 +19489,32 @@ async function lintOneFile(filePath, forcedType, prVariant) {
|
|
|
19198
19489
|
case "finding":
|
|
19199
19490
|
violations.push(...validateFindingDoc(text, { ...prVariant ? { prVariant: true } : {} }).violations);
|
|
19200
19491
|
break;
|
|
19492
|
+
case "provenance": {
|
|
19493
|
+
for (const citation of findProvenanceCitations(text)) {
|
|
19494
|
+
violations.push({
|
|
19495
|
+
ok: false,
|
|
19496
|
+
severity: "medium",
|
|
19497
|
+
code: `lint.provenance.${citation.kind}`,
|
|
19498
|
+
message: `provenance ${citation.kind} citation at line ${citation.line}: "${citation.match}" \u2014 tracked content must not disclose local plan/iteration ids or dated harness deep paths`,
|
|
19499
|
+
fix: `rewrite "${citation.match}" as a placeholder form (e.g. task-N-report, <plan-id>) or a synthetic example slug (any -example- segment)`
|
|
19500
|
+
});
|
|
19501
|
+
}
|
|
19502
|
+
break;
|
|
19503
|
+
}
|
|
19201
19504
|
default:
|
|
19202
19505
|
throw new SddScriptError(`usage: lint <target> \u2014 unsupported file type "${path15.basename(filePath)}" (lintable: plan files, SKILL.md, STRATEGY.md, task-N-report.md, code files)`, 2);
|
|
19203
19506
|
}
|
|
19204
19507
|
return { violations, markers };
|
|
19205
19508
|
}
|
|
19206
19509
|
var lintCommand = program2.command("lint").description("lint harness artifacts by content type (engine-backed): plan files \u2192 quality bar, SKILL.md \u2192 frontmatter, " + "STRATEGY.md \u2192 required sections, task-N-report.md \u2192 SDD TDD triple, code files \u2192 simplify:/temporary markers");
|
|
19207
|
-
lintCommand.description("Lint <target> (file or dir) \u2014 exit 1 on violations, 2 on usage. --type forces one content type " + "(plan | skill | strategy | report | code | finding); finding docs are explicit-only").argument("[target]", "File or directory to lint").option("--type <type>", "Force the content type (plan | skill | strategy | report | code | finding)").option("--pr-variant", "With --type finding: enforce the PR-only Merge class contract (presence, enum, placement after Confidence)").action(async (target, options) => {
|
|
19510
|
+
lintCommand.description("Lint <target> (file or dir) \u2014 exit 1 on violations, 2 on usage. --type forces one content type " + "(plan | skill | strategy | report | code | finding | provenance); finding docs are explicit-only, " + "and --type provenance is a content-agnostic citation scan applied to every collected target " + "(forced-provenance dir walks collect the .md/.ts text face)").argument("[target]", "File or directory to lint").option("--type <type>", "Force the content type (plan | skill | strategy | report | code | finding | provenance); " + "provenance dir walks collect the .md/.ts text face").option("--pr-variant", "With --type finding: enforce the PR-only Merge class contract (presence, enum, placement after Confidence)").action(async (target, options) => {
|
|
19208
19511
|
try {
|
|
19209
19512
|
if (!target)
|
|
19210
19513
|
throw new SddScriptError("usage: lint <target> (file or dir)", 2);
|
|
19211
19514
|
let forcedType = null;
|
|
19212
19515
|
if (options.type !== undefined) {
|
|
19213
19516
|
const forced = options.type.trim().toLowerCase();
|
|
19214
|
-
const KNOWN = ["plan", "skill", "strategy", "report", "code", "finding"];
|
|
19517
|
+
const KNOWN = ["plan", "skill", "strategy", "report", "code", "finding", "provenance"];
|
|
19215
19518
|
if (!KNOWN.includes(forced)) {
|
|
19216
19519
|
throw new SddScriptError(`usage: lint --type must be one of ${KNOWN.join(" | ")}, got ${JSON.stringify(options.type)}`, 2);
|
|
19217
19520
|
}
|
|
@@ -19220,7 +19523,8 @@ lintCommand.description("Lint <target> (file or dir) \u2014 exit 1 on violations
|
|
|
19220
19523
|
const abs = resolveCliPath(target);
|
|
19221
19524
|
if (!fs12.existsSync(abs))
|
|
19222
19525
|
throw new Error(`lint target not found: ${abs}`);
|
|
19223
|
-
const
|
|
19526
|
+
const isDir = fs12.statSync(abs).isDirectory();
|
|
19527
|
+
const targets = !isDir ? [abs] : forcedType === "provenance" ? collectLintTargets(abs, (file) => PROVENANCE_LINT_EXTENSIONS[path15.extname(file).toLowerCase()] === true) : collectLintTargets(abs);
|
|
19224
19528
|
if (targets.length === 0) {
|
|
19225
19529
|
console.log(import_picocolors3.default.yellow(`lint: no lintable files under ${target}`));
|
|
19226
19530
|
return;
|
|
@@ -19247,10 +19551,10 @@ lintCommand.description("Lint <target> (file or dir) \u2014 exit 1 on violations
|
|
|
19247
19551
|
violations += result.violations.length;
|
|
19248
19552
|
const count = result.violations.length;
|
|
19249
19553
|
console.error(import_picocolors3.default.red(`${label}: FAIL (${count} violation${count === 1 ? "" : "s"})`));
|
|
19250
|
-
for (const
|
|
19251
|
-
console.error(` - [${
|
|
19252
|
-
if (
|
|
19253
|
-
console.error(` fix: ${
|
|
19554
|
+
for (const violation17 of result.violations) {
|
|
19555
|
+
console.error(` - [${violation17.severity}] ${violation17.code}: ${violation17.message}`);
|
|
19556
|
+
if (violation17.fix)
|
|
19557
|
+
console.error(` fix: ${violation17.fix}`);
|
|
19254
19558
|
}
|
|
19255
19559
|
}
|
|
19256
19560
|
if (violations > 0)
|
|
@@ -19823,6 +20127,20 @@ prReviewCommand.command("validate-report").description("Validate a saved local P
|
|
|
19823
20127
|
failScript(error, "pr-review validate-report");
|
|
19824
20128
|
}
|
|
19825
20129
|
});
|
|
20130
|
+
var qcCommand = program2.command("qc").description("QC seat-report contract (engine-backed): frontmatter fields, verdict vocabulary, body-verdict " + "agreement, Summary/Findings count parity, truncation/verdict coherence " + "(mstar-review-qc SKILL.md \xA7 seat budgets and truncation)");
|
|
20131
|
+
qcCommand.command("validate-report").description("Validate a saved QC seat report against the machine-readable contract (frontmatter fields, verdict vocabulary, " + "body verdict agreement, Summary/Findings count parity, truncation/verdict coherence; exit 1 with violations printed)").argument("<file.md>", "Saved QC seat report markdown file").action((reportFile) => {
|
|
20132
|
+
try {
|
|
20133
|
+
const abs = resolveCliPath(reportFile);
|
|
20134
|
+
if (!fs12.existsSync(abs))
|
|
20135
|
+
throw new Error(`report file not found: ${abs}`);
|
|
20136
|
+
const gate3 = validateQcReport(fs12.readFileSync(abs, "utf8"));
|
|
20137
|
+
printChecklist(abs, gate3);
|
|
20138
|
+
if (!gate3.ok)
|
|
20139
|
+
process.exitCode = 1;
|
|
20140
|
+
} catch (error) {
|
|
20141
|
+
failScript(error, "qc validate-report");
|
|
20142
|
+
}
|
|
20143
|
+
});
|
|
19826
20144
|
function gitSync(args, cwd) {
|
|
19827
20145
|
return execFileSync11("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
19828
20146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mstar-harness/cli",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"description": "Morning Star harness CLI — installer bootstrap + mstar workflow verbs (path/status/lease/sdd/iteration/dispatch/worktree/lint/design-md/audit/compound/host/skill).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|