Skip to content

feat: source navigation echoes and guarded fork-prefix inheritance - #6393

Open
AdityaVG13 wants to merge 10 commits into
codewhale-hq:mainfrom
AdityaVG13:spike/pod-locator
Open

AdityaVG13 wants to merge 10 commits into
codewhale-hq:mainfrom
AdityaVG13:spike/pod-locator

Conversation

@AdityaVG13

@AdityaVG13 AdityaVG13 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

This preserves @AdityaVG13's index-free source-navigation echoes, bounded tool-output work and fork-prefix experiment while adapting them to the current canonical Engine and authority model. The original eight commits remain in the branch's ancestry. The history-preserving reconciliation is 2095375c, with current main88b4c58d as its second parent.

The intended source has42 changed paths. It keeps all policy-allowed child tools, restricts inherited headers to matching first-level Chat Completions routes with the installed opaque receipt, freezes the parent's observed header at spawn, and records the actual prepared header through the protected transcript path. Unsupported dialects or changed route/model/receipt use the cold path. Derived source reads retain containment/deny rules and existing blocking-worker fences. Caller scans read at most32 candidate bodies; directory enumeration and kernel latency are not bounded by that cap. Deleted symbols use old and new spans. Eligible skill names remain enumerable, workflow events keep task/workspace ownership, and current eager core tools plus the eight-name/16KiB deferred cache remain unchanged.

All12 original Copilot findings have source dispositions and exact code/fixture evidence. Threads remain open until the new exact-head gates qualify. All79 original contributor declarations are retained, including one existing eager-fixture rename; the conditional Unix symlink fixture can early-return. Three feature rows and their facts are added. The agent-doc snapshot is derived from actual main's public documents plus the selected TOOL_SURFACE change; unrelated release/catalog/pricing/OAuth work is excluded. The seven synchronous helper sites are explicitly recorded as future-call debt under the existing checker policy; current production consumers run under existing workers.

Local evidence is from the separate combined canonical source, with the intended feature bytes independently mapped: Runtime20 passed/0failed, Core30/0; original TUI636run631passed/5failed and next58run57passed/1failed are preserved. The four cap/context/trust/path-warning repairs passed, and the final eager fixture/guard selection passed2/0; feature registry2/0. Actual CI-flags workspace/all-target/all-feature Clippy12m19s/0diagnostics, npm1,312passed/0failed/7skipped, corrected generated-docs web/fmt/diff passed. This is not an exact own-head Windows or distribution proof.

Fresh own-head CI38540405096 is running on2095375c; actual Ubuntu/macOS/Windows/Lint and fresh reviews remain required before merge. No live-provider cache savings, universal scan-latency, physical Windows VM or final package acceptance is claimed. 0.10.2 has not shipped. Source branch and contributor history remain preserved.

Refs #6393

Sound every file read, grep, file search, and project map with its
surroundings — sibling podmates, line-numbered symbols, import roots,
resolved file links, and (in the terminal buzz) reverse-link callers —
sounded fresh from source with no index, no background work, and no new
dependencies. Deterministic (sorted, capped, budgeted) so repeated calls
are byte-identical and cache-friendly.

Echolocation (new: tools/echolocation.rs, ~2.5k lines incl. tests):
- read footer: [Pod] mates + [Sounding] symbols/imports/links/heard-by,
  1200B hard budget; miss echo on NotFound (denylist-gated, never fires
  on refused probes); terminal buzz adds callers after 2 distinct
  files read in a pod
- grep + file_search chart matched dirs (caller's own visibility gates:
  denylist, excludes, extensions, gitignore); project_map sounds key
  files; 4 sounding languages (Rust/Python/JS-TS/Go)

Token diet (no compression, behavior-preserving):
- prefix 14,241 -> 7,118 tokens/turn (-50.0%): skill path cut
  (load_skill resolves names), MCP prose 1526->548B (scar-tissue
  phrases kept), agent+workflow deferral, goal tools conditional-eager
  keyed off the turn's resolved goal (preview/wire-safe)
- activation cache: best-match-last push + regex name-rank + 16->24KiB
  bound (fixes deferral stranding agent behind its own discovery set)
- grep empty-context omit, workflow event projection (lossless:
  duplicates dropped, workspaces hoisted, branch kept) + zero-memo omit
- wire-prefix dump moved to PreparedOutboundRequest (exact-final-body)

Evidence: targeted echo 46, workflow 131, file 145 green; full
tui+workflow suites green except 4 failures reproducing identically on
base c75b233 (pre-existing, unrelated) + known timing flakes proven
solo-pass; clippy zero on owned files. Research: codewhale-research/
ECHOLOCATION-THESIS.md (exp-10/11/12 + hardening audit).
DEFAULT_ACTIVE_NATIVE_TOOLS is six names now (agent, workflow,
get/update_goal deferred); the web contract mirror, tool docs, and
mode docs still claimed ten eager + eleven with tool_search.
Activation cache bound 16 -> 24 KiB in facts, docs, and web copy.

Found by the fork staging PR's Lint & Type Check gate.
Footer squeeze (all lossless): same-pod links/callers render bare,
import roots a link already names drop by file stem or package path,
framing tightens to [Pod (N)] / [Sound], and sounded paths are
/-separated on every OS. The squeeze follows CODEWHALE_ECHO gates so
an off:links trial measures links alone.

Edit echoes name touched symbols plus impacted callers on write/edit;
the diff rides metadata for the TUI while the receipt stays one line.
Grep max_results is clamped with honest truncation, skill listings are
capped, JS arrows sound as their source token, and ECHOLOCATION.md
documents the surfaces.

Signed-off-by: AdityaVG13 <adityavgcode@gmail.com>
Relative imports now sound their leaf instead of a bare dot
(from . import sib -> sib, ./server -> server), which composes
with stem-shadowing when the link resolves and names the module
when it does not. Removes the temporary footer-breakdown probe
(its numbers landed in the PR; the eprintln tripped the
print_stderr deny and flipped Lint red).

Signed-off-by: AdityaVG13 <adityavgcode@gmail.com>
Child on the same route/model/tools inherits the parent's cached prompt
prefix (system prompt + compacted history) as its frozen LivePrefix base,
warming from the warm cache instead of going cold. Resolution is a pure
deterministic gate (resolve_fork_inherit) — same route, same model, same
or subset tools, child config digest must descend from the parent chain —
so narrowed roles and grandchildren correctly fall back cold.

No human-language compression anywhere; the child extends the parent's
verbatim prefix with its own delegation message (append-only history per
docs/CACHE.md), keeping prompt-cache prefix-matching intact.
Replace whole-block tool equality (which never held: parent wire blocks
grow by deferred discovery while child grants are fixed and narrower)
with longest byte-equal head resolution. The child adopts the parent's
exact system bytes and sends the matched head on its first request;
the rest of its grant stays deferred and activates on demand, so
truncation costs cache bytes, never capability. Full head
(inherited_full) prices shared history as hits; partial head
(inherited_prefix) still prices system plus matched tools.

Both sides now canonicalize through tool_to_api_json (the wire shape),
so internal-only flag skew (defer_loading, allowed_callers) can't
false-negative the comparison. The hot proof carries forward across
append-only requests, since spawns execute before the current
request's usage lands. Fresh spawns, grandchildren, resumes, route
skew, and cold prefixes stay cold with distinct reasons.

Trial instrumentation (CODEWHALE_FORK_TRIAL=1, default off) mirrors
the decision, prefix span, history-divergence point, and child
first-response cache split to stderr as JSON lines for same-binary
A/B measurement; headless exec installs no tracing subscriber, so
the tracing trial logs are invisible there.

Measured (same-binary A/B, DeepSeek, unique histories, child
first-response): true cold 0/9421 hits; primed cold 4736/9389;
prefix k=3 5504/9941; full k=6 8576/13251. Inherited children
reported correct results in every run. DeepSeek counts hits in
64-token blocks. Follow-ups: fork transcripts freeze at turn 1
(the live tail never rides), framing sits ahead of where the
tail would (breaking the head match), grandchildren carry ~40KB
all-miss transcripts (single-level v1).
The CODEWHALE_FORK_TRIAL readout intentionally writes JSON lines to
stderr (headless exec installs no tracing subscriber, so the tracing
trial logs are invisible there). Narrowly allow clippy::print_stderr
on the two env-gated diagnostic blocks with justification, following
the existing in-repo precedent.

Documents the fork-prefix contract, measured benchmarks, trial
procedure, and known follow-ups in docs/CACHE.md.
The tool layer hands echolocation canonical file paths while the
workspace may be non-canonical (macOS /var to /private/var tempdirs,
Windows verbatim paths). Three spots compared them raw and silently
missed everywhere but Linux:

- workspace_relative now canonicalizes both sides before giving up,
  restoring caller and link matches.
- pod_relative_names compares in workspace-relative space instead of
  joining the raw workspace, restoring same-pod shortening.
- Grep match paths fall back through the same canonical strip
  instead of rendering absolute.

Verified against the three CI failures locally on macOS; Linux
suites are unaffected (fast paths unchanged).
@Hmbown Hmbown added this to the v0.11 milestone Oct 5, 2026
Hmbown pushed a commit that referenced this pull request Oct 6, 2026
Reconcile the complete contributions from #6832 (@aboimpinto), #6867
(@hodeswildsmith455-boop), and #6805 (@LIghtJUNction) with the current
Engine, provider identities, reviewed-plugin policy, and task lifecycle.
Original contributor histories are recorded by subsequent resolved merges.

Fix the already integrated contributor cases: snapshot corruption is an
explicit unavailable/error result (#6817), malformed locales cannot select
an incidental script (#6860), image metadata uses the exact uploaded bytes
and respects available decoders (#6858), automation deletion waits for
actual scheduler reconciliation (#6864), and blocking trust/skill reads stay
off the async executor (#6869). Preserve #6857's compaction regression.

Extend #6872's human-wait lifecycle guard to approval/elevation cards;
retire only the matching ended parent request and refresh activity only
after a delivered decision. Enforce configured finite approval deadlines in
the Engine, including deadline/cancellation races and durable receipts.

Serialize Native Windows ACL admission/retirement across Core processes
with a logon-scoped kernel mutex, preserving exact SID/object validation.
Add an actual child-process lock test; serialize DSH host tests in the
existing extension-host lane. Windows execution proof remains hosted CI.

Reconcile the vendored computer-use plugin with canonical main a656f67455fc
while preserving Core's 0.12.1 embedding contract. Canonical b47/a656 tree
passed Ubuntu/macOS/Windows source and package gates, including 28/28
Windows-focused tests and the controlled desktop fixture; this is separate
from the new Engine head's CI verdict.

Partial adaptation of the discovery-cache priority portion from PR #6393
by @AdityaVG13 (original ac33dd4). Preserve the best match under count
and byte limits without importing the unfinished echolocation/fork design;
the broader draft remains open.

Validation:
- npm test: 1286 passed, 0 failed, 7 skipped; web 767/767.
- npm run check:web: lint, typecheck and production build passed.
- Affected Rust selection: 801/803 initially passed; the two fixture/lifecycle
  expectation failures were corrected and each passed a focused rerun.
- Additional focused Rust: approval 28/28, discovery cache 11/11,
  OrcaRouter synthetic catalog 3/3, and 33/33 lifecycle/API/routing checks.
- Final CI-repair selection: 37/39 initially passed; the BMP feature-proxy
  and feature-registry summary failures were corrected; both corrected tests passed (2/2, 0 failures).
- Qualified Clippy: six packages, all targets/all features, passed with
  the CI style allowances. Portable no-default-feature check passed;
  portable policy verifier 6/6 passed; formatting and diff checks passed.
- Runtime contract: 55 measured metrics passed after explicit remeasurement;
  all 21 structural identities were unchanged. Twelve byte/token-estimate
  budgets account for bounded child-wait disclosure and contributor locale
  descriptions; no runtime field/prompt was removed to lower the budget.
- Persistence budget was not qualified locally: the checker requires a
  clean tree and this shared checkout retains an unrelated operator file.
  Clean hosted CI, fresh stamped build and real DeepSeek TUI acceptance
  remain required before the integration PR can merge to main.

Refs #6872, #6843, #6795.

Co-authored-by: Paulo Aboim Pinto <paulo.aboim.pinto@gmail.com>
Co-authored-by: hodeswildsmith455-boop <hodeswildsmith455-boop@users.noreply.github.com>
Co-authored-by: LIghtJUNction <lightjunction.me@gmail.com>
Co-authored-by: AdityaVG13 <adityavgcode@gmail.com>
Signed-off-by: CodeWhale Bot <bot@codewhale.net>
@Hmbown
Hmbown marked this pull request as ready for review October 11, 2026 08:13
@Hmbown
Hmbown self-requested a review as a code owner October 11, 2026 08:13
Copilot AI balanced review requested due to automatic review settings October 11, 2026 08:13

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@Hmbown

Hmbown commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

sorry @AdityaVG13 I ended up moving too fast I think around the time this happened; would still love to get this in codewhale!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The draft has unresolved capability loss, blocking filesystem work, lossy workflow projection, and provider-specific cache behavior.

12 open findings
What changed in this PR

This draft reduces model context costs through deterministic tool-result “echolocation,” deferred tool schemas, and forked-subagent prefix-cache inheritance.

Changes:

  • Adds bounded navigation echoes to file, search, project-map, and mutation tools.
  • Shrinks eager tool/skill/workflow payloads and expands the deferred-schema cache.
  • Adds same-route fork-prefix inheritance and cache diagnostics.
File Description
web/​lib/​public-surface-contract.test.ts Updates public tool-cache assertions.
web/​lib/​content/​tools.ts Revises public tool activation copy.
docs/​zh_hans/​MODES.md Documents deferred tools in Chinese.
docs/​TOOL_SURFACE.md Updates eager-tool and cache contracts.
docs/​public-surface-facts.json Synchronizes public surface facts.
docs/​MODES.md Documents deferred Work-mode tools.
docs/​ECHOLOCATION.md Defines the echolocation feature.
docs/​CACHE.md Documents fork-prefix inheritance.
crates/​workflow/​src/​lib.rs Omits empty memo usage from serialization.
crates/​tui/​src/​tools/​workflow/​mod.rs Projects workflow events into smaller payloads.
crates/​tui/​src/​tools/​subagent/​tests.rs Expands deferral and inheritance tests.
crates/​tui/​src/​tools/​subagent/​mod.rs Implements child prefix inheritance.
crates/​tui/​src/​tools/​spec.rs Tracks per-directory read activity.
crates/​tui/​src/​tools/​skill.rs Bounds skill listings and descriptions.
crates/​tui/​src/​tools/​search/​tests.rs Tests grep limits and pod soundings.
crates/​tui/​src/​tools/​search.rs Adds bounded grep results and pod charts.
crates/​tui/​src/​tools/​project.rs Adds key-file symbol soundings.
crates/​tui/​src/​tools/​mod.rs Registers the echolocation module.
crates/​tui/​src/​tools/​file/​tests.rs Tests read, miss, buzz, and edit echoes.
crates/​tui/​src/​tools/​file.rs Adds file echoes and correct byte receipts.
crates/​tui/​src/​tools/​file_search.rs Adds matched-directory pod data.
crates/​tui/​src/​tools/​diff_format.rs Updates diff metadata documentation.
crates/​tui/​src/​skills/​tests.rs Updates pathless skill-index tests.
crates/​tui/​src/​skills/​mod.rs Removes native skill paths from prompts.
crates/​tui/​src/​session_manager.rs Applies formatting-only cleanup.
crates/​tui/​src/​prompt_zones.rs Adds live-header inheritance gates.
crates/​tui/​src/​hooks/​executor.rs Updates deferred-tool classification tests.
crates/​tui/​src/​core/​session.rs Expands and reprioritizes activation caching.
crates/​tui/​src/​core/​engine/​turn_loop.rs Captures and updates live request headers.
crates/​tui/​src/​core/​engine/​tool_catalog/​tests.rs Updates eager/deferred catalog tests.
crates/​tui/​src/​core/​engine/​tool_catalog.rs Defers delegation and goal tools.
crates/​tui/​src/​core/​engine/​tests.rs Synchronizes engine surface tests.
crates/​tui/​src/​core/​engine/​preview/​tests.rs Updates preview call signatures.
crates/​tui/​src/​core/​engine/​preview.rs Supplies goal state to preview catalogs.
crates/​tui/​src/​core/​engine.rs Adds live headers and goal-aware activation.
crates/​tui/​src/​client/​prepared.rs Dumps final wire prefixes when requested.
crates/​tui/​src/​client/​chat.rs Expands prompt dumps across wire dialects.
crates/​tui/​src/​client.rs Updates child goal-surface expectations.
crates/​core/​src/​prefix_cache.rs Exposes canonical tool serialization.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/tui/src/tools/subagent/mod.rs Outdated
Comment on lines +13444 to +13449
if steps == 1
&& let Some(prefix) = inherited_prefix.as_ref()
{
tools = prefix.clone();
tool_surface.active_names = prefix.iter().map(|tool| tool.name.clone()).collect();
}
Comment on lines +409 to +416
let full = prefix.len() == snapshot.active_names.len();
ForkInheritDecision {
inherit: true,
reason: if full {
"inherited_full"
} else {
"inherited_prefix"
},
Comment thread crates/tui/src/tools/echolocation.rs Outdated
Comment on lines +714 to +716
similar::DiffOp::Equal { .. } => None,
similar::DiffOp::Delete { new_index, .. } => Some((new_index + 1, 0)),
similar::DiffOp::Insert {
Comment thread crates/tui/src/tools/echolocation.rs Outdated
Comment on lines +1734 to +1736
let mates = list_dir_entries(parent).unwrap_or_default();
let mut callers = BTreeSet::new();
for (raw, _) in mates {
Comment thread crates/tui/src/tools/file.rs Outdated
Comment on lines +631 to +632
if let Some(echo) =
crate::tools::echolocation::sound_edit_echo(&context.workspace, file_path, before, after)
Comment thread crates/tui/src/tools/file_search.rs Outdated
glob_root: &pod_root,
gitignore: true,
};
let (pods, pods_omitted) = super::echolocation::sound_match_pods(&pod_root, &paths, &vis);
Comment on lines +91 to +92
let (key_file_soundings, key_files_omitted) =
super::echolocation::sound_key_files(root, &key_files);
Comment thread crates/tui/src/tools/skill.rs Outdated
Comment on lines +134 to +138
if skills.len() > LOAD_SKILL_LIST_MAX_ROWS {
listing.push_str(&format!(
" ... and {} more installed; load any by exact name.\n",
skills.len() - LOAD_SKILL_LIST_MAX_ROWS
));
Comment thread crates/tui/src/tools/workflow/mod.rs Outdated
Comment on lines +2450 to +2455
if let Some(workspace) = fields.remove("workspace")
&& let Some(path) = workspace.as_str()
&& !path.is_empty()
{
workspaces.insert(path.to_string());
}
Comment thread web/lib/content/tools.ts Outdated
{ name: "agent · workflow", detail: { en: "Loaded on demand via tool_search. Delegate work and coordinate dependent phases.", zh: "通过 tool_search 按需加载。委派工作并协调有依赖关系的阶段。" } },
{ name: "todo_write", detail: { en: "Replace the task list with content and status entries.", zh: "用包含内容与状态的条目替换任务列表。" } },
{ name: "create_goal · get_goal · update_goal", detail: { en: "Create, inspect and update the active goal.", zh: "创建、查看与更新当前目标。" } },
{ name: "create_goal · get_goal · update_goal", detail: { en: "create_goal is available without discovery; get_goal/update_goal load on demand while a goal is active.", zh: "create_goal 无需搜索即可使用;get_goal/update_goal 仅在目标激活时按需加载。" } },
@AdityaVG13

Copy link
Copy Markdown
Contributor Author

@Hmbown no problem, i'll get my agents working on it right now

Preserve all eight original @AdityaVG13 commits and reconcile their source-navigation, bounded tool-output and fork-prefix work with current main88b4c58d. Use the existing Engine, Runtime header ownership, Core serializer and opaque installed route receipt; retain policy-filtered child tools, durable protected header observations and cold fallback on mismatches. Derived source reads remain protected/contained and current async consumers run in existing blocking workers. Retain current eager core tools and the eight-name/16KiB deferred cache. The explicit seven synchronous helper sites are recorded as future-call debt under the existing checker policy, not an intrinsic worker guarantee. Add the three feature rows and derive their facts plus the own-main agent docs from the existing owners. No unrelated release/catalog/pricing/OAuth source or WIP ancestry is included.

Actual local Mac evidence is on the separate combined ECD+102-path source, with exact feature selections/source custody independently bound: Summary20 Runtime tests run:20passed/0failed/176outsidefilter; Summary30 Core tests run:30passed/0failed/67outsidefilter. Original TUI gate ran636:631passed/5failed; the next coherent repair ran58:57passed/1failed. These failures remain preserved. Search cap/context/trust/path-warning cases then passed; the same eager fixture was renamed/migrated and the two-case final selection passed2/0/15417outsidefilter. Feature registry2/0/0skipped. Actual CI-flags workspace/all-target/all-feature Clippy12m19s/0diagnostics; npm540Node+772Vitest=1312passed/0failed/7skipped; generated-docs repair and web/fmt/diff passed. No new agent test function/code comment. All79 original contributor declarations remain with the explicit eager-name migration; the conditional Unix fixture may early-return.

The intended42-path own-PR tree has not yet been compiled or tested; fresh exact-head hosted Ubuntu/macOS/Windows/Lint/reviews remain a required HOLD before merge. No Windows distribution/provider cache-savings/live grant or final release claim. Source branch and original authors/history remain.

Refs codewhale-hq#6393
@Hmbown Hmbown changed the title Draft: echolocation, token diet, and fork-prefix cache inheritance feat: source navigation echoes and guarded fork-prefix inheritance Oct 14, 2026
@Hmbown

Hmbown commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Thank you, @AdityaVG13, for the index-free source navigation, bounded tool responses and fork-prefix work—and for being willing to keep working with us after main moved. Your eight original commits are preserved. I have pushed a history-preserving adaptation to your branch using the current Engine, route identity and protected-read boundaries; the PR body explains the12 review dispositions and the limits of the local evidence.

The repaired canonical feature checks, registry, Clippy, npm and web gates passed. Fresh CI on your actual PR head is now running, so I am keeping the merge and review-thread resolutions gated on those results. The feature remains experimental for0.10.2, which has not shipped; no provider cache-saving or final Windows-package claim is being made. Thank you for giving us the source and tests to carry this forward as your own PR.

Refs codewhale-hq#6393

The first own-head Version drift job failed its contributor-credit gate because the website list omitted @AdityaVG13, whose original source-navigation and fork-prefix work is preserved in this branch. Add their literal handle beside the existing unreleased contributor without changing product source or the credit gate.

Frozen combined canonical verification: npm 540 Node plus 772 Vitest passed; 0 failed; 7 skipped. npm run check:web, fmt and diff checks pass. This exact file matches the verified source. The original failed job log is retained; fresh exact-head hosted CI, reviews and Windows owner-recovery proof remain required. No upload, release, provider call or Windows distribution acceptance occurred.

This branch has not been deployed

No deployments
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.

3 participants