Skip to content

fix(build): restore cloud dispatch package import closure - #162485

Closed
steipete wants to merge 1 commit into
mainfrom
codex/prepare-closure
Closed

steipete wants to merge 1 commit into
mainfrom
codex/prepare-closure

Conversation

@steipete

@steipete steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Related: #162288

What Problem This Solves

Fixes cloud worker dispatches failing before enrollment because a package-shipped prepare script imports a source-only Kysely generator.

User Impact

Cloud workers can package the Gateway runtime again while source installs continue generating Kysely declarations. Published installs retain their existing lifecycle behavior. No configuration, schema, protocol, or SDK changes are required; operators need a build containing this fix to replace the affected runtime.

Why This Change Was Made

The static package validator correctly rejected a literal import even though a source-schema guard made it unreachable in published installs. Source preparation now lives in an unshipped entry point, and the existing package-manifest owner selects the self-contained hooks command when preparing a package. The hooks script remains shipped for its cross-platform install contract (introduced in d21abb8).

A cheap PR test reads the actual package allowlist and uses the same import-closure validator as node bootstrap and release packaging. It covers shipped source scripts and launchers without a build; built dist edges remain covered by the full package check. Existing CI policy watches select the test for manifest, launcher, and script changes. Docker dependency-stage copies and install-cache fingerprints follow the new preparation entry point.

Evidence

The reported live evidence was three dispatches on main, through GCP, Hetzner, and AWS, each failing about five seconds after the request:

Node distribution openclaw has an incomplete built import closure; rebuild and restart the Gateway: scripts/prepare-git-hooks.mjs imports missing scripts/generate-kysely-types.mts

Locally, the new regression failed on base 34a0d30 with that exact missing-import diagnostic, then passed after the fix. The validator was not weakened, and no computed import specifiers were added.

  • Focused lifecycle, codegen, validator, cache, workflow, and node-bootstrap tests: 100 passed across eight files, including all 33 node-bootstrap artifact cases.
  • Final pack/cache/workflow followup: 22 passed; 25 unrelated prepack cases excluded by the explicit test filter. The real pnpm pack fixture verifies source preparation executes, the source-only entry is absent from the tarball, and the source manifest is restored. pnpm 12 strips publish lifecycle scripts from its final manifest; the separate prepared-manifest test exercises the hooks-only command.
  • New closure test, standalone with pnpm test test/scripts/package-source-import-closure.test.ts --maxWorkers=1: 1 passed, 64 ms test time, 2.02 s Vitest wall, 5.97 s runner wall. CI timing is pending.
  • Other changed-test costs with one worker: prepare lifecycle 1.383 s (3 cases), workflow cost 0.073 s (20 cases), dependency fingerprint 8.885 s (1 existing case), selected real pack case 21.346 s. The pack test needs an actual package-manager lifecycle to prove command ordering and manifest restoration.
  • Scoped changed checks passed scripts tsgo and all four root-test tsgo shards, script lint, dead-export scans, and repository guards. Changed-test lint initially found existing missing braces; targeted oxlint passed after repair. Explicit fingerprint lint also passed after equivalent whitespace-parser style fixes.
  • Changed-file oxfmt, pinned actionlint on all three touched workflows, zizmor with the repository's configured thresholds, and git diff --check passed. Default-threshold zizmor also reported six existing low-severity local-action syntax suggestions, outside the configured gate.
  • P2 autoreview: local and committed-branch review scoped-clean.

The pack fixture initially exposed a missing copied source entry and an incorrect expectation about pnpm's manifest stripping; both were corrected. One later attempt was interrupted by a concurrent lint temporary-file mutation invalidating the compiler snapshot; the final checks ran sequentially and passed. No product failure was hidden by retries.

No full build or test suite was run under the loaded-host constraint. This proves the shipped source import closure directly and the bootstrap artifact behavior with its existing fixtures; it does not claim a fresh live cloud dispatch. No Gateway was started, stopped, or restarted.

@clawsweeper

clawsweeper Bot commented Oct 1, 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 docker Docker and sandbox tooling size: S labels Oct 1, 2026
@steipete
steipete marked this pull request as ready for review October 1, 2026 06:46
@steipete
steipete enabled auto-merge (squash) October 1, 2026 06:47
@fuller-stack-dev

Copy link
Copy Markdown
Member

Overlap coordination with #162464: that PR fixes cold-checkout typed lint and currently closes this same package import failure by shipping the generator and its direct-run helper. Its actual npm tarball/import-closure check and source-less packaged execution passed; this is focused package proof, not a full build.

The coordinated macOS packaging owner also reported the exact missing-generator diagnostic at 40a5f71399ce7a3d2b01d2e6179e9f16744ce792: native staging failed its tarball check after the JS/UI, Swift and MLX builds, before Bun installation or signing. This is relayed owner evidence; I did not run that Mac package check.

I inspected this PR at 94484e7edadc930802f7f5f35d24ef34a57fa7ac. Separating source preparation from the shipped hooks script removes the need to publish those generator files, and your lifecycle/pack coverage addresses that replacement contract. The typed-lint preparation in #162464 remains necessary independently.

We will recheck this PR before #162464's next publication. If your change has landed, we will remove our two obsolete package entries and the added shipped-generator packaging case, preserving the existing generator regressions. Until then, #162464 retains its proved closure. We are not starting another packaging repair or changing this PR's ownership.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 2:53 AM ET / 06:53 UTC.

ClawSweeper review

What this changes

The PR separates source-only declaration generation from published install preparation and updates Docker, cache inputs, and regression coverage to preserve package import closure.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still contains the package-import failure, and this PR provides a focused repair with no actionable correctness findings. The overlapping packaging work is explicitly coordinated.

Priority: P1
Reviewed head: 94484e7edadc930802f7f5f35d24ef34a57fa7ac

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused package-boundary repair with useful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from the external-contributor proof gate. Reported production-validator, real pack, and lifecycle checks cover the preparation split; a fresh cloud dispatch is explicitly unclaimed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository-admin author is exempt from the external-contributor proof gate. Reported production-validator, real pack, and lifecycle checks cover the preparation split; a fresh cloud dispatch is explicitly unclaimed. No stored-data contract changes.
Evidence reviewed 7 items Pinned introduced change: The merge-base-to-head diff removes the generator import from the shipped hooks script and adds it to an unshipped source preparation entrypoint; the validator itself is unchanged.
Current main still needs the repair: Fetched main still imports generate-kysely-types.mts from prepare-git-hooks.mjs, while its package allowlist ships the hooks script without that generator. The cloud bootstrap owner rejects missing relative imports before distribution.
Existing package owner and compatibility: The existing manifest preparation owner changes only the exact source prepare command to the shipped hooks command. Its existing backup, concurrent-change rejection, and restoration paths remain intact; Docker dependency stages receive both preparation scripts.
Findings None None.
Security None None.

How this fits together

OpenClaw packages its Gateway runtime for published installs and cloud workers. Package validation checks that shipped scripts reference available files before the runtime can be distributed.

flowchart TD
  A[Source checkout] --> B[Source preparation]
  B --> C[Generated declarations]
  A --> D[Package manifest preparation]
  D --> E[Shipped hooks script]
  E --> F[Import closure validation]
  F --> G[Published runtime and cloud workers]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +113, Docs +2, Config +20, Other +19. Total +154 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 118 5 +113
Docs 1 2 0 +2
Config 5 25 5 +20
Generated 0 0 0 0
Other 6 25 6 +19
Total 17 170 16 +154

Review metrics

Metric Value Why it matters
Lifecycle compatibility coverage 3 layouts: source, dependency stage, published These cases exercise the preparation split across the installation boundaries it changes.
Closure regression cost Reported 64 ms test execution; 2.02 s Vitest wall The package-boundary regression checks the actual allowlist without requiring a build.

Technical review

Best possible solution:

Keep source code generation outside the shipped runtime and let the existing package-manifest owner select the self-contained install command.

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

Yes, from source: current main ships a hooks script that imports an omitted generator, and the production package validator rejects that edge. The body reports the matching baseline regression; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Separating source preparation and using the existing manifest owner removes the invalid shipped dependency without weakening validation or publishing unnecessary source tooling.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The reported failure blocks cloud worker dispatch before enrollment across three providers and also blocks native runtime packaging.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified repository-admin author is exempt from the external-contributor proof gate. Reported production-validator, real pack, and lifecycle checks cover the preparation split; a fresh cloud dispatch is explicitly unclaimed. No stored-data contract changes.

Label justifications:

  • P1: The reported failure blocks cloud worker dispatch before enrollment across three providers and also blocks native runtime packaging.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified repository-admin author is exempt from the external-contributor proof gate. Reported production-validator, real pack, and lifecycle checks cover the preparation split; a fresh cloud dispatch is explicitly unclaimed. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff removes the generator import from the shipped hooks script and adds it to an unshipped source preparation entrypoint; the validator itself is unchanged. (scripts/prepare.mjs:9, 94484e7edadc)
  • Current main still needs the repair: Fetched main still imports generate-kysely-types.mts from prepare-git-hooks.mjs, while its package allowlist ships the hooks script without that generator. The cloud bootstrap owner rejects missing relative imports before distribution. (scripts/prepare-git-hooks.mjs:58, 10cf91f150e2)
  • Existing package owner and compatibility: The existing manifest preparation owner changes only the exact source prepare command to the shipped hooks command. Its existing backup, concurrent-change rejection, and restoration paths remain intact; Docker dependency stages receive both preparation scripts. (scripts/package-manifest.mjs:20, 94484e7edadc)
  • Focused regression coverage: The new lifecycle cases execute source, dependency-stage, and prepared published layouts. The closure regression reads the actual package allowlist and uses the production validator; the existing real pnpm pack case checks exclusion of source preparation and restoration of the original manifest. The body reports baseline failure and passing focused checks; this review executed no tests. (test/scripts/prepare.test.ts:11, 94484e7edadc)
  • Overlap coordination: The member comment at fix(build): restore cloud dispatch package import closure #162485 (comment) confirms that test: cover packaged Kysely scripts and update phase reporting #162464 retains an independent typed-lint repair and will remove its obsolete generator packaging entries after this repair lands. The related Mac packaging attempt reported the same missing-generator diagnostic. (94484e7edadc)
  • Prior merged area history: GitHub commit patches verify prior hook-preservation work by steipete and the original cross-platform hooks script by vincentkoc. Local feature logs also identify steipete's earlier package-manifest work. Some deeper blame, parent-diff, and tag traversal attempts failed on unavailable objects with HTTP 403; bounded GitHub reads supplied the relevant patches instead. (scripts/prepare-git-hooks.mjs:42, 98bb2591c7d3)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded. main fixed the same #162288 regression (a source-only Kysely import in the package-shipped prepare script, which failed every cloud worker bootstrap at the node distribution's import-closure check) another way:

  • 98421de ships the generator's runtime closure (scripts/generate-kysely-types.mts, scripts/lib/direct-run.mjs) and adds eager-import-closure.test.ts › "keeps packaged scripts closed over runtime imports". That is a PR-time guard over every packaged scripts/ file, dynamic imports included, which matches the guard this PR proposed.
  • 83e4755 completes the source-only preparation path in prepare-git-hooks.mjs.

The only coverage this PR would have added beyond that is the root .mjs launchers (openclaw.mjs, node-*.mjs, and so on) through the exact bootstrap validator. That's not worth a second, competing guard; it can be folded into the existing test if it's ever needed.

For context, the update-cli.windows-lifecycle failure in this PR's CI also failed on main (bisected to #162345) and is fixed on main by 9863e3f.

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

Labels

docker Docker and sandbox tooling P1 High-priority user-facing bug, regression, or broken workflow. 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.

2 participants