fix(agent-actions): make the global kill-switch fail-open observable, not silent - #2360
Conversation
…e, not silent isGlobalAgentFrozen fails open (returns false / "not frozen") on a D1 read error or an absent singleton row — an intentional, already-tested tradeoff (a transient hiccup must not by itself halt the fleet). But the failure was completely silent: an operator flipping frozen=1 during an incident, while D1 happens to be degraded at that exact moment, or on a self-host instance whose singleton row was lost to a backup restore, would see "not frozen" with zero signal that the read actually failed rather than genuinely reporting unfrozen. Emit a structured warning distinguishing "confirmed unfrozen" from "read failed/row missing, assumed unfrozen" from both isGlobalAgentFrozen and the duplicate copy in the /status operator health surface (defaultOpsHealthDeps.isFrozen) — the fail-open VALUE is unchanged, only its silence is fixed. Also filed #2359: setGlobalAgentFrozen (the write side) has zero callers anywhere in src/ — there is currently no application-level way to actually flip this kill-switch, only direct SQL. Out of scope for this fix (a real admin route/MCP tool is a separate, larger addition), but worth tracking since it's the necessary next step to make the switch operable at all. Advances #1936. Closes #2125.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2360 +/- ##
=======================================
Coverage 95.71% 95.71%
=======================================
Files 222 222
Lines 24655 24661 +6
Branches 8946 8949 +3
=======================================
+ Hits 23599 23605 +6
Misses 433 433
Partials 623 623
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-01 12:19:16 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
What
isGlobalAgentFrozenfails open (returnsfalse/ "not frozen") on a D1 read error or an absent singleton row — an intentional, already-tested tradeoff (a transient hiccup must not by itself halt the fleet). But the failure was completely silent: an operator flippingfrozen=1during an incident, while D1 happens to be degraded at that exact moment, or on a self-host instance whose singleton row was lost to a backup restore, would see "not frozen" with zero signal that the read actually failed rather than genuinely reporting unfrozen.Fix
Emit a structured warning distinguishing "confirmed unfrozen" from "read failed / row missing, assumed unfrozen" from both
isGlobalAgentFrozenand the duplicate copy in the/statusoperator health surface (defaultOpsHealthDeps.isFrozen, insrc/review/ops.ts) — kept the module's existing "self-contained, no external imports" boundary by inlining the error-message extraction there rather than importing across it. The fail-open value is unchanged — only its silence is fixed.Also found (filed separately, not in this PR's scope)
While fixing this, found
setGlobalAgentFrozen(the write side) has zero callers anywhere insrc/— there is currently no application-level way to actually flip this kill-switch, only direct SQL against D1. Filed as #2359: adding a real admin route/MCP tool is a separate, larger addition (needs its own auth-gating and tests), and closing the "silent" half of this issue is valuable on its own regardless of how the flag gets set.Tests
global_kill_switch_read_errorand still returnsfalse.global_kill_switch_row_missingand still returnsfalse.Errorthrow (e.g. a driver rejecting with a plain string) formats without crashing.Full unsharded
test:coveragegreen;typecheckgreen.Advances #1936. Closes #2125.