Simulation Framework
The simulation framework (palimpsest-sim) provides a virtual internet for testing. It replaces real HTTP with deterministic, seed-driven responses — enabling proof that the Six Laws hold at scale.
SimulatedWeb
A SimulatedWeb hosts multiple “universes,” each owning a domain:
#![allow(unused)]
fn main() {
let mut web = SimulatedWeb::new(CrawlSeed::new(42));
web.add_universe(Box::new(LinkMaze { links_per_page: 500, total_pages: 100_000 }));
web.add_universe(Box::new(EncodingHell));
web.add_universe(Box::new(MalformedDom));
}
Calling web.fetch(&url) returns a SimulatedResponse generated deterministically from the seed and URL.
SimulatedServer
Wraps SimulatedWeb with wiremock to serve responses over real HTTP. The CrawlOrchestrator connects to it as if it were the real web.
verify_determinism
The core harness:
#![allow(unused)]
fn main() {
let result = verify_determinism(
|| build_web(seed), // Factory creates identical web each time
&seed_urls,
max_depth,
max_urls,
).await?;
}
This function:
- Creates a
SimulatedWebfrom the factory - Runs a full crawl (orchestrator + frontier + storage + index)
- Records all URLs, blob hashes, and index entries
- Creates a second
SimulatedWebfrom the same factory - Runs an identical crawl
- Asserts the two runs produced byte-identical results
Any divergence in URLs, blob hashes, or index entries causes a test failure.
verify_resumption_determinism
Tests crawl resumption:
- Crawl 500 pages, save frontier state
- Create new frontier, load saved state
- Continue crawling to 1000 pages
- Compare against a single 1000-page run
Same result = Law 1 holds across save/load boundaries.
Scale Tests
| Test | Pages | Universes | Result |
|---|---|---|---|
test_scale_1000_pages_deterministic | 1,000 | 5 | Zero divergence |
test_scale_5000_pages_linkmaze_only | 5,000 | 1 | Zero divergence |
test_stress_10k_pages_deterministic | 10,000 | 5 | Zero divergence |