Skip to content

fix(agent-actions): make the global kill-switch fail-open observable, not silent - #2360

Merged
JSONbored merged 1 commit into
mainfrom
claude/kill-switch-fail-closed
Jul 1, 2026
Merged

fix(agent-actions): make the global kill-switch fail-open observable, not silent#2360
JSONbored merged 1 commit into
mainfrom
claude/kill-switch-fail-closed

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

What

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.

Fix

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, in src/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 in src/ — 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

  • Both implementations: a read error emits global_kill_switch_read_error and still returns false.
  • Both implementations: an absent singleton row emits global_kill_switch_row_missing and still returns false.
  • A non-Error throw (e.g. a driver rejecting with a plain string) formats without crashing.

Full unsharded test:coverage green; typecheck green.

Advances #1936. Closes #2125.

…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.
@dosubot dosubot Bot added the size:S label Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.71%. Comparing base (ec131cf) to head (481f122).
✅ All tests successful. No failed tests found.

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           
Files with missing lines Coverage Δ
src/db/repositories.ts 96.29% <100.00%> (+<0.01%) ⬆️
src/review/ops.ts 99.18% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb

loopover-orb Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-01 12:19:16 UTC

4 files · 1 AI reviewer · no blockers · readiness 75/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The change preserves the existing fail-open value for the global agent freeze check while making the two ambiguous cases observable with structured warnings in both the repository helper and the ops health dependency. The tests cover read errors, missing singleton rows, and the non-Error throw formatting path for the ops copy, so the visible behavior matches the PR description. I do not see a reachable correctness break in the provided diff; the main remaining concern is that the two warning payload implementations can drift.

Nits — 5 non-blocking
  • nit: src/review/ops.ts:170 duplicates the warning event/message formatting from src/db/repositories.ts:2072, so future edits can make the two operator signals inconsistent again.
  • nit: test/unit/ops.test.ts:24 and test/unit/agent-action-executor.test.ts:169 should restore the console.warn spy through try/finally or an afterEach helper so a failed assertion does not leak the mock into later tests.
  • src/db/repositories.ts:2072 and src/review/ops.ts:170: consider extracting or locally mirroring a tiny shared warning payload helper so the event names and truncation behavior stay identical across both implementations.
  • test/unit/agent-action-executor.test.ts:166: add a non-Error throw assertion for isGlobalAgentFrozen too, matching the ops coverage, since the repository path now depends on errorMessage(error) formatting.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2125
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:S; 1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 67 registered-repo PR(s), 57 merged, 514 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 67 PR(s), 514 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Triage stale or unlinked PRs.
  • No action.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 1, 2026
@JSONbored JSONbored self-assigned this Jul 1, 2026
@JSONbored
JSONbored merged commit 17d70b2 into main Jul 1, 2026
12 checks passed
@JSONbored
JSONbored deleted the claude/kill-switch-fail-closed branch July 1, 2026 12:32
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

fix(agent-actions): global kill-switch fails open on a D1 read error

1 participant