Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .agents/scripts/supervisor/ai-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ _compute_target_state_hash() {
local started
started=$(printf '%s' "$task_line" | grep -oE 'started:[^ ]+' || echo "")
local blocked
blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' || echo "")
blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' || echo "")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field.

Suggested change
blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' || echo "")
blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9.,]+' || echo "")

local pr_field
pr_field=$(printf '%s' "$task_line" | grep -oE 'pr:#[0-9]+' || echo "")
# t1285: Include [proposed:...] annotations in state hash so
Expand Down
2 changes: 1 addition & 1 deletion .agents/scripts/supervisor/ai-context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ build_todo_context() {
if [[ -n "$task_id" ]] && echo "$_db_done_ids" | grep -qxF "$task_id"; then
continue
fi
blocker=$(echo "$line" | grep -oE 'blocked-by:[^ ]+' | head -1)
blocker=$(echo "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field. Additionally, for robustness when extracting metadata fields, tail -1 should be used instead of head -1.

Suggested change
blocker=$(echo "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1)
blocker=$(echo "$line" | grep -oE 'blocked-by:t[0-9.,]+' | tail -1)
References
  1. When extracting metadata fields from a line using 'grep' and 'sed' in shell scripts, use 'tail -1' instead of 'head -1' to ensure robustness, especially when the field might appear multiple times or be at the end of the line.

output+="- $task_id ($blocker)\n"
done <<<"$blocked_tasks"
fi
Expand Down
5 changes: 3 additions & 2 deletions .agents/scripts/supervisor/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,10 @@ is_task_blocked() {
local task_line="$1"
local todo_file="$2"

# Extract blocked-by: field
# Extract blocked-by: field — require value to start with a task ID (tNNN)
# to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions
local blocked_by
blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' | sed 's/blocked-by://' || true)
blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field.

Suggested change
blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true)
blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9.,]+' | sed 's/blocked-by://' || true)

Comment on lines +392 to +395
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Harden blocked‑by parsing to ignore backtick‑quoted inline code

Line 395 can still match blocked-by:t123 inside inline code because the pattern doesn’t require a whitespace/start boundary and allows trailing punctuation. That can reintroduce false blockers. Consider anchoring on whitespace/start and limiting to comma‑separated task IDs; apply the same pattern across the other updated scripts for consistency.

🔧 Suggested regex tightening
- blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true)
+ blocked_by=$(printf '%s' "$task_line" |
+   grep -oE '(^|[[:space:]])blocked-by:t[0-9]+(\.[0-9]+)*(,[[:space:]]*t[0-9]+(\.[0-9]+)*)*' |
+   sed -E 's/^[[:space:]]*blocked-by://' || true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Extract blocked-by: field — require value to start with a task ID (tNNN)
# to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions
local blocked_by
blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' | sed 's/blocked-by://' || true)
blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true)
# Extract blocked-by: field — require value to start with a task ID (tNNN)
# to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions
local blocked_by
blocked_by=$(printf '%s' "$task_line" |
grep -oE '(^|[[:space:]])blocked-by:t[0-9]+(\.[0-9]+)*(,[[:space:]]*t[0-9]+(\.[0-9]+)*)*' |
sed -E 's/^[[:space:]]*blocked-by://' || true)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/cron.sh around lines 392 - 395, The current
extraction for blocked_by can match backtick-quoted inline code and trailing
punctuation; update the grep/sed pattern used to populate blocked_by (the
variable derived from task_line) to require a start-or-whitespace boundary
before "blocked-by:" (e.g. (^|[[:space:]])blocked-by:) and to only capture one
or more comma-separated task IDs that strictly match t[0-9]+ with a clear end
boundary (comma, whitespace or end-of-string) so punctuation/backticks are
excluded; apply the identical tightened regex logic to the other scripts you
modified to keep parsing consistent.


if [[ -z "$blocked_by" ]]; then
return 1 # No dependencies — not blocked
Expand Down
2 changes: 1 addition & 1 deletion .agents/scripts/supervisor/sanity-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ _execute_sanity_action() {
local current_line
current_line=$(sed -n "${line_num}p" "$todo_file")
local blocked_by
blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:[^ ]+' | head -1 | sed 's/blocked-by://' || echo "")
blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field. Additionally, for robustness when extracting metadata fields, tail -1 should be used instead of head -1.

Suggested change
blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "")
blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:t[0-9.,]+' | tail -1 | sed 's/blocked-by://' || echo "")
References
  1. When extracting metadata fields from a line using 'grep' and 'sed' in shell scripts, use 'tail -1' instead of 'head -1' to ensure robustness, especially when the field might appear multiple times or be at the end of the line.


if [[ -z "$blocked_by" ]]; then
echo "no blocked-by field found"
Expand Down
2 changes: 1 addition & 1 deletion .agents/scripts/supervisor/todo-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ auto_unblock_resolved_tasks() {

# Extract blocked-by dependencies
local blocked_by=""
blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:[^ ]+' | head -1 | sed 's/blocked-by://' || echo "")
blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field. Additionally, for robustness when extracting metadata fields, tail -1 should be used instead of head -1.

Suggested change
blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "")
blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:t[0-9.,]+' | tail -1 | sed 's/blocked-by://' || echo "")
References
  1. When extracting metadata fields from a line using 'grep' and 'sed' in shell scripts, use 'tail -1' instead of 'head -1' to ensure robustness, especially when the field might appear multiple times or be at the end of the line.

[[ -z "$blocked_by" ]] && continue

# Check each blocker
Expand Down
Loading