Skip to content

Commit 6baa2b3

Browse files
committed
ci(mantis): make telegram proof skips public-safe
1 parent 48f7db2 commit 6baa2b3

3 files changed

Lines changed: 116 additions & 10 deletions

File tree

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ Hard limits:
1616
- Do not finish with tiny, cropped-wrong, off-bottom, or sidebar-heavy GIFs.
1717
- Do not invent a generic proof. The proof must match the PR behavior.
1818
- Do not force GIFs for internal-only, workflow-only, test-only, docs-only, or
19-
otherwise non-visual PRs. A no-visual-proof manifest is a successful outcome
20-
when GIFs would be misleading.
19+
otherwise non-visual PRs. A no-visual-proof manifest is a successful workflow
20+
outcome when GIFs would be misleading, but it is not proof that the PR passed.
21+
- Keep public-facing manifest summaries short and user-domain. Do not mention
22+
harness internals, mock-provider limits, secret/trust boundaries, local paths,
23+
transcript seeding, or workflow implementation details in the summary.
2124

2225
Inputs are provided as environment variables:
2326

@@ -42,9 +45,10 @@ Required workflow:
4245
before/after. If it does not, write
4346
`${MANTIS_OUTPUT_DIR}/mantis-evidence.json` with `comparison.pass: true`, no
4447
artifacts, and a summary that starts with
45-
`Mantis did not generate before/after GIFs because`. Include the concrete
46-
reason in the summary. Use this manifest shape and do not create worktrees
47-
or start Crabbox for this case:
48+
`Mantis did not generate before/after GIFs because`. Include a short
49+
public reason, such as `the PR changes internal session bookkeeping rather
50+
than Telegram-visible behavior`. Use this manifest shape and do not create
51+
worktrees or start Crabbox for this case:
4852

4953
```json
5054
{
@@ -73,6 +77,14 @@ Required workflow:
7377
}
7478
```
7579

80+
If the PR appears visual but proof is blocked by Telegram Desktop session
81+
state, authorization, credentials, Crabbox, or another capture-infrastructure
82+
issue, do not describe it as a no-visual PR. Write a manifest with
83+
`comparison.pass: false`, skipped lanes, no artifacts, and a summary that
84+
starts with `Mantis could not capture Telegram Desktop proof because`. The
85+
publisher will keep that out of PR comments so the failure stays in the
86+
workflow logs and artifacts.
87+
7688
4. Decide what Telegram message, mock model response, command, callback, button,
7789
media, or sequence best proves the PR. Use `MANTIS_INSTRUCTIONS` as extra
7890
maintainer guidance, not as a replacement for reading the PR.
@@ -134,4 +146,6 @@ Expected final state:
134146
`Main` and `This PR`.
135147
- No-visual-proof manifests contain no artifacts and have `comparison.pass:
136148
true`.
149+
- Capture-infrastructure failure manifests contain no artifacts and have
150+
`comparison.pass: false`.
137151
- The worktree can be dirty only under `.artifacts/`.

‎scripts/mantis/publish-pr-evidence.mjs‎

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,47 @@ function laneLine(label, lane) {
308308
return pieces.join("");
309309
}
310310

