fix(sqlite): add missing agent fields to scanIssues and related queries (#1176)
The scanIssues() function and multiple SQL queries were not selecting or scanning agent-related fields (hook_bead, role_bead, agent_state, last_activity, role_type, rig, mol_type) and time-based scheduling fields (due_at, defer_until). This caused bd list --json to return null for last_activity even when the database contained valid timestamps, preventing proper agent health monitoring. Updated files: - dependencies.go: scanIssues() variable declarations, scan calls, assignments - queries.go: SearchIssues query - labels.go: GetIssuesByLabel query - ready.go: GetReadyWork and GetNewlyUnblockedByClose queries - transaction.go: GetIssue query, SearchIssues query, scanIssueRow() Fixes steveyegge/beads#1175
This commit is contained in:
@@ -332,7 +332,9 @@ func (t *sqliteTxStorage) GetIssue(ctx context.Context, id string) (*types.Issue
|
||||
compaction_level, compacted_at, compacted_at_commit, original_size, source_repo, close_reason,
|
||||
deleted_at, deleted_by, delete_reason, original_type,
|
||||
sender, ephemeral, pinned, is_template, crystallizes,
|
||||
await_type, await_id, timeout_ns, waiters
|
||||
await_type, await_id, timeout_ns, waiters,
|
||||
hook_bead, role_bead, agent_state, last_activity, role_type, rig, mol_type,
|
||||
due_at, defer_until
|
||||
FROM issues
|
||||
WHERE id = ?
|
||||
`, id)
|
||||
@@ -1261,7 +1263,9 @@ func (t *sqliteTxStorage) SearchIssues(ctx context.Context, query string, filter
|
||||
compaction_level, compacted_at, compacted_at_commit, original_size, source_repo, close_reason,
|
||||
deleted_at, deleted_by, delete_reason, original_type,
|
||||
sender, ephemeral, pinned, is_template, crystallizes,
|
||||
await_type, await_id, timeout_ns, waiters
|
||||
await_type, await_id, timeout_ns, waiters,
|
||||
hook_bead, role_bead, agent_state, last_activity, role_type, rig, mol_type,
|
||||
due_at, defer_until
|
||||
FROM issues
|
||||
%s
|
||||
ORDER BY priority ASC, created_at DESC
|
||||
@@ -1316,6 +1320,17 @@ func scanIssueRow(row scanner) (*types.Issue, error) {
|
||||
var awaitID sql.NullString
|
||||
var timeoutNs sql.NullInt64
|
||||
var waiters sql.NullString
|
||||
// Agent fields
|
||||
var hookBead sql.NullString
|
||||
var roleBead sql.NullString
|
||||
var agentState sql.NullString
|
||||
var lastActivity sql.NullTime
|
||||
var roleType sql.NullString
|
||||
var rig sql.NullString
|
||||
var molType sql.NullString
|
||||
// Time-based scheduling fields
|
||||
var dueAt sql.NullTime
|
||||
var deferUntil sql.NullTime
|
||||
|
||||
err := row.Scan(
|
||||
&issue.ID, &contentHash, &issue.Title, &issue.Description, &issue.Design,
|
||||
@@ -1326,6 +1341,8 @@ func scanIssueRow(row scanner) (*types.Issue, error) {
|
||||
&deletedAt, &deletedBy, &deleteReason, &originalType,
|
||||
&sender, &wisp, &pinned, &isTemplate, &crystallizes,
|
||||
&awaitType, &awaitID, &timeoutNs, &waiters,
|
||||
&hookBead, &roleBead, &agentState, &lastActivity, &roleType, &rig, &molType,
|
||||
&dueAt, &deferUntil,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to scan issue: %w", err)
|
||||
@@ -1407,6 +1424,35 @@ func scanIssueRow(row scanner) (*types.Issue, error) {
|
||||
if waiters.Valid && waiters.String != "" {
|
||||
issue.Waiters = parseJSONStringArray(waiters.String)
|
||||
}
|
||||
// Agent fields
|
||||
if hookBead.Valid {
|
||||
issue.HookBead = hookBead.String
|
||||
}
|
||||
if roleBead.Valid {
|
||||
issue.RoleBead = roleBead.String
|
||||
}
|
||||
if agentState.Valid {
|
||||
issue.AgentState = types.AgentState(agentState.String)
|
||||
}
|
||||
if lastActivity.Valid {
|
||||
issue.LastActivity = &lastActivity.Time
|
||||
}
|
||||
if roleType.Valid {
|
||||
issue.RoleType = roleType.String
|
||||
}
|
||||
if rig.Valid {
|
||||
issue.Rig = rig.String
|
||||
}
|
||||
if molType.Valid {
|
||||
issue.MolType = types.MolType(molType.String)
|
||||
}
|
||||
// Time-based scheduling fields
|
||||
if dueAt.Valid {
|
||||
issue.DueAt = &dueAt.Time
|
||||
}
|
||||
if deferUntil.Valid {
|
||||
issue.DeferUntil = &deferUntil.Time
|
||||
}
|
||||
|
||||
return &issue, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user