fix(server): build native dependencies before activating updates #10687
main fromrefs/pull/10687/head·opened View on GitHubNote
🤖 GPT-6 on behalf of Oliver
ELI5#
Check that an update's terminal dependency works before switching to it.
Problem#
npm 12 can exit successfully while skipping unapproved native builds. T3 then marks the runtime complete, but the new server fails to start because node-pty is missing its native binary.
Fix#
Write staging-local build approvals for node-pty and msgpackr-extract. Load the candidate's node-pty with the service's Node executable before publishing or reusing the runtime. This covers local service installation and remote updates, preserving the running service on failure.
Validation: 54 focused tests, targeted lint, and server typecheck pass. Isolated npm 12 fixtures confirmed approved scripts run while unrelated scripts stay blocked; npm 11 accepts the manifest. Independent review found no actionable issues.
UI Changes#
Before: no visual changes.
After: no visual changes.
Made with GPT-6 in Codex.
Note
Probe node-pty with host Node executable before activating pinned runtime updates#
- Pinned-runtime installation now requires the candidate runtime to successfully load
node-ptyvia the host NodeexecPathbefore the completion sentinel is written or the staged directory is published; npm installs also receive a project manifest granting build approval fornode-ptyandmsgpackr-extract. bootService.tsandselfUpdate.tspass the host executable path intoensurePinnedRuntimeInstalledso the probe runs before server preflight and launcher handoff.- Tests across
bootService.test.ts,pinnedRuntime.test.ts, andselfUpdate.test.tscover the probe success and failure paths, including verification that a failed probe leaves the running service untouched. - Behavioral Change: cached and newly staged runtimes that fail the
node-ptyload probe now produce aPinnedRuntimeInstallErrorand leave no final installation, whereas previously a runtime with missing or unusable native binaries could be accepted.
Summary by CodeRabbit#
- Bug Fixes
- Pinned runtime installations now verify that required native modules load successfully before completing.
- Runtime updates and installations report a clear failure when native module loading is unavailable.
- Reinstall attempts preserve the currently running service when validation fails, avoiding unnecessary stops or restarts.
- Improved compatibility with environments requiring explicit approval for native module builds.
- Failed runtime preparation no longer interrupts an existing service unnecessarily.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
447fd9a5-0ceb-4b8a-bf41-7db259456f4a📥 Commits
Reviewing files that changed from the base of the PR and between e16b8b059c9f5ff6dfed1addecffb831c6aee043 and de5b70d4354785f34461c1fd54f8ad961bf07d33.
📒 Files selected for processing (6)
apps/server/src/cloud/bootService.test.tsapps/server/src/cloud/bootService.tsapps/server/src/cloud/pinnedRuntime.test.tsapps/server/src/cloud/pinnedRuntime.tsapps/server/src/cloud/selfUpdate.test.tsapps/server/src/cloud/selfUpdate.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- apps/server/src/cloud/selfUpdate.ts
- apps/server/src/cloud/pinnedRuntime.ts
- apps/server/src/cloud/bootService.ts
- apps/server/src/cloud/pinnedRuntime.test.ts
- apps/server/src/cloud/bootService.test.ts
- apps/server/src/cloud/selfUpdate.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough#
The pinned runtime installation now approves required native builds and verifies that
node-ptyloads with the host Node executable. Boot installation and self-update pass this executable path, with tests covering successful, failed, cached, staged, and update scenarios.Changes#
Pinned runtime validation
Layer / File(s) Summary Runtime validation and native build approvals
apps/server/src/cloud/pinnedRuntime.ts,apps/server/src/cloud/pinnedRuntime.test.tsensurePinnedRuntimeInstallednow receivesexecPath, writes npm native build approvals, and validatesnode-ptybefore accepting a runtime. Tests cover native module availability, manifest contents, and updated command sequences.Boot and self-update integration
apps/server/src/cloud/bootService.ts,apps/server/src/cloud/selfUpdate.ts,apps/server/src/cloud/bootService.test.ts,apps/server/src/cloud/selfUpdate.test.tsBoot installation and self-update pass the host executable path. Tests verify failed native module loading preserves the active runtime and prevents update handoff. Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Merge Risk: ⚪ Minimal · up to
de5b7The runtime activation flow now validates required native dependencies before replacing or reusing a server runtime, with no current merge-blocking risk identified.
Sequence Diagram(s)#
sequenceDiagram participant BootOrUpdate participant ensurePinnedRuntimeInstalled participant validatePinnedRuntime participant HostNode participant node-pty BootOrUpdate->>ensurePinnedRuntimeInstalled: provide host execPath ensurePinnedRuntimeInstalled->>validatePinnedRuntime: validate staged or cached runtime validatePinnedRuntime->>HostNode: require node-pty with CommonJS check HostNode->>node-pty: load native module node-pty-->>HostNode: success or load error validatePinnedRuntime-->>ensurePinnedRuntimeInstalled: validation result ensurePinnedRuntimeInstalled-->>BootOrUpdate: prepared runtime or error🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Title check ✅ Passed The title clearly and concisely describes the main change: building native dependencies before activating server updates. Description check ✅ Passed The description explains the problem, the fix, validation, and the absence of UI changes. It does not use the template's exact "What Changed" and "Why" headings, and it omits the checklist, but it pro… Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6… Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.Note
GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
Note
🤖 GPT-6 on behalf of Oliver
Closing as superseded by #11510, which is already in both
mainandt3code/codex-turn-mapping.This PR adds npm build approvals and a Node-based
node-ptyprobe to the old npm-managed pinned runtime. Pinned runtimes now come exclusively from release archives, with checksum verification and staged executable preflight before activation. The npm install path this change fixes no longer exists. Retargeting it would restore obsolete updater assumptions.flamboh(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Approved at
49f6449Macroscope's review found this PR approvable — This is a contained server update bug fix: native dependencies are approved and verified before a runtime is published or handed off, while failed validation leaves the existing service untouched. The affected production logic is localized and supported by tests for both successful and failed native-module loading.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).