Skip to content

docs(agents): allow the force-if-includes lease the guardrails hook accepts - #15958

Closed
melodic-automation-lanes[bot] wants to merge 1 commit into
mainfrom
work-resolve-issue/issue-15940-43425766537-1
Closed

melodic-automation-lanes[bot] wants to merge 1 commit into
mainfrom
work-resolve-issue/issue-15940-43425766537-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #15940

Summary

Opened by the work-resolve-issue lane. The run's own summary:

The AGENTS.md force-push rule now allows the same forms as the guardrails dangerous-git hook: a lease pinned to the full SHA (or an empty expect for a branch that must not exist yet), or --force-with-lease\[=<branch>\] --force-if-includes. It now forbids the forms the hook blocks: a bare --force, -f alone or bundled, --mirror, a + refspec, and any other lease spelling (one pinned to a name or a short SHA is blocked even with --force-if-includes). Why the prose was widened instead of the hook narrowed: the pinned lease exists so a peer's newer commit fails the push instead of being overwritten. git-push(1) says --force-if-includes with an unpinned lease checks that the remote-tracking tip is reachable from the local branch's reflog and rejects the forced update if not. So a peer's commit that a background fetch pulled in, but that the local branch never included, still fails the push. If nothing was fetched, the lease fails because the remote moved. That form protects a peer's commit, which is the test the issue's decision set. The hook already named both forms in its push-force block messages, so its code is unchanged. The suite already covered every form, allowed and blocked; it now also asserts that the --force, -f and + refspec block messages name both allowed forms, and that the no-expected-value lease block names --force-if-includes. Dogfooding step: this repository enables guardrailsmelodic-software in its project .claude/settings.json, so every session here runs this hook beside the AGENTS.md rule. Because the hook code is unchanged, the hook sessions here already run matches the new prose, with no plugin update needed.

Not verified

  • plugins/guardrails/hooks/block-dangerous-git.test.sh was not executed here (this lane runs no interpreter); left to the PR's CI.
  • Tidy not run: the change touches AGENTS.md, a listed shared path, so the tidy entry does not apply.
  • check-affected skipped typos (not installed) and three validate-plugins sub-checks that run code from the checked tree; CI runs them.

Fix

  • AGENTS.md: the Stop-and-ask force-push entry now allows --force-with-lease=<branch>:<sha> (full SHA, or empty for a branch that must not exist) and --force-with-lease\[=<branch>\] --force-if-includes, and forbids bare --force, -f alone or bundled, --mirror, + refspecs and any…
  • plugins/guardrails/hooks/block-dangerous-git.test.sh: new assertions that the --force, -f and +refspec block messages name both allowed lease forms, and that the no-expected-value lease block message names --force-if-includes.
  • .changes/guardrails/work-resolve-issue-issue-15940-43425766537-1-1a197f39.md: bump none fragment (test-only change, hook unchanged).

Verification

The runner ran each check from the base copy against 742d788:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • read https: //git-scm.com/docs/git-push: --force-if-includes "verifies if the tip of the remote-tracking ref is reachable from one of the reflog entries of the local branch" and rejects the forced update otherwise; it is a no-op without --force-with-lease or alongside…
  • Read block-dangerous-git.sh's push case: allows pinned full-width object id leases, empty-expect leases, and unpinned leases with --force-if-includes; blocks --force, -f bundles, + refspecs, --mirror, unpinned leases without --force-if-includes and movable/short <expect> even with…
  • Read block-dangerous-git.test.sh: existing cases already cover each form allowed (lines 119, 139/307, 308, 309) and blocked (104-112, 316, 326-336); added message assertions.
  • Fresh-context review subagent of the diff: no correctness bugs; three wording gaps (never-list narrower than the hook, -f bundles, coverage overstated for --mirror) fixed.
  • check-changelog-fragments: all 37 fragments valid.
  • check-changed-skills: no changed skills, nothing to gate.
  • check-affected: 13 passed, 6 skipped (none failed).
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43425766537

Left out: the items under Not verified.

Related

#15940

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 742d78830cbb40beb327938ddf8366279e3068ee: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15958, no findings

I read all three changed files in the diff: the changelog fragment, AGENTS.md and plugins/guardrails/hooks/block-dangerous-git.test.sh. I also read the push case of the unchanged hook, its block messages and the test helpers the new assertions call.

Checked against closing issue #15940:

  • The hook and AGENTS.md accept the same forms, and the PR body gives the reason for the direction: met.
    • The new prose allows a lease pinned to the full SHA or with an empty expect, and --force-with-lease[=<branch>] --force-if-includes.
    • It forbids --force, -f alone or bundled, --mirror, a + refspec, and any lease pinned to a name or a short SHA, even beside --force-if-includes.
    • That matches the hook's blocks at block-dangerous-git.sh#L1054-L1063 and #L1091-L1117.
    • The PR body explains why the prose was widened instead of the hook narrowed: --force-if-includes still makes the push fail when a fetch brought in a peer's commit.
  • The tests cover each form, allowed and blocked: met by rows that already exist, for example test.sh#L307-L336.
  • The block message names the allowed form: met.
    • PUSH_FORCE_FIX (#L245) holds both literal strings the new assertions look for.
    • The --force and -f blocks and block_push_refspec_plus all use it.
    • The no-expected-value lease block names --force-if-includes.
    • assert_contains matches with a bash glob, not grep, so needles that start with -- are safe.
  • The PR body names the dogfooding step: met.

Other checks:

  • A bump: none fragment fits: the change only adds tests and changes no shipped hook code.
  • The PR changes no plugin manifests.
  • AGENTS.md matches a trusted path. I read its whole change: it is wording only and changes no gate.

Verification: I did not run the test suite, because this lane has no shell. The PR's verification output is author-claimed and unverified here.

Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 742d78830cbb40beb327938ddf8366279e3068ee: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

critical-findings: 0

Scope: I read every hunk of all 3 changed files: the changelog fragment, AGENTS.md (a trusted path) and plugins/guardrails/hooks/block-dangerous-git.test.sh.

AGENTS.md force-push rule (instruction-surface lens). The rule now allows a second force-push form, --force-with-lease[=<branch>] --force-if-includes, beside the pinned full-SHA lease. It also spells out the empty-<sha> lease for a branch that must not exist yet. Force-pushing falls under the register's irreversible-action class (docs/contracts/instruction-exception-register/README.md line 48). The guardrails hook already enforces this rule, so the prose change doesn't remove a check:

  • The hook already allows both forms. Its block message is set at block-dangerous-git.sh#L245. It blocks a lease with no expected value only when --force-if-includes is missing (#L1059-L1063).
  • A trailing --no-force-if-includes still turns the mitigation off (#L980).
  • A lease pinned to a name or a short SHA is still blocked even with --force-if-includes (header comment, #L13-L16).
  • Bare --force, -f, + refspecs and --mirror are still blocked.

The commit the rule protects, a peer's newer commit, is still protected by both allowed forms, and the hook's code is unchanged. The rule also keeps its "Stop and ask first" placement, its feature-branch-only scope and the default-branch push ban.

Test file. The change adds message assertions only, run against the hook in a temporary test repository. It runs no new untrusted input and reaches no credentials.

Changelog fragment. A bump: none note; no security surface.

No trust control, token scope, kill switch, merge hold or plugin manifest is touched. Nothing here causes a real charge or spends extra credit.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 742d78830cbb40beb327938ddf8366279e3068ee. A person must clear this reason, so the pr-merge lane added the needs-human label: fix the reason, then remove the label, and the next scheduled run judges it again.

pr-merge's gate holds it on its risk score (security-finding: 1 open)

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Nov 13, 2026
@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 13, 2026
@kyle-sexton

Copy link
Copy Markdown
Member

Closed unmerged: the owner decided the other direction for item 15940 (narrow the hook, leave AGENTS.md as written). The decision is recorded on the issue: #15940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Hard merge gate: do not merge while applied. needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the force-push rule in AGENTS.md and the guardrails hook allow the same forms

1 participant