code wiki / _hdl_build / nx_polite_crawl.nx

nx_polite_crawl.nx

buildroot/runtime/_hdl_build/nx_polite_crawl.nx

5379 B98 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind librarytopic polite
docsdependenciesstructsconstsfunctions

about

nx_polite_crawl.nx -- the POLITE CRAWL GOVERNOR (operator: researcher must "not be small sampled but doesnt trigger bot blowback"). The key synergy this encodes: BROAD coverage and POLITENESS are the SAME move -- you reach hundreds of sources by spreading THIN across many hosts (1-2 hits each, paced), never hammering one. The anti-pattern that triggers bot-blocking is small-sample-but- aggressive (one host 100x). The governor enforces broad-and-gentle: * per-host MIN INTERVAL (>= N ms between requests to the SAME host) + robots crawl-delay * EXPONENTIAL BACKOFF on 429/503 (capped) -- back off the moment a host pushes back * round-robin LONGEST-IDLE scheduler -- always fetch the host idle longest = spreads load * BREADTH metric (distinct hosts / total requests) -- high breadth = both large-sample AND polite Per-host state in parallel i64 arrays (struct-free): last_ms[], backoff_until_ms[], consec_429[]. All integer; deterministic given a clock. Composes nx_research_synth (corroborate what's fetched) + nx_resource_governor (host CPU politeness). LAWS: struct-free, integer-only. license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_polite_crawl.nx nx_polite_crawl_test.nx nx_research_auto.nx nx_site_ingest.nx

imports: nx_syscalls.nx

imported by: nx_polite_crawl_test.nxnx_research_auto.nxnx_site_ingest.nx

structs

none

consts

14const PC_MAGIC_1000000000: i64 = 1000000000
16const PC_OK: i64 = 200
17const PC_RETRY: i64 = 429 // rate-limited (or 503) -> back off
18const PC_BLOCKED: i64 = 403 // hard block -> stop hitting this host entirely

functions

21func pc_backoff_ms(consec: i64, base_ms: i64, cap_ms: i64) -> i64
called by 2: pc_on_responsemain
31func pc_may_fetch(last_ms: i64, backoff_until_ms: i64, now_ms: i64, min_interval_ms: i64, crawl_delay_ms: i64) -> i64
called by 2: pc_next_hostmain
40func pc_record(last_ms: *i64, idx: i64, now_ms: i64) -> i64 { last_ms[idx] = now_ms; return 0 }
called by 1: main
43func pc_on_response(backoff_until_ms: *i64, consec_429: *i64, idx: i64, status: i64, now_ms: i64, base_ms: i64, cap_ms: i64) -> i64
called by 1: main calls 1: pc_backoff_ms
55func pc_next_host(last_ms: *i64, backoff_until_ms: *i64, crawl: *i64, n: i64, now_ms: i64, min_interval_ms: i64) -> i64
called by 1: main calls 1: pc_may_fetch
71func pc_breadth_permil(distinct_hosts: i64, total_requests: i64) -> i64
78func pc_is_polite(req_per_host: *i64, n: i64, floor_per_host: i64) -> i64
85func pc_is_broad(distinct_hosts: i64, min_hosts: i64) -> i64
92func pc_research_gate(distinct_hosts: i64, total_requests: i64, req_per_host: *i64, n: i64,