t1188: Add multi-repo TODO scanning and auto-dispatch eligibility to AI context#1801
Conversation
…I context
The AI reasoning pipeline (ai-context.sh) previously only included the
primary repo's TODO.md. Tasks from other registered repos (e.g., awardsapp)
were invisible to the AI reasoner, preventing it from proposing auto-dispatch.
Changes:
- build_ai_context() now iterates all distinct repos from the supervisor DB
and calls build_todo_context() for each, giving the AI full cross-project
visibility
- build_todo_context() header now includes the repo name for disambiguation
- New build_autodispatch_eligibility_context() function scans all repos for
open tasks without #auto-dispatch and assesses eligibility based on:
- Estimate size (>4h needs breakdown)
- Dependency blockers (blocked-by:)
- Human-action-required blocker statuses: account-needed, hosting-needed,
login-needed, api-key-needed, clarification-needed, resources-needed,
payment-needed
- The eligibility assessment is included as Section 3b in the context
snapshot, matching the 'Auto-Dispatch Eligibility Assessment' section
referenced in the reasoning prompt
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
WalkthroughThe supervisor AI context builder now aggregates TODO.md state across all registered repositories instead of just the primary, and introduces a new Auto-Dispatch Eligibility Assessment section that evaluates task candidacy based on blocker status and completion records. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Wed Feb 18 21:36:47 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.agents/scripts/supervisor/ai-context.sh (1)
67-102:⚠️ Potential issue | 🟠 MajorSection 3b runs unconditionally, producing duplicate auto-dispatch content with Section 11 in
fullscope and bloatingquickscope beyond the 50 K-token budget.Line 68 calls
build_autodispatch_eligibility_contextwith no scope guard, while the functionally overlapping Section 11 (build_auto_dispatch_eligibility_context) at line 101 is correctly guarded by[[ "$scope" == "full" ]]. The header comment on line 6 explicitly targets< 50K tokens; emitting two auto-dispatch eligibility sections forfullscope (3b + 11) directly contradicts this design constraint and risks confusing the AI reasoner with two slightly different views of the same data.Two options to resolve:
- Option A (minimal) — guard Section 3b identically to Section 11.
- Option B (preferred) — absorb the multi-repo scanning improvements from Section 3b directly into
build_auto_dispatch_eligibility_contextand remove the standalone 3b call entirely.🛡️ Quick guard fix (Option A)
# Section 3b: Auto-Dispatch Eligibility Assessment (t1188) - context+="$(build_autodispatch_eligibility_context)\n\n" + if [[ "$scope" == "full" ]]; then + context+="$(build_autodispatch_eligibility_context)\n\n" + fi🤖 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 67 - 102, Section 3b unconditionally appends an auto-dispatch block via build_autodispatch_eligibility_context causing duplication with the guarded build_auto_dispatch_eligibility_context and bloating quick scope; fix by removing the standalone call to build_autodispatch_eligibility_context and instead merge its multi-repo scanning logic into build_auto_dispatch_eligibility_context so all auto-dispatch content is produced only when [[ "$scope" == "full" ]] (alternatively, if you want a minimal change, wrap the existing context+="$(build_autodispatch_eligibility_context)\n\n" line with the same [[ "$scope" == "full" ]] guard as used for build_auto_dispatch_eligibility_context).
🧹 Nitpick comments (3)
.agents/scripts/supervisor/ai-context.sh (3)
510-511: Function name is inconsistent with the existing Section 11 counterpart.
build_autodispatch_eligibility_context(new,auto+dispatchmerged) vsbuild_auto_dispatch_eligibility_context(existing, line 1190 —auto_dispatchseparated by underscores). Both functions share a near-identical purpose; the naming divergence makes grepping and reasoning about them harder.🤖 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 510 - 511, Rename the new function build_autodispatch_eligibility_context to match the existing naming style by changing its name to build_auto_dispatch_eligibility_context; update any calls/reference sites that use build_autodispatch_eligibility_context to the new name (or add a thin forwarding alias function named build_autodispatch_eligibility_context that calls build_auto_dispatch_eligibility_context) so both implementations share the same identifier and grepable symbol; ensure tests or invocations that referenced the old name are updated to avoid duplicate definitions.
53-57: Dead code:repo_countis incremented but never used.
repo_countis declared on line 53 and incremented on line 57 but is never referenced anywhere — it carries no output, guards no condition, and contributes nothing to the context.🧹 Suggested removal
if [[ -n "$all_context_repos" ]]; then - local repo_count=0 while IFS= read -r ctx_repo; do [[ -z "$ctx_repo" || ! -d "$ctx_repo" ]] && continue context+="$(build_todo_context "$ctx_repo")\n\n" - repo_count=$((repo_count + 1)) done <<<"$all_context_repos"🤖 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 53 - 57, Remove the unused variable and its increment: delete the declaration "repo_count=0" and the line that updates "repo_count=$((repo_count + 1))" since "repo_count" is never read; leave the loop and the call to build_todo_context intact, and run a quick grep for "repo_count" to confirm there are no other references before committing.
517-517:blocker_patternuses BRE\|alternation withgrep -E; inconsistent with the ERE|used 2 lines later.
grep 'blue\|you'is BRE alternation syntax, whilegrep -E 'blue|you'is the correct ERE form. Theblocker_patternstring uses\|(line 517) and is consumed viagrep -qE(line 575), relying on a GNU grep extension that silently produces the intended alternation on Linux — but a shell script that works on a Linux machine might fail on macOS due to differences between GNU grep and BSD grep. Line 577 in the same function correctly uses bare|in an ERE pattern, making the pair inconsistent.♻️ Proposed fix — consistent ERE alternation
- local blocker_pattern="account-needed\|hosting-needed\|login-needed\|api-key-needed\|clarification-needed\|resources-needed\|payment-needed" + local blocker_pattern="account-needed|hosting-needed|login-needed|api-key-needed|clarification-needed|resources-needed|payment-needed"Also applies to: 575-575
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.agents/scripts/supervisor/ai-context.sh at line 517, The blocker_pattern variable is defined using BRE alternation backslashes ("account-needed\|...") but is later matched with grep -qE (ERE), causing inconsistent behavior across platforms; update the blocker_pattern assignment in ai-context.sh to use ERE-style alternation with plain pipes ("account-needed|hosting-needed|login-needed|api-key-needed|clarification-needed|resources-needed|payment-needed"), ensure it remains quoted where used by grep -qE, and verify the call that uses grep -qE (and any other grep -E uses) references blocker_pattern so the pattern is portable to BSD grep as well as GNU grep.
🤖 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 60-62: The conditional that checks whether repo_path is already
present in all_context_repos uses "grep -qF" which allows substring matches and
can falsely skip the primary repo; update the check to use whole-line matching
(e.g., grep -qxF) so only exact path lines match, leaving the rest of the logic
(the context+="$(build_todo_context "$repo_path")\n\n" branch) unchanged; ensure
you keep proper quoting of variables (all_context_repos and repo_path) when
modifying the grep invocation.
---
Outside diff comments:
In @.agents/scripts/supervisor/ai-context.sh:
- Around line 67-102: Section 3b unconditionally appends an auto-dispatch block
via build_autodispatch_eligibility_context causing duplication with the guarded
build_auto_dispatch_eligibility_context and bloating quick scope; fix by
removing the standalone call to build_autodispatch_eligibility_context and
instead merge its multi-repo scanning logic into
build_auto_dispatch_eligibility_context so all auto-dispatch content is produced
only when [[ "$scope" == "full" ]] (alternatively, if you want a minimal change,
wrap the existing context+="$(build_autodispatch_eligibility_context)\n\n" line
with the same [[ "$scope" == "full" ]] guard as used for
build_auto_dispatch_eligibility_context).
---
Nitpick comments:
In @.agents/scripts/supervisor/ai-context.sh:
- Around line 510-511: Rename the new function
build_autodispatch_eligibility_context to match the existing naming style by
changing its name to build_auto_dispatch_eligibility_context; update any
calls/reference sites that use build_autodispatch_eligibility_context to the new
name (or add a thin forwarding alias function named
build_autodispatch_eligibility_context that calls
build_auto_dispatch_eligibility_context) so both implementations share the same
identifier and grepable symbol; ensure tests or invocations that referenced the
old name are updated to avoid duplicate definitions.
- Around line 53-57: Remove the unused variable and its increment: delete the
declaration "repo_count=0" and the line that updates "repo_count=$((repo_count +
1))" since "repo_count" is never read; leave the loop and the call to
build_todo_context intact, and run a quick grep for "repo_count" to confirm
there are no other references before committing.
- Line 517: The blocker_pattern variable is defined using BRE alternation
backslashes ("account-needed\|...") but is later matched with grep -qE (ERE),
causing inconsistent behavior across platforms; update the blocker_pattern
assignment in ai-context.sh to use ERE-style alternation with plain pipes
("account-needed|hosting-needed|login-needed|api-key-needed|clarification-needed|resources-needed|payment-needed"),
ensure it remains quoted where used by grep -qE, and verify the call that uses
grep -qE (and any other grep -E uses) references blocker_pattern so the pattern
is portable to BSD grep as well as GNU grep.
| if ! echo "$all_context_repos" | grep -qF "$repo_path"; then | ||
| context+="$(build_todo_context "$repo_path")\n\n" | ||
| fi |
There was a problem hiding this comment.
grep -qF without -x risks a substring false-positive, silently dropping the primary repo.
grep -qF "$repo_path" matches anywhere in a line, not the full line. If the DB contains /home/user/aidevops-staging and $repo_path is /home/user/aidevops, the grep succeeds (substring match), and the primary repo's TODO.md is never included in the context — silently.
Fix: add the -x (whole-line) flag so only an exact path match counts.
🐛 Proposed fix
- if ! echo "$all_context_repos" | grep -qF "$repo_path"; then
+ if ! echo "$all_context_repos" | grep -qxF "$repo_path"; then📝 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.
| if ! echo "$all_context_repos" | grep -qF "$repo_path"; then | |
| context+="$(build_todo_context "$repo_path")\n\n" | |
| fi | |
| if ! echo "$all_context_repos" | grep -qxF "$repo_path"; then | |
| context+="$(build_todo_context "$repo_path")\n\n" | |
| fi |
🤖 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 60 - 62, The
conditional that checks whether repo_path is already present in
all_context_repos uses "grep -qF" which allows substring matches and can falsely
skip the primary repo; update the check to use whole-line matching (e.g., grep
-qxF) so only exact path lines match, leaving the rest of the logic (the
context+="$(build_todo_context "$repo_path")\n\n" branch) unchanged; ensure you
keep proper quoting of variables (all_context_repos and repo_path) when
modifying the grep invocation.



Summary
Enables the AI supervisor to see and assess tasks across all registered repos, not just the primary aidevops repo.
build_ai_context()now iterates all distinct repos from the supervisor DB and includes each repo's TODO.md state. Previously only the primary repo was visible.build_autodispatch_eligibility_context()function (Section 3b) scans all repos for open tasks without#auto-dispatchand assesses each for candidacy based on estimate size, dependencies, and blocker statuses.account-needed,hosting-needed,login-needed,api-key-needed,clarification-needed,resources-needed,payment-needed.Impact
The AI reasoner can now organically discover tasks in a managed project (and any future registered repo) and propose
propose_auto_dispatchfor eligible ones. The two-phase safety guard (propose → confirm) still applies.Testing
bash -n: syntax check passshellcheck -x -s bash: zero new violations (only pre-existing SC2004 style warnings).agents/scripts/supervisor/ai-context.sh(+140/-3 lines)Closes #1796
Summary by CodeRabbit
New Features
Improvements