Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

UniverseDomainTests
LinkMazelinkmaze.simDeep graph traversal, configurable fan-out
EncodingHellencoding.simUTF-8 edge cases, mixed encodings, BOM
MalformedDommalformed.simBroken HTML, unclosed tags, invalid attributes
RedirectLabyrinthredirect.simRedirect chains, loops, cross-domain redirects
ContentTraptrap.simInfinite calendars, session IDs, spider traps
TemporalDriftdrift.simContent 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.