Repository navigation
Description
Summary
Design and build a continuous invariant-based testing harness for Trinity's orchestration layer, running against staging/dev. Goal: prove orchestration invariants hold 24/7 under real traffic and adversarial conditions — catching bugs like #378/#403 (phantom stale-slot failures), #407 (subprocess reaping), and #129 (orphaned executions) before users see them.
Full design: docs/testing/orchestration-invariant-catalog.md
Motivation
Recent orchestration bugs all violated obvious-in-hindsight invariants:
- bug: Execution shows Failed then Success after cleanup (race condition) #378/fix(cleanup): prevent phantom stale-slot failures via JIT re-verify (#378) #403 — "a terminal execution state must be immutable"
- bug: agent-server.py spins at ~83% CPU after claude CLI subprocess becomes defunct #407 — "every subprocess must be reapable on every exit path"
- Active watchdog: remediate stuck executions detected by monitoring #129 — "every
runningexecution maps to either an agent registry entry or a cleanup action within one cycle" - bug: Cleanup service does not fail execution records when reclaiming stale slots #219/bug: Stale slot cleanup uses fixed 20-min TTL regardless of agent timeout #226 — "slot TTL ≥ execution timeout"
Unit tests don't catch these because they live in cross-component state — Redis × SQLite × Docker × agent process registry. A continuous harness that checks invariants on a live staging instance would have caught all of them.
Proposed approach
See the full catalog in docs/testing/orchestration-invariant-catalog.md. Summary:
Framework layers (bottom-up):
- Invariant library (~55 invariants across 14 subsystems, each a pure
(snapshot) → ViolationReport) - Snapshot collector (SQL + Redis + Docker + agent registry, roughly simultaneous)
- Scenario runner (pytest-style, exercises flows + asserts invariants)
- Continuous canary (reads-only subset every 5–15 min, alerts on violation)
- Chaos layer (opt-in, container kill / Redis partition / socket lag)
Tiering: Tier A (must hold always) vs. Tier B (must reconcile within SLA T). Severity: 🔴 critical / 🟡 major / 🟢 minor.
Starting subset (Phase 1 — 10 invariants, ~80% coverage)
| ID | Invariant | Reason |
|---|---|---|
| S-01 | Slot–row bijection | Core orchestration |
| S-02 | No overbooking | Capacity |
| E-01 | Terminal-state closure | No stuck executions |
| E-02 | No phantom reversal | #378/#403 |
| E-06 | No completed-but-not-reported | #129 |
| B-01 | Queue-status coherence | Backlog integrity |
| B-02 | No queued without slots-full | Drain liveness |
| L-03 | Delete cascades | Dangling references |
| G-01 | No resource leak on restart | Recovery |
| R-01 | No zombie Claude processes | #407 |
Rollout phases
- Phase 1 — invariant library + snapshot collector + read-only canary for 10-invariant subset. Deploy to staging. Goal: catch one real bug within 30 days.
- Phase 2 — scenario runner exercising all Tier-A invariants through create/delete/trigger flows.
- Phase 3 — Hypothesis stateful testing for scenario generation.
- Phase 4 — chaos injection (Pumba / toxiproxy).
Research questions
Listed in full doc, §Open Questions. Highest-priority:
- Snapshot source-of-truth — backend API (real code path) vs. direct SQLite read (fidelity). Recommendation: API for Phase 1, direct for Phase 3+.
- Simultaneity window for snapshots across Redis/SQLite/Docker.
- Reuse vs. greenfield vs. existing
docs/testing/frameworks (MODULAR_TESTING_STRUCTURE.md,UI_INTEGRATION_TEST.md). - Staging topology — is the canary a Trinity agent on the same instance, or a separate process? (Recommend: Trinity agent — dogfoods the platform.)
Acceptance criteria
-
docs/testing/orchestration-invariant-catalog.mdreviewed and any corrections merged - Phase 1 design doc (subset of 10 invariants, snapshot format, alert channel) reviewed
-
canary_violationsDB table + snapshot-collector service implemented - First 3 invariants (S-01, E-02, L-03) running on staging continuously
- One real violation caught and alerted (or 30 days clean — inform design of Phase 2)
Non-goals (for this issue)
- Replacing unit tests
- Chaos engineering (Phase 4)
- Production deployment of harness
References
- Full catalog:
docs/testing/orchestration-invariant-catalog.md - Architectural invariants:
docs/memory/architecture.md§Architectural Invariants - Recent fixes: PRs bug: Execution shows Failed then Success after cleanup (race condition) #378, fix(cleanup): prevent phantom stale-slot failures via JIT re-verify (#378) #403, bug: agent-server.py spins at ~83% CPU after claude CLI subprocess becomes defunct #407, fix(agent-runtime): reap claude subprocess tree via process groups (#407) #410; Issues Active watchdog: remediate stuck executions detected by monitoring #129, bug: Cleanup service does not fail execution records when reclaiming stale slots #219, bug: Stale slot cleanup uses fixed 20-min TTL regardless of agent timeout #226, bug: Cleanup service misses 'skipped' executions and slow to detect no-session failures #106
Activity
docs(testing): add orchestration invariant catalog and canary harness…
docs(planning): add Tier 2.6 hardening + actor-model destination roadmap
docs(Abilityai#411): scope fleet to strict minimum for AC's 3 invariants
docs(Abilityai#411): expand design doc to cover full Phase 1 (12 inva…
docs(#411): Phase 1 canary harness design + catalog Phase 1 subset ad…
Release: v0.5.0 (#608)
feat(Abilityai#411): canary invariant harness Phase 1 (S-01, E-02, L-03)
fix(Abilityai#411): canary harness demo-driven fixes
fix(Abilityai#411): canary terminal status set must match TaskExecuti…
fix(Abilityai#411): use iso_cutoff() for E-02 terminal-row window (in…
perf(Abilityai#411): drop N+1 in run-cycle, thread row ids through Cy…
test(Abilityai#411): cover CanaryService.run_cycle orchestration
84 remaining items
Release: v0.7.0 (#1319)
vybe commentedon Jul 28, 2026
Epic-health pass 2026-07-28: closing as complete — 53/53 children done (100%). The canary/invariant backbone shipped across v0.6–v0.8.5; per the 2026-07-13 standing note this closes at the release cut (v0.8.5 released 2026-07-26). Follow-on canary work (e.g. #1813) lives under #1259.
fix(canary): wire CANARY_ENABLED/_SLACK_WEBHOOK_URL into prod backend…
fix(canary): wire CANARY_ENABLED/_SLACK_WEBHOOK_URL into prod backend…
fix(ent14): the hard kill switch was inert — wire both registry knobs…
feat(templates): serve the agent catalog from a remote registry (trin…
fix(compose): pass the community-catalog vars to the backend (ent#237) (