Skip to content

feat(standalone): experimental AOT build modes - #183224

Merged
steipete merged 4 commits into
mainfrom
steipete/aot-rd-P0-latest
Oct 25, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/aot-rd-P0-latest

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Related: #183143

What Problem This Solves

The standalone builder needs a reproducible way to compile original TypeScript and select experimental AOT compiler controls without carrying a separate application patch stack.

User Impact

Developers can select --aot-source, trimming, function-source retention, and string-code-generation restrictions with an AOT-capable Bun. JIT and bytecode keep their full emitted-module inventory, and emitted-JavaScript AOT retains --compile-aot. These modes are experimental, leave the production Bun pin unchanged, and require separate per-platform runtime/signing qualification before shipping.

Why This Change Was Made

Build configurations now own source-to-emitted identities, including isolated plugins and postbuild rewrites. The source bridge preserves types, package scopes, and named entry contracts while consuming current worker manifests, WASM inventory, plugin loading, native resources, and lazy metadata tables. It refreshes the complete lazy lookup expression after source discovery.

Source AOT rejects --support-output before staging: its JIT companion would need another discovery compilation after final aliases are known. Build an independent JIT control from the same commit instead. Existing emitted-JavaScript AOT support companions remain supported.

The integration preserves main's content-derived build identity and relative WASM imports from #183179. The TS AOT callback shares the same resource and provenance owner as emitted-JavaScript builds.

Source context identities normalize checkout-contained absolute alias, cwd, and string-tsconfig paths before hashing. Compiler options and recorded semantic inputs remain unchanged; external paths, query suffixes, and different configuration owners keep their distinct semantics.

Evidence

  • Current-main integration: 56 metadata tests and 32 native-resource/data/worker tests pass.
  • Source bridge: 80 tests across ten files; build-contract/support: 62 pass. A real-loader regression fails before and passes after the public-manifest fix.
  • Qualified compiler host: all 21,011 current-main runtime TypeScript files parse with zero failures. Actual source loading resolves 2,097 named entries and all 150 packaged-plugin worker targets.
  • Real tsdown configuration guard covers 73 runtime configurations, including three plain-worker configurations. Direct before/after driver proof preserves lazy companions in emitted-JS modes.
  • Scoped script/test lint, formatting, docs syntax, tooling-test types, and independent P0–P2 review pass. Exact-head PR CI is the broad landing gate.

Native artifact smoke/signing qualification is tracked separately; these source checks do not establish macOS or Linux shipping readiness.

The relocated-checkout regression fails on the preceding head for context IDs, semantic hashes, and embedded entry paths, then passes with the source-owner correction. All 69 affected graph, entry, module-URL, and native-resource tests pass, as do both scripts and tooling test type-check scopes. This establishes stable source inputs for that case; full native executable reproducibility remains a separate qualification.

CI follow-up: the original head exposed strict type errors in new test fixtures. The fixtures now use the current tsdown and manifest-worker APIs, and the failing test-scripts type leaf passes. The integration also removes a stale test-only build identity argument after #183179. The focused follow-up passes 95 support/native/contract/WASM tests, 61 source-bridge tests, and six artifact-adapter tests. The application build at the original head completed in 764 seconds. A CodeQL alert on first-newline replacement is addressed with explicit shebang insertion; exact-head CI remains the final gate for the updated branch.

Compile original TypeScript through the existing build entry and worker contracts, retaining native resources and lazy runtime metadata. Keep emitted-JavaScript JIT, bytecode, and AOT behavior; expose experimental trim and string-code-generation controls with explicit compiler capability checks.
@clawsweeper

clawsweeper Bot commented Oct 25, 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 docs Improvements or additions to documentation scripts Repository scripts size: XL labels Oct 25, 2026
@steipete
steipete marked this pull request as ready for review October 25, 2026 03:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T04:45:05.943245Z 5c12cad New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete

Copy link
Copy Markdown
Contributor Author

P7 reproduced a source-bridge identity issue in this head before invoking the compiler: equivalent absolute aliases in two relocated checkouts change both the context directory and semantic identity.

scripts/lib/bun-standalone-source-graph.mjs hashes raw alias/cwd/tsconfig values into context IDs; scripts/lib/bun-standalone-source-entries.mjs separately hashes raw alias values into semantic identity. The real producers use absolute checkout paths for the grapheme and optional-native worker aliases.

Using the actual exported source-entry and graph APIs with identical synthetic TS bytes/config semantics, two roots with @fixture/helper pointing to each root's own src/helper.ts produced 0-cc8e08cde3f7 versus 0-37654ac1cc22, different semantic hashes, and different /$bunfs/root/runtime/.typed-source/.../src/index.ts strings. The no-alias controls both produced 0-11ce041fe94e. Source owner hashes were unchanged by the probe. This demonstrates different compiler inputs; full executable comparison is still pending, and this is not a compiler defect.

A prepared candidate normalizes only identity preimages for checkout-contained absolute alias/cwd/string-tsconfig paths, leaving actual compiler options and recorded semantic inputs untouched. Its relocated-root probe and eight controls pass: changed owned aliases/query suffixes still invalidate identity, external paths retain their semantics, prefix-sibling paths are not mistaken for children, and define/env values are preserved. Integration still needs the owning test/type/lint/review gates. The P0 source tree was not edited because its runtime build is active.

This should be incorporated at the source-bridge owner before claiming TS reproducibility. The independent JS build-ID/WASM-path/local-stamp repair is PR #183179; full-application byte identity remains an explicit P7 qualification step.

Comment thread scripts/build-bun-standalone.mjs Fixed
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR adds original-TypeScript AOT compilation and experimental compiler controls to the standalone builder.

Example: A packager runs bun scripts/build-bun-standalone.mjs ./standalone-typed --aot-source.

  • Before: The builder rejects --aot-source and supports AOT compilation of emitted JavaScript.
  • After: The builder resolves original TypeScript through existing build configurations and compiles it with an AOT-capable Bun.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful owner-directed experimental work with meaningful source-boundary coverage, but a confirmed build-identity defect remains.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored experimental PR is outside the ordinary contributor proof gate; supplied evidence exercises source parsing, loading, transformations, and configuration contracts, while native artifact and signing qualification is explicitly separate.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Packagers cannot reproducibly compile original TypeScript or select the experimental AOT controls through the maintained standalone builder.
Reason: The feature-history owner authored this direction, and the implementation integrates the experiment with existing packaging owners while explicitly separating shipping qualification.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the experimental direction is owner-approved and the previous finding is fixed, but typed-source changes can still receive an unchanged build identity.

Priority: P2
Reviewed head: 5c12cad76d6c43022df67dff14b499601e2e1f16

Before merge

  • Include typed compiler inputs in the build identity (P2) - With the runtime commit and other build facts fixed, changing identity(value: number): number to identity(value: string): string can leave discovery JavaScript unchanged while changing the TypeScript consumed by this callback. compileStandaloneArtifacts hashes only compiledEntries and resources, and receives none of the original/transformed source hashes already recorded by sourceGraph. Both inputs therefore receive the same build ID and bundled-plugin fingerprint despite different native compiler inputs, as the author's discussion probe also demonstrates. Pass a stable, sorted typed-input digest into the existing identity owner before stamping, preserving checkout relocation stability and emitted-JavaScript support identities. This omission appeared with the shared-identity integration after the earlier reviewed head.

Findings

  • [P2] Include typed compiler inputs in the build identity — scripts/build-bun-standalone.mjs:1021-1024

Tests

  • Low-value test test/scripts/bun-standalone-contract.test.ts: The added default-mode and plugin-list groups repeat cases already covered by the existing option tables; consolidate their genuinely new ordering and rejection cases into those tables.
  • Missing end-to-end proof: The supplied source checks do not demonstrate an exact-head native --aot-source executable exercising the new compiler controls, and no regression currently checks typed-input build-ID invalidation.
Agent review details

How this fits together

The standalone builder consumes a completed runtime build, source files, plugin selection, and compiler options, then produces an executable, resource sidecar, and provenance manifest.

flowchart TD
  A[Build configurations and TypeScript] --> B[Source graph and transforms]
  C[Completed runtime and resources] --> B
  B --> D[JavaScript discovery graph]
  D --> E[Shared build identity]
  B --> F[Native AOT compilation]
  E --> F
  F --> G[Executable sidecar and manifest]
Loading

Technical review

Best possible solution:

Include stable typed-source and semantic-input digests in the existing shared build identity before stamping the source AOT artifact.

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

The source shows the identity omission, and the author's reduced production-API probe demonstrates equal build IDs for different typed inputs; this review did not execute code or establish native binary differences.

Is this the best way to solve the issue?

Reusing build configurations, resource planning, and the shared identity owner is appropriate, but the identity must cover every input consumed by native compilation.

Full review comments:

  • [P2] Include typed compiler inputs in the build identity — scripts/build-bun-standalone.mjs:1021-1024
    With the runtime commit and other build facts fixed, changing identity(value: number): number to identity(value: string): string can leave discovery JavaScript unchanged while changing the TypeScript consumed by this callback. compileStandaloneArtifacts hashes only compiledEntries and resources, and receives none of the original/transformed source hashes already recorded by sourceGraph. Both inputs therefore receive the same build ID and bundled-plugin fingerprint despite different native compiler inputs, as the author's discussion probe also demonstrates. Pass a stable, sorted typed-input digest into the existing identity owner before stamping, preserving checkout relocation stability and emitted-JavaScript support identities. This omission appeared with the shared-identity integration after the earlier reviewed head.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 33d229b35cf2.

Provenance checked

  • Standalone compilation modes and artifact contract keeps the original intent (7c6b8bc: Provide relocatable standalone executables with explicit compiler modes, provenance, sidecars, and whole-artifact updates.)
  • Native resources, image metadata, and sidecar pruning keeps the original intent (9df2906: Embed executable modules while retaining builder-owned disk resources and native dependencies.)
  • Matched JIT support artifacts changes intended behavior with a stated reason (44c7171: Produce a debugging companion from the same prepared graph and provenance.)
  • Content-derived build identity keeps the original intent (cacc271: Identical prepared compiler inputs should share identity, while compiled-code and resource changes invalidate it; the new typed-input omission is listed as a finding.)
  • Plugin runtime build configuration keeps the original intent (87ecc61: Keep one selected plugin-output plan and preserve published runtime capabilities while avoiding redundant packaging work.)
  • Portable worker composition and dependency resolution keeps the original intent (e572c0c: Preserve real npm WebSocket and worker runtime behavior under Bun.)
  • Embedded secret-provider entrypoint handling keeps the original intent (57f6d20: The runtime owner already recognizes embedded entrypoints before disk admission, allowing the obsolete build-time secret-entrypoint adapter to be removed.)
  • Lazy routing tables keeps the original intent (8ae44f9: Avoid eagerly allocating large routing and metadata dictionaries in every worker.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test test/scripts/bun-standalone-source-graph.test.ts test/scripts/bun-standalone-support.test.ts --maxWorkers=1
  • pnpm test test/scripts/bun-standalone-source-entries.test.ts test/scripts/bun-standalone-artifacts.test.ts test/scripts/bun-standalone-wasm.test.ts --maxWorkers=1
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.tooling.json --incremental
  • pnpm tsgo:scripts
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7c6b8bc adds scripts/build-bun-standalone.mjs:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7c6b8bcfcc99; files: scripts/build-bun-standalone.mjs)

PR surface

Tests +4288, Docs +49, Other +3529. Total +7866 across 53 files. Added test files: 12.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 23 4467 179 +4288
Docs 1 56 7 +49
Config 0 0 0 0
Generated 0 0 0 0
Other 29 3866 337 +3529
Total 53 8389 523 +7866

Review metrics

Metric Value Why it matters
New builder options 7 Adds --aot-source and six experimental compiler controls; all remain opt-in and leave the production compiler pin unchanged.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: The feature and identity defect affect optional experimental standalone builds, with limited impact on ordinary installations.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish. Replaced prior rating: 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-25T04:18:20.587Z sha a59096b :: needs changes before merge. :: [P2] Normalize checkout-local paths before hashing source identities

Reviewed October 25, 2026, 12:48 AM ET / 04:48 UTC (Revision 2).

@steipete

steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

P7 found a second original-TS build-identity issue at current head 64111a1abffbb6290d05d5b306f88f1e130f5af7: compileStandaloneArtifacts hashes the emitted JS graph, but the compileAot callback also consumes the original typed source. The recorded original/transformed TS digests from sourceGraph.manifest() are not passed into that identity.

A reduced probe using the actual source-graph and shared compilation APIs compares these two inputs:

export function identity(value: number): number { return value; }
export function identity(value: string): string { return value; }

Node type erasure produces identical JS bytes. The actual graph records different originalSha256 and compiledSourceSha256, but both calls receive the same module-graph digest and build ID 2d6c1dbd5011e8d7b39aefd0ebc0fed266c3575c74c098d83d5bc8fdfb5d9505. The synthetic compilation callback confirms it consumes different original bytes under that same identity. This is a source-input omission proof; no native binary inequality or runtime failure is claimed.

The immutable bundled-plugin fingerprint uses that build ID. The original-source digest therefore needs to participate before stamping, using stable checkout-relative names/config identity and sorted original/transformed source hashes. Retain the emitted-JS digest and same-ID standard/support contract. This is separate from the previously reported absolute-alias relocation defect; P7 has a reviewed-path candidate for that defect in progress and can carry the owner repair after this port lands. No changes were made to the frozen P0 build checkout or artifacts.

Follow-up: the focused five-file repair is now validated against the repaired owner and the adopted path fix. The actual support-owner regression fails at the expected unchanged build ID before the repair; all 78 affected tests, both required test type leaves, scoped lint and formatting pass afterward. Independent review is scoped-clean at P0–P2. The digest covers recorded runtime graph inputs and normalized contexts; declarations/type-only/config bytes outside that graph remain outside this proof. P7 is retaining this as a follow-up to the source port rather than opening a duplicate port PR.

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the source-context identity finding in 5c12cad. Checkout-contained absolute alias, cwd, and string-tsconfig paths are normalized only in hash inputs; compiler options and recorded semantic inputs remain unchanged.

The regression fails on the preceding head for context IDs, semantic hashes, and embedded entry paths. With the correction, all 69 affected graph/entry/module-URL/native-resource tests pass, both relevant test type-check scopes pass, scoped lint/formatting pass, and independent review found no actionable issues. External paths, query suffixes, and separate configuration owners retain their distinctions. Full executable reproducibility remains a separate qualification.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 25, 2026
@steipete
steipete merged commit c36710e into main Oct 25, 2026
120 of 122 checks passed
@steipete
steipete deleted the steipete/aot-rd-P0-latest branch October 25, 2026 05:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
* feat(standalone): experimental AOT build modes

Compile original TypeScript through the existing build entry and worker contracts, retaining native resources and lazy runtime metadata. Keep emitted-JavaScript JIT, bytecode, and AOT behavior; expose experimental trim and string-code-generation controls with explicit compiler capability checks.

* test(standalone): remove duplicate metadata fixture binding

* fix(standalone): normalize source context path identities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:feature Preliminary submission classification; full source review pending. docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants