diff --git a/CHANGELOG.md b/CHANGELOG.md index db215b93..a1abf64c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `knowledge_brief` treats a present-but-null `cutoff`, `knowledge_cutoff`, or `cutoff_date` as an omitted field instead of rejecting it as a near-miss, so a serializer that emits an unset optional member as JSON null no longer fails the call. Every non-null near-miss value is still rejected with the same repair hint. - Browser interception applies the reserved-hostname classifier before DNS, so `.invalid`, `.test`, and `.localhost` names fail closed in the render path too. Trailing-dot fully-qualified names classify exactly like their canonical spelling in both the fetch validator and the browser path, and both paths share one classifier rather than separate suffix lists. - A blocked redirect preserves the validator's reason verbatim under `redirect_target_blocked`, so a reserved or private target no longer reports as `private network: …`; the embedded-credentials arm keeps its `credentials: ` prefix. +- `snapshot.compare` reports real changes for a container document. Container documents (CSV/TSV, DOCX, XLSX, PPTX, EPUB) carry their text in `parts` and leave `blocks` empty, so the comparison projected an empty string, hashed the empty string, and returned `same` with `chars_added: 0` and no hunks for every document, including one whose bytes had changed. The projection now uses the part texts joined with a blank line when `blocks` is empty, keeps the blocks path for HTML, PDF, and markdown, and reports `snapshot_content_unavailable` rather than storing an empty baseline when a document has no comparable text. A stored empty baseline is not migrated: the next fetch of that URL stores real text and reports `changed` once. +- Startpage's block page reports `blocked` instead of a structural `parse_error`. A `Startpage Blocked` page matched no declared marker, so it was classified as a drifted result container and reported as a parser defect; it is now a declared block marker. The Anubis selectors are the only markers that start a challenge solve, so a generic block page never enters the solver. +- A completed or cancelled deferred task no longer reports `statusMessage: "working"`. The message was seeded at spawn and never rewritten, so a task that had reached a terminal state still advertised a working state. No message is seeded now; a task reports only a phase message that its operation publishes. ### Added diff --git a/architecture/fetch.md b/architecture/fetch.md index 47344dc4..15efeabe 100644 --- a/architecture/fetch.md +++ b/architecture/fetch.md @@ -1130,10 +1130,16 @@ cache scope (anonymous or opaque profile ID), normalized URL, extraction mode, selector-scoping fingerprint, representation class, and optional caller key; one caller label never crosses URLs or profiles. -The snapshot source is Tier-1-sanitized `FetchDocument.blocks`, projected with -`project_document_text` under the raw text cap. Truncated documents, blocks, or -projections are refused with `snapshot_content_limit_exceeded`; `response.text` -is used only when no document exists. The path deliberately avoids `raw_text`, +The snapshot source is Tier-1-sanitized document content: `FetchDocument.blocks` +projected with `project_document_text` under the raw text cap, or — for a container +document, which populates `parts` and leaves `blocks` empty — the part texts joined +with a blank line by `project_parts_text`. A container document that projected an +empty block list stored an empty baseline and compared as `same` for every change, +so the parts path is required. Truncated documents, blocks, or projections are +refused with `snapshot_content_limit_exceeded`; `response.text` is used only when a +document carries neither blocks nor parts, and a document with no comparable text +reports `snapshot_content_unavailable` instead of storing an empty baseline. The path +deliberately avoids `raw_text`, which is derived from decoded transport bytes and may contain HTML. Browser rendered responses are excluded. HTTP 404/410 is observed before ordinary fetch-error conversion and reports `removed` without deleting the prior entry. diff --git a/docs/features.md b/docs/features.md index 655f48fe..f9119c6f 100644 --- a/docs/features.md +++ b/docs/features.md @@ -118,11 +118,12 @@ cargo build --no-default-features --features pdf ``` The Python extension builds with `default-features = false` and -`features = ["pdf", "browser"]`. Every Python wheel target uses this one -feature set; there is no browser/no-browser wheel variant, and `egress` is not -compiled. A wheel built from current source includes both PDF extraction and -browser rendering. The published `eggsearch==0.4.4` wheel remains PDF-only. See -the [Python library guide](python-library.md). +`features = ["pdf", "browser", "documents"]`. Every Python wheel target uses +this one feature set; there is no browser/no-browser wheel variant, and `egress` +is not compiled. A wheel built from current source includes PDF extraction, +browser rendering, and container-document extraction. The published +`eggsearch==0.4.4` wheel remains PDF-only. See the +[Python library guide](python-library.md). ### Capabilities diff --git a/docs/release.md b/docs/release.md index 6a413119..d30f8a28 100644 --- a/docs/release.md +++ b/docs/release.md @@ -81,11 +81,12 @@ PyPI's long description is embedded from `bindings/python/PYTHON_README.md`, which mirrors the root `README.md`. Updating that source changes the description on the next version upload; an existing PyPI release cannot be overwritten. -The wheel is deliberately narrower than the binary assets: -`bindings/python/Cargo.toml` sets `default-features = false, features = ["pdf"]`, -so the Python distribution carries PDF extraction but not browser rendering. -Python users who need rendering need the Rust binary or a source build that -enables the feature; this asymmetry changes no binary asset name or count. +The wheel compiles the same feature set as the binary assets: +`bindings/python/Cargo.toml` sets `default-features = false` and +`features = ["pdf", "browser", "documents"]`, so the Python distribution carries +PDF extraction, browser rendering, and container-document extraction. `egress` +is compiled into neither the released binaries nor the wheel. This parity +changes no binary asset name or count. Public install instructions are in `README.md` and `docs/python-library.md`. The published aarch64 wheel has passed native smoke and benchmarking; results diff --git a/docs/test-inventory.md b/docs/test-inventory.md index 225a742c..29bbf8d7 100644 --- a/docs/test-inventory.md +++ b/docs/test-inventory.md @@ -6,8 +6,12 @@ Inventory of all hardening and regression test suites. | Feature Combo | Tests | Ignored | |--------------|-------|---------| -| `--all-features` | 6711 | 30 | -| `--features mock` | 6647 | 6 | +| `--all-features` | 6733 | 25 | +| `--features mock` | 6681 | 2 | + +Counts measured with `cargo test --locked -- --list` and +`-- --list --ignored` on 2026-11-30. They are a snapshot of the candidate, not a +stable claim; re-measure at each closure rather than deriving them from a diff. Ignored tests are live-network smoke tests (`corpus_runner`, `mcp_http` via `live-mcp-smoke` or `live-release-smoke`, `browser_live_smoke`, `native_forge_smoke`, `retrieval_quality`), the PDF fidelity recorder (`pdf_fidelity`), plus the opt-in live-model comparison (`tool_surface_live`) — they run only via explicit opt-in targets. `make live-release-smoke` builds the same `mcp_http` smoke with `--release`; challenge-solver and proof-of-work timings are only meaningful there. @@ -17,10 +21,10 @@ Ignored tests are live-network smoke tests (`corpus_runner`, `mcp_http` via `liv |-------|-------------|-------| | `mcp_tools` | `mock` (mostly) | Tool registration, input validation for all 10 tools, including the tagged fetch web/repo item schema, response shape, legacy-name rejection; opt-in screenshot PNG bounds, browser capability/conflict errors, image-out-of-JSON/cache behavior, and ordered batch image association | | `web_search_integration` | `mock` (mostly) | Web search validation, sanitization, intent reranking, excerpt bounds, explicit-provider unbuildable-id rejection, derived-intent reporting and applied reranking, search-result cache hit/miss/coalesce equivalence and partial-fan-out bypass, blocked-provider classification | -| `engine_parse_conformance` | `mock` | Captured-fixture conformance for the five HTML scrapers: parsed rows, explicit empty state, block classification, and a seeded-drift negative control that requires `parse_error` plus a stable, bounded title/body fingerprint | +| `engine_parse_conformance` | `mock` | Captured-fixture conformance for the five HTML scrapers: parsed rows, explicit empty state, block classification (including the two distinct Startpage block pages), and a seeded-drift negative control that requires `parse_error` plus a stable, bounded title/body fingerprint | | `engine_api_conformance` | none | Table-driven conformance for the nine forge engines: 401/403/500 mapping, malformed-JSON `ParseFailed`, zero-result no-request, per-page limit, documented auth header, skipped invalid URLs, and one conversion case per engine | | `web_fetch_integration` | `mock` (mostly) | Fetch extraction, truncation, metadata-only mode, safety bounds, anti-bot challenge marking (`fetch_challenge_page` + `manual_interaction_required`), Anubis and ALTCHA solve-and-replay under `[search.challenge]`, fetch-side pass-cookie reuse, lifetime expiry, malformed-lifetime refusal, rejection eviction, in-call recovery from a refused pair set, and cross-origin isolation; plus auto-mode ordering (the solver owns a solvable wall and Chrome is never launched), unresolved-wall marking, interactive challenges staying manual, the deadline leaving no render time, the `browser_completions` counter, and the browser-gated status seam (a `429` and a `500` each escalate once, `402`/`403`/`404` never render, `http_only` never renders, a missing browser keeps the `http_status` error and names the unavailable escalation, a render that ends on `5xx` without a completed wall keeps the original error, and a served origin is not charged to the circuit breaker) | -| `snapshot_change` | `mock` | Deterministic `new` → `same` → `changed` comparison of sanitized extracted text, SQLite privacy inspection, brief projection, and disabled-store warning/no-file behavior | +| `snapshot_change` | `mock` | Deterministic `new` → `same` → `changed` comparison of sanitized extracted text, including a container document whose text lives in `parts` rather than `blocks`, SQLite privacy inspection, brief projection, and disabled-store warning/no-file behavior | | `documents` | `documents` (feature-off cases run without it) | Bounded container-document extraction for CSV/TSV, EPUB, DOCX, XLSX, and PPTX: format detection by content type, extension, and container introspection; deterministic part order and one-based part addressing; spreadsheet dates and locale-independent numbers; the `document_empty`/`document_malformed`/`document_unsupported`/`document_encrypted` outcomes; archive-entry, decompression, inflation-ratio, part, character, XML-depth, and cell bounds; feature-off parity for CSV and every container format; 11 cases with the feature and 3 without, including a DOCX with XML character references, an EPUB with a plain doctype, and delimiter-dense CSV refused at the cell bound | | `site_map` | `mock` | Bounded same-origin URL discovery as a `fetch` item: robots `Sitemap:` reading, declared and fallback sitemaps, one index level, duplicate collapse, query normalisation, malformed XML, gzip refusal, cross-origin refusal including a cross-origin redirect, URL/XML-depth truncation, deterministic ordering, and zero fetch of discovered URLs | | `provider_routing` | `mock` (mostly) | Provider routing, code-host rewrites, diagnostics, capability-skip telemetry, keyless source-provider routing/disabled-skip behavior, credentialed-provider opt-in/configured status reporting, explicit-provider rejection classification matrix (unknown/disabled/missing-credential/not-built), CodeGG parity qualification journeys | @@ -109,7 +113,7 @@ Every case is generated synthetically by this repository; no third-party documen | `egress_routing` | None (proxy composition under `egress`) | 35 | Egress config validation (incl. IPv6 literals), credential redaction, custom-dialer SSRF gate, deterministic HTTP/SOCKS/multi-hop composition, pool reuse, handshake cancellation/deadline, HTTPS TLS/SNI through CONNECT, gzip/Brotli decode with decoded-body limits, authenticated HTTP/SOCKS with credential non-forwarding, malformed-proxy fail-closed, routed redirects | | `proxy_route_feasibility` | None (Eggress comparison under `egress`) | 11 (+1 with `egress`) | Loopback-only dynamic-proxy characterization: CONNECT authority and pinned-IP/Host/SNI behavior, HTTP forward and pin rejection, SOCKS5/SOCKS5H, authentication, proxy TLS, malformed route, timeout, pinned redirect, `NO_PROXY`, loopback refusal, handler-level pinned CONNECT and SOCKS5 targeting, proxy `407` mapping, redirect route-change refusal, and optional Eggress custom-dialer comparison | | `fetch_proxy_route` | `mock` | 7 | `[fetch.proxy]` handler contract: `no_proxy` reporting for single and batch items, direct route metadata omission, `proxy_required` plaintext refusal before any direct request, unreachable-endpoint fail-closed, missing credentials before target lookup, `cache_only` under a proxy route, and redacted `provider_status` without environment names | -| `snapshot_change` | `mock` | 6 | Persistent deterministic comparison across `new`/`same`/`changed`/`removed`, sanitized storage and privacy, brief-projection retention, disabled and corrupt-store degradation, caller-key validation, and the no-store default | +| `snapshot_change` | `mock` | 8 | Persistent deterministic comparison across `new`/`same`/`changed`/`removed`, a container document's parts-backed text compared across a changed row, a metadata-only container document that refuses to store an empty baseline, sanitized storage and privacy, brief-projection retention, disabled and corrupt-store degradation, caller-key validation, and the no-store default | | `documents` | `documents` (feature-off cases run without it) | 3 without the feature; 11 with it | Container-document extraction and outcome contract for CSV/TSV, EPUB, DOCX, XLSX, and PPTX, deterministic part order across repeated runs, the `documents_enabled` switch, the capability triad, and feature-off parity for CSV and container formats | ## Forge Adapter Tests (`tests/forge_adapter.rs`) diff --git a/plans/implementation/agentic-retrieval-integrity/058-live-sweep-defect-correctives.md b/plans/implementation/agentic-retrieval-integrity/058-live-sweep-defect-correctives.md new file mode 100644 index 00000000..5caa023a --- /dev/null +++ b/plans/implementation/agentic-retrieval-integrity/058-live-sweep-defect-correctives.md @@ -0,0 +1,189 @@ +# M058 — Live Sweep Defect Correctives + +Status: active +Date: 2026-11-30 +Subsystem: agentic retrieval integrity +Milestone class: invariant (corrective program) +Baseline: commit `9061bf8e4d04953d940fe13082c3f8587d548d6b` with the two documentation corrections from the 2026-11-30 live sweep applied +Corrects: M003 (snapshot comparison), M009 (deferred task surface), M049 (non-success block classification) +Decision authority: user approval of the 2026-11-30 live sweep report ("go ahead and patch the 3 defects found"); `plans/003-planning-process.md` §7 (corrective work is a new plan). +Closure: `plans/closure/agentic-retrieval-integrity/058-status.md` + +## Objective + +Close the three defects that a live end-to-end sweep of all twelve callable MCP names +found on the shipped `v0.4.5` surface. Each defect is a silent wrong answer rather than a +crash: a container-document snapshot comparison reports `same` for content that changed, +a Startpage block page is reported as a parser defect, and a completed deferred task keeps +advertising `statusMessage: "working"`. Each fix is bounded to one seam and is backed by a +regression test that fails on the baseline. + +## Evidence and corrective rationale + +| Finding | Baseline evidence | Why the existing coverage missed it | +|---|---|---| +| F1 (P1) Snapshot comparison reports `same` for every container document. Container documents populate `parts` and leave `blocks` empty, so the projection hashes the empty string. Live probe: fetch a CSV with `snapshot.compare: "line"` → `new`; append a row; refetch with `cache_policy: "bypass"` → `same`, `chars_added: 0`, `hunks: []`, while `text` demonstrably contains the new row. The store rows held `text = ''` and `content_sha256 = e3b0c442…` (SHA-256 of the empty string), while the HTML and PDF rows stored real text. | `src/fetch/snapshot/mod.rs:52` projects `document.blocks` only; `src/fetch/projection.rs:10` returns `("", false)` for an empty block list; `src/fetch/client.rs:901` joins `part.text` with `\n\n` and constructs the document with `blocks: Vec::new()`. | `tests/snapshot_change.rs` serves HTML only, and the projection unit tests assert that an empty block list projects to empty text, which is true but is the defect path. No test drives a container document through `compare_response`. | +| F2 (P2) A Startpage block page is classified as a structural parse failure. Live probe: `provider_status` with `probe: true` reported `engine 'startpage' parse failed: result container 'div.result' missing [title=Startpage Blocked digest=a04b95062ac56f00]`. | `SHAPE.blocked_markers` in `src/meta/engines/startpage.rs:27` lists `Access Denied - Startpage` and the two Anubis selectors, so the observed page matched no marker and fell through to `finalize_scrape`'s structural branch. | The captured fixture carries the `Access Denied - Startpage` title, which is the CDN error page, not the page this egress receives; the sweep observed a different block page. | +| F3 (P3) A completed deferred task keeps `statusMessage: "working"`. Live probe with `[mcp.tasks] enabled = true`: poll `tasks/get` until terminal → `status: "completed"` with `statusMessage: "working"`. | `src/mcp/tasks.rs:66-69` seeds the message once at spawn through `TaskOptions::with_status_message`; rmcp assigns `status_message` only at spawn (`task_manager.rs:324`) and in `TaskContext::set_status_message` (`:100`), never on a terminal transition. | No test reads `status_message`; the tasks tests assert terminal status only. | + +## Contract and invariants + +- Keep the nine advertised tools, twelve callable names, aliases, accepted argument sets, + error codes, providers, default sets, response fields, and trust framing unchanged. +- No advertised schema or description change, so no fingerprint re-pin is expected. +- Keep `snapshot_content_limit_exceeded` for a truncated document and + `snapshot_content_unavailable` when there is no comparable text; do not invent a new + warning code. +- Keep the four scraper outcomes distinct. A block page stays `EngineError::Blocked`; a + drifted result container stays `EngineError::ParseFailed` with the same bounded + fingerprint; an empty state stays an empty result list. +- Keep every Anubis solve path reachable: only the declared challenge markers may start a + solve, so a generic block page must not enter the solver. +- Do not migrate or rewrite existing snapshot rows. A stored empty baseline stays until the + next comparison overwrites it for that key. +- Tests stay keyless and network-independent. + +## Expected production changes + +| File | Change | +|---|---| +| `src/fetch/projection.rs` | Add `project_parts_text`: join part texts with a blank line, then bound the joined text with the existing window. | +| `src/fetch/snapshot/mod.rs` | Project `document.blocks` when present, else `document.parts` when present, else fall back to `response.text`; return `snapshot_content_unavailable` when none carries text. | +| `src/meta/engines/startpage.rs` | Declare the Anubis selectors as `CHALLENGE_MARKERS` and use only those in `is_challenge_page`; add `Startpage Blocked` to the classified block markers. | +| `tests/fixtures/engines/startpage/blocked-search.html` | New synthetic fixture carrying the observed `Startpage Blocked` title; `blocked.html` is retained unchanged. | +| `src/mcp/tasks.rs` | Stop seeding a status message; a task reports the message an operation publishes, and nothing otherwise. | +| `src/mcp/server.rs` | Spawn call sites drop the seeded message. | + +No CLI, configuration, packaging, provider, or dependency change is expected. + +## Work packages + +### WP1 — Container-document snapshot comparison (M) + +Add `project_parts_text(parts, window_chars)` to `src/fetch/projection.rs`: return +`("", false)` for no parts, otherwise join `part.text` with `"\n\n"` — the same join +`client.rs` uses for the legacy `text` field — and bound the result with `bound_text`. + +In `compare_response`, keep the truncation guard, then select the projection source in +order: non-empty `blocks` → `project_document_text`; non-empty `parts` → +`project_parts_text`; otherwise `response.text`. Return +`snapshot_content_limit_exceeded` when the chosen projection reports a cut, and +`snapshot_content_unavailable` when there is no text at all. + +Tests: + +- `projection` unit tests: parts join with a blank line, a window cut reports + `truncated`, and an empty part list projects to empty text with no cut. +- `tests/snapshot_change.rs`, `#[cfg(feature = "documents")]`: an httpmock server serving + `text/csv` returns `new`, the unchanged body returns `same`, and an appended row + returns `changed` with `chars_added > 0` and one hunk; the stored row must not be empty. + +Acceptance: a container-document change is never reported as `same`; HTML, PDF, and +markdown snapshots keep their current classification; a metadata-only fetch reports +`snapshot_content_unavailable` instead of storing an empty baseline. + +### WP2 — Startpage block classification (S) + +Add `PageMarker::Text("Startpage Blocked")` to `SHAPE.blocked_markers` and keep the +existing three markers. Declare +`const CHALLENGE_MARKERS: &[PageMarker] = &[PageMarker::Selector("#anubis_challenge"), PageMarker::Selector("#anubis_version")]` and +make `is_challenge_page` consult only those, so a generic block page is classified by +`parse` → `finalize_scrape` instead of entering the solver. + +Tests: + +- `tests/engine_parse_conformance.rs`: a second Startpage block fixture + (`blocked-search.html`) must yield `EngineError::Blocked` with the `startpage` id. +- `startpage_tests.rs`: the block page is not a challenge page, while the existing Anubis + fixture still is. +- `tests/fixtures/engines/README.md`: record the fixture as a synthetic reconstruction — + the title was observed live, the body was not captured — and add the marker to the + marker table. + +Acceptance: the observed block page reports `blocked` with or without challenge solving +enabled; every Anubis solve path and its fixtures behave as before; the seeded-drift +control still yields `parse_error`. + +### WP3 — Terminal task status message (S) + +Remove the seeded `status_message` from `TaskRuntime::options` and `spawn`; the two +`server.rs` call sites and the task tests stop passing `"working"`. A task now reports no +status message unless an operation publishes one through +`TaskContext::set_status_message`, so a terminal task never advertises a working state. + +Tests, in `src/mcp/tasks.rs`: + +- A task that completes reports `Completed` and no status message. +- A cancelled task reports `Cancelled` and no status message. +- A task that publishes a phase message keeps that message while working. + +Acceptance: no terminal task reports `"working"`; task creation, polling, cancellation, +capacity, and eligibility behavior are unchanged. + +## Ordering and dependencies + +1. WP1 — projection helper, then the selector, then the regression test. +2. WP2 — challenge-marker split first, then the block marker and fixture. +3. WP3 — signature change and call sites together, then the assertions. + +Dependencies: hard — none. Interface — M003's closed snapshot contract, M049's closed +block-classification contract, and M009's task surface. M007/M008 closure records are not +amended. + +## Verification + +Focused, on the candidate: + +```bash +RUSTUP_TOOLCHAIN=1.89.0 cargo fmt --all +RUSTUP_TOOLCHAIN=1.89.0 cargo test --locked --features mock --test snapshot_change +RUSTUP_TOOLCHAIN=1.89.0 cargo test --locked --features mock --test engine_parse_conformance +RUSTUP_TOOLCHAIN=1.89.0 cargo test --locked --all-features --lib 'meta::engines::startpage' +RUSTUP_TOOLCHAIN=1.89.0 cargo test --locked --all-features --lib 'mcp::tasks' +RUSTUP_TOOLCHAIN=1.89.0 cargo test --locked --all-features --lib 'fetch::projection' +``` + +Canonical gates: + +```bash +RUSTUP_TOOLCHAIN=1.89.0 make check +python3 packaging/check-planning-consistency.py +git diff --check +``` + +Supplemental only: a live re-probe of the three seams after the gate. Do not make network +access a CI requirement; if a probe cannot reproduce its shape, record it as unverified. + +## Compatibility and migration + +- A stored empty snapshot row is not rewritten. The next fetch of that URL stores real text + and reports `changed` once, because the previous baseline was empty. +- A Startpage block page reports `blocked` instead of `upstream_failed`; no caller-visible + error code changes beyond that correction. +- `tasks/get` no longer returns `statusMessage: "working"` for a task the server did not + message. Hosts that read the field must treat it as optional, which the schema already + declares. + +## Acceptance criteria + +- A container-document change is reported as `new` → `same` → `changed` with non-zero + character counts and a hunk, and the store row holds the document text. +- `project_document_text` remains the blocks path; PDFs and HTML keep their classification. +- The observed Startpage block page yields `EngineError::Blocked` with challenge solving + enabled and disabled, and `is_challenge_page` stays true only for Anubis pages. +- A completed and a cancelled task each report no `"working"` status message. +- `make check` and planning consistency pass on the candidate. +- A closure record at + `plans/closure/agentic-retrieval-integrity/058-status.md` records the candidate SHA, + requirement-to-evidence mapping, tests and gates, deviations, and residual risks. + +## Stop conditions and non-goals + +Stop and register a separate decision if a repair requires a new warning code, error kind, +tool, alias, argument, response field, provider, or default-set change, or a schema +description change that re-pins the advertised fingerprint. + +Do not reopen M003, M009, or M049; do not re-capture the whole engine fixture set; do not +redesign the snapshot key, the diff algorithm, or the task manager; do not add a progress +reporting system for deferred tasks; and do not treat the empty-baseline rows already in an +operator's store as data to migrate. diff --git a/plans/registry.md b/plans/registry.md index 1d2036b3..7b98b229 100644 --- a/plans/registry.md +++ b/plans/registry.md @@ -27,7 +27,7 @@ Closed or superseded implementation plans are archived under | Repository security, supply-chain, and maintenance hardening | active; M001, M002, M003, M004, M005, M007, M008, M009, M010, and M011 closed; M006 superseded by ADR-0014 | `plans/subsystems/repository-hardening-roadmap.md` | M007: `plans/archive/implementation/repository-hardening/007-corrective-closure-evidence-and-process-ratchet.md` (closed by M010); M011 closure: `plans/closure/repository-hardening/011-status.md`; chromiumoxide `reqwest` edge accepted and guard-bounded. | | Python PyPI distribution and prebuilt SBC wheels | active; M001–M003, M005, and M006 closed; M004 blocked; M007 closed | `plans/subsystems/python-pypi-distribution-roadmap.md` | M004 awaits physical ARMv7 evidence; M005 closure: `plans/closure/python-pypi-distribution/005-status.md`; M006 closure: `plans/closure/python-pypi-distribution/006-status.md` on `fedf82c67a6d331fa1fab127b4ad5376cd27a84c`; M007 typed-surface parity corrective: `plans/implementation/python-pypi-distribution/007-typed-surface-parity-correctives.md`. | | Retrieval quality evidence extension | closing (M007) | `plans/subsystems/retrieval-quality-evidence-extension-roadmap.md` | Local evidence is complete; hosted Linux, macOS, and Windows CI is required on the merged candidate. | -| Agentic retrieval integrity and context economy | active; M001–M048 closed; M049 active; M050–M052 closed; M053 ready; M054 active (partial); M055 active (partial); M056 closed; M057 closed | `plans/subsystems/agentic-retrieval-integrity-roadmap.md` | M049: `plans/implementation/agentic-retrieval-integrity/049-non-success-block-classification.md` (canonical gate outstanding); M050 closure: `plans/closure/agentic-retrieval-integrity/050-status.md` on `79ea653a124916de696637adda8ed95798153715`; M051 closure: `plans/closure/agentic-retrieval-integrity/051-status.md` on the working tree applied to `8fe39cd`; M047/M048 remain closed with their closure records. M052 closure: `plans/closure/agentic-retrieval-integrity/052-status.md` on commit `02c4163`; M053 ready corrective plan: `plans/implementation/agentic-retrieval-integrity/053-executable-follow-up-pointer-binding-correctives.md`; M054 active corrective plan from the 2026-11-26 live trial: `plans/implementation/agentic-retrieval-integrity/054-agent-facing-payload-economy-correctives.md`; M055 active corrective plan for extraction completeness and render-path status: `plans/implementation/agentic-retrieval-integrity/055-fetch-extraction-completeness-correctives.md`; M056 closed corrective plan for live-surface diagnostic honesty from the 2026-11-27 live trial: `plans/implementation/agentic-retrieval-integrity/056-live-surface-diagnostic-honesty-correctives.md`; closure: `plans/closure/agentic-retrieval-integrity/056-status.md`; M057 closed corrective plan from the M056 post-closure audit: `plans/implementation/agentic-retrieval-integrity/057-m056-audit-follow-up-correctives.md`; closure: `plans/closure/agentic-retrieval-integrity/057-status.md`. | +| Agentic retrieval integrity and context economy | active; M001–M048 closed; M049 active; M050–M052 closed; M053 ready; M054 active (partial); M055 active (partial); M056 closed; M057 closed; M058 active | `plans/subsystems/agentic-retrieval-integrity-roadmap.md` | M049: `plans/implementation/agentic-retrieval-integrity/049-non-success-block-classification.md` (canonical gate outstanding); M050 closure: `plans/closure/agentic-retrieval-integrity/050-status.md` on `79ea653a124916de696637adda8ed95798153715`; M051 closure: `plans/closure/agentic-retrieval-integrity/051-status.md` on the working tree applied to `8fe39cd`; M047/M048 remain closed with their closure records. M052 closure: `plans/closure/agentic-retrieval-integrity/052-status.md` on commit `02c4163`; M053 ready corrective plan: `plans/implementation/agentic-retrieval-integrity/053-executable-follow-up-pointer-binding-correctives.md`; M054 active corrective plan from the 2026-11-26 live trial: `plans/implementation/agentic-retrieval-integrity/054-agent-facing-payload-economy-correctives.md`; M055 active corrective plan for extraction completeness and render-path status: `plans/implementation/agentic-retrieval-integrity/055-fetch-extraction-completeness-correctives.md`; M056 closed corrective plan for live-surface diagnostic honesty from the 2026-11-27 live trial: `plans/implementation/agentic-retrieval-integrity/056-live-surface-diagnostic-honesty-correctives.md`; closure: `plans/closure/agentic-retrieval-integrity/056-status.md`; M057 closed corrective plan from the M056 post-closure audit: `plans/implementation/agentic-retrieval-integrity/057-m056-audit-follow-up-correctives.md`; closure: `plans/closure/agentic-retrieval-integrity/057-status.md`; M058 active corrective plan from the 2026-11-30 live sweep: `plans/implementation/agentic-retrieval-integrity/058-live-sweep-defect-correctives.md`. | | PDF ingestion and extraction fidelity | closing | `plans/subsystems/pdf-ingestion-fidelity-roadmap.md` | M001/M002/M007 are implemented with closure records; M006 qualification remains open; M008 is active by user approval against the existing M001 implementation, with M001 exact-candidate status reconciliation still open; M003–M005 are ready. | | Adaptive fetch target routing and artifacts | active (M001 active; M002 and M003 closed) | `plans/subsystems/adaptive-fetch-routing-roadmap.md` | M002 closed on `24f045729f8409dadc96b4c2455253d8a9c7b6ec`; see `plans/closure/adaptive-fetch-routing/002-status.md`. M001's implementation remains committed on that candidate but its closure record is outstanding. M003 closed on candidate `59ff64ad00940573ee520ecf19d7b5c0abcb1c87`; see `plans/closure/adaptive-fetch-routing/003-status.md`. Local PDF behavior remains owned by PDF M008. | | Knowledge-delta research | active; M001–M007 closed | `plans/subsystems/knowledge-delta-roadmap.md` | Closure evidence is linked from the roadmap. | @@ -49,6 +49,7 @@ Closed or superseded implementation plans are archived under | Agentic retrieval integrity | M055 fetch extraction completeness and render-path status correctives | active | `plans/implementation/agentic-retrieval-integrity/055-fetch-extraction-completeness-correctives.md` | Trial-found P1: the HTML extractor emits only block-level content, so body copy rendered in `div`/`span` disappears silently (`quotes.toscrape.com` has 10 quote blocks in its HTML and returns 115 chars); `include_selectors` reports matches and returns nothing for `.card`, `li`, and `a` roots; browser transport returns an HTTP 404 page as a successful fetch. Five bounded packages. No tool, alias, argument, provider, or default-provider-set change. | | Agentic retrieval integrity | M056 live-surface diagnostic honesty and keyless-tier degradation correctives | closed | `plans/implementation/agentic-retrieval-integrity/056-live-surface-diagnostic-honesty-correctives.md` | Trial-found P2/P3: bare-`cutoff` strings drop silently on `knowledge_brief`; resolved cutoffs with zero timestamp-capable providers warn nothing; `transport` field misreads as escalation state; reserved `.invalid` hostnames report as policy blocks; keyless degradation has no runbook. Five bounded packages plus trial-hygiene note. No tool, alias, provider, default-set, or trust-framing change; WP1 took option B (targeted near-miss scan), fingerprint unchanged. | | Agentic retrieval integrity | M057 M056 audit follow-up correctives | closed | `plans/implementation/agentic-retrieval-integrity/057-m056-audit-follow-up-correctives.md` | Post-closure audit of M056 at `99b2532`: browser interception never applies the reserved-hostname classifier, trailing-dot FQDNs bypass every hostname predicate, the redirect wrapper re-adds the `private network: ` prefix, a present-but-null `cutoff` still rejects, and two documentation fragments do not resolve. Five bounded packages with one shared classifier, an explicit null-is-absent rule, and a fragment-only Markdown guard; no fingerprint re-pin, no new `FetchErrorKind`, no tool/alias/provider/default-set/trust-framing change. | +| Agentic retrieval integrity | M058 live sweep defect correctives | active | `plans/implementation/agentic-retrieval-integrity/058-live-sweep-defect-correctives.md` | The 2026-11-30 live sweep of all twelve callable names found three silent wrong answers: container-document snapshots report `same` for changed content (the projection reads an empty block list while `parts` carry the text), Startpage's block page reports as a `parse_error` instead of `blocked`, and a completed deferred task keeps `statusMessage: "working"`. Three bounded packages; no tool, alias, argument, provider, default-set, or advertised-schema change expected. | | Retrieval quality evidence extension | M007 expanded live and consumer acceptance | active | `plans/implementation/retrieval-quality-evidence-extension/001-expanded-live-and-consumer-acceptance.md` | No M006 amendment or production behavior change. | | Retrieval quality evidence extension | M007 cross-domain, extraction, and resource qualification | closing | `plans/implementation/retrieval-quality-evidence-extension/002-cross-domain-extraction-and-resource-qualification.md` | Hosted Linux, macOS, and Windows CI remains. | | PDF ingestion | M001 PDF fetch contract and budgets | closing | `plans/implementation/pdf-ingestion-fidelity/001-pdf-fetch-contract-and-budgets.md` | Closure record is present. | diff --git a/plans/subsystems/agentic-retrieval-integrity-roadmap.md b/plans/subsystems/agentic-retrieval-integrity-roadmap.md index 874d244e..8ccb5c4b 100644 --- a/plans/subsystems/agentic-retrieval-integrity-roadmap.md +++ b/plans/subsystems/agentic-retrieval-integrity-roadmap.md @@ -210,6 +210,7 @@ ADR-0011 fetch document addressing ──> M019 fetch document budget ──> M0 | M055 — fetch extraction completeness and render-path status correctives | invariant (corrective program) | `plans/implementation/agentic-retrieval-integrity/055-fetch-extraction-completeness-correctives.md` | interface M054 (proposed); interface M039 (closed); interface M042 (closed) | A deterministic fixture and live pages show that extraction keeps only block-level content, so `div`/`span` body copy is dropped silently (`quotes.toscrape.com`: 10 quote blocks, 115 returned chars); `include_selectors` matched 25 anchors on `lobste.rs` and returned 0 chars; and browser transport returns a 404 page as `ok: true`. Five bounded packages; no tool, argument, provider, or default-set change | | M056 — live-surface diagnostic honesty and keyless-tier degradation correctives | invariant (corrective program) | `plans/implementation/agentic-retrieval-integrity/056-live-surface-diagnostic-honesty-correctives.md` | interface M051 (closed); interface M054 (active); interface M055 (active) | Closed: a bare `cutoff` string becomes a repair hint, a resolved cutoff with zero timestamp-capable providers warns, the `transport` field stops reading as escalation state, reserved `.invalid`/`.test`/`.localhost` names fail closed with a distinct message, and keyless degradation has a runbook. Five bounded packages; no tool, alias, provider, default-set, or trust-framing change; WP1 took option B. Closure: `plans/closure/agentic-retrieval-integrity/056-status.md`. | | M057 — M056 audit follow-up correctives | invariant (corrective to M056) | `plans/implementation/agentic-retrieval-integrity/057-m056-audit-follow-up-correctives.md` | interface M056 (closed) | The post-closure audit of M056 at `99b2532` found five defects: browser interception never applies the reserved-hostname classifier, trailing-dot FQDNs bypass every hostname predicate in both paths, the redirect wrapper re-adds the `private network: ` prefix, a present-but-null `cutoff` still rejects, and two in-repository documentation fragments do not resolve. Five bounded packages with one shared classifier, an explicit null-is-absent rule, and a fragment-only Markdown guard; no fingerprint re-pin, no new `FetchErrorKind`, no tool/alias/provider/default-set/trust-framing change | +| M058 — live sweep defect correctives | invariant (corrective program) | `plans/implementation/agentic-retrieval-integrity/058-live-sweep-defect-correctives.md` | interface M003 (closed); interface M009 (closed); interface M049 (closed) | The 2026-11-30 live sweep of all twelve callable names found three silent wrong answers: a container document always compares as `same` because the snapshot projects an empty block list, a Startpage block page classifies as a structural parse failure, and a completed deferred task keeps `statusMessage: "working"`. Three bounded packages; no tool, alias, argument, provider, default-set, or advertised-schema change | M001–M005 are closed at `c9912fc0e4824c4ec6b1231be2057fb4cd0ba8ab` (baseline `cd81f4d`). Each closure record in `plans/closure/agentic-retrieval-integrity/` records the implementation evidence, and the closure diff --git a/src/fetch/projection.rs b/src/fetch/projection.rs index ee46ddce..acf5a911 100644 --- a/src/fetch/projection.rs +++ b/src/fetch/projection.rs @@ -1,4 +1,4 @@ -use crate::core::document::RenderedBlock; +use crate::core::document::{DocumentPart, RenderedBlock}; use crate::core::sanitize::bound_text; use crate::fetch::render; @@ -21,10 +21,33 @@ pub(crate) fn project_document_text( (bounded, block_cut || text_cut) } +pub(crate) fn project_parts_text(parts: &[DocumentPart], window_chars: usize) -> (String, bool) { + if parts.is_empty() { + return (String::new(), false); + } + let joined = parts + .iter() + .map(|part| part.text.as_str()) + .collect::>() + .join("\n\n"); + bound_text(&joined, window_chars) +} + #[cfg(test)] mod tests { - use super::project_document_text; - use crate::core::document::{BlockKind, RenderedBlock}; + use super::{project_document_text, project_parts_text}; + use crate::core::document::{BlockKind, DocumentPart, DocumentPartKind, RenderedBlock}; + + fn part(text: &str) -> DocumentPart { + DocumentPart { + index: 1, + kind: DocumentPartKind::Section, + title: None, + text: text.to_string(), + chars: text.chars().count(), + truncated: false, + } + } fn block(text: &str, kind: BlockKind) -> RenderedBlock { RenderedBlock { @@ -68,6 +91,29 @@ mod tests { assert!(!cut); } + #[test] + fn container_parts_project_with_a_blank_line_between_parts() { + let parts = vec![part("name,qty\nwidget,2"), part("gadget,5")]; + let (text, cut) = project_parts_text(&parts, 200); + assert_eq!(text, "name,qty\nwidget,2\n\ngadget,5"); + assert!(!cut); + } + + #[test] + fn a_window_that_cuts_a_container_document_reports_truncation() { + let parts = vec![part(&"a".repeat(60)), part(&"b".repeat(60))]; + let (text, cut) = project_parts_text(&parts, 80); + assert_eq!(text, format!("{}\n\n{}…", "a".repeat(60), "b".repeat(17))); + assert!(cut); + } + + #[test] + fn an_empty_part_list_projects_to_empty_text() { + let (text, cut) = project_parts_text(&[], 10); + assert!(text.is_empty()); + assert!(!cut); + } + #[test] fn the_projection_does_not_mutate_its_input() { let blocks = vec![ diff --git a/src/fetch/snapshot/mod.rs b/src/fetch/snapshot/mod.rs index 4ca189af..7b120298 100644 --- a/src/fetch/snapshot/mod.rs +++ b/src/fetch/snapshot/mod.rs @@ -53,15 +53,31 @@ pub(crate) async fn compare_response( if document.document_truncated || document.block_truncated { return SnapshotOutcome::warning("snapshot_content_limit_exceeded"); } - let (text, truncated) = crate::fetch::projection::project_document_text( - &document.blocks, - response.raw_text_cap.unwrap_or(1_048_576), - document.text_format == "markdown", - ); - if truncated { - return SnapshotOutcome::warning("snapshot_content_limit_exceeded"); + let window_chars = response.raw_text_cap.unwrap_or(1_048_576); + let projected = if !document.blocks.is_empty() { + Some(crate::fetch::projection::project_document_text( + &document.blocks, + window_chars, + document.text_format == "markdown", + )) + } else if !document.parts.is_empty() { + Some(crate::fetch::projection::project_parts_text( + &document.parts, + window_chars, + )) + } else { + None + }; + match projected { + Some((_, true)) => { + return SnapshotOutcome::warning("snapshot_content_limit_exceeded"); + } + Some((text, false)) => text, + None => match response.text.as_deref() { + Some(text) => text.to_string(), + None => return SnapshotOutcome::warning("snapshot_content_unavailable"), + }, } - text } else if let Some(text) = response.text.as_deref() { text.to_string() } else { diff --git a/src/mcp/server.rs b/src/mcp/server.rs index 6eccd91a..c094fd2f 100644 --- a/src/mcp/server.rs +++ b/src/mcp/server.rs @@ -182,7 +182,7 @@ impl EggsearchServer { let preset = self.tool_preset; let state = self.state.clone(); let runtime = runtime.clone(); - Some(runtime.spawn("working", move |context| { + Some(runtime.spawn(move |context| { Box::pin(async move { let work = async move { match build(state).await { @@ -907,7 +907,7 @@ mod tests { } fn blocked_task(runtime: &TaskRuntime) -> rmcp::model::CreateTaskResult { - runtime.spawn("working", |context| { + runtime.spawn(|context| { Box::pin(async move { crate::mcp::tasks::run_cancellable(Some(context), async { std::future::pending::>().await diff --git a/src/mcp/tasks.rs b/src/mcp/tasks.rs index eca9cb86..708d5aea 100644 --- a/src/mcp/tasks.rs +++ b/src/mcp/tasks.rs @@ -62,18 +62,17 @@ impl TaskRuntime { self.manager.running_task_count() >= self.max_concurrent } - pub fn options(&self, status_message: &str) -> TaskOptions { + pub fn options(&self) -> TaskOptions { TaskOptions::new() .with_ttl_ms(self.ttl_ms) .with_poll_interval_ms(self.poll_interval_ms) - .with_status_message(status_message.to_string()) } - pub fn spawn(&self, status_message: &str, operation: F) -> CreateTaskResult + pub fn spawn(&self, operation: F) -> CreateTaskResult where F: FnOnce(TaskContext) -> TaskFuture + Send + 'static, { - let task = self.manager.spawn(self.options(status_message), operation); + let task = self.manager.spawn(self.options(), operation); CreateTaskResult::new(task) } @@ -184,9 +183,9 @@ mod tests { } #[tokio::test] - async fn spawn_returns_a_task_handle_and_completes() { + async fn spawn_returns_a_task_handle_that_completes_without_a_message() { let runtime = enabled_runtime(2); - let created = runtime.spawn("working", |context| { + let created = runtime.spawn(|context| { Box::pin(async move { run_cancellable(Some(context), async { Ok(rmcp::model::CallToolResult::structured( @@ -199,6 +198,12 @@ mod tests { let task_id = created.task.task_id.clone(); for _ in 0..100 { if settled(&runtime, &task_id) == Some(rmcp::model::TaskStatus::Completed) { + let detailed = runtime.manager().get_task(&task_id).expect("task"); + assert!( + detailed.task.status_message.is_none(), + "completed task kept {:?}", + detailed.task.status_message + ); return; } tokio::time::sleep(std::time::Duration::from_millis(10)).await; @@ -209,7 +214,7 @@ mod tests { #[tokio::test] async fn cancel_settles_as_cancelled() { let runtime = enabled_runtime(2); - let created = runtime.spawn("working", |context| { + let created = runtime.spawn(|context| { Box::pin(async move { run_cancellable(Some(context), async { std::future::pending::>().await @@ -224,6 +229,12 @@ mod tests { .expect("cancel accepted"); for _ in 0..100 { if settled(&runtime, &task_id) == Some(rmcp::model::TaskStatus::Cancelled) { + let detailed = runtime.manager().get_task(&task_id).expect("task"); + assert!( + detailed.task.status_message.is_none(), + "cancelled task kept {:?}", + detailed.task.status_message + ); return; } tokio::time::sleep(std::time::Duration::from_millis(10)).await; @@ -231,10 +242,47 @@ mod tests { panic!("task did not settle as cancelled"); } + #[tokio::test] + async fn a_published_phase_message_is_visible_while_working() { + let runtime = enabled_runtime(2); + let (release, wait) = tokio::sync::oneshot::channel::<()>(); + let created = runtime.spawn(|context| { + Box::pin(async move { + context.set_status_message("fetching 9 items"); + run_cancellable(Some(context), async move { + let _ = wait.await; + Ok(rmcp::model::CallToolResult::structured( + serde_json::json!({"ok": true}), + )) + }) + .await + }) + }); + let task_id = created.task.task_id.clone(); + let mut observed: Option = None; + for _ in 0..100 { + let detailed = runtime.manager().get_task(&task_id).expect("task"); + observed = detailed.task.status_message.clone(); + if observed.as_deref() == Some("fetching 9 items") { + break; + } + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + } + assert_eq!(observed.as_deref(), Some("fetching 9 items")); + let _ = release.send(()); + for _ in 0..100 { + if settled(&runtime, &task_id) == Some(rmcp::model::TaskStatus::Completed) { + return; + } + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + } + panic!("task did not settle as completed"); + } + #[tokio::test] async fn saturation_reports_capacity_without_error() { let runtime = enabled_runtime(1); - let _created = runtime.spawn("working", |context| { + let _created = runtime.spawn(|context| { Box::pin(async move { run_cancellable(Some(context), async { std::future::pending::>().await diff --git a/src/meta/engines/startpage.rs b/src/meta/engines/startpage.rs index ea49a6a6..f94df977 100644 --- a/src/meta/engines/startpage.rs +++ b/src/meta/engines/startpage.rs @@ -26,11 +26,17 @@ const SHAPE: ScrapeShape = ScrapeShape { ], blocked_markers: &[ PageMarker::Text("Access Denied - Startpage"), + PageMarker::Text("Startpage Blocked"), PageMarker::Selector("#anubis_challenge"), PageMarker::Selector("#anubis_version"), ], }; +const CHALLENGE_MARKERS: &[PageMarker] = &[ + PageMarker::Selector("#anubis_challenge"), + PageMarker::Selector("#anubis_version"), +]; + struct SearchResponse { body: String, cookies: String, @@ -189,7 +195,7 @@ fn endpoint(base_url: &str, path: &str) -> String { fn is_challenge_page(html: &str) -> Result { let document = Html::parse_document(html); let mut rendered: Option = None; - for marker in SHAPE.blocked_markers { + for marker in CHALLENGE_MARKERS { if super::marker_matches(ENGINE, *marker, &document, &mut rendered)? { return Ok(true); } diff --git a/src/meta/engines/startpage_tests.rs b/src/meta/engines/startpage_tests.rs index 28ff5cc8..6e9b5864 100644 --- a/src/meta/engines/startpage_tests.rs +++ b/src/meta/engines/startpage_tests.rs @@ -98,6 +98,34 @@ fn anubis_challenge_page_is_blocked() { ); } +#[test] +fn a_search_block_page_is_blocked_and_not_a_challenge_page() { + let html = r#"Startpage Blocked

Startpage Blocked

"#; + assert!( + !is_challenge_page(html).expect("classification"), + "a block page must not start a challenge solve" + ); + let err = parse(html, 10).expect_err("a block page must not parse as empty"); + assert!( + matches!( + err, + EngineError::Blocked { + engine: "startpage", + .. + } + ), + "unexpected error: {err:?}" + ); +} + +#[test] +fn an_anubis_page_still_starts_a_challenge_solve() { + assert!( + is_challenge_page(CHALLENGE_PAGE).expect("classification"), + "the Anubis proof-of-work page must remain a challenge page" + ); +} + static CHALLENGE_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(()); const CHALLENGE_PAGE: &str = r#"
"#; diff --git a/tests/engine_parse_conformance.rs b/tests/engine_parse_conformance.rs index e93daf30..43191d7b 100644 --- a/tests/engine_parse_conformance.rs +++ b/tests/engine_parse_conformance.rs @@ -148,6 +148,23 @@ fn blocked_fixture_reports_blocked() { } } +#[test] +fn startpage_search_block_is_classified_blocked() { + let html = fixture("startpage", "blocked-search.html"); + let error = + parse_html("startpage", &html, 10).expect_err("a block page must not parse as empty"); + match error { + EngineError::Blocked { engine, reason } => { + assert_eq!(engine, "startpage", "blocked engine id"); + assert!( + reason.contains("Startpage Blocked"), + "blocked reason must name the marker, got: {reason}" + ); + } + other => panic!("startpage blocked-search.html must yield Blocked, got: {other:?}"), + } +} + #[test] fn seeded_drift_reports_parse_failed() { for case in &CASES { diff --git a/tests/fixtures/engines/README.md b/tests/fixtures/engines/README.md index b7c0047c..86fdc2c0 100644 --- a/tests/fixtures/engines/README.md +++ b/tests/fixtures/engines/README.md @@ -37,6 +37,7 @@ a synthetic reconstruction. | `startpage` | `results.html` | **Live-captured** | `GET https://www.startpage.com/search?q=rust+programming+language` with a solved Anubis `spchal-auth` cookie, HTTP 200, 251,915 bytes, 2026-11-11 22:56 UTC, difficulty 6; payload reduced to `render.presenter.regions.mainline` and trimmed to the two `web-google` result blocks | | `startpage` | `empty.html` | Synthetic reconstruction | No live empty SERP was observable: every query, including a nonsense string, returned ten fuzzy `web-google` results. The file reproduces the captured payload shape with an empty `web-google` region plus the documented `div.no-results` marker | | `startpage` | `blocked.html` | **Live-captured** | `GET https://www.startpage.com/search?q=...` → HTTP 302 → `https://cdn.startpage.com/sp/cdn/error-pages/blocked.html`, HTTP 200, 38,957 bytes; trimmed to the page shell and title | +| `startpage` | `blocked-search.html` | Synthetic reconstruction | The 2026-11-30 live sweep recorded `title=Startpage Blocked digest=a04b95062ac56f00` from a `provider_status` probe. The body was not captured, so the file reproduces the observed title and a minimal block-page shell; the recorded body digest cannot be reproduced from it | | `yahoo` | `results.html` | Synthetic reconstruction | `GET https://search.yahoo.com/search?p=...` returned HTTP 500 with an empty body from the edge (ATS) for every query and header set | | `yahoo` | `empty.html` | Synthetic reconstruction | Same HTTP 500 edge block | | `yahoo` | `blocked.html` | Synthetic reconstruction | The edge returned an empty 500, not a renderable page; minimal reconstruction of the Yahoo consent wall | @@ -127,9 +128,16 @@ in live pages cannot masquerade as an empty state. | `brave` | `div[data-type='web']` | `#bad-results-info-banner`, `div.fallback-snippet`, text `Not many great matches came back for your search` | text `Please verify you are a human` (synthetic) | | `duckduckgo` | `div.result` | `div.no-results` (synthetic), text `No results.` (synthetic) | `#challenge-form`, `div.anomaly-modal`, text `Unfortunately, bots use DuckDuckGo too.` (live) | | `mojeek` | `ul.results-standard, ol.results-standard` | `div.no-results` (synthetic), text `No pages found` (synthetic) | `div.captcha-wrap`, text `JavaScript is required to complete this challenge`, text `your network appears to be sending automated queries` (live) | -| `startpage` | `div.result` (payload-first: `React.createElement(UIStartpage.AppSerpWeb, …)` → `render.presenter.regions.mainline[]`, `display_type` prefix `web`) | `div.no-results` (synthetic), text `No search results were found`, text `No results found for` (synthetic) | text `Access Denied - Startpage` (live), `#anubis_challenge`, `#anubis_version` (live, 2026-11-11) | +| `startpage` | `div.result` (payload-first: `React.createElement(UIStartpage.AppSerpWeb, …)` → `render.presenter.regions.mainline[]`, `display_type` prefix `web`) | `div.no-results` (synthetic), text `No search results were found`, text `No results found for` (synthetic) | text `Access Denied - Startpage` (live), text `Startpage Blocked` (live title, 2026-11-30), `#anubis_challenge`, `#anubis_version` (live, 2026-11-11) | | `yahoo` | `div.algo-sr` | text `We did not find results for` (synthetic) | text `Before you continue to Yahoo` (synthetic) | +Startpage's block classification covers two distinct pages: the captured CDN error page +(`Access Denied - Startpage`) and the page this egress receives for a search request +(`Startpage Blocked`, observed as a `provider_status` title and body digest on 2026-11-30). +Only the CDN page is a capture; the search-block page is a title-faithful reconstruction. +The Anubis selectors are the only markers that start a challenge solve; the two text markers +are classification-only, so a generic block page never enters the solver. + The Brave empty markers are the only empty-state markers derived from live-rendered markup; the DuckDuckGo, Mojeek, and Startpage blocked markers are also live-derived. All remaining markers are synthetic: they use the provider's documented wording or diff --git a/tests/fixtures/engines/startpage/blocked-search.html b/tests/fixtures/engines/startpage/blocked-search.html new file mode 100644 index 00000000..dfdb1b6f --- /dev/null +++ b/tests/fixtures/engines/startpage/blocked-search.html @@ -0,0 +1,18 @@ + + + + + +Startpage Blocked + + +
+ +

Startpage Blocked

+

Your request could not be processed because it appears to come from an automated client.

+

Please try again later.

+
+ + diff --git a/tests/snapshot_change.rs b/tests/snapshot_change.rs index ab2f683d..07e059e0 100644 --- a/tests/snapshot_change.rs +++ b/tests/snapshot_change.rs @@ -1,7 +1,9 @@ use std::sync::Arc; use eggsearch::core::config::AppConfig; -use eggsearch::core::fetch::{FetchCachePolicy, FetchSnapshotRequest, SnapshotCompare}; +use eggsearch::core::fetch::{ + ExtractMode, FetchCachePolicy, FetchSnapshotRequest, SnapshotCompare, +}; use eggsearch::mcp::projection::ResponseDetail; use eggsearch::mcp::state::ServerState; use eggsearch::mcp::tools::{run_web_fetch, WebFetchArgs}; @@ -119,6 +121,79 @@ async fn compares_extracted_content_and_never_stores_html() { assert!(!stored.contains("RAW_HTML_SECRET")); } +#[cfg(feature = "documents")] +#[tokio::test] +async fn container_document_changes_are_never_reported_as_same() { + let server = MockServer::start(); + let mut original = server.mock(|when, then| { + when.method(GET).path("/rows.csv"); + then.status(200) + .header("content-type", "text/csv; charset=utf-8") + .body("name,qty\nwidget,2\n"); + }); + let directory = tempfile::tempdir().unwrap(); + let path = directory.path().join("private").join("snapshots.sqlite3"); + let state = snapshot_state(path.clone(), true); + let url = server.url("/rows.csv"); + + let first = compare(state.clone(), url.clone()).await; + assert_eq!(first["change"]["status"], "new"); + + let same = compare(state.clone(), url.clone()).await; + assert_eq!(same["change"]["status"], "same"); + + original.delete(); + server.mock(|when, then| { + when.method(GET).path("/rows.csv"); + then.status(200) + .header("content-type", "text/csv; charset=utf-8") + .body("name,qty\nwidget,2\ngadget,5\n"); + }); + let changed = compare(state, url).await; + assert_eq!(changed["change"]["status"], "changed"); + assert!(changed["change"]["chars_added"].as_u64().unwrap_or(0) > 0); + assert_eq!(changed["change"]["hunks"].as_array().unwrap().len(), 1); + + let connection = rusqlite::Connection::open(path).unwrap(); + let stored: String = connection + .query_row("SELECT text FROM snapshots", [], |row| row.get(0)) + .unwrap(); + assert!(stored.contains("gadget"), "stored: {stored:?}"); +} + +#[cfg(feature = "documents")] +#[tokio::test] +async fn a_metadata_only_container_document_never_stores_an_empty_baseline() { + let server = MockServer::start(); + server.mock(|when, then| { + when.method(GET).path("/rows.csv"); + then.status(200) + .header("content-type", "text/csv; charset=utf-8") + .body("name,qty\nwidget,2\n"); + }); + let directory = tempfile::tempdir().unwrap(); + let path = directory.path().join("private").join("snapshots.sqlite3"); + let state = snapshot_state(path.clone(), true); + + let response = run_web_fetch( + state, + WebFetchArgs { + url: server.url("/rows.csv"), + extract_mode: Some(ExtractMode::MetadataOnly), + snapshot: Some(FetchSnapshotRequest { + compare: SnapshotCompare::Line, + ..Default::default() + }), + ..Default::default() + }, + ) + .await + .expect("fetch succeeds"); + assert!(response.get("change").is_none()); + assert!(warning_text(&response).contains("snapshot_content_unavailable")); + assert!(!path.exists(), "no empty baseline may be stored"); +} + #[tokio::test] async fn disabled_store_warns_without_opening_a_file() { let server = MockServer::start();