Skip to content

ci(daemon): runtime-launcher protocol ratchet and Node slot marker - #24108

Merged
OrcaWin merged 14 commits into
mainfrom
OrcaWin/node-rt-gates
Oct 1, 2026
Merged

OrcaWin merged 14 commits into
mainfrom
OrcaWin/node-rt-gates

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​279 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​271
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​213 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​185

ELI5

This adds two safety rules for the move from Bun to Node. First, a PR can't change the process that runs the terminal daemon and the daemon's protocol version at the same time. Second, a server install built for Node is labelled so that older Orca clients never mistake it for a broken Bun install.

What Changed

  • R3 ratchet (config/scripts/check-runtime-launcher-protocol-ratchet.mjs, run in the cross-version-wire job):
    • Fails when a PR changes any file in RUNTIME_LAUNCHER_PATHS (the orcad handoff, slot layout, slot runtime selection and daemon host launch) and also changes PROTOCOL_VERSION.
    • The label allow-runtime-launcher-protocol-bump overrides it; the violation is still reported. A new push is needed after adding the label.
  • R5 slot marker:
    • A Node server slot carries .runtime-node containing the runtime's sha256, never .build-target.
    • selectOrcadSlotRuntimeCommand checks for a Node slot first, then Bun (unchanged), then a legacy host-Node install.
    • The runtime is resolved at runtimes/node-<sha>/bin/node. A Node slot never falls back to host Node: it exits 78 if the marker is malformed or the runtime is missing.
    • A test runs a frozen copy of the selector that shipped clients use against a Node slot. It picks host Node and does not exit 78.
  • check-node-runtime-pin.mjs loads the TypeScript pin file without the MODULE_TYPELESS_PACKAGE_JSON warning.

Why

Swapping the runtime (Electron, Bun or Node) isn't a protocol change, so it shouldn't happen in the same PR as one: that is how live terminals get stranded during an upgrade. Old clients already use .build-target to mean "Bun slot, exit 78 if Bun is missing", so Node slots need a marker old clients don't act on.

Linked Issue

Part of the Node runtime plan (compatibility rules R3 and R5). Stacked on OrcaWin/node-rt-phase1, which merges #24087, #24088 and #24089.

Visual Proof

N/A. These are CI checks and remote-host slot selection, with no UI.

Testing

  • 106 tests pass across the ratchet, orcad-remote-runtime, process control, pin checks, PR routing and artifacts. That includes real-git scenarios for the ratchet, and shell-parse coverage for the selector when it is embedded in $(...).

  • pnpm tc and the changed-code gate pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

m4air added 12 commits September 30, 2026 01:42
Lands daemon-protocol-facts.mjs from the Windows update diagnostic branch with a
stricter parser, and adds check-daemon-protocol-crossing.mjs (rule R1): the working
tree must attach the newest release tag's daemon. Rollback crossing is reported only.
Runs in the cross-version-wire job, which already has full tags; tag selection moves
to config/scripts/stable-release-tags.mjs so both use one rule.
The profile preflight parser now takes the expected runtime identity from the
caller (shipped callers pass the pinned Bun identity), and the native
preflight is renamed to orcad-runtime-native-preflight with neutral wording.
… check

Add src/shared/node-runtime-pin.ts (NODE_RUNTIME_PIN, SERVER_TARGETS,
NODE_RUNTIME_ASSETS for all 8 server targets plus the headers tarball),
generated by config/scripts/update-node-runtime-pin.mjs from the nodejs.org
and unofficial-builds SHASUMS. check-node-runtime-pin.mjs verifies, with no
network, that the pin tracks the locked Electron, matches engines.node's
major, and covers exactly SERVER_TARGETS; it runs in the static analysis job.

ORCAD_BUN_TARGETS consumers now read SERVER_TARGETS so there is one target
list; orcad's Bun runtime and build output are unchanged.
# Conflicts:
#	src/shared/orcad-bun-runtime.ts
… protocol

D7.1 R3: hosting orcad or the daemon on another runtime is not a protocol change,
so one PR must not do both. The launcher file list lives in the check script; the
allow-runtime-launcher-protocol-bump label overrides it.
D7.1 R5: a Node slot names its shared runtimes/node-<sha256>/node through
.runtime-node instead of .build-target, so Bun-era clients read it as a legacy
slot rather than exiting 78 on a missing bun-runtime. Nothing builds the marker yet.
check-node-runtime-pin.mjs now requires the pin and takes nodeDistArchiveName from
its own module, so it no longer loads the update script's build graph.
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Modifies CI/CD workflows and build infrastructure across multiple systems.

The PR is not safe to merge until a failed or interrupted /clear can no longer strand queued drafts on the superseded conversation.

Summary

The PR adds the runtime-launcher protocol ratchet and Node slot marker alongside broader stacked changes to relay operations, packaging, and client behavior. Since the previous review, it also changes structured-chat /clear to found an at-rest replacement and adds Claude command discovery at rest.

  • The clear transaction creates the replacement and moves the tab atomically, but queued-draft carry occurs afterward.
  • Claude command discovery adds workspace and account commands and skills, with refresh and bounded scanning that need attention.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["/clear stops source agent"] --> B["Commit replacement record and move tab"]
  B --> C["Copy queued drafts to replacement journal"]
  C --> D["Return committed result"]
  B --> E["Exit or journal-open failure"]
  E --> F["Drafts remain in superseded source journal"]
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The R3 ratchet omits src/main/ssh/orcad-artifact-materializer.ts from RUNTIME_LAUNCHER_PATHS. That file is where a packaged slot's runtime file is actually chosen and placed, so it is squarely in the group the comment calls "orcad slot layout: which runtime file a packaged slot carries" — and it is the file the Node migration will change. Its sibling orcad-bun-runtime-materializer.ts is listed, which makes the omission look accidental.

Reviewed changes

  • R3 ratchet — new check-runtime-launcher-protocol-ratchet.mjs fails a PR that both edits a path in RUNTIME_LAUNCHER_PATHS and changes PROTOCOL_VERSION, with an env/label override that still reports the violation. Wired into the cross-version-wire job, with the checker routed there via pr-code-change-scope.mjs.
  • R5 slot marker — selectOrcadSlotRuntimeCommand now prefers .runtime-node (validated as exactly 64 lowercase hex → runtimes/node-<sha>/bin/node, exit 78 on a malformed marker or missing runtime), then Bun, then legacy host Node.
  • Refactor — nodeDistArchiveName/NODE_DIST_PLATFORMS extracted into node-dist-archive-name.mjs so the offline pin check no longer loads the build graph; the pin's .ts is loaded via createRequire to drop the typeless-package warning.
  • Tests — POSIX selector coverage including a frozen copy of the shipped Bun-era selector run against a Node slot, malformed-marker cases, and the $(...) stop-path embedding; plus git-history tests for the ratchet.

ℹ️ The Node slot marker has no producer in this branch

ORCAD_NODE_RUNTIME_MARKER_FILENAME is read by the selector and written only by the test fixture. Nothing in the branch (or its base) assembles a Node slot: orcad-artifact-materializer.ts still emits bun-runtime + .build-target, and the preflight/install probe still expects Bun. The new selector branch is therefore unreachable in production until the writer lands, so this PR cannot exercise R5 end to end. That is expected for a stacked compatibility-rules PR, but worth confirming the writer is tracked and matches the reader's exact contract.

Technical details
# Node slot marker contract is asserted only by the reader

## Affected sites
- `src/shared/orcad-artifacts.ts:34` — `ORCAD_NODE_RUNTIME_MARKER_FILENAME` defined.
- `src/main/ssh/orcad-remote-runtime.ts:38-45` — reader; requires the marker to be exactly 64 lowercase hex characters after command-substitution strips trailing newlines (so the file must be `<sha256>\n`, no spaces, no CR).
- `src/main/ssh/orcad-artifact-materializer.ts` + `orcad-bun-runtime-materializer.ts` — still build Bun slots; no `.runtime-node` writer.

## Required outcome
- Confirm the marker's producer (sha of the executable, LF-terminated) is implemented in a later stacked PR and that both the sha source and line ending agree with the strict 64-hex validation.
- If the producer is expected in this PR series, add a test that a materialized Node slot is accepted by `selectOrcadSlotRuntimeCommand`.

## Open questions for the human
- Is the `.runtime-node` writer deliberately scoped to a follow-up PR, and does it use `NODE_RUNTIME_ASSETS[target].executableSha256`?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

'src/shared/node-runtime-pin.ts',
'src/main/ssh/orcad-bun-runtime-materializer.ts',
// orcad slot layout: which runtime file a packaged slot carries.
'src/shared/orcad-artifacts.ts',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orcad-artifact-materializer.ts is where a packaged slot's runtime file is chosen and copied into the slot (artifactSources → orcadArtifactFilenames/orcadBunRuntimeFilename, then assembleOrcadArtifact). A future PR that swaps a slot to the Node runtime would change this file, so leaving it out of RUNTIME_LAUNCHER_PATHS gives the R3 gate a hole exactly where the runtime swap happens. Its sibling orcad-bun-runtime-materializer.ts is already listed.

Suggested change
'src/shared/orcad-artifacts.ts',
'src/shared/orcad-artifacts.ts',
'src/main/ssh/orcad-artifact-materializer.ts',

# Conflicts:
#	config/scripts/check-node-runtime-pin.mjs
#	config/scripts/update-node-runtime-pin.mjs
#	config/scripts/update-node-runtime-pin.test.mjs
#	package.json
#	src/shared/orcad-bun-runtime.ts
# Conflicts:
#	.github/workflows/pr.yml
#	config/scripts/pr-code-change-scope.mjs
#	package.json
@OrcaWin
OrcaWin changed the base branch from OrcaWin/node-rt-phase1 to main October 1, 2026 06:24
@greptile-apps

greptile-apps Bot commented Oct 1, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P2 Idle menus do not refresh src/main/claude/claude-at-rest-commands.ts:70 ▶

    The ten-second expiry only starts a scan when something calls read() again. If a command file changes while a chat remains open without another read or session event, its slash menu stays stale indefinitely. The file-change test likewise needs an explicit host.readCommands call to show the update.

  • P2 File limit does not bound reads src/main/claude/claude-command-folder-scan.ts:58 ▶

    readFile loads each entire command file before the code slices it to 256 KiB. Large Markdown commands therefore consume their full size in the daemon on every scan, making the slash menu more expensive to open despite the stated limit.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 78975f4f-02b7-4820-8454-0e029f8cf725

📥 Commits

Reviewing files that changed from the base of the PR and between 2a83c95 and 7fe9515.

📒 Files selected for processing (12)
  • .github/workflows/pr.yml
  • config/scripts/check-node-runtime-pin.mjs
  • config/scripts/check-runtime-launcher-protocol-ratchet.mjs
  • config/scripts/check-runtime-launcher-protocol-ratchet.test.mjs
  • config/scripts/node-dist-archive-name.mjs
  • config/scripts/pr-code-change-scope.mjs
  • config/scripts/update-node-runtime-pin.mjs
  • config/scripts/update-node-runtime-pin.test.mjs
  • package.json
  • src/main/ssh/orcad-remote-runtime.test.ts
  • src/main/ssh/orcad-remote-runtime.ts
  • src/shared/orcad-artifacts.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds a CI check that rejects daemon protocol changes when runtime-launcher files also change, unless the override is enabled. It updates remote slot selection to recognize Node runtime markers and select the matching pinned executable. It also centralizes Node distribution archive naming and updates the pin scripts to use the shared function.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 7fe95

The runtime-selection changes have no established blocking defect. The compatibility guard has a bounded coverage gap: include the artifact materializer so future runtime changes cannot bypass the protocol check.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 7fe95

Marked Node slots fail closed rather than silently switching runtimes, and process stopping retains its identity checks. No newly exposed security vulnerability was established. Trusted installation and lifecycle management for shared runtimes remain unproven, and the new compatibility gate covers only a fixed subset of runtime-producing paths.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Substitution or premature removal of one shared runtime could affect multiple slots referencing the same digest within an installation, including launch and incumbent-stop verification. Exploitation would require influence over the relevant filesystem state; cross-user, tenant, or fleet-wide authority was not established.

Security Findings and Attack Paths

  • inferred — Marker content is constrained to lowercase hexadecimal characters and inserted through a quoted expansion, preventing direct shell-command or path-traversal injection through that value. Whether an attacker can replace the selected executable remains unresolved because installation ownership and permissions were not evidenced; this is not a verified vulnerability.

Trust Boundaries and Controls

  • observed — The workflow derives the ratchet override from exact label membership, not free-form PR text, and the checker accepts only true or 1. Protocol-file and checker changes route to cross-version-wire. Repository policy governing who may apply the override label remains unverified.

Resilience and Maintainability Implications

  • observed — Unavailable marked runtimes do not cause incumbent stopping to fall back to host Node or signal an unverified process. Deployment consequently refuses to replace that incumbent. Cleanup of this client's just-launched candidate bypasses readiness parsing through the selected runtime, preserving a separate cleanup route.

Hardening Proposals

  • proposed — Before production Node-slot publication, define a trusted installer that verifies executable bytes against the pin, publishes the runtime and marker atomically, establishes write ownership, and retains runtimes needed by active or rollback slots. This would close the currently unproven producer and lifecycle contract.
  • proposed — Define the ratchet's launcher ownership scope explicitly and include deployment-owned executable packaging when that scope is intended to cover packaged-runtime selection. Restrict the override label to an authorized maintainer action.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 10 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the two primary changes: the runtime-launcher protocol ratchet and the Node slot marker.
Description check ✅ Passed The description is detailed and covers the main change, rationale, testing, visual proof, and scope. It does not provide a direct linked issue or the remaining template sections, but these omissions d…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 10 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit d2dfc79 into main Oct 1, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant