Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .agents/scripts/supervisor/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,10 @@ cmd_auto_pickup() {
continue
fi

# Skip tasks with assignee: or started: fields (t1062)
# These indicate someone is already working on the task
if echo "$line" | grep -qE '(assignee:|started:)'; then
# Skip tasks with assignee: or started: metadata fields (t1062, t1263)
# Match actual metadata fields, not description text containing these words.
# assignee: must be followed by a username (word chars), started: by ISO timestamp.
if echo "$line" | grep -qE '(assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T)'; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For performance and to reduce reliance on external processes, consider using bash's built-in regular expression matching instead of piping to grep. This avoids creating a subshell and invoking another process.

Suggested change
if echo "$line" | grep -qE '(assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T)'; then
if [[ "$line" =~ (assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T) ]]; then

log_info " $task_id: already claimed or in progress — skipping auto-pickup"
continue
fi
Expand All @@ -556,7 +557,7 @@ cmd_auto_pickup() {
local existing
existing=$(db "$SUPERVISOR_DB" "SELECT status FROM tasks WHERE id = '$(sql_escape "$task_id")';" 2>/dev/null || true)
if [[ -n "$existing" ]]; then
if [[ "$existing" == "complete" || "$existing" == "cancelled" ]]; then
if [[ "$existing" == "complete" || "$existing" == "cancelled" || "$existing" == "verified" ]]; then
continue
fi
Comment on lines +560 to 562

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and make it easier to add more statuses in the future, consider using a case statement instead of a chain of || operators.

Suggested change
if [[ "$existing" == "complete" || "$existing" == "cancelled" || "$existing" == "verified" ]]; then
continue
fi
case "$existing" in
complete|cancelled|verified) continue ;;
esac

log_info " $task_id: already tracked (status: $existing)"
Expand Down Expand Up @@ -616,9 +617,10 @@ cmd_auto_pickup() {
continue
fi

# Skip tasks with assignee: or started: fields (t1062)
# These indicate someone is already working on the task
if echo "$line" | grep -qE '(assignee:|started:)'; then
# Skip tasks with assignee: or started: metadata fields (t1062, t1263)
# Match actual metadata fields, not description text containing these words.
# assignee: must be followed by a username (word chars), started: by ISO timestamp.
if echo "$line" | grep -qE '(assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T)'; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For performance and to reduce reliance on external processes, consider using bash's built-in regular expression matching instead of piping to grep. This avoids creating a subshell and invoking another process.

Suggested change
if echo "$line" | grep -qE '(assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T)'; then
if [[ "$line" =~ (assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T) ]]; then

log_info " $task_id: already claimed or in progress — skipping auto-pickup"
continue
fi
Expand All @@ -631,7 +633,7 @@ cmd_auto_pickup() {
local existing
existing=$(db "$SUPERVISOR_DB" "SELECT status FROM tasks WHERE id = '$(sql_escape "$task_id")';" 2>/dev/null || true)
if [[ -n "$existing" ]]; then
if [[ "$existing" == "complete" || "$existing" == "cancelled" ]]; then
if [[ "$existing" == "complete" || "$existing" == "cancelled" || "$existing" == "verified" ]]; then
continue
fi
Comment on lines +636 to 638

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and make it easier to add more statuses in the future, consider using a case statement instead of a chain of || operators.

Suggested change
if [[ "$existing" == "complete" || "$existing" == "cancelled" || "$existing" == "verified" ]]; then
continue
fi
case "$existing" in
complete|cancelled|verified) continue ;;
esac

log_info " $task_id: already tracked (status: $existing)"
Expand Down Expand Up @@ -764,8 +766,8 @@ cmd_auto_pickup() {
continue
fi

# Skip tasks with assignee: or started: fields
if echo "$sub_line" | grep -qE '(assignee:|started:)'; then
# Skip tasks with assignee: or started: metadata fields (t1263)
if echo "$sub_line" | grep -qE '(assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T)'; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For performance and to reduce reliance on external processes, consider using bash's built-in regular expression matching instead of piping to grep. This avoids creating a subshell and invoking another process.

Suggested change
if echo "$sub_line" | grep -qE '(assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T)'; then
if [[ "$sub_line" =~ (assignee:[a-zA-Z0-9_-]+|started:[0-9]{4}-[0-9]{2}-[0-9]{2}T) ]]; then

log_info " $sub_id: already claimed or in progress — skipping subtask pickup"
continue
fi
Expand Down
Loading