Skip to content

fix: recover reviewed issue fixes without enabling merge - #982

Merged
steipete merged 3 commits into
mainfrom
codex/clawsweeper-stale-issue-job-recovery
Jul 31, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/clawsweeper-stale-issue-job-recovery

Conversation

@steipete

@steipete steipete commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Accept every authenticated, review-created issue implementation trigger instead of accidentally trusting only review_viable_issue; this unblocks strict reproducible OpenClaw bug fixes without weakening the existing branch, issue identity, source revision, action, or owner guards.
  • Recover completed issue workers that produced no PR with a two-minute retry delay, a maximum of three attempts per queued-review revision, paginated workflow history, dispatch-generation fencing, live-worker deduplication, freshness-verified priority and regeneration for newer authoritative reviews, and delayed deduplication/rechecks while an implementation PR exists.
  • Explicitly force CLAWSWEEPER_ALLOW_MERGE=0 for generated issue jobs in both the planner and executor while preserving separately authorized maintainer automerge lanes.
  • Preserve the standalone, offline pnpm run local-review feature and protect its package command with an explicit regression test.
  • Hydrate only the changed base/head Git blobs before a restricted PR review, so blobless target checkouts remain fully inspectable when Codex has no network.

Production root cause and runtime proof

Real affected issue: openclaw/openclaw#98276

Failed autonomous worker: https://github.com/openclaw/clawsweeper/actions/runs/30654950729

The actual durable job was authenticated, bug-only, and explicitly blocked close and merge, but carried trigger_source: review_reproducible_bug. The executor only recognized review_viable_issue, so it treated this reviewed issue job as untrusted and rejected its focused three-file fix because the planner described five affected behaviors:

likely_files:
  - .github/workflows/ci.yml
  - scripts/dist-runtime-build-artifact.mjs
  - test/scripts/ci-workflow-guards.test.ts
old decision: fix artifact is too broad for autonomous execution
new decision: approved for bounded execution

The live durable intake audit separately reported worker_dispatched: true indefinitely after completed workers produced no PR. The same audit also contained a stale job_report_revision_sha256, so retrying the old job unchanged would replay an outdated review. The current-head runtime proof loads the real production job, its real downloaded planner artifact, the real production intake audit, and live worker history; it proves all of the following:

{
  "reviewTrigger": "review_reproducible_bug",
  "affectedSurfaces": 5,
  "previousDecision": "fix artifact is too broad for autonomous execution; split into narrower jobs or explicitly set CLAWSWEEPER_ALLOW_BROAD_FIX_ARTIFACTS=1",
  "currentDecision": "approved for bounded execution",
  "liveCompletedWorkerRecovered": true,
  "staleCompletedJobRefreshed": true,
  "workerRetryAttemptsMaximum": 3,
  "generatedIssueMergeAllowed": false,
  "issueExecutionModel": "gpt-5.6-sol",
  "issueExecutionReasoningEffort": "xhigh"
}

The old and new scope decisions are generated by the actual production-parent and changed validateAutonomousFixScope functions against the exact same real job and planner artifact. Recovery queries the real current Actions workflow history. Merge proof checks the actual issue-job frontmatter plus the actual parsed planner and executor workflow expressions.

Previously blocked self-review: real partial-clone proof

The previous review correctly reported that its restricted sandbox could not inspect current-head blobs: the exact-review checkout is a --filter=blob:none partial clone, the reviewer fetched only the PR commit/tree, and Codex had no DNS to lazily fetch the changed objects. This PR fixes that root cause in a separate focused module: before the restricted review, it validates at most 80 Git paths, inspects only their base/head tree entries, discovers missing blob sizes in one read-only GitHub GraphQL metadata request, enforces a strict 4 MiB aggregate blob budget, and retrieves every permitted missing object in one Git fetch. It never checks out PR content, changes working-tree files, weakens the sandbox, forwards write credentials, downloads oversized contributor blobs, or runs for offline --local-range review.

The real behavior regression creates a genuine local filtered/promisor clone, proves two PR blobs do not exist with GIT_NO_LAZY_FETCH=1, fetches the PR head with --filter=blob:none, calls the actual current-head hydration helper, then changes the origin to https://invalid.invalid/offline.git and proves git show <head>:added.txt, git show <head>:changed.txt, and git diff <base> <head> -- changed.txt all succeed completely offline. A Git trace proves 12 missing files cause exactly one fetch, not 12. Separate genuine promisor-clone tests prove 5 MiB objects and aggregate 3 MiB + 2 MiB objects are never downloaded while a neighboring small source file remains inspectable. The base working tree remains clean. Traversal, absolute, .git, backslash, control-character, gitlink, literal-pathspec, and >80-file cases are safely handled.

{
  "actualFilteredPromisorClone": true,
  "headObjectsMissingBeforeHydration": [true, true],
  "boundedObjectsHydrated": 6,
  "metadataRequestsForTwelveMissingFiles": 1,
  "networkFetchesForTwelveMissingFiles": 1,
  "maximumTotalBlobBytes": 4194304,
  "oversizedBlobDownloaded": false,
  "remoteAfterHydration": "https://invalid.invalid/offline.git",
  "headFileInspectionWithoutNetwork": "new implementation",
  "baseToHeadDiffWithoutNetwork": "+after",
  "workingTreeModified": false,
  "offlineLocalReviewStillAvailable": true
}

Deterministic token boundary and existing-worker recovery

CLAWSWEEPER_ISSUE_IMPLEMENTATION_WORKFLOW_TOKEN is the existing central ClawSweeper dispatch installation token, with actions: write for openclaw/clawsweeper; it is not a target-repository mutation token and is not exposed to Codex or repair execution. It exists only in the deterministic issue-intake prepare step, where workflow-history discovery explicitly overrides its local GH_TOKEN for authenticated central Actions reads:

const workflowToken = process.env.CLAWSWEEPER_ISSUE_IMPLEMENTATION_WORKFLOW_TOKEN;
const env = workflowToken ? { ...process.env, GH_TOKEN: workflowToken } : undefined;
const readPage = fetchPage ?? ((args) => ghJsonWithRetry(args, env ? { env } : {}));

The existing dispatch step already uses that installation token independently. When dispatch finds an active worker instead of launching a duplicate, it exports that worker's actual immutable createdAt through the GitHub Actions step-output file; the separate deterministic mark-dispatched step records this exact original timestamp. Recovery then queries created>=<actual worker createdAt>, paginates all matching workflow runs, rejects active workers and historical completed workers, and tests completed deduplicated workers through the actual filtered history path. Invalid/blank legacy timestamps fall back to the durable preparation time. If the worker successfully opens an implementation PR, the unchanged issue is suppressed for 30 minutes rather than consuming capacity on every sweep; its live PR state is then rechecked so closing an unresolved PR allows the still-open issue to resume. A genuinely newer authoritative review can still safely reopen work immediately.

- name: Dispatch repair worker
  id: dispatch-worker
  env:
    GH_TOKEN: ${{ steps.dispatch-token.outputs.token }}

- name: Record successful repair worker dispatch
  env:
    WORKER_CREATED_AT: ${{ steps.dispatch-worker.outputs.issue_worker_created_at || '' }}
  run: pnpm run repair:issue-implementation-intake -- mark-dispatched --worker-created-at "$WORKER_CREATED_AT"

An isolated end-to-end intake replay creates a durable issue job tied to an older review with three exhausted attempts and a retry deadline 30 minutes in the future, supplies one completed real-shape worker plus a fresh competing issue, and executes the actual dist/repair/issue-implementation-intake.js prepare entrypoint against a deterministic GitHub API fixture. A stale runner snapshot is rejected before it can downgrade either dispatched or undispatched durable jobs; shared review/item timestamps are compared only when present on both records, so incomplete legacy audit metadata cannot misclassify older records. The genuinely newer authoritative review is selected first; an explicitly referenced open competing PR receives a delayed 30-minute recheck; closing that PR and advancing its retry timer regenerates the old completed job immediately, advances its durable review revision, and resets its attempt count to zero. Audit records retain authoritative review/item freshness for subsequent comparisons. Active queued/in-progress workers continue to block duplicate dispatch; same-review retry timers and attempt caps remain enforced.

No dispatch token is added to the repair-cluster-worker.yml Codex process. Generated issue jobs force CLAWSWEEPER_ALLOW_MERGE=0 in both cluster and execute jobs, retain gpt-5.6-sol + xhigh, and require human merge. Existing separately authorized non-issue maintainer merge lanes are unchanged.

Validation

  • pnpm run build:all
  • pnpm run check:static
  • pnpm run lint
  • node --test test/review-blob-hydration.test.ts test/local-review.test.ts test/local-range-review.test.ts test/repair/issue-worker-recovery.test.ts test/repair/execute-fix-validation.test.ts test/repair/issue-implementation-intake.test.ts test/repair/cluster-workflow-security.test.ts test/repair/gitcrawl-store.test.ts test/repair/issue-implementation-dispatch.test.ts test/repair/post-flight.test.ts — 107 passed, 0 failed, including genuine filtered-clone integration, one-fetch Git traces, 4 MiB budget enforcement, terminal completed-PR deduplication, deterministic dispatch timestamps, actual CLI preparation of newer exhausted-worker reviews, and offline local review.
  • Real production replay against https://github.com/openclaw/clawsweeper/actions/runs/30654950729 and the live issue-intake audit.
  • Existing safety coverage still rejects unknown issue triggers, missing issue provenance, branch mismatches, broad untrusted artifacts, duplicate active workers, premature retries, and exhausted same-review retry budgets; a newer authoritative review safely starts a fresh bounded attempt cycle.
  • Pre-commit and committed-branch Codex review findings were accepted and fixed: retry caps compare against the durable job's review revision, worker history paginates beyond the configured worker ceiling, deduplicated workers durably retain their real original creation timestamp, directly referenced and discovered competing PRs receive delayed rechecks rather than permanently suppressing unresolved issues, blank legacy timestamps fence out old historical runs, verified newer reviews outrank fresh issues while stale or partially timestamped snapshots cannot downgrade dispatched or undispatched work, and offline partial-clone review now uses one bounded metadata query plus one byte-capped Git fetch.
  • The package still exposes pnpm run local-review; committed-range local review remains offline, rejects dirty checkouts, scrubs GitHub credentials, and disables web search.
  • Required fresh Codex review before commit and another fresh review against main before landing.

Generated OpenClaw issue PRs are create-only and require manual merge. This change does not disable or otherwise alter the separately authorized maintainer/service automerge lanes.

@steipete
steipete requested a review from a team as a code owner July 31, 2026 18:59
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 4:58 PM ET / 20:58 UTC.

ClawSweeper review

What this changes

The PR accepts all authoritative reviewed-issue triggers, recovers completed repair workers that produced no PR, prevents generated issue jobs from inheriting merge permission, and hydrates bounded Git blobs for restricted PR reviews.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This PR remains necessary: current main generates the review_reproducible_bug trigger but accepts only review_viable_issue at the autonomous execution trust boundary, matching the reported rejected repair path. The proposed repair is focused on restoring reviewed issue recovery while preserving manual merge control; no discrete current-head patch defect is established from the available evidence.

Priority: P2
Reviewed head: fbb0402d8eae7019602d893e8553cfb2d5560a81

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The source-backed root cause and unusually detailed runtime proof make this a strong repair, with shared automation and authorization boundaries still warranting maintainer review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies detailed after-fix production replay evidence plus genuine filtered-promisor-clone output that directly exercises worker recovery, no-merge behavior, and offline blob inspection.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies detailed after-fix production replay evidence plus genuine filtered-promisor-clone output that directly exercises worker recovery, no-merge behavior, and offline blob inspection.
Evidence reviewed 5 items Current-main trigger mismatch: The trusted issue-implementation check permits only review_viable_issue, although the repair lane defines separate authoritative trigger constants including review_reproducible_bug and review_vision_fit.
Current-main merge inheritance: Both cluster and execute jobs currently derive CLAWSWEEPER_ALLOW_MERGE from the general merge gate without an issue-job-specific override, so the PR's explicit generated-issue restriction addresses a real boundary.
Origin and ownership provenance: Blame attributes the existing single-trigger trust condition to the original repair-backlog implementation, and recent history shows the same area was subsequently extended by the automatic OpenClaw bug-repair work.
Findings None None.
Security None None.

How this fits together

ClawSweeper converts authoritative issue reviews into durable repair jobs and dispatches GitHub Actions workers that may create a repair PR but require separately authorized merging. Restricted PR reviews consume changed-file metadata and Git objects, so missing blobs in a partial clone can prevent the reviewer from inspecting the proposed patch.

flowchart LR
  A[Authoritative issue review] --> B[Durable repair job]
  B --> C[Worker dispatch and recovery]
  C --> D[Generated repair PR]
  D --> E[Human-controlled merge]
  F[Changed PR paths] --> G[Bounded blob hydration]
  G --> H[Restricted Codex review]
Loading

Before merge

  • Resolve merge risk (P1) - Because this changes shared durable-job retry, deduplication, and dispatch behavior, an error in the current-head fencing could either leave valid repairs queued indefinitely or dispatch duplicate workers.
  • Resolve merge risk (P1) - Generated issue jobs must not inherit a merge gate; maintainers should confirm both the cluster and execute workflow expressions keep CLAWSWEEPER_ALLOW_MERGE=0 for every issue inbox path before merge.
  • Complete next step (P2) - The implementation is an open shared-workflow repair with no discrete automatic fix to hand off; the next action is maintainer review of its current-head authorization and retry boundaries.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 14 files affected; 1,701 additions and 25 deletions The patch spans shared repair intake, recovery, dispatch, workflow gating, and restricted-review data access.
Workflow boundary 2 GitHub Actions workflows changed Both worker execution and issue-intake workflow paths participate in the generated-job merge and dispatch boundary.

Merge-risk options

Maintainer options:

  1. Verify the bounded recovery path (recommended)
    Run the focused current-head worker-recovery, dispatch, workflow-security, and blob-hydration checks before merge.
  2. Pause for workflow-boundary audit
    Keep the PR open if maintainers cannot independently confirm that the workflow token stays read-only for history lookup and issue jobs cannot inherit merge permission.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run the focused worker-recovery, dispatch, workflow-security, and bounded blob-hydration checks on the current head; refresh runtime proof if behavior differs.

Technical review

Best possible solution:

Land the narrow repair only after focused current-head validation confirms authoritative reviewed triggers remain provenance-checked, completed workers retry within the bounded policy, and generated issue jobs can create repair PRs without ever enabling merge.

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

Yes. Current main defines review_reproducible_bug as an authoritative issue-review trigger but rejects that trigger in the broad autonomous issue-implementation trust check, giving a high-confidence source reproduction of the central failure.

Is this the best way to solve the issue?

Yes. Expanding acceptance only to the existing authoritative review-trigger constants while preserving repository, issue, source-revision, branch, and allowed-action checks is a narrower solution than weakening the general autonomous execution guard.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 16f01b295086.

Labels

Label justifications:

  • P2: This is a bounded repair-automation reliability and safety issue with meaningful operational impact but no evidence of an emergency outage.
  • merge-risk: 🚨 automation: The patch changes repair-job intake, retry timing, deduplication, and GitHub Actions dispatch behavior.
  • merge-risk: 🚨 security-boundary: The patch changes generated-job merge gating and uses a dedicated token for central Actions-history reads.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies detailed after-fix production replay evidence plus genuine filtered-promisor-clone output that directly exercises worker recovery, no-merge behavior, and offline blob inspection.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies detailed after-fix production replay evidence plus genuine filtered-promisor-clone output that directly exercises worker recovery, no-merge behavior, and offline blob inspection.

Evidence

What I checked:

  • Current-main trigger mismatch: The trusted issue-implementation check permits only review_viable_issue, although the repair lane defines separate authoritative trigger constants including review_reproducible_bug and review_vision_fit. (src/repair/execute-fix-validation.ts:175, 16f01b295086)
  • Current-main merge inheritance: Both cluster and execute jobs currently derive CLAWSWEEPER_ALLOW_MERGE from the general merge gate without an issue-job-specific override, so the PR's explicit generated-issue restriction addresses a real boundary. (.github/workflows/repair-cluster-worker.yml:189, 16f01b295086)
  • Origin and ownership provenance: Blame attributes the existing single-trigger trust condition to the original repair-backlog implementation, and recent history shows the same area was subsequently extended by the automatic OpenClaw bug-repair work. (src/repair/execute-fix-validation.ts:175, eaeed67dc5fc)
  • Current PR provenance: The head commit follows the prior completed ClawSweeper review and is based directly on current main, so this is a fresh review cycle rather than an obsolete branch. (fbb0402d8eae)
  • Review-environment limitation: The checked-out partial clone contains the PR commit metadata, but attempting to read unhydrated PR diff objects triggered a promisor fetch that failed because this sandbox could not resolve the GitHub remote. The patch-level assessment therefore uses the supplied PR diff and runtime proof together with accessible current-main source and history. (fbb0402d8eae)

Likely related people:

  • steipete: The accessible blame identifies Peter Steinberger as author of the reviewed-issue trust boundary, recent main commits continue the automatic repair lane, and the supplied PR metadata maps the current repair to steipete. (role: original implementation author and recent area contributor; confidence: high; commits: eaeed67dc5fc, 3d2a878f6e2a, 16f01b295086; files: src/repair/execute-fix-validation.ts, src/repair/issue-implementation-intake.ts, .github/workflows/repair-cluster-worker.yml)

Rank-up moves

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

  • Confirm the exact current-head workflow expressions and bounded recovery tests before merge.

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 (2 earlier review cycles)
  • reviewed 2026-07-31T19:04:35.499Z sha 4501244 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T19:23:54.191Z sha 2817b60 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit ec2f84c into main Jul 31, 2026
12 checks passed
@steipete
steipete deleted the codex/clawsweeper-stale-issue-job-recovery branch July 31, 2026 21:01
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
* fix: recover reviewed issue fixes without enabling merge

* fix: hydrate restricted review blobs and recover deduplicated issue workers

* fix: harden bounded review hydration and issue retry recovery

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant