Skip to content

feat(agent): DB-backed global kill-switch (instant freeze, no redeploy)#1243

Merged
JSONbored merged 1 commit into
mainfrom
fix/global-freeze-killswitch
Jun 24, 2026
Merged

feat(agent): DB-backed global kill-switch (instant freeze, no redeploy)#1243
JSONbored merged 1 commit into
mainfrom
fix/global-freeze-killswitch

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Re-ports reviewbot's instant global freeze that the convergence dropped (audit §5.2). The only global brake was the env var AGENT_ACTIONS_PAUSED — which needs a Worker redeploy/secret push to flip — and the /status isFrozen field was a hardcoded false stub.

  • Adds a singleton global_agent_controls row (migration 0059) an operator flips with one SQL statement, no redeploy.
  • resolveAgentActionMode's globalPaused now folds in the DB freeze at all three call sites (the executor, the queue re-gate sweep, the MCP activation preview), so a freeze halts every agent write action within one evaluation cycle.
  • /status now reports the real freeze state (defaultOpsHealthDeps.isFrozen reads the row).
  • The read fails open (the env var remains the hard backstop) so a transient D1 hiccup can't by itself halt the fleet.

Deferred (documented): the per-PR SubmissionLock / consumer-max_concurrency piece of §5.3 is a larger Durable-Object port, and the audit rated its race refuted-to-low — the planner is deterministic and every side-effect write is an idempotent upsert keyed by repo#pr, with the merge SHA-pin from #1227 as the hard backstop. Out of scope here.

Scope

  • Backend + migration 0059_global_agent_controls.sql (contiguous); no wrangler binding change

Validation

  • npm run test:ci — full gate green; db:migrations:check OK (contiguous 0001..0059)
  • npm audit --audit-level=moderate — 0 vulnerabilities
  • New tests: DB freeze denies + clears execution; isGlobalAgentFrozen / defaultOpsHealthDeps.isFrozen report live state and fail open on a read error
  • Every changed line + branch covered (verified against merged full-suite lcov)

Safety

  • No secrets / wallets / hotkeys / trust scores / reward values; the kill-switch can only halt actions
  • No site/ / CNAME / lovable

Re-ports reviewbot's instant global freeze that the convergence dropped
(audit §5.2). The only global brake was the env var AGENT_ACTIONS_PAUSED,
which needs a Worker redeploy/secret push to flip, and the /status isFrozen
field was a hardcoded `false` stub.

Adds a singleton global_agent_controls row an operator can flip with one SQL
statement (no redeploy). The action-mode resolver now folds the DB freeze
into globalPaused at all three call sites (executor, the queue re-gate sweep,
and the MCP activation preview), so a freeze halts every agent write action
within one evaluation cycle. /status now reports the real freeze state. The
read fails OPEN (the env var remains the hard backstop) so a transient D1
hiccup can't by itself halt the fleet.

The per-PR SubmissionLock / consumer-concurrency piece of §5.3 is a larger
Durable-Object port and the audit rated its race refuted-to-low (the planner
is deterministic and all side-effect writes are idempotent upserts keyed by
repo#pr, with the merge SHA-pin from #1227 as the hard backstop); deferred.
@dosubot dosubot Bot added the size:M label Jun 24, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.96%. Comparing base (7b434b7) to head (36b474a).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1243   +/-   ##
=======================================
  Coverage   94.96%   94.96%           
=======================================
  Files         177      177           
  Lines       19783    19793   +10     
  Branches     7114     7118    +4     
=======================================
+ Hits        18787    18797   +10     
  Misses        397      397           
  Partials      599      599           
Files with missing lines Coverage Δ
src/db/repositories.ts 96.05% <100.00%> (+0.01%) ⬆️
src/mcp/server.ts 95.47% <100.00%> (ø)
src/queue/processors.ts 86.50% <100.00%> (+0.01%) ⬆️
src/review/ops.ts 99.15% <100.00%> (+0.02%) ⬆️
src/services/agent-action-executor.ts 90.47% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit da8a339 into main Jun 24, 2026
18 of 19 checks passed
@JSONbored
JSONbored deleted the fix/global-freeze-killswitch branch June 24, 2026 17:43
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
12 tasks
JSONbored added a commit that referenced this pull request Jun 24, 2026
…1247)

The readiness review for re-enabling autonomous review found two autonomous
PR-close paths that call closePullRequest DIRECTLY, bypassing the executor
chokepoint — so they honored neither the per-repo pause, the global freeze
(#1243), nor agent_dry_run:

- maybeRecloseDisallowedReopen (reopen-reclose) consulted none of them.
- The draft-dodge auto-close honored agentPaused but not the freeze or dry-run.

Both now resolve the agent action mode (the same env-brake || global-freeze ||
per-repo-pause || dry-run logic the executor uses) and gate the GitHub close on
it: paused/frozen → no action, dry-run → audit the would-be close without
touching GitHub, live → close as before. This closes the kill-switch coverage
gap (frozen=1 is now a COMPLETE stop) and makes agent_dry_run a true no-op for
these paths — a prerequisite for safely re-enabling review in dry-run first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant