public snapshot · areas/examples/raft-nib/ · system@main · commit da2bf624f03d · shared 2026-11-23T17:23:12Z· frozen: this page does not change when the repository does
all files
  1#!/usr/bin/env bash
  2# Run raft.nib under many seeded worlds and judge each run with nib-tla.
  3#
  4#   bash explore.sh [WIRE] [FIRST_SEED] [LAST_SEED]
  5#
  6# WIRE is Main (the program as Raft states it), Mutant (a node that votes
  7# twice in one term), Careless (votes ignore the candidate's log) or Forgetful
  8# (a store that recovers nothing; it shows only under a world with crashes,
  9# as worlds/crash.json, which `nib-tla verify` sweeps). Each seed's world draws delays, loss, duplication and
 10# the schedule from that seed, with a partition in the middle of the run. A
 11# run the monitor refuses is kept in out/: its journal, and the world file
 12# that makes its exact choices (`nib-tla world`), so it can be replayed and cut
 13# down. Needs nibc and nib-tla built, and a checker (APALACHE_JAR,
 14# NIB_TLA_JAVA) as nib-tla finds one.
 15set -euo pipefail
 16here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
 17root=$(cd "$here/../../.." && pwd)
 18nibc=${NIBC:-$root/system/tools/nib/_build/default/lib/nibc.exe}
 19tla=${NIB_TLA:-$root/system/tools/modelcheck/nib-tla/target/release/nib-tla}
 20export NIBC_STD=${NIBC_STD:-$root/system/tools/nib/std}
 21wire=${1:-Main}
 22first=${2:-1}
 23last=${3:-20}
 24out="$here/out"
 25mkdir -p "$out"
 26admitted=0
 27refused=0
 28for seed in $(seq "$first" "$last"); do
 29  world="$out/world-$seed.json"
 30  journal="$out/run-$wire-$seed.jsonl"
 31  cat >"$world" <<JSON
 32{ "seed": $seed, "schedule": "random",
 33  "net": { "delay_ms": [1, 80], "drop_permille": 100, "duplicate_permille": 50,
 34           "partitions": [ { "from_ms": 500, "until_ms": 1500,
 35                             "sides": [["10.0.0.1"], ["10.0.0.2", "10.0.0.3"]] } ] } }
 36JSON
 37  "$nibc" --run "$here/raft.nib" --wire "$wire" --world "$world" --journal-out "$journal" >/dev/null
 38  verdict=$("$tla" check --spec "$here/RaftTrace.tla" --journal "$journal" || true)
 39  if grep -q "verdict=admitted" <<<"$verdict"; then
 40    admitted=$((admitted + 1))
 41    rm -f "$journal" "$world"
 42  else
 43    refused=$((refused + 1))
 44    "$tla" world --journal "$journal" --base "$world" >"$out/steer-$wire-$seed.json"
 45    echo "seed $seed: $(grep -E '^nib-tla: refused|frontier' <<<"$verdict" | tr '\n' ' ')"
 46  fi
 47done
 48echo "$wire: $admitted admitted, $refused refused (kept in $out)"