A review of the queue, the turn loop and the consent gates found 29 ways a
run could go silent, act on nobody's word, or lose what it produced. Each
one is fixed here.
Stuck and lost work:
- A task claim took three jobs for one computer, so every task slot sat
waiting in `computer_lock` behind the one running, and replies stalled
with them. A claim now takes one job per computer and skips a computer
that already has one (`claim-bot-jobs`).
- A send stored the prompt and then enqueued in the same try: a throw left
a message with no job behind it, so the thinking row stayed up for good.
The insert, the enqueue (which deletes the message if it fails), the
attachments and the push are now separate steps, and `client_id` makes a
resend idempotent instead of posting the prompt twice.
- `open_jobs` in the catch-up read tells the thread whether a reply is
still to come, so a job that ends without a message can't leave the row
up (`grab-session-open-replies`, `useReplyCatchUp`).
- A completed job inserted its answer after marking itself done: a throw
lost it, with no notice. The answer lands first (and is taken back if
the completion fails), and nothing in the way of clearing up can lose it.
- A failed plan step left the plan active with nothing to advance it: it
is paused now (`pause-failed-plan-step`).
- Deleting a bot left its open crew requests `working` forever, costing
the asker its cap: they end with a reason and wake the asker
(`end-asks-for-bot`).
- A deferral refunded the attempt even when the run had spent real tool
work; cancelBotJob failed a possibly-running job without aborting it or
fixing the face; a face stayed `working` while only pending jobs were
left; a failed row with no bot was rescanned every poll. All four are
fixed, and the face now has one place that decides it
(`bot-face-after-job`, `answering-ask-face` keeps a crew request's
answer on show).
Acting without consent:
- `set_workspace_computer` was the one workspace mutation with no role
check.
- Any run could rewrite a bot's core instructions and core memory: those
are the admin's now, and a refusal says what to use instead.
- Schedules and irreversible crew deletion are off for a hook call (whose
payload is someone else's words) and for any run nobody is following.
- A hidden session no longer gets secret cards or questions nobody can
answer; `can_ask` checks `isHiddenSession` too.
- Answering a secret card no longer closes it on a swallowed failure: the
user gets a button that sends the bot the message it never got.
- Redaction skipped values under four characters, and `read_message_usage`
answered for any job id, not the run's own session.
Silently lost or wasted work in the loop:
- A reply is cleaned before review (unresolved `[setting:]` refs, app
record lines, work claims), and a refused closing tool or a card with no
text no longer ends the run on a sentence that promises something that
isn't there.
- The wrap up no longer marks a message answered, a session carry-over
takes queued replies with it, and a trimmed remembered result is read
again instead of answered with "its output is above".
- An oversized newest result is cut last instead of sent whole, an empty
answer fails with a reason rather than an empty bubble, orphan question
cards are deleted, a reply that ran out of steps marks its task
exhausted, and a throwing review is logged instead of swallowed.
AGENTS.md's two drifted lines are corrected (the crew request's face and
the task run's `can_ask`).
Verification: bun run typecheck clean; bun run test 2117 pass, 0 fail.