Skip to content

Workspace file APIs: glob and search - #13633

Merged
vito merged 16 commits into
mainfrom
llm-workspace-file-apis
Jul 14, 2026
Merged

vito merged 16 commits into
mainfrom
llm-workspace-file-apis

Conversation

@vito

@vito vito commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Note

Stack 2/5, stacked on #13600 — each PR is based on the one below it, so the diff shows only this PR's own changes. Merge bottom-up; when a PR below merges and its branch is deleted, GitHub retargets this one automatically and the rest of the stack gets rebased.

  1. Engine & TUI fixes: clientdb writes, dagql fan-out, high-verbosity traces #13632 — Engine & TUI fixes
  2. Workspace file APIs: glob and search #13633 — Workspace file APIs: glob and search 👈 this PR
  3. LLM foundation: providers, config, session CLI, and TUI #13634 — LLM foundation: providers, config, session CLI, and TUI
  4. LLM ⇄ Workspace: object tools and Env removal #13635 — LLM ⇄ Workspace: object tools, Env removal, and @agent plugins
  5. llm-workspace dev tooling: skills, tui-qa agent, sparse-read design doc #13636 — llm-workspace dev tooling

Adds two file-discovery APIs to Workspace:

  • feat(workspace): add Workspace.glob API
  • feat(workspace): add Workspace.search API

🤖 Generated with Claude Code

@vito
vito changed the base branch from llm-workspace-engine-tui-fixes to main July 13, 2026 21:21
@vito
vito force-pushed the llm-workspace-file-apis branch from a401ef8 to c5420c2 Compare July 13, 2026 21:27
@vito
vito changed the base branch from main to llm-workspace-engine-tui-fixes July 13, 2026 21:34
@vito
vito force-pushed the llm-workspace-engine-tui-fixes branch from 320d61a to a0981f4 Compare July 13, 2026 21:57
@vito
vito force-pushed the llm-workspace-file-apis branch 4 times, most recently from 1d2c945 to ad03dfd Compare July 14, 2026 02:13
@vito
vito marked this pull request as ready for review July 14, 2026 02:41
@vito
vito requested review from a team as code owners July 14, 2026 02:41
@grouville
grouville force-pushed the llm-workspace-engine-tui-fixes branch from a0981f4 to e38e693 Compare July 14, 2026 08:56
Comment thread core/schema/workspace.go Resolved
Comment thread engine/client/filesync.go Resolved
Comment thread engine/client/filesync.go Resolved
@vito
vito changed the base branch from llm-workspace-engine-tui-fixes to main July 14, 2026 14:54
vito added 5 commits July 14, 2026 10:55
database/sql had no MaxOpenConns limit, so each concurrent query got
its own SQLite connection. SQLite only allows one writer at a time;
under write contention every extra connection spins in the busy
handler, and in modernc.org/sqlite that wait is a raw nanosleep
syscall pinning an OS thread per connection. During a burst of
concurrent telemetry inserts this exhausted the Go runtime's
10000-thread limit and crashed the engine.

With a single connection, concurrent queries queue in database/sql's
pool (plain goroutine parking) rather than busy-waiting inside SQLite.
This trades away WAL-mode read/write concurrency, which is acceptable
now that log writes are batched and reads are periodic bounded drains.

Signed-off-by: Alex Suraci <[email protected]>
clientLogs was registered directly as a log Processor, so every log
record emitted anywhere in the engine did a synchronous InsertLog into
the per-client SQLite DB on the emitting goroutine (plus one more per
parent client). A single query fanning out into thousands of parallel
resolutions (e.g. a large Workspace.search result with all fields
selected) piled thousands of concurrent writers onto SQLite's write
lock, each busy-waiting in a raw nanosleep syscall that pins an OS
thread in modernc.org/sqlite, crashing the engine with "fatal error:
thread exhaustion" once the runtime hit its 10000-thread limit.

Wrap the exporter in a BatchProcessor with the same NearlyImmediate
interval already used for live span batching, so records are queued
and inserted by one background goroutine per client instead. The
synchronous OnEmit path is removed so it can't be reintroduced by
accident.

Signed-off-by: Alex Suraci <[email protected]>
Resolve and the list-element path in resolvePath used unbounded conc
pools: one goroutine per sibling selection and one per list element,
recursively. A single query selecting several fields on a large list
(e.g. thousands of Workspace.search results) exploded into tens of
thousands of concurrent resolutions, each emitting telemetry, which
contributed to a thread-exhaustion engine crash.

Cap each pool at 100 goroutines. Pools are per-node, so this bounds
fan-out width rather than total request concurrency, and each pool's
limiter is independent, so a blocked parent pool cannot deadlock a
child pool. Legitimate parallel workloads still run 100 wide per
level; pathological fan-outs are throttled instead of unbounded.

Signed-off-by: Alex Suraci <[email protected]>
IsExpanded gated tool-call and rolled-up spans behind an unconditional
neverExpand check, so no verbosity level could ever open them. Zooming a
slow LLM tool call with 'dagger trace --span <id> -vvvvv' showed the same
collapsed rollup as with no flag, hiding the call tree beneath it.

Let a verbosity at or above the expand-completed threshold punch through
the rollup boundary, matching the existing alwaysExpand gate, and honor
per-span verbosity like the sibling ShouldShow checks. Below that
threshold the guts stay hidden as before.

Signed-off-by: Alex Suraci <[email protected]>
The trace loader always streamed priority spans and backfilled subtrees
lazily on expand. But at a verbosity that expands every completed span
(or --debug/--expand), the whole tree renders open, so lazy loading just
leaves never-expanded spans unfetched in report mode's single render and
costs a round-trip per expand interactively.

Fetch the entire trace up front (Incremental: false) when the tree is
going to be fully expanded anyway, keyed on the same threshold IsExpanded
uses. Lower verbosities keep the incremental behavior.

Signed-off-by: Alex Suraci <[email protected]>
vito and others added 11 commits July 14, 2026 10:55
Mirrors Directory.glob for the host filesystem. Adds a new
GlobCallerHostPath engine capability that walks the host directory and
matches paths against a glob pattern using the same patternmatcher used
by Directory.glob, avoiding any filesync.

Signed-off-by: Alex Suraci <[email protected]>
Mirrors Directory.search for the host filesystem. Runs ripgrep
client-side via a new SearchCallerHostPath engine capability, falling
back to grep if rg is unavailable. Avoids any filesync — the search
tool runs directly on the caller's host and returns structured results
over the existing diffcopy protocol.

Emits search results to the span's stdout using the same format as
Directory.search: file paths for files-only mode, or file:line:content
for full results. Logging happens engine-side as results are received
from the client. The client additionally creates an internal span so you
can see exactly the command it shelled out to and results it saw.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
TestBaseSchemaAllowlist failed in CI because the new Workspace.glob and
Workspace.search fields were installed without a view gate, leaking them
into the base schema visible to the oldest supported module view. Gate
both fields with View(AfterVersion("v1.0.0-0")) like the rest of the
native workspace API surface, and bump the globber, searcher, and
files-searcher test fixture modules to engineVersion v1.0.0 so they can
still see the gated fields, mirroring the precedent set for
Workspace.cwd fixtures in b1fab4b.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Workspace.search passed explicit path operands straight to ripgrep or
grep with cmd.Dir set to the workspace root, so arguments like
../secret.txt could read files outside the workspace. Validate and
normalize paths the same way Directory.search does: treat absolute
paths as root-relative, reject anything non-local after cleaning, and
resolve symlinks scoped to the root so a symlinked operand cannot point
outside it either.

Signed-off-by: Alex Suraci <[email protected]>
The grep fallback only honored the search limit when parsing content
matches; the files-only branch appended every file grep printed. Stop
appending once the limit is reached, matching the ripgrep path.

Signed-off-by: Alex Suraci <[email protected]>
globHostPath walked the entire host directory tree even after the
request context was canceled, since WalkDir had no way to observe it.
Pass the stream context in and check it from the walk callback so the
walk stops promptly when the caller goes away.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the llm-workspace-file-apis branch from aad0a00 to c767c6f Compare July 14, 2026 14:55
@vito

vito commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@grouville Fixed all three and pulled in the tests - thanks!

edit, related: also pointed this PR against main since it doesn't strictly depend on the first PR (and neither do the rest)

@vito vito modified the milestones: 1.0.0-beta.1, v1.0.0 Jul 14, 2026
@grouville
grouville self-requested a review July 14, 2026 17:46
@grouville
grouville force-pushed the llm-workspace-file-apis branch from c767c6f to 03f6e49 Compare July 14, 2026 17:47
@vito
vito force-pushed the llm-workspace-file-apis branch from 03f6e49 to c767c6f Compare July 14, 2026 18:02
@vito
vito merged commit abe4771 into main Jul 14, 2026
88 checks passed
@vito
vito deleted the llm-workspace-file-apis branch July 14, 2026 18:51
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