mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-27 10:38:09 +00:00
Schema-migration matrix + fuzz harness + RSS budget gate + read-latency
under sync + sync lock regression + tests/heavy convention + nightly CI
workflow + BFS frontier cap on traverseGraph.
CI infra (T1-T7):
- tests/heavy/ directory convention + scripts/run-heavy.sh + bun run test:heavy
- tests/heavy/pg_upgrade_matrix.sh: walk pre-v0.13 + pre-v0.18 brain shapes
forward to head via bootstrap → SCHEMA_SQL → migrations → verifySchema
- test/fuzz/{pure,mixed,filesystem}-validators.test.ts: 1000-run fast-check
property tests across 8 trust-boundary validators
- scripts/check-fuzz-purity.sh: bun-bundle + grep guard, wired into verify
- tests/heavy/measure_rss.sh: in-memory PGLite workload + peak RSS measurement
via /proc/self/status (Linux) or process.memoryUsage().rss fallback (macOS,
refuses to write baseline)
- tests/heavy/read_latency_under_sync.sh: phase A baseline + phase B under
parallel writer load, reports p50/p95/p99 + delta_pct
- tests/heavy/sync_lock_regression.sh: N concurrent gbrain sync against one
DB, asserts 1 winner + N-1 lock-busy + zero leaked gbrain_cycle_locks rows
- .github/workflows/heavy-tests.yml: cron '17 8 * * *' + heavy-tests label
trigger + Postgres service + artifact upload on failure
Engine (T8):
- BrainEngine.traverseGraph opts gain frontierCap?: number + onTruncation?:
(info: TruncationInfo) => void callback. Return shape preserved
(Promise<GraphNode[]>) for MCP wire stability.
- Postgres CTE: parenthesized LIMIT N ORDER BY (slug, id) inside recursive term.
- PGLite: same SQL with positional params.
- Per-call callback closure — not engine-instance state — so concurrent
traversals on the same engine don't cross-talk. 5 contracts pinned in
test/regressions/v0_36_frontier_cap.test.ts.
Three plan-review passes ran before any code: CEO scope review (Approach C),
Eng dual-voice review (Claude subagent + Codex), and Codex 2nd-pass against
the revised plan. The 2nd pass caught issues the first two missed (Bun ESM
vs require.cache; engine-instance metadata stomping under concurrency;
fixture-size inconsistency). All addressed.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
75 lines
2.0 KiB
Bash
Executable File
75 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/run-heavy.sh
|
|
# Runs every shell script under tests/heavy/ sequentially.
|
|
# Sister to scripts/run-slow-tests.sh and scripts/run-e2e.sh, but for
|
|
# ops-shape tests that aren't bun:test targets.
|
|
#
|
|
# Usage:
|
|
# bun run test:heavy # all scripts, sequential
|
|
# bash scripts/run-heavy.sh # same
|
|
# bash scripts/run-heavy.sh <pattern> # only scripts whose basename matches glob
|
|
#
|
|
# Exit codes:
|
|
# 0 all scripts passed (or no scripts found — informational)
|
|
# N exit code of the first failing script
|
|
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
PATTERN="${1:-}"
|
|
|
|
heavy_files=()
|
|
while IFS= read -r f; do
|
|
# Skip README.md, non-shell files, and underscore-prefixed helpers
|
|
# (convention: `_foo.sh` is a library/helper invoked by sibling tests).
|
|
[[ "$f" == *.sh ]] || continue
|
|
base=$(basename "$f")
|
|
case "$base" in
|
|
_*) continue ;;
|
|
esac
|
|
if [ -n "$PATTERN" ]; then
|
|
case "$base" in
|
|
$PATTERN) ;;
|
|
*) continue ;;
|
|
esac
|
|
fi
|
|
heavy_files+=("$f")
|
|
done < <(find tests/heavy -maxdepth 1 -type f -name '*.sh' | sort)
|
|
|
|
if [ "${#heavy_files[@]}" -eq 0 ]; then
|
|
if [ -n "$PATTERN" ]; then
|
|
echo "[run-heavy] no scripts under tests/heavy/ matched '$PATTERN'" >&2
|
|
exit 1
|
|
fi
|
|
echo "[run-heavy] no scripts under tests/heavy/; nothing to do."
|
|
exit 0
|
|
fi
|
|
|
|
echo "[run-heavy] running ${#heavy_files[@]} heavy script(s):"
|
|
for f in "${heavy_files[@]}"; do echo " - $f"; done
|
|
echo ""
|
|
|
|
failed=0
|
|
for f in "${heavy_files[@]}"; do
|
|
echo "[run-heavy] --- $f ---"
|
|
start=$(date +%s)
|
|
if bash "$f"; then
|
|
elapsed=$(( $(date +%s) - start ))
|
|
echo "[run-heavy] OK ($f, ${elapsed}s)"
|
|
else
|
|
rc=$?
|
|
elapsed=$(( $(date +%s) - start ))
|
|
echo "[run-heavy] FAIL ($f exited $rc after ${elapsed}s)" >&2
|
|
failed=$rc
|
|
break
|
|
fi
|
|
echo ""
|
|
done
|
|
|
|
if [ "$failed" -ne 0 ]; then
|
|
echo "[run-heavy] FAILED — first failing script aborted the run." >&2
|
|
exit "$failed"
|
|
fi
|
|
|
|
echo "[run-heavy] all ${#heavy_files[@]} script(s) passed."
|