Session 3 of killing-the-bash-daemon plan (/home/g/.claude/plans/
structured-baking-kazoo.md). Collapses the five-tier auto_inject_mode
ladder (off|queue_only|beacon|next_best|strategist) to binary off|on
and removes the dead complexity that protected the upper tiers.
What the modes meant (now retired):
off — manual, every dispatch is a click
queue_only — drain the queue, then stop
beacon — popup with countdown auto-pick (default for new users)
next_best — auto-fire canned template silently
strategist — Groq composes a fresh prompt from context
What "on" means now: when status:ready arrives, fire the queue head if
non-empty, else the canned next_best template. Safety rails (status:
working/blocked, blockers, no-op fuse, health/tests gate) all still
apply — being "on" doesn't override the agent's "not done" signal.
Most users only ever toggled between off and "fire when ready"; the
intermediate tiers added cognitive load without proportionate value.
DB migration applied to both local and Hetzner prod in this commit:
UPDATE beacon_settings SET auto_inject_mode = CASE WHEN
auto_inject_mode='off' THEN 'off' ELSE 'on' END
UPDATE entities SET auto_inject_mode_override = (same CASE)
ALTER TABLE ... ADD CONSTRAINT CHECK IN ('off','on')
ALTER TABLE beacon_settings ALTER COLUMN auto_inject_mode
SET DEFAULT 'on'
0 beacon_settings rows existed (both envs), 21 entities updated on
prod, 1324 on local. Constraints added cleanly.
Code deltas:
- src/config/beacon.ts — AUTO_INJECT_MODE_VALUES is ["off","on"].
LEGACY_AUTO_INJECT_MODE_VALUES + normalizeAutoInjectMode helper
kept for tolerant reads of any unmigrated row.
- src/lib/constants/control.ts — DEFAULT_AUTO_INJECT_MODE = "on".
- src/db/schema/beacon-settings.ts — default "on".
- src/lib/orchestration/dispatch-gates.ts — simplified to off/on
decision; no fall-through to a composer. Safety rails preserved.
- src/app/api/control/dispatch/route.ts — 361 → 160 LoC. Deleted
buildPrompt, callGroq, parseGroqResponse, OrangeCat fetch, the
strategist branch, and the gitBranch/recentCommits/mission
decision inputs. DispatchResult.source union dropped "groq" +
"fallback"; DispatchAction dropped "composed".
- scripts/test/dispatch-gates.ts — rewrote for binary modes;
11/11 pass.
Popup deletion (the L3 "beacon" mode's UI surface):
- src/app/beacon/{layout,[id]/{page,BeaconClient},live/{page,
BeaconLiveClient}}.tsx — the popup React tree
- src/app/api/beacon/{[id],cancel,sse,window/{hide,show}}/route.ts
— popup-specific API routes
KEPT: /api/beacon/queue (Fleet Runner uses it), /api/beacon/recent,
/api/beacon/transcribe, top-level /api/beacon/route.ts (other
consumers besides the popup import cancelActiveBeaconSessions).
UI updates (mode collapse fans through):
- AutomationPolicyControl.tsx — 2 dots not 5
- ControlFleetStatus.tsx — 2 hint strings
- ProjectCard.tsx — automation labels for off/on only
- use-project-card-actions.ts — strategist "composed" path removed
Verification: tsc clean, test:home 97/97, test:dispatch-gates 11/11,
test:control-presenter 19/19, lint clean (8 pre-existing warnings).
scripts/agent-hook-bridge.sh shows as dirty in the working tree from
earlier system-level edits today; intentionally left out of this
commit. It (and the rest of the bash scripts) gets deleted in
Session 4.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Live-incident regression. Earlier today the autopilot injected a
2000-char next_best template into the user's keystrokes mid-typing
while they were composing a message to the agent, producing garbled
text like "wtf ust happened? what is this injecSetup (run, read
outputs):...". The session handoff said status:working — which is
documented in three places as the suppression signal — but the
daemon fired anyway because nothing in the dispatch pipeline
actually read the status field.
Root cause: agent-hook-bridge.sh:autopilot_dispatch_and_inject()
extracted done/next/tests/todos/health from the session file but
not status. The dispatch route's HandoffSchema didn't include
status either. The user trusted a guarantee the code never made.
Three coordinated fixes:
1. agent-hook-bridge.sh now reads `status:` from the session file
AND counts files in ~/.claude/sessions/<P>.blockers/pending/.
Either condition (status:working OR blockerCount>0) causes the
daemon to skip the dispatch HTTP call entirely — saves a network
round-trip and surfaces the gate in daemon logs.
2. The dispatch route's HandoffSchema gains a `status` field and
the body gains `blockerCount`. Defence-in-depth: even if a
custom integration or cloud-only caller bypasses the daemon's
client-side gate, the route refuses to act on a working status
or pending blockers. Two new DispatchResult.source values
(status_gate, blocker_gate) make these refusals greppable in
logs.
3. The gate logic moves out of the route handler into a pure
helper at src/lib/orchestration/dispatch-gates.ts so the
invariants can be unit-tested without spinning up a real Next
request. 11 inline tests cover: status:working wins over every
mode; blockers beat happy-path; legacy empty status preserves
existing permissive behavior; etc. Wired into
`npm run test:dispatch-gates`.
Closes the highest-impact symptom of the strategist's broken trust
model. The user can now leave autopilot on and trust that their
status:working handoff actually stops it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>