Skip to content

fix(ledger): publish successful shard artifacts after workflow reruns - #1061

Merged
steipete merged 1 commit into
mainfrom
codex/fix-rerun-ledger-publish
Aug 7, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-rerun-ledger-publish

Conversation

@steipete

@steipete steipete commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where rerunning a partially failed ClawSweeper sweep could leave completed reviews unpublished. GitHub retains successful review-shard artifacts from the first attempt, but the attempt-2 publisher required every shard to claim run_attempt=2; it rejected the valid retained attempt-1 ledger before publication.

This was observed in run 31223072940 attempt 2, where the publisher reported expected 2, got 1 even though the review shard for openclaw/openclaw#120368 had completed and uploaded its review artifact.

Why This Change Was Made

The ledger importer remains exact by default. It now also supports an explicit positive maximum-attempt provenance constraint, and only the sweep publisher's downloaded review-artifact handoff uses it. Repository, commit SHA, workflow, producer job, and workflow run ID must still match exactly; malformed constraints and artifacts from later attempts fail closed.

The sibling GitHub-read amplification exposed by the same incident was independently repaired and landed in #1060. This PR is based on that commit and owns only the retained-artifact provenance defect.

User Impact

Operators can rerun failed sweep jobs without losing successful reviews from earlier attempts of the same immutable workflow run. Exact command-manifest imports, current-job imports, and all other ledger provenance checks retain their previous strict behavior.

OpenClaw Bay is unaffected: this changes ledger import admission and one workflow caller, not dashboard or status data contracts.

Evidence

  • Source failure: run 31223072940 attempt 2 / publisher job 93015214709 rejected attempt 1 against attempt 2, then the apply path exhausted GitHub App quota before replacing the placeholder.
  • Focused regression: exact attempt 2 still rejects an attempt-1 shard; explicit maximum attempt 2 imports it; attempt 3 and malformed bounds are rejected.
  • Focused commands passed on Node v24.19.0: all builds, the two ledger provenance tests, the two CLI validation tests, and the workflow provenance assertion.
  • git diff --check origin/main...HEAD passed.
  • Pre-commit dirty autoreview passed with no actionable findings (0.96 confidence).
  • Committed branch autoreview against origin/main passed with no actionable findings (0.99 confidence).
  • pnpm run check passed formatting, all three builds, all lint lanes, the changed coverage gate, and the changed ledger/workflow tests. Its full-suite tail hit seven unrelated test/repair/target-validation.test.ts fixture failures because their isolated package mirrors could not resolve pinned [email protected]; exact-head hosted CI is the authoritative follow-up for that environment-only gap.

Production LOC: +46/-5 (net +41) | Tests: +90/-0. The production growth introduces the explicit bounded provenance contract, validates it fail-closed at the CLI/runtime boundary, and binds the sole retry-aware workflow consumer to it.

Real Behavior Proof

  • Claim: an attempt-2 publisher can import a retained successful attempt-1 review ledger from the same immutable workflow run without weakening exact provenance elsewhere.
  • Exercised surface: a fresh PR checkout of current head, the built dist/clawsweeper.js publish-action-events command, and the real action-ledger shard writer/importer inside Docker-backed Crabbox.
  • Scenario: a temporary Node 24 fixture generated a canonical review-completed shard with run ID 31223072940, producer job review, and attempt 1. The built publisher then ran as job publish, attempt 2, first in exact mode and then with the new maximum-attempt constraint.
  • Command and environment: local-container Crabbox cbx_a2bd315ceba0 (pearl-lobster), image node:24-bookworm, Node v24.19.0, fresh PR checkout at 0e1dc0fe7fa9c0afaaf7379979061a27fa90fe9c; no credentials or hydration. The uploaded proof script installed the frozen lockfile, built all TypeScript surfaces, ran the built CLI scenario, and ran the focused runtime/workflow tests.
  • Observed result: exit 0 in 14.846 seconds total. Exact mode rejected attempt 1 against attempt 2; bounded mode created one shard; attempt 3 was rejected against maximum attempt 2. The two runtime provenance tests and workflow provenance assertion passed 3/3.
  • Artifact or trace: the redacted stdout trace was:
{
  "schema": "clawsweeper.rerun-ledger-proof",
  "schema_version": 1,
  "head": "0e1dc0fe7fa9c0afaaf7379979061a27fa90fe9c",
  "immutable_identity": {
    "repository": "openclaw/clawsweeper",
    "sha": "0e1dc0fe7fa9c0afaaf7379979061a27fa90fe9c",
    "workflow": "sweep.yml",
    "job": "review",
    "run_id": "31223072940"
  },
  "retained_attempt": {
    "producer_run_attempt": 1,
    "publisher_run_attempt": 2,
    "exact_mode": "rejected: expected 2, got 1",
    "bounded_mode": "accepted",
    "created_shards": 1
  },
  "future_attempt": {
    "producer_run_attempt": 3,
    "publisher_max_run_attempt": 2,
    "bounded_mode": "rejected: expected at most 2, got 3"
  }
}
  • Cleanup: the lease reported leaseStopped: true; no container remains.
  • Limits: this is a current-head Docker-backed built-CLI proof, not a deployed Actions rerun. The live canary is a safe retry/backfill after merge.

Root Cause and Provenance

The authenticated importer compared every producer field for exact equality. That is correct for ordinary and manifest-bound imports, but the sweep publisher is a retry collector: GitHub reruns preserve successful artifacts from prior attempts under the same immutable run ID. The publisher supplied its current attempt as though it were the producer attempt, conflating collector generation with artifact generation.

The exact-attempt validation was introduced in 7ecb1fdc631ed17f9a9a20ae010ee1e087e3693c as part of #521. Blame identifies @vincentkoc as code author and #521 merger; the defect became observable in the August 7 rerun above.

Best-Fix Assessment

Best-fix verdict: best owner-boundary repair. The importer owns provenance semantics, while the workflow caller owns whether it is an exact producer handoff or a retry collector.

Alternatives considered: removing the attempt check would weaken all imports and was rejected; rewriting downloaded shards to the collector attempt would forge provenance and was rejected; rerunning every successful review shard would waste model work and still encode the wrong artifact-ownership contract.

Remaining uncertainty: no post-merge deployed rerun has exercised the new workflow source yet. The safe canary/backfill is tracked as the landing follow-up.

@steipete
steipete requested a review from a team as a code owner August 7, 2026 23:16
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 7:33 PM ET / 23:33 UTC.

ClawSweeper review

What this changes

The PR permits the sweep publisher to import successful review-ledger artifacts retained from earlier attempts of the same workflow run while keeping all other producer identity checks strict.

Regression provenance

