Skip to content

feat(search): land the per-call workspace resolution ladder - #21

Merged
LittleCoinCoin merged 35 commits into
mainfrom
agents/workspace-discovery-resolution
Nov 27, 2026
Merged

LittleCoinCoin merged 35 commits into
mainfrom
agents/workspace-discovery-resolution

Conversation

@LittleCoinCoin

Copy link
Copy Markdown
Member

Closes the workspace_discovery campaign (roadmap: __roadmap__/workspace_discovery/): replaces the silent wrong-project default root with the sponsor-folded per-call resolution ladder explicit paths → request _meta → client roots → COLGREP_MCP_ROOT pin → guarded cwd / ROOT_UNRESOLVED guided failure.

What lands

  • Probe hardening (level 1): truth-sourced dump-only probe (tool attribution, declared/empty/error roots classes), total record() that never raises past the resolve call site, forge_record/diff_record calibration oracle, and the client-surface dump-only signature (four listings byte-identical with the probe off).
  • Harness evidence (level 2): measured harness × signal matrix with honest — cells and named gap records (neither reached harness invoked the doctor trigger), never synthesized.
  • Per-call ladder (level 2): _meta consumption (META_WORKSPACE_KEYS), race-safe per-call roots (late root beats premature cwd, including concurrent first calls), COLGREP_MCP_ROOT pin, and ROOT_UNRESOLVED whose named remedy verifiably works; guide.md §Scoping documents the ladder.
  • Adjudication (level 3): findings report (dynamic_channels_work = 0) scoping the next campaign.
  • Verifier close-out (F1–F4): four regression tests with fail-first quotes — absolute-path remedy escapes its own error; path-less file: roots are rejected instead of silently scoping to / (this PR's silent-worst-case guard); empty root lists never classified declared; concurrent first calls all get the bounded roots reassurance.

Verdict from the adversarial verification: SIGN on the dump-only invariant (four listing digests reproduce byte-identically at tip).

Portability note (CI Windows leg)

This is the first PR to land the roots URI handling the F2 guard sits on (url2pathname file:-root coercion in server/colgrep_mcp/paths.py) and the reassurance state machine (_roots_settled / _FIRST_EMPTY_WAITERS) — please read the Windows verdict specifically.

Gates green locally: uv run pytest (all pass, 1 skip), uv run ruff check, uv run ruff format --check, uv run cz check --rev-range origin/main..HEAD, conflict-marker scan clean. Per-step commits one roadmap-step-per-commit, merge history preserved (--merge, not squash).

LittleCoinCoin and others added 30 commits November 27, 2026 13:48
The default-root fallback silently searches the plugin install tree whenever
the env pin and client roots are both absent; before any probe work ships,
its ladder, dump schema and harness matrix need to be on the record so leaves
have a contract to implement against (campaign-lead: reports before roadmap,
roadmap before dispatch). The error rung is fail+guidance per sponsor review,
not a bare loud failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Phase 0 materializes the BFS node graph before any code: two parallel
level-1 leaves (probe instrumentation, protocol survey), then evidence
collection and synthesis by depth ordering. Every leaf names deliverables,
deterministic consistency checks and file-disjoint ownership so level merges
cannot conflict (KT-B: worktrees see only committed files). All seven files
pass dirtree-rdm validate before this commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Both level-1 implementers dispatched on their own worktrees (task/probe-instrumentation, task/protocol-survey); status flips to inprogress for the window.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The probe is dump-only and inert — with COLGREP_MCP_PROBE unset
nothing observable changes (no tool-surface diff, no resolution
diff).  probe.py exports capture_pure, record, and PROBE_ENV;
paths.resolve_target_paths calls _probe_record after get_settings
and client_roots so the record captures the shared runtime outcome
without adding a second round-trip.  The probe module uses logging
safe-logged on failure per maintainer-policy §C4.  roots_list is
shared with the single client_roots call so resolution cost stays
unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
test_probe.py: 6 tests covering capture_pure round-trip, probe inert
without env, R01 JSONL keys in record output, runtime match between
probe record resolved and resolve_target_paths results, and a
regression check that COLGREP_MCP_PROBE unset never triggers writes.

probe_workspace.py: harness evidence driver (claude|codex) that injects
a stub colgrep on $PATH, never touches a real index, and writes R01
JSONL records per invocation with schema validation and 3-entry
rotation.

probe_data/.gitignore: exclude *.jsonl from git, keep .gitignore.
…egration debt

The ca3cb40 merge message states this marker as committed; this repays that
claim honestly: two verifier dispatch rounds vanished with zero output, so
the dump-only invariant is signed only by the lead's re-verification and the
implementer's report. Level 2 (evidence/) stays gated on a real signature,
escalated one tier per campaign-lead. probe_instrumentation itself is done --
its leaf gates were independently re-run green post-rebase.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Two protocol-survey dispatch rounds died with zero output, so the lead
authors R02 from what is already observed and able to cite in-vessel:
the mcp SDK 2.2.0 MCPDeprecationWarning that names a 2026-07-28 revision
(SEP-2577) while the repo's own paths.py self-announces roots/list as
deprecated at that same timestamp, Agent Plugins 1.0 S9.2's no-expansion
freeze, and the probe-instrumentation implementer's SDK-source reading of
RequestParams.Meta. Keeps the ZERO UNKNOWN law: station cells that need
behavioural evidence stay at the R03 fleet target in Steering [next run];
the discovered mismatch (SEP-2577 = logging, not roots) is flagged as a
sensor hole rather than smoothed over.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… analysis

Two distinct artifacts, one decision. The verdict report (02-findings_)
stores the adversary's four lever outcomes verbatim with proofs so the
campaign record cites evidence, not a summary memo. The gap analysis
(02-gap_analysis_) translates it into the amendment workflow's required
shape -- problem statement, evidence, root cause, impact scope, and proposed
probe_hardening remedy at depth-1 before evidence/ -- because the UNSOUND
verdict is a broken-assumption gap (my defect diagnosis rule, not a
post-hoc fix): the probe has no truth-source oracle, so a stub-authored
record can pass for harness evidence on every matrix the campaign exists
to fill. The amendment review dispatch depends on both existing in the
reports store.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tch table

Runs hold a silent-delivery rule not to leave these conclusions only in
chat; the amendment's A1 source column record needs the reviewer's APPROVE
verdict filed alongside the gap analysis already in the reports store.
Also corrects the topic batch table's stale R02 "planned" flag (it landed
at ecb77d5) and adds the two missing 02 rows plus this 03 entry, so
consumers see the full chronology rather than an incomplete list.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Re-lands the dump-only probe with its two falsified columns repaired so the
ledger reflects what the harness measured, not what the probe guessed.

- tool attribution: the frame scan (which resolved to "record" every time via
  paths.resolve_target_paths) now skips the probe/resolve module internals and
  names the actual calling tool. The record must never claim a tool it did not
  run (verifier lever 1).
- roots_list: classified declared/empty/error via a new _client_roots that
  surfaces the errored flag; "error" when the round-trip raised or the
  back-channel was absent, "empty" only when a client genuinely answered zero.
  The old record mapped both to the same "empty" value (lever 6 / gap defect 6).

Both new tests FAILED first against the shipped faulty state (ca3cb40),
capturing this leaf's fail-first evidence:

  $ cd server && uv run pytest \
      tests/test_probe.py::test_tool_column_names_the_actual_tool \
      tests/test_probe.py::test_roots_error_distinct_from_empty -q
  E AssertionError: ... assert 'record' == '_fake_tool_handler'
  E ImportError: cannot import name '_classify_roots' from 'colgrep_mcp.probe'

The old test_no_probe_side_effects was blind: it never read the ledger and
asserted dead filenames, so a fabricated column value passed it (lever 3); the
rewrite that retires it lands with the calibration oracle in a later commit.
Resolution output stays byte-identical to base: the hook only adds a pure label
walk and record() early-returns whenever COLGREP_MCP_PROBE is unset.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The never-raise law becomes a property, not a docstring claim. capture_pure
now coerces unmappable snapshot values with default=str so a record stays a
witness even for hostile values, and record() wraps its whole body (after the
env sentinel) in one try/except that logs and swallows anything else — an
unwritable probe dir, a value whose str() itself fails — so no error escapes
to the resolve call site (verifier lever 2b).

Both new tests FAILED first against the shipped faulty state (ca3cb40), where
capture_pure had no default=str and sat outside the never-raise boundary:

  $ cd server && uv run pytest \
      tests/test_probe.py::test_record_never_raises_on_hostile_snapshot \
      tests/test_probe.py::test_tool_call_survives_probe_rename -q
  E TypeError: Object of type _ExplodingStr is not JSON serializable
  E TypeError: ... (same, propagated up through resolve_target_paths)

The old test_no_probe_side_effects never exercised this path, so the escape
travelled unnoticed exactly as lever 2b describes. Both now pass with the
total boundary in place.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rdening

Reverts ca3cb40 (the dump-only probe facility) per the adversarial
verdict's own decision rule: the probe can pass stub-authored records
through validate() as harness evidence, its tool column claims "record"
regardless of the real handler, and a TypeError escapes past the
never-raise boundary into the resolve path (see
__reports__/workspace_discovery/02-findings_probe_verifier_v0.md and the
approved gap analysis 02-gap_analysis_calibrated_probe_v0.md). The full
hardening fix (probe_hardening: truth-source columns, never-raise
guarantee, forge_record/diff_record calibration oracle, driver provenance
flagging) needs the roadmap amendment's node authority to proceed and is
not yet executable, so withdrawal-before-landing is the verdict's named
alternative rather than shipping artifacts its own verifier refuses. The
reports (R00-R03 history) stay intact as the record of the measurement
attempt; the probe code returns once hardened and re-signed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dger test

Ships the witness the gap analysis prescribes (02-gap_analysis_calibrated
_probe_v0.md): forge_record builds ground truth from an explicit snapshot (no
frame/env reading) and diff_record returns field-level disagreements, so a
test harness can catch a probe that lies. FORGED_SAMPLE is the canonical
stub-authored record (lever 1b) whose fabricated init_capabilities the oracle
must whistle on verbatim. test_calibration_whistles_on_fabrication feeds a
fabricated init_capabilities and requires diff_record to whistle;
test_no_probe_side_effects is rewritten to read the real ledger
colgrep_probe.jsonl and compare capture_pure round-trip against forge_record,
retiring the old test that asserted dead filenames and re-read only the env.

Fail-first against the shipped faulty state (ca3cb40), capturing lever 3:

  $ cd server && uv run pytest \
      tests/test_probe.py::test_calibration_whistles_on_fabrication \
      tests/test_probe.py::test_no_probe_side_effects -q
  E ImportError: cannot import name 'forge_record' from 'colgrep_mcp.probe'
  E AssertionError: probe fabricated the tool column as 'record'
  E   assert 'record' != 'record'

The old test_no_probe_side_effects was blind — it never failed on this faulty
state — because it deleted COLGREP_MCP_PROBE, never read a ledger, and
checked filenames the implementation never writes; the rewritten test now
fails first on the very fabrication it exists to catch. Both new tests pass
with the oracle in place.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rectly

ca3cb40 (the probe facility these findings diagnosed) has been withdrawn
pending hardening, so one path-local cross-link table rows now reads as a
stale bit-for-file existence. Annotates each with its owning commit and
points the remedy reader at the owning case file directly (02-gap_analysis_)
rather than at a file that may have just landed in co-generate through a
just-pushed commit unavailable for review alone.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…idator

Restores the probe driver with its two hygiene defects repaired. Stub-written
records are stamped "provenance": "stub" (server rows carry none), so a ledger
reader can separate stub synthesis from harness-sent rows (lever 1b). The
validator now returns a per-line verdict ("valid"/"gap"/"invalid") and a gap
row parses to "gap" instead of collapsing to False / KeyError-ing, so the
driver can use its own gap signalling (lever 5). The raw rotation persists
whole timestamped raw dirs under probe_data/ (the reverted .gitignore is
restored so rotation never pollutes git), keeping the newest 3.

Both new tests FAILED first against the shipped faulty driver (ca3cb40),
where the stub carried no provenance and the validator returned bool False
for gap rows instead of a named verdict:

  $ cd server && uv run pytest tests/test_probe_step4_failfirst.py -q
  E AssertionError: assert False == 'gap'
  E AssertionError: assert '"provenance": "stub"' in '...stub script...'

Both pass with the driver restored and hardened.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…robe findings

R03b answers the campaign's question on the wire instead of in theory: the
stamped _meta vendor keys arrived verbatim per tools/call and the client
roots round-trip resolved the workspace per call in both negotiation runs,
with the first-call roots race (empty answer defeats a late arrival) and
the two auth-gated host rows recorded as measured gaps. The ledgers and
wire transcripts travel with the report so the claims cite raw artifacts,
not transcriptions. The batch README closes with the remaining-cycle notes
each matrix cell justifies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Discharges the signature debt the campaign README records against ca3cb40:
the hardened probe must be provably inert at the surface a client can see.
Lead-measured end-to-end: an mcp.ClientSession over stdio dumps
list_tools / list_resources / list_resource_templates / list_prompts on
the base checkout (main at 5b8b099, no probe module) and on this branch at
75abe82 with COLGREP_MCP_PROBE removed from the child env; canonicalized
tuples hash-identical on all four listings (tools 9/88714214c2d7908f,
resources 4/3c97ad1b6677e9b2, resource_templates 1/627bc16ed6218d0f,
prompts 4/078a59b3f2053426). The in-tree legs (test_probe_inert_without_env,
the rewritten test_no_probe_side_effects against forge_record ground truth,
test_tool_call_survives_probe_rename) are re-verified green at the same
time (347 passed, 1 skipped).

This is evidence-only: no owned source file changes with this commit; it
carries the pre-condition set on collect_harness_evidence in the roadmap
Gotchas (verifier signs the dump-only invariant before level-2 dispatch).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The sponsor decision of 2026-11-13 fixes the ladder as the campaign's
implementation target: paths argument > dynamic (per-call request _meta
vendor keys + per-call client roots, both wire-measured in R03b) >
COLGREP_MCP_ROOT pin > fail with guidance naming an absolute paths entry.
Amendment A1 records the fold; probe_hardening (the approved UNSOUND-probe
remedy) and resolution/per_call_resolution (the ladder) are authored with
named deliverables and deterministic gates, sequenced by depth so the
calibration oracle lands before the resolution rework it verifies. protocol_survey
closes done.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… (workspace_discovery level 1: probe hardening)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…esolution (workspace_discovery level 2: harness evidence collection)
Rung 2a of the sponsor-folded resolution ladder (R03b): before falling to
client roots, COLGREP_MCP_ROOT, or cwd, the resolver now reads a workspace
directory out of the request '_meta' stamp that hosts send per tools/call
(measured arriving verbatim on the wire, 03-findings_live_probe_v0.md).
META_WORKSPACE_KEYS carries the alias list in priority order with the
documented primary key last; default_root_from_meta walks it and degrades
silently on any absent or non-path value so a bad stamp never raises.
resolve_target_paths threads the stamp through resolve_paths/default_root,
and _roots_can_matter now short-circuits the roots round-trip when meta has
already settled the root (roots cannot outrank meta).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
R03b measured a fresh connection answering the first roots/list of call 1
with a provisional empty set, then the real root a moment later in the same
call; the pre-fix resolver fell to cwd on the first answer and lost the late
root. _client_roots now gives the process's first empty roots answer one
bounded reassurance round-trip before concluding 'nothing sent', so a
late-arriving root wins over a premature cwd fallback. Once a call has
concluded, steady state snaps back to one round-trip per call; an error-class
round-trip (back-channel absent or raised) still records as 'error', never
'empty', and falls to the COLGREP_MCP_ROOT pin.

Fail-first evidence (run against the step-1 parent, which has no reassurance):
  tests/test_paths_resolution.py::test_first_call_roots_race_regression
    assert 1 == 2
    AssertionError: the first empty must be re-asked once (bounded reassurance)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Compose the sponsor-folded ladder in default_root: request _meta stamp >
per-call client roots > COLGREP_MCP_ROOT > guarded server cwd.  When
everything is silent and the working directory is not a plausible project
root, resolution now raises Code.ROOT_UNRESOLVED whose message names the
remedy verbatim (pass an absolute paths entry) instead of silently scoping
to a non-project or failing bare — R01 fail+guidance.  guide.md §Scoping
documents the ladder and the remedy (client-visible, pinned by a test), and
the errors resource carries the new code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ladders

Lead tier-2 integration across the two concurrent level-2 leaves: the
resolution ladder landed with meta > roots > env precedence and a
ROOT_UNRESOLVED guided failure, but the probe hook still re-derived the
root without meta_root and outside its total boundary. A meta-sourced
call recorded env/roots/cwd instead of meta, and a fully silent ladder
made the probe hook raise ROOT_UNRESOLVED past the resolve call site even
with COLGREP_MCP_PROBE unset (resolve_target_paths reaches the hook before
resolve_paths). The hook now threads meta_root and records
{"root": null, "source": "unresolved"} when the ladder declines; record()
accepts a nullable root. The two drift guards invalidated by the ladder's
new precedence and error code are re-anchored to it (the Code-enum pin
gains ROOT_UNRESOLVED; test_default_root_prefers_env becomes
test_default_root_orders_meta_first_then_roots).

Fail-first evidence (tests run against the pre-fix parent):
  tests/test_probe.py::test_probe_record_survives_unresolvable_ladder
    mcp.server.mcpserver.exceptions.ToolError: [ROOT_UNRESOLVED] no
    default workspace resolved from request _meta, client roots, or
    COLGREP_MCP_ROOT, and the working directory is not a project root
  tests/test_probe.py::test_probe_record_reports_meta_source
    TypeError: _probe_record() got an unexpected keyword argument
    'meta_root'

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tion (workspace_discovery level 2: per-call resolution ladder)
Headline metric dynamic_channels_work counts 0: all three fleet harness rows
(claude, codex, copilot-agent-plugins) measured -- on request _meta, per-call
roots, and every other signal — gap records hold only "completed but no probe
record written", so the Resolution Picks land on the guarded-cwd fail+guidance
rung R01 predicts when both dynamic channels and any pin are silent. With the
consumption side (ladder, ROOT_UNRESOLVED guided failure, meta/roots rungs) already
landed on this branch, the Decision scopes the NEXT campaign to re-probe the fleet
from authenticated sessions and default every still-silent harness to the
fail+guidance contract (error names an absolute paths entry) rather than inventing
a live dynamic signal the measurement does not support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Lead housekeeping: the results-table preamble said 'gas cell'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
LittleCoinCoin and others added 5 commits November 27, 2026 14:34
… (workspace_discovery level 3: findings report)
Close-out verifier finding F1: the ROOT_UNRESOLVED remedy looped. The error
named one absolute paths entry as the escape, but resolve_paths resolved
the default root before implicating explicit paths, so following the remedy
literally re-raised the identical ROOT_UNRESOLVED. The ladder now settles
only what inference owes — the default root for a path-less call, or the
base for relative entries — and a fully absolute paths list is the user
speaking: honored on its own, no inference consulted. The guide's existing
claim ("a single absolute project directory is the reliable way to scope
when the default root cannot be inferred") is now true; no doc wording
changed. The PATH_NOT_FOUND message only blames the default root when one
was in play.

Fail-first evidence (test run against the pre-fix parent):
  tests/test_paths_resolution.py::test_named_remedy_is_itself_a_working_escape
    mcp.server.mcpserver.exceptions.ToolError: [ROOT_UNRESOLVED] no
    default workspace resolved from request _meta, client roots, or
    COLGREP_MCP_ROOT, and the working directory is not a project root

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Close-out verifier findings F2 + F3. F2: pydantic normalizes a path-less
`file:` root URI to the truthy path '/', so the roots guard passed a root
that names no directory and a path-less call silently scoped to the entire
filesystem — the silent wrong root this campaign exists to prevent — while
the ledger certified {'static': 'declared', 'items': ['/']}. The guard now
excludes a path whose Unix-normalized form names no directory, degrading
it to the zero-root class. F3: `_classify_roots` labeled an empty item list
`declared`, against its own truth-source taxonomy ("declared: actually
returned items"); it now needs at least one usable item, so the ledger can
never certify roots the client never sent.

Fail-first evidence (tests run against the pre-fix parent):
  tests/test_paths_resolution.py::test_pathless_file_uri_root_never_scopes_the_filesystem
    AssertionError: ROOT_UNRESOLVED never raised; resolved the filesystem root
  tests/test_paths_resolution.py::test_classify_needs_usable_items_for_declared
    AssertionError: assert 'declared' == 'empty'

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rance

Close-out verifier finding F4: the first-empty reassurance was a one-shot
process budget, so a concurrent first pair lost one late root — the caller
that did not win the flag concluded from a provisional empty and fell to a
premature cwd fallback (the silent wrong root the race fix exists to end;
observable whenever a plausible-looking project sits at the server cwd).
The budget now belongs to the unsettled channel state: a caller catching
the fresh state re-asks (bounded, one per waiter), a re-ask that lands the
root settles the period and releases every concurrent waiter, and each
released waiter decides on its own one-shot re-ask rather than the stale
empty. Steady state is unchanged (settled means one round-trip per call),
and a period nobody settles releases everyone into the empty verdict with
no hanging awaits.

Fail-first evidence (test run against the pre-fix commit):
  tests/test_paths_resolution.py::test_concurrent_first_calls_both_reassure_before_settling
    AssertionError: caller B resolved [...looks-like-project] — lost the
    late root to a premature fallback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The cycle retrospective the campaign-lead close-out owes: wins (file-disjoint
dispatch rounds, fail-first at every landing, signed dump-only invariant),
pain points and root causes (permission fail-closed spine, host-path tooling,
call-graph coupling between concurrent leaves), and the next-cycle changes
that seed the following campaign.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@LittleCoinCoin
LittleCoinCoin merged commit d14e974 into main Nov 27, 2026
5 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