code wiki / _hdl_build / nx_polite_crawl.nx
nx_polite_crawl.nx
buildroot/runtime/_hdl_build/nx_polite_crawl.nx
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
imports: nx_syscalls.nx
imported by: nx_polite_crawl_test.nxnx_research_auto.nxnx_site_ingest.nx
structs
| none |
consts
| 14 | const PC_MAGIC_1000000000: i64 = 1000000000 |
| 16 | const PC_OK: i64 = 200 |
| 17 | const PC_RETRY: i64 = 429 // rate-limited (or 503) -> back off |
| 18 | const PC_BLOCKED: i64 = 403 // hard block -> stop hitting this host entirely |
functions
| 21 | func pc_backoff_ms(consec: i64, base_ms: i64, cap_ms: i64) -> i64 |
| 31 | func pc_may_fetch(last_ms: i64, backoff_until_ms: i64, now_ms: i64, min_interval_ms: i64, crawl_delay_ms: i64) -> i64 |
| 40 | func pc_record(last_ms: *i64, idx: i64, now_ms: i64) -> i64 { last_ms[idx] = now_ms; return 0 } called by 1: main |
| 43 | func pc_on_response(backoff_until_ms: *i64, consec_429: *i64, idx: i64, status: i64, now_ms: i64, base_ms: i64, cap_ms: i64) -> i64 |
| 55 | func pc_next_host(last_ms: *i64, backoff_until_ms: *i64, crawl: *i64, n: i64, now_ms: i64, min_interval_ms: i64) -> i64 |
| 71 | func pc_breadth_permil(distinct_hosts: i64, total_requests: i64) -> i64 |
| 78 | func pc_is_polite(req_per_host: *i64, n: i64, floor_per_host: i64) -> i64 |
| 85 | func pc_is_broad(distinct_hosts: i64, min_hosts: i64) -> i64 |
| 92 | func pc_research_gate(distinct_hosts: i64, total_requests: i64, req_per_host: *i64, n: i64, |