Repository navigation
feat(link): journal ocx link add and revoke under an operation id, with --require-ephemeral - #8623
Merged
Merged
Conversation
A Home-initiated link may now record explicitRoute {proxyCommand, user, port}
and exclusive. Every SSH builder takes a required route, so each caller decides;
the route reaches ssh on the command line for enrollment, revoke, purge, every
exec and every tunnel start, where ssh_config cannot change it. An exclusive
link refuses route edits. No link has either field until a caller passes the
new flags.
The inspection dependency now takes the link's explicit route after the alias; the mock records it so a routed inspection would show up.
The privacy scan reads tracked files and flags user@domain text; the fixtures keep their @ words without a domain.
…literals Only the tunnel argv was compared to a literal; exec, probe, route probe and Windows probe are now compared to the argv origin/dev e85a975 built, so a drift in any option of any builder fails.
The supervisor's record instance left out explicitRoute and exclusive, so a hand edit of links.json on a running Home kept the live tunnel on the old route until it exited. Both fields are now part of it. The comment on the multi-route spawn now says what happens instead of assuming null.
… secret The command is visible in the process list to every local user and is written to the tunnel pidfile, the link status rows and ocx link status --json. The test fixtures no longer use a value that reads like a key.
…inks Beside the store downgrade trade-off: an older validateStatus, which ocx sync also uses, refuses a row with exclusive or explicitRoute, so an older ocx link status or ocx sync against a Home with an exclusive link fails for every row.
A provisioning caller reads the contract list to know whether this Home's OpenCodex supports the explicit, exclusive route of a Remote Link (the --proxy-command, --ssh-user, --ssh-port and --exclusive flags and the explicitRoute and exclusive body keys).
… recovery An apply that carries an operation id writes <configDir>/link/operations.json: the link id and key id it will create are reserved before any effect, each Home effect gets an intent and a completion mark, and the outcome is recorded (committed, failed_clean, residual, unknown). A repeat with the same id and parameters replays it; another digest is refused. An entry left open by a process that died is recovered by reserved id. Apply and the alias take a per-alias lock file. Nothing passes an operation id yet.
…hemeral Apply with requireEphemeral runs a census over every full ocx candidate the gated argv could select (served-runtime census, Desktop, system and PATH), without stopping at an ocx-child, before any plant, key or Child change. A runnable full ocx answers 409 full_install_present; an unfinished census fails closed; a Windows Child answers 409 require_ephemeral_unsupported.
…operation-id Every revoke takes the alias lock, so a force revoke waits while a purge holds it and cannot land between the purge and its receipt. With an operation id the revoke is journalled: remote cleanup, key and record each get an intent and a completion, a purge's purged:true is recorded as the receipt for that link id, and a repeat replays the outcome even after the link is gone. Without an operation id nothing is written and the answer is unchanged.
GET /api/link/operations[/{id}] reads the journal; POST
/api/link/operations/{id}/resolve marks a residual or unknown entry resolved,
which starts its 30 days of retention (resolveLinkOperation is the call O5
makes once it proves a Child clean). The enrollment digest leaves plant out:
it follows from the probe, which a replay does not repeat.
ocx link add takes --operation-id (with --expect-fingerprint) and --require-ephemeral; with an id it first reads the operation and, when it is recorded, replays it through apply without a new probe. ocx link revoke takes --operation-id and prints the outcome and purge receipt. ocx link operations lists, reads and (with --yes) resolves entries. Error answers keep their operation id and outcome through the CLI's error filter; the new refusals get fixed guidance. The capability registry, the management route registry and the generated skill surface list the new flags and routes.
… the lock wait structure/remote-link.md gains "Operation journal": the file, the reserved ids, the effect marks, how outcomes are classified, recovery by reserved id, the per-alias lock, the full-install census and the routes and CLI. The guide lists the new flags and command. New tests cover the journal file's strict parse, privacy and retention, and a second enrollment that waits for the lock.
…lain callers inert Review round 1: a force revoke that died after revoking the key, a revoke whose link something else removed, a key issue that threw after the config may have been saved, and a plant that did not report completion were each settled too optimistically. They now settle unknown or residual from the operation's own marks, and an open revoke entry refuses other revokes of its link. Without an operation id, apply and revoke take the alias lock and read the journal only once this Home has a journal file, so a Home that never journalled behaves exactly as before.
A provisioning caller reads it to know that ocx link add and revoke take --operation-id, ocx link add takes --require-ephemeral, and the operation journal and its routes are served.
Review round 2: an apply whose reserved key issue threw returned before the plant rollback, leaving a planted binary behind; it now goes through the same failure path, which purges it, and the outcome stays unknown. A regression test pins that the first journalled purge on a Home cannot be overtaken by a plain force revoke (the link's Child-operation reservation excludes it in the runtime; the spend-ledger owner lease keeps it to one runtime per store), and the structure doc states that guarantee. The link CLI leaf test lists the two operations leaves and no longer names a count in its title.
…esidual with any outcome Review round 3: a plain apply on a Home without a journal and the first journalled revoke of the link it had just recorded could overlap, because revoke did not consult the per-alias operation set apply holds. A journalled revoke, and any revoke once the journal exists, now takes that set too. An enroll entry records childResidual when the Child may keep an enrollment or a plant, so a replay of an unknown outcome still reports it.
… for a residual plant Review round 4: the in-memory per-alias set compared spellings, while the alias lock and the journal ignore case, so a plain apply of one spelling could overlap the first journalled apply of another. The set is now keyed without case. A replayed residual whose entry shows a plant now gives the managed binary's detach --purge, since a disconnect would leave the plant.
Review round 5: the replayed plant step named only the POSIX path, and on a replay the CLI, which never probed, fell back to full-install advice and ignored the server's step. Journalled answers now carry residualKind (plant or enrollment); the CLI maps it to its own fixed guidance, and the plant step names both managed locations with detach --purge.
…on Child conflicts Review round 6: the Windows plant step now also names the location used when LOCALAPPDATA is not set, with quoted paths. The CLI's port-busy and external-provider messages, which say no Child file changed, now apply only to answers that are not residual, so a plant whose rollback failed gets the purge guidance instead.
…ommands Review round 7: %LOCALAPPDATA% and a bare quoted executable are Command Prompt syntax; PowerShell expands neither. The guidance now says where they run.
Contributor
|
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 18 minutes. View limit details
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. |
Contributor
|
✅ 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. |
lidge-jun
added a commit
that referenced
this pull request
Nov 13, 2026
Conflicts resolved: CAPABILITY_CONTRACTS is the union (link.route/1, link.operation/1,
link.recover/1); the forced-revoke tombstone is written before O1's journal.intent("key_revoked");
both the /api/link/operations and /api/link/recover blocks are kept; usage, docs and the
skill surface (regenerated) carry both lanes' commands; serialized() keeps dev's case-folded set.
Also in this commit: recover runs under O1's underAliasLock as well as serialized() (item 3);
each forced-revoke attempt stamps its tombstone with a random attempt token and a failed
attempt removes only its own (review r9); GET /api/link/recover is covered by the link
recover capability, whose flags and usage name --list, --forget and --yes.
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A provisioning caller (a hub that builds a disposable machine and links it to its Home) has to know exactly what an enrollment or a revoke did, even when it loses the answer or the Home process dies halfway. Today
ocx link addandocx link revokeleave nothing behind but their effects: after a crash the caller cannot tell whether a key was issued, a link recorded or the Child enrolled, and repeating the command enrolls again. A revoke also has no receipt that a planted ocx-child was purged, and a force revoke can run while a purge is still in flight.This adds an operation journal,
<configDir>/link/operations.json(src/link/operations-journal.ts), used only when a caller passes an operation id:ocx link add --operation-id <id>(which needs--expect-fingerprint) writes an entry that reserves the link id and the data key id it will create, plus the explicit route andexclusiveflag from feat(link): let a Remote Link carry an explicit, exclusive SSH route #8615. The key is issued under the reserved id (issueApiKeyInProcessaccepts a reserved UUID). The Child picks the tunnel port after a plant, so the port is recorded before the first Home effect.plant,key_issued,link_recorded,child_enrolledandrelay_verifiedfor apply;remote_cleanup,key_revokedandrecord_removedfor revoke. A purge's completion records{purged: true, linkId}as its receipt.committed,failed_clean,residual(the Child may still hold an enrollment or a plant) andunknown. An entry also recordschildResidualwhenever the Child may keep something, whatever the outcome says about the Home's key, and answers carry a closedresidualKind(plantorenrollment).409 operation_mismatch. An entry left open by a process that died is settled from its own marks, comparing by reserved id only: a completed relay verification committed; otherwise whatever carries the reserved link id or key id is undone. Another link for the alias, or compensation that fails, makes the outcome unknown; an enrollment intent or a plant makes it residual. A recovered revoke counts a missing link as its own removal only after its own removal intent.src/link/alias-lock.ts) is held for the whole operation. A second holder waits on an injected clock, then answers409 link_operation_in_progress, so a force revoke cannot run between a journalled purge and its receipt. In the runtime, a revoke also takes the link's Child-operation reservation, and journalled revokes join the per-alias operation set apply holds, so an apply and a revoke of one alias never overlap. That set is now keyed without case, like the lock and the journal. Only one runtime per state directory serves these routes (spend-ledger owner lease).--require-ephemeralruns a census before any plant, key or Child change. It counts every runnable full ocx the gated argv could select (served-runtime census, Desktop, system and every PATH directory) and never stops at an ocx-child the way runtime inspection does. Any one answers409 full_install_present, also beside an ocx-child; an unfinished census fails closed; a Windows Child answers409 require_ephemeral_unsupported.GET /api/link/operations[/{id}]andPOST /api/link/operations/{id}/resolve(marks a residual or unknown entry resolved;resolveLinkOperationis the call the O5 recovery work will make). Alsoocx link revoke --operation-id,ocx link operations [--operation-id]andocx link operations resolve --operation-id --yes. With an id,ocx link addfirst reads the operation and replays a recorded one without a new probe. Error answers keep their operation id, outcome and residual kind through the CLI's error filter, and the CLI maps the kind to its own fixed guidance.ocx capabilities --contractslistslink.route/1(the explicit, exclusive route of feat(link): let a Remote Link carry an explicit, exclusive SSH route #8615) andlink.operation/1(this change).links.jsonis unchanged.The branch starts with four small follow-ups to #8615 from its final review, each its own commit: every SSH builder's route-less argv is compared to the literal pre-#8615 argv; the supervisor restarts a tunnel whose explicit route was edited in
links.json; the docs say a ProxyCommand must not hold a secret (it shows inps, the pidfile, status rows andocx link status --json); and they note that an older CLI's status validation rejects rows of exclusive links. This branch was stacked on #8615 and joined to dev through the merge of 51de887 (the #8615 line after its squash); it is clean against current dev (git merge-treeexit 0).What stays unchanged by default
Nothing passes
--operation-idor--require-ephemeraluntil a caller does. On a Home whoseoperations.jsondoes not exist, an apply or revoke without an operation id behaves and answers exactly as before: no lock file, no journal read, no new refusal, and the file is never created. Once the journal exists, plain applies and revokes also take the alias lock and respect open entries. Two deliberate changes apply without the new flags:ocx link probe/add/routesoperations on two case variants of one alias now refuse to overlap (one gets 409), the rule the alias lock, the journal, OpenSSH andlink_existsalready apply; and the CLI's port-busy and external-provider messages ("no Child files were modified") are no longer printed for a residual answer.Contract for the O5 recovery lane
O5 calls
resolveLinkOperation(id)(orPOST /api/link/operations/{id}/resolve) when it proves a Child clean. It readsreserved.linkId,reserved.explicitRouteandaliasfrom residual entries to rundetach --purge --expect-linkover the link's route; SSH builders take a requiredrouteargument, so its commands must passrecord.explicitRoute ?? entry route. The Child's purge report names no link id today, so the revoke receipt bindspurged:trueto the link id the Home revoked; a report from--expect-linkthat names the link would let the receipt rest on the Child's own statement.Verification
Tests that failed first, and why (each run with the change's
srcstashed, so against the code before it):tests/server/link-enrollment-operation.test.ts(21 cases at first): before, apply refusedoperationIdas an unknown body key, so all failed. Live outcomes with reserved ids and the exact mark order; replay without SSH; digest mismatch; an open entry refusing other enrollments; the alias lock; a crash table that builds the journal, keys and store for every boundary (after each intent and each completion, plant included) and checks the outcome and what is undone; a foreign link and a failing revoke giving unknown; a residual entry older than 30 days still present and recoverable.--require-ephemeral: 3 failed before the census existed (a full ocx beside ocx-child refused before any plant or key; the census runs once, before the port; an unfinished census fails closed).tests/server/link-revoke-operation.test.ts: 8 of 9 failed (the purge receipt and its replay; a failed purge; mode mismatch; a force revoke waiting for, or refused by, a held lock; crash recovery). The guard "without an operation id nothing is written" passed before and after.tests/cli/cli-link-operation.test.ts: the five behavioural cases failed (first run, replay without probing, recorded failure keeping its outcome, revoke receipt,ocx link operations).tests/clients/link-explicit-route.test.ts(P3 follow-up): a reload after alinks.jsonroute edit did not restart the tunnel (killed 0, expected 1); now it restarts on the new port.tests/clients/link-operations-journal.test.ts(strict parse, 0600, retention, digest),tests/clients/link-alias-lock.test.ts(waits, bound, symlink refused),tests/clients/link-full-install-census.test.ts(the real census script under/bin/shagainst a fake home holding ocx-child state and a full ocx),tests/server/link-operations-routes.test.ts.Commands (Bun 1.4.4, TMPDIR=/tmp), on head 3a3283d:
bun run typecheck→ exit 0bun run privacy:scan→ exit 0bun run structure:check→ exit 0bun run skill:surface:check→ exit 0bun scripts/test.ts --parallel=2over tests/clients/link-, tests/clients/client-link-, tests/server/link-, tests/cli/cli-link, tests/cli/sync-, tests/cli/link-, tests/codex-integration/messaging-remote*, the layout, structure, file-size ratchet and skill-ocx tests, the CLI capability tests, management-route-registry, readyz-features, persistent-dashboard-consent, cli-api-protocols, api-keys-routes, api-key-attribution, api-access-endpoints and ocx-launcher-desktop-handoff (158 files) → exit 1: 2623 pass, 29 skip, 3 fail. The 3 failures are the Rust-toolchain cases under NOT RUN; they fail the same way on origin/dev.git merge-tree --write-tree origin/dev feat/link-enroll-journal→ exit 0 against origin/dev 522a6cd.NOT RUN: the full
bun run testsuite (this machine is limited to focused files);tests/clients/link-ocx-child-e2e.test.ts(2 cases) and the Rust conformance runner intests/clients/link-ocx-child-conformance.test.ts, which need a Rust toolchain this machine lacks (rustup has no default toolchain); a real crash of a running Home (crash boundaries are covered by constructing the journal, key and store state each boundary leaves); a second process contending for the alias lock (the lock is SQLiteBEGIN IMMEDIATE, exercised with two connections in one process); Windows and macOS.Review: an independent read-only reviewer went through eight rounds on this branch (crash safety, concurrency, replay, census, inertness, exposure). It raised 4 P1 and 12 P2 findings. Each was answered in its own commit above; one P1, the first-use race between a plain and a journalled revoke, was answered with a regression test that shows the existing exclusion (the link's Child-operation reservation in the runtime, the spend-ledger owner lease across processes) rather than a code change. Its last round reported no open P0-P2. It did not run tests (read-only).
Docs:
structure/remote-link.mdgains "Operation journal" and the follow-up notes in "Explicit route"; the English Remote Link guide documents the flags andocx link operations; the capability registry, the management route registry and the generated skill surface list the new flags and routes.Checklist
devsrc/have focused regression tests in their domain folders, registered in the test layout maps