Skip to content

chore: repo-compare.json: gate record against a MISS+failed-compare run producing no verdict - #637

Merged
getappz merged 1 commit into
masterfrom
task/181-repo-compare-json-gate-record-against-a
Aug 31, 2026
Merged

getappz merged 1 commit into
masterfrom
task/181-repo-compare-json-gate-record-against-a

Conversation

@getappz

@getappz getappz commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Only repo-compare.json uses run_if, so this change is isolated. Done.

What I did: Extended compile_run_if in crates/flare-workflow/src/json.rs to support a single top-level OR/AND combining two atomic conditions (each still ==/!=/bare-truthy), and fixed a landmine I hit along the way: expand_variables leaves an unresolved {{var}} as literal template text rather than empty string, which would have made verdict != '' spuriously true whenever compare never ran. I now normalize any still-bracketed {{...}} output to falsy/empty inside run_if evaluation only (prompt expansion elsewhere is untouched, preserving the "agent sees the raw placeholder and refuses to fabricate" fallback).

Wired record's gate in .agentflare/workflows/repo-compare.json to {{cache_check}} != 'MISS' OR {{verdict}} != '' — skips only on a fresh-analysis run with no verdict, still runs on a legitimate cache-hit passthrough.

Tests: added two unit tests directly against compile_run_if (run_if_or_treats_unset_var_as_falsy_not_its_own_placeholder_text, covering MISS+no-verdict skip / MISS+verdict run / cache-hit run; and run_if_and_requires_both_sides). Full flare-workflow crate suite: 29/29 passing, no regressions. JSON file validated as well-formed. Confirmed no other workflow file in the repo uses run_if, so this grammar change is isolated to repo-compare.json.

Concerns: the OR/AND split is a plain substring match, so a quoted literal containing the literal substring " OR " or " AND " would misparse — acceptable per the task's own scope note ("string-only, no full expression language"), but worth remembering if this grammar gets reused elsewhere.


Opened by claude-code on flared:51bb8de6c33b for item #181 via agentflare.

Summary by CodeRabbit

  • New Features
    • Workflow conditions now support nested OR and AND logic for more flexible automation.
    • Unset variables are safely treated as false when evaluating workflow conditions.
  • Bug Fixes
    • Cached comparison results can now continue to the recording step without requiring a newly generated verdict.
    • Improved reliability when workflows evaluate missing or partially populated values.

@getappz

getappz commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

Tracking this PR for automated review (flared:c997d745ae66).

@coderabbitai

coderabbitai Bot commented Aug 29, 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

Run ID: c36c4196-d832-4b72-99ca-1ce0d74ae6e1

📥 Commits

Reviewing files that changed from the base of the PR and between cb1b3d1 and daae25f.

📒 Files selected for processing (2)
  • .agentflare/workflows/repo-compare.json
  • crates/flare-workflow/src/json.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The workflow now evaluates recursive OR and AND conditions, treats unset variables as falsy, and tests these cases. The repository comparison workflow also records cached results when no fresh verdict exists.

Changes

Workflow condition updates

Layer / File(s) Summary
Recursive run_if evaluation
crates/flare-workflow/src/json.rs
compile_run_if supports recursive OR and AND conditions. Unset variables expand to empty values. Tests cover both operators and unset-variable handling.
Cached comparison recording
.agentflare/workflows/repo-compare.json
The record step runs when cache_check is not MISS or verdict is non-empty.

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

Merge Risk: ⚪ Minimal · up to daae2

This change gates recording when a fresh comparison produces no verdict while preserving cache-hit behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary workflow change: gating the record step for failed comparisons that produce no verdict. It is specific and related to the changeset.
Description check ✅ Passed The description provides the change summary, implementation details, test results, risk assessment, and compatibility context. It does not use the template headings or test-plan checkboxes, but it con…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. (1 skipped: 1 …
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.
Full details: Description check

Explanation

The description provides the change summary, implementation details, test results, risk assessment, and compatibility context. It does not use the template headings or test-plan checkboxes, but it contains the required information and is mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. (1 skipped: 1 unsupported.)

✨ 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/181-repo-compare-json-gate-record-against-a

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

…one.

**What I did:** Extended `compile_run_if` in `crates/flare-workflow/src/json.rs` to support a single top-level `OR`/`AND` combining two atomic conditions (each still `==`/`!=`/bare-truthy), and fixed a landmine I hit along the way: `expand_variables` leaves an unresolved `{{var}}` as literal template text rather than empty string, which would have made `verdict != ''` spuriously true whenever `compare` never ran. I now normalize any still-bracketed `{{...}}` output to falsy/empty inside `run_if` evaluation only (prompt expansion elsewhere is untouched, preserving the "agent sees the raw placeholder and refuses to fabricate" fallback).

Wired `record`'s gate in `.agentflare/workflows/repo-compare.json` to `{{cache_check}} != 'MISS' OR {{verdict}} != ''` — skips only on a fresh-analysis run with no verdict, still runs on a legitimate cache-hit passthrough.

**Tests:** added two unit tests directly against `compile_run_if` (`run_if_or_treats_unset_var_as_falsy_not_its_own_placeholder_text`, covering MISS+no-verdict skip / MISS+verdict run / cache-hit run; and `run_if_and_requires_both_sides`). Full `flare-workflow` crate suite: 29/29 passing, no regressions. JSON file validated as well-formed. Confirmed no other workflow file in the repo uses `run_if`, so this grammar change is isolated to `repo-compare.json`.

**Concerns:** the `OR`/`AND` split is a plain substring match, so a quoted literal containing the literal substring `" OR "` or `" AND "` would misparse — acceptable per the task's own scope note ("string-only, no full expression language"), but worth remembering if this grammar gets reused elsewhere.

Agentflare-Branch: task/181-repo-compare-json-gate-record-against-a
Agentflare-Item: 181-repo-compare-json-gate-record-against-a
@getappz
getappz force-pushed the task/181-repo-compare-json-gate-record-against-a branch from f644eb4 to 9367452 Compare August 31, 2026 06:43
@getappz
getappz merged commit 28bfcf3 into master Aug 31, 2026
2 of 15 checks passed
@getappz
getappz deleted the task/181-repo-compare-json-gate-record-against-a branch August 31, 2026 08:53
getappz added a commit that referenced this pull request Sep 24, 2026
…llow-up)

CodeRabbit on #803 asked for a test exercising the dispatcher route rather
than the compiled git shim directly. agentflare-shim's PATH dispatcher sets
LEAN_CTX_AGENT before routing a command through lean-ctx -c git, but that
marker was in neither agent-detector 0.2.1's catalog nor the AGENTFLARE_AGENT
check, so a caller reaching this shim only via that route would misclassify
as human and bypass the canonical-mutate guard entirely.

- agent_invocation_detected() now also checks LEAN_CTX_AGENT directly.
- human_shim strips it too, since it is ambient under lean-ctx sessions.
- New test proves both branch-create and HEAD-detach stay denied under this
  marker, with the escape hatch set, matching the existing CLAUDECODE tests.

Agentflare-Agent: claude-code_2-1-281_harness
Agentflare-Branch: task/637-flare-git-shim-agent-settable-agentflare
Agentflare-Item: 637
Agentflare-Session: 85157ad7-4af8-4643-ae34-bcbbf05e7434
getappz added a commit that referenced this pull request Sep 24, 2026
…ical-mutate guard (#803)

* fix(git-shim): agent-invoked calls can no longer self-clear the canonical-mutate guard (item 637)

deny_canonical_detach_reason checked AGENTFLARE_GIT_ALLOW_CANONICAL_MUTATE
before checking agent_invocation_detected(), so an agent denied by the
worktree-mandatory guard could set the override itself and mutate the
canonical checkout directly -- this happened twice in practice, most
recently detaching the user's main working-directory HEAD.

Reorder the checks so the override is only reachable for non-agent-invoked
(human/interactive) calls; the stranded-checkout checkout/switch recovery
path (main.rs:502) is left untouched since it's narrow and already audited.
Flip the existing escape-hatch tests to assert denial for agent-invoked
callers and add a test confirming human/interactive use is unaffected.

Agentflare-Agent: claude-code_2-1-281_harness
Agentflare-Branch: task/637-flare-git-shim-agent-settable-agentflare
Agentflare-Item: 637
Agentflare-Session: e402be06-2dbb-4058-bb61-bf38039c7d27

* fix(git-shim): classify LEAN_CTX_AGENT as agent-invoked (item #637 follow-up)

CodeRabbit on #803 asked for a test exercising the dispatcher route rather
than the compiled git shim directly. agentflare-shim's PATH dispatcher sets
LEAN_CTX_AGENT before routing a command through lean-ctx -c git, but that
marker was in neither agent-detector 0.2.1's catalog nor the AGENTFLARE_AGENT
check, so a caller reaching this shim only via that route would misclassify
as human and bypass the canonical-mutate guard entirely.

- agent_invocation_detected() now also checks LEAN_CTX_AGENT directly.
- human_shim strips it too, since it is ambient under lean-ctx sessions.
- New test proves both branch-create and HEAD-detach stay denied under this
  marker, with the escape hatch set, matching the existing CLAUDECODE tests.

Agentflare-Agent: claude-code_2-1-281_harness
Agentflare-Branch: task/637-flare-git-shim-agent-settable-agentflare
Agentflare-Item: 637
Agentflare-Session: 85157ad7-4af8-4643-ae34-bcbbf05e7434
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