Skip to main content

Crate fats

Crate fats 

Source
Expand description

fats: web pages and documents → small, clean, cached Markdown for AI agents. Module map (one crate for now): lang (argv + the only printer) · html (html5ever → node arena) · clean (prune, loss guard, doc; kind_of = what a body is) · text (text documents) · pdf (PDF text, page budget) · setup (the key menu and the local key form) · provider (plain, Bright Data, Oxylabs, Decodo) · fetch (router, content check) · outline (sections, reads) · search (filter ladder) · cache (ids, sessions, snapshots) · stats (status, stats, config, dry) · cli (dispatch) · mcp (fats mcp, one tool) · settings (every knob + source) · tables (generated data) · telemetry (notice, update check, weekly counts).

Modules§

cache
CACHE: root, session, ids, cursor, URL index, global jobs, page snapshots.
clean
CLEAN: tree → lines in three prune modes + loss guard → Doc (sections, links, info, loss, tokens). Links resolve with the WHATWG url crate.
cli
CLI: command → action → Out. Pages come from the cache, local files or the fetch router (fetch.rs); FATS_OFFLINE=1 keeps every command off the network.
fetch
FETCH: the router. auto = the ladder (Plan::ladder): plain first, then the keyed tiers cheapest first, Oxylabs and Decodo without JavaScript, then the renders (Bright Data, Oxylabs, Decodo) racing one hedge apart (hedge:, 5 s) while the content check fails. Oxylabs without JS is a page rung: after plain’s captcha with both keys, first with the free fetch off, on every page with its key alone, never after a shell (Plan::ladder; Decodo’s the same); it also serves a search, a PDF’s bytes and provider:oxy. The first good body wins and the other call is cancelled, its bill unverified (billed). Government hosts skip Bright Data (it refuses them). A PDF (pdf_run) goes plain → Oxylabs without JS → Bright Data for its bytes, never JavaScript; a /pdf/ path (Plan::hint) only gets the file timeout and raw bytes, page rules otherwise; a zip document (docx, xlsx) never goes to a provider, and a text document plain served (clean::Lists::text) stops it. next is the whole decision table, pure, so it is tested without a network. Every page fetch walks the same ladder; js:true walks the table’s render order (JS_QUOTE).
html
HTML → node arena. html5ever (WHATWG tree construction) feeds a small TreeSink; the arena is what the renderer walks.
lang
LANG: argv → command (parse + repair) and the ONLY place that writes to stdout.
mcp
MCP surface: fats mcp = a stdio server with ONE tool, fats(cmd). Its text is exactly what the CLI prints for the same command line (same cli::run, same cache, same session), so there is one language on every surface.
outline
OUTLINE + READ: lines → sections; outline-top, all, section parts, full, links.
pdf
PDF bytes → Doc: one section per page, so u3#4 is page 4. Text comes from pdf_oxide’s per-page extractor; no OCR, so a page without a text layer stays an empty section and the outline counts it.
provider
PROVIDERS: how a URL becomes bytes. plain = a direct GET with Safari 26’s TLS, HTTP/2 and header profile; bd = Bright Data Web Unlocker; oxy / oxyjs = Oxylabs Web API /v1/scrape without / with JavaScript rendering (one key, two prices, two timeouts); decodo / decodojs = Decodo Web Data API /v1/scrape the same way. One table holds names, keys, timeouts and list prices; the router (fetch.rs) decides which to call.
search
FILTER inside a page: the match ladder’s local rungs: exact phrase → all words (stemmed) → best partial. near/topic need a model and are not in this build (a ! row says so).
settings
SETTINGS: every knob read once, with where it came from and any input that was refused. One reader per knob, so fats config shows the value in effect: a second reader that parses the same env var its own way can disagree with it. A refused value is never silent: it prints a ! row and shows in config.
setup
fats setup past the piped check rows (stats::setup): way 1, a person at a terminal, walks the provider list, a key page per provider and the agent connection (a menu that exits); way 2, an agent, starts a one-shot local key form for its user (fats setup oxy); way 3, a pipe (printf %s "$KEY" | fats setup oxy). Also every rule about a key on its way in or out: its shape on a command line (refused there, masked in ? rows), the status line’s tails and the environment’s rows, the Bright Data zone pick. Screen words are data (src/data/screens/, lang::screen), the form is src/data/setup-form.html.
stats
Self-observability: fats status, fats stats, fats config, fats account.
tables
Generated by scripts/gen_tables.py (Python 3.14.8, Unicode 16.0.0). Regenerate, never hand-edit. FOLD = NFKD minus combining marks for every non-combining code point except Hangul syllables, which clean::fold decomposes by formula; COMBINING = every ccc > 0 range; ND_ZEROS = the first code point of every Unicode Nd run of ten (what regex \d matches).
telemetry
TELEMETRY: the one-time notice, the daily update check (L1) and the weekly counts (L2); what each sends is printed by fats telemetry show and listed in docs/telemetry.md. The foreground run only makes small files, one create_new each, so ten agents that start at once still ping once a day; the one process that made today’s stamp goes on detached (fats --continue telemetry, cli::detach) and makes the call there. A process that started before the notice was shown sends nothing. Off under a CI marker (telemetry.json ci_env), DO_NOT_TRACK, FATS_TELEMETRY=0 or FATS_OFFLINE (settings::Settings::telemetry): nothing written, nothing sent. Never sent: an id, a URL, a search, a path, a key.
text
Text documents (clean::Lists::text: plain text, CSV, Markdown, JSON, XML incl. RSS/Atom/sitemaps) → Doc, served as they are: each line one row, no id (lN names a link, so a numbered line read as one: ? lN unknown), 300 lines per section (u1#2 = lines 301-600). Never the page path: a text body judged as a page reads as a JS shell and goes to every provider.