interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

branch main Branches Tags History

synapse / scripts / run_gate4_qualification.sh

100 lines · 4126 bytes Raw Blame History
1#!/usr/bin/env bash
2set -euo pipefail
3
4# Gate 4 comparative qualification run for Synapse (aien-sovereign-core#515).
5#
6# Builds the synapse-bench harness, then measures Synapse changeset ingest and
7# checkout-free queries against Git worktree and Git plumbing workflows on a pinned
8# commit of a real repository, runs the WAL, Git, and Radicle conformance suites,
9# and writes evidence/gate4-qualification/ (report.json, manifest.json,
10# traces/*.jsonl, SHA256SUMS).
11#
12# The fixture repository is only read: the harness clones it once with
13# --no-checkout --no-hardlinks into a temporary work directory and records a digest
14# of its refs before and after the run.
15#
16# Environment overrides:
17# FIXTURE_REPO real repository to clone (default ~/workspace/aien-sovereign-core)
18# FIXTURE_REV pinned commit (default: the Gate 0 baseline commit)
19# OUT_DIR evidence directory (default <repo>/evidence/gate4-qualification)
20# WORK_PARENT parent of the temporary work directory (default ${TMPDIR:-/tmp})
21# REPS, TIERS, ARMS, SEED override run dimensions (see synapse-bench docs)
22# RADICLE_REPO bare Radicle storage repo for the live conformance case; unset uses
23# the aien-sovereign-core storage repo when present, empty disables
24# SMOKE=1 tiny end-to-end run for checking the harness
25
26REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
27FIXTURE_REPO="${FIXTURE_REPO:-$HOME/workspace/aien-sovereign-core}"
28FIXTURE_REV="${FIXTURE_REV:-1b6e340d48417dfbcfe2df56d48a0696a3a9b250}"
29OUT_DIR="${OUT_DIR:-$REPO_ROOT/evidence/gate4-qualification}"
30WORK_PARENT="${WORK_PARENT:-${TMPDIR:-/tmp}}"
31SMOKE="${SMOKE:-0}"
32DEFAULT_RADICLE_REPO="$HOME/.radicle/storage/z2kdkm8HpiyFbMFpFmzzWZQgTn1EQ"
33if [ -z "${RADICLE_REPO+set}" ]; then
34 if [ -d "$DEFAULT_RADICLE_REPO" ]; then
35 RADICLE_REPO="$DEFAULT_RADICLE_REPO"
36 else
37 RADICLE_REPO=""
38 fi
39fi
40
41started=$(date +%s)
42echo "== free disk at $WORK_PARENT"
43df -h "$WORK_PARENT"
44
45echo "== building synapse-bench (release)"
46(cd "$REPO_ROOT" && cargo build --release -p synapse-bench --offline)
47# CARGO_TARGET_DIR, when set, is where cargo put the binary (relative to REPO_ROOT, where it ran).
48TD=${CARGO_TARGET_DIR:-target}; case $TD in /*) ;; *) TD="$REPO_ROOT/$TD" ;; esac
49BIN="$TD/release/synapse-bench"
50
51# Identity of the harness source that produced the evidence.
52SOURCE_REV="$(git -C "$REPO_ROOT" rev-parse HEAD)"
53if [ -n "$(git -C "$REPO_ROOT" status --porcelain -- crates Cargo.toml Cargo.lock scripts)" ]; then
54 SOURCE_DIRTY="dirty"
55else
56 SOURCE_DIRTY="clean"
57fi
58SOURCE_DIGEST="$(cd "$REPO_ROOT" \
59 && git ls-files -z -co --exclude-standard -- crates Cargo.toml Cargo.lock scripts \
60 | LC_ALL=C sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
61
62WORK_DIR="$(mktemp -d "$WORK_PARENT/synapse-gate4.XXXXXX")"
63cleanup() { rm -rf "$WORK_DIR"; }
64trap cleanup EXIT
65
66# Replace only the files this script produces.
67mkdir -p "$OUT_DIR"
68rm -rf "$OUT_DIR/traces"
69rm -f "$OUT_DIR/report.json" "$OUT_DIR/manifest.json" "$OUT_DIR/SHA256SUMS"
70
71args=(run
72 --fixture-repo "$FIXTURE_REPO"
73 --fixture-rev "$FIXTURE_REV"
74 --out "$OUT_DIR"
75 --work-dir "$WORK_DIR"
76 --source-rev "$SOURCE_REV"
77 --source-dirty "$SOURCE_DIRTY"
78 --source-digest "$SOURCE_DIGEST")
79[ -n "${REPS:-}" ] && args+=(--reps "$REPS")
80[ -n "${TIERS:-}" ] && args+=(--tiers "$TIERS")
81[ -n "${ARMS:-}" ] && args+=(--arms "$ARMS")
82[ -n "${SEED:-}" ] && args+=(--seed "$SEED")
83[ -n "$RADICLE_REPO" ] && args+=(--radicle-repo "$RADICLE_REPO")
84[ "$SMOKE" = "1" ] && args+=(--smoke)
85
86echo "== running qualification (work dir $WORK_DIR)"
87"$BIN" "${args[@]}"
88
89# Keep raw traces reasonably sized: compress them when they exceed 20 MiB.
90trace_bytes="$(du -sb "$OUT_DIR/traces" | cut -f1)"
91if [ "$trace_bytes" -gt $((20 * 1024 * 1024)) ]; then
92 echo "== traces total $trace_bytes bytes; compressing with gzip -n"
93 gzip -n -9 "$OUT_DIR"/traces/*.jsonl
94fi
95
96(cd "$OUT_DIR" && find . -type f ! -name SHA256SUMS -printf '%P\n' | LC_ALL=C sort \
97 | xargs -d '\n' sha256sum > SHA256SUMS)
98
99finished=$(date +%s)
100echo "== done in $((finished - started)) s; evidence in $OUT_DIR"