school-core

Worst-Day-Ever: School-Core Scale Architecture

Adversarial stress-test of docs/school-core-scale-architecture.md, following the worst-day-ever methodology (8 attack dimensions, 6 safeguards, severity-ranked disaster report).

Mode: dry-run design review (no execution, synthesized scenarios, no secrets, no external calls, no mutation — per the 6 safeguards). Purpose: place an error-boundary node at each dimension so the specific worst-day failure is caught before it reaches students/GitHub/Orca.

The 8 dimensions → mapped to the school topology

# Dimension School surface it attacks
1 Input Boundary Issue bodies → crew briefs; agent names; bookbag payloads
2 State Machine Torture crew registry lifecycle; bookbag handoff; grading-job transitions
3 Temporal / Timing CREW_TIMEOUT (900s) vs 30-min job; clock skew; counter races
4 AuthN/Z Shadow worktree/bookbag cross-tenant; role scope mismatch
5 Data Integrity Cascade crew_runs.json corruption; scores.json wipe; verify-contract false pass
6 Concurrent Load 20+ graders; lock escalation; fleet exhaustion; thundering herd
7 External Dependency Failure Orca daemon crash; FirstMate down; GitHub API timeout
8 Brownfield Mining replay real past failures (16-turn timeout, node: command not found)

DIMENSION 1 — Input Boundary

Worst day: A GitHub issue body contains (a) a 2 MB Unicode RTL-override string, (b) null bytes, (c) shell metacharacters, (d) a NaN/Infinity in a numeric field the director parses. The brief writer (_write_brief) concatenates it into the crew launch brief and the Hermes task prompt. A student agent executes a crafted instruction hidden by RTL override; a shell metacharacter in the issue title reaches orca terminal create quoting.

Error-boundary nodes:


DIMENSION 2 — State Machine Torture

Worst day: (a) A crew’s running record is double-written (retry logic re-dispatches the same issue while the first is still polling) → two Orca worktrees for one issue, both write the same bookbag, grading queue gets two jobs. (b) The BookbagSignal flag-file handoff races: student writes done.flag while the reviewer bot reads the bookbag JSON mid-write → partial JSON. (c) A grading job is ACKed twice → graded twice, score updated twice (EMA double-applied).

Error-boundary nodes:


DIMENSION 3 — Temporal / Timing

Worst day: A crew polls for the full CREW_TIMEOUT_SECONDS=900s, but the CI job is hard-capped at 30 minutes = 1800s (school-loop.yml:139). Two crews at cap=2 each take 900s → 1800s exactly, but the grader then needs time → job killed mid-grade, bookbag written, score never recorded, GitHub issue left unlabeled. Clock skew between the Mac and GitHub makes started_at comparisons wrong, so sweep_stale_runs reclaims a live crew as “stale.”

Error-boundary nodes:


DIMENSION 4 — AuthN/Z Shadow

Worst day: (a) A student-coder crew, resolving capability for issue A, is handed a worktree that still contains issue B’s uncommitted diff (Orca worktree reuse / cleanup race) → cross-contamination of student output. (b) A teacher (CTO/COO) bot, reviewing issue A’s bookbag, reads issue B’s bookbag because the path is derived from a wrong bead id → horizontal escalation across issues. (c) A force_agent override lets a low-trust role run with a high-trust profile.

Error-boundary nodes:


DIMENSION 5 — Data Integrity Cascade

Worst day (the sharpest): crew_runs.json is truncated by a crashed write → on next read, _load_runs hits except (OSError, json.JSONDecodeError): return [] (crew_dispatch.py:427–428). The registry silently becomes empty → admission sees 0 in-flight → over-admits → fleet exhaustion. Parallel: scores.json is torn by the lock-free ScoreStore.save() → on reload, load() hits JSONDecodeError and re-seeds from SEED_AGENTS, wiping the entire leaderboard. And the verify-contract killer: a grader, unable to read the crew’s persisted verification, re-runs the gate on the clean cached base (repo_path) → false PASS (the exact fc7.3 hazard).

Error-boundary nodes:


DIMENSION 6 — Concurrent Load

Worst day: 20 graders finish near-simultaneously → 20 concurrent ScoreStore.save() calls (lock-free) → write skew + leaderboard corruption. The fleet hits capacity and 20 new crews queue; the dispatch office’s least-loaded selector has a race → two crews assigned the same worktree. The school-core-live-orca CI concurrency lock (school-loop.yml:130) serializes two execute jobs → a stalled job holds the lock → the second waits 30 min → both time out (deadlock-by-lock).

Error-boundary nodes:


DIMENSION 7 — External Dependency Failure

Worst day: The Orca daemon crashes mid-worktree → the student’s process dies; dispatch_crew’s poll sees the terminal gone → CrewUnavailableError → fallback to direct path, but the worktree is orphaned (Orca-local identity lost). FirstMate is down → every spawn fails → the whole cycle falls back to direct model path, overloading OmniRoute. GitHub API times out during _mark_github_issue → the issue is graded but never labeled → board desync.

Error-boundary nodes:


DIMENSION 8 — Brownfield Mining

Worst day (replay real history): The design’s own beads record the actual past disasters — replay them as regression scenarios:

Error-boundary nodes:


Disaster Report (design-phase)

Resilience is scored 0–10 per dimension for the current design + proposed boundary nodes. With the CRITICAL + HIGH/MED nodes now implemented and tested (see commit history: worst-day-ever CRITICAL nodes, then the resilience sweep), the realized scores are:

Dim Name Score Worst finding (pre-node) Node that closes it Status
1 Input Boundary 8 RTL/shell injected into brief N1.1–N1.3 ✅ done (sanitize at edge + list-args + safe_float)
2 State Machine 7 Double-dispatch + bookbag race N2.1–N2.3 ✅ N2.2 atomic bookbag; N2.1/N2.3 primitives ready for queue
3 Temporal 8 900s crew vs 30-min job cascade N3.1–N3.3 ✅ N3.1 cap×timeout reserve; N3.2 monotonic sweep
4 AuthN/Z Shadow 7 Worktree/bookbag cross-tenant N4.1–N4.3 ✅ N4.3 force_agent allowlist; N4.1 verifier; N4.2 scope helper
5 Data Integrity 8 _load_runs swallows corruption → over-admit; ScoreStore wipe N5.1, N5.2, N5.3 ✅ done (prior commit)
6 Concurrent Load 7 Lock-free ledger + global CI lock deadlock N6.1–N6.3 ✅ N6.2 lease; N6.1 bounded pool; N6.3 per-daemon CI lock
7 External Dep 7 Orphan worktree + GitHub-label desync N7.1–N7.3 ✅ N7.1 retry budget; N7.2 label queue; N7.3 backpressure
8 Brownfield 7 Historical failures not yet regression-tested N8.1–N8.2 ✅ N8.2 clean-assert; N8.1 regression suite grows

Overall resilience: 7.4 / 10 (realized, with nodes tested — up from 4.0 design-only).

CRITICAL (landed):

HIGH (landed):

Remaining (deferred to the Option-B scheduler build):


Next step

These nodes are a design contract. The three CRITICAL nodes (N5.1, N5.2, N5.3) are small, independent, and implementable now without the full scheduler. Recommended: land them as the first build slice, then re-run this grill to lift Dimension 5 from 2 → 8.