palimpsest-sim
Deterministic simulation testing framework. Proves the Six Laws hold at scale by crawling a virtual internet twice with the same seed and asserting byte-identical results.
SimulatedWeb
#![allow(unused)]
fn main() {
pub struct SimulatedWeb {
seed: CrawlSeed,
universes: BTreeMap<String, Box<dyn UniverseGenerator>>,
}
impl SimulatedWeb {
pub fn new(seed: CrawlSeed) -> Self;
pub fn add_universe(&mut self, generator: Box<dyn UniverseGenerator>);
pub fn fetch(&self, url: &Url) -> Option<SimulatedResponse>;
}
}
UniverseGenerator Trait
#![allow(unused)]
fn main() {
pub trait UniverseGenerator: Send + Sync {
fn domain(&self) -> &str;
fn generate(&self, seed: &CrawlSeed, url: &Url) -> SimulatedResponse;
fn page_count(&self) -> usize;
}
}
Each universe owns a domain (e.g., linkmaze.sim) and generates deterministic responses for any URL under that domain.
SimulatedResponse
#![allow(unused)]
fn main() {
pub struct SimulatedResponse {
pub status: u16,
pub headers: Vec<(String, String)>,
pub body: Bytes,
pub delay: Option<Duration>,
pub fault: Option<FaultType>,
}
pub enum FaultType {
ConnectionRefused, Timeout, Reset, RedirectLoop,
}
}
Six Adversarial Universes
| Universe | Domain | Tests |
|---|---|---|
| LinkMaze | linkmaze.sim | Deep graph traversal, configurable fan-out |
| EncodingHell | encoding.sim | UTF-8 edge cases, mixed encodings, BOM |
| MalformedDom | malformed.sim | Broken HTML, unclosed tags, invalid attributes |
| RedirectLabyrinth | redirect.sim | Redirect chains, loops, cross-domain redirects |
| ContentTrap | trap.sim | Infinite calendars, session IDs, spider traps |
| TemporalDrift | drift.sim | Content changes between fetches |
Verification Harness
#![allow(unused)]
fn main() {
pub async fn verify_determinism<F>(
web_factory: F,
seeds: &[Url],
max_depth: u32,
max_urls: usize,
) -> Result<VerificationResult, String>
where F: Fn() -> SimulatedWeb;
}
Crawls twice, compares URLs, blob hashes, and index entries. Any divergence = failure.
VerificationResult
#![allow(unused)]
fn main() {
pub struct VerificationResult {
pub urls: Vec<String>,
pub blob_hashes: Vec<String>,
pub index_entries: Vec<(String, String)>,
pub pages_fetched: usize,
pub errors: usize,
}
}
Scale
Proven deterministic at 1,000, 5,000, and 10,000 pages across all six universes with zero divergence.