Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f96ff06
fix(tests): make the changed-file map select per script and stabilize…
Aug 28, 2026
54b978f
feat(bin): make suite wall clock a result and let a family's concurre…
Aug 28, 2026
274c4e9
perf(bin): schedule the changed suite concurrently, longest first
Aug 28, 2026
2c0e7b8
fix(bin): bound a hung test instead of letting it hang the suite
Aug 28, 2026
eb48c97
no-mistakes(review): Enforce safe concurrency and descendant timeouts
kunchenguid Aug 28, 2026
3f2b212
no-mistakes(review): Validate empty runs and isolation proof pools
kunchenguid Aug 28, 2026
46dc59a
no-mistakes(review): Measure selection time in wall budget
kunchenguid Aug 28, 2026
980da4b
no-mistakes(review): Reap interrupted workers and bound finalization
kunchenguid Aug 28, 2026
b6517c4
no-mistakes(review): Contain shutdown descendants and watchdog finali…
kunchenguid Aug 28, 2026
59d1b86
no-mistakes(review): Honor remaining budget and close launch races
kunchenguid Aug 28, 2026
fbe6744
no-mistakes(review): Restore timeout helper and simplify runner cleanup
kunchenguid Aug 28, 2026
c686b19
no-mistakes(review): Record isolation pool admission metadata
kunchenguid Aug 28, 2026
5b447e0
no-mistakes(review): Bound Chrome reap and scope proof admission
kunchenguid Aug 28, 2026
077a797
no-mistakes(review): Align proof scheduling and preserve budget summa…
kunchenguid Aug 28, 2026
45c678d
no-mistakes(review): Remove unreliable finalization watchdog
kunchenguid Aug 28, 2026
82a9f50
no-mistakes(review): Freeze budget duration and enforce admission caps
kunchenguid Aug 28, 2026
255aa52
no-mistakes(document): Refresh test runner concurrency documentation
kunchenguid Aug 28, 2026
c89e081
no-mistakes(lint): Fix ShellCheck findings in test runner scripts
kunchenguid Aug 28, 2026
8e3440d
no-mistakes(ci): Fixed Greptile’s concurrency-consent finding. `--cha…
kunchenguid Aug 28, 2026
169f8c8
no-mistakes(review): Restore automatic changed-suite concurrency and …
kunchenguid Aug 28, 2026
9d23ac9
no-mistakes(review): Correct changed-suite contributor guidance
kunchenguid Aug 28, 2026
b508ebb
no-mistakes(review): Reject gate-skipped isolation proofs
kunchenguid Aug 28, 2026
cd82232
no-mistakes(review): Correct automatic concurrency evidence
kunchenguid Aug 28, 2026
5efc71b
no-mistakes(review): Isolate nested runner process groups
kunchenguid Aug 28, 2026
cac50e9
no-mistakes(review): Remove unreliable signal cleanup machinery
kunchenguid Aug 28, 2026
1218788
no-mistakes(test): Narrow changed-suite selection to executable contr…
kunchenguid Aug 28, 2026
535ccb7
no-mistakes(document): Document isolation proof skip and artifact sem…
kunchenguid Aug 28, 2026
e4eaa4c
no-mistakes(ci): Fixed Greptile’s concurrency-consent finding. `--cha…
kunchenguid Aug 28, 2026
c8744cf
no-mistakes(review): Restore plain changed-suite automatic concurrency
kunchenguid Aug 28, 2026
7a19628
no-mistakes(review): Record resolved changed-suite worker count
kunchenguid Aug 28, 2026
0de0f81
fix(bin): keep a runner change selecting its whole curated family
Aug 28, 2026
2aa93b2
perf(bin): admit the pure-contract-unit family to bounded concurrency
Aug 28, 2026
c1d1ff4
no-mistakes(review): Align contract-unit concurrency cap with recorde…
kunchenguid Aug 28, 2026
1f51419
no-mistakes(document): Record final changed-suite performance evidence
kunchenguid Aug 28, 2026
6d5dad5
fix(bin): keep an empty changed selection clean on stock macOS Bash
Aug 28, 2026
681bda8
no-mistakes(document): Document shell-bound changed-suite performance
kunchenguid Aug 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ bin/fm-lint.sh # lint that shell surface plus GitHub workflows via pinned acti
bin/fm-test-run.sh tests/<subject>.test.sh # one script (primary local focus path, timed)
bin/fm-test-run.sh --family pure-contract-unit # ordinary family-scoped local path (serial, timed)
bin/fm-test-run.sh --changed # conservative changed-file-informed set (never silent full suite)
bin/fm-test-run.sh --proven-isolated --jobs 4 # explicit local parallel of the proven set only (default is serial)
bin/fm-test-run.sh --proven-isolated --jobs 4 # explicit local parallel of the individually proven set
bin/fm-test-run.sh --lane portable-serial # portable serial remainder (watcher/AFK/tmux/stateful)
bin/fm-test-run.sh --list-lanes # discover exact lane names, including the current CI serial shards
bin/fm-test-run.sh --check-coverage # prove portable shards + serial + serial shards + Herdr equal the full inventory
bin/fm-test-run.sh --all # deliberate complete regression (optional local full walk; not no-mistakes Test)
bin/fm-test-isolation-proof.sh --list # proven parallel candidate set (Phase 2 owner)
bin/fm-test-isolation-proof.sh --jobs 4 --json /tmp/fm-isolation-proof.json # re-run concurrent isolation proof only
bin/fm-test-isolation-proof.sh --list # proven portable parallel candidate set
bin/fm-test-isolation-proof.sh --jobs 4 --json /tmp/fm-isolation-proof.json # re-run the portable candidate proof
bin/fm-test-isolation-proof.sh --pool watcher-wake-lock --jobs 4 # re-run an admitted family proof
[ ! -L CLAUDE.md ] && cmp -s CLAUDE.md - <<'EOF'
<!-- Points Claude at AGENTS.md via import; edit AGENTS.md, not this file. -->
@AGENTS.md
Expand All @@ -96,9 +97,9 @@ EOF
tmp=$(mktemp -d) && printf 'done: smoke\n' > "$tmp/smoke.status" && FM_STATE_OVERRIDE="$tmp" FM_SIGNAL_GRACE=1 FM_POLL=1 FM_HEARTBEAT=999999 bin/fm-watch-arm.sh # watcher re-arm smoke test (prints arm status, then an actionable signal)
```

`bin/fm-test-run.sh` is the single owner of behavior-suite selection, portable CI lane composition, optional local `--jobs` for the proven-isolated set only, per-script timing markers, family totals, the coverage guard, and the optional JSON timing artifact.
`bin/fm-test-run.sh` is the single owner of behavior-suite selection, portable CI lane composition, bounded concurrency admission, per-script timing markers, family totals, the coverage guard, and the optional JSON timing artifact.
Its header and `--help` own the flags, family labels, lanes, and changed-file map; this section only documents the entry points.
`bin/fm-test-isolation-proof.sh` remains the single owner of the Phase 2 concurrent isolation proof and the exact proven candidate set; see `docs/fm-test-isolation-proof.md`.
`bin/fm-test-isolation-proof.sh` remains the single owner of the portable candidate proof and reusable family proof harness; see `docs/fm-test-isolation-proof.md`.
Portable shard balance evidence lives in `docs/fm-test-portable-shards.md`.
Local no-mistakes Test stays intent-targeted and must not wire `commands.test` to `--all` or a `tests/*.test.sh` walk.
Family selection is the ordinary local path; `--all` is deliberate full regression only.
Expand Down
137 changes: 108 additions & 29 deletions bin/fm-test-isolation-proof.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/usr/bin/env bash
# fm-test-isolation-proof.sh - bounded concurrent isolation proof for portable
# behavior-test candidates (Phase 2 pre-shard gate).
# fm-test-isolation-proof.sh - bounded concurrent isolation proofs for portable
# behavior-test candidates and selected runner families.
#
# This is the single owner of the proven parallel candidate set, the concurrent
# proof run, and the isolation checks that admitted that set. Production
# portable CI shards and bounded local fm-test-run.sh --jobs for this exact set
# are owned by bin/fm-test-run.sh (docs/fm-test-portable-shards.md).
# This is the single owner of the proven portable candidate set, the reusable
# concurrent proof run, and its isolation checks. Production portable CI shards,
# bounded local fm-test-run.sh --jobs admission, and family worker caps are owned
# by bin/fm-test-run.sh (docs/fm-test-portable-shards.md).
#
# It does NOT:
# - compose production CI shard membership (fm-test-run.sh owns that partition)
# - run real Herdr, real default-server tmux, watcher lock races, AFK, live
# harnesses, or GUI backends
# It does NOT compose production CI shard membership; fm-test-run.sh owns that
# partition. The default portable pool excludes real Herdr, real default-server
# tmux, watcher lock races, AFK, live harnesses, and GUI backends. A named family
# pool instead runs that family's exact membership and inherits its prerequisites.
#
# Usage:
# fm-test-isolation-proof.sh [--jobs N] [--json path] [--list]
# fm-test-isolation-proof.sh [--pool <name>] [--jobs N] [--json path] [--list]
# fm-test-isolation-proof.sh --list-exclusions
# fm-test-isolation-proof.sh -h | --help
#
# Options:
# --pool NAME candidate pool: "portable" (default, this harness's own curated
# set) or a bin/fm-test-run.sh family name, to prove a stateful
# family that stays serial on CI but may earn bounded local
# concurrency. bin/fm-test-run.sh's list_concurrent_safe_families
# records which families passed.
# --jobs N max concurrent workers (default: 4; min 1)
# --json path write a machine-readable proof artifact after the run
# --list print the proven candidate paths (one per line) and exit 0
Expand Down Expand Up @@ -52,6 +57,7 @@ JOBS=4
JSON_PATH=
LIST_ONLY=0
LIST_EXCLUSIONS=0
POOL=portable

usage() {
awk '
Expand Down Expand Up @@ -219,10 +225,10 @@ global_git_snapshot() {
}

write_json_artifact() {
local out=$1 started=$2 finished=$3 run_id=$4 total=$5 failed=$6 concurrency=$7 duration=$8 records=$9
python3 - "$out" "$started" "$finished" "$run_id" "$total" "$failed" "$concurrency" "$duration" "$records" <<'PY'
local out=$1 started=$2 finished=$3 run_id=$4 total=$5 failed=$6 concurrency=$7 duration=$8 records=$9 pool=${10} jobs_enabled=${11}
python3 - "$out" "$started" "$finished" "$run_id" "$total" "$failed" "$concurrency" "$duration" "$records" "$pool" "$jobs_enabled" <<'PY'
import json, sys
out, started, finished, run_id, total, failed, concurrency, duration, records_path = sys.argv[1:10]
out, started, finished, run_id, total, failed, concurrency, duration, records_path, pool, jobs_enabled = sys.argv[1:12]
scripts = []
with open(records_path, encoding="utf-8") as fh:
for line in fh:
Expand All @@ -242,6 +248,7 @@ doc = {
"started_at": started,
"finished_at": finished,
"kind": "isolation-proof",
"pool": pool,
"concurrency": int(concurrency),
"summary": {
"total": int(total),
Expand All @@ -250,7 +257,7 @@ doc = {
},
"scripts": scripts,
"production_sharding_enabled": False,
"fm_test_run_jobs_enabled": False,
"fm_test_run_jobs_enabled": jobs_enabled == "1",
}
with open(out, "w", encoding="utf-8") as fh:
json.dump(doc, fh, indent=2, sort_keys=True)
Expand Down Expand Up @@ -278,6 +285,15 @@ while [ "$#" -gt 0 ]; do
JSON_PATH=${1#--json=}
shift
;;
--pool)
[ "$#" -gt 1 ] || die "--pool requires a name (portable, or a family name)"
POOL=$2
shift 2
;;
--pool=*)
POOL=${1#--pool=}
shift
;;
--list)
LIST_ONLY=1
shift
Expand Down Expand Up @@ -309,11 +325,41 @@ if [ "$LIST_EXCLUSIONS" -eq 1 ]; then
exit 0
fi

# The portable pool is this harness's own curated set. A family pool proves a
# stateful family that stays serial on CI but may earn bounded local
# concurrency; bin/fm-test-run.sh's list_concurrent_safe_families records which
# families passed. Membership stays empirical: a family that fails here is not
# admitted, and this harness never retries a failure into green.
pool_candidates() {
case "$POOL:$LIST_ONLY" in
portable:1)
list_parallel_candidates
;;
portable:0)
"$ROOT/bin/fm-test-run.sh" --list-scheduled --proven-isolated
;;
*:1)
"$ROOT/bin/fm-test-run.sh" --list --family "$POOL" \
|| die "--pool $POOL is not a known family (see bin/fm-test-run.sh --list-families)"
;;
*)
"$ROOT/bin/fm-test-run.sh" --list-scheduled --family "$POOL" \
|| die "--pool $POOL is not a known family (see bin/fm-test-run.sh --list-families)"
;;
esac
}

set +e
candidate_output=$(pool_candidates)
pool_rc=$?
set -e
[ "$pool_rc" -eq 0 ] || exit "$pool_rc"

CANDIDATES=()
while IFS= read -r s; do
[ -n "$s" ] || continue
CANDIDATES+=("$s")
done < <(list_parallel_candidates | LC_ALL=C sort -u)
done < <(printf '%s\n' "$candidate_output" | awk '!seen[$0]++')

if [ "$LIST_ONLY" -eq 1 ]; then
for s in "${CANDIDATES[@]+"${CANDIDATES[@]}"}"; do
Expand Down Expand Up @@ -348,14 +394,15 @@ printf 'FM_ISOLATION_BEGIN %s concurrency=%s candidates=%s\n' \
# Worker state arrays parallel to CANDIDATES indices (1-based worker labels).
declare -a WORKER_PIDS=()
declare -a WORKER_IDX=()
ACTIVE_WORKERS=0

wait_one_slot() {
local pid idx work rc duration script mode
# Wait for the oldest launched worker still recorded.
pid=${WORKER_PIDS[0]}
idx=${WORKER_IDX[0]}
WORKER_PIDS=("${WORKER_PIDS[@]:1}")
WORKER_IDX=("${WORKER_IDX[@]:1}")
local slot=$1 pid idx work rc duration script mode
pid=${WORKER_PIDS[$slot]}
idx=${WORKER_IDX[$slot]}
unset 'WORKER_PIDS[slot]'
unset 'WORKER_IDX[slot]'
ACTIVE_WORKERS=$((ACTIVE_WORKERS - 1))
set +e
wait "$pid"
set -e
Expand Down Expand Up @@ -398,6 +445,29 @@ wait_one_slot() {
esac
}

worker_pid_is_running() {
local want=$1 running inventory="$PROOF_ROOT/running-pids"
jobs -r -p >"$inventory"
while IFS= read -r running; do
[ "$running" = "$want" ] && return 0
done <"$inventory"
return 1
}

wait_one_completed_slot() {
local slot work
while :; do
for slot in "${!WORKER_PIDS[@]}"; do
work="$PROOF_ROOT/w${WORKER_IDX[$slot]}"
if [ -f "$work/out/exit" ] || ! worker_pid_is_running "${WORKER_PIDS[$slot]}"; then
wait_one_slot "$slot"
return
fi
done
sleep 0.01
done
}

idx=0
for script in "${CANDIDATES[@]}"; do
idx=$((idx + 1))
Expand Down Expand Up @@ -440,17 +510,18 @@ for script in "${CANDIDATES[@]}"; do
printf '%s\n' "$duration" >"$work/out/duration_ms"
exit 0
) &
WORKER_PIDS+=("$!")
WORKER_IDX+=("$idx")
WORKER_PIDS[idx]=$!
WORKER_IDX[idx]=$idx
ACTIVE_WORKERS=$((ACTIVE_WORKERS + 1))

# Bound concurrency.
while [ "${#WORKER_PIDS[@]}" -ge "$JOBS" ]; do
wait_one_slot
while [ "$ACTIVE_WORKERS" -ge "$JOBS" ]; do
wait_one_completed_slot
done
done

while [ "${#WORKER_PIDS[@]}" -gt 0 ]; do
wait_one_slot
while [ "$ACTIVE_WORKERS" -gt 0 ]; do
wait_one_completed_slot
done

GIT_AFTER=$(global_git_snapshot)
Expand Down Expand Up @@ -487,9 +558,17 @@ if [ -n "$JSON_PATH" ]; then
mkdir -p "$(dirname "$JSON_PATH")"
# Stable record order for the artifact.
sort -t$'\t' -k1,1 "$RECORDS" -o "$RECORDS"
jobs_enabled=0
jobs_max=0
if "$ROOT/bin/fm-test-run.sh" --list-concurrent-safe-families | grep -Fxq "$POOL"; then
jobs_max=$("$ROOT/bin/fm-test-run.sh" --concurrent-safe-family-jobs-max "$POOL")
fi
if [ "$AGG_RC" -eq 0 ] && [ "$JOBS" -gt 1 ] && [ "$JOBS" -le "$jobs_max" ]; then
jobs_enabled=1
fi
write_json_artifact "$JSON_PATH" \
"$RUN_STARTED_ISO" "$RUN_FINISHED_ISO" "$RUN_ID" \
"$TOTAL" "$FAILED" "$JOBS" "$RUN_DURATION" "$RECORDS"
"$TOTAL" "$FAILED" "$JOBS" "$RUN_DURATION" "$RECORDS" "$POOL" "$jobs_enabled"
log "wrote isolation proof artifact: $JSON_PATH"
fi

Expand Down
Loading
Loading