Repository navigation
feat(tools): search v2 and tree over an ignore-aware contained walk (T2) - #32
Merged
Merged
Conversation
…(T2) search: modes content/names/definition/references, regex and smart case, include/exclude globs, context, limit and max_per_file, exact resume cursor (base64url path\0line), header with matches=shown/total files= scanned= skipped= next= partial= hint=, byte budget respected by the walk itself so nothing is cut mid-body. Zero sensitive results hint the insensitive count. tree: breadth-first fill, (Nf Nd) counts from a bounded sub-walk, single-child chain collapse, packed leaf rows, sizes, @ symlinks, …ignored markers; list_dir stays a hidden alias for tree depth=1 and resolves while tree is exposed. walk: cap-std listing with a stacked gitignore matcher (.git/info/exclude, ancestors, per-directory), generated-directory list, binary sniff, 4 MiB file cap, shared scan budget with entry/byte/time stops. lang: per-language definition tables (Rust, TS/JS, Python, Go, Zig, C/C++, Markdown) compiled lazily per symbol. Deps: ignore, regex, base64 added to qq-core (regex/base64 were already in the lock; ignore brings globset, bstr, crossbeam-deque/epoch). Slice T2 of docs/plans/tool-layer.md.
… and TUI (T2) - list_dir resolves as a hidden alias while tree is exposed; an exposure list naming list_dir exposes tree. - Config vocabulary, pruning list, and the system prompt name tree and steer the model to search/tree over shell grep, rg, find, ls. - TUI reads search and tree metrics from the header (shown/total hits, entries) instead of counting body lines. - New search_walk bench over a synthetic 10k-file workspace (content, definition, references, names, tree) with a same-size target/ tree the walk must skip. - Definition mode prefilters candidate lines with the word-boundary scan before running the anchored table pattern (2x on the full-scan case).
…s measurement The T2 schemas are ~40% larger than the six they replace, which showed up as +7% on tool_dispatch (run start re-serialized and re-hashed every static schema) and +20% on plan_compile. - StaticTool carries its serialized schema; built-ins are serialized once per process behind a OnceLock and cloned as Arc<str>. - ToolCatalog computes the static and full-exposure measurements at compile from the schemas it already serialized; the run loop asks the catalog instead of re-measuring, and only pinned lists are measured afresh. tool_dispatch A/B (pinned core, 12 pairs): base 42.8 µs → cand 41.4 µs median. plan_compile 22.2 → 23.1 µs (was 27.7 µs).
Design: § Built-In Tools names tree and the list_dir alias; § Read-Side Walk (new) covers the cap-std-fed ignore stack, search modes, output grammar, cursor and partial semantics, and tree's fill order and bounds. Ledger: T1 shipped, T2 in review with receipt; root.md records the workspace dependency rows; plan dependency table updated.
This was referenced Sep 14, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
T2:
searchv2 andtreeover one ignore-aware, contained walkSpec: docs/plans/tool-layer.md#d2--read-side-tools-search-read_file-tree-t2-t3 Linear: ENG-772
What changed
User-visible
searchgains modes (content|names|definition|references),regex,case=smart|sensitive|insensitive,include/excludeglobs,context,limit/max_per_file,include_ignored, and acursor. Results group by file asL<n>: text; the header carriesmatches=<shown>/<total>[+] files= scanned= [skipped=] [next=<cursor>] [truncated=bytes] [partial=scan|bytes|time] [hint=case_insensitive_matches=N]. The walk honours.gitignore/.ignore/.git/info/exclude(stacked, git semantics), skips hidden entries andtarget/node_modules/dist/build/.venv/__pycache__/.git, and never follows symlinks. Files > 4 MiB and binary files are skipped and counted.searchnever cuts the middle out of a result: the walk stops at its 12 KiB body budget and hands back a cursor, so every match is reachable across pages and none repeats.treereplaceslist_dirin the advertised catalog: breadth-first fill (top level complete first),(Nf Nd)counts, single-child chain collapse (deep/er/est/), packed leaf rows with sizes,@symlinks,…ignoredmarkers,depth≤ 6,limit≤ 500,glob.list_dirstays a hidden alias fortree depth=1(ignored entries included) so persisted transcripts and grants resolve; it resolves only whiletreeis exposed andexposed_tools: ["list_dir"]exposestree.invalid_regex,regex_too_large,bad_glob,path_not_found,path_escapes_workspace,cursor_invalid,invalid_symbol,not_a_directory,invalid_depth/invalid_limit/…search/treeovergrep/rg/find/ls. TUI reads hit/entry counts from the header (25/90+ hits · 3 files,3/12 entries).Design
tools/walk.rs(new):list_childrenreads one directory through the workspace'scap-stdDir;IgnoreStackusesignore::gitignore::Gitignoreas a matcher only (neverignore::Walk, which opens ambient paths). Containment keeps one addressing scheme. Children sort asname/for directories so a DFS yields bytewise path order — the property the cursor depends on.tools/lang.rs(new): definition templates per language as data; compiled lazily per symbol per language; definition mode prefilters candidate lines with the word-boundary scan (2× on the full-scan case).tools/search.rs: whole-bufferregex::bytesscan, matches mapped to lines afterwards; cursor =base64url(path \0 line);skips_dirprunes whole directories that sort before the cursor without allocating.tools/tree.rs: BFS queue of(dir, depth, parent); counts from a bounded sub-walk;ListDirArgs → TreeArgsalias.tool_dispatch, +20 %plan_compile).StaticToolnow carries its serialized schema (built-ins serialized once per process), andToolCatalogprecomputes the static/full measurements at compile; the run loop asks the catalog and measures afresh only for pinned lists.Dependencies —
ignore0.4 (new; bringsglobset,bstr,crossbeam-deque/epoch),regex1 (already locked via tree-sitter),base64(workspace) added toqq-core. RootCargo.tomlgained the two[workspace.dependencies]rows; recorded inroot.md. No version bumps.How verified
cargo test --workspace: 1315 passed / 0 failed.cargo test -p qq-provider --no-default-features --features test-support: 162 passed.cargo fmt --check✓,cargo clippy --workspace --all-targets --all-features -D warnings✓..gitignore, negation,/vendor/, hidden,target/, andinclude_ignoredlifting all but.git); match perf(provider): prompt-cache breakpoints for Anthropic Messages and Bedrock Converse (C4) #61 reachable by cursor with no repeats across pages; oversized (> 4 MiB) and NUL-binary files skipped and counted; invalid UTF-8 mid-file; CRLF (CR stripped); symlink loop; byte budget → cursor, never a mid-body marker; per-file cap+N more in file; definition/references/regex/context/globs/smart-case/hint; typed failures;treeBFS/counts/chains/packing/…ignored/glob/limit/not_a_directory/invalid_depth; alias exposure; catalog measurement equality; TUI header metrics.treeoutput for the oldlist_dircases, schema hash).Measurements
search_walkcontent, no match, full 10k-file scan (page cache)search_walkcontent, rare symbolsearch_walkcontent, common symbol first pagesearch_walkdefinition / references (full scan)search_walknamessearch_walktree depth 2 (200 dirs + ignoredtarget/)tool_dispatchA/B (pinned core, 12 pairs, median)plan_compileEvidence:
target/qq-perf/t2-2026-09-12/(untracked).Docs
docs/design/tools.md: § Built-In Tools updated; § Read-Side Walk (new).docs/plans/progress/tool-layer.md: T1 shipped, T2 in review + receipt.root.md: dependency rows. Plan dependency table updated.Compatibility
built_in_tool_declarations_keep_their_order_and_schema_identity).searchoutput grammar changed frompath:line:textto groupedL<n>: textunder a header;list_dirresults now carry atreeheader. Persisted transcripts replay as-is;list_dircalls keep executing.MAX_SEARCH_BYTES(16 MiB) removed; the scan bound is now 64 MiB withpartial=bytes.Follow-ups
langtables forread_file mode=outline; T4 givestruncated=bytesa spill handle; T12 reuses the walker for@completion.AGENTS.mdstill names Linear teamDEV; workspace team isENG(issue filed under ENG/qq).