-
Notifications
You must be signed in to change notification settings - Fork 1
fix(runtime): pass the target runtime dir from install and sync too #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NagyVikt
merged 1 commit into
main
from
agent/claude/credentials-source-install-sync-2026-08-07-13-47
Aug 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...spec/changes/agent-claude-credentials-source-install-sync-2026-08-07-13-47/.openspec.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| schema: spec-driven | ||
| created: 2026-08-07 |
51 changes: 51 additions & 0 deletions
51
.../changes/agent-claude-credentials-source-install-sync-2026-08-07-13-47/notes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # agent-claude-credentials-source-install-sync-2026-08-07-13-47 (minimal / T1) | ||
|
|
||
| Branch: `agent/claude/credentials-source-install-sync-2026-08-07-13-47` | ||
|
|
||
| Completes #139, whose review raised a HIGH that its own merge did not carry. | ||
|
|
||
| ## The HIGH | ||
|
|
||
| #139 made the self-overlay guard opt-in via `options.runtimeDir`. `launch.ts` | ||
| passes it; `cue install` and `cue sync` do not — and both rebuild runtimes | ||
| through `prepareRuntime()`. So either command run from inside a cue session | ||
| still took `CLAUDE_CONFIG_DIR` — its own runtime dir — as the overlay source and | ||
| reproduced #137's self-referential symlinks. The guard was off exactly where the | ||
| materialization happens. | ||
|
|
||
| Both callers now pass the dir they are about to write: | ||
|
|
||
| - `install.ts` — `runtimeDirFor(profile.name, agent)`, matching | ||
| `prepareRuntime`'s own `runtimeKey ?? profile.name` default. | ||
| - `sync.ts` — `runtimeDirFor(key, agent)`; `key` is already the `runtimeKey` | ||
| passed to `prepareRuntime` two lines below. | ||
|
|
||
| ## Why it is a separate PR | ||
|
|
||
| The fix was committed on #139's branch as `91c6601d` but never reached the | ||
| remote before the PR merged — main got only the narrowing commit. Verified after | ||
| the fact on `origin/main`: `isSelfOverlaySource` present (3 hits), `runtimeDir:` | ||
| in install.ts / sync.ts absent (0). Cherry-picked here onto the post-#139 main. | ||
|
|
||
| ## Also carried | ||
|
|
||
| The comment on #139's LOW finding, explaining why the wiring test asserts | ||
| `not.toBe(target)` rather than a concrete fall-through path: `os.homedir()` | ||
| reads the passwd entry, not `$HOME`, so a temp-HOME fixture does not pin the | ||
| branch (measured — it still resolved the real `~/.claude`). No fall-through | ||
| branch can return the target, so the assertion holds on any machine and stays | ||
| mutation-proof. | ||
|
|
||
| ## Verification | ||
|
|
||
| - `bun run typecheck` — clean. | ||
| - `bun run lint` — warnings pre-existing; zero in the touched files. | ||
| - `bun test src/lib/runtime-install.test.ts` — 23 pass / 0 fail. | ||
| - `bun test` (full), branch vs base in the same worktree and shell — failing set | ||
| compared both directions. | ||
|
|
||
| ## Cleanup | ||
|
|
||
| - [ ] Run: `gx branch finish --branch agent/claude/credentials-source-install-sync-2026-08-07-13-47 --base main --via-pr --gate-review --review-provider claude --wait-for-merge --cleanup` | ||
| - [ ] Record PR URL + `MERGED` state in the completion handoff. | ||
| - [ ] Confirm sandbox worktree is gone (`git worktree list`, `git branch -a`). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
🔵 LOW · tests
The new install/sync wiring ships without a regression test, which is the exact gap that let this bug reach main in the first place.
runtime-install.test.tscoversisSelfOverlaySourceandpickClaudeCredentialsSource({runtimeDir})at the unit level, but nothing asserts thatmaterializeProfile()(install.ts:254) and the sync loop (sync.ts:152) actually pass aruntimeDir—src/commands/install.test.tsandWhy this matters
src/commands/sync.test.tscontain noruntimeDirassertion. #139 wired the guard intolaunch.tsonly and the suite stayed green; deleting either line here would likewise stay green and silently resurrect #137's self-referential symlinks. A test that setsCLAUDE_CONFIG_DIRtoruntimeDirFor(<profile>, "claude-code")and asserts the rebuilt runtime's credentials are not sourced from itself (or spies onresolveClaudeCredentialsSourcefor a non-undefinedruntimeDir) would pin both call sites; verified correct otherwise —runtimeDirFor(profile.name, agent)matchesmaterializeRuntime'sruntimeKey ?? profile.namedefault, and sync'skeyis theruntimeKeypassed two lines below.