Skip to content

Commit 0933263

Browse files
authored
fix(mantis): publish proof comments on auto-triggered runs (#127787)
## What Problem This Solves Auto-triggered Mantis proof runs (label/`clawsweeper_label` and other non-comment request sources) end with no PR comment at all. The durable evidence publisher runs with `--create-missing false` and only edits an existing marker comment, but the inline status comment carrying that marker was only created when `request_source == 'issue_comment'`. Label-triggered runs therefore published nothing and logged the misleading "Skipped stale Mantis QA evidence comment because its status is no longer active" — observed on PR #127735. This is the silent-failure class: a Mantis run completes and the PR shows no visible outcome. ## Why This Change Was Made - `.github/workflows/mantis-telegram-desktop-proof.yml`: the status ack comment (👀 + active-job link + run-scoped marker) is now created for every request source that resolves to a PR (`pr_number != ''`), not only `issue_comment`. The 👀 *reaction* stays `issue_comment`-only (it lives in `mantis-resolve-request.yml`, untouched — there is no triggering comment to react to on label runs). - The start-failure fallback comment and the existing-artifact republish path now use the same run-scoped marker `<!-- mantis-telegram-desktop-proof:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT} -->` as the status comment and the main publisher, so every publisher edits the single run-owned comment (ack → progress → final proof; no comment spam). The republish path gets an explicit `--create-missing false` to match. The design invariant that makes `false` safe: the fallback status-comment step is not `continue-on-error`, so a run in which no marker comment could be created fails `resolve_request` and never reaches publish. - `scripts/mantis/publish-pr-evidence.mjs`: the two skip cases now log honestly — "no existing comment found" vs "could not update existing comment" — instead of one misleading stale-status message. ## User Impact Operators triggering Mantis via labels (ClawSweeper flows) now get the same single evolving PR comment as comment-triggered runs: an immediate 👀 ack with the running job link, edited in place into the final proof evidence. No more runs that finish invisibly. ## Evidence - Focused suite: `node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts` — 28/28, including new assertions that the status/failure comment gates use `pr_number != ''` (and not `request_source`) and that both publishers pass the run-scoped marker with `--create-missing false`. - `node scripts/check-changed.mjs -- <touched files>` green; `git diff --check` clean. - Marker alignment verified across all five sites in the workflow (status comment, prior-attempt cleanup regex, fallback comment, failure report, both publisher invocations): all use `mantis-telegram-desktop-proof:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}`. - Live-run proof of the label-triggered path requires a merged workflow (GitHub runs the workflow from the default branch for these triggers), so the first post-merge label-triggered Mantis run is the live verification; stated here as the known evidence gap. Production LOC delta: −4 (workflow/tooling); tests +13.
1 parent 10e0e69 commit 0933263

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ jobs:
181181
setOutput("request_source", requestSource);
182182
- name: Create Mantis status token
183183
id: mantis_status_token
184-
if: ${{ steps.resolve.outputs.request_source == 'issue_comment' }}
184+
if: ${{ steps.resolve.outputs.pr_number != '' }}
185185
continue-on-error: true
186186
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
187187
with:
@@ -201,12 +201,9 @@ jobs:
201201
with:
202202
github-token: ${{ steps.mantis_status_token.outputs.token }}
203203
script: |
204-
const markerRoot = "<!-- mantis-telegram-desktop-proof:";
205-
const runId = Number(process.env.GITHUB_RUN_ID);
206-
const runAttempt = Number(process.env.GITHUB_RUN_ATTEMPT);
207-
const marker = `${markerRoot}${runId}-${runAttempt} -->`;
204+
const marker = `<!-- mantis-telegram-desktop-proof:${process.env.GITHUB_RUN_ID}-${process.env.GITHUB_RUN_ATTEMPT} -->`;
208205
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
209-
const body = `${marker}\nMantis started this proof. [Follow the active job](${runUrl}).`;
206+
const body = `${marker}\n👀 Mantis started this proof. [Follow the active job](${runUrl}).`;
210207
const { owner, repo } = context.repo;
211208
const issueNumber = Number(process.env.TARGET_PR);
212209
await github.rest.issues.createComment({
@@ -248,7 +245,7 @@ jobs:
248245
if: >-
249246
${{
250247
always() &&
251-
steps.resolve.outputs.request_source == 'issue_comment' &&
248+
steps.resolve.outputs.pr_number != '' &&
252249
(
253250
steps.mantis_status_token.outcome != 'success' ||
254251
steps.mantis_status_comment.outcome != 'success'
@@ -260,7 +257,7 @@ jobs:
260257
with:
261258
github-token: ${{ github.token }}
262259
script: |
263-
const marker = "<!-- mantis-telegram-desktop-proof -->";
260+
const marker = `<!-- mantis-telegram-desktop-proof:${process.env.GITHUB_RUN_ID}-${process.env.GITHUB_RUN_ATTEMPT} -->`;
264261
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
265262
const { owner, repo } = context.repo;
266263
await github.rest.issues.createComment({
@@ -1238,7 +1235,7 @@ jobs:
12381235
--request-source "$REQUEST_SOURCE"
12391236
12401237
- name: Report failed Mantis proof
1241-
if: ${{ always() && needs.resolve_request.outputs.request_source == 'issue_comment' && steps.publish_evidence.outcome != 'success' }}
1238+
if: ${{ always() && needs.resolve_request.outputs.pr_number != '' && steps.publish_evidence.outcome != 'success' }}
12421239
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
12431240
env:
12441241
TARGET_PR: ${{ needs.resolve_request.outputs.pr_number }}
@@ -1367,7 +1364,8 @@ jobs:
13671364
--manifest "$root/mantis-evidence.json" \
13681365
--target-pr "$TARGET_PR" \
13691366
--artifact-root "mantis/telegram-desktop/pr-${TARGET_PR}/published-${PUBLISH_RUN_ID}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \
1370-
--marker "<!-- mantis-telegram-desktop-proof -->" \
1367+
--marker "<!-- mantis-telegram-desktop-proof:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT} -->" \
1368+
--create-missing false \
13711369
--artifact-url "$PUBLISH_ARTIFACT_URL" \
13721370
--run-url "https://github.com/${GITHUB_REPOSITORY}/actions/runs/${PUBLISH_RUN_ID}" \
13731371
--request-source "$REQUEST_SOURCE"

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ function upsertPrComment({ body, createMissing, marker, prNumber, repo }) {
631631
} catch {
632632
if (!createMissing) {
633633
console.log(
634-
"Skipped stale Mantis QA evidence comment because its status is no longer active.",
634+
`Could not update existing Mantis QA evidence comment ${commentId}; create-missing is false.`,
635635
);
636636
return;
637637
}
@@ -641,9 +641,7 @@ function upsertPrComment({ body, createMissing, marker, prNumber, repo }) {
641641
}
642642
}
643643
if (!createMissing) {
644-
console.log(
645-
"Skipped stale Mantis QA evidence comment because its status is no longer active.",
646-
);
644+
console.log("No existing Mantis QA evidence comment found and create-missing is false.");
647645
return;
648646
}
649647
run("gh", ["pr", "comment", prNumber, "--body-file", bodyFile], { stdio: "inherit" });

‎test/scripts/mantis-telegram-desktop-proof-workflow.test.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,20 @@ describe("Mantis Telegram Desktop proof workflow", () => {
382382
const fallbackComment = resolver?.steps?.find(
383383
(step) => step.name === "Report Mantis start failure with workflow token",
384384
);
385-
expect(startedToken?.if).toContain("request_source == 'issue_comment'");
385+
expect(startedToken?.if).toBe("${{ steps.resolve.outputs.pr_number != '' }}");
386+
expect(startedToken?.if).not.toContain("request_source");
386387
expect(startedToken?.with?.["permission-pull-requests"]).toBe("write");
387388
expect(startedComment?.["continue-on-error"]).toBe(true);
388-
expect(startedComment?.with?.script).toContain("Mantis started this proof.");
389+
expect(startedComment?.with?.script).toContain("👀 Mantis started this proof.");
389390
expect(startedComment?.with?.script).toContain("actions/runs/${process.env.GITHUB_RUN_ID}");
390391
expect(startedComment?.with?.script).toContain("mantis-telegram-desktop-proof:");
391392
expect(startedComment?.with?.script).toContain("GITHUB_RUN_ATTEMPT");
392393
expect(startedComment?.with?.script).toContain("issues.createComment");
393394
expect(startedComment?.with?.script).toContain("issues.deleteComment");
394395
expect(fallbackComment?.if).toContain("steps.mantis_status_token.outcome != 'success'");
395396
expect(fallbackComment?.if).toContain("steps.mantis_status_comment.outcome != 'success'");
397+
expect(fallbackComment?.if).toContain("steps.resolve.outputs.pr_number != ''");
398+
expect(fallbackComment?.if).not.toContain("request_source");
396399
expect(fallbackComment?.with?.["github-token"]).toBe("${{ github.token }}");
397400
expect(fallbackComment?.["continue-on-error"]).toBeUndefined();
398401
expect(fallbackComment?.with?.script).toContain("mantis-telegram-desktop-proof");
@@ -406,7 +409,8 @@ describe("Mantis Telegram Desktop proof workflow", () => {
406409
const failureComment = proofSteps.find((step) => step.name === "Report failed Mantis proof");
407410
expect(evidenceComment?.id).toBe("publish_evidence");
408411
expect(failureComment?.if).toContain("always()");
409-
expect(failureComment?.if).toContain("request_source == 'issue_comment'");
412+
expect(failureComment?.if).toContain("needs.resolve_request.outputs.pr_number != ''");
413+
expect(failureComment?.if).not.toContain("request_source");
410414
expect(failureComment?.if).toContain("steps.publish_evidence.outcome != 'success'");
411415
expect(failureComment?.with?.script).toContain("Mantis could not complete this proof.");
412416
expect(failureComment?.with?.script).toContain("issues.updateComment");
@@ -454,6 +458,15 @@ describe("Mantis Telegram Desktop proof workflow", () => {
454458
expect(workflowText).toContain(
455459
"PUBLISH_ARTIFACT_URL=https://github.com/${GITHUB_REPOSITORY}/actions/runs/",
456460
);
461+
const evidenceComment = jobStep(
462+
WORKFLOW,
463+
"publish_existing_telegram_desktop_proof",
464+
"Comment PR with inline QA evidence",
465+
);
466+
expect(evidenceComment.run).toContain(
467+
"mantis-telegram-desktop-proof:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}",
468+
);
469+
expect(evidenceComment.run).toContain("--create-missing false");
457470
});
458471

459472
it("limits evidence publishers to comment and PR-read permissions", () => {

0 commit comments

Comments
 (0)