311+
function hasVisibleProofArtifacts(manifest) {
312+
return manifest.artifacts.some((artifact) =>
313+
["desktopScreenshot", "fullVideo", "motionClip", "motionPreview", "timeline"].includes(
314+
artifact.kind,
315+
),
316+
);
317+
}
318+
319+
function isSkippedNoVisualProof(manifest) {
320+
const comparison = manifest.comparison ?? {};
321+
return (
322+
!hasVisibleProofArtifacts(manifest) &&
323+
comparison.baseline?.status === "skipped" &&
324+
comparison.candidate?.status === "skipped"
325+
);
326+
}
327+
328+
function publicSummary(manifest) {
329+
if (isSkippedNoVisualProof(manifest)) {
330+
return "Mantis did not generate before/after GIFs because this PR does not have a clean Telegram-visible before/after proof in the standard Mantis run.";
331+
}
332+
return manifest.summary ?? "Mantis captured QA evidence for this scenario.";
333+
}
334+
335+
function overallStatus(manifest) {
336+
if (isSkippedNoVisualProof(manifest)) {
337+
return "skipped";
338+
}
339+
const pass = manifest.comparison?.pass;
340+
return typeof pass === "boolean" ? String(pass) : "";
341+
}
342+
343+
export function shouldPublishPrComment(manifest) {
344+
if (!isSkippedNoVisualProof(manifest)) {
345+
return true;
346+
}
347+
return !/(authorization[- ]?error|credential infrastructure|logged[- ]out|login screen|welcome screen|bad telegram session)/iu.test(
348+
manifest.summary ?? "",
349+
);
350+
}
351+
311352
export function renderEvidenceComment({
312353
artifactUrl: actionsArtifactUrl,
313354
manifest,
@@ -333,7 +374,7 @@ export function renderEvidenceComment({
333374
marker,
334375
`## ${manifest.title}`,
335376
"",
336-
`Summary: ${manifest.summary ?? "Mantis captured QA evidence for this scenario."}`,
377+
`Summary: ${publicSummary(manifest)}`,
337378
"",
338379
`- Scenario: \`${manifest.scenario}\``,
339380
];
@@ -354,8 +395,9 @@ export function renderEvidenceComment({
354395
if (candidateLine) {
355396
lines.push(candidateLine);
356397
}
357-
if (typeof comparison.pass === "boolean") {
358-
lines.push(`- Overall: \`${comparison.pass}\``);
398+
const overall = overallStatus(manifest);
399+
if (overall) {
400+
lines.push(`- Overall: \`${overall}\``);
359401
}
360402
lines.push("");
361403

@@ -551,6 +593,10 @@ export async function publishEvidence(rawArgs = process.argv.slice(2)) {
551593
runUrl: args.run_url,
552594
treeUrl: published.treeUrl,
553595
});
596+
if (!shouldPublishPrComment(manifest)) {
597+
console.log("Skipped Mantis QA evidence PR comment because the run did not capture proof.");
598+
return;
599+
}
554600
upsertPrComment({
555601
body,
556602
marker: args.marker,

‎test/scripts/mantis-publish-pr-evidence.test.ts‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
loadEvidenceManifest,
77
publishArtifactFiles,
88
renderEvidenceComment,
9+
shouldPublishPrComment,
910
} from "../../scripts/mantis/publish-pr-evidence.mjs";
1011

1112
const tempDirs: string[] = [];
@@ -276,13 +277,58 @@ describe("scripts/mantis/publish-pr-evidence", () => {
276277
"mantis-evidence.json",
277278
]);
278279
expect(body).toContain(
279-
"Summary: Mantis did not generate before/after GIFs because this PR changes CI wiring only.",
280+
"Summary: Mantis did not generate before/after GIFs because this PR does not have a clean Telegram-visible before/after proof in the standard Mantis run.",
280281
);
281-
expect(body).toContain("- Overall: `true`");
282+
expect(body).toContain("- Overall: `skipped`");
282283
expect(body).not.toContain("<table");
283284
expect(body).not.toContain("<img ");
284285
});
285286

287+
it("does not publish PR comments for Telegram capture infrastructure failures", () => {
288+
const dir = mkdtempSync(path.join(tmpdir(), "mantis-evidence-test-"));
289+
tempDirs.push(dir);
290+
const manifestPath = path.join(dir, "mantis-evidence.json");
291+
writeFileSync(
292+
manifestPath,
293+
JSON.stringify({
294+
artifacts: [],
295+
comparison: {
296+
baseline: {
297+
expected: "no acceptable native Telegram Desktop visual artifact",
298+
status: "skipped",
299+
},
300+
candidate: {
301+
expected: "no acceptable native Telegram Desktop visual artifact",
302+
status: "skipped",
303+
},
304+
pass: false,
305+
},
306+
id: "telegram-desktop-proof",
307+
scenario: "telegram-desktop-proof",
308+
schemaVersion: 1,
309+
summary:
310+
"Mantis could not capture Telegram Desktop proof because native Telegram Desktop opened to the logged-out welcome screen.",
311+
title: "Mantis Telegram Desktop Proof",
312+
}),
313+
);
314+
315+
const manifest = loadEvidenceManifest(manifestPath);
316+
const body = renderEvidenceComment({
317+
manifest,
318+
marker: "<!-- mantis-telegram-desktop-proof -->",
319+
rawBase: "https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-1/run-1",
320+
requestSource: "pull_request_target",
321+
runUrl: "https://github.com/openclaw/openclaw/actions/runs/1",
322+
treeUrl: "https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-1/run-1/index.json",
323+
});
324+
325+
expect(body).toContain(
326+
"Summary: Mantis did not generate before/after GIFs because this PR does not have a clean Telegram-visible before/after proof in the standard Mantis run.",
327+
);
328+
expect(body).toContain("- Overall: `skipped`");
329+
expect(shouldPublishPrComment(manifest)).toBe(false);
330+
});
331+
286332
it("rejects artifact paths that escape the manifest directory", () => {
287333
const dir = mkdtempSync(path.join(tmpdir(), "mantis-evidence-test-"));
288334
tempDirs.push(dir);

0 commit comments

Comments
 (0)