Run reviews and nudges on the state-driven coordinator

This commit is contained in:
Ian Gulliver
2026-10-21 12:54:34 -07:00
parent 97b71416d5
commit b4a454bab1
16 changed files with 718 additions and 567 deletions
+10 -3
View File
@@ -12,13 +12,20 @@ const cutPointTriggers = `('answer', 'fork', 'ask_human')`
const snapshotColumns = `id, task_id, agent_session_id, n, commit_sha, tree_sha, event_seq, trigger, created_at`
func (s *Store) CreateSnapshot(ctx context.Context, snap api.Snapshot, projectID string) error {
func (s *Store) CreateSnapshot(ctx context.Context, snap api.Snapshot, projectID string, review bool) error {
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
_, err := tx.ExecContext(ctx, `INSERT INTO snapshots (`+snapshotColumns+`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
snap.Id, snap.TaskId, snap.AgentSessionId, snap.N, snap.CommitSha, snap.TreeSha, snap.EventSeq, string(snap.Trigger), formatTime(snap.CreatedAt))
_, err := tx.ExecContext(ctx, `INSERT INTO snapshots (`+snapshotColumns+`, review) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,
? AND EXISTS (SELECT 1 FROM projects WHERE id = ? AND review_workflow != ''))`,
snap.Id, snap.TaskId, snap.AgentSessionId, snap.N, snap.CommitSha, snap.TreeSha, snap.EventSeq, string(snap.Trigger), formatTime(snap.CreatedAt), review, projectID)
if err != nil {
return err
}
if review {
_, err = tx.ExecContext(ctx, `UPDATE tasks SET review_requests = max(review_requests - 1, 0) WHERE id = ?`, snap.TaskId)
if err != nil {
return err
}
}
_, err = tx.ExecContext(ctx, `UPDATE tasks SET ready = '' WHERE id = ? AND ? NOT IN `+cutPointTriggers, snap.TaskId, string(snap.Trigger))
if err != nil {
return err