Skip to content

fix(link): bind every failed-enrollment step to the attempt's link id, and finish a bound detach killed while restoring its own attach - #8694

Merged
lidge-jun merged 14 commits into
devfrom
fix/link-remedy-followups-2
Nov 13, 2026
Merged

lidge-jun merged 14 commits into
devfrom
fix/link-remedy-followups-2

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

The follow-ups from #8691's final review, and the last item of this lane. A failed enrollment that may have left the Child connected used to print a plain ocx disconnect or ocx-child detach (or a status check that could not tell this attempt's link from another's). Read long after the attempt, that step could remove a link the machine joined since. The answer now carries the attempt's link id, and every surface prints a step bound to it. A bound ocx-child detach also finishes its own detach that was killed while it restored an interrupted attach.

Failed-enrollment remedy (the out-of-scope item: CLI, server, journal replay, dashboard, guides en/es, capability text, structure):

  • Apply fixes the attempt's link id when it starts (the journal's reserved id, else a new one), before any plant. A residual answer carries it as linkId, with residualInstall (ephemeral or full) next to residualKind and remotePlatform. A journalled replay carries the reserved id, and so does the first answer of a journalled apply whose plant did not report (it returns before the live residual is built).

  • One builder, src/link/residual-recovery.ts, writes the step for the server answer and the CLI:

    • full install: ocx disconnect --expect-link <id>, then ocx restart if it disconnected;
    • lightweight Child: the agent's detach --expect-link <id> through its managed path for the Child's platform (~/.cache/opencodex/bin/ocx-child, or both Windows locations in Command Prompt), which need not be on PATH, or through the path command -v ocx-child (where.exe ocx-child) prints for a copy placed by hand;
    • plant only: the planted copy's detach --purge --expect-link <id>, both Windows locations named.

    Each acts only while the Child's records name that link or nothing at all. A build older than the flag refuses it before acting; then a full install falls back to "run the plain commands only if ocx connect status --json shows that id, right after the check", and a lightweight Child is left. Without an id, nothing can be bound and the Child is left.

  • The CLI keeps linkId (link-id shape only), residualInstall and remotePlatform from the error body. The dashboard picks its step from those closed fields instead of matching the server's prose, and shows the bound commands as chips in all 11 locales. The old "check the Child, treat links you do not recognise as another's" line is gone.

ocx-child (P3-1): check_expected_link now finishes the owner's own interrupted operation in phase attaching or detaching, when any attach rollback names no link or this one. Before, a bound detach that marked the record detaching and then died while restoring that rollback left (L, detaching) plus the rollback, and every later bound detach answered residual with a reason that was false there. A rollback naming another link is still refused earlier. Test: kill the detach at restore-before-write, then a second detach --expect-link finishes it (it failed with exit 6 before the fix).

Text items:

  • P3-2 child_link_mismatch: "a connect or key rotation of it may be in progress … if the same answer comes back, revoke this link with --force once any enrollment of this link has finished".
  • P3-4 alias_linked: "then run ocx link recover --link-id <id> again" (never automatic). The CLI's revoke names --link-id <that link's id>, shown by ocx link status.
  • P3-5 child_recover_unsupported: "once the machine is gone, or a person on that machine has checked and cleaned its ocx-child records by hand". An --operation-id recover names that operation id: alias_linked says to run ocx link recover --operation-id <op> again, and the way out for either refusal is ocx link operations resolve --operation-id <op> --yes (an operation's target comes from the journal, and --list shows only tombstones).
  • P3-6 nits:
    • the unknown-type reason on the link-not-found path says the link is no longer on this Home;
    • ocx link cleanup restarts only "if it disconnected";
    • the capability text and skill reference give the race reason;
    • the dashboard's Windows paths are labelled as Command Prompt paths, and the sentence beside the bound-detach chip (which shows the POSIX path) names the .exe path;
    • the /1 residual reason drops "written by an older ocx-child", since a current build also writes /1 when it adopts a pre-ownership attachment.

Item 7, tests/ci-workflows/structure-ssot.test.ts locally: this machine's git is a shell shim (~/.local/bin/git) that finds the real binary under $HOME. The test preload replaces HOME with a sandbox, so every git call in the test exits 127. The two git-scaffold cases fail on that directly. The tree check, unable to read the index, falls back to the filesystem, where this worktree has no node_modules/@openai/codex, codex-win32-x64, .package-lock.json or .pnpm. CI has a real git, so it passes there; nothing in the repository to fix.

Residual step after a failed enrollment, full install, before and after:

Residual step, full install, before
Residual step, full install, after

Residual step after a failed plant rollback, before and after:

Residual step, plant, before
Residual step, plant, after

Commits, one per item:

9cc00cdc4 fix(ocx-child): a bound detach finishes its own detach that stopped while it restored an interrupted attach
7487c56ac fix(link): child_link_mismatch says a connect or rotation may be in progress, and ends in --force when the answer repeats
90002fc4b fix(link): alias_linked says to run recover again and names the other link's id for its revoke
7dc964c5c fix(link): child_recover_unsupported names a way to a clean machine, and an --operation-id recover names where the link id comes from
51ca94002 fix(link): wording nits from the #8691 review: the absent-link reason, the cleanup restart, the race reason, the Windows Command Prompt paths, and the /1 reason
76d00512e fix(link): a failed enrollment's residual answer names the attempt's link id and binds the Child's step to it
aff4518ed fix(cli): a failed enrollment prints the Child step bound to the attempt's link id, never a plain disconnect or detach
e9f457698 fix(gui): a failed enrollment's Child step is bound to the attempt's link id in every locale, and is left without one
9782dd939 docs(link): the guides and structure describe the failed enrollment's Child step bound to the attempt's link id
296503f10 fix(link): the first answer to an uncertain journalled plant names the reserved link id and the bound purge
cc35e05c9 fix(link): a lightweight Child's enrollment step names the managed ocx-child path for its platform and a copy placed by hand
5ecbacf96 docs(link): the structure note and recover reference say a bound detach also finishes a detach that stopped while restoring its rollback
920af68c6 fix(cli): an --operation-id recover's refusals name the operation id: recover it again, or resolve it
bcc33aedb test(gui): the residual without a link id shows neither the server message nor its recovery line

Known limits: a lightweight Child whose ocx-child predates --expect-link is left as it is after a failed enrollment, because no step can be bound there. Its configuration names a link whose key the Home revoked.

Verification

All on the final head, ee0098a03 plus these commits:

  • native/ocx-child on Rust 1.100.0: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings and cargo test --locked pass (54 unit, 27 owner_link, the other binaries).
  • bun test tests/cli/cli-link*.test.ts tests/server/link-*.test.ts tests/ci-workflows/docs-spanish-localization.test.ts tests/ci-workflows/skill-ocx.test.ts (temporary HOME/OPENCODEX_HOME, empty git guard): 1005 pass, 0 fail.
  • cd gui && bun test tests/remote-link.test.tsx tests/locale-parity.test.ts: 78 pass, 0 fail (remote-link.test.tsx), and locale-parity.test.ts passes. lint:i18n and build exit 0.
  • bun run typecheck, structure:check, skill:surface:check, privacy:scan: pass.
  • The final review's P2 (structure said a bound detach finishes a detach only with no rollback left) and three P3s are fixed in the last four commits. One terra review round found two P2s (the first answer of an uncertain journalled plant lacked the link id; the lightweight step named an ocx-child that need not be on PATH), both fixed test-first in their own commits. Each behaviour change failed its test first: the Rust kill test (exit 6), the server, CLI and GUI residual tests, and the text tests.
  • Screenshots come from a scratch harness, deleted afterwards, that renders the Remote Link page with stubbed API answers, captured with headless Chrome. "Before" used dev's GUI sources.

NOT RUN: full bun run test (focused suites only; CI runs the rest); Windows and real SSH execution.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

…rogress, and ends in --force when the answer repeats
…and an --operation-id recover names where the link id comes from
…, the cleanup restart, the race reason, the Windows Command Prompt paths, and the /1 reason
…mpt's link id, never a plain disconnect or detach
…link id in every locale, and is left without one
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 13, 2026
…x-child path for its platform and a copy placed by hand
@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 14:30
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 14:30
@lidge-jun
lidge-jun merged commit 624ce71 into dev Nov 13, 2026
54 of 59 checks passed
@lidge-jun
lidge-jun deleted the fix/link-remedy-followups-2 branch November 13, 2026 14:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T14:32:29.271963Z bcc33ae Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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 15, 2026
…ntity-file texts; close #8694 remedy gaps (#8754)

* fix(link): refuse a route edit while a removal of the link is unfinished (#8678)

A route edit made after a failed revoke rewrote the link record without reading its retirement receipt, so every later revoke compared the edited record with the receipt copy and answered link_changed for good. handleLinkRouteEdit now refuses with 409 link_retirement_pending while a receipt is outstanding (an unreadable one counts), checked before the probe and again under the config mutation lock at the commit. ocx link routes names the way out, and the link_changed next step no longer says a current Home edit can cause it.

* docs(link): scope the identity-file refusal texts to this user (#8723)

P3-A..D from the #8722 review: chmod go-w only on a private folder this user owns (its own, or one a tool made for it), in the directory and ancestor texts and every copy; read access only with chmod u+r / u+rx and never group or other; chmod 600 only on a key of this user own, never chown or chmod another user or the system key. Updates the pinned strings and the two stale test comment/title nits.

* fix(link): close the remedy gaps the #8694 review left (#8696)

ocx-child: a bound detach accepts its own ownership record in phase cleanup complete (a detach killed inside release() between marking it and removing it), which only release() writes; covered by a kill test at that point. Residual steps name a copy placed by hand in ~/.local/bin (%USERPROFILE%\.local\bin on Windows), which discovery tries first; the plant purge says what a not-found binary means (server text, dashboard in all 11 locales, guides). The link add capability text labels Command Prompt, adds the USERPROFILE fallback, separates the lightweight step from ocx restart and says what to do when an older build refuses --expect-link. child_restart_unsupported says that ocx disconnect ends the link the machine uses now.

* test(gui): pin the residual purge not-found step in the Remote Link fixtures (#8696)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant