Background sync inherits the session's working directory and keeps worktrees from being deleted on Windows
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- cli, operating-systems
Research direction
Start by reading sync-cli.js and tracing the detached background spawn and summarizer subprocess creation described in the issue. Check how each subprocess receives its working directory and whether the sync already uses absolute paths for transcripts. Reproduce on Windows by ending a session in a temporary worktree and attempting to delete it; completion means the detached sync and summarizer use a neutral working directory and no longer keep the worktree open.
Written by the indexing model from the issue text.
Description
Version: 1.6.0, Windows 11, Claude Code started by an orchestrator that gives each agent its own git worktree.
What happens: the SessionStart hook runs episodic-memory sync --background. sync-cli.js re-spawns itself detached (spawn(process.execPath, [...], { detached: true, windowsHide: true, stdio: [...] })) without a cwd option, so the background sync inherits the session's working directory, and the summarizer's claude subprocess inherits it in turn. On Windows a process's current directory is an open handle, so that directory cannot be deleted while the sync runs (several minutes with summaries). An orchestrator that removes a worker's worktree right after the worker finishes gets "The process cannot access the file because it is being used by another process" (git unregisters the worktree, but the empty folder stays). The parent session is already gone, so nothing points at the orphaned node ... dist/sync-cli.js holding the folder.
Reproduce: start a session in a throwaway folder, end it, and try to delete the folder while node ... dist/sync-cli.js is still running; it succeeds as soon as that process (and its claude child) exits or is killed.
Suggested fix: give the detached background spawn, and the summarizer subprocesses, a neutral working directory, e.g. cwd: os.homedir() (or the index/data directory). Nothing in the sync depends on the session's directory as far as I can tell, since it reads transcripts by absolute path.
Workaround today: EPISODIC_MEMORY_DISABLE_AUTO_SYNC=1 for the agent sessions, at the cost of no auto-sync there.
Possibly related: #189 (summarizer and removed worktree cwd).
- Dominant language
- TypeScript
- Stars
- 511
- Forks
- 154
- Avg merge
- 14d 20h
- Merged PRs (30d)
- 6
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from obra/episodic-memory
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
obra/episodic-memory#218 ·
-
Sync reads the whole exchanges table once per archived file: no index on exchanges.archive_pathOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
obra/episodic-memory#216 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
obra/episodic-memory#195 ·
-
Sync reads every changed transcript whole in hasConversationContent (1.6 GB for a 507 MB file)Possibly taken @gezerui888 claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
obra/episodic-memory#194 · 2 comments ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
obra/episodic-memory#191 ·
All issues in obra/episodic-memory
Similar issues
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainers usually reply within 1 day
-
area: middleware enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
agent/quality testing
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
juspay/agent-distro#203 ·
Maintainers usually reply within 1 day