Skip to content

chore: CLI: agentflare item approve-plan <id> — human-only route for plan_approver=human items - #778

Merged
getappz merged 4 commits into
masterfrom
task/596-cli-agentflare-item-approve-plan-id-huma
Sep 20, 2026
Merged

getappz merged 4 commits into
masterfrom
task/596-cli-agentflare-item-approve-plan-id-huma

Conversation

@getappz

@getappz getappz commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

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 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.

Opened by claude-code on flared:c997d745ae66 for item #596 via agentflare.

Summary by CodeRabbit

  • New Features

    • Added the human-only item approve-plan command for submitting plan approval requests from the command line.
    • AI agents are prevented from using this approval workflow.
  • Documentation

    • Clarified the available plan approval options, including Telegram card approval and command-line approval.
    • Improved error guidance by directing users to supported approval paths when self-approval is unavailable.

…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.
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: fe8ccc4e-585d-4742-af89-7eb6fcf4ff4b

📥 Commits

Reviewing files that changed from the base of the PR and between fc9aa11 and e7392f5.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: ce9085fe-2d51-46ae-ba41-9ef34e2dd069

📥 Commits

Reviewing files that changed from the base of the PR and between 2bd8646 and f93f3c8.

📒 Files selected for processing (2)
  • src/cli/item.rs
  • src/mcp_server/item.rs

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.


📝 Walkthrough

Walkthrough

Changes

Plan approval

Layer / File(s) Summary
Human-only CLI approval route
src/cli/item.rs
The CLI adds item approve-plan. It denies detected AI agents, invokes item_approve_plan_via_channel for humans, prints successful JSON, and exits on errors. Tests cover both access paths.
Approval route guidance
src/mcp_server/item.rs
The documentation lists Telegram and human-only CLI approval routes. The rejection message states that agents cannot self-approve.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the new human-only agentflare item approve-plan <id> CLI route and its purpose. It is specific and related to the main change, although slightly long.
Description check ✅ Passed The description explains the change, implementation, tests, verification results, limitations, risks, and backward-compatibility considerations. It does not use the exact template headings or checklis…
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Claiming self-repair for flared:c997d745ae66.

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI self-repair dispatched

Failing checks: hakari, CI Green.

Please investigate and push a fix.

job: smb8o8pwMRYgbJxooTGdP

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI self-repair dispatched

Failing checks: hakari, CI Green.

Please investigate and push a fix.

job: BF5My2bScmSlDos6xZfku

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI self-repair dispatched

Failing checks: hakari, CI Green.

Please investigate and push a fix.

job: QMPuPKvacMtLAI0P-ZtAl

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI self-repair dispatched

Failing checks: hakari, CI Green.

Please investigate and push a fix.

job: eKtm2bWnqY8p6kGK_-VIi

@getappz
getappz enabled auto-merge (squash) September 20, 2026 18:15
@getappz
getappz merged commit 141e90b into master Sep 20, 2026
16 checks passed
@getappz
getappz deleted the task/596-cli-agentflare-item-approve-plan-id-huma branch September 20, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant