fix(build): forward default exports through stable runtime aliases#99678
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 7:16 PM ET / 23:16 UTC. Summary PR surface: Tests +29, Other +33. Total +62 across 2 files. Reproducibility: yes. source-level reproduction is high confidence: current main emits wildcard-only aliases, the compaction caller imports default through such an alias, the runtime helper exports default, and a Node ESM probe confirms wildcard re-exports omit default. I did not run a packaged live compaction flow in this read-only review. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this focused generator fix after required CI and maintainer review, leaving broader compaction guardrail work to its separate canonical issues. Do we have a high-confidence way to reproduce the issue? Yes, source-level reproduction is high confidence: current main emits wildcard-only aliases, the compaction caller imports default through such an alias, the runtime helper exports default, and a Node ESM probe confirms wildcard re-exports omit default. I did not run a packaged live compaction flow in this read-only review. Is this the best way to solve the issue? Yes, this is the best fix boundary: the generated alias is the layer dropping the default export, while the caller and runtime helper agree on a default import/export contract. Changing only the compaction caller would leave the alias generator as a latent footgun. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c45124ab8554. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Tests +29, Other +33. Total +62 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
75f4081 to
712f7dc
Compare
|
Fixed the @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
712f7dc to
a2eb826
Compare
runtime-postbuild writes stable aliases (`X.runtime.js`) for hashed runtime
chunks as bare `export * from "./X-HASH.js"` — but `export * from` never
re-exports `default`. In the shipped 2026.6.10/2026.6.11 artifacts the
compaction runtime alias points at a chunk whose only export is default, so
its lazy consumer destructuring `{ default: reconcile }` gets undefined:
every successful auto-compaction logs "late compaction count reconcile
failed: TypeError: reconcile is not a function" and the persisted
compactionCount never updates. On local-model deployments the resulting
repeat compactions each cost a multi-minute full re-prefill (observed:
3 compactions in 25 minutes). Other stable aliases are latent instances of
the same generator defect for any target that gains a default export.
Fix: when the alias target has a default export, also emit
`export { default } from ...` (applies to both the stable-alias and
legacy-compat writers). Detection is an anchored export-statement pattern,
verified against all 7 shipped runtime chunks (no false positives; naive
text matching would both miss and over-match — an alias claiming a default
its target lacks is a hard SyntaxError at import). Adds a regression test
mirroring the real compaction-reconcile chunk shape.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01H6Hz9UEpxQ4W3d8XecvupH
8f29406 to
34c7a93
Compare
|
Maintainer land-ready proof for
Known proof gaps: none for the generated runtime alias behavior. |
|
Merged via squash.
|
…penclaw#99678) * fix(build): forward default exports through stable runtime aliases runtime-postbuild writes stable aliases (`X.runtime.js`) for hashed runtime chunks as bare `export * from "./X-HASH.js"` — but `export * from` never re-exports `default`. In the shipped 2026.6.10/2026.6.11 artifacts the compaction runtime alias points at a chunk whose only export is default, so its lazy consumer destructuring `{ default: reconcile }` gets undefined: every successful auto-compaction logs "late compaction count reconcile failed: TypeError: reconcile is not a function" and the persisted compactionCount never updates. On local-model deployments the resulting repeat compactions each cost a multi-minute full re-prefill (observed: 3 compactions in 25 minutes). Other stable aliases are latent instances of the same generator defect for any target that gains a default export. Fix: when the alias target has a default export, also emit `export { default } from ...` (applies to both the stable-alias and legacy-compat writers). Detection is an anchored export-statement pattern, verified against all 7 shipped runtime chunks (no false positives; naive text matching would both miss and over-match — an alias claiming a default its target lacks is a hard SyntaxError at import). Adds a regression test mirroring the real compaction-reconcile chunk shape. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H6Hz9UEpxQ4W3d8XecvupH * fix(build): preserve defaults through legacy runtime aliases --------- Co-authored-by: headbouyJB <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
|
Follow-up on the "possible sibling" note in the description: verified — |
Fixes #99677.
What Problem This Solves
runtime-postbuildwrites stable runtime aliases as bareexport * from "./X-HASH.js"— butexport * fromnever re-exportsdefault. One shipped alias (2026.6.10 and 2026.6.11 tarballs) points at a chunk whose only export isdefault(the compaction-reconcile runtime), so its lazy consumer destructuringdefaultgetsundefined; the remaining stable aliases are latent instances of the same generator defect (corrected from an earlier "seven affected" count — see the issue's correction note). Proven-broken path: after every successful auto-compaction,(
selectionchunk lazy-imports{ default: reconcile }through the compaction runtime alias) — so the persistedcompactionCountnever updates. On local-model deployments the resulting repeat compactions each trigger a multi-minute full re-prefill (observed: 3 compactions in 25 minutes = an unresponsive agent).Why This Change Was Made
The alias writers (
writeStableRootRuntimeAliases,writeLegacyRootRuntimeCompatAliases) now build alias source via a shared helper: if the target chunk contains a default export, the alias additionally emitsexport { default } from .... Aliases for targets without a default are byte-identical to before. Conservative detection (anchored export-statement patterns) so aliases never claim adefaulttheir target lacks (which would be a hardSyntaxErrorat import time).User Impact
defaultlazy-imports.Evidence
[email protected]is a bare star re-export whose target's only export isdefault; the reconcile caller destructuresdefault(see issue for excerpts + correction note).as defaultfalse-positives on string content in minified chunks — appendingexport { default }to an alias whose target lacks one is a hardSyntaxErrorat import (we hit exactly this on our deployment with a hasty local hotfix). This PR's anchored export-statement pattern was verified against all 7 real shipped chunks: no false positives, correct match on the compaction chunk.pnpm exec vitest run test/scripts/runtime-postbuild.test.ts→ 29 passed (29).Note for maintainers
scripts/stage-bundled-plugin-runtime.mjsemits the same bareexport * frompattern for plugin runtime staging — I have not verified whether any plugin runtime target exportsdefault; flagging as a possible sibling rather than expanding this PR's scope.Maintainer follow-up
Maintainer review found and repaired two same-surface edge cases before landing:
export { default } from ...aliases now propagate their default through legacy compatibility aliases;Additional evidence on the repaired branch:
node scripts/run-vitest.mjs test/scripts/runtime-postbuild.test.ts— 29/29 passed, including import-level stable/legacy and repeated-run coverage;tbx_01kwn4h68kbccmctj63t0s6h23:pnpm check:changedandpnpm buildpassed;8f29406f58df15538052ebaa76ff764e17771be0— no actionable findings.