Skip to content

refactor(orcad): shared serve-option validation; no daemon barrel - #27443

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/p399-0-9
Oct 11, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/p399-0-9

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46 $\color{#cf222e}{\Huge{\mathbf{−}}}$​88 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42

ELI5

Two small cleanups in the headless server (orcad) and the terminal daemon code. First, orcad now checks its command-line flags with the same rule set the desktop --serve mode and the orca serve CLI already use. Second, a few "forwarding" files that only re-exported other files are gone; code now imports the file that actually defines what it uses.

What Changed

  • orcad flag checks (small bug fix, accepted behaviour change). Before: orcad only checked two of the five serve-flag rules, so orcad --no-pairing --mobile-pairing or orcad --recipe-json --project-root X --no-pairing started anyway and one flag silently won. After: parseArgs calls the shared getServeOptionValidationError, so those combinations exit with the same message desktop serve prints (e.g. Use either --mobile-pairing or --no-pairing, not both.). The two rules orcad already enforced now use the shared wording too. Managed SSH hosts are unaffected: the desktop app never passes these pairing flags to orcad.
  • CLI duplicate removed. serveOrcaApp re-checked "recipe JSON needs --project-root". Its only caller (orca serve in cli/handlers/core.ts) already runs the shared validator first, so the copy could never fire.
  • Barrels removed. src/main/daemon/daemon-init.ts (re-export only, 11 importers + 2 dynamic imports + 9 test mocks/harness) and src/cli/runtime/index.ts (one importer) are deleted. The parsePtySessionId re-export in daemon/pty-session-id.ts and the OrcadInstanceLockError re-export in orcad/orcad-instance-lock.ts are deleted too. Callers and vi.mock sites now target daemon-provider-state, daemon-provider-init, daemon-provider-restart, daemon-legacy-adapters, daemon-replacement-preflight, shared/pty-session-id-format, and orcad-data-root-privacy. None of the defining modules has top-level side effects, so dropping the barrel does not change load order.

Net lines: production −48, tests +16 (one new contradictory-flag test). No wire-visible change.

Why

One serve-flag rule set means orcad and Electron serve cannot drift again, and it fixes a real (if rarely hit) "flag silently ignored" bug. The repo rule is no barrels or re-export shims. With the barrel, tests mocked a file nothing defines, and orcad modules mixed barrel and direct imports of the same state module. The alternative was to keep the barrel and only add orcad's missing rules inline, but that is the duplication that caused the drift.

src/cli/runtime-client.ts stays as the single CLI handler import and mock surface. It now re-exports from the concrete ./runtime/* files instead of a second barrel. Removing it touches many handler mocks and belongs in the Wave 3 barrel PRs.

Linked Issue

Phase 3.99 cleanup plan, PR 0.9 (maintainer refactor; no issue).

Visual Proof

N/A: no UI change. The only behaviour change is orcad's exit message when it gets contradictory command-line flags.

Testing

  • pnpm tc passes.

  • Focused pnpm test: daemon-init suites, pty-management, hydrate-local-pty-registry*, all of src/main/orcad/, main-process-quit*, desktop-profile-instance-lock, serve-*, runtime-pairing-desktop-control-grant, src/cli/runtime/, cli/handlers/core, index-serve-command, serve-option-validation, plus the parsePtySessionId callers. 105 files / 935 tests pass.

  • New test: orcad-launch-contract.test.ts "rejects contradictory pairing flags with the desktop serve message".

  • Bundles: build:electron-vite, build:cli, build:orcad all succeed. Rollup would fail on a missing export.

  • Dead-path proof: rg "daemon-init['\"]" and rg "runtime/index" over src config tests mobile return no imports. rg over all 159 // @ts-nocheck files for daemon-init|runtime/index|parsePtySessionId|OrcadInstanceLock(Error|Code)|serveOrcaApp returns 0 hits.

  • oxlint, pnpm run check:code-quality:changed (0 new findings) and pnpm lint (process-host baseline unchanged at 127) pass.

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

Review

P0/P1 review: self-review plus an independent reviewer. Reports are kept with the Phase 3.99 notes.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: argv-only and import-path changes, nothing platform-specific. SSH: managed hosts start orcad with fixed flags that never combine pairing flags, so they are unaffected. Mobile/wire: unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b85f3cf-321c-47ec-b3d8-4eb9b53d1a2c

📥 Commits

Reviewing files that changed from the base of the PR and between 7310ffc18eed1cfa6cbc43ed1d96e467522dadb0 and 86aca5b.


📒 Files selected for processing (43)
  • config/scripts/verify-packaged-daemon-entry.cjs
  • src/cli/runtime-client.ts
  • src/cli/runtime/index.ts
  • src/cli/runtime/launch.ts
  • src/main/daemon/daemon-init-fresh-import.ts
  • src/main/daemon/daemon-init-wedged-daemon-grace.test.ts
  • src/main/daemon/daemon-init.ts
  • src/main/daemon/daemon-pty-process-inspection.ts
  • src/main/daemon/daemon-pty-session-inventory.ts
  • src/main/daemon/pty-session-id.test.ts
  • src/main/daemon/pty-session-id.ts
  • src/main/daemon/pty-subprocess/foreground-process-tracker.ts
  • src/main/daemon/wsl-session-context.ts
  • src/main/ipc/pty-management.test.ts
  • src/main/ipc/pty-management.ts
  • src/main/local-builds/local-build-compatibility.ts
  • src/main/memory/hydrate-local-pty-registry-folder-workspaces.test.ts
  • src/main/memory/hydrate-local-pty-registry.test.ts
  • src/main/memory/hydrate-local-pty-registry.ts
  • src/main/orcad/orcad-command-arguments.ts
  • src/main/orcad/orcad-daemon-retirement.test.ts
  • src/main/orcad/orcad-daemon-retirement.ts
  • src/main/orcad/orcad-daemon-supervision.test.ts
  • src/main/orcad/orcad-daemon-supervision.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-exit-code.ts
  • src/main/orcad/orcad-health.test.ts
  • src/main/orcad/orcad-health.ts
  • src/main/orcad/orcad-instance-lock.test.ts
  • src/main/orcad/orcad-instance-lock.ts
  • src/main/orcad/orcad-launch-contract.test.ts
  • src/main/orcad/orcad-managed-idle-exit-host.ts
  • src/main/orcad/orcad-push-startup.test.ts
  • src/main/startup/desktop-profile-instance-lock.test.ts
  • src/main/startup/desktop-profile-instance-lock.ts
  • src/main/startup/main-process-pty-startup.ts
  • src/main/startup/main-process-quit-pending-writer.test.ts
  • src/main/startup/main-process-quit-update-veto.test.ts
  • src/main/startup/main-process-quit.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/shared/daemon-lifecycle-telemetry.ts
  • tests/e2e/fixtures/daemon-generation-desktop-discovery.ts
  • tests/tools/win-update-e2e/daemon-processes.mjs

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: a4cee168-e544-43b2-98fd-878a3a2e94a5


📥 Commits

Reviewing files that changed from the base of the PR and between 398cb84 and 7310ffc18eed1cfa6cbc43ed1d96e467522dadb0.



📒 Files selected for processing (43)
  • config/scripts/verify-packaged-daemon-entry.cjs
  • src/cli/runtime-client.ts
  • src/cli/runtime/index.ts
  • src/cli/runtime/launch.ts
  • src/main/daemon/daemon-init-fresh-import.ts
  • src/main/daemon/daemon-init-wedged-daemon-grace.test.ts
  • src/main/daemon/daemon-init.ts
  • src/main/daemon/daemon-pty-process-inspection.ts
  • src/main/daemon/daemon-pty-session-inventory.ts
  • src/main/daemon/pty-session-id.test.ts
  • src/main/daemon/pty-session-id.ts
  • src/main/daemon/pty-subprocess/foreground-process-tracker.ts
  • src/main/daemon/wsl-session-context.ts
  • src/main/ipc/pty-management.test.ts
  • src/main/ipc/pty-management.ts
  • src/main/local-builds/local-build-compatibility.ts
  • src/main/memory/hydrate-local-pty-registry-folder-workspaces.test.ts
  • src/main/memory/hydrate-local-pty-registry.test.ts
  • src/main/memory/hydrate-local-pty-registry.ts
  • src/main/orcad/orcad-command-arguments.ts
  • src/main/orcad/orcad-daemon-retirement.test.ts
  • src/main/orcad/orcad-daemon-retirement.ts
  • src/main/orcad/orcad-daemon-supervision.test.ts
  • src/main/orcad/orcad-daemon-supervision.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-exit-code.ts
  • src/main/orcad/orcad-health.test.ts
  • src/main/orcad/orcad-health.ts
  • src/main/orcad/orcad-instance-lock.test.ts
  • src/main/orcad/orcad-instance-lock.ts
  • src/main/orcad/orcad-launch-contract.test.ts
  • src/main/orcad/orcad-managed-idle-exit-host.ts
  • src/main/orcad/orcad-push-startup.test.ts
  • src/main/startup/desktop-profile-instance-lock.test.ts
  • src/main/startup/desktop-profile-instance-lock.ts
  • src/main/startup/main-process-pty-startup.ts
  • src/main/startup/main-process-quit-pending-writer.test.ts
  • src/main/startup/main-process-quit-update-veto.test.ts
  • src/main/startup/main-process-quit.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/shared/daemon-lifecycle-telemetry.ts
  • tests/e2e/fixtures/daemon-generation-desktop-discovery.ts
  • tests/tools/win-update-e2e/daemon-processes.mjs


💤 Files with no reviewable changes (5)
  • src/cli/runtime/launch.ts
  • src/main/orcad/orcad-instance-lock.ts
  • src/main/daemon/daemon-init.ts
  • src/cli/runtime/index.ts
  • src/main/daemon/pty-session-id.ts


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

CLI argument parsing now uses shared serve-option validation, and runtime exports come directly from their source modules. The daemon re-export module was removed, and daemon consumers now import APIs from provider-specific modules. PTY session ID parsing and Orcad lock APIs are imported from their defining modules.



Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 7310f

This change reorganizes module imports and routes orcad's argument validation through the shared validator, so contradictory pairing flags now fail with the desktop serve message. No user-visible regressions were identified, and it looks ready to merge.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 38 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 identifies the two primary changes: shared orcad serve-option validation and removal of the daemon barrel.
Description check Passed The description is complete and aligned with the template. It explains the changes, rationale, linked planning context, testing, behavior impact, cross-platform considerations, and checklist status. T…
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 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

orcad now checks its flags with the same validator Electron serve and the
CLI use, so contradictory pairing flags fail with the same message instead
of one silently winning. The CLI launcher drops its duplicate recipe check
(the CLI handler already ran the shared validator).

Removes the daemon-init and cli/runtime/index re-export barrels and the
parsePtySessionId / OrcadInstanceLockError re-exports; callers and mocks
import the defining modules.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@OrcaWin
OrcaWin merged commit 061cb22 into main Oct 11, 2026
53 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