Skip to content

fix(build): stabilize declaration cache reuse - #138385

Open
vincentkoc wants to merge 21 commits into
mainfrom
fix/declaration-cache-reuse-20260904
Open

vincentkoc wants to merge 21 commits into
mainfrom
fix/declaration-cache-reuse-20260904

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes package builds whose runtime chunk layout changes when declaration emission is toggled. Stable outputs avoid invalidating restored declaration caches. Current main's final runtime-only build pass remains unchanged; this repair addresses the package graph producer rather than removing that existing mitigation.

Why This Change Was Made

Runtime JavaScript and declaration emission now use separate, stable tsdown config partitions for AI and all workspace packages, including agent-core, while preserving main's consolidated full declaration program and SDK-only selection. The build wrapper owns DTS mode for the default, main, and AI configs, including CAC's --dts=true and --dts=false forms; arbitrary custom configs and --no-config retain their original arguments.

The compiler-input snapshot, cache namespace algorithm, cache format, dependencies, and environment surface are unchanged. The shared config-splitting helper is reached through the canonical generator import closure, so edits invalidate the producer stamps without a new hard-coded input list. Current package compiler options, runtime-cache ownership and runtime-only plugins remain intact. Cleanup now receives the same effective DTS mode as compilation.

User Impact

Warm full builds can reuse restored declaration artifacts after runtime-only rebuilds instead of recompiling all declaration groups. Explicit DTS CLI overrides continue to work without recombining the runtime and declaration graphs.

Evidence

Published Current-Main Correction

Current published head: 75e3a6a385cad7110fb3dfe6dccfca9d09a70615, tree 2539d949e3dac0841a5bdc9755d2d26d98bdb5f8. Native signed integration 828968d45df5 preserves the formatting correction aec7099c3276 as first parent and captured main 5c0201b1e7d8 as second parent. The final product diff is 19 build/config/tooling/test paths, +729/-96; no dependency, schema, protocol or excluded product-surface change.

The four independently reviewed conflict resolutions retain main's new AI entrypoints, dynamic/updater consumers and current fixtures. Standalone source-module metadata stays on runtime partitions only. The signed follow-up migrates main's new standalone source loader to the split AI config array and extends its existing real-loader fixture to both declaration modes, asserting one runtime entry while preserving original JavaScript worker mapping. Fresh full-branch AutoReview against the captured baseline found no actionable P0-P2 findings; source whitespace is clean.

Predecessor CI40481742185 exposed two concrete integration defects: main had removed imports still used by this PR's watch/precedence fixtures, and the expanded standalone-loader destructuring needed formatting. The declaration file actually ran 23 cases: 18 passed, three failed with the missing group import, and two skipped; tooling types separately reported four missing-symbol errors. Changed formatting identified only the loader file, while all lint substeps passed. Signed successor 75e3a6a385ca restores both imports from their maintained owners and reformats the loader, with no assertion, literal or behavior changes. Independent bounded integration review found no additional defects; fresh scoped AutoReview with full fixture/helper context is clean through P2. Predecessor failures remain recorded, not waived.

Exact-head CI40483818685 binds 75e3a6a385ca through merge 671a39ba into main 4c3fd8a08b56. Retained Linux logs verify 321 passed and three explicit skips across 11 relevant suites: declaration-resolution21/2skips, config62, build-wrapper110, runtime-config13, build-all55, runtime-cache2, standalone-loader9, Knip-export28, AI-package1, SDK-declarations11/1skip and unified-writer9. Both formerly failing watch modes and DTS precedence pass. Both split-AI loader modes pass, as do the actual declaration-cache reuse/input-edit cases. Hosted tooling types and changed formatting/Bun parity pass; the build-artifacts job also succeeds. Skips are not counted as passes.

CI completed successfully at10:07UTC; landing still requires causal proof and final native admission. The baseline-ratchet job and complete current-head CI succeeded. The two-case loader regression still needs an executed pre-fix comparison using the unchanged current test and the loader blob from signed integration 828968d45df5, followed by exact production restoration and focused green confirmation. Expected failure is the existing named-entry-map guard, not an infrastructure or timeout failure. This proof must use the existing executor and an admitted remote route; no new lease was allocated in this continuation. No application tests, builds, formatter, lint or typecheck ran on the local Mac. Native github_pending was publication admission, not a completed final-gate stamp. Substantive review and completed-hosted native squash gates remain; no merge or auto-merge was requested.

Historical b41 CI39347889372 completed with 39 successful jobs, 27 skipped and two failed jobs: changed-test formatting and the aggregate gate. All formerly queued jobs executed; there is no remaining queue blocker from that run. The exact two-file formatting correction is preserved. Its 14 passing Knip cases and all earlier passes/failures below remain predecessor evidence, not qualification of the new head.

Historical Qualification and Review Disposition

The following checkpoints retain their original source and execution identities. References to then-current heads and pending work describe those historical checkpoints.

Predecessor native integration: 097b5b637185ff7f085ae23c093146f2a289b08a, tree bee60f2ffb07e34dac4563c56a655b62dbe1ab7c. The signed native baseline integration preserves b98fd8a322c54f2f2dbafa3a648bfc92f8ce6a33 as first parent and pins main6deac372 as second parent. This consumes the canonical main UI typecheck repair without adding a UI change to the PR's 15-file build/cache product diff. The emitted-asset and explicit-build-cwd repairs, all original ancestry and current compiler/cache/worker/fixture owners remain intact.

Independent source review verified the exact materialized resolution: unconditional real lockfile copy, physical fixture boundary, installed-dependency protection and opt-in Mistral license. Current client-credential worker and Darwin native-asset contracts remain intact. Fresh full-diff AutoReview raised one standalone-build finding. Parent and independent review rejected it as an introduced regression: that owner deliberately retains its unchanged full-DTS, clean-output, uncached build contract; build-all's repaired cache route calls a different owner. The existing real standalone test remains mandatory hosted coverage. Source review is not runtime qualification.

Both substantive historical ClawSweeper findings are addressed in source: spaced boolean DTS values are consumed with their option, and the native declaration emitter removes maps owned by excluded runtime stub chunks. Effective DTS mode also reaches cleanup, and sequential CLI tests check retained declaration bytes rather than incorrectly expecting removal. Cache tests retain cold/warm/mixed-hit/disabled cases, actual runtime imports, declaration restoration and byte/hash comparisons; watch tests require two completed generations.

Predecessor proof has two retained failures; successor proof is pending. CI39336508914 binds 0b512449, not this successor. Actual Linux logs show tsdown-config 62 passes, declaration-resolution 24 passes/four platform-capability skips, build-all 59 passes, and plugin-SDK declarations 11 passes/one skip. The unified writer suite has 11 passes/one failure: its first warm-build assertion incorrectly requires invocation-specific build-cache-inputs.json to retain cold-build bytes; all other 160 artifact hashes match. The AI package streaming test also fails because its direct caller spreads the now-array config export as one object, losing license-copy settings. Both failures remain recorded, not waived.

The two test corrections at be0a5f4e8e2 derive each phase's expected receipt from explicit cache owners and authoritative stamps while retaining every other artifact hash, and select the unique AI runtime config while retaining license and streaming assertions. CI39339178297 advanced beyond the repaired first warm-build assertion, then failed the mixed-cache phase because only packages/ai/dist/mistral.LICENSE was missing. The unified writer retained 11 passes/one failure. Actual passing suites included config62, declaration-resolution24/four platform-capability skips, build wrapper106, build-all59 and SDK declarations11/one skip. These remain predecessor results, not qualification of the new head.

The current three-file correction emits the license through the bundler's asset owner instead of an out-of-band copy, and includes physical asset provenance in runtime-cache signatures. This preserves both license restoration and invalidation when its source changes. The existing cache test now exercises a non-module asset, unchanged restoration and isolated source invalidation; the real mixed-cache fixture, complete artifact hashes, declaration signatures, cache reuse and license/streaming assertions are unchanged. Installed tsdown/Rolldown contracts were inspected directly; independent source audit and fresh scoped autoreview found no actionable P0-P2 findings. No cache format, dependency, schema or protocol change is introduced.

Predecessor CI39341268365, at 4d165d35, passed all 12 unified-writer cases, including the formerly failing strict mixed-cache packaged-hash comparison. The actual AI streaming/license case passed, as did build-all59, SDK declarations11/one intentional skip and config62. Declaration-resolution had21 passes, three failures and four platform/capability skips: both explicit AI DTS override cases read the license under the ambient process cwd instead of the build cwd; the overlapping-build fixture then timed out after the same AI build-start failure. These are actual failures, not flaky-check exemptions.

The signed two-line correction at b98fd8a3 uses the normalized buildStart(options).cwd supplied by Rolldown. Strict license reads, emitted provenance, runtime-cache signatures and every test remain unchanged. Dependency source/types and the existing nested-root/concurrent-build fixtures were inspected; fresh scoped autoreview found no actionable P0-P2 findings. No timeout increase, process-cwd mutation, fallback or assertion weakening is used. Its hosted CI39342546256 actually passed declaration-resolution24/four explicit skips and config62, including both formerly failing AI overrides, overlapping workspace/AI builds, two-generation watch and canonical DTS precedence. Separate actual Linux output confirms unified-writer12, build wrapper106, AI streaming/license1 and build-all59 passes. These results bind b98fd8a3, not the integrated successor.

That CI's merge into db91ecf9 failed the unrelated UI typecheck: resumeStoredChatOutboxes was referenced without its import. The PR does not change that UI file. Canonical main6deac372 adds exactly the missing import. The new signed integration consumes that fix through main ancestry; it does not copy a UI patch into this PR or replace a failed scheduled run with manual green. Prior passes and failures retain their exact source bindings. Current-head CI39344635400 has started for 097b5b63; its completed proof remains required.

Actual predecessor 097b5b63 Linux output confirms 277 passed and five explicit skips across eight relevant suites: declaration-resolution24/4skips, config62, unified-writer12, build wrapper106, AI streaming/license1, build-all59, runtime-cache2, and SDK declarations11/1skip. This includes strict mixed-cache artifact/hash equality, emitted-asset source invalidation/corruption, both watch modes, overlapping workspace/AI builds, and canonical SDK publication. The previously failing production typecheck also passed. Its completed CI failed three jobs: Knip's single-object AI config consumer (TS2339), formatting in the two touched declaration tests, and an inherited xAI test status-argument mismatch (TS2345). The first two are repaired in the current correction and await exact-head hosted verification. Independent source attribution proves the xAI caller/helper unchanged across baseline and candidate; canonical 177830, commit 0449ef26b26630eba2c75cb53262bee23343e31c, fixes that call on main. This PR adds no xAI patch. Failed predecessor gates remain failed, and these277 passes do not qualify the new regression. Skipped cases are not claimed as passes.

The completed ClawSweeper review binds be0a5f4: it resolves the earlier DTS-boolean/orphan-map findings and identifies the accepted license-loss P2. Emitted-asset ownership plus predecessor097 strict mixed-cache and runtime-cache asset-invalidation proof address that finding; the cwd repair also passes its previously failing declaration cases. Independent composition review verified an identical 15-file product patch across the native baseline integration, unchanged product blobs and no conflicts. Automatic dispatch did not produce a newer review. Native github_pending publication is not a successful gate stamp. No application tests or checks ran on the local Mac; no new Testbox was allocated. Required full new-head CI, substantive review and native squash gates remain.

Retained Historical Correction Evidence

The following results bind private 3ffbf06672cca9161da426ef54c603893792b383 / tree 0e7c3c238a9c94cd5aa5b3d710ada10f89e08531, not the newly published correction.

Composition proof passed 314 tests, zero failures and four Windows-only skips across eight suites; scoped formatting/diff checks passed and source pins stayed exact. Earlier scoped proof retains270 passes and complete scoped checks under its original binding. The causal baseline retains two intended failures, independently reconciled from its verifier-text mismatch. These are separate results, not cumulative current-head qualification.

Full native gate remains failed/incomplete. Run37099949204 completed build/full checks and five groups with 30,961 passed /57 skipped, but tooling did not complete. Wrapper255/native1 and the absence of a successful gate stamp remain recorded. GitHub names Blacksmith's bot as cancellation actor; the exact termination cause is unknown. Provider completion, joined children and native lock recovery were verified. The unavailable failed-job log was not fetched again; the portal warning is separate reporting.

That unknown cancellation cause still prevents an unchanged Testbox retry. It does not block the independently reviewed native hosted-publication route now used. No provider switch, deadline extension, inherited-failure exception or partial-group success stamp is used.

Remaining: inspect actual current-head Linux coverage for the changed suites and fixture consumers, fix concrete failures, complete fresh head-bound review and native completed-hosted gates, then squash only when all required checks pass.

Historical Evidence for Public Head c0403dbf4945

The following evidence predates the current-main reconstruction and does not qualify the current correction.

  • node scripts/run-vitest.mjs test/scripts/tsdown-build.test.ts: 174 passed at the exact head.
  • node scripts/run-vitest.mjs test/scripts/tsdown-build.test.ts -t 'assigned|preserves repeated DTS switches': 4 expected failures before the repair; 16 passed after. Covers default, explicit main, AI, last-switch precedence, custom config preservation, and --no-config preservation.
  • node scripts/run-vitest.mjs test/scripts/tsdown-build.test.ts -t 'keeps one owned watcher through its initial build and one edit': 1 passed. Covers initial build plus edit, JavaScript, declarations, source maps, and child cleanup.
  • node scripts/run-vitest.mjs test/scripts/tsdown-config.test.ts test/scripts/write-unified-entry-dts.test.ts -t 'isolates runtime output from bounded declaration-only graphs|keeps source maps aligned across package runtime and declaration graphs|reuses declarations after AI and workspace runtime graphs rebuild': 3 passed. The real-emitter case covers a cold build, retained declaration cache, runtime-only AI/package rebuilds, mixed upstream cache hits/misses, cache-disabled rebuilds, and downstream declaration reuse.
  • node scripts/run-vitest.mjs test/scripts/tsdown-build.test.ts test/scripts/build-all.test.ts test/scripts/tsdown-config.test.ts -t 'isolates runtime output|keeps source maps aligned|keeps node package artifacts|keeps.*runtime imports|resolveTsdownBuildInvocation|invalidates both workspace declaration caches|rebuilds runtime JS': 167 passed, 122 skipped in one earlier candidate-wide run. This is a separate run, not a cumulative count with the exact-head checks above.
  • Fresh exact-head autoreview at c0403dbf4945955156de5ea0069062cc939a6502: scoped clean for P0-P2 findings.
  • Exact-head Linux cold/warm proof passed: https://github.com/openclaw/openclaw/actions/runs/33893083920. In this one run, the cold build took 301,789 ms and the warm build took 94,273 ms. The warm build restored both upstream caches, hit all 8 declaration groups, recorded 0 misses and 0 post-decision declaration compiler invocations, and kept all 10 producer/declaration records identical for signatures, inputs, and outputs with no missing inputs.
  • Exact-head hosted CI passed: https://github.com/openclaw/openclaw/actions/runs/33893319437. All 112 admitted jobs succeeded, including openclaw/ci-gate; 16 non-applicable jobs were skipped.

A broader local build/config invocation completed 196 tests and failed 2 unrelated memory-lancedb fixture cases because this candidate worktree lacked the per-plugin extensions/memory-lancedb/node_modules links used by the untouched fixture. The canonical baseline has the declared Darwin native-binding link. After wiring that missing worktree link without installing or changing dependencies, both untouched fixture cases passed (2 passed, 22 skipped). This PR does not change dependency manifests, the lockfile, or that test; the original incomplete-worktree run is not counted as green evidence.

@vincentkoc vincentkoc self-assigned this Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 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: L maintainer Maintainer-authored PR labels Sep 4, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 4, 2026 16:06
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 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 exact_review_queue).
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: 🐚 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head be0a5f4e8e2f14b26df482892a460a01a4384beb, but the PR head is now b41ff62b3156c9140f43fe1a551372bd565eb1fb. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (6 earlier review cycles)
  • reviewed 2026-09-04T17:44:01.326Z sha c0403db :: blocked before merge. :: none
  • reviewed 2026-09-04T18:17:13.118Z sha c0403db :: blocked before merge. :: none
  • reviewed 2026-10-02T22:35:53.055Z sha c0403db :: blocked before merge. :: [P2] Consume spaced DTS boolean values with their option | [P2] Prevent declaration stubs from publishing runtime source maps
  • reviewed 2026-10-02T23:47:20.741Z sha c0403db :: blocked before merge. :: [P2] Consume spaced DTS boolean values with their option | [P2] Prevent declaration stubs from publishing runtime source maps
  • reviewed 2026-10-03T07:16:01.056Z sha c0403db :: blocked before merge. :: [P2] Consume spaced DTS boolean values with their option | [P2] Prevent declaration stubs from publishing runtime source maps
  • reviewed 2026-10-19T23:20:11.391Z sha be0a5f4 :: needs changes before merge. :: [P2] Preserve copied assets on the newly cacheable DTS override path

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 4, 2026
* commit 'c0e6951d6f02d3eabd4bc13cf8e9fa9e77d290ac': (21 commits)
  fix(cron): align regression fixtures with Gateway scheduler
  fix(cron): supply scheduler in startup recovery fixture
  fix(whatsapp): make shutdown drain coverage deterministic (#159115)
  refactor: clear repository lint warnings (#159133)
  test: accelerate provider shutdown recovery coverage (#159098)
  chore(ui): refresh control ui locales (#159122)
  refactor(ui): deslop pages third pass (#158846)
  perf(team-reports): keep collection off the Gateway event loop (#159101)
  perf(agents): avoid repeated retained subagent recovery reads (#159082)
  test(core,plugins,ui): remove low-value tests (batch d041) (#159097)
  refactor(cron): schedule foreign receipt reconciliation (#159114)
  test(android): avoid idle waits for settled gateway actions (#159077)
  refactor(gateway): share periodic maintenance scheduling (#159111)
  fix(cron): keep future jobs running after startup catch-up fails (#159086)
  refactor(cron): own retained run transcript access (#158776)
  fix(memory): Chinese queries lose English terms written without spaces (#159076)
  test(plugins, model-picker, terminal): remove low-value tests (batch d043) (#159108)
  improve(channels): prune ingress overflow inside SQLite (#159050)
  fix(tasks): preserve changed cron history and finish deferred cancellation (#159064)
  test(build): preserve SDK artifacts after declaration errors
  ...
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant