Conversation
SessionStart hook now queries backend DB for items assigned to the
current agent that are still open (excludes completed/cancelled via
state group check). Pending items listed as:
Pending items assigned to you (claude-code, 3 open):
#42 Review PR #193
#47 MCP prompt argument completion
Adds agentflare-backend::item::list_by_assignee_agent(conn, project_id, agent)
with a JOIN on states to filter out completed/cancelled state groups.
Graceful no-op when backend.db doesn't exist yet (first run).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughChangesPending assigned items
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SessionStart
participant BackendDB
participant ProjectResolver
participant ItemQuery
SessionStart->>BackendDB: Open backend.db
SessionStart->>ProjectResolver: Resolve project
SessionStart->>ItemQuery: Query items for current agent
ItemQuery-->>SessionStart: Return pending items
SessionStart-->>SessionStart: Append pending items section
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/hook.rs (1)
88-97: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider capping the pending-item list.
Unbounded iteration over
itemscould produce a very long session-start message for agents with many open items.♻️ Example cap
for item in &items { - lines.push(format!(" #{} {}", item.sequence_id, item.name)); + for item in items.iter().take(10) { + lines.push(format!(" #{} {}", item.sequence_id, item.name)); + } + if items.len() > 10 { + lines.push(format!(" ... and {} more", items.len() - 10)); + } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/hook.rs` around lines 88 - 97, Cap the pending-item output in the hook’s items iteration so session-start messages remain bounded for agents with many open items. Update the loop over items to emit only the configured maximum number, while preserving the existing header and formatting for the displayed entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hook.rs`:
- Around line 73-102: Replace the arbitrary project query in the pending-item
lookup with resolution of the active project from the current workspace/cwd. Use
that resolved project ID when calling list_by_assignee_agent, preserving the
existing filtering and display behavior for pending items.
---
Nitpick comments:
In `@src/hook.rs`:
- Around line 88-97: Cap the pending-item output in the hook’s items iteration
so session-start messages remain bounded for agents with many open items. Update
the loop over items to emit only the configured maximum number, while preserving
the existing header and formatting for the displayed entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0689b111-22ed-47fd-9024-053a983bdc28
📒 Files selected for processing (2)
crates/agentflare-backend/src/item.rssrc/hook.rs
- SessionStart's pending-item lookup used "SELECT id FROM projects WHERE deleted_at IS NULL ORDER BY created_at LIMIT 1" -- backend.db is a single shared database across every repo agentflare has ever touched on this machine, so with more than one project this picked an arbitrary (oldest) one instead of the current repo's, surfacing the wrong agent's pending items. Now reuses AgentflareMcp::resolve_project (made pub(crate)), the same repo-linked resolution every other item/artifact/comment call already goes through. - Cap the displayed pending-item list at 10 with a "+N more" note so an agent with a large open queue doesn't blow up the session-start message. - Fix clippy (collapsible_if via let-chains) and fmt. - Update the regression test to route project setup through the same resolve_project() call session_start_message uses internally, so it proves the actual fix instead of a lookup path that no longer matches production.
…ntic warnings in an unrelated crate. Both crates compile, clippy is clean on the changed files, and all tests pass. Implemented the dependency-cascade auto-dispatch mechanism per the spec: 1. **`crates/agentflare-backend/src/item/relations.rs`**: added `dependents_of(conn, item_id)` (reverse of `list_dependencies`) and `all_dependencies_completed(conn, item_id)` (true only when the item has ≥1 dependency and every one is in the `completed` state group; a soft-deleted dependency target counts as unsatisfied, fail-closed). 2. **`src/supervisor.rs`**: added `cascade_unblock_dependents(conn, item_id)` — for each dependent of `item_id` whose dependencies are now all completed, applies `READY_LABEL` via the existing `item::add_label` (idempotent `INSERT OR IGNORE`). Dependents with no `assignee_agent` are skipped with a loud `eprintln!` rather than silently no-op'd, per option (a) in the spec. 3. **`src/mcp_server/item.rs`**: `item_check_merge` now calls `cascade_unblock_dependents` right after `promoted` becomes true — this is the single hook point that catches both the automatic tick (`promote_merged_item`) and manual/reconciliation calls. **Tests** (8 new, all passing): - Backend: `dependents_of_finds_reverse_edges`, `all_dependencies_completed_requires_every_dependency_done`, `all_dependencies_completed_false_for_item_with_no_dependencies`. - Supervisor: labels a dependent once its only dependency completes; leaves a dependent alone with a still-open sibling dependency; skips (doesn't label) an unassigned dependent; idempotent across repeated calls. Ran `cargo test -p agentflare-backend` and `cargo test --bin agentflare -- supervisor:: item_check_merge` — all pass, no regressions in the 37 pre-existing supervisor tests. Clippy clean on both touched crates. **Concerns / judgment calls:** - Went with option (a) (require pre-existing `assignee_agent`, loud log) as recommended — unassigned dependents like #193/#194 won't auto-dispatch from this alone. - Followed the spec literally on "completed" only (not "completed or cancelled") for the all-deps-done check, even though `groom`'s existing `blocked_by_map` treats cancelled dependencies as non-blocking too. This means a dependent stuck behind a *cancelled* dependency won't be auto-unblocked by this cascade — flagging this divergence in case it's not what's wanted. - Didn't add a full `item_check_merge` end-to-end integration test (would require mocking a merged PR via git/worktree state) — coverage is at the `cascade_unblock_dependents` unit level instead, which matches the spec's test list. Agentflare-Agent: claude-code_2-1-245_agent Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking Agentflare-Item: 195-auto-dispatch-dependents-when-a-blocking
…cy-graph-driven dynamic workflows) (#621) * Clean — no warnings from `agentflare-backend`, only pre-existing pedantic warnings in an unrelated crate. Both crates compile, clippy is clean on the changed files, and all tests pass. Implemented the dependency-cascade auto-dispatch mechanism per the spec: 1. **`crates/agentflare-backend/src/item/relations.rs`**: added `dependents_of(conn, item_id)` (reverse of `list_dependencies`) and `all_dependencies_completed(conn, item_id)` (true only when the item has ≥1 dependency and every one is in the `completed` state group; a soft-deleted dependency target counts as unsatisfied, fail-closed). 2. **`src/supervisor.rs`**: added `cascade_unblock_dependents(conn, item_id)` — for each dependent of `item_id` whose dependencies are now all completed, applies `READY_LABEL` via the existing `item::add_label` (idempotent `INSERT OR IGNORE`). Dependents with no `assignee_agent` are skipped with a loud `eprintln!` rather than silently no-op'd, per option (a) in the spec. 3. **`src/mcp_server/item.rs`**: `item_check_merge` now calls `cascade_unblock_dependents` right after `promoted` becomes true — this is the single hook point that catches both the automatic tick (`promote_merged_item`) and manual/reconciliation calls. **Tests** (8 new, all passing): - Backend: `dependents_of_finds_reverse_edges`, `all_dependencies_completed_requires_every_dependency_done`, `all_dependencies_completed_false_for_item_with_no_dependencies`. - Supervisor: labels a dependent once its only dependency completes; leaves a dependent alone with a still-open sibling dependency; skips (doesn't label) an unassigned dependent; idempotent across repeated calls. Ran `cargo test -p agentflare-backend` and `cargo test --bin agentflare -- supervisor:: item_check_merge` — all pass, no regressions in the 37 pre-existing supervisor tests. Clippy clean on both touched crates. **Concerns / judgment calls:** - Went with option (a) (require pre-existing `assignee_agent`, loud log) as recommended — unassigned dependents like #193/#194 won't auto-dispatch from this alone. - Followed the spec literally on "completed" only (not "completed or cancelled") for the all-deps-done check, even though `groom`'s existing `blocked_by_map` treats cancelled dependencies as non-blocking too. This means a dependent stuck behind a *cancelled* dependency won't be auto-unblocked by this cascade — flagging this divergence in case it's not what's wanted. - Didn't add a full `item_check_merge` end-to-end integration test (would require mocking a merged PR via git/worktree state) — coverage is at the `cascade_unblock_dependents` unit level instead, which matches the spec's test list. Agentflare-Agent: claude-code_2-1-245_agent Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking Agentflare-Item: 195-auto-dispatch-dependents-when-a-blocking * cascade_unblock_dependents now inherits completed item's assignee (bare agent id) for unassigned dependents; added regression test; pre-existing unrelated test failure confirmed via baseline stash and flagged, not touched. Agentflare-Agent: claude-code_2-1-245_agent Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking Agentflare-Item: 195-auto-dispatch-dependents-when-a-blocking * style: cargo fmt cascade_unblock_dependents, allowlist supervisor_tests.rs LOC gate Agentflare-Agent: claude-code Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking Agentflare-Item: 195 Agentflare-Session: 3eedea22-3a44-4342-963d-d211427f1fea --------- Co-authored-by: shiva <shiva@gosysinfo.tech>
Auto-opened on
item donefor 019f5fa8-3c1f-7432-b8e7-edc6a41e0fa3.Summary by CodeRabbit
New Features
Tests