Files
loki/drizzle/0009_project_states_session_status.sql
T
g-but 15af9d93ea feat(db): add session_status column to project_states (migration 0009)
Completes scope cut #1 from yesterday's 27f31cb commit. The auto-inject
gate now reads status from project_states server-side (not just from
raw session.md content in the beacon), so the cloud /control flow
surfaces the agent's lifecycle state end-to-end.

Plumbing:
  • src/db/schema/project-states.ts — sessionStatus column declared
    (text, nullable). Position: before sessionDone so the SELECT row
    shape reads top-down as status → done → next → ... → health.
  • drizzle/0009_project_states_session_status.sql — idempotent
    ADD COLUMN IF NOT EXISTS. Apply with drizzle-kit push (no
    auto-runner; matches the 0001-0008 pattern).
  • src/app/api/control/route.ts — both upsertProjectState callsites
    (mtime-advanced + bootstrap) now persist session.status.
  • src/app/api/control/stream/route.ts — SSE row construction reads
    r.sessionStatus into session.status alongside the other fields.
  • src/app/api/project-states/[key]/route.ts — PATCH body schema +
    upsert object both accept sessionStatus for the daemon's push.

Migration safety:
  • Column is nullable + new — existing rows get NULL.
  • The auto-inject gate treats NULL/undefined as suppress (matches
    the user's stated default: only fire on explicit 'ready').
  • Idempotent SQL — re-applying the migration won't error.

Apply on production: \`DATABASE_URL=<neon> npx drizzle-kit push\` (or
the user's preferred migration runner).

tsc clean, npm run test:home 82/82.

Scope cut #2 remains queued: agent-hook-bridge.sh:emit_worker_finished
including session_status in worker.finished events (user denied prior
edits 3x — happy to ship if they want or leave it for them to land).
2026-05-20 09:47:42 +02:00

14 lines
675 B
SQL

-- Add session_status column to project_states.
--
-- Mirrors the new 'status' field in the canonical handoff format
-- (src/lib/orchestration/contract.ts:ORCHESTRATION_TASK_SUMMARY_FIELDS).
-- Value space: 'ready' | 'working' | NULL. The auto-inject gates in
-- src/hooks/use-project-card-actions.ts and src/app/beacon/[id]/BeaconClient.tsx
-- only fire when status === 'ready'; anything else (NULL included) suppresses.
--
-- Idempotent — `ADD COLUMN IF NOT EXISTS` lets the migration run more than
-- once without erroring if the column already exists on a partially-migrated
-- environment.
ALTER TABLE "project_states" ADD COLUMN IF NOT EXISTS "session_status" text;