Skip to content

feat: selector round-trip + canonical discover emission (1.7.0) - #19

Merged
sting8k merged 8 commits into
mainfrom
us071-step3-selector-roundtrip
Aug 13, 2026
Merged

sting8k merged 8 commits into
mainfrom
us071-step3-selector-roundtrip

Conversation

@sting8k

@sting8k sting8k commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Shared typed path:symbol selector grammar with a single resolution seam, consumed by show/context/trace — canonical selectors now round-trip between command output and command input.
  • discover emits the canonical owning-container selector for resolvable hits, including per-term sections of batch (comma-separated) queries.
  • Preserves exact selector evidence through display; consistent copyable-path classification.
  • Release prep 1.7.0 (Cargo.toml, npm/package.json, CHANGELOG, Cargo.lock).

Known limitation (documented in CHANGELOG + GUIDE)

  • Dotted bare terms inside batch discover queries (discover 'A.b,C') resolve as free-text for the dotted term; its canonical selector is not emitted. Single-term dotted queries are unaffected.

Verification

  • cargo fmt --check OK, cargo clippy -- -D warnings clean, cargo test --locked 1259 passed / 0 failed (54 suites).
  • node npm/install.test.js PASS; npm pack --dry-run = srcwalk-1.7.0.tgz.
  • Field evidence: binary at 848d272 ran 7 live benchmark sessions (Python/TS/Rust/Go incl. Kubernetes-scale repo) with zero navigation fabrications; emitted selectors were adopted verbatim by agents (copy-rate up to 67% on Python).

…primitives

US-071 Step 3 Step 1 (emit mapping). Discover builds the symbol selector
from outline primitives (deepest owning container / Go receiver, dropping
namespace wrappers) rather than the display-qualified name, so C# emits
JsonSerializerOptions.GetTypeInfoInternal and never
System.Text.Json.GetTypeInfoInternal.

qualified.rs: resolve_selector_matches (distinct sorted ranges; duplicate
rows deduped) + selector_from_outline; resolve_selector_first delegates.

semantic.rs: build_target requires UNIQUE cardinality through the shared
resolver for symbol_backed in ALL cases - an ambiguous top-level bare name
(N>1 distinct ranges) is never symbol-backed (no first-match escape hatch).
The definition fallback is RANGE-OWNED: find_function_definition_member
recovers the ACTUAL outline member at the exact range (returns None when
distinct names share the range), never derives from a display string or line
number, so a simple def_name rebuilds the real member and a multi-dot
display name no longer trips the T21 trap.

tests: in-source display-boundary coverage including through
context_target_for_match with real Match + OutlineCache for both
def_name=Some("foo") and Some("System.Text.Json.GetTypeInfoInternal"),
plus same-range/different-name ambiguity; US-065 updated so both same-file
top-level helpers fall back to numeric ranges.
US-071 Step 3 Step 2 (shared grammar/resolution). One shared result
distinguishes every path-symbol state so show/context/callees/callers handle
ambiguity and unresolved identically.

section.rs: typed PathSymbolResolution (NotForm/UnsupportedColonSymbol/
NamedPathMissing/Unique/NamedFileUnresolved/NamedFileUnreadable/
NamedFileUnresolvable/Ambiguous). The split finds the single separating colon
while preserving a Windows drive colon (C:\ / C:/ stay in the path) and
keeping range grammar (path:1-3) as NotForm; a colon-bearing Rust A::target is
an explicit unsupported state, never silently normalized to a dotted selector.
resolve_symbol_ranges surfaces distinct same-file matches via
resolve_selector_matches so N>1 is Ambiguous, not silent first-pick.
resolve_path_symbol_target preserves legacy behavior: only a real readable
file yields Some(range=None); missing path, unreadable, ambiguous, colon all
return None.

qualified.rs: terminal_callable_key shared helper picks the terminal after the
RIGHTMOST separator across both '.' and '::' (A.B::method -> method,
A::B.method -> method), with explicit trailing/leading/empty handling so the
lookup key is never an empty string.

bfs.rs: frontier bare-name derivation delegates to terminal_callable_key,
removing the competing ad-hoc rsplit_once('.') / rsplit_once('::').

tests: typed resolution states incl missing-path, ambiguous cardinality,
Windows drive split (C:\ and C:/), terminal key rightmost+table. 1231 pass;
clippy/fmt/diff-check clean.
…t/trace

US-071 Step 3 Step 3 (command plumbing). show, context, trace callers, and
trace callees now route <path>:<symbol> through one shared consumer
(commands::pathsymbol) instead of four private spellings.

- Same explicit intent in all four for a raw `::` selector.
- Unique target: show/context/callees read the exact owning range; callers
  looks up the terminal callable key while the canonical root is preserved
  in headers, counts, pagination, and recovery (search::callers::CallerRoot).
- Missing / unreadable / unresolvable / ambiguous never broaden to a bare
  search; candidates are bounded. context alone keeps named-file (never bare)
  semantics when an existing file defines no such selector.
- callees no longer requires global uniqueness: a same-name definition in
  another file cannot block an exact root.
- callers states the path only identifies the definition and call sites stay
  by-name, so same-name sites may be included; depth>=2 marks only the root
  exact and caveats that later hops expand by name.
- An exact root outside --scope stays readable; relation search remains
  scope-bounded and the output labels it.

1235 passed, 0 failed; clippy/fmt clean.
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds parser-validated path:symbol selectors that round-trip through discovery, source reads, context, and call tracing.

  • Centralizes exact selector parsing, resolution, ambiguity handling, and command errors.
  • Emits canonical structural targets with numeric fallback when uniqueness cannot be proven.
  • Preserves scope boundaries and labels by-name caller/callee limitations.
  • Adds cross-command, ambiguity, external-scope, and Windows-path coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/read/section.rs Introduces the shared path-symbol resolution states and cardinality-aware exact-range resolution.
src/commands/pathsymbol.rs Centralizes consistent command-facing outcomes and bounded ambiguity diagnostics.
src/lang/qualified.rs Adds canonical selector construction, distinct-range matching, and terminal callable-key handling.
src/commands/callers.rs Accepts exact roots while retaining explicitly labeled direct by-name caller semantics.
src/commands/callees.rs Anchors callee extraction to the exact resolved body and labels later by-name traversal.
src/search/display/structural_targets.rs Emits validated canonical selectors and falls back to numeric ranges for ambiguity.
tests/us071_selector_round_trip.rs Exercises emitted selector replay across all four supported commands and key scope and ambiguity cases.
tests/windows_paths.rs Covers drive-qualified selector parsing and emitted command behavior on Windows.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    D[Discover structural hit] --> V{Selector resolves to exactly one body?}
    V -- Yes --> S[path:symbol]
    V -- No --> N[path:start-end]
    S --> R[Shared selector resolver]
    R --> SH[show exact body]
    R --> CT[context exact range]
    R --> CR[trace callers by terminal name]
    R --> CE[trace callees from exact root range]
    N --> SH
Loading

Reviews (3): Last reviewed commit: "chore(release): prepare 1.7.0" | Re-trigger Greptile

Reuse the resolver-validated target planner per batch section and route dotted comma queries before automatic file inference. Preserve explicit mode overrides and numeric-offer suppression.\n\nKnown limitation: dotted terms inside a batch still return zero through the pre-existing batch matcher; single dotted queries remain supported and the follow-up is recorded.
@sting8k sting8k changed the title feat: round-trip exact selectors across commands feat: selector round-trip + canonical discover emission (1.7.0) Aug 13, 2026
@sting8k
sting8k merged commit f52c8fa into main Aug 13, 2026
7 checks passed
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