Skip to content

t1284: fix create_improvement dedup window + add recent fixes context#2040

Merged
marcusquinn merged 1 commit intomainfrom
feature/t1284
Feb 21, 2026
Merged

t1284: fix create_improvement dedup window + add recent fixes context#2040
marcusquinn merged 1 commit intomainfrom
feature/t1284

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 21, 2026

Summary

  • Investigated the Feb 11-12 worker hang timeouts (t311.2 x2, t311.3, t303) that triggered this task
  • Found all root causes were already fixed by t314, t1196, t1199, t1222 (merged Feb 12-18)
  • Root cause of t1284 being created: create_improvement dedup only checked tasks completed within 24h, missing t314 which was merged 9 days earlier
  • Fixed the dedup window to 30 days and added a 'Recently Fixed Issues' context section

Investigation Findings

Task Hang Root Cause Fix
t311.2, t311.3, t303 No heartbeat → log mtime stale after 1800s t1196: worker heartbeat every 300s (merged Feb 18)
t311.2, t311.3, t303 30min hung timeout too short for complex tasks t314: extended to 1h (merged Feb 12)
t311.2, t311.3, t303 No per-task timeout scaling t1199: 2x estimate-based timeout (merged Feb 18)
t311.2, t311.3, t303 Hard kill only, no graceful shutdown t1222: two-phase SIGTERM+SIGKILL (merged Feb 18)

Why t1284 was created despite all fixes being in place: The supervisor's AI reasoner saw stale failure data (8-9 days old) and the create_improvement dedup only checked tasks completed within 24h — missing t314 (merged 9 days earlier).

Changes

ai-actions.sh

  • Extended completed-task dedup window from 24h to 30 days (configurable via AI_IMPROVEMENT_DEDUP_DAYS)
  • Uses date comparison (>) instead of exact today/yesterday match
  • Prevents re-creating improvement tasks for already-fixed systemic issues

ai-context.sh

  • Added Section 12: 'Recently Fixed Systemic Issues' — shows the AI reasoner what bugfix/improvement tasks were completed in the last 30 days
  • Filters for #bugfix, #self-improvement, #automation, and hang/timeout/worker keywords
  • Placed at end of full-scope context so AI sees recent fixes before proposing new investigations

Testing

  • bash -n: PASS (both files)
  • ShellCheck: zero violations (both files)
  • Date comparison logic verified: Feb 12 correctly identified as within 30 days of Feb 21

Summary by CodeRabbit

Release Notes

  • New Features
    • Added "Recently Fixed Systemic Issues" section to AI context, improving visibility of recent improvements and reducing duplicate work.
    • Introduced configurable task deduplication window (default 30 days) to more flexibly track recently completed tasks.

…t (t1284)

Investigation findings:
- Feb 11-12 hangs (t311.2 x2, t311.3, t303) were caused by missing heartbeat (t1196),
  30min hung timeout (t314), no per-task timeout scaling (t1199), and no graceful
  SIGTERM (t1222) — all fixed by Feb 18, 6 days before t1284 was created.
- t1284 was created by the supervisor's AI reasoner looking at stale failure data
  (8-9 days old) because the create_improvement dedup only checked tasks completed
  within 24h, missing t314 which was merged 9 days earlier.

Changes:
1. ai-actions.sh: extend completed-task dedup window from 24h to 30 days
   (configurable via AI_IMPROVEMENT_DEDUP_DAYS, default 30). Uses date comparison
   instead of today/yesterday exact match. This prevents re-creating improvement
   tasks for already-fixed systemic issues.
2. ai-context.sh: add Section 12 'Recently Fixed Systemic Issues' — shows the AI
   reasoner what bugfix/improvement tasks were completed in the last 30 days so it
   can avoid proposing investigations for already-fixed problems. Filters for
   #bugfix, #self-improvement, #automation, and hang/timeout/worker keywords.
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the AI supervisor was generating redundant improvement tasks for problems that had already been resolved. This occurred because the AI's deduplication mechanism only considered fixes from the last 24 hours, causing it to miss older, but still relevant, resolutions. The changes extend this deduplication window to 30 days and introduce a new context section for the AI, ensuring it is better informed about recent systemic fixes before proposing new work.

Highlights

  • Dedup Window Extension: The create_improvement task deduplication window was extended from 24 hours to a configurable 30 days to prevent the AI from re-creating tasks for already-fixed systemic issues.
  • Dynamic Date Comparison: The logic for identifying recently completed tasks was updated to use a dynamic cutoff date based on the configured deduplication window, replacing the previous fixed "today or yesterday" check.
  • AI Context Enhancement: A new section, "Recently Fixed Systemic Issues," was added to the AI's full-scope context, providing the AI reasoner with awareness of recent bug fixes and improvements.
Changelog
  • .agents/scripts/supervisor/ai-actions.sh
    • Introduced AI_IMPROVEMENT_DEDUP_DAYS variable to configure the deduplication window for create_improvement tasks.
    • Modified the _keyword_prefilter_open_tasks function to scan completed tasks within the AI_IMPROVEMENT_DEDUP_DAYS period, replacing the fixed 24-hour window.
    • Updated date comparison logic to use a cutoff_date for filtering completed tasks.
  • .agents/scripts/supervisor/ai-context.sh
    • Integrated a call to the new build_recent_fixes_context function within build_ai_context when the scope is "full".
    • Added the build_recent_fixes_context function, which generates a markdown section detailing systemic fixes completed within the last AI_IMPROVEMENT_DEDUP_DAYS, filtering by specific keywords and task types.
Activity
  • The author investigated worker hang timeouts (t311.2, t311.3, t303) from Feb 11-12.
  • It was determined that the root causes for these timeouts were already addressed by fixes merged between Feb 12-18 (t314, t1196, t1199, t1222).
  • The reason for t1284's creation was identified as the create_improvement dedup window being too short (24h), missing t314 which was merged 9 days prior.
  • The changes were tested with bash -n and ShellCheck, both passing.
  • Date comparison logic was verified to correctly identify dates within the new 30-day window.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

Walkthrough

This pull request introduces a configurable AI_IMPROVEMENT_DEDUP_DAYS parameter (default 30 days) to replace the fixed 24-hour deduplication window, and adds a "Recently Fixed Systemic Issues" section to the AI context that surfaces recently completed systemic fixes from TODO.md within the configurable dedup window.

Changes

Cohort / File(s) Summary
Configurable Dedup Window
.agents/scripts/supervisor/ai-actions.sh
Replaces hardcoded 24-hour dedup window with configurable AI_IMPROVEMENT_DEDUP_DAYS (default 30). Updates keyword pre-filter and dedup checks to compute a cutoff date and filter completed tasks by completion date within the new window.
Recently Fixed Systemic Issues Context
.agents/scripts/supervisor/ai-context.sh
Adds build_recent_fixes_context() function to parse TODO.md, extract completed systemic fixes (matching task identifiers with markers like #bugfix, #self-improvement, #automation) completed within the dedup window, and format as markdown. Integrates into build_ai_context() when scope is "full". Function is defined multiple times within the file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • marcusquinn/aidevops#1863: Modifies dedup logic in ai-actions.sh to enhance the recently-completed-tasks filtering mechanism.
  • marcusquinn/aidevops#1607: Introduced the ai-context script and the primary build_ai_context() function that this PR now extends.
  • marcusquinn/aidevops#1969: Generalizes semantic dedup logic in ai-actions.sh to consider recently completed tasks within a broader time window.

Poem

🔄 A thirty-day window now frames what's been done,
Recent fixes surfaced so smart context can run,
Dedup grows wiser, no more hardcoded days,
Systemic issues mended in configurable ways! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the two main changes: fixing the dedup window in create_improvement and adding recent fixes context, directly matching the changeset's core objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t1284

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 34 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 21 00:27:14 UTC 2026: Code review monitoring started
Sat Feb 21 00:27:14 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 34

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 34
  • VULNERABILITIES: 0

Generated on: Sat Feb 21 00:27:17 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively addresses the issue of redundant improvement task creation by extending the deduplication window to 30 days and providing the AI reasoner with a 'Recently Fixed Issues' context section. The implementation correctly handles date comparisons and follows established portability patterns for the date command. However, several grep operations require || true guards to prevent script termination under set -e and pipefail when no matches are found. Additionally, some redundant error suppressions should be removed to align with the repository's style guide, and head -1 should be replaced with tail -1 for more robust metadata extraction.

# Only include if completed: timestamp is recent (today or yesterday)
# Only include if completed: timestamp is within the dedup window
local completed_date
completed_date=$(printf '%s' "$task_line" | grep -oE 'completed:[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1 | sed 's/completed://')

Choose a reason for hiding this comment

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

high

In a script with set -euo pipefail enabled, this command substitution will cause the script to exit if grep fails to find a match (returning exit code 1). Since the completed: field is optional or may not match the pattern, a || true guard is required to ensure the script continues. Additionally, use tail -1 instead of head -1 for robustness when extracting metadata fields, as the field might appear multiple times or be at the end of the line.

Suggested change
completed_date=$(printf '%s' "$task_line" | grep -oE 'completed:[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1 | sed 's/completed://')
completed_date=$(printf '%s' "$task_line" | grep -oE 'completed:[0-9]{4}-[0-9]{2}-[0-9]{2}' | tail -1 | sed 's/completed://' || true)
References
  1. Use || true guards for commands that may fail under set -e (grep, arithmetic) (link)
  2. In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'jq' fails on an optional lookup.
  3. 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.

while IFS= read -r task_line; do
# Only include if completed: timestamp is within the dedup window
local completed_date
completed_date=$(printf '%s' "$task_line" | grep -oE 'completed:[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1 | sed 's/completed://')

Choose a reason for hiding this comment

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

high

This pipeline will trigger a script exit under set -e and pipefail if grep returns no matches. Add || true to allow the script to proceed with an empty completed_date variable, which is already handled by the subsequent null check. Additionally, use tail -1 instead of head -1 for robustness when extracting metadata fields, as the field might appear multiple times or be at the end of the line.

Suggested change
completed_date=$(printf '%s' "$task_line" | grep -oE 'completed:[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -1 | sed 's/completed://')
completed_date=$(printf '%s' "$task_line" | grep -oE 'completed:[0-9]{4}-[0-9]{2}-[0-9]{2}' | tail -1 | sed 's/completed://' || true)
References
  1. Use || true guards for commands that may fail under set -e (grep, arithmetic) (link)
  2. 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.

fi

local task_id
task_id=$(printf '%s' "$task_line" | grep -oE 't[0-9]+(\.[0-9]+)?' | head -1)

Choose a reason for hiding this comment

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

high

Similar to the completed_date assignment, this grep operation needs a || true guard to prevent the script from crashing if a task line somehow lacks a valid ID pattern. Additionally, use tail -1 instead of head -1 for robustness when extracting metadata fields, as the field might appear multiple times or be at the end of the line.

Suggested change
task_id=$(printf '%s' "$task_line" | grep -oE 't[0-9]+(\.[0-9]+)?' | head -1)
task_id=$(printf '%s' "$task_line" | grep -oE 't[0-9]+(\.[0-9]+)?' | tail -1 || true)
References
  1. Use || true guards for commands that may fail under set -e (grep, arithmetic) (link)
  2. 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 [[ -n "$completed_date" && "$completed_date" > "$cutoff_date" ]]; then
_score_task_line "$task_line"
fi
done < <(grep -E '^\s*- \[x\] t[0-9]' "$todo_file" 2>/dev/null)

Choose a reason for hiding this comment

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

medium

The use of 2>/dev/null here is redundant because the existence of $todo_file is verified at the start of the function. Furthermore, it violates the style guide's restriction on blanket error suppression. An explicit || true guard should be used instead to handle the case where no completed tasks are found.

Suggested change
done < <(grep -E '^\s*- \[x\] t[0-9]' "$todo_file" 2>/dev/null)
done < <(grep -E '^\s*- \[x\] t[0-9]' "$todo_file" || true)
References
  1. 2>/dev/null is acceptable ONLY when redirecting to log files, not blanket suppression (link)
  2. Avoid using 2>/dev/null to suppress errors on file operations if the file's existence has already been verified by a preceding check.


found_fixes+="- **$task_id** (completed: $completed_date${pr_ref:+, $pr_ref}): $excerpt\n"
fix_count=$((fix_count + 1))
done < <(grep -E '^\s*- \[x\] t[0-9]' "$todo_file" 2>/dev/null)

Choose a reason for hiding this comment

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

medium

Remove the redundant 2>/dev/null suppression and add an explicit || true guard to handle cases where no completed tasks match the pattern, ensuring compliance with the style guide and robustness under set -e.

Suggested change
done < <(grep -E '^\s*- \[x\] t[0-9]' "$todo_file" 2>/dev/null)
done < <(grep -E '^\s*- \[x\] t[0-9]' "$todo_file" || true)
References
  1. 2>/dev/null is acceptable ONLY when redirecting to log files, not blanket suppression (link)
  2. Avoid using 2>/dev/null to suppress errors on file operations if the file's existence has already been verified by a preceding check.

coderabbitai[bot]
coderabbitai bot previously requested changes Feb 21, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
.agents/scripts/supervisor/ai-context.sh (1)

1536-1540: Keyword filter may be overly broad — common words like "fix", "worker", "dispatch" will match many non-systemic tasks.

Terms like fix, worker, supervisor, and dispatch are prevalent in this codebase's task vocabulary. A completed task like "t999 Add worker health dashboard" would match on worker even though it's not a systemic fix. This could inflate the section with noise, diluting the signal for the AI reasoner and consuming context tokens.

Consider tightening the filter to require at least one tag match (#bugfix|#self-improvement|#automation) OR a combination of symptom keywords (e.g., hang.*timeout|timeout.*hang|worker.*hang), rather than a flat OR across all terms.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/ai-context.sh around lines 1536 - 1540, The
current keyword filter in the lower_line check (using task_line -> lower_line
and grep -qE
'#bugfix|#self-improvement|#automation|fix|investigate|hang|timeout|worker|supervisor|dispatch')
is too broad; tighten it by changing the condition to accept a task only if it
matches at least one explicit tag (`#bugfix`|#self-improvement|#automation) OR a
symptom-combination pattern (e.g.,
hang.*timeout|timeout.*hang|worker.*hang|supervisor.*hang|dispatch.*hang), and
also make common single-word matches use word boundaries (e.g., \bfix\b) so
substrings don't trigger. Update the grep/regex logic that references lower_line
to implement these two alternative checks (tag OR combined-symptom) and drop the
flat OR across common words.
.agents/scripts/supervisor/ai-actions.sh (1)

487-499: Date cutoff logic is solid; minor boundary note.

The dual-fallback date computation (BSD -v → GNU -d) is correct and portable. The empty-string guard at line 490 gracefully skips the block if neither works.

One subtlety: the > comparison on line 495 is strictly greater-than, so a task completed exactly on the cutoff date is excluded. For a 30-day window this is effectively 29 days + fraction. In practice this is unlikely to matter, but worth being aware of if you ever reduce the window to a small number of days.

If you want an inclusive boundary (≥), change to:

Optional: inclusive cutoff
-			if [[ -n "$completed_date" && "$completed_date" > "$cutoff_date" ]]; then
+			if [[ -n "$completed_date" && ! "$completed_date" < "$cutoff_date" ]]; then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/ai-actions.sh around lines 487 - 499, The current
date comparison excludes tasks completed exactly on the cutoff; to make the
cutoff inclusive, change the test in the loop that checks completed_date vs
cutoff_date from a strict greater-than to a greater-or-equal comparison (replace
if [[ -n "$completed_date" && "$completed_date" > "$cutoff_date" ]]; then with
an inclusive test). For a quick fix use the Bash string-comparison operator: if
[[ -n "$completed_date" && "$completed_date" >= "$cutoff_date" ]]; then which
will include tasks completed on the cutoff date; alternatively, for robust
chronological comparison convert completed_date and cutoff_date to epoch seconds
with date -d/-v and compare numerically. Ensure the change is applied where
completed_date is extracted and _score_task_line is called.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agents/scripts/supervisor/ai-context.sh:
- Around line 1500-1512: build_recent_fixes_context currently only scans the
primary repo; update callers in build_ai_context to iterate over all registered
repos (use the existing all_context_repos variable) and invoke
build_recent_fixes_context for each repo, aggregating their outputs into Section
12 so TODO.md entries from secondary repos are included; ensure
build_recent_fixes_context still accepts a repo_path parameter (defaulting to
REPO_PATH) and preserve dedup_days handling when called multiple times.
- Around line 104-111: Update the stale inline comment in ai-context.sh (the
lines describing the create_improvement dedup window) to reflect that dedup is
no longer fixed at 24h but uses the configurable AI_IMPROVEMENT_DEDUP_DAYS
(default 30 days) as implemented in _keyword_prefilter_open_tasks in
ai-actions.sh; change the wording to mention the configurable dedup window
and/or default 30 days so the comment accurately matches the code behavior.

---

Nitpick comments:
In @.agents/scripts/supervisor/ai-actions.sh:
- Around line 487-499: The current date comparison excludes tasks completed
exactly on the cutoff; to make the cutoff inclusive, change the test in the loop
that checks completed_date vs cutoff_date from a strict greater-than to a
greater-or-equal comparison (replace if [[ -n "$completed_date" &&
"$completed_date" > "$cutoff_date" ]]; then with an inclusive test). For a quick
fix use the Bash string-comparison operator: if [[ -n "$completed_date" &&
"$completed_date" >= "$cutoff_date" ]]; then which will include tasks completed
on the cutoff date; alternatively, for robust chronological comparison convert
completed_date and cutoff_date to epoch seconds with date -d/-v and compare
numerically. Ensure the change is applied where completed_date is extracted and
_score_task_line is called.

In @.agents/scripts/supervisor/ai-context.sh:
- Around line 1536-1540: The current keyword filter in the lower_line check
(using task_line -> lower_line and grep -qE
'#bugfix|#self-improvement|#automation|fix|investigate|hang|timeout|worker|supervisor|dispatch')
is too broad; tighten it by changing the condition to accept a task only if it
matches at least one explicit tag (`#bugfix`|#self-improvement|#automation) OR a
symptom-combination pattern (e.g.,
hang.*timeout|timeout.*hang|worker.*hang|supervisor.*hang|dispatch.*hang), and
also make common single-word matches use word boundaries (e.g., \bfix\b) so
substrings don't trigger. Update the grep/regex logic that references lower_line
to implement these two alternative checks (tag OR combined-symptom) and drop the
flat OR across common words.

Comment on lines +104 to +111
# Section 12: Recently Fixed Systemic Issues (t1284)
# Shows improvement/bugfix tasks completed in the last 30 days so the AI
# reasoner doesn't re-create investigation tasks for already-fixed problems.
# The create_improvement dedup only checks 24h; this section provides broader
# awareness of recent fixes to prevent stale-data false positives.
if [[ "$scope" == "full" ]]; then
context+="$(build_recent_fixes_context "$repo_path")\n\n"
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stale comment: dedup window is no longer 24h.

Lines 107–108 state "The create_improvement dedup only checks 24h" — but this very PR updates _keyword_prefilter_open_tasks in ai-actions.sh to use AI_IMPROVEMENT_DEDUP_DAYS (default 30 days). The comment is now inaccurate.

Suggested fix
 	# Section 12: Recently Fixed Systemic Issues (t1284)
 	# Shows improvement/bugfix tasks completed in the last 30 days so the AI
 	# reasoner doesn't re-create investigation tasks for already-fixed problems.
-	# The create_improvement dedup only checks 24h; this section provides broader
-	# awareness of recent fixes to prevent stale-data false positives.
+	# Complements the create_improvement dedup window (AI_IMPROVEMENT_DEDUP_DAYS)
+	# by giving the AI reasoner visibility into recent fixes before proposing actions.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/ai-context.sh around lines 104 - 111, Update the
stale inline comment in ai-context.sh (the lines describing the
create_improvement dedup window) to reflect that dedup is no longer fixed at 24h
but uses the configurable AI_IMPROVEMENT_DEDUP_DAYS (default 30 days) as
implemented in _keyword_prefilter_open_tasks in ai-actions.sh; change the
wording to mention the configurable dedup window and/or default 30 days so the
comment accurately matches the code behavior.

Comment on lines +1500 to +1512
build_recent_fixes_context() {
local repo_path="${1:-$REPO_PATH}"
local dedup_days="${AI_IMPROVEMENT_DEDUP_DAYS:-30}"
local output="## Recently Fixed Systemic Issues (last ${dedup_days}d)\n\n"
output+="**IMPORTANT**: Do NOT create \`create_improvement\` tasks for problems listed here — they were already fixed.\n"
output+="If the same symptom recurs, check whether the fix was effective before proposing new work.\n\n"

local todo_file="${repo_path}/TODO.md"
if [[ ! -f "$todo_file" ]]; then
output+="*TODO.md not found*\n"
printf '%b' "$output"
return 0
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

build_recent_fixes_context only scans the primary repo — misses fixes in other registered repos.

build_ai_context passes only $repo_path (the primary repo) on line 110. However, Section 3 (lines 50–65) iterates over all registered repos from the supervisor DB to build TODO context. A systemic fix completed in a secondary repo's TODO.md won't appear in Section 12, creating a dedup blind spot — the exact class of problem this PR aims to fix.

Consider iterating over all registered repos the same way Section 3 does:

Sketch: multi-repo support

In build_ai_context (around line 110):

 	if [[ "$scope" == "full" ]]; then
-		context+="$(build_recent_fixes_context "$repo_path")\n\n"
+		# Include recent fixes from all registered repos (like Section 3)
+		local _fixes_ctx=""
+		if [[ -n "$all_context_repos" ]]; then
+			while IFS= read -r _fix_repo; do
+				[[ -z "$_fix_repo" || ! -d "$_fix_repo" ]] && continue
+				_fixes_ctx+="$(build_recent_fixes_context "$_fix_repo")\n\n"
+			done <<<"$all_context_repos"
+			if ! echo "$all_context_repos" | grep -qF "$repo_path"; then
+				_fixes_ctx+="$(build_recent_fixes_context "$repo_path")\n\n"
+			fi
+		else
+			_fixes_ctx="$(build_recent_fixes_context "$repo_path")\n\n"
+		fi
+		context+="$_fixes_ctx"
 	fi

Note: $all_context_repos is already populated on line 51 and would need to be accessible here (it's currently in scope since build_ai_context is one function).

Also applies to: 104-111

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/ai-context.sh around lines 1500 - 1512,
build_recent_fixes_context currently only scans the primary repo; update callers
in build_ai_context to iterate over all registered repos (use the existing
all_context_repos variable) and invoke build_recent_fixes_context for each repo,
aggregating their outputs into Section 12 so TODO.md entries from secondary
repos are included; ensure build_recent_fixes_context still accepts a repo_path
parameter (defaulting to REPO_PATH) and preserve dedup_days handling when called
multiple times.

@marcusquinn marcusquinn dismissed coderabbitai[bot]’s stale review February 21, 2026 00:48

Auto-dismissed: bot review does not block autonomous pipeline

@marcusquinn marcusquinn merged commit a6aadaa into main Feb 21, 2026
23 checks passed
@marcusquinn marcusquinn deleted the feature/t1284 branch February 21, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant