# Reader guarantees

The reader uses Google's crawler. It does not contact the origin directly, execute page scripts, download files, extract PDFs, or reconstruct missing article text. A closed HTML document or a complete saved page does not prove full article coverage.

## Contract and regression checks

Run `yarn check` for the offline gate. The two reader scripts are included in TypeScript, ESLint, Prettier, and the default test chain.

| Guarantee                                                                                                                                                                                                                                                                                                                                                                                                                           | Regression check                                                                     | Owner                                     |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ----------------------------------------- |
| Unsafe caller URLs are rejected before credential lookup or progress. Search uses the same URL predicate, plus a best-effort DNS filter before contacting origins.                                                                                                                                                                                                                                                                  | `scenarioGuards`; foundations URL policy cases; search citations tests               | `utils/address.ts`                        |
| URL credentials and recognized credential carriers are redacted on rendered surfaces. Ordinary diagnostic values and JSON structure survive. Exact caller/service URL echoes in page content are redacted before the page is shown or saved. Arbitrary secrets in page text are not promised filtered.                                                                                                                              | `scenarioSecrets`; foundations redaction and JSON cases                              | `utils/security.ts`, `web-fetch.ts`       |
| Malformed credentials cannot appear in parser errors or retained causes.                                                                                                                                                                                                                                                                                                                                                            | Foundations credential cases                                                         | `client/client.ts`                        |
| Third-party text has valid UTF-16. Metadata is bounded and single-line; page bodies retain their line structure.                                                                                                                                                                                                                                                                                                                    | Foundations text, metadata, and body cases                                           | `utils/text.ts`                           |
| Relative redirects resolve normally. Explicit private, credential-bearing, or non-HTTP destinations fail closed. Only destinations reported by Google are visible; intermediate redirects and remote DNS are not independently checked.                                                                                                                                                                                             | `scenarioRedirects`; foundations URL policy                                          | `web-fetch.ts`                            |
| One shared ten-second network deadline and at most ten Google requests bound retrieval. Endpoint failover is transport-only. The caller's abort is respected.                                                                                                                                                                                                                                                                       | `scenarioAlternateOnSecondEndpoint`; deadline and abort cases                        | `web-fetch.ts`                            |
| Recovery retains a useful original when live or optional representation reads fail. At most one publisher representation URL is selected.                                                                                                                                                                                                                                                                                           | `scenarioRecovery`, `scenarioAlternate`, `scenarioPdf`                               | `web-fetch.ts`                            |
| HTML work is bounded before parsing: 2,000,000 characters, 50,000 markup tokens, 128 nested elements. Script strings and comments do not count as nested markup. Independent blocks avoid repeated prefix joins.                                                                                                                                                                                                                    | Foundations size, node, depth, script/comment, and many-block cases                  | `document.ts`, `markdown.ts`              |
| Inspection uses an owned DOM, substantive content regions, and body evidence for access-wall judgments. A heading alone does not prove a wall or a JavaScript shell.                                                                                                                                                                                                                                                                | Foundations inspection and real-page fixtures; `scenarioStatusArticle`               | `inspect.ts`, `markdown.ts`               |
| XML, SVG, Markdown, and text are not silently emptied as HTML. PDF refusal uses the reported media type, URL suffix, or line-start signature rather than prose mentioning a signature.                                                                                                                                                                                                                                              | Foundations media cases; `scenarioDetection`, `scenarioPdf`                          | `media.ts`, `markdown.ts`, `web-fetch.ts` |
| Source completeness, content assessment, and output truncation remain separate. Publisher metadata is labeled as publisher claims. Omitted publisher sections are noted.                                                                                                                                                                                                                                                            | `scenarioTruncatedCopy`; foundations MDN cases                                       | `inspect.ts`, `mdn.ts`, `web-fetch.ts`    |
| Returned text plus serialized details share the configured character cap. Provenance and the saved-page footer count too. Small budgets can omit older attempt details; the omission count is explicit and doctor retains the bounded full history.                                                                                                                                                                                 | `scenarioReadablePage`, `scenarioBudget`, `scenarioLongFence`; live smoke cap checks | Feature entrypoint and formatter          |
| A page that does not fit is saved whole to a private temp file named in the answer and in `details.fullOutputPath`. A budget too small to answer leaves no file behind, and a failed save is reported in the answer without losing the page. Pages beyond the conversion limits are refused with Google's unconverted HTML saved. Raw mode returns the crawled source whatever its size and saves it without the provenance header. | `scenarioReadablePage`, `scenarioBudgetFailure`, `scenarioUnconverted`               | `save.ts`, feature entrypoint             |
| Cut-off or unavailable Wikipedia articles and raw GitHub files recover only through a copy that names the requested article or file. Advertised, MDN, Wikipedia and GitHub copies share one representation contract.                                                                                                                                                                                                                | `scenarioWikipedia`, `scenarioGithubRaw`                                             | `sites.ts`, `web-fetch.ts`                |
| Successful degraded reads and failures leave sanitized diagnostics.                                                                                                                                                                                                                                                                                                                                                                 | Deadline/degraded diagnostics cases                                                  | Reader and `diagnostics/`                 |

Search caches expire after ten minutes and skip known secret-bearing keys or values. Client lookup caches use token digests rather than raw access tokens as keys.

The response stream is capped at 5,000,000 bytes. Limits are refusals, not claims that a page is complete.

## Live check

After `/login antigravity`, run `yarn smoke:fetch`. It exercises Example.com, GitHub Docs, and an old MDN URL, checks the complete output cap, and checks that a saved page can be read without network or credentials. Wrong page text is a failure. Explicit retrieval failures explaining a degraded copy and an unobserved canonical alias are warnings. Upstream availability warnings produce exit code 2; an alias-only warning does not. Exit code 2 means live coverage was insufficient; a passing offline gate does not replace this check.

The saved fixture data comes from the existing main-branch corpus. Its provenance is listed in `scripts/fixtures/web-fetch/README.md`. The branch's registered-tool suite remains the implementation contract; main's incompatible reader suite is not imported.
