prospector/migrations/0015_draft_actor.sql
Natalie 61a1005f28
Some checks failed
CI / verify (push) Failing after 3m49s
feat(draft-mode): DRAFT runner mode stages replies for operator review
Add a 'DRAFT' ProspectorMode trust-ramp between PAUSE and GO/AWAY: the
runner actively drafts but nothing auto-sends. When Gate-2 would allow a
send, advanceDraft parks the rendered body as a new 'pending_review' task
(actor-tagged 'runner') instead of enqueuing the send child; GO/AWAY keep
auto-send, PAUSE and Gate-2 holds behave as before. The inbound webhook
respects DRAFT too — a sendable decision routes into the work queue rather
than dispatching inline.

- prospector-settings: add DRAFT to ProspectorMode + PROSPECTOR_MODES
- prospector-task: add 'pending_review' status (non-terminal) + actor column
- prospect-draft: add actor (human|agent|runner) + DraftActor type
- task-state: legal transitions for pending_review
- advancement: DRAFT gate, markStatus pending_review handling, thread actor
  through insertTask and the audit record on dispatch
- audit: persist actor on the decision row
- migration 0015: actor on prospect_drafts + prospector_tasks, pending_review idx
- co-located tests for the mode gate (DRAFT/GO/PAUSE)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 11:40:26 -04:00

21 lines
1.1 KiB
SQL

-- Draft Mode actor attribution (plan §3). Adds `actor` to both the decision
-- audit trail (prospect_drafts) and the work queue (prospector_tasks):
-- * prospect_drafts.actor — who authored/authorized the recorded decision:
-- 'runner' (AFK auto-runner, the default), 'human' (operator approve/edit
-- via the review endpoints), 'agent' (MCP coworker).
-- * prospector_tasks.actor — who staged this unit of work; threaded into the
-- prospect_drafts.actor audit row on dispatch (NULL = the auto-runner).
-- Also introduces the `pending_review` task status (no enum/check constraint —
-- status is plain TEXT, validated in the app's pure state machine).
ALTER TABLE prospect_drafts
ADD COLUMN IF NOT EXISTS actor TEXT NOT NULL DEFAULT 'runner';
ALTER TABLE prospector_tasks
ADD COLUMN IF NOT EXISTS actor TEXT;
-- The review queue reads `WHERE status = 'pending_review'`; index it alongside
-- the existing status/created composite usage.
CREATE INDEX IF NOT EXISTS idx_prospector_tasks_pending_review
ON prospector_tasks (queued_at)
WHERE status = 'pending_review';