Skip to content

fix(build): allow retrying failed source builds - #160059

Merged
steipete merged 1 commit into
mainfrom
deslop/l129-build-failure-cleanup
Sep 28, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/l129-build-failure-cleanup

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Failed source builds can leave distribution artifact ownership behind and block the next build, even after all build children have exited.

User Impact

Developers can retry a failed source build without manually removing a stale artifact lock. Failure exit codes and diagnostics stay unchanged. Crashes and unjoined children still retain ownership for inspection.

Why This Change Was Made

The build entry runs inside the inherited artifact owner's import wrapper. Calling process.exit bypassed that wrapper's finally and left a child claim behind. Setting process.exitCode lets the existing cleanup finish; the argument-error path also skips build work. No lock-recovery policy changes are needed.

Found while validating #159933 and kept in this separate tooling fix.

Evidence

  • On unchanged production code, both new regression cases returned the expected exit code and diagnostics, then failed because a child claim and owner.json remained. After the repair, both release the lock and successfully reacquire ownership.
  • The new test runs the real build entry, managed child lifecycle, and artifact owner; only the terminal build workload is synthetic. It adds no production seam, sleeps, retries, or weakened assertions.
  • Blacksmith Testbox: pnpm test test/scripts/build-all-ownership.test.ts --maxWorkers=1 passed both cases in 3.67s wall (2.26s Vitest duration). The existing build and distribution-ownership suites passed 119 tests in 24.10s wrapper time, including crash/unjoined retention controls. The new regression also passed in hosted CI in 1.065s test time.
  • The first changed check reached unrelated type errors in three CI fixtures. Main commit 57f1abecc191ea0a54a9af93a6ccb97e6eb87700 already fixes them; this branch incorporates it. The refreshed node scripts/check-changed.mjs -- scripts/build-all.mts test/scripts/build-all-ownership.test.ts and full pnpm build passed on the rebased head. Build phase time was 7m38s; the combined completion command exited 0 in 13m45s.
  • Hosted CI run 36373657155 passed at exact head a19b6d66f460c959f01f64a0731bbda3f5d55bca, including openclaw/ci-gate.
  • Independent isolated Codex review through P2: no accepted/actionable findings.

The focused proof used Blacksmith Testbox lease tbx_01m3jzqp43s4p491q1tj27csdb. Completion gates used tbx_01m3k0f639j097m2extz9vqe9z (run 36373369154) at candidate a19b6d66f460c959f01f64a0731bbda3f5d55bca; the rebase is patch-identical. Both leases are stopped. All tests, checks, and builds ran remotely through scripts/crabbox-wrapper.mjs, with source bytes verified before execution.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 03:25
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 11:31 PM ET / September 28, 2026, 03:31 UTC.

ClawSweeper review

What this changes

The source-build entry now reports failures through its process exit code, with process-level tests for failed builds and invalid arguments.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has the reported cleanup failure, and this focused PR addresses it. Source review found no blocking defect.

Priority: P2
Reviewed head: a19b6d66f460c959f01f64a0731bbda3f5d55bca

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful process-boundary regression coverage and reported Testbox results; the execution trace was not independently inspected here.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored PR is exempt from the contributor proof gate. Its body reports a Testbox run through the real build entry and ownership wrapper, using a synthetic failing workload and observing clean lock reacquisition after the fix; no stored-data format changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the contributor proof gate. Its body reports a Testbox run through the real build entry and ownership wrapper, using a synthetic failing workload and observing clean lock reacquisition after the fix; no stored-data format changes.
Evidence reviewed 7 items Current-main defect: The pinned main branch calls process.exit on argument rejection and failed build results, bypassing the inherited wrapper's cleanup.
Introduced repair: The introduced patch sets process.exitCode and prevents argument-error paths from starting build work.
Ownership lifecycle: The wrapper removes a child claim after its imported entry completes; the parent releases its lock only when no child or unjoined-work claim remains.
Findings None None.
Security None None.

How this fits together

OpenClaw's source-build script selects and runs artifact-producing steps. An ownership wrapper tracks build children and controls when another build may write generated artifacts.

flowchart LR
A[Build command and profile] --> B[Artifact ownership wrapper]
B --> C[Selected build steps]
C --> D[Managed child process]
D --> E{Child work joined?}
E -->|Yes| F[Release claim and lock]
E -->|Unverified| G[Retain lock for inspection]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +108, Other 0. Total +108 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 108 0 +108
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 3 0
Total 2 111 3 +108

Review metrics

Metric Value Why it matters
Production and test growth production +0 net, tests +108 The added test exercises the process and lock lifecycle behind the small production change.
Reported focused test cost 3.67 s wall; 2.26 s Vitest The reported one-worker run is within the repository's under-five-second test target.

Technical review

Best possible solution:

A joined failed build should preserve its exit code and diagnostics while releasing ownership for an immediate retry; unverified child work should continue retaining the lock.

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

Yes, from source: run a failing build under inherited artifact ownership on pinned main and the immediate exit can strand its claim. The PR reports this pre-fix failure and after-fix success on Testbox; this review did not execute it.

Is this the best way to solve the issue?

Yes. Setting the exit code at the build entry preserves failure reporting while allowing the existing ownership cleanup to finish.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7b2394da7a9d.

Labels

Label changes:

  • add P2: Failed source builds can block developer retries, but the impact is limited to build tooling.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the contributor proof gate. Its body reports a Testbox run through the real build entry and ownership wrapper, using a synthetic failing workload and observing clean lock reacquisition after the fix; no stored-data format changes.

Label justifications:

  • P2: Failed source builds can block developer retries, but the impact is limited to build tooling.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the contributor proof gate. Its body reports a Testbox run through the real build entry and ownership wrapper, using a synthetic failing workload and observing clean lock reacquisition after the fix; no stored-data format changes.

Evidence

What I checked:

  • Current-main defect: The pinned main branch calls process.exit on argument rejection and failed build results, bypassing the inherited wrapper's cleanup. (scripts/build-all.mts:622, 7b2394da7a9d)
  • Introduced repair: The introduced patch sets process.exitCode and prevents argument-error paths from starting build work. (scripts/build-all.mts:622, a19b6d66f460)
  • Ownership lifecycle: The wrapper removes a child claim after its imported entry completes; the parent releases its lock only when no child or unjoined-work claim remains. (scripts/lib/dist-artifact-lock.mts:26, 7b2394da7a9d)
  • Regression boundary: Both new cases spawn the real ownership wrapper and build entry, assert the failure code and diagnostic, then reacquire the released lock. Only the terminal failing workload is synthetic. (test/scripts/build-all-ownership.test.ts:38, a19b6d66f460)
  • Reported execution proof: The PR body reports that both cases failed on unchanged production code because ownership remained, then passed on this head on Blacksmith Testbox in 3.67 seconds wall time. This is contributor-reported execution, not a run performed during this read-only review. (a19b6d66f460)
  • Feature history: Prior merged work introduced the artifact ownership wrapper; its raw recorded parent lacks this file. This supports routing to the existing build-ownership area. (scripts/lib/dist-artifact-lock.mts:26, 2ff07dbab332)

Likely related people:

  • Peter Steinberger: Raw commit 2ff07db adds scripts/lib/dist-artifact-lock.mts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2ff07dbab332; files: scripts/lib/dist-artifact-lock.mts)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete merged commit 915567d into main Sep 28, 2026
159 checks passed
@steipete
steipete deleted the deslop/l129-build-failure-cleanup branch September 28, 2026 03:52
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. 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