Skip to content

improve(update): reuse dev preflight build cache - #117246

Merged
steipete merged 1 commit into
mainfrom
codex/reuse-staged-update-build
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/reuse-staged-update-build

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where source-checkout operators updating on the dev channel would wait for the same expensive TypeScript declaration build twice: once in the safety preflight worktree and again after the live checkout moved to the selected commit. The updater also rebuilt the Control UI after the full build had already produced it.

Why This Change Was Made

The dev preflight and final checkout now share build-all's content-addressed cache. The final checkout still performs its authoritative build, so rebased source changes miss the relevant cache automatically and all normal stamps, runtime outputs, and clean-tree checks remain intact. The standalone Control UI build now runs only when the target build or doctor actually omitted its assets.

User Impact

Dev-channel source updates retain the existing newest-buildable-commit safety contract while spending seconds, rather than minutes, on the repeated same-content build phase.

Evidence

  • Focused Vitest: 116 tests passed in test/scripts/build-all.test.ts and src/infra/update-runner.test.ts.
  • Blacksmith Testbox tbx_01kyxwh45ashyxmdv81a6dwtm1: touched core/tooling lint passed, focused tests passed, and two full builds used an isolated shared cache.
  • Cold full build: 211,465 ms. Same-content warm full build: 10,329 ms (95% lower).
  • tsdown-unified: 141.5 s cold to 3.93 s with the declaration cache restored. The warm build still ran runtime JS, Control UI, stamps, build-info, and postbuild phases.
  • Autoreview: clean, no accepted/actionable findings.

Provenance: the paired preflight/live builds were introduced by direct commit ff3d8cab2bc98b5b8a2c098dfc442b56ab328640 on 2026-01-22; GitHub has no associated PR. PR #86010 later made the full build include Control UI, leaving the updater's explicit UI build redundant for current targets.

@steipete steipete self-assigned this Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:50 AM ET / 05:50 UTC.

ClawSweeper review

What this changes

This PR shares the declaration-build cache between dev-update preflight worktrees and the rebased checkout, while avoiding a second Control UI build when the normal full build already produced its assets.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for the assigned maintainer’s technical approval rather than cleanup closure. The patch uses the existing content-addressed declaration cache for the two dev-update builds, preserves the final checkout’s authoritative build, and retains the existing post-build Control UI fallback; no discrete correctness defect was established. Likely related people: steipete (high confidence) and yetval (medium confidence).

Priority: P3
Reviewed head: 33dbf032ca6721e44d50abf900d745bcae61deda
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-aligned tooling optimization with detailed real build evidence and regression coverage; the remaining gate is protected maintainer approval rather than a demonstrated patch defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies after-fix Testbox and terminal evidence for two isolated full builds, including a cold-to-warm timing comparison and confirmation that runtime JS, Control UI, stamps, build-info, and postbuild phases still ran.
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 after-fix Testbox and terminal evidence for two isolated full builds, including a cold-to-warm timing comparison and confirmation that runtime JS, Control UI, stamps, build-info, and postbuild phases still ran.
Evidence reviewed 6 items Shared cache is content-signature guarded: The PR adds an optional cache-root resolver and continues to treat a cache hit as valid only when the cache version, input signature, and stamped outputs match; restored declaration outputs are copied into the receiving checkout rather than moving build trees.
Final build remains authoritative: The final dev checkout invokes the normal build with the same cache root, performs the existing clean-tree check, and only runs the standalone UI build when dist/control-ui/index.html is absent; doctor retains its independent post-doctor repair path.
Focused regression coverage covers both handoffs: The PR adds a cross-checkout cache restore test and verifies that preflight and final dev builds receive the same cache-root environment value; existing update tests cover the UI fallback when assets are missing.
Findings None None.
Security None None.

How this fits together

Dev-channel source updates first build a candidate in a temporary Git worktree, then rebase and build the live checkout before running doctor. The changed path passes reusable declaration outputs through build-all’s cache while the final build still creates the runtime and Control UI artifacts consumed by the updated installation.

flowchart LR
  A[Dev update request] --> B[Preflight worktree build]
  B --> C[Content-addressed declaration cache]
  B --> D[Selected buildable commit]
  D --> E[Rebased live checkout]
  C --> F[Final checkout build]
  E --> F
  F --> G[Control UI asset health check]
  G --> H[Doctor and updated runtime]
Loading

Decision needed

Question Recommendation
Does the update-tooling owner approve using the internal BUILD_ALL_CACHE_ROOT handoff to share only dev preflight declaration cache outputs with the final checkout build? Approve the updater-owned cache handoff: Accept the scoped dev-update environment handoff because signature validation, the authoritative final build, and UI fallback checks remain intact.

Why: The PR carries the protected maintainer label and introduces a process-level environment control for a compatibility-sensitive update path; source evidence supports the implementation, but the intended permanent operator contract belongs to the update owner.

Before merge

  • Complete next step (P2) - The PR is freshly assigned and has the protected maintainer label, so the remaining action is owner approval of the update-path environment handoff rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +18, Tests +63, Docs 0, Other +12. Total +93 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 30 12 +18
Tests 2 72 9 +63
Docs 1 3 3 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 15 3 +12
Total 7 120 27 +93

Review metrics

Metric Value Why it matters
Build-cache environment handoff 1 added internal environment variable BUILD_ALL_CACHE_ROOT is the single new control used to carry declaration-cache outputs across the dev preflight and final checkout boundary.

Stored data model

Persistent data-model change detected: migration/backfill/repair: docs/cli/update.md, persistent cache schema: docs/cli/update.md, persistent cache schema: scripts/build-all.mjs, persistent cache schema: src/infra/update-runner-git-preflight.ts, persistent cache schema: src/infra/update-runner-git.ts, persistent cache schema: src/infra/update-runner.test.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one cache handoff owned by the dev updater, retain the normal final build and UI-health fallbacks, and merge only after the assigned owner accepts the internal environment handoff on the current head.

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

Not applicable: this PR improves an existing dev-update performance path rather than reporting a broken behavior. Its body provides after-fix full-build timing evidence and focused test results, but this read-only review did not rerun the build.

Is this the best way to solve the issue?

Yes: reusing the existing content-addressed declaration cache is narrower than introducing another build flow or copying whole worktree outputs, while the final checkout still performs its normal runtime/UI build and health checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded dev-update performance improvement with no established user-facing regression or security impact.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix Testbox and terminal evidence for two isolated full builds, including a cold-to-warm timing comparison and confirmation that runtime JS, Control UI, stamps, build-info, and postbuild phases still ran.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies after-fix Testbox and terminal evidence for two isolated full builds, including a cold-to-warm timing comparison and confirmation that runtime JS, Control UI, stamps, build-info, and postbuild phases still ran.

Label justifications:

  • P3: This is a bounded dev-update performance improvement with no established user-facing regression or security impact.
  • 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 after-fix Testbox and terminal evidence for two isolated full builds, including a cold-to-warm timing comparison and confirmation that runtime JS, Control UI, stamps, build-info, and postbuild phases still ran.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix Testbox and terminal evidence for two isolated full builds, including a cold-to-warm timing comparison and confirmation that runtime JS, Control UI, stamps, build-info, and postbuild phases still ran.

Evidence

What I checked:

  • Shared cache is content-signature guarded: The PR adds an optional cache-root resolver and continues to treat a cache hit as valid only when the cache version, input signature, and stamped outputs match; restored declaration outputs are copied into the receiving checkout rather than moving build trees. (scripts/build-all.mjs:638, 33dbf032ca67)
  • Final build remains authoritative: The final dev checkout invokes the normal build with the same cache root, performs the existing clean-tree check, and only runs the standalone UI build when dist/control-ui/index.html is absent; doctor retains its independent post-doctor repair path. (src/infra/update-runner-git.ts:387, 33dbf032ca67)
  • Focused regression coverage covers both handoffs: The PR adds a cross-checkout cache restore test and verifies that preflight and final dev builds receive the same cache-root environment value; existing update tests cover the UI fallback when assets are missing. (test/scripts/build-all.test.ts:739, 33dbf032ca67)
  • Current main already builds the Control UI in the full profile: Current main defines ui:build in build-all’s full profile and explicitly leaves it uncached because its build identity incorporates Git and environment state; the proposed updater fallback therefore avoids only the separate redundant invocation. (scripts/build-all.mjs:245, ad409a828515)
  • Preflight provenance: The paired preflight/final update flow appears to date to the direct commit that introduced preflight-before-rebase; the later merged Control UI build change is adjacent prior art, not a replacement for this cache-reuse proposal. (src/infra/update-runner-git-preflight.ts:390, ff3d8cab2bc9)
  • Current-area provenance: The current cache implementation lines blame to a recent main commit, while the update-runner split/refactor is attributable to steipete; this supports routing review to both the cache and update-path history. (scripts/build-all.mjs:638, c13a0493aa10)

Likely related people:

  • steipete: The original preflight-before-rebase behavior dates to direct commit ff3d8ca, and the current update-runner module split is commit f6de912. (role: preflight-flow introducer and recent update-path refactor author; confidence: high; commits: ff3d8cab2bc9, f6de912efec8; files: src/infra/update-runner-git.ts, src/infra/update-runner-git-preflight.ts, src/infra/update-runner-git-commands.ts)
  • yetval: The current cache-path and signature implementation in build-all blames to commit c13a049, making this a useful adjacent routing candidate for cache-contract review. (role: recent build-cache area contributor; confidence: medium; commits: c13a0493aa10; files: scripts/build-all.mjs)

Rank-up moves

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

  • Let the current-head build and check suite finish before merging.

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 137050c into main Aug 1, 2026
199 of 212 checks passed
@steipete
steipete deleted the codex/reuse-staged-update-build branch August 1, 2026 05:59
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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