OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[claude-code plugin] recall compressor spawns `claude -p` without cwd — child registers the user's worktree as its cwd

Open devstar-korea opened this issue 4 weeks ago • 0 comments

Summary

The Claude Code plugin's local recall compressor (recallCompress: auto / client) spawns claude -p without a cwd, so the child inherits the editing session's current directory. When that session works inside a git worktree, the short-lived compressor session registers that worktree as its working directory in ~/.claude/sessions/<pid>.json. Any tooling that treats "another live session whose cwd is this worktree" as a sign of concurrent use (worktree-isolation guards in multi-session setups) then sees a phantom occupant on every user prompt.

Where

claude-code-openviking-memory 0.6.9 — scripts/lib/host-compressor.mjs, runCommand():

child = spawn(command, args, { env: childEnv(), stdio: ["pipe", "pipe", "pipe"] });

Observed

  • Windows 11, Claude Code 2.1.287, plugin 0.6.9, default recallCompress: "auto".
  • One session per user prompt appears under the worktree's project directory (~/.claude/projects/<encoded-worktree-path>/<id>.jsonl, ~31 lines), first message: You are a memory relevance compressor utility. Do not use any tools. ...
  • Its ~/.claude/sessions/<pid>.json has "entrypoint":"sdk-cli" and "cwd":"<the worktree>" for the tens of seconds it runs.

Suggested fix

The compressor only transforms stdin text and needs no project context, so run it from a neutral directory, e.g.:

child = spawn(command, args, { env: childEnv(), cwd: os.tmpdir(), stdio: ["pipe", "pipe", "pipe"] });

This also keeps the child from picking up project-level CLAUDE.md / settings of whatever repo the user is in. (We applied the same fix to our own claude -p helper hook earlier and it removed the phantom-session registrations.)

Workarounds we considered

recallCompress: "server" or "off" avoids the local spawn but changes where/whether the digest is produced; a cwd on the spawn would keep the default behaviour intact.

devstar-korea avatar Nov 05 '26 15:11 devstar-korea