Skip to content

fix(core): the newest installed copy of a harness is launched - #5

Merged
eshatalov merged 2 commits into
mainfrom
claude/codex-version-path-conflict-ac2a84
Oct 3, 2026
Merged

eshatalov merged 2 commits into
mainfrom
claude/codex-version-path-conflict-ac2a84

Conversation

@eshatalov

Copy link
Copy Markdown
Owner

When a harness is installed more than once (for example an npm -g copy under nvm and a native copy in ~/.local/bin), discovery took the first hit on PATH, and the pin cache kept that file until its own mtime changed. A newer copy elsewhere was never launched, and nothing reported it.

Discovery now collects every copy on PATH and in the well-known dirs, runs --version on each and launches the newest. The pin is keyed on the whole candidate set (paths, mtimes, sizes): an unchanged machine admits without a probe, and any install, upgrade or removal re-probes. Duplicate PATH entries and symlink aliases of one file count once. subturn status lists the older copies it skipped.

For a reviewer:

  • A pre-existing discovery.json without candidates is a cache miss and gets rewritten on the first turn.
  • Cost measured on a machine with two claude copies: cold resolve 60 ms, warm resolve 0.55 ms per turn.
  • New test/discovery.test.ts covers PATH order, cache reuse, install, in-place upgrade, removal, aliases and a tie. npm run typecheck and npm test pass; live tests were not run.

Claude Fable 5.1 in Claude Code.

🤖 Generated with Claude Code

When a harness was installed more than once, discovery took the first hit
on PATH and the pin cache kept that file until its own mtime changed, so a
newer copy elsewhere was never launched.

Discovery now collects every copy on PATH and in the well-known dirs, runs
`--version` on each and launches the newest. The pin is keyed on the whole
candidate set (paths, mtimes, sizes), so an unchanged machine admits
without a probe and any install, upgrade or removal re-probes. `subturn
status` lists the older copies it skipped.

Claude Fable 5.1 in Claude Code.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T00:32:54.643450Z e517856 PR opened
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e517856f79

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/discovery.ts Resolved
A shim that dispatches to another file at run time keeps its mtime and
size when its target is upgraded, so the candidate-set key alone would
keep a stale choice. A pin older than a day is probed again.

Claude Fable 5.1 in Claude Code.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@eshatalov
eshatalov merged commit bc5595a into main Oct 3, 2026
1 check passed
@eshatalov
eshatalov deleted the claude/codex-version-path-conflict-ac2a84 branch October 3, 2026 00:35
eshatalov added a commit that referenced this pull request Oct 3, 2026
OpenCode 2 keeps credentials and sessions in one SQLite file, `opencode.db`, and has no `auth.json`, so the opencode plugin could neither check the login nor build a shadow home. It also lists its models before its plugins have added theirs, so a spawn on an OpenCode Go model (or a provider from the user's config) was refused with "model not found" every time.

The plugin now works with OpenCode 2 only.

- **Login check.** Reads the `credential` table of the user's `opencode.db`, read-only.
- **Shadow home.** A per-session snapshot of that file: `VACUUM INTO` from a read-only connection, then every table except the login and schema bookkeeping emptied. The user's sessions never reach the shadow and the shadow's sessions never reach the user's lists.
- **`OPENCODE_DB`.** When the user's environment sets it, the login check and the snapshot read the file it names, and the child gets it set to the shadow database, so the subagent cannot write into the user's.
- **OAuth logins.** Copied with an empty refresh token. The shadow can use the access token but cannot refresh it, so it cannot revoke the user's. When the token expires, turns in that shadow fail with an auth error and a new spawn snapshots the current login.
- **Late models.** When the model is refused with `-32602`, the ACP turn sets it again after each `config_option_update`, for up to 5 s, and records each retry in the evidence. A model that never appears fails with the harness's own refusal, 5 s later than before. This needs OpenCode 2.0.21 or newer; upstream tracks the remaining gap in anomalyco/opencode#52472, and the retry can go once that lands.
- **`subturn status`.** Models come from a throwaway ACP handshake in a temp shadow; `opencode models` would leave a background service running. It shows the list the server gives at session start, so late models such as `opencode-go/*` are not listed even though a turn can select them.
- **Usage.** `cachedWriteTokens` and `thoughtTokens` are read from OpenCode 2's usage records.

Node 22.13 is now the minimum, for `node:sqlite` without a flag.

Two small riders, since they touch the same files: the docs and the live test name the current codex model ids (`gpt-6-luna`, `gpt-6.1-sol`), and plugin comments state each quirk without the date it was seen.

For a reviewer:

- Offline: `npm run typecheck`, `npm test` (36 pass, 3 live tests skipped). New tests cover the login check, the snapshot, resume reusing the shadow, and both late-model paths on the fake agent.
- Live on OpenCode 2.0.22: smoke + resume on `zai-coding-plan/glm-5.3-flash` with `OPENCODE_DB` pointing at a copy of the user's database, which gained no session. Before the rebase onto #5: the same on `opencode-go/muse-spark-1.3-contributor`.

Claude Fable 5.1 in Claude Code.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@eshatalov eshatalov mentioned this pull request Oct 11, 2026
eshatalov added a commit that referenced this pull request Oct 11, 2026
Version bump for 0.2.0. Minor rather than patch because OpenCode support
moved to OpenCode 2 (#6).

Ships since 0.1.1:
- #5 the newest installed copy of a harness is launched
- #6 support OpenCode 2
- #7 OpenCode model is set once, without a retry
- #8 Grok's requested model is no longer overridden by launch campaigns
- #9 README: the caller's instructions are an inline example

Done by Claude Opus 5.5 in Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant