Skip to content

perf(build): add identical runtime-only server builds - #169039

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-release-build-skip-dts-20260919
Oct 11, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-release-build-skip-dts-20260919

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Server deployments compile TypeScript declarations that the Gateway never consumes. On the isolated comparison host, the normal build took 338.74 seconds, including 147.1 seconds in the unified declaration writer.

User Impact

pnpm build:runtime builds the runtime JavaScript, plugins, Control UI, and metadata without declarations. The Team deployment controller selects the same mode with OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build, preserving migration/preparation of historical checkouts that predate the new package script. The measured build falls to 110.07 seconds: 3.08× faster, saving 228.67 seconds (67.5%).

Development/package builds retain declarations and their validation. CI still owns typechecking. Source updates already select the runtime-only graph through their existing update marker; their lifecycle, explicit declaration override, and rollback behavior are unchanged. No production server was contacted or changed.

Why This Change Was Made

Both build modes now finish with the same runtime-only compiler pass. Full builds first produce/cache declarations, then that final pass replaces package JavaScript while retaining declarations. This matters because combining declarations with runtime modules causes the bundler to share helper chunks differently: merely skipping declarations changed AI and gateway-protocol JavaScript. One final runtime pass removes that discrepancy and replaces the separate unified-only step, preserving its concurrency limit.

The runtime profile reuses the existing complete runtime graph. Production/tooling LOC is −14 overall; no dependency or configuration option is added.

Evidence

Measured on the pre-rebase candidate at base 390f0f0acb98; the final branch retains main’s later behavior-preserving build-plan refactor. Same Hetzner Crabbox lease, cbx_c3b0345b93ee (ccx33, Linux, Node 24.21.0), pinned source and build identity, clean output roots, OPENCLAW_BUILD_CACHE=0:

Build Wall time Generated declarations
pnpm build 338.74 s 577
pnpm build:runtime 110.07 s 0

All 19,019 JavaScript files are byte-identical. All 22,091 runtime artifacts are byte-identical after excluding declaration files and the two input-tracking stamps. Full compilation and the SDK declaration gate passed.

  • The regression fails against the original builder (Unknown build profile: runtime) and passes with the change.
  • pnpm test test/scripts/build-all.test.ts --maxWorkers=1: 55 passed, 29.93 s wall time. No meaningful new per-test cost; the added cases exercise profile selection and the final compiler boundary.
  • Build/tsdown/declaration/updater siblings: 222 passed, four platform-dependent skips. The affected ownership file was rechecked after the final change: two passed.
  • Controller preparation tests: eight passed, including a regression that rejects the previous PR head’s unsupported historical build:runtime dispatch and accepts the existing build script plus declaration-skip selector.
  • After migrating the declaration fixture, all five focused build/declaration files passed: 100 tests and four platform skips, 45.76 s wall time. Existing runtime-output assertions remain intact.
  • Independent review completed; the two actionable compatibility/fixture findings are fixed. A suspected loss of package declarations was rejected: skip-mode cleanup explicitly preserves declarations, the child compiler receives --no-clean, and the full build retained all 577 declaration files. The rebase preserves main’s declaration-step helper. The follow-up also migrates the unified declaration fixture to the shared runtime step while keeping its runtime-artifact assertions.
  • Runtime-only package entry probes passed for AI, agent-core, and gateway-client. The isolated Gateway passed /readyz and /healthz on loopback; it was stopped after the probe.
  • node scripts/check-changed.mjs -- <the five changed paths> passed its format, boundary, declaration, dead-export, script-typecheck, and test-root-typecheck checks. Its single lint finding was a shadowed callback parameter; the parameter was renamed and node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.scripts.json scripts passed with zero warnings/errors in run run_2e0a4ad2a2454e30647927826408403d.

Selected remote proof runs (all task-owned and isolated):

Run Provider / lease Result
run_32f966179d85a7ce365dc5ba1380c52c Hetzner / cbx_c3b0345b93ee Both timed builds succeeded; all runtime artifacts matched.
run_bf821f97a65e6b1d1a53b45f7731989c Hetzner / cbx_c3b0345b93ee Package entry points and Gateway readiness/liveness passed; every changed-file check except the subsequently fixed callback-shadow lint passed.
run_2e0a4ad2a2454e30647927826408403d Hetzner / cbx_c3b0345b93ee Full script lint passed with zero errors/warnings after the callback rename.

CI on the first PR head passed the build, lint, types, and build/declaration checks. Seven unrelated shards failed. The same eight affected files failed on unchanged main ac8a432aafa73674f8e41ab2132860d8901c6dcb, using the CI runner on AWS lease cbx_bacd0cee6a65 (run_13aa434700a9a8996eb29f88fd6fb141). The worker-wire cases were rechecked with a trusted temporary directory in run_2d20f0a09dd1fac50e3a2f682f049cf6, reproducing their CI failures; that run also reproduced the unrelated unused exports reported by the local changed-file scan. The failing files are unchanged between the CI baseline and the qualified main snapshot.

The controller and fixture follow-up passed its focused tests, formatting, boundaries, and typecheck in run_29d7981f28c587dba1f8aec27f59adf3; only the independently reproduced unused-export scan remained red. No CI reruns or update-branch requests were used to chase green.

Final head 4fee81740d78fb8639e2a4b27db7d49cf42fe9f7 passed the CI build, lint, types, and affected build/declaration tests. Its five red test shards are independently baseline-qualified. The remaining memory-fallback and both Telegram cases reproduce on the exact CI main parent 68ee251419d706a1950b2ef7077d69b68daa12f5 in Hetzner run run_14b7970a2f3276174bc09a8ae396995b (lease cbx_6bba415b0e10). The other failures reproduce in the earlier unchanged-main qualification above. No failing source/test path is modified by this PR. Landing uses the explicitly authorized inherited-CI exception.

Merged as 3a0db8a3a05283c21600bc39e2772bf1432f7d0e under the authorized inherited-CI exception. Native verification accepted the exact final head, tested merge, five independently qualified failing jobs, security review, and writer authority before the pinned squash merge. All task-owned compute leases are stopped.

Use one final runtime pass for all JavaScript so declaration helpers cannot change package chunk topology. Expose build:runtime and select it in the Team deploy controller while retaining full declaration gates.
@clawsweeper

clawsweeper Bot commented Oct 11, 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: S labels Oct 11, 2026
@steipete
steipete marked this pull request as ready for review October 11, 2026 09:32
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds a runtime-only build command and makes full and runtime-only builds share their final JavaScript compilation pass.

Example: Build a Linux server checkout with Node 24.21.0.

  • Before: The reported full build generated 577 declaration files alongside runtime artifacts.
  • After: The reported runtime-only build generated no declarations and matched all 19,019 JavaScript files from the full build.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, coherent, and supported by reported shipped-entry-point results; both prior defects are fixed, while latest-head CI attribution remains incomplete.
Proof confidence 🐚 platinum hermit (4/6) The host identifies this as maintainer-authored, outside the ordinary contributor proof gate; supplied results cover real build commands, artifact comparison, package imports, and isolated Gateway health, with corrective regressions reported after the follow-up.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Server operators spend build time compiling declarations their Gateway does not consume.
Reason: The maintainer-authored direction has concrete measured value, reuses the existing runtime-only contract, and preserves development/package declaration gates.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. It provides useful build savings beyond current main, and both previous findings are fixed. No actionable introduced defect remains; required CI has not cleared.

Priority: P2
Reviewed head: 4fee81740d78fb8639e2a4b27db7d49cf42fe9f7

Before merge

None.

Findings

None.

Agent review details

How this fits together

The build orchestrator turns source, plugin assets, and build identity into package JavaScript, Gateway artifacts, Control UI assets, metadata, and optional declarations; deployment preparation consumes those outputs.

flowchart TD
  A[Source and plugin assets] --> B[Build profile selection]
  B --> C[Optional declaration compilation]
  B --> D[Shared runtime compiler]
  C --> D
  D --> E[Plugin assets and runtime postbuild]
  E --> F[Control UI and metadata]
  F --> G[Server deployment artifacts]
Loading

Technical review

Best possible solution:

Land the shared runtime pass and compatible historical build selector after required CI clears or inherited failures receive supported attribution.

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

Source confirms that normal builds compile declarations and current main lacks the new profile; the PR supplies isolated build measurements, while this review executed no target code.

Is this the best way to solve the issue?

The change fits the existing build owner, preserves declaration validation and memory limits, and fixes runtime-output differences at the compiler boundary.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Full-build compiler sequencing changes intended behavior with a stated reason (d783961: Independent declaration groups reduced repeated compilation while rebuilding runtime JavaScript.)
  • Runtime-only profile selection keeps the original intent (2eecf3d: Proof Gateways consume runtime artifacts rather than declarations; the uncached runtime graph avoids declaration-cache contamination.)
  • Unified runtime concurrency keeps the original intent (8e6f084: Serial bundle admission reduces native allocation peaks on memory-constrained build hosts.)
  • Deployment preparation keeps the original intent (072215c: The installed controller builds and validates frozen official source targets under the existing deployment owner.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduction and resolved prior findings: The introduced diff adds the shared runtime pass. The follow-up replaces historical build:runtime dispatch with the existing build script plus declaration-skip selector, and migrates the fixture to the replacement runtime step. (scripts/build-all.mts:104, 4fee81740d78)
  • Declaration retention: Skip-mode cleanup protects existing generated declarations, and the child compiler receives --no-clean; the final runtime pass therefore does not discard the full build's declaration outputs. (scripts/tsdown-build.mts:222, 4fee81740d78)
  • Current-main distinction: Fetched main retains the separate unified runtime step and has no build:runtime package script; its existing environment selector already supports runtime-only builds, but does not provide this PR's shared final compiler pass. (package.json:1697, d1618ccd0b27)
  • Supplied behavior results: The complete PR body reports isolated real CLI builds, matching runtime artifacts, retained full-build declarations, package entry probes, and Gateway readiness/liveness; the author discussion confirms both corrective regressions passed. (4fee81740d78)
  • Existing runtime-only contract: perf(mantis): build proof lanes runtime-only #128007 established the environment-selected complete runtime graph and declaration-cache separation; this PR reuses that owner rather than adding a competing builder. (scripts/build-all.mts:319, 2eecf3d3f2cc)
  • Memory policy preserved: fix(build): serialize unified tsdown runtime bundles to cap peak memory #157739 serialized unified bundles to reduce native memory peaks; the replacement runtime pass retains concurrency 1. (scripts/build-all.mts:106, 8e6f08486b51)

Likely related people:

  • Peter Steinberger: Raw commit 9ef5fdf adds scripts/build-all.mts:87 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9ef5fdf8b6ef; files: scripts/build-all.mts)

PR surface

Tests +45, Docs +5, Config +1, Other -15. Total +36 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 55 10 +45
Docs 1 5 0 +5
Config 1 1 0 +1
Generated 0 0 0 0
Other 2 45 60 -15
Total 7 106 70 +36

Review metrics

Metric Value Why it matters
Production versus test changes Production/tooling +46/-60; tests/support +55/-10 Shared compiler orchestration removes net production code; test growth covers profile selection and historical deployment compatibility.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a useful server-build performance improvement without an established urgent runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T09:40:18.297Z sha 9a32b30 :: needs changes before merge. :: [P1] Preserve builds of historical controller targets | [P2] Migrate the declaration fixture's retired runtime-step selector

Reviewed October 11, 2026, 7:40 AM ET / 11:40 UTC (Revision 2).

Select runtime-only output through the existing environment contract when the controller builds historical source. Exercise the replacement runtime compiler in the unified declaration fixture and cover historical package-script dispatch.
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the two source findings in 4fee817:

  • Historical targets keep pnpm build and select runtime-only output with the existing OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 contract. The added historical-package regression fails on the previous PR head and passes now (8 controller tests passed).
  • The declaration fixture selects the shared runtime step and constrains it to the unified graph that the fixture materializes. Its existing runtime-JavaScript, cache, and declaration assertions remain intact. All 5 focused files passed: 100 tests, 4 platform skips.

The package-declaration retention concern is not a defect: cleanTsdownOutputRoots preserves generated declarations in skip mode, and the wrapper passes --no-clean to the child compiler. The measured full build retained 577 declarations, equal to the original count, and passed the SDK declaration gate. Both modes produced byte-identical JavaScript and runtime artifacts.

