Skip to content

Commit 3520958

Browse files
authored
fix(mantis): enforce verdict-expectation coherence and publish agent analysis files (#128124)
* fix(mantis): enforce verdict-expectation coherence and publish agent analysis files Mantis run 32619081130 on #127989 published an overall `pass` while its own manifest recorded that the candidate expectation was not observed: per-lane `status` was mechanical capture success and the agent's judgment lived only in `expected` prose, so nothing reconciled the two before publication. - `mantis-evidence.json` schemaVersion 2: each comparison lane carries a required boolean `expectationMet`. The desktop agent sets it in the same manifest edit as `expected`; mechanical producers (Telegram live, web UI, Slack, Discord) derive it from lane status. - `scripts/mantis/publish-pr-evidence.mjs` is the single enforcement owner: it requires the booleans, recomputes `pass`/`outcome`, downgrades a contradictory pass claim to `fail`, and renders a visible "verdict downgraded" note. The desktop workflow invokes it with `--validate-only` before upload or comment. - Agent top-level `*.json`/`*.md` analysis files (assertions, comparisons, recipe suggestion) now survive the quarantine rebuild and upload, so cited evidence actually exists in the artifact. * fix(mantis): derive expectations from trusted lane facts
1 parent 0774c20 commit 3520958

14 files changed

Lines changed: 525 additions & 59 deletions

‎.github/codex/prompts/mantis-telegram-desktop-proof.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ commands, and proof facts. The builder publishes it as a non-inline attachment.
177177
Build `mantis-evidence.json` with
178178
`scripts/mantis/build-telegram-desktop-proof-evidence.mts` as before, using each
179179
lane's generated `telegram-user-crabbox-session-summary.json`. Edit only the
180-
human summary/expected wording. Name the concrete product defect or missing
181-
primitive when a lane fails or blocks; the workflow derives the outcome from
182-
trusted lane facts.
180+
human summary/expected wording and add each lane's assertion in the same edit:
181+
`{"target":"providerRequests|botApiRequests|observationEvents","mode":"contains|absent","value":"literal substring (1..200 chars)"}`.
182+
Trusted code evaluates it against that lane's recorded facts; never set
183+
`expectationMet`. If the expectation cannot be expressed as this fact predicate,
184+
the lane is `blocked` with a concrete reason—never `pass`.
183185

184186
```bash
185187
node --import tsx scripts/mantis/build-telegram-desktop-proof-evidence.mts \

‎.github/workflows/mantis-discord-status-reactions.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,15 @@ jobs:
369369
--arg baseline_sha "${{ needs.validate_refs.outputs.baseline_revision }}" \
370370
--arg candidate_sha "${{ needs.validate_refs.outputs.candidate_revision }}" \
371371
'{
372-
schemaVersion: 1,
372+
schemaVersion: 2,
373373
id: "discord-status-reactions",
374374
title: "Mantis Discord Status Reactions QA",
375375
summary: "Mantis reran Discord status reactions against the known queued-only baseline and the candidate ref. The baseline reproduced the bug, while the candidate showed the expected queued -> thinking -> done reaction sequence.",
376376
scenario: "discord-status-reactions-tool-only",
377377
comparison: {
378-
baseline: { sha: $baseline_sha, expected: "queued-only", status: $baseline_status, reproduced: ($baseline_status == "fail") },
379-
candidate: { sha: $candidate_sha, expected: "queued -> thinking -> done", status: $candidate_status, fixed: ($candidate_status == "pass") },
378+
baseline: { sha: $baseline_sha, expected: "queued-only", expectationMet: ($baseline_status == "fail"), status: $baseline_status, reproduced: ($baseline_status == "fail") },
379+
candidate: { sha: $candidate_sha, expected: "queued -> thinking -> done", expectationMet: ($candidate_status == "pass"), status: $candidate_status, fixed: ($candidate_status == "pass") },
380+
outcome: (if (($baseline_status == "fail") and ($candidate_status == "pass")) then "pass" else "fail" end),
380381
pass: (($baseline_status == "fail") and ($candidate_status == "pass"))
381382
},
382383
artifacts: [

‎.github/workflows/mantis-discord-thread-attachment.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,16 @@ jobs:
402402
--arg candidateStatus "$candidate_status" \
403403
--argjson pass "$([[ "$comparison_status" == "pass" ]] && echo true || echo false)" \
404404
'{
405-
schemaVersion: 1,
405+
schemaVersion: 2,
406406
id: "discord-thread-attachment",
407407
title: "Mantis Discord Thread Attachment QA",
408408
summary: "Mantis reproduced the Discord thread-reply filePath attachment bug with a synthetic baseline that reverts only the thread attachment fix, then verified the candidate preserves the attachment.",
409409
scenario: "discord-thread-reply-filepath-attachment",
410410
comparison: {
411+
outcome: (if $pass then "pass" else "fail" end),
411412
pass: $pass,
412-
baseline: { ref: $baselineRef, status: $baselineStatus, expected: "thread reply omits filePath attachment" },
413-
candidate: { ref: $candidateRef, status: $candidateStatus, expected: "thread reply includes filePath attachment" }
413+
baseline: { ref: $baselineRef, status: $baselineStatus, expected: "thread reply omits filePath attachment", expectationMet: ($baselineStatus == "fail") },
414+
candidate: { ref: $candidateRef, status: $candidateStatus, expected: "thread reply includes filePath attachment", expectationMet: ($candidateStatus == "pass") }
414415
},
415416
artifacts: [
416417
{ kind: "timeline", lane: "baseline", label: "Baseline missing filePath attachment", path: "baseline/discord-thread-reply-filepath-attachment-attachment.png", targetPath: "baseline.png", alt: "Baseline Discord thread reply without filePath attachment", width: 420 },

‎.github/workflows/mantis-slack-desktop-smoke.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,14 @@ jobs:
411411
--argjson screenshot_required "$screenshot_required" \
412412
--argjson desktop_capture_inline "$desktop_capture_inline" \
413413
'{
414-
schemaVersion: 1,
414+
schemaVersion: 2,
415415
id: "slack-desktop-smoke",
416416
title: "Mantis Slack Desktop Smoke QA",
417417
summary: $summary,
418418
scenario: $scenario,
419419
comparison: {
420-
candidate: { sha: $candidate_sha, expected: $expected, status: $status, fixed: ($status == "pass") },
420+
candidate: { sha: $candidate_sha, expected: $expected, expectationMet: ($status == "pass"), status: $status, fixed: ($status == "pass") },
421+
outcome: (if $status == "pass" then "pass" else "fail" end),
421422
pass: ($status == "pass")
422423
},
423424
artifacts: ([

‎.github/workflows/mantis-telegram-desktop-proof.yml‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,22 @@ jobs:
10231023
manifest="$trusted_output/mantis-evidence.json"
10241024
judgment="$RUNNER_TEMP/mantis-agent-judgment.json"
10251025
sudo jq -e '
1026+
def valid_assertion:
1027+
select(type == "object") |
1028+
select((keys | sort) == ["mode", "target", "value"]) |
1029+
select(.target == "providerRequests" or .target == "botApiRequests" or .target == "observationEvents") |
1030+
select(.mode == "contains" or .mode == "absent") |
1031+
select((.value | type) == "string" and (.value | length) >= 1 and (.value | length) <= 200);
1032+
select(.schemaVersion == 2) |
10261033
select((.summary | type) == "string" and (.summary | length) <= 4000) |
10271034
select((.comparison.baseline.expected | type) == "string" and (.comparison.baseline.expected | length) <= 1000) |
10281035
select((.comparison.candidate.expected | type) == "string" and (.comparison.candidate.expected | length) <= 1000) |
10291036
{
10301037
summary,
10311038
baselineExpected: .comparison.baseline.expected,
1032-
candidateExpected: .comparison.candidate.expected
1039+
baselineAssertion: (.comparison.baseline.assertion | valid_assertion),
1040+
candidateExpected: .comparison.candidate.expected,
1041+
candidateAssertion: (.comparison.candidate.assertion | valid_assertion)
10331042
}
10341043
' "$agent_manifest" > "$judgment"
10351044
baseline_status="$(sudo jq -r '.comparison.baseline.status' "$agent_manifest")"
@@ -1164,17 +1173,15 @@ jobs:
11641173
sudo jq --slurpfile judgment "$judgment" '
11651174
.summary = (if .comparison.outcome == "pass" then $judgment[0].summary else .summary end) |
11661175
.comparison.baseline.expected = $judgment[0].baselineExpected |
1167-
.comparison.candidate.expected = $judgment[0].candidateExpected
1176+
.comparison.baseline.assertion = $judgment[0].baselineAssertion |
1177+
.comparison.candidate.expected = $judgment[0].candidateExpected |
1178+
.comparison.candidate.assertion = $judgment[0].candidateAssertion
11681179
' "$manifest" | sudo tee "$trusted_manifest" >/dev/null
11691180
sudo mv "$trusted_manifest" "$manifest"
1170-
1171-
jq -e '
1172-
(.comparison.outcome == "pass" and .comparison.pass == true and
1173-
.comparison.baseline.status == "pass" and .comparison.candidate.status == "pass") or
1174-
(.comparison.outcome == "blocked" and .comparison.pass == false and
1175-
(.comparison.baseline.status == "blocked" or .comparison.candidate.status == "blocked")) or
1176-
(.comparison.outcome == "fail" and .comparison.pass == false)
1177-
' "$manifest" >/dev/null
1181+
sudo env -i PATH=/usr/local/lib/mantis-toolchain:/usr/local/bin:/usr/bin:/bin \
1182+
/usr/local/lib/mantis-toolchain/node \
1183+
"$GITHUB_WORKSPACE/scripts/mantis/publish-pr-evidence.mjs" \
1184+
--manifest "$manifest" --validate-only true
11781185
11791186
token="$(sudo jq -r '.sutToken' "$SUT_CREDENTIAL_DIR/credential.json")"
11801187
if sudo grep -RIlF -- "$token" "$trusted_output" >/dev/null; then

‎scripts/mantis/build-telegram-desktop-proof-evidence.mts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type ManifestLane = {
3434
detail?: string;
3535
digest?: string;
3636
expected: string;
37+
expectationMet?: boolean;
3738
status: string;
3839
ref?: string;
3940
sha?: string;
@@ -490,7 +491,7 @@ function buildTelegramDesktopProofManifest({
490491
const baselineDigest = laneDigest(baseline.facts);
491492
const candidateDigest = laneDigest(candidate.facts);
492493
return {
493-
schemaVersion: 1,
494+
schemaVersion: 2,
494495
id: "telegram-desktop-proof",
495496
title: "Mantis Telegram Desktop Proof",
496497
summary: outcome === "pass" ? PASS_SUMMARY : INCOMPLETE_SUMMARY,

‎scripts/mantis/build-telegram-evidence.mts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ type TelegramEvidenceManifest = {
4747
comparison: {
4848
candidate: {
4949
expected: string;
50+
expectationMet: boolean;
5051
status: string;
5152
fixed: boolean;
5253
ref?: string;
5354
sha?: string;
5455
};
56+
outcome: "fail" | "pass";
5557
pass: boolean;
5658
};
5759
artifacts: TelegramEvidenceArtifact[];
@@ -444,7 +446,7 @@ export function buildTelegramEvidenceManifest({
444446
},
445447
];
446448
return {
447-
schemaVersion: 1,
449+
schemaVersion: 2,
448450
id: "telegram-live",
449451
title: "Mantis Telegram Live QA",
450452
summary:
@@ -455,9 +457,11 @@ export function buildTelegramEvidenceManifest({
455457
...(candidateSha ? { sha: candidateSha } : {}),
456458
...(candidateRef ? { ref: candidateRef } : {}),
457459
expected: "Telegram live QA scenarios pass",
460+
expectationMet: pass,
458461
status,
459462
fixed: pass,
460463
},
464+
outcome: pass ? "pass" : "fail",
461465
pass,
462466
},
463467
artifacts,

‎scripts/mantis/build-web-ui-chat-evidence.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function artifactEntry({ inline = false, kind, label, path: artifactPath, requir
5050
export function buildWebUiChatEvidenceManifest({ candidateRef, candidateSha, status }) {
5151
const passed = status === "pass";
5252
return {
53-
schemaVersion: 1,
53+
schemaVersion: 2,
5454
id: "web-ui-chat-proof",
5555
title: "Mantis Web UI Chat Proof",
5656
summary:
@@ -61,9 +61,11 @@ export function buildWebUiChatEvidenceManifest({ candidateRef, candidateSha, sta
6161
...(candidateSha ? { sha: candidateSha } : {}),
6262
...(candidateRef ? { ref: candidateRef } : {}),
6363
expected: "Control UI chat sends through the Gateway and renders the final reply",
64+
expectationMet: passed,
6465
status,
6566
fixed: passed,
6667
},
68+
outcome: passed ? "pass" : "fail",
6769
pass: passed,
6870
},
6971
artifacts: [

0 commit comments

Comments
 (0)