Skip to content

How It Works

Ranesh Rajit edited this page Oct 8, 2026 · 3 revisions

How It Works

Phase 0 - Trusted enrollment (once, clean room)

Enroller measures the golden files (binary, config, memory)
        |
        v
config/baseline.json saved (Boss trusted store) + genesis anchored
        |
        v
public key pinned at enrollment -> key swaps fail as KEY_MISMATCH
        |
        v
contract + chainId pinned when config/chain.json exists -> mismatch refuses chain mode

Phase 1 - Heartbeat (every 5s forever)

Checker reads binary + config + memory
        |
        v
H_bin, H_cfg, H_mem -> H_comb = SHA256(raw32 || raw32 || raw32)
        |
        v
Sign(agentId|seq|ts|hBin|hCfg|hMem|hComb|prevHash) with keys/ privateKey
        |
        v
Anchor to Integrity.sol (locally signed EIP-155 raw tx, owner-only) / ledger.jsonl FALLBACK
        |
        v
After a mined anchor: eth_call getLatest, stored record must equal the submission
        |
        v
Boss checks the verdict set (see below)
        |
        v
GREEN (all pass) or RED (reason + expected vs got)
        |
        v
Dashboard (PORT env, default 8080) + /metrics + console log + witness.jsonl counter-attestation

Every 12 cycles the heartbeat closes a Merkle batch window over the recent window: the root appears in /api/status (batchRoot) and the console prints BATCH window=12 root=... proofs=... build=...us, showing proof generation running continuously at scale. (The contract stores single-cycle hashes; the batch root is attested off-chain through the frozen prevHash linkage.)

The verdict checks

The Verifier returns GREEN only if every check passes:

  1. Comb: hComb == SHA256(raw32||raw32||raw32) (raw bytes, never hex-concat).
  2. Seal: the full 8-field Ed25519 signature verifies (off-chain; the EVM has no Ed25519).
  3. Link: prevHash matches the previous cycle's hComb (genesis = 64 zeros). 3b. Readback (when anchored on-chain): the record read back from getLatest equals the submitted measurement, else CHAIN_MISMATCH comp=chain.
  4. Recompute: Boss re-measurement equals the reported hash per component (catches a lying Checker as MEASURE_MISMATCH_BIN/CFG/MEM).
  5. Baseline: reported hash equals the golden baseline per component (catches an edit as POLICY_BIN/CFG/MEM_CHANGED).
  6. Freshness: ts within 12s (chain block.timestamp authoritative when up) and seq strictly monotonic (catches replay as STALE_REPLAY).

A swapped signing key is checked before everything else: pin present and disk key matches, or KEY_MISMATCH.

Verdict state machine

stateDiagram-v2
    [*] --> GREEN : fresh clone boots
    GREEN --> RED : POLICY_*_CHANGED / MEASURE_MISMATCH_* / SIG_FAIL / STALE_REPLAY / COMB_MISMATCH / PREV_HASH_BREAK / CHAIN_MISMATCH
    GREEN --> STALE : no fresh anchor for 12s (watchdog)
    RED --> GREEN : restore bytes / clear memory
    RED --> STALE : heartbeat stalls while RED
    STALE --> GREEN : heartbeat resumes
Loading

Timing

  • Heartbeat interval: 5s (frozen).
  • STALE after: 12s without a fresh anchor, enforced by a 1s watchdog even with zero dashboard requests.
  • Worst-case detection: next interval + pipeline = ~5s + ~4ms average (24ms worst, 20 trials; on-chain RPC + receipt wait excluded from the pipeline spans, shown as anchor+verify in the dashboard).
  • A stalled heartbeat shows CYCLE_ERR with the cause first, then STALE past the 12s window (no flicker between the two).
  • Receipt polling is fast-first: 10 x 50ms, then 3 x 200ms (worst ~1.1s) before a cycle reports the tx as pending.

Clone this wiki locally