Repository navigation
chore: CLI: agentflare item approve-plan <id> — human-only route for plan_approver=human items - #778
Conversation
…t approves a pending plan. It is not committed, and I did not smoke-test the built binary.
**What changed**
- **`src/cli/item.rs`:** the new `ApprovePlan { id }` subcommand takes the item id positionally (`#1` or UUID). It first runs the same `agent_detector::agent_name()` check as `agentflare work`. If it detects an AI agent, it prints a "human-only" error and exits 1. Otherwise it calls the existing `item_approve_plan_via_channel`, the route the Telegram Approve tap already uses. It prints the JSON result, or exits 1 on error, for example if the plan isn't pending.
- **Tests:** the denial logic is a small pure function, `approve_plan_denial`, with two unit tests (agent denied, human allowed).
- **`src/mcp_server/item.rs`:** the public `approve_plan` refusal now also points to `agentflare item approve-plan <id>`. I updated the doc comment on `item_approve_plan_via_channel`, which had said its only caller was Telegram.
**Verification (all run in the foreground)**
- `cargo test --bin agentflare cli::item` passed 2/2.
- `cargo test --bin agentflare plan` passed 27/27. That covers the existing plan-gate tests, including `channel_approve_plan_succeeds_for_a_human_approver_item` and `public_approve_plan_refuses_a_human_approver_item`, plus the Telegram callback tests.
- `cargo fmt --all --check` is clean.
- `cargo clippy --locked --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic` is clean.
**Concerns**
- I did not run the built binary. I only ran `cargo test`, so the argument parsing has not been exercised end to end. The compile is verified, but the live "refused under an agent" run is not.
- I did not run the full `cargo test --workspace`. I only ran the targeted tests above.
- Agent detection is best-effort process and env sniffing, like `agentflare work`. It is a guard against accidental self-approval, not a hard security boundary.
- On success the `plan_approved_by` field records the `AGENTFLARE_AGENT` identity, whatever `AgentflareMcp::default()` resolves to. It is not a separate "human" marker.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Repository: getappz/agentflare/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: getappz/agentflare/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (2)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughChangesPlan approval
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Human
participant ItemArgs
participant MCPServer
Human->>ItemArgs: Run approve-plan with item ID
ItemArgs->>ItemArgs: Check agent name
ItemArgs->>MCPServer: Invoke item_approve_plan_via_channel
MCPServer-->>ItemArgs: Return approval result or error
ItemArgs-->>Human: Print JSON result or error
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Claiming self-repair for |
supervisor — CI self-repair dispatchedFailing checks: hakari, CI Green. Please investigate and push a fix. job: smb8o8pwMRYgbJxooTGdP |
supervisor — CI self-repair dispatchedFailing checks: hakari, CI Green. Please investigate and push a fix. job: BF5My2bScmSlDos6xZfku |
supervisor — CI self-repair dispatchedFailing checks: hakari, CI Green. Please investigate and push a fix. job: QMPuPKvacMtLAI0P-ZtAl |
supervisor — CI self-repair dispatchedFailing checks: hakari, CI Green. Please investigate and push a fix. job: eKtm2bWnqY8p6kGK_-VIi |
I added
agentflare item approve-plan <id>, a human-only command that approves a pending plan. It is not committed, and I did not smoke-test the built binary.What changed
src/cli/item.rs: the newApprovePlan { id }subcommand takes the item id positionally (#1or UUID). It first runs the sameagent_detector::agent_name()check asagentflare work. If it detects an AI agent, it prints a "human-only" error and exits 1. Otherwise it calls the existingitem_approve_plan_via_channel, the route the Telegram Approve tap already uses. It prints the JSON result, or exits 1 on error, for example if the plan isn't pending.approve_plan_denial, with two unit tests (agent denied, human allowed).src/mcp_server/item.rs: the publicapprove_planrefusal now also points toagentflare item approve-plan <id>. I updated the doc comment onitem_approve_plan_via_channel, which had said its only caller was Telegram.Verification (all run in the foreground)
cargo test --bin agentflare cli::itempassed 2/2.cargo test --bin agentflare planpassed 27/27. That covers the existing plan-gate tests, includingchannel_approve_plan_succeeds_for_a_human_approver_itemandpublic_approve_plan_refuses_a_human_approver_item, plus the Telegram callback tests.cargo fmt --all --checkis clean.cargo clippy --locked --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedanticis clean.Concerns
cargo test, so the argument parsing has not been exercised end to end. The compile is verified, but the live "refused under an agent" run is not.cargo test --workspace. I only ran the targeted tests above.agentflare work. It is a guard against accidental self-approval, not a hard security boundary.plan_approved_byfield records theAGENTFLARE_AGENTidentity, whateverAgentflareMcp::default()resolves to. It is not a separate "human" marker.Opened by
claude-codeon flared:c997d745ae66 for item #596 via agentflare.Summary by CodeRabbit
New Features
item approve-plancommand for submitting plan approval requests from the command line.Documentation