Repository navigation
refactor(orcad): shared serve-option validation; no daemon barrel - #27443
Conversation
|
Warning Review limit reachedYou'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. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to 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 |
|
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]>
7310ffc to
86aca5b
Compare
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
--servemode and theorca serveCLI 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
orcadonly checked two of the five serve-flag rules, soorcad --no-pairing --mobile-pairingororcad --recipe-json --project-root X --no-pairingstarted anyway and one flag silently won. After:parseArgscalls the sharedgetServeOptionValidationError, 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.serveOrcaAppre-checked "recipe JSON needs --project-root". Its only caller (orca serveincli/handlers/core.ts) already runs the shared validator first, so the copy could never fire.src/main/daemon/daemon-init.ts(re-export only, 11 importers + 2 dynamic imports + 9 test mocks/harness) andsrc/cli/runtime/index.ts(one importer) are deleted. TheparsePtySessionIdre-export indaemon/pty-session-id.tsand theOrcadInstanceLockErrorre-export inorcad/orcad-instance-lock.tsare deleted too. Callers andvi.mocksites now targetdaemon-provider-state,daemon-provider-init,daemon-provider-restart,daemon-legacy-adapters,daemon-replacement-preflight,shared/pty-session-id-format, andorcad-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.tsstays 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 tcpasses.Focused
pnpm test: daemon-init suites,pty-management,hydrate-local-pty-registry*, all ofsrc/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 theparsePtySessionIdcallers. 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:orcadall succeed. Rollup would fail on a missing export.Dead-path proof:
rg "daemon-init['\"]"andrg "runtime/index"oversrc config tests mobilereturn no imports.rgover all 159// @ts-nocheckfiles fordaemon-init|runtime/index|parsePtySessionId|OrcadInstanceLock(Error|Code)|serveOrcaAppreturns 0 hits.oxlint,pnpm run check:code-quality:changed(0 new findings) andpnpm 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)