Skip to content

fix(claude-accounts): stop path resolution from creating the config directory - #12309

Merged
nwparker merged 7 commits into
stablyai:mainfrom
makoto-developer:fix/claude-runtime-path-no-mkdir
Sep 13, 2026
Merged

nwparker merged 7 commits into
stablyai:mainfrom
makoto-developer:fix/claude-runtime-path-no-mkdir

Conversation

@makoto-developer

@makoto-developer makoto-developer commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Background Claude usage checks should read account paths without recreating directories. This removes the synchronous mkdirSync from path resolution; credential and configuration writers still create their own parent directories.

What Changed

  • Keep ClaudeRuntimePathResolver.getRuntimePaths() free of directory writes, including inherited CLAUDE_CONFIG_DIR paths.
  • Preserve the existing credential path, colocated configuration preference, home configuration fallback, and environment patch.
  • Cover background usage preparation, repeated lookups with existing/missing directories, and actual managed-credential creation and recreation after the directory is removed.

Why

A usage refresh reached the resolver even with Claude disabled and no managed account, repeatedly recreating ~/.claude. Each path lookup also paid for a redundant synchronous directory operation. The deterministic work-count regression exercises 1,000 lookups with both existing and missing directories: baseline performs 1,000 mkdirSync calls; this change performs zero. No timing or cache-freshness policy changes.

Linked Issue

Fixes #12181.

Visual Proof

N/A — backend path resolution; no rendered or interaction changes.

Testing

Verified against main at 1a9a5f9bc720, with ORCA_BACKGROUND_LAUNCH=1, on macOS:

  • pnpm test src/main/claude-accounts src/main/rate-limits: 692 tests passed in 71 files.
  • pnpm tc:node with an 8 GB Node heap: passed.
  • pnpm run check:code-quality:changed origin/main: passed all three changed-file gates.
  • Formatting and git diff --check: passed.
  • Restoring only the original resolver makes all five targeted regression cases fail; the four path-compatibility cases still pass.

The credential materialization test now starts without a runtime directory and removes the whole directory before a second launch. Both writes succeed and retain the expected credential contents. The existing broader suites cover account switching, readback, snapshots, file modes, and WSL selection. These local checks are not a claim of a full all-platform build/test run; PR CI covers the broader matrix.

Review

All current resolver consumers are in the Claude runtime auth service. Reads handle absent files; credential/config writers create parent directories themselves; Keychain calls use the config path as a namespace. Path construction still uses Node path APIs. Execution-host routing, SSH/WSL commands, folder-workspace behavior, remote wire formats, and refresh intervals are unchanged.

Original implementation by @makoto-developer; maintainer follow-up preserves the contributor commits, updates the branch to current main, and strengthens regression coverage.

AI Disclosure

The original PR disclosed Claude Code assistance. The maintainer follow-up and verification were assisted by OpenAI Codex.

Agent skill upstream boundary

  • Not applicable; no upstream skill content is copied.

Independent review follow-up

Preserve canonical macOS Keychain aliases when a missing config directory sits below a symlinked parent. Resolve the nearest existing ancestor without creating directories, and retain raw-only lookup for broken symlinks, inaccessible paths, or missing paths containing parent traversal (..), whose canonical credential namespace cannot safely be inferred across symlinks. This fixes a rare credential-discovery regression while keeping redundant directory writes removed. Seven real-filesystem alias cases and the existing account suite pass (224 tests across 27 files); Node typecheck and changed-code quality pass. Keychain calls are mocked; no user credentials were accessed.

@makoto-developer
makoto-developer marked this pull request as ready for review August 3, 2026 13:44
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b58169fe-42a0-4189-95f3-841e496f8a03

📥 Commits

Reviewing files that changed from the base of the PR and between ff83f4b and c328187.

📒 Files selected for processing (5)
  • src/main/claude-accounts/keychain-config-directory-aliases.test.ts
  • src/main/claude-accounts/keychain.test.ts
  • src/main/claude-accounts/keychain.ts
  • src/main/claude-accounts/runtime-auth-service-materialization.test.ts
  • src/main/claude-accounts/runtime-paths.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

ClaudeRuntimePathResolver.getRuntimePaths no longer creates the resolved configuration directory. The unused mkdirSync import was removed. Tests cover default and inherited configuration directories, path-resolution non-materialization, credential placement, configuration-file precedence, and CLAUDE_CONFIG_DIR environment isolation.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c3281

Runtime path lookup remains side-effect free while credential materialization and keychain alias handling retain their required behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #12181 requires side-effect-free runtime path reads and usage checks, while credential and configuration writes must still create parent directories. `ClaudeRuntimePathResolver.getRuntimePaths()…
Out of Scope Changes check ✅ Passed The changes stay within issue #12181. The Keychain alias update preserves canonical macOS aliases when a configuration directory is missing, which supports side-effect-free path handling. Its tests an…
Title check ✅ Passed The title clearly and concisely describes the main change: preventing path resolution from creating the Claude configuration directory.
Description check ✅ Passed The description covers the required ELI5, change summary, rationale, linked issue, visual proof, testing, review, AI disclosure, and upstream-boundary sections. It provides detailed regression and com…
  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

makoto-developer and others added 2 commits August 4, 2026 09:23
…irectory

getRuntimePaths() created ~/.claude as a side effect of resolving paths, so
the deferred usage refresh materialized it even when Claude was disabled and
no session had ever run. Writers already create the directory themselves
(writeJson, writeRuntimeCredentials, the metadata dir), and the keychain
helpers only use configDir as a service name, so resolution can stay pure.

Fixes stablyai#12181
@Jinwoo-H
Jinwoo-H force-pushed the fix/claude-runtime-path-no-mkdir branch from 54a33fe to ff83f4b Compare August 4, 2026 14:10

@Jinwoo-H Jinwoo-H left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact candidate ff83f4b. The background auth-preparation oracle is red on current main and the explicit revert, green on this head, and legitimate credential/config writers still create their parent directories.

@nwparker nwparker removed the P1 label Aug 19, 2026
@nwparker
nwparker merged commit d1309d8 into stablyai:main Sep 13, 2026
26 checks passed
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.

[Bug]: Orca creates ~/.claude during background usage refresh even when Claude is disabled

6 participants