Skip to content

fix(link): verify recorded installations before probing - #8981

Merged
lidge-jun merged 5 commits into
lidge-jun:devfrom
luvs01:codex/verify-recorded-runtime-before-probe
Nov 21, 2026
Merged

lidge-jun merged 5 commits into
lidge-jun:devfrom
luvs01:codex/verify-recorded-runtime-before-probe

Conversation

@luvs01

@luvs01 luvs01 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Remote Link checks the ownership and permissions of a recorded Linux installation before using it for version discovery, inspection, or pinned sync. When ownership cannot be established, discovery continues through the existing installation locations.
  • macOS discovery uses the existing Desktop, system, and PATH locations. A macOS installation available only through a saved record must be made discoverable through one of those locations.
  • Add coverage for the discovery and fallback behavior and update the Remote Link guides and architecture contract. Maintainer security review is requested for this trust decision.

Verification

  • On Windows x64 with Bun 1.4.4, bun run typecheck checked 2,682 files. bun run structure:check, bun run privacy:scan, and git diff --check passed.
  • The documentation build completed and checked 126,212 internal links across 820 pages.
  • At 687f8f4a, one unfiltered run of the five focused Remote Link files and both layout tests passed in an offline Windows x64 Sandbox under the signed-in guest user. Bun 1.4.4, Git for Windows 2.56.1, stock timeouts: 111 passed, 110 skipped, 0 failed, 781 assertions in 141.62 s. The pinned version-probe case completed in 39.62 s under its 60 s limit. The earlier physical-host run had 93 passes, 110 skips and 18 failures. The full repository suite was not run locally.
  • The 30 POSIX trust tests are skipped on Windows. On the same PR head, 687f8f4a, all 30 passed in Ubuntu shard 3/5. All five Ubuntu shards passed.
  • A fresh offline Windows Sandbox ran four ordinary discovery cases with unmodified tests, Windows PowerShell and Bun 1.4.4. Both f2d38e7d and base d61cca12 passed all four: recorded Bun/CLI discovery, served runtime version inspection, census lookup with a separate HOME, and Child precedence. These runs used fixture installations.
  • In an offline Windows Sandbox, the native argv/stdin and installation-order tests reached the original 5-second runner timeout on f2d38e7d. With a diagnostic 45-second limit, both cases passed on that commit and on base. On 687f8f4a, both passed under the normal runner in 3.12 s and 22.90 s. These two tests use the repository's 45-second subprocess budget with a 5-second teardown reserve. The exit, argv/stdin, and installation-order assertions are unchanged. Separate controls rejected a dropped argument and reversed installation order. A teardown check confirmed that the fixture is removed after a late child exits. Typecheck, privacy scan and diff checks passed locally.
  • The complete original log accounts for all 18 Windows failures. Sixteen reported uv_spawn EPERM alone, the pinned version-probe test reported its 60-second runner timeout, and the native argv test reported both a launch denial and its then-current 5-second timeout. A focused run on the physical host at 687f8f4a also reported EPERM starting PowerShell in the pinned-sync and loopback HTTP success cases (1.26 s and 0.11 s). No endpoint block decision was established.
  • All 18 test names passed in existing Windows CI at 6a4ae9d6: pinned sync, 1 case and discovery, 17 cases. Sixteen test bodies and the Windows script builder file are byte-identical between that run and 687f8f4a. Two tests now use the updated subprocess deadline described above. The seven-file native Windows result above covers the current head. Maintainer security review remains outstanding.

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.

Summary by CodeRabbit

  • New Features
    • Remote Link now checks recorded OpenCodex installations on Linux before use, including ownership, permissions, symlink paths, and whether files or parent directories can be replaced. Both the executable and package entrypoint must pass these checks.
    • Untrusted or unverifiable installations are skipped in favor of existing discovery options. Recorded installations are also skipped on macOS and unsupported platforms; macOS installations must be available through other discoverable locations or the SSH account’s PATH.
  • Documentation
    • Updated the Remote Link guides with platform-specific discovery behavior and setup guidance.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds Linux trust checks for recorded remote-runtime paths and applies them before served-runtime candidates run. macOS and unsupported platforms skip recorded candidates. Documentation describes platform-specific selection, and tests cover trust checks, fallback behavior, and test fixtures.

Changes: Recorded Runtime Trust

Layer / File(s) Summary
Recorded path validation
src/link/remote-runtime-trust.ts
Adds a Linux shell check for path metadata, ownership, permissions, and symlink traversal. The check prints the original path only when validation passes.
Served-runtime selection and platform guidance
src/link/ssh-argv.ts, structure/remote-link.md, docs-site/src/content/docs/guides/remote-link.md, docs-site/src/content/docs/ko/guides/remote-link.md
The generated script checks the recorded executable and optional package entrypoint before attempting them. Documentation describes Linux checks, macOS and unsupported-platform fallback, and continued discovery through existing locations.
Trust-check tests and fixtures
tests/clients/link-served-runtime-trust.test.ts, tests/clients/link-*.test.ts, scripts/test-layout/layout-clients.json, tests/fixtures/test-layout-expected.json
Adds tests for trust validation and platform fallback. Updates fixtures with required commands and a Linux platform stub, adjusts Windows test cleanup timing, and registers the new test in the clients layout.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#8424: Adds the serving-runtime census and first-entry served-install lookup used by the path this change now checks.
  • lidge-jun/opencodex#8431: Changes the census reader in the same generated script that this change uses to select recorded runtime candidates.
Merge Risk: Minimal · up to ce8c1

Recorded Linux installations are now ownership- and permission-checked before they are probed, and discovery falls back to existing locations otherwise. No actionable merge-blocking issue was identified in the supplied changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(link): verify recorded installations before probing" matches the main change: the PR adds ownership and permission checks on recorded Linux installations before version probing, inspect…
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.
Full details: Title check

Explanation

The title "fix(link): verify recorded installations before probing" matches the main change: the PR adds ownership and permission checks on recorded Linux installations before version probing, inspection, and pinned sync, and skips recorded installs on macOS. The title is specific, concise, and in the conventional-commit style. It does not cover the Windows census or test fixture changes, which is expected.

Finishing Touches

Generate unit tests (beta)

  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4f634bb and ce8c11e.

Files selected for processing: 1

  • tests/fixtures/test-layout-expected.json

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

@github-actions

github-actions Bot commented Nov 20, 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 20, 2026

luvs01 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Windows follow-up for f2d38e7d: the pinned-sync containment test failed at the same fixture setup operation on both the candidate and the unchanged dev version of the Remote Link implementation and test. Bun returned EPERM from uv_spawn when starting Windows PowerShell, before the fixture exercised the behavior under test. This accounts for the compared case only. The initial run had 18 failures in total; the remaining Windows failures have not been individually classified. The Windows run does not establish POSIX runtime behavior.

luvs01 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Additional Windows evidence for f2d38e7d against d61cca12: I compared the actual argument builders with Bun 1.4.4 on Windows, without running the generated commands. Ten accepted inputs produced identical argument arrays or quoted strings. Three rejected inputs produced identical error types and messages. The cases cover discovery, ordinary CLI arguments, gated update planning, pinned sync and overwrite variants. A POSIX discovery control changed as expected.

I also located five of the locally failing test names in the existing Windows CI logs at 6a4ae9d6. All five passed there: pinned sync and Windows discovery. That run predates the PR base by two commits. This establishes historical results and argument parity for the inputs above. A Windows run of this PR head and a complete classification of the original 18 failures remain outstanding.

@luvs01
luvs01 marked this pull request as ready for review November 20, 2026 13:13
The fixture home now uses its canonical path. macOS tmpdir sits below the
/var symlink, which the trust gate resolves, so the stat stub keyed on the
unresolved path never matched and two foreign-owner cases ran the binary.

The trailing-newline symlink case runs on Linux only: BSD readlink omits the
appended newline when a target already ends in one, which the Linux-only gate
never meets. Ubuntu CI keeps exercising it.
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (per MAINTAINERS.md; maintainer integration, not an independent approval)

  • Exact head: ce8c11e3884e844bd2843120cae2edac53102c6f
  • Checks on this head: 22 passed, 11 skipped, none pending or failing (Ubuntu PR CI; Windows/macOS are covered by the next dev batch gate).
  • Review threads: none unresolved.
  • Review: gpt-6.1-terra, two rounds, final verdict PASS. No shell-injection path through recorded paths and no trust bypass within the stated boundary; credential or token handling unchanged.
  • Fix added in-house (4f634bb8c): the new suite failed on macOS. The fixture home is now canonical (macOS tmpdir sits below the /var symlink, which the gate resolves). The trailing-newline symlink case runs on Linux only, because BSD readlink omits the appended newline when a target already ends in one, and the gate itself only runs when uname reports Linux.
  • Regression: with src/link/ssh-argv.ts restored from dev, tests/clients/link-served-runtime-trust.test.ts gives 26 failures (unsafe recorded binaries and entrypoints get probed).
  • This head merges current dev; on it: typecheck clean, structure:check passes, 7 focused Link files 201 pass / 20 skip / 0 fail on macOS.

@lidge-jun
lidge-jun merged commit a09506f into lidge-jun:dev Nov 21, 2026
37 checks passed
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.

2 participants