Commit graph

2 commits

Author SHA1 Message Date
7f830a36ef Advance Python test coverage — voting, recorder, simulation extensions
Pre-existing tests covered crypto / graph / message / order / rounds /
weight, but left three high-value modules unverified:

  - voting.py — 25 KB of BBA virtual leader election + safe voting
    pattern (Algorithms 6 & 7), the heart of the protocol. Zero
    tests. Now 14 tests covering the four public entry points
    (`build_knowledge_graph`, `select_quorum`, `voting_set`,
    `compute_safe_voting_pattern`, `compute_virtual_leader_election`)
    plus `initial_vote`. Uses a small in-process Simulation to
    produce realistic multi-round graphs.

  - recorder.py — the bridge that turns simulation runs into the
    JSON consumed by CrisisViz. Zero tests despite being the choke
    point: if recorder silently drops fields, the viz lies. Now 11
    tests covering EventRecorder bookkeeping (sequence, filtering),
    SimulationRecording integration (STEP_BEGIN/END,
    MESSAGE_CREATED/DELIVERED), capture_snapshot well-formedness,
    and JSON-serializability of both snapshots and event data.

  - test_simulation.py extended with three regression guards:
      - test_byzantine_vertices_flagged_in_snapshots: ensures the
        `is_byzantine_source` flag survives the recorder pipeline.
        CrisisViz's Ch10 (byzantine) chapter relies on this to
        colour Dave's lane red.
      - test_recorder_deterministic_with_seed: same seed produces
        identical event-stream length and type ordering. Tightens
        the existing vertex-count determinism check.
      - test_consensus_pipeline_progresses: a fast claim that rounds
        advance past 0 and the SVP / voting code paths engage. The
        stronger claim (full convergence + non-empty total order)
        takes minutes in pure Python and belongs in a separate
        long-running benchmark, not the unit-test suite — but the
        weaker claim is sufficient to catch the dead-pipeline
        failure mode that motivated regenerating crisis_data.json
        on 2026-05-04.

Suite: 72 -> 100 tests, all green in ~0.75s.

Explicitly out of scope (separate engineering effort):
  - gossip.py / node.py TCP integration tests — heavy harness;
  - export_json.py — thin composition of tested layers;
  - Swift XCTest — the CrisisViz testbed harness already covers
    the curriculum-correctness layer.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 15:52:30 +02:00
1df4790fb4 Initial implementation of the Crisis protocol (Richter, 2019)
Complete Python PoC of "Probabilistically Self Organizing Total Order
in Unstructured P2P Networks". Implements all 10 algorithms from the paper:
message generation, integrity checks, Lamport graphs, virtual synchronous
rounds, safe voting patterns, virtual leader election (BA*), longest chain
rule, total order via Kahn's algorithm, and push/pull gossip.

Includes simulation harness, full node binary, and 72 passing tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-23 13:20:30 +02:00