Schema migration + round-start/instruction-query runner endpoint #427

Closed
opened 2026-08-18 18:31:31 +00:00 by jared · 1 comment
Owner

#427 Schema migration + round-start/instruction-query runner endpoint

(open)

@jared created 2026-08-18 14:31

#427 Schema migration + round-start/instruction-query runner endpoint

(open)

@jared created 2026-08-18 14:31

Parent

#425
Map: #425

What to build

A Sequel migration on the existing per-project runner SQLite database adding
implementations, agents, and handoffs tables and extending dispatches with
received/created handoff FKs and lifecycle timestamps, plus a new Thor
command on the runner CLI that opens a round (creating an implementation
row, stamping abandoned_at on any prior unfinished implementation for the
session) and answers instruction queries from derived state. The query path
is idempotent: repeated queries never create dispatch rows or mutate state
(query/command split — today's advance path creates Dispatch rows
unconditionally). One JSON object on stdout; usage errors exit 3, matching
existing runner CLI conventions. State contract: implementation active when
completed_at and abandoned_at are both null; latest row per session is
current; an event state cannot explain fails loudly per ADR-0108.

Acceptance criteria

[ ] migration applies cleanly to an existing runner DB
[ ] CLI tests (Thor commands + synthetic JSON in, emitted JSON + SQLite rows
asserted — the single test seam) cover round open, prior-round abandonment,
idempotent re-query, and the loud-stall response
[ ] no hooks changed yet

Blocked by

#426

Origin

• Trigger: /to-tickets skill on #425 spec
• Improvised this session: none
• Chain: #425 (DESIGN — spec of #425) ← decomposed via /to-tickets user
approval 2026-08-18
• Root candidate: none (this is a decomposition task)

# #427 Schema migration + round-start/instruction-query runner endpoint (open) @jared created 2026-08-18 14:31 # #427 Schema migration + round-start/instruction-query runner endpoint (open) @jared created 2026-08-18 14:31 ## Parent #425 Map: #425 ## What to build A Sequel migration on the existing per-project runner SQLite database adding implementations, agents, and handoffs tables and extending dispatches with received/created handoff FKs and lifecycle timestamps, plus a new Thor command on the runner CLI that opens a round (creating an implementation row, stamping abandoned_at on any prior unfinished implementation for the session) and answers instruction queries from derived state. The query path is idempotent: repeated queries never create dispatch rows or mutate state (query/command split — today's advance path creates Dispatch rows unconditionally). One JSON object on stdout; usage errors exit 3, matching existing runner CLI conventions. State contract: implementation active when completed_at and abandoned_at are both null; latest row per session is current; an event state cannot explain fails loudly per ADR-0108. ## Acceptance criteria [ ] migration applies cleanly to an existing runner DB [ ] CLI tests (Thor commands + synthetic JSON in, emitted JSON + SQLite rows asserted — the single test seam) cover round open, prior-round abandonment, idempotent re-query, and the loud-stall response [ ] no hooks changed yet ## Blocked by #426 ## Origin • Trigger: /to-tickets skill on #425 spec • Improvised this session: none • Chain: #425 (DESIGN — spec of #425) ← decomposed via /to-tickets user approval 2026-08-18 • Root candidate: none (this is a decomposition task)
Author
Owner

Resolution

Done: Inline Sequel migration adds implementations (session_id, completed_at, abandoned_at), agents (name), handoffs tables and extends dispatches with received_handoff_id/created_handoff_id FKs + dispatched_at/completed_at, all via existing create_table?/ensure_column! mechanism so pre-existing DBs migrate cleanly. New Thor commands round-open (creates implementation row, stamps abandoned_at on prior unfinished round for the session) and next (pure idempotent instruction query from derived state — never creates dispatch rows or mutates; UnexplainedStateError stalls loudly, exit 3, per ADR-0108/0128). No hooks changed. Built TDD at the agreed CLI seam.

Evidence: commit 237d16c; tests: db_migration_test 4 runs/16 assertions, cli_round_open_test 4/9, cli_next_instruction_test 3/6, all green; rubocop clean on touched files (cli.rb:78 MethodLength offense pre-exists on main in untouched code)

Follow-ups: none — wiring agents/handoffs rows and the new dispatch columns is already scoped to later chain tickets (#428+); pre-existing recovery_status/tea_tracker individual-run NameErrors predate this change and are out of map scope

## Resolution **Done:** Inline Sequel migration adds implementations (session_id, completed_at, abandoned_at), agents (name), handoffs tables and extends dispatches with received_handoff_id/created_handoff_id FKs + dispatched_at/completed_at, all via existing create_table?/ensure_column! mechanism so pre-existing DBs migrate cleanly. New Thor commands round-open (creates implementation row, stamps abandoned_at on prior unfinished round for the session) and next (pure idempotent instruction query from derived state — never creates dispatch rows or mutates; UnexplainedStateError stalls loudly, exit 3, per ADR-0108/0128). No hooks changed. Built TDD at the agreed CLI seam. **Evidence:** commit 237d16c; tests: db_migration_test 4 runs/16 assertions, cli_round_open_test 4/9, cli_next_instruction_test 3/6, all green; rubocop clean on touched files (cli.rb:78 MethodLength offense pre-exists on main in untouched code) **Follow-ups:** none — wiring agents/handoffs rows and the new dispatch columns is already scoped to later chain tickets (#428+); pre-existing recovery_status/tea_tracker individual-run NameErrors predate this change and are out of map scope
jared closed this issue 2026-08-18 19:31:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#427
No description provided.