#!/usr/bin/env bash # hosts/ocaml/test/persist_durable_test.sh # Acceptance test for the host durable-storage adapter (Sx_persist_store). # # Exercises `persist/durable-backend` (REAL `perform`, not the mock) under the # WORKTREE-built sx_server.exe, and asserts: # 1. durable: writes land on disk and read back (the silent-data-loss repro # from plans/persist-on-sx.md now returns correct values). # 2. last-seq is monotonic across truncate (compaction never reassigns a seq). # 3. kv ops round-trip and delete. # 4. recovery: a REAL process restart (write, exit, fresh process, replay) # recovers state from disk. # # Run from repo root or anywhere; locates the worktree binary relative to itself. set -uo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$HERE/../../.." && pwd)" # repo/worktree root cd "$ROOT" SX="hosts/ocaml/_build/default/bin/sx_server.exe" if [ ! -x "$SX" ]; then echo "ERROR: worktree binary not found at $SX — build it first:" >&2 echo " (cd hosts/ocaml && dune build bin/sx_server.exe)" >&2 exit 1 fi DATADIR="$(mktemp -d)" trap 'rm -rf "$DATADIR"' EXIT PASS=0 FAIL=0 check() { # check