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
17 changes: 15 additions & 2 deletions .agents/scripts/supervisor/ai-context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,22 @@ build_health_context() {
AND updated_at > datetime('now', '-7 days');
" 2>/dev/null || echo 0)

# Tasks failed in last 7 days
# Tasks failed in last 7 days (t1248: exclude cancelled — cancelled tasks are
# administrative cleanup, not worker failures; including them inflates the failure
# rate and causes false alarms. Cancelled tasks have their own metric row.)
Comment on lines +847 to +849

Choose a reason for hiding this comment

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

medium

The comment correctly explains the rationale, but it is verbose. Condensing it improves readability and aligns with the rule for providing a single, clear justification.

Suggested change
# Tasks failed in last 7 days (t1248: exclude cancelled — cancelled tasks are
# administrative cleanup, not worker failures; including them inflates the failure
# rate and causes false alarms. Cancelled tasks have their own metric row.)
# Tasks failed in last 7 days (t1248: exclude cancelled tasks from failure count;
# cancelled tasks are administrative cleanup, not worker failures.)
References
  1. Ensure comments provide a single, clear justification for a design choice, avoiding the presentation of multiple, potentially conflicting rationales.

local failed_7d
failed_7d=$(db "$SUPERVISOR_DB" "
SELECT COUNT(*) FROM tasks
WHERE status IN ('failed', 'cancelled')
WHERE status = 'failed'
AND updated_at > datetime('now', '-7 days');
" 2>/dev/null || echo 0)

# Tasks cancelled in last 7 days (separate from failures — cancellations are
# intentional administrative actions: orphaned tasks, superseded work, cleanup)
Comment on lines +857 to +858

Choose a reason for hiding this comment

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

medium

The comment for cancelled_7d is verbose. Shortening it while retaining clarity aligns with the rule for providing a single, clear justification.

Suggested change
# Tasks cancelled in last 7 days (separate from failures — cancellations are
# intentional administrative actions: orphaned tasks, superseded work, cleanup)
# Tasks cancelled in last 7 days (administrative actions, not worker failures)
References
  1. Ensure comments provide a single, clear justification for a design choice, avoiding the presentation of multiple, potentially conflicting rationales.

local cancelled_7d
cancelled_7d=$(db "$SUPERVISOR_DB" "
SELECT COUNT(*) FROM tasks
WHERE status = 'cancelled'
AND updated_at > datetime('now', '-7 days');
" 2>/dev/null || echo 0)

Expand All @@ -874,6 +885,7 @@ build_health_context() {
AND updated_at > datetime('now', '-7 days');
" 2>/dev/null || echo "0")

# Success rate excludes cancelled tasks (t1248: cancelled != failed)
local total_7d=$((completed_7d + failed_7d))
local success_rate="N/A"
if [[ "$total_7d" -gt 0 ]]; then
Expand All @@ -884,6 +896,7 @@ build_health_context() {
output+="| Metric | Value |\n|--------|-------|\n"
output+="| Completed (7d) | $completed_7d |\n"
output+="| Failed (7d) | $failed_7d |\n"
output+="| Cancelled (7d) | $cancelled_7d |\n"
output+="| Success rate (7d) | $success_rate |\n"
output+="| Currently queued | $queued_count |\n"
output+="| Currently blocked | $blocked_count |\n"
Expand Down
Loading