Files
rune/scripts/factory_spawn_gate.sh
T
Nick 7b86d15e67
CI Pipeline / documentation (push) Successful in 9s
CI Pipeline / best-practices (push) Successful in 9s
CI Pipeline / rust-surface (push) Failing after 14s
CI Pipeline / go-surface (push) Failing after 17s
CI Pipeline / gitea-offline (push) Successful in 16s
Auto-version and Release / release (push) Successful in 34s
CI Pipeline / type-check (push) Failing after 45s
CI Pipeline / lint (push) Failing after 1m4s
CI Pipeline / canary (push) Failing after 2m12s
deploy / deploy (push) Failing after 15m41s
CI Pipeline / unit-tests (push) Failing after 17m4s
CI Pipeline / required-checks (push) Failing after 1s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Failing after 4s
chore(factory): commit spawn gate + verify script + ladder doc + claims
These lived untracked since 2026-10-11 — nearly lost to a stash drop.
Factory law files belong on master. Claims: 42 landed, 32 in_flight.
2026-10-13 02:06:45 +01:00

32 lines
1.2 KiB
Bash

#!/bin/bash
# factory_spawn_gate.sh — deterministic factory spawn gate.
# Answers ONE question: may a new agent spawn right now?
# EXIT 0 = yes, EXIT 1 = no (reason printed).
# Usage: factory_spawn_gate.sh
# Law: agent count NEVER relies on coordinator cognition.
MAX_AGENTS=20
MAX_UNVERIFIED=3
REPO=/mnt/workdrive/rune
# count running factory agents from the live store + worktrees
ACTIVE=$(git -C "$REPO" worktree list 2>/dev/null | grep -c "rune-wave")
# verification backlog: dichotomy commits on gitea/master without a closed contract
COVERAGE=$(cd "$REPO" && python3 scripts/dichotomy_audit.py 2>/dev/null | grep "CONTRACT-COVERAGE" | grep -oE "[0-9]+/[0-9]+" | head -1)
VERIFIED=$(echo "$COVERAGE" | cut -d/ -f1)
TOTAL=$(echo "$COVERAGE" | cut -d/ -f2)
UNVERIFIED=$((TOTAL - VERIFIED))
echo "gate: active=$ACTIVE max=$MAX_AGENTS unverified=$UNVERIFIED max=$MAX_UNVERIFIED"
if [ "$ACTIVE" -ge "$MAX_AGENTS" ]; then
echo "DENY: $ACTIVE agents active (max $MAX_AGENTS). Wait for a completion."
exit 1
fi
if [ "$UNVERIFIED" -gt "$MAX_UNVERIFIED" ]; then
echo "DENY: $UNVERIFIED unverified landings (max $MAX_UNVERIFIED). Verify first."
exit 1
fi
echo "ALLOW: spawn next queued module into a fresh worktree"
exit 0