Possible regression — probable (reproduction; reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still uses exact attempt matching, while the proposed bounded retry-only admission preserves the other immutable provenance checks. No actionable patch finding was identified.

Priority: P2
Reviewed head: 0e1dc0fe7fa9c0afaaf7379979061a27fa90fe9c

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The narrowly scoped repair has strong current-head behavioral proof and preserves strict provenance outside the retry collector.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body contains a redacted current-head Docker-backed built-CLI trace showing exact rejection, bounded acceptance, future-attempt rejection, focused tests, and lease cleanup.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body contains a redacted current-head Docker-backed built-CLI trace showing exact rejection, bounded acceptance, future-attempt rejection, focused tests, and lease cleanup.
Evidence reviewed 6 items Bounded provenance implementation: The importer requires exactly one positive attempt constraint, retains exact repository/SHA/workflow/job/run-ID matching, and accepts a shard only when its attempt is no greater than the explicit bound.
Retry-only workflow use: Only the downloaded review-artifact import supplies the maximum-attempt flag; the publisher's own ledger import continues to use its exact default attempt.
Focused regression coverage: Coverage proves exact rejection of a retained earlier shard, bounded acceptance, rejection of a later shard, and rejection of malformed constraints.
Findings None None.
Security None None.

How this fits together

Review shards emit authenticated ledger artifacts during a sweep workflow. The publisher imports those artifacts before publishing durable review results, including when GitHub Actions reruns retain successful earlier shards.

flowchart LR
  A[Review shards] --> B[Immutable ledger artifacts]
  B --> C[Actions rerun]
  C --> D[Publisher provenance gate]
  D --> E[Durable review results]
Loading

Before merge

  • Resolve merge risk (P1) - A deployed GitHub Actions rerun has not yet exercised the new workflow source; the supplied current-head container proof does not replace a post-merge canary.
  • Complete next step (P2) - No repair lane is needed because the PR has no actionable finding and has sufficient real-behavior proof.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +46/-5, tests +90/-0 The bounded provenance contract is accompanied by focused runtime, CLI, and workflow coverage.
Retry-aware callers 1 workflow importer changed Only the retained review-artifact handoff opts into prior-attempt acceptance.

Root-cause cluster

Relationship: canonical
Canonical: #1061
Summary: This PR is the canonical fix for retained-artifact provenance on reruns; the merged rate-limit repair is adjacent but distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Merge with bounded retry admission (recommended)
    Accept the narrowly scoped retry rule and observe a safe rerun canary after merge.
  2. Pause for pre-merge deployed proof
    Hold the PR until maintainers can exercise an actual Actions rerun before landing.

Technical review

Best possible solution:

Keep the strict immutable identity checks, merge the bounded exception only for retained review artifacts, and verify one safe sweep rerun or backfill after landing.

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

Yes: current-main source establishes the exact-attempt rejection path, and the supplied current-head built-CLI proof recreates retained-attempt rejection, bounded acceptance, and later-attempt rejection.

Is this the best way to solve the issue?

Yes: preserving immutable producer identity and granting the upper-bound exception only to the retry collector is narrower and safer than weakening every importer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5bfa2d9f256d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains a redacted current-head Docker-backed built-CLI trace showing exact rejection, bounded acceptance, future-attempt rejection, focused tests, and lease cleanup.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body contains a redacted current-head Docker-backed built-CLI trace showing exact rejection, bounded acceptance, future-attempt rejection, focused tests, and lease cleanup.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: The repair addresses a bounded but real failure to publish completed sweep reviews after a rerun.
  • merge-risk: 🚨 automation: The patch changes the sweep publisher's GitHub Actions artifact-import behavior.
  • merge-risk: 🚨 security-boundary: The authenticated artifact-admission condition is broadened for one workflow caller.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body contains a redacted current-head Docker-backed built-CLI trace showing exact rejection, bounded acceptance, future-attempt rejection, focused tests, and lease cleanup.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains a redacted current-head Docker-backed built-CLI trace showing exact rejection, bounded acceptance, future-attempt rejection, focused tests, and lease cleanup.

Evidence

What I checked:

  • Bounded provenance implementation: The importer requires exactly one positive attempt constraint, retains exact repository/SHA/workflow/job/run-ID matching, and accepts a shard only when its attempt is no greater than the explicit bound. (src/action-ledger-runtime.ts:1116, 0e1dc0fe7fa9)
  • Retry-only workflow use: Only the downloaded review-artifact import supplies the maximum-attempt flag; the publisher's own ledger import continues to use its exact default attempt. (.github/workflows/sweep.yml:4470, 0e1dc0fe7fa9)
  • Focused regression coverage: Coverage proves exact rejection of a retained earlier shard, bounded acceptance, rejection of a later shard, and rejection of malformed constraints. (test/action-ledger-runtime.test.ts:3937, 0e1dc0fe7fa9)
  • Current-main provenance: The PR head has current main as its parent and is not an ancestor of main, so the fix is not already implemented on main or in release v0.3.0. (src/action-ledger-runtime.ts:1116, 0e1dc0fe7fa9)
  • Feature-history routing: Blame shows the original producer-validation function on current main dates to commit 559a796; the prior ledger-hardening history includes commit 7ecb1fd. (src/action-ledger-runtime.ts:1112, 559a7969d173)
  • Current-head behavior proof: The PR body provides a redacted Docker-backed Crabbox built-CLI trace at the stated head: exact mode rejects attempt 1 against 2, bounded mode imports it, and attempt 3 is rejected against bound 2. (0e1dc0fe7fa9)

Likely related people:

  • Martin Cleary: Current-main blame attributes the producer-validation function to this contributor's commit. (role: recent runtime contributor; confidence: high; commits: 559a7969d173; files: src/action-ledger-runtime.ts)
  • vincentkoc: The prior exact-receipt hardening commit is part of the action-ledger provenance history relevant to this boundary. (role: original ledger contributor; confidence: medium; commits: 7ecb1fdc631e; files: src/action-ledger-runtime.ts)

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-07T23:20:38.679Z sha 0e1dc0f :: needs real behavior proof before merge. :: none

@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes the requested redacted current-head Docker-backed Crabbox trace from lease cbx_a2bd315ceba0, covering retained attempt-1 acceptance at publisher attempt 2, exact-mode rejection, future-attempt rejection, immutable producer identity, focused tests, and cleanup.

@clawsweeper

clawsweeper Bot commented Aug 7, 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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 7, 2026
@steipete
steipete merged commit d7f1836 into main Aug 7, 2026
31 checks passed
@steipete
steipete deleted the codex/fix-rerun-ledger-publish branch August 7, 2026 23:36
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: 🦞 diamond lobster Very strong PR readiness with only minor 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