waggle-core 0.1.0

Sans-I/O core of waggle: tokens, timestamps, entropy injection. No clock, no I/O, no storage — every effect is a parameter. Compiles to wasm32 unchanged.
Documentation

waggle-core — the sans-I/O domain

The core performs no I/O, owns no clock, and generates no entropy (design doc 03 §1). Every effect is a parameter:

  • randomness arrives through [Entropy] (blanket-implemented for closures — function passing, not global state),
  • time arrives as a [Timestamp] value in every signature that needs one,
  • storage never appears here at all (see waggle-store).

This is what lets the identical code run in the native daemon, in Cloudflare Workers wasm, and under deterministic tests.

CP-0 shipped the foundation trio: [Token], [Timestamp], [Entropy]. CP-1 adds the domain model: slugs ([Sharer], [Channel], [Stage]), targets ([CanonicalUrl], [TargetMeta], [MediaRef]), the three-zone [AttributionManifest] with variants, and [mint] — a pure function of (spec, options, entropy, now). The sealed variant matcher and folds land in CP-2/CP-3 (design docs 0204).

use waggle_core::{Entropy, Token};

// A deterministic entropy source: fine for tests, never for production.
let mut counter = 0u8;
let mut entropy = |buf: &mut [u8]| {
    for b in buf.iter_mut() {
        counter = counter.wrapping_add(41);
        *b = counter;
    }
    Ok(())
};
let token = Token::generate(8, &mut entropy).expect("entropy never fails here");
assert_eq!(token.as_str().len(), 8);