Skip to content

fix(plan): use task's cwd for synthetic requests instead of context cwd#90

Merged
branchseer merged 8 commits intomainfrom
01-11-fix_plan_use_task_s_cwd_for_synthetic_requests_instead_of_context_cwd
Jan 11, 2026
Merged

fix(plan): use task's cwd for synthetic requests instead of context cwd#90
branchseer merged 8 commits intomainfrom
01-11-fix_plan_use_task_s_cwd_for_synthetic_requests_instead_of_context_cwd

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented Jan 10, 2026

Lazy Cache Initialization and Improved Subpackage Task Execution

This PR makes two key improvements:

  1. Adds lazy initialization of the SQLite cache to prevent race conditions when multiple processes start simultaneously. The cache is now created only when first accessed, using a file lock to ensure thread safety.

  2. Fixes synthetic command execution in subpackages by ensuring commands use the task's resolved working directory rather than the original invocation context. This ensures tools like oxlint run in the correct package directory when invoked through a synthetic command.

Additional changes:

  • Switched from DiGraph to StableGraph to preserve node indices during removal
  • Added test fixtures for synthetic commands in subpackages
  • Improved documentation for CLI argument handling
  • Added custom_subcommand() method to inspect custom subcommands before session creation

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@branchseer branchseer marked this pull request as ready for review January 10, 2026 17:51
branchseer and others added 3 commits January 11, 2026 02:11
DiGraph uses swap-remove which invalidates indices when nodes are removed
during iteration. StableGraph preserves indices, fixing panic when
executing task graphs with 3+ nodes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When multiple parallel processes (e.g., `pnpm build` running multiple
`vite lib` commands simultaneously) start at the same time, they can all
try to create the SQLite cache database concurrently, causing:
"table spawn_fingerprint_cache already exists"

The fix makes the cache lazily initialized using `once_cell::OnceCell`,
so it's only created when first accessed by commands that actually need
caching. Commands like `vite lib` that don't use caching will no longer
trigger cache initialization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use an exclusive file lock (db_open.lock) to prevent race conditions
when multiple processes initialize the database simultaneously, instead
of relying on CREATE TABLE IF NOT EXISTS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@branchseer branchseer merged commit db0eaf1 into main Jan 11, 2026
7 checks passed
@branchseer branchseer deleted the 01-11-fix_plan_use_task_s_cwd_for_synthetic_requests_instead_of_context_cwd branch January 11, 2026 05:59
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.

2 participants