Repository navigation
fix(locate): keep Codex's shared skills read when a root is recorded - #1890
Conversation
`rootsOf` re-roots a tool's declared reads through `relocated()`, which runs the read through `applyToolRoots` as if it were the tool's skills path. With `toolRoots.codex` recorded, the one-entry map made the read's own root count as Codex's, so both reads became `<root>/skills`: the shared `~/.agents/skills` teamai writes disappeared from what pull and doctor see Codex reading, and every pull failed "codex reads the skills teamai writes" with advice pointing at the configured path instead (Tencent#1886). Move a declared read with a recorded root only when it hangs off one of the tool's own roots, the set `applyToolRoots` moves (`toolPathRoots` of the tool's configured paths plus its shipped default). A bare file name still moves, so `.claude.json` keeps following `CLAUDE_CONFIG_DIR`. Regression test in `locate.test.ts`: a recorded Codex root reads `['<root>/skills', '~/.agents/skills']` and reports no unread writes.
|
No findings. The current diff shows no concrete bug or review-rule violation I can confidently identify. The PR description documents sufficient testing: a regression test, related suites, lint/typecheck, and a representative before/after real-CLI Review was read-only; I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at be526b2.
What I checked
- Red on main, green here. With main's
src/locate.ts, the new case "reads the recorded skills directory and the shared one" fails. With this head,locate.test.tsandtool-roots.test.tspass (129 tests), and typecheck passes. - Real CLI on POSIX, as a pair. Each verify world had a git team repo with one skill, user scope, Codex on PATH, and
CODEX_HOME=$HOME/.codex-workrecorded at init:- main (d1b2528): FAILED.
teamai pullends with✖ codex reads the skills teamai writes → codex does not read …/home/.agents/skills. Point toolPaths.codex.skills …, andteamai doctorshows the same failed check. - this head (be526b2): VERIFIED.
pullends with no failed check, anddoctorshows✔ codex reads the skills teamai writes. The skill lands in~/.codex-work/skills. A secondpullis a clean no-op ("Already synced"), and the verify world's uninstall check reports nothing left behind.
- main (d1b2528): FAILED.
- Scope. Without a recorded root,
relocated()now returns the read as it is, which is whatscopedToolPathsalready did whentoolRootswas empty. A bare file name still moves, so Claude's.claude.jsonkeeps followingCLAUDE_CONFIG_DIR.
[P2 non-blocking]
- The new helper copies an existing private one.
rootsRecordedRootMoves(locate.ts:592-598) has the same body asrelocationRootsOfinsrc/types.ts:3515, which is whatapplyToolRootsuses. There is one difference:applyToolRootspasses thetoolRootskey (toolRootsKeyOf(tool)), and this passes the tool. For an instance recorded on the root of the tool it extends, the two can disagree about which roots move. ExportingrelocationRootsOfand callingrelocationRootsOf(toolRootsKeyOf(tool), install.toolPaths)would keep one definition, and would matchapplyToolRootsfor instances too. Fine as a follow-up.
[P3 nit]
- In my world nothing was written to
~/.agents/skills, on main or on this head. Only~/.codex-work/skillsgot the skill. The body says the skill was written to both, so the difference may come from the Codex version or which other tools are present. It doesn't affect the fix: the shared directory is back among the reads, and that is what the check needs. locate.ts:585has a double blank line before the new doc comment.
CI review. No findings. We agree, apart from the P2 above.
Merge risk. Low. One closure in path resolution changes, and only when a tool root is recorded.
The Tencent#1886 fix moved a declared read only when it hangs off one of the tool's roots, and built that set from the tool's own paths plus its shipped default. An instance (`extends: codex`) has no shipped default of its own, so a read that spells Codex's `.codex/skills` matched nothing, stayed un-relocated, and `unreadWrites` then reported the instance's write under the recorded root as not read — `tool-instances.test.ts` failed on it, and CI with it. An instance reads through the tool it extends, so its shipped root is that tool's default. Only the "no shipped default for an instance" half was wrong; the guard against re-rooting a read that names no root keeps Tencent#1886 fixed. Co-Authored-By: Claude Code <[email protected]>
|
No findings. The current diff contains no concrete bug or Code Review Rules violation I can confidently identify. The earlier review reported no findings, so none require resolution. The PR description documents sufficient testing: a failing-before-fix regression test, related suites, lint/typecheck, and a representative before/after real-CLI Review was read-only and limited to the specified diff. I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving again at 52a08bf.
What changed. The CI run at be526b2 failed on tool-instances.test.ts ("relocates an instance with no home to the recorded root of the tool it extends…"). An instance (extends: codex) got no shipped default, so a read under Codex's .codex/skills matched no root. Now the shipped roots come from the base tool for an instance too, and an instance's own default paths are still not assumed.
What I checked
- With be526b2's
locate.ts, that case fails (1 failed, 98 passed). With this head,tool-instances.test.tsandlocate.test.tspass (181 tests), and typecheck passes. - The earlier real-CLI pair still covers a plain Codex root. This commit changes only how an instance finds its base's roots.
CI review. No findings, and we agree. My earlier P2 and P3 still stand as non-blocking.
Merge risk. Low. An instance now relocates reads under its base tool's default roots, as the base tool already did.
Summary
A member who records
CODEX_HOMEat init had everypull(anddoctor) failcodex reads the skills teamai writesfor the shared~/.agents/skills— with advice that cannot work, since the write judged unread is the shared directory, not the configured skills path.rootsOfresolves a tool's declared reads throughrelocated(), which ran each read throughapplyToolRootsas if it were the tool'sskillspath. WithtoolRoots.codexrecorded, the one-entry map made the read's own root (.agents) count as one of Codex's roots, so both reads became<recorded root>/skillsand the shared directory vanished from the readsunreadWriteschecks.relocated()now moves a declared read only when it hangs off one of the tool's own roots — the setapplyToolRootsmoves (toolPathRootsof the tool's configured paths, plus its shipped default). A bare file name still moves, so Claude's.claude.jsonkeeps followingCLAUDE_CONFIG_DIR; Claude's and Cursor's declared reads hang off their own roots and are unchanged.Fixes #1886.
Type of Change
Bug fix (no behavior change beyond the reported check).
Test Plan
src/__tests__/locate.test.ts: withtoolRoots: { codex: '/home/m/.codex-work' }in user scope,locate('codex', 'skills', …)reads['/home/m/.codex-work/skills', '/home/m/.agents/skills'],sharedis~/.agents/skills, andunreadWritesis empty. Reverting onlysrc/locate.tsfails it (duplicate<root>/skillsreads) — the reported symptom.locate(82),tool-roots,doctor-delivery,skills(295 together), andlint+typecheckpass.CODEX_HOME=$HOME/.codex-workrecorded at init:main17238b7 build):pullends⚠ ✖ codex reads the skills teamai writes → codex does not read …/.agents/skills, anddoctorshows the same failed check;pullends without a failed check anddoctorshows✔ codex reads the skills teamai writes, with the skill written to both~/.codex-work/skillsand~/.agents/skills.Notes
Not checked: a real-CLI run on Windows. The change is in path resolution shared by every tool, which the
locateandtool-rootssuites cover.