Skip to content

refactor(orcad): make profile backup and preflight runtime-neutral - #24088

Merged
OrcaWin merged 4 commits into
mainfrom
OrcaWin/node-rt-orcad-neutral
Oct 1, 2026
Merged

OrcaWin merged 4 commits into
mainfrom
OrcaWin/node-rt-orcad-neutral

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15

ELI5

Some of orcad's startup and backup code assumed it would always run under Bun or Electron. This removes those assumptions, so the same code works when orcad runs on plain Node. What ships today still runs under Bun, so nothing changes for it.

What Changed

  • Profile backups: the worker thread is used under Electron or Bun, as before, and now also whenever its bundled entry file exists. Before, plain Node validated the whole snapshot on the main thread. The inline path stays for tests and dev runs that have no bundled entry.
  • Profile preflight: parseOrcadProfilePreflight takes the expected runtime identity instead of hard-coding 'bun'. Every current caller passes ORCAD_BUN_RUNTIME_IDENTITY, so today's behaviour is unchanged. Tests cover a Node candidate and rejection of a mismatch in either direction.
  • Rename: orcad-bun-native-preflight.ts becomes orcad-runtime-native-preflight.ts. Its PTY spawn, watcher delivery and Windows process-identity probes don't depend on Bun. The timeout message says "Bundled file watcher" instead of "Bun file watcher".

Why

These are the Node runtime plan's Phase 1 prerequisites that don't depend on the cutover itself. Landing them separately keeps the cutover PR focused on the runtime swap.

Linked Issue

Part of the Node runtime plan (Phase 1).

Visual Proof

N/A. The only visible change is the wording of an internal error message.

Testing

  • The targeted suites pass: backup-worker, orcad-profile-preflight (shared and main), orcad-runtime-native-preflight, orcad-artifact-preflight, orcad-remote-deploy and profile-state-store-backups.

  • The backup-worker test passes under Bun too. A fix commit skips the plain-Node cases in the Bun profile suite.

  • pnpm tc and the changed-code gate pass.

  • Known and pre-existing: 3 tests in profile-state-backup-rotation.test.ts time out on this machine's Node 26.6.0 on main too. This change doesn't touch that path under vitest.

  • 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 3 commits September 30, 2026 01:48
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.
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors runtime identity checks to support multiple runtimes.

The PR appears safe to merge; no new actionable failure or outstanding previous finding was identified.

Summary

The PR makes profile backup worker selection depend on the bundled entry’s availability, parameterizes the expected preflight runtime identity, and renames the native preflight module without changing shipped Bun callers.

  • Plain Node can now run a bundled backup entry off-thread while retaining the inline fallback when no entry is present.
  • Current preflight callers continue to require the pinned Bun identity.

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

@coderabbitai

coderabbitai Bot commented Sep 30, 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: 45da18ea-9623-4b1e-9b05-8344ec92c3fb

📥 Commits

Reviewing files that changed from the base of the PR and between 5dbbfc0 and 7cfdb74.

📒 Files selected for processing (1)
  • src/shared/orcad-bun-runtime.ts

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


📝 Walkthrough

Walkthrough

Orcad preflight now validates runtime and version against an expected identity, and its native preflight entry point uses a runtime-neutral name. Profile-state backup worker selection now uses the worker for Electron and Bun, and uses it for other runtimes only when the worker path exists; otherwise, it writes the backup inline.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 7cfdb

The reviewed runtime identity and backup changes preserve their stated contracts and are mergeable.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 7cfdb

The inspected identity checks and backup safeguards remain intact, with no introduced security issue identified. Confidence is limited by incomplete deployment and security coverage.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected security-relevant scope is candidate runtime acceptance on local and SSH paths, and profile backup files handled by the owning process. Worker execution receives the same job paths and profile identity; no additional filesystem authority is evident in this routing change.

Trust Boundaries and Controls

  • observed — Candidate process output crosses an acceptance boundary through schema parsing and exact nonce, runtime, runtime-version, and optional artifact-version comparisons. Production callers generate the nonce and supply both identity expectations. Allowing a caller-selected Node identity does not make candidate output authoritative over that choice.

Resilience and Maintainability Implications

  • inferred — Worker failure, timeout, or cancellation settles after worker exit and cleans temporary files. A snapshot already published is not removed by that cleanup, while failed completion prevents rotation from pruning older backups. Interruption recovery removes recognized, sufficiently old temporary files only when their process owner has exited.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 13 files. 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 and concisely describes the main change: removing Bun and Electron assumptions from Orcad profile backup and preflight code.
Description check ✅ Passed The description is mostly complete. It includes the ELI5, changed behavior, rationale, testing details, visual-proof statement, and automated-test checklist. The linked issue section does not contain …
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@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.

✅ No new issues found.

Reviewed changes

  • Preflight runtime identity generalized — parseOrcadProfilePreflight now takes an OrcadPreflightRuntimeIdentity and compares runtime/runtimeVersion against it instead of hard-coding 'bun'. All four shipped callers pass the new ORCAD_BUN_RUNTIME_IDENTITY, so today's behavior (bun + pinned version) is unchanged; a Node candidate and mismatch-in-either-direction are now covered by tests.
  • Backup worker selection made runtime-neutral — runProfileStateBackup uses the worker when electron || bun || existsSync(workerPath), with a new optional workerPath test seam; plain Node with no bundled entry still falls back to inline writeProfileStateBackup. Three new tests pin the worker-present, built-entry, and missing-entry branches.
  • Rename to drop the Bun assumption — orcad-bun-native-preflight.* → orcad-runtime-native-preflight.*, preflightOrcadBunNativeRuntime → preflightOrcadNativeRuntime, watcher-timeout copy now says "Bundled file watcher", and ci-shard-timings.json tracks the new test path.

I verified the focused suites pass (orcad preflight + ssh remote-deploy + backup worker, 96 tests), pnpm tc:node is clean, the changed-code quality gate reports 0 findings, and a HEAD grep finds no stale references to the old module path, function name, or watcher message.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…-neutral

# Conflicts:
#	src/shared/orcad-bun-runtime.ts

@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.

✅ No new issues found.

Reviewed changes

  • Merged the base branch (origin/main, base now 3135fbb) into the PR branch. The only delta in a PR-authored file is src/shared/orcad-bun-runtime.ts, where the conflict resolution keeps ORCAD_BUN_RUNTIME_IDENTITY (runtime bun, pinned 1.4.2) and adopts the base's export type OrcadBunTarget = ServerTarget. SERVER_TARGETS is the same eight-target list the PR previously inlined, so the alias is behavior-preserving. Every other PR-authored file is byte-identical to the previously reviewed revision.

I re-ran the focused orcad preflight and profile-backup suites (64 tests) plus pnpm tc:node on the merged head; both pass. A tree-wide grep finds no dangling ORCAD_BUN_TARGETS reference and confirms ORCAD_TEMPLATE_TARGETS now lives in node-runtime-pin.ts (a base-branch move, not this PR).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 49a83de into main Oct 1, 2026
51 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