Skip to content

feat(fetch): harden fetch flows and consolidate shared logic - #18

Merged
dbowm91 merged 69 commits into
mainfrom
feat/auto-20261117-044c4885
Nov 22, 2026
Merged

dbowm91 merged 69 commits into
mainfrom
feat/auto-20261117-044c4885

Conversation

@dbowm91

@dbowm91 dbowm91 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Scope

This PR combines adaptive-fetch work with M001–M008 code-duplication consolidation:

  • Target-aware fetch routing, batch per-target capability parity, and local-workspace PDF ingestion.
  • Opt-in bounded webpage screenshots for web_fetch and batch web items as native MCP image content. Captures are viewport-only PNGs capped at 1280×720 and 4 MiB; screenshot bytes stay out of structured JSON and fetch caches.
  • Shared repository-target fields, request-validation helpers, browser-fetch escalation, bounded engine JSON transport, engine conformance coverage, compact provider capability declarations, and SearchEngine forwarding.
  • Preserves the advertised MCP tool surface, aliases, schema budgets, and JSON response contracts.
  • Adds live-mcp-smoke to exercise the real MCP protocol with built-in keyless defaults, default PDF and browser features enabled, and no mock feature.

Local validation

  • RUSTUP_TOOLCHAIN=1.89.0 make check — 94 all-features test targets; 6,489 passed, 0 failed, 30 ignored; formatter, Clippy, no-default-features compile, hygiene, dependency-policy, and packaging checks passed.
  • RUSTUP_TOOLCHAIN=1.89.0 make docs-check — passed.
  • The live-mcp-smoke test passed: default providers returned brave, duckduckgo, and yahoo; PDF extraction and browser rendering succeeded with no API credentials and no mock feature.
  • Focused regression checks for the type_alias response spelling, recursive integration-test helper guard, and deterministic cache-expiry case passed.

eggsearch added 4 commits November 17, 2026 22:31
Adaptive-fetch M002 and PDF M008 land together on this branch:
- web batch items gain pdf, render, and browser_profile with web_fetch semantics
- repo batch items gain symbol, match_text, block expansion, and prefer_local
- batch workspace items receive the same host-local scope as repo_fetch
- local workspace PDFs are read under the configured and feature gates, and
  batch web items gain per-URL page selection through the shared handler
- pass-cookie tests isolate their own provider, traversal wording matches the
  established error string, and the chrono advisory and packaging fixture PATH
  are handled without weakening the surrounding guards
Record the acceptance matrix, exact command outcomes, qualification
corrections, and limitations. Mark M003 ready and keep its implementation
research, seams, bounds, fixture gap, and open decisions with the plan.
@dbowm91 dbowm91 changed the title feat(fetch): add opt-in webpage screenshots feat(fetch): add target routing and webpage screenshots Nov 18, 2026
eggsearch added 25 commits November 18, 2026 15:01
…ones

ADR-0017 extends ADR-0009's permitted class from search upstreams to the
general fetch path, decides one shared orchestration module outside
src/fetch/** and src/meta/**, and leaves the prohibition list unchanged.
Anubis argon2id and hashx remain unsupported scheme and are recorded as
deferred with their own ADR.

Registers M031 fetch-path challenge solve parity, M032 ALTCHA on the
general fetch path, and M033 fetch-side pass-cookie reuse. M031 is
dependency-ready; M032 and M033 wait on M031's closure.

No production code changed.
Implements M031 under ADR-0017. The bounded Anubis solve moves out of the
MCP web-fetch tool into a shared module, src/challenge_replay/, that owns
the detect, solve, replay, and classify sequence. The MCP web family, the
remote repo_fetch path, and the CLI fetch command now share one
implementation.

The fetch layer still only detects and marks: no file under src/fetch/ may
import the solver, and only src/challenge_replay/ may call it. Two static
guards enforce both.

Fetch-path solves are recorded under the ledger label "fetch". The
repo_fetch response gains manual_interaction_required and forwards the
fetch_challenge_page warning. The CLI payload gains structured_warnings and
manual_interaction_required.

No configuration key, default, dependency, refusal key, advertised tool, or
advertised schema changed.
Records the exact-candidate evidence for M031: the shared
src/challenge_replay/ module, the remote repo_fetch and CLI solve paths,
the proven batch_fetch inheritance, the two static guards, and the
corrected stale architecture/fetch.md residual.

Pinned Rust 1.89 make check passed on candidate
7f7219b with 85 suites and 6,374 tests,
and make docs-check passed.
M031 is closed, so the hard dependency behind both remaining fetch-path
milestones is satisfied. ADR-0017 is accepted and the shared replay seam
M031 landed is the module both plans build on.
Implements M032 under ADR-0017. The shared src/challenge_replay/ module
gains an ALTCHA branch beside the Anubis one, so a general fetch that meets
a published ALTCHA PBKDF2 wall attempts one bounded solve and one replay on
every surface: the MCP web family, the remote repo_fetch path, and the CLI.

The new src/challenge_replay/altcha.rs owns the two page-shaped decisions
the solve needs. It reads the challenge document and the verification
endpoint from the page's own altcha-widget publication, resolves a published
endpoint against the page URL with Url::join rather than string
concatenation, and refuses a cross-origin, scheme-changing, credentialed,
query-bearing, over-long, or off-shape endpoint as unsupported scheme before
any request is issued. A published payload that does not parse into the
documented parameter set is refused as malformed parameters.

src/meta/challenge/altcha.rs keeps one solve implementation. It now also
accepts a document the page published inline, so the engine-side caller and
the fetch-path caller share the same parse, counter search, and
verification POST. The published PBKDF2 cost is the work factor of a single
counter iteration, so a cost above MAX_PBKDF2_COST is refused as malformed
rather than started.

Two static guards enforce the ownership and the same-origin gate, and a
property test proves a derived endpoint is never cross-origin.

No configuration key, default, dependency, refusal key, advertised tool, or
advertised schema changed.
Records the exact-candidate evidence for M032: the shared
src/challenge_replay/ module gained an ALTCHA branch, the page-published
endpoint derivation is same-origin only, one ALTCHA solve implementation
serves the engine side and the fetch side, the two new static guards and the
cross-origin property test hold, and the stale docs/config.md batch_fetch
claim is corrected.

Pinned Rust 1.89 make check passed on candidate
421d4b2 with 85 suites and 6,399 tests,
and make docs-check passed.
M033 closed with a known limitation: a stored pass pair set the upstream
refused cost one degraded fetch, because the call that discovered the refusal
returned the marked challenge page and the next fetch solved.

ADR-0018 authorizes the in-call recovery and refines ADR-0017 clause 5. The
surviving bound is one solve and one replay of a solved pair set per fetch
call. A refused pair set is presented at most once, as a reuse probe that no
solve produced, and the call's single solve and single replay are spent on the
freshly issued pair set. A transport error, a timeout, and a non-2xx status
are not refusals, so a transient failure never spends the solve budget.

The rule is written into architecture/fetch.md before the code.
The shared challenge module consulted the origin-keyed pass-cookie cache
before it solved. When the upstream refused the stored pair set, the call
ended there: the entry was evicted, the marked challenge page was returned,
and the next fetch solved from cold. A caller had to await a second fetch to
get a document.

The refusal already carries everything the recovery needs, because the call
still holds the challenge page it was about to solve. The reuse path now
reports the refusal, and the call continues into the ordinary solve path with
the challenge page it already holds, then the ordinary replay, then the
ordinary storage of the freshly issued pair set. The rejected pair set is
never presented a second time.

The bound is unchanged where it matters: one solve and one replay of a
solved pair set per fetch call, inside max_difficulty, max_attempts,
timeout_ms, and the call deadline. The refused pair set costs no solve
attempt of its own because no solve produced it. A transport error, a
timeout, and a non-2xx status are not refusals, so the stored pair set is
kept, no solve is attempted, and the original response is left exactly as it
was.

The origin key, the same-origin gate, the first-hop-only attachment, the
reuse window, the tool surface, the configuration surface, and the refusal
vocabulary are unchanged. No tool, argument, schema, or configuration key
changes.
A fetch that met a stored pass pair set the upstream refused now recovers in
the same call: the refused entry is evicted, the call solves the challenge it
was already holding, replays once with the freshly issued pair set, and
returns the document. The caller never has to await a second fetch.

The bound holds: one solve and one replay of a solved pair set per fetch
call, inside max_difficulty, max_attempts, timeout_ms, and the call deadline.
A refused pair set is presented at most once and costs no solve attempt of
its own. A transport error, a timeout, and a non-2xx status are not
refusals, so the stored pair set is kept and no solve is attempted. A failed
recovery leaves the original response and the origin exactly as they were.

The closure record also closes M033's live-qualification gap. The pass-cookie
reuse was observed against a real protected origin, git.disroot.org behind
Anubis v1.25.0: one cold fetch solved once at 1143 ms, and the next two
fetches returned the document at 466 ms and 464 ms with the solve count
frozen at one. A control run with solving disabled met the Anubis wall on
every fetch, so the documents came from the stored pair set and not from the
upstream relaxing. The upstream never refused a stored pair set during the
window, so the recovery itself remains proven by deterministic loopback
evidence only.
Widen the permitted challenge class by property rather than by name, add a memory
ceiling beside difficulty, attempts, and wall clock, adopt browser challenge
completion and browser-like identity, and default the solver on with a false
value restoring the current behaviour exactly.

Supersede ADR-0009 in four clauses and ADR-0010's coverage bullet by appended
pointer; the accepted records are not rewritten.
With policy=auto, send a solvable wall to the solver rather than Chrome, complete
a script-driven wall in the browser by live re-classification, and return an
unresolved wall marked rather than as a bare document.
The solver runs before the browser on a detected wall, the browser completes a script-driven wall by live classification rather than four title substrings, and an unresolved wall is returned marked rather than as a bare document.
…o the solver

Under render=auto the fetch path now attempts the bounded solver before any browser escalation, so a solvable Anubis or ALTCHA wall returns its document without launching Chrome. A wall the solver leaves unsolved is completed by the browser, which polls live classification instead of four title substrings, and a wall that does not resolve is returned with manual_interaction_required and the fetch_challenge_page warning rather than as an unmarked document.

provider_status challenge_solver entries gain browser_completions, a count of walls a browser render completed. One solver attempt pair and one escalation per call still hold.
Record the exact candidate, the requirement-to-evidence matrix, the observed ordering before and after, the suite counts, and the residual risk. The browser polling loop itself is not in the default gate and is recorded as such rather than as a satisfied criterion.
…routing

M036 charges a unified fetch repo item by readable text plus bounded metadata
instead of its serialized JSON, clips text before an omission, marks an omitted
item failed with a budget error and one structured warning, and names the
missing field for an incomplete locator. A repo file that repo_fetch returned
is now returnable through fetch at the default budget.

M037 keeps the local source-role bonus as ranking only: a file is admitted only
on a query, path/file, content, or symbol match, a no-match query reports an
explicit empty state, a remote-scoped request includes local results only with
explicit include_local, and truncation is reported only when a match was
dropped.

M038 selects already-enabled native advisory providers for identifier-bearing
security requests that carry no explicit provider list, makes the availability
and severity warnings conditional and truthful, and adds an optional sanitized
advisory summary bounded to 500 characters.

make check passes with 85 suites and 6,445 tests (28 ignored), the mock feature
build passes with 6,418 tests (5 ignored), and make docs-check plus the planning
and hygiene contracts pass.

Also records the M035 live browser evidence and page-scraping surface audit from
the same review.
Record the exact implementation candidate 76c1156,
the requirement-to-evidence matrices, the live before/after probes, the broad-gate
counts, and the residual risk for the three corrective milestones.

M036 records the readable-text measure, truncate-before-omit, the failed omission
outcome, and the locator repair. M037 records role-only ranking, the explicit
no-match state, the scoped include_local rule, and the truncation meaning, plus
the bounded content-recall limit. M038 records default native advisory selection,
truthful warnings, the conditional severity warning, and the 500-character
summary.

Registry and roadmap move the three milestones to closed.
MSG && git log -3 --format='%h %s' && git status --short | wc -l
M039 makes max_total_chars bound the emitted fetch payload: optional
document/lines structure degrades before the requested text is clipped, and
payload_chars reports the true emitted size alongside the readable measure.

M040 makes local content and symbol queries scan beyond the path-ranked
candidate window inside a time/byte bound, with bounded git acceleration where
available and truncation/no-match signalling that describes the scan.

Both are corrective to the closed M036 and M037. The measured evidence (a
three-item batch reporting 12,223 characters while serializing 186,812 bytes;
a default local request reading 10 of 983 files while a 0.05 s git grep finds
the term) and the work packages are in each plan.
MSG && echo '---' && git log -2 --format='%h %s' && git status --short | wc -l
M039 enforces max_total_chars against the serialized item payload, degrading document blocks/chunks, document, and lines before clipping text, with payload_chars/total_payload_chars telemetry and one batch_payload_budget_degraded warning per degraded item.

M040 adds a deterministic second local-search pass beyond the path-ranked window (512 files / 8 MiB / 1.5 s), a bounded git-grep skip hint, symbol-hint recall, and exhausted-versus-cut-short signalling.
@dbowm91
dbowm91 force-pushed the feat/auto-20261117-044c4885 branch from 414b28b to 10986ed Compare November 20, 2026 18:01
eggsearch added 11 commits November 20, 2026 18:56
…iagnostics

Bundle a source-verified model-cutoff catalog instead of a single row. The
checked-in manifest is the review surface: eleven verified cutoffs across
OpenAI, Anthropic and xAI, each carrying the vendor page and verification
date, plus five explicit no-published-cutoff dispositions. A validator test
rejects alias collisions, precision mismatches, and any disagreement between
the manifest and the bundled snapshot, and model_resolution now reports
catalog_as_of so a stale catalog is visible without a schema break.

Distinguish index states that M004 left merged. A request that asks to read or
retain while the index is disabled now reports index_status: disabled and
never opens or creates the database, and an index refresh that emits nothing
separates index_not_seeded and index_stale from a genuine
no_matching_index_hits. Freshness comes from a bounded partition-scoped
status probe and a pure retention classifier; a probe failure degrades the
index instead of failing the call.

Qualify discovery on a frozen corpus: 88 cases over eight ecosystems covering
direct emission, withheld-name recovery through an indexed edge, negative
controls, month-precision ambiguity and duplicate conflicts. The harness
asserts zero false temporal claims, zero duplicate ids, budget and identity
invariants, and deterministic replay. No ranking or planner code changed.
Record the three closures together with the status they assert. M005 publishes
eleven source-verified cutoffs across three provider families plus five explicit
no-published-cutoff dispositions. M006 makes disabled, unseeded, stale,
no-match and unreadable index states distinguishable without changing a default.
M007 publishes a frozen 88-case corpus and a 15-topic live study, makes no
production change, and therefore claims measurement rather than improved recall.

Gates on the recorded candidate: make check exit 0 with 6,549 passed and 28
ignored, make docs-check exit 0, planning consistency ok.
The candidate needed three hosted attempts. The first two failed on
local_workspace_integration::local_repo_search_finds_source_files, whose compiled
test binary is identical to the one that passed the same macOS job before these
milestones, and which passes 8/8 locally; the third attempt is green on all three
CI jobs plus egress and drift. Record the attempts instead of claiming a clean
first run.
…nism

The M005-M007 hosted qualification failed twice on
local_workspace_integration::local_repo_search_finds_source_files and passed on an
unchanged third attempt with a byte-identical test binary. The fixture's only
match is content-based, and the response does not say whether the bounded
content pass was skipped, clipped, or genuinely found nothing.

Register corrective M043 rather than patching the assertion: classify the cause
with telemetry, make an incomplete content pass distinguishable from a true
no-match, add a forced-skip regression, and require 20/20 saturated runs plus a
green hosted macOS job on the exact candidate.
A cold local repo_search spent its whole 500 ms default request budget on the
first inventory build (measured 174-305 ms on an idle host), so the bounded
content pass could return nothing under hosted load while the response carried
`local_search_timeout`. The scan clock now starts when the build finishes, and
the build keeps its own 5 s git bound.

The second pass also skips its `git grep` hint below 32 unscanned candidates,
because one git spawn costs more than reading a small set.

`local_repo_search_finds_source_files` now requires the content match instead
of any non-empty group, and states the response on failure. New regression
tests cover the aged-start starvation, the hint threshold, a stated timeout,
and a stated file-cap truncation.

M043.
The hosted macOS job that failed twice on e817dfd passed on attempt 1 for
5a218a4, so the fixture's environment sensitivity is closed with the scan
budget starting after the inventory build.

Records the classification (cold build consuming 35-61% of the 500 ms request
budget before any candidate was scanned), the captured before/after responses,
the 20/20 saturated profile, the exact-candidate gates, and the pre-existing
Python native qualification failure that predates this milestone.
@dbowm91
dbowm91 force-pushed the feat/auto-20261117-044c4885 branch from df88b7c to 56f0bcb Compare November 20, 2026 22:53
eggsearch and others added 13 commits November 20, 2026 23:52
`src/meta/knowledge_delta/catalog.json` was added in e817dfd but
`[package] include` matches only `src/**/*.rs`, so neither the crate tarball
nor the maturin sdist carried it. `cargo package` verification and the
extracted-sdist rebuild both failed on the missing file. The guard also found
`packaging/release-targets.txt`, read by a platform unit test, absent from the
same list.

Add both entries and wire `packaging/check-packaged-assets.py` into
`packaging/check-contract.sh`: it compares `cargo package --list` against
every `include_str!`/`include_bytes!` literal under `src/` and fails when a
target is missing from the packaged set.

Registers Python PyPI distribution M005 as the corrective milestone and
reconciles the M043 closure record, which had described this regression as
pre-existing.
Hosted evidence on ca24ee1: Python native qualification 44839984115 green
including the extracted-sdist rebuild that had failed since bc52970, CI
44839984052 green on all three jobs, egress 44839984130 and release drift
44839984046 green, all on attempt 1.

Records the packaged-file counts before and after, the guard's positive and
negative controls, and the residual limits (src-only coverage, literal paths,
maturin 1.9.5 locally against the pinned 1.15.0 lane).
…alls

ADR-0019 §4 states that `[search.challenge].enabled` defaults to true; M035
shipped the capability with the default still false. Turn it on and raise the
shipped ceilings to what the supported upstreams serve today:
`max_difficulty = 6`, `max_attempts = 100000000`, `timeout_ms = 10000`.
The attempt ceiling sits above what the wall clock can spend at measured
release speed, so the clock governs the cost while a projected difficulty 7 is
still refused.

On a config with no `[search.challenge]` table, the release build now returns
five results for mojeek (1.6 s then 0.3 s) and startpage (2.6 s then 0.4 s)
instead of `blocked`, and the fetch path solves a startpage Anubis wall
without launching the browser. duckduckgo is unchanged; `enabled = false`
restores the previous behaviour.

Registers M044 and updates the config, provider-setup, features, architecture
and changelog text that still described the solver as opt-in.
Hosted evidence on 7b28436: CI 44859709721 green on all three jobs, Python
native qualification 44859709648 green including the extracted sdist, egress
44859709752 and release drift 44859709669 green, all on attempt 1.

Records the ADR gap (default still false), the ceiling change with the
23.07M-candidate measurement behind it, the default-config solve and reuse
timings, the fetch-path solve, and the Brave 429 / Yahoo 500 evidence with the
options that would resolve them.
Brave answers its proof-of-work wall with HTTP 429 while serving the challenge
document. The HTML engines classified the status without reading the body, so a
solvable challenge became `rate_limited` and the provider cooled down.

Read and classify the body for any status: the shape's blocked markers decide
first, then a raw-payload marker set for script-rendered shells whose visible
text never appears as a node (Brave's 80 KiB captcha shell keeps its strings in
the embedded i18n script). Brave's markers move to the current page text; an
empty 500 still reports BadStatus.

In-app browser verification on this egress: Brave serves the captcha and returns
full results once the browser completes it, reusing the pass cookie on the next
search, and Yahoo renders a complete results page with no visible challenge.
That is M045 work package 2 (browser-rendered SERP); this commit is work package
1 and reconciles the M044 record that called these egress refusals.
…rowser

Brave answers HTTP 429 with a proof-of-work page and Yahoo answers a
headless client with HTTP 500 and a zero-byte body, while a real browser
receives a full result page from both. The engines now keep the HTTP
request as the first attempt and fall back once to a bounded browser
render when that attempt is blocked or answered with 429/5xx, parsing the
rendered DOM with each provider's existing parser.

The browser also presents the identity of the Chrome build it is instead
of HeadlessChrome/..., and valued flags reach chromiumoxide as key/value
pairs; a literal "--key=value" argument was emitted as "----key=value"
and silently ignored, so --user-data-dir never reached the process.

- meta::engines::render owns SerpRenderer and the escalation predicate;
  src/serp_render implements it over the shared lifecycle, so fetch stays
  independent of meta and the browser stays optional.
- classify: a wall marker outranks the document status, the served-page
  override is limited to 202/429, and interactive markers are widget
  specific so "Switch to traditional CAPTCHA" is not a captcha.
- navigate: one click of the page's own scripted-verification control per
  render, inside verification_wait_ms.
- brave: rebuild the destination from the displayed cite when the result
  links to the opaque /go/v1 token.

No tool, argument, schema property, configuration key, or provider id
changes. M045 work package 2.
Records work package 1 and work package 2 closure on
364014c: hosted CI, Python, egress,
and drift all green; local gates 6 567 passed / 28 ignored with 723
engine tests; release matrix returning five results from both
browser-gated providers.

M045 is closed in the registry, the roadmap, and the implementation
plan; the roadmap's deferred list no longer claims browser challenge
completion and browser-like identity are unimplemented.
M046. The fetch client rejects every non-2xx document with FetchError::HttpStatus before the automatic escalation decision runs, so a 429 or 5xx from a browser-gated origin never reached the browser the search engines already use. Under render=auto the tool now escalates once at that error seam, before the retry and before any origin failure is recorded, and accepts the rendered document only when the render ended on 2xx/3xx or completed a recognised wall. The status class is defined once in fetch::challenge::is_browser_gated_status and meta::engines::render::is_browser_gated delegates to it. The CLI honours [fetch.browser].policy with no new flag. No tool, argument, schema property, configuration key, provider id, or dependency changed.
Records the exact-candidate evidence for 20c0672: the pre-change measurements, the mock escalation matrix, the live before/after for web_fetch and the CLI on both origins, the refusal case, the gates, the hosted qualification, and the residual risk. Flips M046 to closed in the plan, the registry, and the roadmap, and points them at the closure record.
- Retire repo_fetch from the advertised inventory and keep it callable as a
  third compatibility alias with its unchanged request and response (ADR-0022).
- Point generated follow-ups, recipes, and the SDK at fetch with an executable
  repo item, so no suggestion asks a caller to reconstruct a locator.
- Project the build_evidence_bundle input to a bounded passthrough shape:
  40,152 -> 2,578 definition bytes, 39 -> 1 $defs, runtime types and pinned
  bundle/source/fetch IDs unchanged.
- Single-source the goal and research_domain vocabularies so both schema
  profiles advertise the same accepted values, and move compact field
  allow-lists next to their argument types.
- Add tests/tool_inventory_parity.rs and strengthen the alias boundary; drop
  copied preset counts from prose.
- Amend the long-term specification, ADR-0001/0016/0020/0022, AGENTS.md, the
  tool matrix, CodeGG and architecture docs, skills, and the changelog.
- Close M001-M004 with closure records.

Full tools/list drops 72,388 -> 31,521 bytes; compact 19,739 -> 18,686.
The python-native-qualification workflow and the installed-wheel smoke script
pinned the canonical inventory at ten names, so the sdist rebuild and the
ARMv7 installed-wheel jobs failed after repo_fetch became a compatibility
alias. They now expect nine, and the wheel smoke passes locally against the
built wheel.

Also correct the remaining "ten canonical tools" wording in src/lib.rs,
src/core/config/mcp.rs, and two test failure messages.
@dbowm91 dbowm91 changed the title feat(fetch): add target routing and webpage screenshots feat(fetch): harden fetch flows and consolidate shared logic Nov 22, 2026
@dbowm91
dbowm91 merged commit ec04967 into main Nov 22, 2026
47 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