Repository navigation
fix(client): refuse a bare OCX_SERVICE=1 client runtime with the re-register advice - #8796
Conversation
…egister advice A client runtime whose only owner evidence is a bare OCX_SERVICE=1 (a service registered before 2.49, or the proxy of ocx claude, ocx codex or ocx opencode) cannot show who owns it. Before, ocx restart refused it only while some service looked viable and otherwise spawned a detached replacement, which a legacy manager could still own and kill. Per the owner decision, such a runtime is now always refused as legacy-flag: ocx restart answers 409 restart_supervised legacy-flag, ocx sync defers, and ocx disconnect keeps it (exit 0, the disconnect itself completed). Each prints the same advice: re-register the service once with ocx service repair, which writes the current ownership marker, or stop and restart a companion's proxy. Ownership is never inferred from the service diagnostic or the parent's command line, and nothing is stopped on inference. The runtime record states restartOwner legacy-flag so disconnect can name the case. Closes #8545
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Deterministic PR hygiene checks passed. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merge-manager review against the #8545 owner decision at e772b21: MERGE. A bare Follow-ups (not blocking; outside the client restart/disconnect path #8545 names): other bare-flag trusts in |
|
Maintainer integration of #8796 at e772b21 (closes #8545), reviewed against the #8545 owner decision.
|
Summary
A Remote Link Child's client runtime can carry a bare
OCX_SERVICE=1and no other owner evidence. This happens for a service registered before 2.49, and for the detached proxy thatocx claude,ocx codexorocx opencodestarts. Nothing the runtime can read tells these apart. Before this PR,ocx restartrefused only while some service looked viable; otherwise it spawned a detached replacement, which a legacy systemd unit or launchd job could still own and kill.ocx disconnectleft the runtime serving with no explanation.Owner decision (lidge-jun, 2026-11-16, #8545): do not accept parent-command-line evidence as ownership proof. Refuse a legacy bare-flag runtime with a message telling the user to re-register the service once, which writes the current ownership marker. Stop nothing on inference.
What changes:
classifyClientRestartSupervisor(src/client/runtime-restart.ts) returns a new verdict,legacy-flag, for a bareOCX_SERVICE=1. It does so whatever the service diagnostic says and whether or not the connection ended. The oldlegacyServiceViableinput (isServiceViable) is gone, and the parent-command-line derivation is never consulted.restartRefusedByOwnerincludeslegacy-flag, so the runtime answers 409restart_supervised/legacy-flagand stops, replaces and recycles nothing.restartOwner: "legacy-flag"(recordedRestartOwner). The record validator already accepts any string up to 64 characters, so older CLIs read it as an unhandled owner, which is their current behavior.ocx restartreports: "Restart not performed; the running client runtime was kept and nothing was stopped." followed byLEGACY_FLAG_OWNER_ADVICE(src/cli/restart-failure.ts). The advice: if a background service runs it, re-register the service once withocx service repair; ifocx claude,ocx codexorocx opencodestarted it, runocx stopand start it again.ocx syncdefers its restart with the same advice.ocx disconnectsends no restart request forlegacy-flag, prints the advice on stderr, and exits 0. The disconnect itself completed, so a Home's revoke still finishes. A Home-driven leave that runsocx restartnext gets the same refusal and advice.Scope: runtimes that carry a current marker (
OCX_SERVICE_MANAGED, the Windows wrapper marker) or that run under the desktop app are unchanged. A runtime with noOCX_SERVICEat all is unchanged too. The start-time stay-out check insrc/service/service-child-ownership.tsstill reads the parent's command line, because it only refuses to serve and never stops anything. A companion proxy on a Child is now refused as well, because it is indistinguishable from a legacy service. Giving companions their own non-inheritable marker was deliberately left out (the removed attempt in #8529).Docs: the English and Spanish CLI lifecycle reference and Remote Link guide are updated; the other locales of those pages do not describe the bare-flag case. The
structure/remote-link.mdandstructure/runtime.mdcontracts are updated as well.Closes #8545
Verification
ci:fullon e772b21: all 32 checks passed, including all five full Ubuntu test shards (test 1/5–test 5/5). That run includestests/server/proxy-liveness-self-pid-record.test.ts, so the local timeouts in that file came from load on this host, not from this branch.Export named 'recordedRestartOwner' not found,LEGACY_FLAG_OWNER_ADVICEnot found):tests/clients/client-runtime-restart.test.ts: for a legacy service child and each of the three companion proxies, with every service diagnostic and the connection ended or not, the verdict islegacy-flag, the admission is supervised, and stop, spawn and recycle are never called. A markerless legacy Windows service whose parent command line names this install's wrapper is stilllegacy-flag, which is the "never infer from the parent command line" guard; that test covers restart, disconnect and sync.tests/cli/disconnect-runtime.test.ts:legacy-flagrecords give exit 0, no restart request, and stderr that names the pid, "nothing was stopped" andocx service repair, in text and--jsonmodes and for disconnected, connected and invalid states.tests/cli/link-apply-restart.test.ts: sync defers with the advice; the 409legacy-flagparse, deferral and message are covered.bun test tests/clients/client-runtime-restart.test.ts tests/cli/disconnect-runtime.test.ts tests/cli/link-apply-restart.test.ts tests/cli/cli-client-start-fence.test.ts: 133 pass, 0 fail.ocx-launcher-desktop-handoffandstop-deferred-teardownpassed on re-run.proxy-liveness-self-pid-record(two realocx startspawn cases) failed on re-runs on this branch and passed once on the base commit. This host's load average reached 130 during these runs, and neither case reaches the client-runtime code, but I could not finish a clean A/B. This PR carriesci:fullso hosted shards settle it.bun test tests/ci-workflows/docs-spanish-localization.test.ts tests/ci-workflows/docs-link-targets.test.ts: 38 pass, 0 fail.bun run typecheck: exit 0.bun run structure:check: passed.bun run privacy:scan: exit 0.bun run test:changedand fullbun run testlocally. The host was at critical load, and the launching thread asked for no heavy local commands. Hosted CI'stest changedand theci:fullshards cover them.Checklist
Summary by CodeRabbit
Behavior Changes
OCX_SERVICE=1are no longer stopped or restarted automatically.ocx restartrefuses, andocx syncdefers the restart with guidance.ocx disconnectleaves these runtimes running and completes successfully, with advice on how to restart them safely.Documentation