Skip to content

Commit ae63b16

Browse files
authored
feat: add maturity shortlist helper (#373)
1 parent 84796f0 commit ae63b16

7 files changed

Lines changed: 168 additions & 4 deletions

File tree

‎package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
"crabbox:warmup": "crabbox warmup",
9898
"repair:pr-intake": "node dist/repair/pr-repair-intake.js"
9999
},
100+
"dependencies": {
101+
"yaml": "^2.9.0"
102+
},
100103
"devDependencies": {
101104
"@types/node": "^25.9.2",
102105
"@typescript/native-preview": "7.0.0-dev.20260609.1",

‎pnpm-lock.yaml‎

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎prompts/review-item.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ review findings.
166166

167167
Set `maturityLabels` for issues only; use `[]` for PRs or unsupported matches.
168168
`maturity:stable`: Issue affects a taxonomy feature currently scored M4/M5.
169-
Match the issue to active features in `taxonomy.yaml` and
170-
the checked-out `qa/maturity-scores.yaml` (`docs/maturity/` may help). Select
171-
`maturity:stable` only for M4/M5 matches. Cite the feature id/name and score in
172-
`evidence` and `labelJustifications`.
169+
First run `node "$CLAWSWEEPER_PROOF_SCRATCH_DIR/maturity-stable-shortlist.mjs"`
170+
from the target checkout and compare the issue against the M4+ shortlist. Read
171+
`taxonomy.yaml`, the full checked-out `qa/maturity-scores.yaml`, or
172+
`docs/maturity/` only if the shortlist is ambiguous. Select `maturity:stable`
173+
only for M4/M5 matches. Cite the feature id/name and score in `evidence` and
174+
`labelJustifications`.
173175
Stable maturity supports priority, but does not automatically escalate it.
174176

175177
Set `mergeRiskLabels` as PR-only ClawSweeper-owned GitHub labels for merge
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env node
2+
import { existsSync, readFileSync } from "node:fs";
3+
import { parse } from "yaml";
4+
5+
const scorecardPath = process.argv[2] || "qa/maturity-scores.yaml";
6+
7+
if (!existsSync(scorecardPath)) {
8+
console.error(`Maturity scorecard not found: ${scorecardPath}`);
9+
process.exit(1);
10+
}
11+
12+
console.log(stableShortlist(readFileSync(scorecardPath, "utf8")));
13+
14+
function stableShortlist(text) {
15+
const scorecard = parse(text);
16+
const surfaces = Array.isArray(scorecard?.surfaces) ? scorecard.surfaces : [];
17+
const rows = surfaces
18+
.map(surfaceSummary)
19+
.filter((surface) => Number(surface.code.replace(/^M/, "")) >= 4);
20+
21+
if (rows.length === 0) return "No M4+ maturity scorecard surfaces found.";
22+
return rows
23+
.map((surface) => {
24+
const categories = surface.categories.length
25+
? ` | categories: ${surface.categories.join("; ")}`
26+
: "";
27+
return `${surface.id} | ${surface.name} | ${surface.code} ${surface.label} | q${surface.quality} c${surface.completeness}${categories}`;
28+
})
29+
.join("\n");
30+
}
31+
32+
function surfaceSummary(surface) {
33+
return {
34+
id: String(surface?.id ?? ""),
35+
name: String(surface?.name ?? ""),
36+
code: String(surface?.level?.code ?? ""),
37+
label: String(surface?.level?.label ?? ""),
38+
quality: Number(surface?.scores?.quality?.score ?? 0),
39+
completeness: Number(surface?.scores?.completeness?.score ?? 0),
40+
categories: Array.isArray(surface?.categories)
41+
? surface.categories.map((category) => String(category?.name ?? "")).filter(Boolean)
42+
: [],
43+
};
44+
}

‎src/clawsweeper.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,11 @@ const DEFAULT_CODEX_FALLBACK_MIN_BUDGET_MS = 120_000;
10861086
const REVIEW_POLICY_VERSION = "2026-06-15-policy-v22";
10871087
const REVIEW_ITEM_PROMPT_PATH = join(ROOT, "prompts", "review-item.md");
10881088
const CLAWSWEEPER_DECISION_SCHEMA_PATH = join(ROOT, "schema", "clawsweeper-decision.schema.json");
1089+
const MATURITY_STABLE_SHORTLIST_SCRIPT_PATH = join(
1090+
ROOT,
1091+
"scripts",
1092+
"maturity-stable-shortlist.mjs",
1093+
);
10891094
const PR_CLOSE_COVERAGE_PROOF_PROMPT_PATH = join(ROOT, "prompts", "pr-close-coverage-proof.md");
10901095
const PR_CLOSE_COVERAGE_PROOF_SCHEMA_PATH = join(
10911096
ROOT,
@@ -7009,6 +7014,9 @@ function buildReviewPrompt(
70097014
const contextJson = contextJsonForPrompt(context);
70107015
const schema = reviewDecisionSchemaText();
70117016
const proofScratchDir = runtimeHints.proofScratchDir?.trim();
7017+
const maturityHelperPath = proofScratchDir
7018+
? `\`${proofScratchDir}/maturity-stable-shortlist.mjs\``
7019+
: "the scratch directory as `maturity-stable-shortlist.mjs`";
70127020
const mediaProofPrompt = mediaProofRuntimePrompt(
70137021
runtimeHints.mediaProofSummary,
70147022
runtimeHints.mediaProofManifestPath,
@@ -7043,6 +7051,7 @@ ${additionalPrompt.trim()}
70437051
- You may use the available network and read-only GitHub token to inspect PR body links, comments, screenshots, videos, logs, terminal output, and target-repo artifacts.
70447052
- Download proof artifacts into ${proofScratchDir ? `\`${proofScratchDir}\`` : "a temporary scratch directory"} before inspecting them.
70457053
- The target checkout is read-only for review. Do not modify repository files; use the scratch directory or /tmp for downloaded evidence and generated video stills/contact sheets.
7054+
- A token-light maturity helper is available at ${maturityHelperPath}. For issue maturity labels, first run \`node "$CLAWSWEEPER_PROOF_SCRATCH_DIR/maturity-stable-shortlist.mjs"\` from the target checkout and compare the issue against that shortlist; read the full scorecard or taxonomy only if the shortlist is ambiguous.
70467055
${mediaProofPrompt}
70477056

70487057
## GitHub Context
@@ -7064,6 +7073,31 @@ ${extra}
70647073
};
70657074
}
70667075

7076+
function prepareMaturityStableShortlistScript(proofScratchDir: string, openclawDir: string): void {
7077+
const scorecardPath = join(openclawDir, "qa", "maturity-scores.yaml");
7078+
const shortlist = maturityStableShortlist(scorecardPath);
7079+
writeFileSync(
7080+
join(proofScratchDir, "maturity-stable-shortlist.mjs"),
7081+
`#!/usr/bin/env node\nconsole.log(${JSON.stringify(shortlist)});\n`,
7082+
"utf8",
7083+
);
7084+
}
7085+
7086+
function maturityStableShortlist(scorecardPath: string): string {
7087+
const result = spawnSync(
7088+
process.execPath,
7089+
[MATURITY_STABLE_SHORTLIST_SCRIPT_PATH, scorecardPath],
7090+
{
7091+
encoding: "utf8",
7092+
maxBuffer: 1024 * 1024,
7093+
},
7094+
);
7095+
if (result.status === 0) return result.stdout.trim();
7096+
const detail =
7097+
result.stderr?.trim() || result.error?.message || "maturity shortlist script failed";
7098+
return `Unable to read maturity shortlist: ${detail}`;
7099+
}
7100+
70677101
function reviewPromptTelemetry(
70687102
item: Item,
70697103
context: ItemContext,
@@ -7446,6 +7480,7 @@ function runCodex(options: {
74467480
const proofScratchDir =
74477481
options.proofScratchDir ?? join(options.workDir, "proof-scratch", String(options.item.number));
74487482
ensureDir(proofScratchDir);
7483+
prepareMaturityStableShortlistScript(proofScratchDir, options.openclawDir);
74497484
const preparedMediaProof = options.prompt
74507485
? { manifestPath: null, summaryPath: null, artifacts: [] }
74517486
: prepareMediaProofArtifacts(options.context, proofScratchDir);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import assert from "node:assert/strict";
2+
import { execFileSync } from "node:child_process";
3+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
4+
import { tmpdir } from "node:os";
5+
import { join } from "node:path";
6+
import test from "node:test";
7+
8+
test("maturity shortlist script emits only M4+ surfaces", () => {
9+
const dir = mkdtempSync(join(tmpdir(), "clawsweeper-maturity-"));
10+
try {
11+
const scorecard = join(dir, "maturity-scores.yaml");
12+
writeFileSync(
13+
scorecard,
14+
[
15+
"surfaces:",
16+
" - id: gateway-runtime",
17+
" name: Gateway runtime",
18+
" level:",
19+
" code: M4",
20+
" label: Stable",
21+
" scores:",
22+
" quality:",
23+
" score: 81",
24+
" completeness:",
25+
" score: 89",
26+
" categories:",
27+
" - name: HTTP APIs",
28+
" - id: agent-runtime",
29+
" name: Agent runtime",
30+
" level:",
31+
" code: M3",
32+
" label: Beta",
33+
].join("\n"),
34+
);
35+
36+
const output = execFileSync(process.execPath, [
37+
"scripts/maturity-stable-shortlist.mjs",
38+
scorecard,
39+
]).toString();
40+
41+
assert.match(output, /gateway-runtime \| Gateway runtime \| M4 Stable \| q81 c89/);
42+
assert.match(output, /categories: HTTP APIs/);
43+
assert.doesNotMatch(output, /agent-runtime/);
44+
} finally {
45+
rmSync(dir, { recursive: true, force: true });
46+
}
47+
});

‎test/review-prompt-policy.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,28 @@ test("review prompt and schema describe positive-only feature showcase labels",
317317
assert.deepEqual(featureShowcase.properties.status.enum, ["showcase", "none"]);
318318
});
319319

320+
test("review prompt uses token-light maturity shortlist helper", () => {
321+
const prompt = readFileSync("prompts/review-item.md", "utf8");
322+
const runtimePrompt = reviewPromptForTest(
323+
item({ kind: "issue" }),
324+
{ issue: {}, comments: [], timeline: [] },
325+
{ mainSha: "abc123", latestRelease: null },
326+
"",
327+
{ proofScratchDir: "/tmp/proof" },
328+
);
329+
330+
assert.match(prompt, /maturity-stable-shortlist\.mjs/);
331+
assert.match(prompt, /compare the issue against the M4\+ shortlist/);
332+
assert.match(
333+
runtimePrompt,
334+
/node "\$CLAWSWEEPER_PROOF_SCRATCH_DIR\/maturity-stable-shortlist\.mjs"/,
335+
);
336+
assert.match(
337+
runtimePrompt,
338+
/read the full scorecard or taxonomy only if the shortlist is ambiguous/,
339+
);
340+
});
341+
320342
test("review prompt classifies Telegram visible proof candidates", () => {
321343
const prompt = readFileSync("prompts/review-item.md", "utf8");
322344

0 commit comments

Comments
 (0)