Skip to content

feat(git-shim): CI paths in trust-root baseline + /flare:git slash command - #367

Merged
getappz merged 2 commits into
masterfrom
task/403
Jul 29, 2026
Merged

feat(git-shim): CI paths in trust-root baseline + /flare:git slash command#367
getappz merged 2 commits into
masterfrom
task/403

Conversation

@getappz

@getappz getappz commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Item #403, from the 2026-07-29 git-shim competitor audit:

  • Added .github/workflows/, .gitlab-ci.yml, .circleci/ to TRUST_ROOT_PATHS (CI-wipe was named as an attack agentflare didn't yet cover). Documented a known limitation in the code: resolve_trust_root_touch self-diffs when the pushed branch equals the default branch by name, so this doesn't change behavior for the ordinary direct-push case yet — tracked as an addendum comment on item fix(worktree): reuse an existing branch that owns no worktree instead of failing #321 (also bumped to high priority).
  • New /flare:git prompt (same mechanism as /flare:artifact//flare:handoff), surfacing the git-shim's own admin subcommands: install-hooks, install-shim, uninstall-shim, snapshot list/restore/prune, audit preview/prune, doctor. Deliberately scoped to just these — ordinary git commands (status/log/commit/push/...) already run via the ! shell-escape, and other CLI/MCP surfaces (pr_check, etc.) already have their own MCP tool entrypoint, so neither is duplicated here.

Related backlog filed from the same audit (not in this PR): epic #399 (tunable git-shim policy catalog, FailproofAI-inspired) with children #400#402, the last of which is secret-exfiltration scanning as the first new policy.

Test plan

  • cargo test --bin agentflare mcp_prompts and cargo test -p flare-git-core classify — all green
  • cargo test --workspace — 0 failed
  • cargo clippy --workspace --all-features -- -D warnings — clean

Summary by CodeRabbit

  • New Features

    • Added a git MCP prompt for supported Git administration and recovery commands.
    • Added usage guidance when no command is provided, including available options and flags.
    • Added instructions for running specified Git commands through the project’s shell tool.
  • Documentation

    • Clarified limitations related to trust-root path protections and direct default-branch pushes.

…mmand

Item #403, from the 2026-07-29 git-shim competitor audit:

- Added .github/workflows/, .gitlab-ci.yml, .circleci/ to
  TRUST_ROOT_PATHS in classify.rs (CI-wipe was named as an attack
  agentflare didn't yet cover). Documented a known limitation:
  resolve_trust_root_touch self-diffs when the pushed branch equals
  the default branch by name, so this doesn't change behavior for the
  ordinary direct-push case yet -- tracked as an addendum on item #321.

- New /flare:git prompt (mcp_prompts.rs), same mechanism as the
  existing /flare:artifact and /flare:handoff prompts, surfacing the
  agentflare git-shim's own admin subcommands: install-hooks,
  install-shim, uninstall-shim, snapshot list/restore/prune, audit
  preview/prune, doctor. Deliberately scoped to just these -- ordinary
  git commands and other CLI/MCP surfaces (pr_check, etc.) already have
  their own entrypoint (the ! shell-escape, or their own MCP tool) and
  don't need duplicating here.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@getappz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: aceafa00-f8f1-4246-8f94-7d67e2f2df5e

📥 Commits

Reviewing files that changed from the base of the PR and between 65de22a and e39ed62.

📒 Files selected for processing (2)
  • crates/flare-git-core/src/classify.rs
  • src/mcp_prompts.rs
📝 Walkthrough

Walkthrough

The change adds an MCP git prompt for git-shim administrative commands, including usage and execution guidance with tests. It also expands trust-root deny documentation and reformats the unchanged path list.

Changes

MCP git prompt

Layer / File(s) Summary
Register and dispatch git prompt
src/mcp_prompts.rs
Registers the git prompt with a command argument, dispatches requests to its handler, and updates the prompt-count test.
Format git command guidance
src/mcp_prompts.rs
Adds usage and command-specific responses, with tests covering surfaced commands, hidden commands, and supplied arguments.

Trust-root documentation

Layer / File(s) Summary
Clarify trust-root path behavior
crates/flare-git-core/src/classify.rs
Documents a known trust-root deny limitation and reformats TRUST_ROOT_PATHS without changing its values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant get_prompt
  participant get_git_command
  MCPClient->>get_prompt: request git with command
  get_prompt->>get_git_command: pass prompt request
  get_git_command-->>MCPClient: return usage or agentflare git instruction
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the two main changes: trust-root CI paths and the new /flare:git prompt.
Description check ✅ Passed The description covers the required Summary and Test plan sections and is sufficiently complete for review.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/403

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@crates/flare-git-core/src/classify.rs`:
- Around line 70-76: The TrustRootTouch::Unknown denial message must stay
synchronized with TRUST_ROOT_PATHS. Update the message construction in the
TrustRootTouch::Unknown handling to derive its listed paths from the effective
trust_root_paths configuration, including all configured CI paths, rather than
maintaining a separate hardcoded subset.

In `@src/mcp_prompts.rs`:
- Around line 257-290: Validate the parsed command in get_git_command before
generating assistant_text: parse and allowlist only the documented git-shim
subcommands and their supported arguments, rejecting shell metacharacters,
malformed grammar, and hidden commands such as scope-check. Render the execution
instruction only for validated commands, and add rejection tests covering
command injection and unsupported hidden commands.
🪄 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: 2fdfc4cb-d377-4c45-be10-600bd044e290

📥 Commits

Reviewing files that changed from the base of the PR and between a041ac4 and 65de22a.

📒 Files selected for processing (2)
  • crates/flare-git-core/src/classify.rs
  • src/mcp_prompts.rs

Comment thread crates/flare-git-core/src/classify.rs
Comment thread src/mcp_prompts.rs
Comment on lines +257 to +290
fn get_git_command(request: &GetPromptRequestParams) -> GetPromptResult {
let command = request
.arguments
.as_ref()
.and_then(|a| a.get("command"))
.and_then(|v| v.as_str())
.unwrap_or("")
.trim()
.to_string();

if command.is_empty() {
return assistant_text(
"agentflare git-shim commands — pass as this command's argument.\n\
install-hooks [--yes] — install branch-protection/provenance git hooks into this repo\n\
install-shim --binary <path> — install the flare-git-shim binary as `git` on PATH (dogfooding/local use)\n\
uninstall-shim — remove a previously installed git shim\n\
snapshot list — list recovery snapshots for this repo, newest first\n\
snapshot restore [<id>] [--yes] — restore a snapshot's files into the working tree (non-destructive)\n\
snapshot prune [--keep N] — delete all but the N most recent snapshots (default 5)\n\
audit preview — list orphaned worktree directories\n\
audit prune <names...|--all> — remove orphaned worktree directories (snapshots taken first)\n\
doctor [--format text|json|markdown] [--reclaim] [--force] [--staleness-days N] — health sweep over all claim worktrees",
);
}

assistant_text(format!(
"agentflare git command requested: `{command}`\n\n\
Run it as `agentflare git {command}` via the project's shell tool (ctx_shell if \
lean-ctx is available through the flare gateway, else Bash), then report its output \
to the user. These are the underlying git-shim CLI subcommands directly — install-hooks, \
install-shim, uninstall-shim, snapshot list/restore/prune, audit preview/prune, and doctor \
(see the bare `/git` usage card for each one's options). `doctor --reclaim` and \
`audit prune`/`snapshot prune` mutate local state (worktrees/snapshots) — confirm with \
the user before running those if it wasn't clearly what they asked for."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Validate commands before generating a shell instruction.

command is interpolated verbatim into agentflare git {command}. Inputs such as snapshot list; ... can escape into a second shell command, and scope-check can surface a hidden internal subcommand. Parse/allowlist the supported admin grammar and reject invalid input before rendering the execution instruction; add rejection tests for shell metacharacters and hidden commands.

🤖 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/mcp_prompts.rs` around lines 257 - 290, Validate the parsed command in
get_git_command before generating assistant_text: parse and allowlist only the
documented git-shim subcommands and their supported arguments, rejecting shell
metacharacters, malformed grammar, and hidden commands such as scope-check.
Render the execution instruction only for validated commands, and add rejection
tests covering command injection and unsupported hidden commands.

…-shim subcommands in /flare:git

- cargo fmt fix for the new test in mcp_prompts.rs
- TrustRootTouch::Unknown deny message now lists policy.trust_root_paths
  instead of a hardcoded subset, so it stays accurate as the list grows
- get_git_command rejects trailer-inject/ref-transaction-log/scope-check
  instead of echoing a run instruction for internal-only subcommands
@getappz
getappz merged commit 83a204c into master Jul 29, 2026
15 checks passed
@getappz
getappz deleted the task/403 branch July 29, 2026 05:18
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