Skip to content

feat(guardrails): detect and clean what the retired reference-verify entry left in a clone #18576

Description

@kyle-sexton

Problem

guardrails 4.0.0 removed the reference-verify pre-push git-hook entry (#18205, commit c4c251a),
because it ran far over the 3 s push budget. A clone that installed it with an earlier
/guardrails:setup apply install-git-hooks keeps running the old copy at every push until someone
removes it by hand, and nothing in the plugin tells the operator it is there:

  • plugins/guardrails/CHANGELOG.md (4.0.0, Removed) and plugins/guardrails/README.md (end of
    ### Git hooks) give manual removal steps only.
  • plugins/guardrails/skills/setup/SKILL.md:179-187 says "verify no longer lists a copy an
    earlier release installed, so look for one" and leaves the search to the agent's own reading.
  • plugins/guardrails/retirements.yaml holds only guardrails-r001 to guardrails-r004 (the
    retired install-commit-msg and install-pre-commit-content hooks). The check-retirements.sh
    detection that setup check runs (SKILL.md:101) therefore cannot see this entry's leftovers.
  • lib/git-hooks/install.mjs detects drift for current entries only: copyState returns stale
    (install.mjs:660-675) and driftLine prints
    guardrails: git hook <entry> stale; run /guardrails:setup apply install-git-hooks
    (install.mjs:1617-1625). Leftover detection (leftoverSources, install.mjs:1428-1455) covers
    only earlierNames and earlierEntries. An earlierEntries rule cannot record a removal with no
    successor, since earlierEntryErrors requires a non-empty to naming current entries
    (install.mjs:309-318).
  • The documented removal list names only the marker, the reference-verify.sh copy, lefthook jobs,
    a husky line and the shared .githooks copy. It omits the eight assets the entry copied beside
    its script. Before c4c251a, git-hooks/entries.json listed them for reference-verify:
    hooks/run-guards.sh, hooks/abort-boundary.sh, hooks/hook-utils.sh,
    hooks/cli-flag-verify.sh, hooks/skill-reference-verify.sh, hooks/stale-path-verify.sh,
    lib/verification/verify-cli-flag.sh, lib/verification/cli-flag-cache.sh. No current entry
    lists any of them (git-hooks/entries.json on main).

This is the mechanism that hit the reporting clone. That clone, on Windows Git Bash, ran a local
plain-hooks copy (checks-dispatcher v1, markers pre-push.d/guardrails.reference-verify and
guardrails.pre-push-content) whose reference-verify.sh was dated 2026-11-04, older than the
installed plugin. One push took about 5.5 minutes in reference-verify.sh. A later push over SSH
failed when GitHub closed the connection while the hook was still running (exit 141, SIGPIPE), and
the retry went over HTTPS.

Evidence

Verified this pass on origin/main (guardrails 4.0.0):

Did not reproduce: the push timing and the SSH failure. Both are the reporting session's single
observation, not re-measured. The item's question of whether the old copy already narrowed merges
is moot for this issue: 4.0.0 runs no reference-verify at push at all.

Proposed approach

Give a removed entry a manifest record, so detection and cleanup run through the paths setup
already has.

  1. Preferred: add retirement records to plugins/guardrails/retirements.yaml (append-only; next ids
    guardrails-r005 onward, per docs/contracts/retired-conventions/README.md):
    • kind: file, .git/hooks/pre-push.d/guardrails.reference-verify, action: delete, with a
      content_match that matches the marker text the old installer wrote.
    • kind: file, .git/hooks/guardrails/reference-verify.sh, action: delete, content_match
      on a stable line of the old script header.
    • One kind: file record per orphaned asset under .git/hooks/guardrails/, action: delete,
      each with a content_match. Only assets no current entry ships qualify, and today that is all
      eight.
    • .githooks/guardrails/reference-verify.sh (shared scope) and the shared pre-push.d marker
      as kind: file records.
    • A guardrails-reference-verify job in lefthook.yml or lefthook-local.yml as a
      kind: block record if the block kind fits the job's shape (harness-ops: retirement clean for r002/r003 deletes the whole harness-ops.yaml #14251 added it). Otherwise leave
      the lefthook job to the SKILL.md prose and say so in the record's note.
      Setup check then reports them, and bare apply cleans each one on the operator's yes.
  2. Alternative: extend entries.json with a retiredEntries list (name, event, script, assets),
    and have install.mjs leftovers() report a marker, copy or job for a retired entry as a
    superseded-style drift row. That gives a session-start drift line too, but it adds a new
    manifest field and validator to the shared installer, which other plugins vendor. Choose it only
    if the retirement manifest cannot express hooks-path-relative files (see gotchas).
  3. Update skills/setup/SKILL.md:179-187, the README ### Git hooks tail and the 4.0.0 removal
    text: name the detection, and list the eight assets in the manual steps.

Refresh vs removal: for a current entry, a stale copy is refreshed with
/guardrails:setup apply install-git-hooks (the command driftLine prints). For the retired
reference-verify entry there is nothing to refresh; the fix is removal, which this issue makes
detectable.

Files: plugins/guardrails/retirements.yaml, plugins/guardrails/git-hooks/retired-installs.test.sh
(or a new sibling test), plugins/guardrails/skills/setup/SKILL.md, plugins/guardrails/README.md,
plugins/guardrails/CHANGELOG.md, the plugin manifest version.

Acceptance criteria

  • In a throwaway repository with a 3.x-style local install of reference-verify (marker, script
    and the eight assets under .git/hooks/guardrails/), check-retirements.sh --manifest retirements.yaml reports every one of those files, and nothing for a clone with only the
    current entries installed.
  • --clean <id> removes exactly that record's file. The current entries' files (dispatcher,
    guardrails.pre-push-content marker, pre-push-content.sh, content-scan.sh, pattern
    libraries, check-lib.sh) are untouched, and the next push still runs pre-push-content.
  • A file at a recorded path whose content does not match content_match (a user's own) is not
    reported or removed.
  • The same detection works in a linked worktree and when core.hooksPath points at
    .githooks (shared scope), or the records say which they do not cover and SKILL.md keeps
    the manual step for that case.
  • SKILL.md, the README and the CHANGELOG name the detection and list all eight assets in the
    manual removal steps.
  • The test suite for the changed files passes on Linux and in Windows CI.

Constraints and gotchas

  • Retirement ids are append-only and never reused.
  • check-retirements.sh skips kind: file records when the root is $HOME or not a git work
    tree (CHANGELOG, fix(lib): check-retirements reads the user-global .claude layer as a retired file at a home or non-repository root #13504). Check how it resolves .git/hooks/... in a linked worktree and under
    core.hooksPath; lib/check-retirements-worktree.test.sh and
    plugins/harness-config/lib/check-retirements.test.sh cover the existing cases. check-retirements.sh
    is a shared copy synced across plugins, so a change to it is a cross-plugin sync, not a local edit.
  • Test fixtures must be throwaway repositories under mktemp -d with the host git config
    isolated (GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM), as retired-installs.test.sh does. Never
    point a test at a real clone.
  • hook-utils.sh, run-guards.sh and abort-boundary.sh are also plugin hook files under
    plugins/guardrails/hooks/. The records target only the copies under a clone's git hooks
    directory.
  • Version bump and CHANGELOG entry per the repository's release rules.

Context

Source: local handoff item 20261119-213200-guardrails-reference-verify-push-cost.md (retired into
this issue and #18577). Related:
#18205 and #18209 (entry removed from pre-push), #17985 (Windows pre-push timing, 44-67 s for the
remote reference-verify), #16398 and #16389 (merged-branch narrowing), #9861 (earlier 8-17 min
stacked-branch pushes).

Activity

  1. added
    agent-ready
    on Nov 23, 2026
  2. added
    needs-triage
    on Nov 23, 2026
  3. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Size: Medium
    Complexity: Medium
    Uncertainty: Knowable
    Flags: none
    Blocked by: none
    Blast radius: guardrails plugin retirements.yaml, its tests, setup SKILL.md, README and CHANGELOG, plus a version bump; read by operators running setup check and apply.
    Reversible: yes; revert the change. Files already deleted from a clone by an operator's apply are not restored.
    Open questions: none
    I understood this as a request to make guardrails detect and clean what the retired reference-verify pre-push entry left in a clone. The issue picks the retirement-records approach and gives acceptance criteria. The entries.json retiredEntries alternative is named only as a fallback if the manifest cannot express the paths, so I treated it as settled. The check for how check-retirements.sh resolves linked worktrees and core.hooksPath is part of the work. I found no duplicate among the open issues. #18205 is the merged change that removed the entry. It does not add this detection.

    Automated triage. A maintainer reviews it.

  4. removed
    needs-triage
    on Nov 23, 2026
  5. melodic-automation-lanes commented on Nov 23, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"c7368710ed3f0a1057bbef60d79d3446e27534c86f31e39a3abbc56a79efbc48","body_sha256":"1ad02b43eefc260acfb21c6ab8cd10d82ae2510112c2a8e89175002035f8a1ed"}

  6. melodic-automation-lanes commented on Nov 23, 2026

    @melodic-automation-lanes
    Contributor

    This records a re-fire of an earlier stop, not a new one. The start gate stopped run 45278169359, the work-resolve-issue run that agent-ready started, before any model turn, because the GITHUB_TOKEN budget was under its start-gate share, or the window was projected to have under its start-project share of the header's limit left by the run's expected end (github-token start-gate, start-project and start-run-minutes in rate-limits.json; the run's start-gate notice names which); that run ended at 2026-11-23T22:33:41Z. work-unblock has now removed and added agent-ready back to start a fresh run. A budget stop is the lanes' load, not a fault in this issue: it never counts toward limits.limit-stops-per-issue or the kill-switch wait.

  7. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor
    No description provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-ready

    Fields

    Work status

    needs-triage

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions