Skip to content

Commit 2cb024f

Browse files
vincentkocLucienShui
authored andcommitted
fix(qa): allow evidence-free maturity input checks
1 parent bc0e61a commit 2cb024f

3 files changed

Lines changed: 93 additions & 1 deletion

File tree

‎scripts/qa/render-maturity-docs.ts‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ type DerivedCoverageScores = QaMaturityCoverageScores & {
8585
warnings: string[];
8686
};
8787

88+
const MATURITY_DOC_OUTPUTS = ["maturity/scorecard.md", "maturity/taxonomy.md"] as const;
89+
8890
function parseArgs(argv: string[]): Args {
8991
const args: Args = {
9092
taxonomy: DEFAULT_TAXONOMY_PATH,
@@ -848,14 +850,58 @@ function writeOrCheck(outputPath: string, content: string, check: boolean): bool
848850
return false;
849851
}
850852

853+
function checkEvidenceIndependentInputs({
854+
args,
855+
scoresPath,
856+
taxonomy,
857+
taxonomyPath,
858+
}: {
859+
args: Args;
860+
scoresPath: string;
861+
taxonomy: QaMaturityTaxonomy;
862+
taxonomyPath: string;
863+
}): void {
864+
const { warnings } = readValidatedQaMaturityScoreSources({
865+
scoresPath,
866+
taxonomy,
867+
taxonomyPath,
868+
});
869+
writeInputWarnings(warnings);
870+
if (args.strictInputs) {
871+
enforceStrictInputs(warnings);
872+
}
873+
874+
const missing = MATURITY_DOC_OUTPUTS.map((fileName) =>
875+
path.join(args.outputDir, fileName),
876+
).filter((outputPath) => !fs.existsSync(outputPath));
877+
if (missing.length > 0) {
878+
throw new Error(
879+
`maturity docs check cannot skip evidence-backed freshness because generated docs are missing:\n${missing.map((file) => `- ${file}`).join("\n")}`,
880+
);
881+
}
882+
}
883+
851884
function main(): void {
852885
const args = parseArgs(process.argv.slice(2));
853886
const taxonomyPath = path.normalize(args.taxonomy);
854887
const scoresPath = path.normalize(args.scores);
855888
const docsRoot = path.normalize(args.docsRoot);
856889
const outputDir = path.normalize(args.outputDir);
857-
const evidenceSummaries = readEvidenceSummaries(args.evidenceDir);
858890
const taxonomy = readQaMaturityTaxonomySource(taxonomyPath);
891+
if (args.check && !args.evidenceDir?.trim()) {
892+
checkEvidenceIndependentInputs({
893+
args: { ...args, outputDir },
894+
scoresPath,
895+
taxonomy,
896+
taxonomyPath,
897+
});
898+
process.stdout.write(
899+
`maturity docs inputs are valid in ${outputDir}; evidence-backed freshness check skipped because --evidence-dir was not supplied\n`,
900+
);
901+
return;
902+
}
903+
904+
const evidenceSummaries = readEvidenceSummaries(args.evidenceDir);
859905
const coverage = deriveCoverageScores(taxonomy, evidenceSummaries);
860906
const { scores, warnings: scoreWarnings } = readValidatedQaMaturityScoreSources({
861907
coverageScores: coverage,

‎scripts/test-projects.test-support.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,7 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([
13111311
["scripts/qa-lab-up.ts", ["test/scripts/qa-lab-up.test.ts"]],
13121312
["scripts/qa-coverage-report.ts", ["test/scripts/qa-report-cli.test.ts"]],
13131313
["scripts/qa-parity-report.ts", ["test/scripts/qa-report-cli.test.ts"]],
1314+
["scripts/qa/render-maturity-docs.ts", ["test/scripts/render-maturity-docs.test.ts"]],
13141315
[
13151316
"scripts/qa/ux-matrix-evidence-producer.ts",
13161317
["test/scripts/qa-ux-matrix-evidence-producer.test.ts"],
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Maturity docs renderer tests cover evidence-backed generated-doc checks.
2+
import { spawnSync } from "node:child_process";
3+
import path from "node:path";
4+
import { afterEach, describe, expect, it } from "vitest";
5+
import { createTempDirTracker } from "../helpers/temp-dir.js";
6+
7+
const repoRoot = path.resolve(__dirname, "../..");
8+
const tempDirs = createTempDirTracker();
9+
10+
afterEach(() => {
11+
tempDirs.cleanup();
12+
});
13+
14+
function runCli(...args: string[]) {
15+
return spawnSync(
16+
process.execPath,
17+
["--import", "tsx", "scripts/qa/render-maturity-docs.ts", ...args],
18+
{
19+
cwd: repoRoot,
20+
encoding: "utf8",
21+
},
22+
);
23+
}
24+
25+
describe("maturity docs renderer CLI", () => {
26+
it("checks maturity inputs without requiring QA evidence artifacts", () => {
27+
const result = runCli("--check");
28+
29+
expect(result.status).toBe(0);
30+
expect(result.stderr).toBe("");
31+
expect(result.stdout).toContain("maturity docs inputs are valid in docs");
32+
expect(result.stdout).toContain("evidence-backed freshness check skipped");
33+
});
34+
35+
it("still requires QA evidence artifacts when rendering generated docs", () => {
36+
const outputDir = tempDirs.make("openclaw-maturity-docs-test-");
37+
const result = runCli("--output-dir", outputDir);
38+
39+
expect(result.status).toBe(1);
40+
expect(result.stdout).toBe("");
41+
expect(result.stderr).toContain(
42+
"maturity scorecard rendering requires all or release profile qa-evidence.json",
43+
);
44+
});
45+
});

0 commit comments

Comments
 (0)