Skip to content

⚡️ parallelize --deep synthesis batches - #411

Open
mezis wants to merge 2 commits into
trailhq:mainfrom
mezis:feat/concurrent-synthesis
Open

mezis wants to merge 2 commits into
trailhq:mainfrom
mezis:feat/concurrent-synthesis

Conversation

@mezis

@mezis mezis commented Sep 16, 2026

Copy link
Copy Markdown

Why

--deep concept synthesis still runs one LLM batch at a time. File summaries already honour -j; this pass does not, and engine.init() never received --concurrency.

On a large repo (~6k files, 98 synthesis batches) that serial wait is many hours. Each batch is a long call (~48k chars in, 8k tokens out). A local or OpenAI-compatible server can overlap them; today the GPU/API sits idle between batches.

The change

  • Thread -j / --concurrency into graft init (and workspace child builds).
  • Run synthesis through the same mapWithConcurrency pool as summaries.
  • Per-batch catch + LlmFailureGate: a dead provider stops further calls; a throw does not drop in-flight siblings; empty results stay uncached (--allow-partial still sees result.errors).
  • Progress: start and result are each a full stderr line, so concurrent batches do not share a \r spinner.

Tests

-j never reached concept synthesis, so a local LLM waited on one batch at a time. Share that pool and keep sibling batches when one throws.
A \r spinner plus a newline-terminated batch result shared one stderr line and scrambled under -j.
@trailhq-graft

trailhq-graft Bot commented Sep 16, 2026

Copy link
Copy Markdown

🌱 graft blast radius

3 areas changed → 1 area can be affected. 1 dependent symbol, depth 2.
Tests: no test reaches Workspace Child Building; CLI Initialization has tests the diff did not touch; 1 area updated its tests.
Tag: @anirudhkumar-nanonets — 3 of 4 areas · @shhdwi — 3 of 4 areas · @Frankie-Xu — Build Context

flowchart TB
  A0(("Workspace Splitting<br/>1 symbol"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Workspace Splitting 1 src/graph/workspace.ts:L709-L722 splitWorkspace — calls, depth 1 CLI Initialization, Workspace Child Building
Who knows this code — 4 people across 4 areas
Area Who knows it
CLI Initialization · changed @anirudhkumar-nanonets — 42 commits, last today · @shhdwi — 24 commits, last 1mo ago
Workspace Child Building · changed @shhdwi — 3 commits, last 1mo ago · @anirudhkumar-nanonets — 2 commits, last 1mo ago
Build Context · changed @anirudhkumar-nanonets — 4 commits, last 27d ago · @Frankie-Xu — 2 commits, last 16d ago
Workspace Splitting · affected @shhdwi — 6 commits, last 1mo ago · Buseong Kim — 2 commits, last 16d ago

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 1 dependent symbol, grouped by area

Workspace Splitting — 1 symbol in 1 file

  • src/graph/workspace.ts:L709-L722 — splitWorkspace (calls, depth 1)
    712: buildChild: (childDir: string, childName: string) => Promise<void>,
Test signal per changed area — 1 ✓ · 1 ⚠ · 1 ✗

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • CLI Initialization — 1 of 1 reached · 1 test file reaches it, none changed here
  • Workspace Child Building — 0 of 1 reached · no test file reaches it
    • not reached: buildChild
  • Build Context — 1 of 1 reached · 1 test file changed here: test/context.test.ts
5 test suites also reference this code

5 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/context-checkpoint.test.ts
  • test/context-only-dir.test.ts
  • test/covers.test.ts
  • test/utf16-source.test.ts
  • test/workspace.test.ts

graft blast · origin/main...HEAD · depth 2 · 5 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Sep 16, 2026
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.

1 participant