Skip to content

fix(mantis): prove the PR merge commit instead of the raw head - #127961

Merged
obviyus merged 1 commit into
mainfrom
t3code/mantis-merge-candidate
Aug 22, 2026
Merged

obviyus merged 1 commit into
mainfrom
t3code/mantis-merge-candidate

Conversation

@obviyus

@obviyus obviyus commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Mantis Telegram Desktop Proof proved the raw PR head (pr.head.sha) against its merge base. A PR whose head is behind main was therefore proved on a tree that lacks fixes already landed on main, and failed for reasons unrelated to the PR. Observed today on #127770 (head 6544389d, 59 commits behind main): its pdf-tool lane dies on the static-runtime Unknown model defect that #127952 already fixed on main — the proof could not say anything about the PR itself.

A first iteration used GitHub's PR test merge (pr.merge_commit_sha), but live evidence killed it: GitHub's test merge is lazily cached and does not refresh when main advances. #127770's cached merge base was 0978e27f — 50 commits / 12 hours behind main, still missing the pdf fix — and repeated pulls.get calls never refreshed it (verified over ~15 minutes; live run 32581065979 exercised exactly that stale candidate: run 32581065979 came back Overall: blocked with both lanes pinned to the stale pair — baseline 0978e27f, candidate 525b4ac2 — and the pdf tool dying on Unknown model in both, i.e. the proof said nothing about the PR).

Why This Change Was Made

Mantis must prove what would actually land, on today's main. The workflow now builds the candidate itself, deterministically:

  • Resolve: baseline = live refs/heads/main tip; merge base via the compare API; PR must target main (a PR based on a stale topic branch can no longer be labeled "merged onto main" — this also removes the vacuous ancestor check). Fork approval still pins the exact untrusted head (approved_head_sha === pr.head.sha); the local merge only adds the trusted main parent on top of those reviewed bytes.
  • Proof worktrees: depth-1 fetches of main tip, head, and merge base, then git merge-tree --write-tree --merge-base=<mergeBase> <mainTip> <head> + git commit-tree with fixed identity and the baseline committer date, so the candidate SHA is reproducible for the same (main, head) pair. Content conflicts (exit 1) fail with a direct "needs a rebase or merge" message; other git failures propagate as themselves.
  • Deleted: the mergeable polling loop and both stale-cache failure paths, the test-merge two-parents proof, and the baseline-ancestor-of-main compare. No fallback to the raw head — proving a stale tree is the bug.
  • User-visible lane labels and docs/concepts/mantis.md say the candidate is the PR merged onto main — now literally true at dispatch time.

User Impact

Maintainers dispatching Mantis on any open PR get a proof of the PR merged onto the main tip resolved at dispatch, with a direct "rebase needed" message when the PR conflicts. Fork dispatch inputs are unchanged.

