Skip to content

fix(flare-git-shim): reset recursion depth before exec'ing real git - #359

Merged
getappz merged 2 commits into
masterfrom
task/379
Jul 28, 2026
Merged

fix(flare-git-shim): reset recursion depth before exec'ing real git#359
getappz merged 2 commits into
masterfrom
task/379

Conversation

@getappz

@getappz getappz commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • FLARE_GIT_SHIM_DEPTH was meant to guard against the shim resolving git back to itself, but it counted total process nesting instead — the incremented value was inherited unchanged into the real git child process (and anything it spawns), so it kept accumulating across unrelated git invocations within a single long-lived process tree.
  • cargo test --workspace locally fails 8 tests that shell out to git, tripping the guard on legitimate usage; reproduces identically on origin/master, and passes fine in CI (no shim installed there).
  • Fix: exec_real() clears RECURSION_ENV immediately before handing off to the real git binary, so each real-git subtree gets a fresh budget. The guard still applies to this shim's own internal git shell-outs (branch/classify/snapshot) made before that handoff, so genuine self-recursion is still caught.

Closes agentflare item #379.

Test plan

  • cargo test --workspace — 866/866 passed in the main binary (previously 8 failing), no "recursion guard tripped" anywhere in the run
  • cargo clippy --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic — clean
  • cargo fmt --check — clean

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility when Git commands are delegated to the system Git executable.
    • Prevented stale recursion state from affecting nested or subsequent Git invocations.
    • Ensured pass-through commands, repository checks, bypass scenarios, and version queries execute reliably.

FLARE_GIT_SHIM_DEPTH counted total process nesting rather than actual
self-recursion, since the incremented value was inherited unchanged
into the real git child (and anything it spawns). A long-lived process
like cargo test --workspace accumulates depth across unrelated git
invocations until the guard trips on legitimate usage -- reproduced
identically on origin/master (8 failing tests), passing fine in CI
where no shim is installed.

Reset the counter immediately before handing off to the real binary so
each real-git subtree starts its own fresh budget, while still keeping
the guard active for this shim's own internal git shell-outs (branch/
classify/snapshot) that happen before that handoff.

Fixes #379.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fdf94dae-cf2e-487c-938f-f508d0ff7645

📥 Commits

Reviewing files that changed from the base of the PR and between 5dab94b and 7b3f7eb.

📒 Files selected for processing (1)
  • crates/flare-git-shim/src/main.rs

📝 Walkthrough

Walkthrough

The git shim adds an exec_real helper that removes RECURSION_ENV before executing the real git binary, then routes non-git, repository-exit, bypass, missing-subcommand, passthrough, and silent-exempt paths through it.

Changes

Real git delegation

Layer / File(s) Summary
Centralized real-git execution and call-site updates
crates/flare-git-shim/src/main.rs
Adds exec_real, which clears RECURSION_ENV before delegating, and replaces direct run_real calls across all listed handoff paths.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: resetting recursion depth before handing off to real git.
Description check ✅ Passed The summary and test plan are complete and specific; the notes for reviewers section is missing, but that's non-critical.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/379

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

@getappz
getappz enabled auto-merge (squash) July 28, 2026 13:47
@getappz
getappz merged commit f7eb1c4 into master Jul 28, 2026
15 checks passed
@getappz
getappz deleted the task/379 branch July 28, 2026 13:52
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