I also qualified the first head’s unrelated CI failures against unchanged main ac8a432aafa73674f8e41ab2132860d8901c6dcb, using AWS Crabbox cbx_bacd0cee6a65 and the same CI test runner. The affected files reproduce the following failures:

  • extensions/discord/src/subagent-hooks.test.ts: missing listThreadBindingsBySessionKeyAsync mock export and its waiting test timeout.
  • extensions/codex/registration-imports.test.ts: the same two forbidden eager import paths.
  • test/scripts/run-vitest-state-cleanup.test.ts: unresolved custom test/non-isolated-runner.ts runner path.
  • extensions/codex/src/app-server/run-attempt.steering{,-settlement}.test.ts: steering settlement and database cleanup failures/timeouts.
  • test/e2e/qa-lab/runtime/node-worker-launch-wire.e2e.test.ts and paired-node-worker-lifecycle-wire.e2e.test.ts: worker turns return error where the fixtures expect ok.
  • test/e2e/qa-lab/runtime/telegram-model-picker-prepared-gateway.e2e.test.ts: CLI invocation assertion mismatch.

The worker-wire cases were rechecked under a trusted /var/tmp fixture root to rule out an earlier unrelated permission refusal. Qualification runs: run_13aa434700a9a8996eb29f88fd6fb141 and run_2d20f0a09dd1fac50e3a2f682f049cf6. The latter also reproduces the unrelated main unused-export findings. None of these source/test paths is changed by this PR. No CI rerun or update-branch request was used to chase green.

@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Final-head CI 38135854007 has five baseline-qualified failing shards; its build, lint, type, and affected build/declaration tests passed. No code-review changes remain.

The newly observed memory fallback assertion and both Telegram failures reproduce on the exact CI main parent 68ee251419d706a1950b2ef7077d69b68daa12f5 in run_14b7970a2f3276174bc09a8ae396995b (Hetzner cbx_6bba415b0e10). This includes the model-identity mismatch assertion and the Telegram retained-attempt counter mismatch. The Discord, Codex settlement/teardown, and worker-launch failures are covered by the unchanged-main qualifications in the preceding comment.

All five failing source/test paths are unchanged by this PR. The native inherited-CI verifier passed for exact head 4fee81740d78fb8639e2a4b27db7d49cf42fe9f7, its inspected merge checkout, the five job logs, baseline evidence, security review, and writer authority. Landing follows the explicitly authorized inherited-failure rule; no failed CI jobs were rerun to chase green. All task-owned compute leases are stopped.

@steipete
steipete merged commit 3a0db8a into main Oct 11, 2026
235 of 244 checks passed
@steipete
steipete deleted the steipete/perf-micro-release-build-skip-dts-20260919 branch October 11, 2026 12:36
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
* perf(build): add identical runtime-only server builds

Use one final runtime pass for all JavaScript so declaration helpers cannot change package chunk topology. Expose build:runtime and select it in the Team deploy controller while retaining full declaration gates.

* fix(build): preserve historical deploy targets and declaration fixtures

Select runtime-only output through the existing environment contract when the controller builds historical source. Exercise the replacement runtime compiler in the unified declaration fixture and cover historical package-script dispatch.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 19, 2026
First-parent upstream 5ed6a30..cb1b6cd (21 commits, including
openclaw#168999 state query reduction and worker moves, openclaw#169075, af03aa0 ACP
owner settlement, openclaw#168837 plugin metadata/reload ownership, openclaw#168776,
openclaw#168951, openclaw#169039 runtime-only server builds, openclaw#169092 test batch d050,
openclaw#168860 memory index publication writes into workers, openclaw#168991 session
read lifetimes and reconciliation scheduling, openclaw#169091 tool/replay prompt
prefixes, openclaw#168762 Solid chat leaf elements, openclaw#168941).

Conflicts:
- test/vitest/vitest.unit-fast-paths.mjs: upstream stopped forcing the
  two ACP translator files into the fast lane; kept that and our
  reply-turn-admission module-identity entry.
- worker-access inventory: regenerated (634 files, 2429 calls).

openclaw-state-worker-contract.ts auto-merged: upstream's GitHub
publication-source operations next to our continuation custody operations.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 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