Skip to content

Commit bc277fa

Browse files
steipeteampagent
andauthored
1 parent 7068006 commit bc277fa

8 files changed

Lines changed: 361 additions & 168 deletions

File tree

‎config/assertion-safety-baseline.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ extensions/qa-lab/src/suite-runtime-agent-process.ts 7
11131113
extensions/qa-lab/src/suite-runtime-agent-session.ts 5
11141114
extensions/qa-lab/src/suite-runtime-agent-tools.ts 1
11151115
extensions/qa-lab/src/suite-runtime-gateway.ts 2
1116-
extensions/qa-lab/src/suite-summary.ts 6
1116+
extensions/qa-lab/src/suite-summary.ts 5
11171117
extensions/qa-lab/src/suite-support.ts 1
11181118
extensions/qa-lab/src/test-file-scenario-script-evidence.ts 2
11191119
extensions/qa-lab/src/test-file-scenario-vitest-report.ts 1

‎extensions/qa-lab/src/cli.runtime.test.ts‎

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,84 @@ describe("qa cli runtime", () => {
507507
);
508508
});
509509

510+
it("rejects a direct suite summary with unaccounted outcomes", async () => {
511+
await fs.writeFile(
512+
suiteSummaryPath,
513+
JSON.stringify({
514+
counts: { total: 2, passed: 1, failed: 0, skipped: 0 },
515+
scenarios: [{ status: "pass" }],
516+
}),
517+
"utf8",
518+
);
519+
runQaSuite.mockResolvedValueOnce(
520+
unifiedSuiteRuntimeResult({
521+
outputDir: suiteArtifactsDir,
522+
reportPath: suiteReportPath,
523+
summaryPath: suiteSummaryPath,
524+
evidencePath: suiteEvidencePath,
525+
}),
526+
);
527+
528+
await expect(runQaSuiteCommand({ repoRoot: "/tmp/openclaw-repo" })).rejects.toMatchObject({
529+
code: "summary_counts_invalid",
530+
});
531+
});
532+
533+
it("rejects a direct suite summary whose canonical evidence contradicts its counts", async () => {
534+
await fs.writeFile(
535+
suiteSummaryPath,
536+
JSON.stringify({
537+
counts: { total: 1, passed: 1, failed: 0, skipped: 0 },
538+
scenarios: [{ status: "pass" }],
539+
evidence: { entries: [{ result: { status: "fail" } }] },
540+
}),
541+
"utf8",
542+
);
543+
runQaSuite.mockResolvedValueOnce(
544+
unifiedSuiteRuntimeResult({
545+
outputDir: suiteArtifactsDir,
546+
reportPath: suiteReportPath,
547+
summaryPath: suiteSummaryPath,
548+
evidencePath: suiteEvidencePath,
549+
}),
550+
);
551+
552+
await expect(runQaSuiteCommand({ repoRoot: "/tmp/openclaw-repo" })).rejects.toMatchObject({
553+
code: "summary_counts_invalid",
554+
});
555+
});
556+
557+
it("accepts a passing scenario with lower-level blocked and passing producer checks", async () => {
558+
const priorExitCode = process.exitCode;
559+
process.exitCode = undefined;
560+
await fs.writeFile(
561+
suiteSummaryPath,
562+
JSON.stringify({
563+
counts: { total: 1, passed: 1, failed: 0, skipped: 0 },
564+
scenarios: [{ status: "pass" }],
565+
evidence: {
566+
entries: [{ result: { status: "blocked" } }, { result: { status: "pass" } }],
567+
},
568+
}),
569+
"utf8",
570+
);
571+
runQaSuite.mockResolvedValueOnce(
572+
unifiedSuiteRuntimeResult({
573+
outputDir: suiteArtifactsDir,
574+
reportPath: suiteReportPath,
575+
summaryPath: suiteSummaryPath,
576+
evidencePath: suiteEvidencePath,
577+
}),
578+
);
579+
580+
try {
581+
await runQaSuiteCommand({ repoRoot: "/tmp/openclaw-repo" });
582+
expect(process.exitCode).toBeUndefined();
583+
} finally {
584+
process.exitCode = priorExitCode;
585+
}
586+
});
587+
510588
it("keeps a direct suite green for a real pass and a report-only optional tool skip", async () => {
511589
const priorExitCode = process.exitCode;
512590
process.exitCode = undefined;
@@ -624,12 +702,10 @@ describe("qa cli runtime", () => {
624702
await fs.writeFile(
625703
suiteSummaryPath,
626704
JSON.stringify({
627-
counts: {
628-
total: 1,
629-
passed: 0,
630-
failed: 0,
631-
skipped: summary === "required-skip" ? 1 : 0,
632-
},
705+
counts:
706+
summary === "required-skip"
707+
? { total: 1, passed: 0, failed: 0, skipped: 1 }
708+
: { total: 1 },
633709
scenarios: [
634710
{
635711
name: "Required channel scenario",

‎extensions/qa-lab/src/confidence-report.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ describe("qa confidence report", () => {
750750
for (const [artifact, expectedDetail] of [
751751
[
752752
{ counts: { total: 1, passed: -1, skipped: 0, failed: 0 } },
753-
"counts.passed must be a non-negative integer",
753+
"counts.passed must be a non-negative safe integer",
754754
],
755755
[
756756
{ counts: { total: 1, passed: 2, failed: 0 } },

‎extensions/qa-lab/src/confidence-report.ts‎

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
type RuntimeParityResult,
2727
type RuntimeParityToolCall,
2828
} from "./runtime-parity.js";
29+
import { findQaSuiteSummaryAccountingError } from "./suite-summary.js";
2930
import { buildTokenEfficiencyReport } from "./token-efficiency-report.js";
3031

3132
const QA_CONFIDENCE_VERDICTS = [
@@ -364,44 +365,19 @@ function evaluateQaSuiteSummary(payload: unknown): QaConfidenceLaneEvaluation {
364365
details: "qa-suite-summary payload was not an object",
365366
};
366367
}
367-
const counts = isRecord(payload.counts) ? payload.counts : undefined;
368-
for (const key of ["total", "passed", "failed", "skipped"] as const) {
369-
if (counts && Object.hasOwn(counts, key) && readCount(counts[key]) === undefined) {
370-
return {
371-
passed: false,
372-
status: "unknown",
373-
details: `qa-suite-summary counts.${key} must be a non-negative integer`,
374-
};
375-
}
368+
const accountingError = findQaSuiteSummaryAccountingError(payload);
369+
if (accountingError) {
370+
return {
371+
passed: false,
372+
status: "unknown",
373+
details: `qa-suite-summary ${accountingError}`,
374+
};
376375
}
376+
const counts = isRecord(payload.counts) ? payload.counts : undefined;
377377
const totalCount = readCount(counts?.total);
378378
const passedCount = readCount(counts?.passed);
379379
const failedCount = readCount(counts?.failed);
380380
const explicitSkippedCount = readCount(counts?.skipped);
381-
if (totalCount !== undefined) {
382-
const providedCountSum = (passedCount ?? 0) + (failedCount ?? 0) + (explicitSkippedCount ?? 0);
383-
if (totalCount < providedCountSum) {
384-
return {
385-
passed: false,
386-
status: "unknown",
387-
details: `qa-suite-summary counts.total=${totalCount} is less than provided count sum=${providedCountSum}`,
388-
};
389-
}
390-
if (
391-
passedCount !== undefined &&
392-
failedCount !== undefined &&
393-
explicitSkippedCount !== undefined &&
394-
totalCount !== providedCountSum
395-
) {
396-
return {
397-
passed: false,
398-
status: "unknown",
399-
details: `qa-suite-summary counts.total=${totalCount} does not match counts.passed+counts.failed+counts.skipped=${
400-
providedCountSum
401-
}`,
402-
};
403-
}
404-
}
405381
const scenarios = Array.isArray(payload.scenarios) ? payload.scenarios : undefined;
406382
const failedScenarios = scenarios?.filter(
407383
(scenario) => isRecord(scenario) && scenario.status === "fail",

‎extensions/qa-lab/src/errors.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type QaSuiteArtifactErrorCode =
1111
| "summary_missing"
1212
| "summary_read_failed"
1313
| "summary_parse_failed"
14+
| "summary_counts_invalid"
1415
| "summary_failure_count_missing"
1516
| "summary_blocking_count_missing";
1617

‎extensions/qa-lab/src/live-transports/telegram/cli.runtime.test.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ describe("Telegram live QA scenario gate", () => {
5757
let summaryPath: string;
5858

5959
function writeSummary(status: string) {
60+
const skipped = status === "skip" || status === "skipped";
61+
const counts =
62+
status === "pass" || status === "fail" || skipped
63+
? {
64+
total: 1,
65+
passed: status === "pass" ? 1 : 0,
66+
failed: status === "fail" ? 1 : 0,
67+
skipped: skipped ? 1 : 0,
68+
}
69+
: { total: 1 };
6070
writeFileSync(
6171
summaryPath,
6272
JSON.stringify({
63-
counts: {
64-
total: 1,
65-
passed: status === "pass" ? 1 : 0,
66-
failed: status === "fail" ? 1 : 0,
67-
skipped: status === "skip" || status === "skipped" ? 1 : 0,
68-
},
73+
counts,
6974
scenarios: [{ name: "channel-canary", status }],
7075
}),
7176
"utf8",

0 commit comments

Comments
 (0)