Skip to content

fix(harness-ops): find the session's own CLI binary in inventory - #14042

Merged
kyle-sexton merged 3 commits into
mainfrom
fix/14033-inventory-running-cli
Nov 7, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix/14033-inventory-running-cli

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Closes #14033
Siblings: #14040

Delivers #14033 item 11 and the done-when's marker item; #14040 delivered items 1-10.

Summary

Item 11 of #14033: the release lane's native-drift pass read no Claude Code binary, so it reported version unknown and filed native-drift:inventory-broken:unknown:inventory. Items 1-10 are in #14040. This PR also moves the changelog marker in docs/upstream/claude-code.md to 2.1.319, which closes the release (hub option 1).

Fix

  • inventory.py candidate_binaries() now tries the session's own CLI first, read from /proc/$CLAUDE_PID/exe. Claude Code sets CLAUDE_PID in the Bash and hook subprocesses it starts (env-vars). The cause: run-claude-cli installs the CLI under $LANE_WORK_DIR/cli/node_modules (ci-workflows lane.cjs:1237-1273), which is outside both PATH and the install roots the old search checks. An interpreter exe (node, nodejs, bun) is skipped. PATH and the install roots stay as fallbacks.
  • The lane runs the CLI under bwrap --dev-bind / / with no PID namespace (lane.cjs:782-795), so the parent's /proc entry is visible to its Bash child.
  • docs/upstream/claude-code.md: marker set to 2.1.319 (published 2026-11-06), read by the release lane in run 42411723819.

Verification

  • python3 test_inventory.py: 321 tests OK, including 2 new TestCandidateBinaries cases.

  • Lane-like lookup, with PATH=/usr/bin:/bin and an empty HOME:

    • without CLAUDE_PID: BROKEN: no claude executable found on PATH or in the usual install roots, the CI result;
    • with it: DEGRADED: cli 2.1.319, validated against 2.1.318.
  • changelog-status.sh reads last-applied: 2.1.319 from the moved marker.

  • Not live-verified on CI. The next release-lane run is the proof.

  • Known after this fix: a baseline CI run (CI never advances the previous summary, ci-mode.md:27) still files two items on new keys:

    • native-drift:inventory-degraded:<version>:inventory: the version is past VALIDATED_AGAINST, plus the accepted builtin_plugins floors;
    • native-drift:unresolved-description:send-to-project:inventory.

    Both are real extraction states, not a refile of item 11. They are reported to the hub as a separate question.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 7, 2026 16:21
The release lane installs Claude Code outside PATH and the install
roots, so its native-drift pass read no binary, reported version
unknown and filed an inventory-broken item (#14033 item 11). The
inventory now reads the running CLI through CLAUDE_PID first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release lane read 2.1.319 (run 42411723819, 0 PRs); its handoffs
are #14033 items 1-10 (PR #14040) and item 11 (this branch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 7, 2026 23:03
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T23:03:05.391180Z
We couldn’t complete this review. Comment @codex review to try again.
90dfc47 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 90dfc47f07d889c19138541a553bbc0e5bb56c39: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

critical-findings: 0

I read every hunk of all 5 changed files. None of them matches a trusted-path glob, and no trust control, merge hold, plugin manifest or standing instruction changed.

What I checked

  • inventory.py candidate_binaries() (L227-L236): the new code reads CLAUDE_PID from the environment and resolves /proc/<pid>/exe.
    • The PID only reaches the path if pid.isdigit() passes, so the value cannot inject a path.
    • The resolved file is never run. pick_binary only calls is_file() and stat() on it. read_bundle then reads the bundle bytes out of the file. The script's only subprocess.run calls are git commands (L6073, L6090, L6095), so pointing the candidate somewhere else does not lead to code execution.
    • Setting CLAUDE_PID requires control of the session's own environment. Whoever has that is already the session, so the change opens no new trust boundary.
  • test_inventory.py: test-only mocks of os.readlink and shutil.which. No security surface.
  • SKILL.md: one flag description reworded. No rule was removed, narrowed or softened.
  • docs/upstream/claude-code.md and the .changes fragment: documentation and the changelog marker moved to 2.1.319. No security surface.

The PR description and closing issue contain no embedded directives aimed at this review lane.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 90dfc47f07d889c19138541a553bbc0e5bb56c39: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk in all 5 changed files: the changelog fragment, docs/upstream/claude-code.md, the inventory SKILL.md, inventory.py and test_inventory.py. I also read the code the changed function feeds (pick_binary) and the path-scoped rules that match these files. This is a full review, not a partial one, and it is the lane's first review of this PR, so advisory findings would have been allowed.

candidate_binaries() change (inventory.py#L227-L236)

  • Off Linux: on any platform without /proc, the session lookup quietly does nothing. A missing or unreadable /proc/<pid>/exe raises OSError, which is caught, and the lookup then falls back to PATH and the install roots as before.
  • Interpreters: an exe named node, nodejs or bun is skipped, so an npm-installed session still falls through to the old search.
  • Bad CLAUDE_PID values: any value that isn't all digits is ignored.
  • Deleted binary: a link that ends in (deleted) (the binary was replaced while the session ran) is not a file. pick_binary's is_file() check skips it, and the next candidate wins.
  • Duplicates: the existing dedup step collapses the session binary when it is the same file that PATH resolves to.
  • Tests: the two new TestCandidateBinaries cases cover both branches: the running CLI comes first, and a node launcher is left out. The readlink mock falls through to the real call for other paths, so Path.resolve() in the dedup loop still behaves normally.

Closing issue #14033, "Done when"

Path-scoped rules

  • skill-bodies-state-current-rules: the SKILL.md edit states our own lookup order and repeats nothing volatile from upstream. Pass.
  • cost-claims: no cost claims. Pass.
  • ruff-pin: nothing to judge from the diff.

Not checked by me: the test run (321 OK), the lane-like lookup output and the changelog-status.sh reading in the PR description are what the author says happened. I did not run them. As the author notes, the fix has not been tested on a real CI run yet.

No embedded instructions were found in the PR context or prior-findings files. No plugin manifest changes, so there are no manifest lines.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit b2bc8d9 Nov 7, 2026
80 checks passed
@kyle-sexton
kyle-sexton deleted the fix/14033-inventory-running-cli branch November 7, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code v2.1.319 changelog: 11 handoffs

1 participant