threshold-triggered-automation.md
1 # Threshold-Triggered Automation 2 3 *proto-026 | Operational pattern for spawning agents when metrics exceed thresholds* 4 5 --- 6 7 - **principle** 8 - "When a metric exceeds a threshold, spawn an agent to address it automatically." 9 - "Don't wait for human intervention on predictable triggers." 10 11 - **shape** 12 - Define thresholds for each issue type 13 - Monitor continuously (or on-demand) 14 - When threshold crossed → spawn appropriate agent 15 - Agent runs with same safeguards as manual invocation 16 - Results flow back for review 17 18 --- 19 20 ## The Insight 21 22 Manual intervention doesn't scale. When you know: 23 1. What metric to watch 24 2. What threshold indicates action needed 25 3. What agent can address it 26 27 ...then waiting for a human to notice and act is waste. 28 29 ``` 30 MANUAL PATTERN: 31 Human notices → Human decides → Human spawns agent 32 ↑ 33 └── bottleneck, delay, missed issues 34 35 THRESHOLD-TRIGGERED PATTERN: 36 System monitors → Threshold crossed → Agent spawns automatically 37 ↓ 38 Human reviews results 39 ``` 40 41 The human still has oversight—they review results and can adjust thresholds—but the system doesn't wait. 42 43 --- 44 45 ## Implementation 46 47 ```python 48 # Threshold configuration 49 THRESHOLDS = { 50 "phoenix_update": 10, # 10+ violations = spawn fixer 51 "hygiene_check": 5, # 5+ violations = spawn fixer 52 "alignment_report": 20, # 20+ missing = spawn fixer 53 } 54 55 # Strategy per issue type 56 STRATEGIES = { 57 "phoenix_update": "infrastructure", # Build enforceable code 58 "hygiene_check": "infrastructure", 59 "alignment_report": "protocol", # Update documentation 60 } 61 62 def check_thresholds(issues_by_type: Dict) -> List[str]: 63 """Return issue types that exceed thresholds.""" 64 triggers = [] 65 for issue_type, threshold in THRESHOLDS.items(): 66 if len(issues_by_type.get(issue_type, [])) >= threshold: 67 triggers.append(issue_type) 68 return triggers 69 70 def spawn_for_triggers(triggers: List[str], issues: Dict) -> List[Agent]: 71 """Spawn agents for triggered thresholds.""" 72 agents = [] 73 for issue_type in triggers: 74 agent = create_agent( 75 issue_type=issue_type, 76 strategy=STRATEGIES[issue_type], 77 violations=issues[issue_type], 78 ) 79 agents.append(agent) 80 return agents 81 ``` 82 83 --- 84 85 ## When to Apply 86 87 | Signal | Action | 88 |--------|--------| 89 | Violation count > threshold | Spawn fixer agent | 90 | Error rate > threshold | Spawn diagnostic agent | 91 | Staleness > threshold | Spawn refresh agent | 92 | Drift > threshold | Spawn alignment agent | 93 94 **The key insight:** If you can define the threshold and the response, automate it. 95 96 --- 97 98 ## Safeguards 99 100 Automated spawning requires same safeguards as manual: 101 102 1. **Confidence decay** - Agent stops if confidence drops below threshold 103 2. **Escalation zones** - Agent escalates if unsure (doesn't guess) 104 3. **Timeout limits** - Agent can't run forever 105 4. **Result validation** - Re-check after agent completes 106 107 ``` 108 Agent spawned → Runs with safeguards → Collapses if uncertain 109 ↓ 110 Human reviews results 111 ``` 112 113 --- 114 115 ## Axiom Alignment 116 117 | Axiom | Alignment | 118 |-------|-----------| 119 | **A0 (Boundary)** | Thresholds define clear boundaries for action | 120 | **A1 (Integration)** | Automatic response integrates monitoring + action | 121 | **A3 (Navigation)** | Thresholds can be adjusted based on context | 122 | **A4 (Ergodicity)** | Prevents accumulation of issues that could compound | 123 124 --- 125 126 ## Instances 127 128 ### Positive Instance: Speed Run Fixer Spawning 129 - **Context:** Speed run found 57 phoenix violations, 23 hygiene violations 130 - **Thresholds:** phoenix > 10, hygiene > 5 131 - **Action:** Automatically created 4 fixer agents 132 - **Result:** Fixers ready to execute without human having to count violations 133 - **Outcome:** ✓ Saved manual triage, same safeguards applied 134 135 ### Positive Instance: Phoenix Hygiene Critical 136 - **Context:** LIVE-COMPRESSION.md staleness > 180 minutes 137 - **Threshold:** STALENESS_CRITICAL_MINUTES = 180 138 - **Action:** Exit code 2 (critical), blocks session start 139 - **Result:** Agent cannot proceed without addressing 140 - **Outcome:** ✓ Enforced hygiene without human remembering to check 141 142 --- 143 144 ## Related 145 146 - [[validation-loop]] - After fixer runs, validate it worked 147 - [[infrastructure-over-suggestion]] - Prefer enforceable thresholds 148 - [[transparent-automation-principle]] - System acts, human overrides 149 150 --- 151 152 *proto-026 | Threshold-Triggered Automation | 2026-01-15*