Advance workflow stages from the state-driven coordinator
This commit is contained in:
@@ -16,6 +16,7 @@ type Work struct {
|
||||
StartStages []StageStart
|
||||
SettleReviews []SnapshotRef
|
||||
ReadyPrompts []ReadyPrompt
|
||||
AdvanceStages []string
|
||||
}
|
||||
|
||||
func (s *Store) Coordinate(ctx context.Context) (Work, error) {
|
||||
@@ -69,6 +70,10 @@ func (s *Store) Coordinate(ctx context.Context) (Work, error) {
|
||||
return err
|
||||
}
|
||||
work.ReadyPrompts, err = readyPrompts(ctx, tx, emit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
work.AdvanceStages, err = finishedStages(ctx, tx)
|
||||
return err
|
||||
})
|
||||
return work, err
|
||||
|
||||
@@ -260,8 +260,14 @@ func (s *Store) StageOutput(ctx context.Context, sessionID string) (string, erro
|
||||
return output, err
|
||||
}
|
||||
|
||||
func (s *Store) FinishedStages(ctx context.Context) ([]string, error) {
|
||||
return queryIDs(ctx, s.db, `SELECT id FROM agent_sessions WHERE stage_finished = 1 ORDER BY created_at`)
|
||||
func (s *Store) StageFinished(ctx context.Context, sessionID string) (bool, error) {
|
||||
finished := false
|
||||
err := s.db.QueryRowContext(ctx, `SELECT stage_finished FROM agent_sessions WHERE id = ?`, sessionID).Scan(&finished)
|
||||
return finished, err
|
||||
}
|
||||
|
||||
func finishedStages(ctx context.Context, tx *sql.Tx) ([]string, error) {
|
||||
return queryIDs(ctx, tx, `SELECT id FROM agent_sessions WHERE stage_finished = 1 AND state != 'running' ORDER BY created_at`)
|
||||
}
|
||||
|
||||
func (s *Store) ClearStage(ctx context.Context, sessionID string) error {
|
||||
|
||||
Reference in New Issue
Block a user