Commit da8e804
feat(supervisor): operator supervisor surface with signed escalation receipts (#1805)
* feat(supervisor): operator supervisor surface with signed escalation receipts
Adds `bernstein supervisor status` and `bernstein supervisor escalate`
as an operator-facing surface over the existing stalled_manager,
watchdog, and spawn_supervisor detectors. The detectors remain the
source of truth; the new command aggregates and renders.
Each escalation appends a signed receipt to the audit chain. The
receipt carries the worker id, worktree id, last N audit entries,
identity tokens, stall reason, recommended action, and the previous
chain digest. The receipt verifies offline against the install's
Ed25519 public key.
The recommended_action field is a pure function of the chain slice
at stall time (stall_reason + audit_entries + respawn_budget_remaining).
Two operators verifying the same receipt arrive at the byte-identical
recommendation. A cross-worktree fence assertion refuses receipt
assembly when the stuck session leaked into a sibling worktree's
resolution events.
The aggregator surfaces a stuck-count + oldest-stall summary line on
`bernstein status` and `bernstein fleet`. The TUI gains a
SupervisorPane that highlights stalled / parked / no-progress sessions
with the same recommended action. Worker badges learn a STUCK status
so the dashboard's existing widgets stay consistent with the pane.
Closes #1800.
Files touched:
- src/bernstein/core/orchestration/supervisor_receipt.py (new)
- src/bernstein/core/orchestration/supervisor_aggregator.py (new)
- src/bernstein/cli/commands/supervisor_cmd.py (new)
- src/bernstein/cli/main.py
- src/bernstein/cli/commands/status_cmd.py
- src/bernstein/cli/commands/fleet_cmd.py
- src/bernstein/core/lifecycle/hooks.py (worker.escalated event)
- src/bernstein/tui/status_bar.py (SupervisorPane + helpers)
- src/bernstein/tui/worker_badges.py (STUCK status)
- docs/api/supervisor.md (new)
- tests/unit/test_supervisor_receipt.py (new)
- tests/integration/test_supervisor_chain_roundtrip.py (new)
- tests/snapshot/test_supervisor_pane_snapshot.py (new)
* chore(ci): regenerate contract drift allow-lists
Auto-applied by contract-drift-autofix.yml on PR #1805.
Regenerated via scripts/regen_contract_drift.py. Refs #1273.
Source CI run: https://github.com/sipyourdrink-ltd/bernstein/actions/runs/26249756348
* fix(supervisor): address CodeRabbit must-address findings
- Validate `--reason` strips to non-empty before any state mutation in
`bernstein supervisor escalate`. A whitespace-only reason previously
passed through into the receipt body.
- Log silent-broad-exception paths in the supervisor summary helpers
(status + fleet) and in the install-fingerprint lookup so an empty
summary surfaces a cause in the orchestrator log instead of looking
identical to a healthy run.
- Refuse to silently reset the audit chain anchor when the audit log
directory exists but is unreadable. The previous fallback to the
genesis sentinel would have let a fresh receipt skip the chain head
and break the tamper-evidence guarantee.
- Switch receipt filenames to nanosecond timestamps and open the file
exclusively (``"x"``) so two escalations in the same second cannot
silently overwrite each other.
- Escape every dynamic field interpolated into the supervisor TUI
pane's Rich markup; an upstream caller passing ``[``/``]`` in a
worker id or role no longer corrupts the dashboard layout.
bot-ack: 3284009273
bot-ack: 3284009276
bot-ack: 3284009287
bot-ack: 3284009299
bot-ack: 3284009302
bot-ack: 3284009305
bot-ack: 3284009328
---------
Co-authored-by: auto-heal-fixup <auto-heal-fixup@bernstein.local>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>1 parent 2daf12b commit da8e804
15 files changed
Lines changed: 2676 additions & 0 deletions
File tree
- docs/api
- src/bernstein
- cli
- commands
- core
- lifecycle
- orchestration
- tui
- tests
- integration
- snapshot
- __snapshots__
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
140 | 170 | | |
141 | 171 | | |
142 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
184 | 187 | | |
185 | 188 | | |
186 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
187 | 195 | | |
188 | 196 | | |
189 | 197 | | |
| |||
200 | 208 | | |
201 | 209 | | |
202 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
203 | 253 | | |
204 | 254 | | |
205 | 255 | | |
| |||
0 commit comments