Evidence

  • Tests: 49/49 across the three Mantis workflow/evidence suites (node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts test/scripts/mantis-publish-pr-evidence.test.ts).
  • Checks: node scripts/check-changed.mjs over the touched files (format, oxlint, tsgo, workflow guards) green; fresh structured review clean.
  • Determinism: the merge recipe run twice against main tip 963fafbb + feat(pdf): add explicit OpenAI native document opt-in #127770 head 6544389d produced identical candidate SHA 8698bf2b2456ab7049912d289f29c5d582406dab both times.
  • Live proof (this branch, fork PR feat(pdf): add explicit OpenAI native document opt-in #127770, run 32582294668): baseline resolved to the live main tip 963fafbb; candidate was built in CI as 8698bf2b — byte-identical to the SHA predicted by the local determinism check. Neither lane hit Unknown model; the verdict now differentiates on the PR itself (baseline pass via extraction fallback, candidate fail on a malformed-JSON pdf tool response in its native input_file path — a real finding posted on feat(pdf): add explicit OpenAI native document opt-in #127770).

@clawsweeper

clawsweeper Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@obviyus
obviyus marked this pull request as ready for review August 22, 2026 15:13
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: S maintainer Maintainer-authored PR labels Aug 22, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 22, 2026
@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 11:34 AM ET / 15:34 UTC.

ClawSweeper review

What this changes

This PR makes Mantis build and prove a deterministic local merge of an open pull request head onto the live main tip, then labels the evidence accordingly.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The previous P1 blocker is addressed: the workflow now requires a main-targeting PR and constructs a two-parent candidate from the live main tip and reviewed head. No new concrete correctness defect was found, but this protected maintainer workflow needs exact-head CI and a maintainer merge decision.

Priority: P1
Reviewed head: ed843bd2804a513a0a3c3f259ae6cbd717e7f201

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation and regression contract are coherent, with exact-head CI and a production workflow dispatch as the remaining merge confidence check.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-associated workflow PR is exempt from the external-contributor proof gate; its body also records a live deterministic merge recipe, while exact-head workflow validation remains required before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-associated workflow PR is exempt from the external-contributor proof gate; its body also records a live deterministic merge recipe, while exact-head workflow validation remains required before merge.
Evidence reviewed 6 items Current-main behavior: Current main creates the candidate worktree from the raw PR head, so a behind branch can omit main-only fixes.
Candidate construction: The PR resolves immutable main, head, and merge-base SHAs, uses merge-tree with that explicit base, and creates a two-parent candidate before adding the candidate worktree.
Bounded proof handoff: The generated candidate SHA is the candidate ref/SHA handed to the existing Codex Mantis invocation, while the prepared worktree remains root-owned and read-only.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127961-AuRxm6/target$ node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts
node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts
[test] starting test/vitest/vitest.tooling.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127961-AuRxm6/target

 ✓  tooling  test/scripts/mantis-telegram-desktop-proof-workflow.test.ts (31 tests) 486ms

 Test Files  1 passed (1)
      Tests  31 passed (31)
   Start at  15:35:15
   Duration  1.01s (transform 266ms, setup 64ms, import 83ms, tests 486ms, environment 0ms)

[test] passed 1 Vitest shard in 7.03s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127961-AuRxm6/target$ node scripts/run-vitest.mjs test/scripts/mantis-telegram-desktop-proof-workflow.test.ts



































Assertions:

  • PASS expect_output: mantis-telegram-desktop-proof-workflow.test.ts

How this fits together

Mantis is OpenClaw’s PR-proof workflow: it resolves a pull request, prepares baseline and candidate worktrees, runs isolated Telegram proof lanes, and publishes evidence on the PR. This change replaces the raw-head candidate with a synthesized merge candidate so the proof includes current main behavior.

flowchart LR
  A[PR dispatch] --> B[Resolve main tip and PR head]
  B --> C[Find merge base]
  C --> D[Build deterministic merge candidate]
  D --> E[Run isolated proof lanes]
  E --> F[Publish PR evidence]
Loading

Before merge

  • Resolve merge risk (P1) - This changes a secret-bearing proof workflow; exact-head CI and one production Mantis dispatch should confirm that the synthesized candidate still reaches evidence publication correctly.
  • Complete next step (P2) - The protected maintainer workflow and remaining exact-head production validation require maintainer handling, not an automated repair.
Agent review details

Security

None.

PR surface

Tests +61, Docs 0, Config +24, Other 0. Total +85 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 95 34 +61
Docs 1 9 9 0
Config 1 72 48 +24
Generated 0 0 0 0
Other 2 2 2 0
Total 6 178 93 +85

Review metrics

Metric Value Why it matters
Production versus test delta production +24, tests +61, docs 0 net The workflow growth implements the merge-candidate boundary; focused tests add contract coverage for the new revision construction.

Merge-risk options

Maintainer options:

  1. Validate the production proof path (recommended)
    Require exact-head workflow checks and one Mantis dispatch that publishes evidence for the synthesized candidate before merge.

Technical review

Best possible solution:

Keep one canonical candidate recipe: resolve the dispatch-time main tip, merge it with the exact reviewed head, prove that immutable result, and publish its SHA as the candidate evidence.

Do we have a high-confidence way to reproduce the issue?

Yes, by source: current main makes the candidate worktree directly from the raw PR-head SHA, while the changed workflow constructs a merge candidate from live main and that head. The focused workflow test names and protects that distinction.

Is this the best way to solve the issue?

Yes. Building the merge candidate locally from immutable main, head, and merge-base revisions avoids reliance on GitHub’s stale test-merge cache while retaining the reviewed head as a parent.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 963fafbb1652.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated workflow PR is exempt from the external-contributor proof gate; its body also records a live deterministic merge recipe, while exact-head workflow validation remains required before merge.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Incorrect proof candidates can make active PR evidence fail for unrelated main-only defects or misrepresent what would land.
  • merge-risk: 🚨 automation: The PR changes CI workflow revision resolution, worktree construction, and publication inputs in the Mantis proof pipeline.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated workflow PR is exempt from the external-contributor proof gate; its body also records a live deterministic merge recipe, while exact-head workflow validation remains required before merge.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Authored the current change and multiple immediately preceding merged Mantis workflow, proof-build, lease, and evidence changes. (role: recent Mantis workflow contributor; confidence: high; commits: ed843bd2804a, da0cb592ddbe, 10c774cf38eb; files: .github/workflows/mantis-telegram-desktop-proof.yml, test/scripts/mantis-telegram-desktop-proof-workflow.test.ts)
  • Peter Steinberger: History shows earlier Mantis candidate-isolation and harness-hardening commits on the same workflow. (role: earlier Mantis isolation and hardening contributor; confidence: medium; commits: 1695854877ff, 45bad50e2690, ff10db092be5; files: .github/workflows/mantis-telegram-desktop-proof.yml)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run the exact-head workflow checks and dispatch Mantis once against a behind-main PR; post only redacted evidence.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-22T15:20:32.909Z sha 1446a61daf16598e641b24f174c48bd5a1e50824 :: found issues before merge. :: [P1] Bind the test merge to the PR's current main base

… head

The Telegram Desktop proof previously built the candidate from the raw PR
head, so a head behind main failed for reasons main already fixed
(observed on #127770: 59 commits behind, hitting the Unknown-model defect
fixed by #127952). GitHub's cached PR test merge cannot be the candidate
either: it was observed 50 commits / 12 hours stale and never refreshed.

The workflow now resolves the live refs/heads/main tip and merge base at
dispatch, requires a main-targeting PR, and builds a deterministic local
merge (merge-tree --merge-base + commit-tree with pinned identity/date) as
the candidate; conflicts fail with a direct rebase message and there is no
fallback to the raw head. Lane labels and docs now say the candidate is
the PR merged onto main.
@obviyus
obviyus force-pushed the t3code/mantis-merge-candidate branch from 1446a61 to ed843bd Compare August 22, 2026 15:29
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 22, 2026
@obviyus
obviyus merged commit 6917a15 into main Aug 22, 2026
165 of 169 checks passed
@obviyus
obviyus deleted the t3code/mantis-merge-candidate branch August 22, 2026 15:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 23, 2026
… head (openclaw#127961)

The Telegram Desktop proof previously built the candidate from the raw PR
head, so a head behind main failed for reasons main already fixed
(observed on openclaw#127770: 59 commits behind, hitting the Unknown-model defect
fixed by openclaw#127952). GitHub's cached PR test merge cannot be the candidate
either: it was observed 50 commits / 12 hours stale and never refreshed.

The workflow now resolves the live refs/heads/main tip and merge base at
dispatch, requires a main-targeting PR, and builds a deterministic local
merge (merge-tree --merge-base + commit-tree with pinned identity/date) as
the candidate; conflicts fail with a direct rebase message and there is no
fallback to the raw head. Lane labels and docs now say the candidate is
the PR merged onto main.

This branch had an error being deployed

1 failed deployment
qa-live-shared — ed843bd2 Deployed Aug 22, 2026 by obviyus via Run agentic native Telegram proof #493394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant