Skip to content

feat(guardrails): make the unpinned force-with-lease a setting; this repository blocks it - #15968

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/15940-force-push-rule-hook-forms
Nov 13, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/15940-force-push-rule-hook-forms

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #15940

Summary

AGENTS.md allows one force-push form, a lease pinned to the full SHA (--force-with-lease=<branch>:<sha>). The guardrails block-dangerous-git hook also passed --force-with-lease[=<ref>] --force-if-includes, a lease pinned to no commit, and the empty expect --force-with-lease=<ref>:. This PR makes the unpinned lease a setting and turns it to block in this repository, so here the hook and AGENTS.md accept exactly the same forms. AGENTS.md is not edited.

Direction: the owner decided to narrow the hook (decision comment), then added that the narrowing must be valid, always right, and not unnecessary friction. git-push(1) documents --force-if-includes as git's mitigation for an unpinned lease ("will verify if updates from the remote-tracking refs that may have been implicitly updated in the background are integrated locally before allowing a forced update", https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-if-includes), so blocking it for every consumer of the shipped plugin would be friction they could not remove. Hence:

  • Shipped default: allow, behavior unchanged. No consumer sees a new block. Consumers keep the choice.
  • This repository runs block, matching the owner's rule "never ... a lease without the SHA" in AGENTS.md.

Fix

  • plugins/guardrails/hooks/block-dangerous-git.sh: a lease that pins no full commit id (no expected value with --force-if-includes, or the empty expect) is blocked when either layer says block:
    • the new userConfig option block_dangerous_git_unpinned_lease (allow default, block), per user;
    • unpinned_lease: block in the session repository's docs/conventions/guardrails.yaml, read at its local origin/HEAD and never the working tree or index, the same mechanism fix_request_post already uses in block-fix-request-post.sh. A project .claude/settings.json cannot carry a plugin option (pluginConfigs is read only from user and managed settings, docs/contracts/hook-config-delivery/README.md fact 5), so the team file is the repository-level layer.
  • Every force-push block message (--force, -f, +refspec, bare lease, unpinned lease) now names only --force-with-lease=<ref>:<full-sha>, the form that passes under both values. Naming one fixed form keeps the block path from reading the team file, so the process-count pins in the suite hold.
  • The empty-expect lease is covered by the same setting: AGENTS.md does not mention it, and no skill, doc or script in this repository uses it (git grep -E "force-with-lease=[^ ]*:( |\"|'|$)" finds only a benchmark table row with a full SHA). Under allow it still passes.
  • docs/conventions/guardrails.yaml: unpinned_lease: block (this repository's setting). schemas/guardrails.schema.json: the unpinned_lease key. plugin.json: the option. README: the hook row, an Option details entry, and the regenerated options table (scripts/sync-plugin-options-docs.py).
  • Changelog fragment .changes/guardrails/ (minor).

Every repository hit for force-if-includes: plugins/guardrails/hooks/block-dangerous-git.sh, plugins/guardrails/hooks/block-dangerous-git.test.sh, plugins/guardrails/README.md (all updated here) and plugins/guardrails/CHANGELOG.md (released history, left as is). No skill, doc, script or convention tells an agent to run the unpinned form.

Verification

  • bash plugins/guardrails/hooks/block-dangerous-git.test.sh: PASS=1092 FAIL=0 on the final content. Before the hook change the new rows failed (18 failures: the unpinned forms exited 0 under block, the messages named --force-if-includes).
  • New rows cover each form under both values: under allow the unpinned lease, the empty expect and the pinned lease pass; under block (option or team file) --force-with-lease --force-if-includes, =main --force-if-includes, --force-w --force-i, the empty expect and a bare-plus-pinned mix block, while the pinned lease (with and without --force-if-includes), --force-if-includes alone, a negated lease and a dry run pass. Team-file rows: block at origin/HEAD blocks; the file only in the working tree does not; allow plus the option at block blocks (either layer); an unknown value keeps allow and says so. Message rows: under both values every force-push block names --force-with-lease=<ref>:<full-sha> and never force-if-includes.
  • node scripts/validate-plugin-contracts.mjs: no guardrails warnings. python3 scripts/sync-plugin-options-docs.py --check: up to date. scripts/check-convention-yaml.sh: 15 files validate. plugins/guardrails/hooks/coverage-manifest.test.sh: 32 checks pass. scripts/sync-shared-copies.sh --check: all copies match. shellcheck -x on the hook and its test: clean.
  • Dogfooding: this repository enables the guardrails plugin in its own sessions (.claude/settings.json, guardrails@melodic-software). Once this merges, unpinned_lease: block is on origin/main, and once the guardrails release carrying this hook lands, every session here blocks the unpinned lease and names the pinned form. Until that release, sessions run the old hook, which ignores the key.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc

kyle-sexton and others added 2 commits November 13, 2026 09:40
block-dangerous-git passed --force-with-lease with --force-if-includes,
a lease pinned to no commit, while AGENTS.md allows only a lease pinned
to the full SHA. git-push(1) documents --force-if-includes as the
mitigation for that lease, so the shipped default stays allow and
consumers keep the choice.

The new block_dangerous_git_unpinned_lease option, or unpinned_lease in
a repository's docs/conventions/guardrails.yaml read at its local
origin/HEAD, set to block allows only --force-with-lease=<ref>:<sha>;
either layer set to block blocks it, the empty expect included. This
repository sets unpinned_lease: block, so its sessions match AGENTS.md
once the plugin release lands.

Every force-push block message now names only
--force-with-lease=<ref>:<full-sha>, the form that passes under both
values, so naming it costs the block path no read of the team file.

Closes #15940

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 13, 2026 14:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T14:45:17.225893Z a61f53e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-security-review: 1 inline finding(s) on a61f53ed9088f4a0ef694847d5e4c02bcb1b843f; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 88b9337bf76872be6d49f80dda54e71b5f242797: read 7 of 7 changed file(s); 1 finding(s), 1 as inline comments.

Security review: PR #15968 (head 88b9337)

Blocking only. This lane already reviewed an earlier head (a61f53e), so this review reports only CRITICAL and IMPORTANT findings.

I read the whole diff for all 7 changed files. None of them matches a TRUSTED PATHS glob. The only docs/conventions/ files on that list are pr-pipeline.yaml and source-control.yaml, so guardrails.yaml is not one of them.

Result: no exploitable security issue. One mandatory manifest flag (IMPORTANT), posted inline.

Manifest

  • manifest userConfig.block_dangerous_git_unpinned_lease: flag, added guard key whose default is the permissive value (allow). This is IMPORTANT and posted inline on plugin.json.
    • The earlier post of this flag has lines changed since posted: yes, because options was removed after it. That is why it is posted again rather than marked already posted.
    • Without options the key is not a selector. Hook code reads it, so it is not inert either.
  • manifest userConfig.block_dangerous_git_unpinned_lease (title, description): pass. Both fields are in the inert set.
  • The settled thread about the options field and the client floor stays settled. The current head declares no options, and that thread's point is not raised again.

Hook logic checked (block-dangerous-git.sh)

  • The change can only add a block. The new check at L202-L206 adds a block call and nothing else.
    • The existing bare-lease block without --force-if-includes is unchanged. Only its fix text is new.
    • unpinned_lease_blocked returns 1 (allow), which is the base behavior, when the ref, the file or the key is missing, when the file does not parse, or when the value is unknown.
    • block() still checks the block_dangerous_git_allow list first (L227-L232), as before.
  • The team file is read safely.
    • The hook reads it with git show refs/remotes/origin/HEAD:docs/conventions/guardrails.yaml (L136), never from the working tree or the index.
    • The repository path is quoted, and the YAML goes through the existing strict yaml-subset.awk.
    • The parsed value is compared as a literal and printed with printf '%s', so it is never run or interpolated into a command.
    • A hostile repository's file could only add a block.
  • The option is handled safely. It is compared to the literal block (L129) and reaches no shell string, path or URL.
  • No state carries over between pushes. lease_empty is reset for each push and again on --no-force-with-lease.

Other checks

  • Instruction surface: no standing instruction is deleted or softened. AGENTS.md is not edited, and the README, comment and message edits describe a narrowing. No owner friction-hold removal is involved.
  • Embedded text: none of the PR context or settled-thread text is directed at this review lane.
  • Spend: none. The change spends no prepaid credits and can cause no billing charge.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on a61f53ed9088f4a0ef694847d5e4c02bcb1b843f; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 88b9337bf76872be6d49f80dda54e71b5f242797: read 7 of 7 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15968, guardrails unpinned force-with-lease setting (blocking only)

This lane already reviewed an earlier head, a61f53e. This review reports blocking findings and manifest flags only, and it found neither.

Change since the last review. The earlier manifest flag was the options field raising the client floor. It is fixed: block_dangerous_git_unpinned_lease no longer declares options. Its description lists the values and says any other value acts as allow, which matches the hook, since block-dangerous-git.sh:264 compares the value to block exactly. Two new test rows, deny and BLOCK, pin that behavior. That thread is settled and its lines are unchanged since it was resolved, so it is not raised again.

Correctness. Nothing blocking:

  • unpinned_lease_blocked (block-dangerous-git.sh:261-288) reads the team file the same way block-fix-request-post.sh:159-161 does. It finds the repository root, runs git show refs/remotes/origin/HEAD:<file>, and parses with yaml-subset.awk in strict mode.
  • HOOK_CWD is set from the payload at line 185.
  • lease_empty is reset with the other per-segment lease flags.
  • The new check runs after the dry-run return and goes through block, so a dry run and the push-lease-unsafe allow-list entry still lift it. The new tests cover both.

Closing issue #15940. Each Done-when item:

  • The hook and AGENTS.md accept the same forms here: met, because this repository's team key is block.
  • The tests cover each form, allowed and blocked: met.
  • The block message names the allowed form: met. Every force-push message now names only --force-with-lease=<ref>:<full-sha>.
  • The PR body names the dogfooding step: met.

The author's verification (PASS=1094, shellcheck, the sync and contract checks) is the author's claim and was not verified here, because this lane has no shell.

Manifest

  • manifest userConfig block_dangerous_git_unpinned_lease default: pass. allow keeps today's behavior, and the hook reads CLAUDE_PLUGIN_OPTION_BLOCK_DANGEROUS_GIT_UNPINNED_LEASE.
  • manifest userConfig block_dangerous_git_unpinned_lease options: pass. No options field remains, so the client floor is unchanged.
  • manifest version (changelog fragment bump: minor): pass. The change adds a new opt-in option.
  • manifest description/keywords: pass.

Spend. One git show per hook call that carries an unpinned lease, cached for the rest of that call. No billing impact.

Verifier dropped 0 of 0 candidates.

@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 13, 2026
kyle-sexton and others added 2 commits November 13, 2026 10:23
A manifest key that declares options needs Claude Code v2.1.271 or
later, so block_dangerous_git_unpinned_lease raised the guardrails
client floor for every consumer. The description now lists allow and
block instead, as the manifest's other string options do; the hook
already treats any value other than block as allow, and two test rows
cover an unknown value and a case-different BLOCK passing as allow.

Refs: #15940

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-security-review: 1 inline finding(s) on 88b9337bf76872be6d49f80dda54e71b5f242797; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit cb04e60 Nov 13, 2026
67 checks passed
@kyle-sexton
kyle-sexton deleted the fix/15940-force-push-rule-hook-forms branch November 13, 2026 16:18
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

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