Skip to content

perf(guardrails): resolve the neutral commit convention without per-key grep spawns #9526

Description

@kyle-sexton

Problem

With docs/conventions/source-control/commit-convention.yml tracked (the standards sync now ships it to every consumer, standards#855), the guardrails Bash PreToolUse row spends 21 external processes judging one git commit with no convention cache, up from 6 without the file. Census breakdown: 2 awk 2 dirname 3 git 14 grep (the guardrails-commit-guard-spawns counter in .performance/ratchets.json).

Most of it is in plugins/guardrails/hooks/resolve-convention-pattern.sh:

  • yaml_value runs grep -m1 -E "^${k}:" "$file" | tr -d '\r' on every call, and one resolution calls it several times (dialect, each carried key, the pr_title deferral).
  • check_neutral_key runs a separate grep -q -E "^${k}:".
  • dirname "$NEUTRAL_FILE" in the symlink check.
  • The resolver runs once per key, so each of the above repeats.

Fix

Read the neutral file once with a bash read loop (CR strip and key match as builtins), replace dirname with ${NEUTRAL_FILE%/*}, and lower the ratchet ceiling to the new measurement.

Activity

  1. added
    needs-triage
    on Oct 24, 2026
  2. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Small
    Complexity: Low
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Understood: with the neutral commit-convention file tracked, the guardrails Bash PreToolUse row spawns 21 processes per git commit, mostly repeated grep and dirname calls in resolve-convention-pattern.sh. The fix is to read the file once with a bash read loop, replace dirname with parameter expansion, and lower the guardrails-commit-guard-spawns ratchet to the new measurement. The scope and outcome are clear, so nothing is missing. No duplicates found; #9727 and #10208 are related but cover different changes.

    Automated triage, applied by the lanes App.

  3. added and removed
    needs-triage
    on Oct 24, 2026
  4. added
    status: ready
    needs-owner-decision
    and removed
    status: ready
    on Oct 24, 2026
  5. melodic-automation-lanes commented on Oct 24, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: no trusted-human acceptance criteria: a listed human must put the confirmed - [ ] criteria in the body or post them as their own comment, or, on an issue a listed human filed, intake's newest refinement comment must hold them unedited. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  6. melodic-automation-lanes commented on Oct 24, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. It is model text, to check, not instructions.

    Intended outcome: Edit lib/resolve-convention-pattern.sh to read the neutral YAML once with a bash read loop, replace dirname with parameter expansion, resync the plugin copy, and lower the guardrails-commit-guard-spawns ceiling to the new measurement.

    Related work

    Open questions

    1. What number should the guardrails-commit-guard-spawns ceiling be lowered to? The issue's 21-spawn measurement cannot be reproduced in this checkout.
      RECOMMENDED: Run the census with the neutral file present and tracked, then set the ceiling to that measured count. Basis: .performance/ratchets.json:7 sets ceiling 6, and docs/conventions/source-control/ has no files in this checkout, so the with-file case is not measured here.
    2. Should the ratchet census command be changed to measure the with-file case, for example by seeding a tracked neutral file in a temp git repo? As written it runs with no file and would not catch this regression.
      RECOMMENDED: Yes, seed a tracked neutral file so the ceiling guards the with-file path. Basis: judgment
    3. Where should the edit be made, given the plugin copy is generated?
      RECOMMENDED: Edit lib/resolve-convention-pattern.sh, then run scripts/sync-shared-copies.sh to regenerate plugins/guardrails/hooks/resolve-convention-pattern.sh. Basis: plugins/guardrails/hooks/resolve-convention-pattern.sh:2 says it is generated from lib/ and must not be edited.
    4. Is the awk-based h2_value path and the git ls-files tracked check in scope, or only yaml_value, check_neutral_key and dirname?
      RECOMMENDED: Only the three named spots; the issue lists them, and the git call is a required policy-floor check. Basis: lib/resolve-convention-pattern.sh:163 comments the tracked-file policy floor.

    Sources read

    • plugins/guardrails/hooks/resolve-convention-pattern.sh:133: yaml_value runs grep -m1 -E piped to tr on each call
    • plugins/guardrails/hooks/resolve-convention-pattern.sh:195: dirname spawn in the canonical-directory check
    • plugins/guardrails/hooks/resolve-convention-pattern.sh:221: check_neutral_key runs a separate grep -q
    • plugins/guardrails/hooks/resolve-convention-pattern.sh:306: grep -E validity probe on the final pattern
    • plugins/guardrails/hooks/resolve-convention-pattern.sh:2: file is generated from lib/ by scripts/sync-shared-copies.sh
    • lib/resolve-convention-pattern.sh:128: canonical source holding yaml_value
    • lib/resolve-convention-pattern.sh:193: canonical dirname call
    • lib/resolve-convention-pattern.test.sh: existing test file for the resolver
    • .performance/ratchets.json:7: guardrails-commit-guard-spawns ceiling is 6, measured with no neutral file

    Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.

  7. added a commit that references this issue on Oct 24, 2026
  8. removed
    needs-owner-decision
    on Oct 24, 2026
  9. kyle-sexton commented on Oct 24, 2026

    @kyle-sexton
    MemberAuthor

    Released for re-triage under the owner's 2026-10-24 rule: an issue stops for a person only for an intent or vision question, a security call, a host or attended run, or spend outside prepaid credit. The hold label came off and intake triage runs again now; it re-applies a hold, with a numbered question, when one of those applies.

    To hold this issue again, add needs-human (or status: needs-decision) and say why in a comment.

  10. added
    status: ready
    needs-owner-decision
    and removed
    status: ready
    on Oct 24, 2026
  11. melodic-automation-lanes commented on Oct 24, 2026

    @melodic-automation-lanes
    Contributor

    The latest triage verdict holds nothing: the issue is at status: ready.

  12. melodic-automation-lanes commented on Oct 24, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: The resolver reads the neutral convention file once with a bash read loop and uses parameter expansion instead of dirname, and the guardrails-commit-guard-spawns ceiling drops to the new census count.

    Acceptance criteria

    • lib/resolve-convention-pattern.sh yaml_value no longer runs grep or tr; it takes the first matching key line and strips CR with bash builtins (read loop and parameter expansion)
    • lib/resolve-convention-pattern.sh check_neutral_key no longer runs grep -q; key presence comes from the same single read of the neutral file
    • The neutral file is read at most once per resolver run, and dialect, subject_pattern and pr_title_pattern values all come from that one read
    • The symlink check in lib/resolve-convention-pattern.sh uses ${NEUTRAL_FILE%/*} instead of $(dirname "$NEUTRAL_FILE")
    • plugins/guardrails/hooks/resolve-convention-pattern.sh is resynced from lib/ and the shared-copies check in scripts/shared-copies.txt passes
    • Resolver output and exit codes are unchanged for quoted, single-quoted, CRLF, empty-valued, missing-key, comment-line and dialect-mismatch inputs, covered by the existing resolver tests passing and a test for any case not yet covered
    • Running the guardrails-commit-guard-spawns census command from .performance/ratchets.json prints a spawns count below 21 with docs/conventions/source-control/commit-convention.yml tracked
    • The ceiling of guardrails-commit-guard-spawns in .performance/ratchets.json equals that measured count, and its goal text no longer says #​9526 tracks lowering it

    Dependencies

    • No blocking dependency: PR #​9527 already re-baselined the ratchet at 21 and is closed, so the ceiling to lower is the current one

    Related work

    Sources read

    • lib/resolve-convention-pattern.sh:128: yaml_value runs grep -m1 -E and tr -d per call
    • lib/resolve-convention-pattern.sh:193: canon_dir uses $(dirname "$NEUTRAL_FILE")
    • lib/resolve-convention-pattern.sh:216: check_neutral_key runs grep -q then yaml_value
    • lib/resolve-convention-pattern.sh:101: h2_value uses awk, and line 304 runs a grep -E validity probe; both stay outside this change
    • plugins/guardrails/hooks/resolve-convention-pattern.sh:130: generated copy with the same code, offset by two lines
    • scripts/shared-copies.txt: lists resolve-convention-pattern for the lib to plugin copy sync
    • /.performance/ratchets.json:7: guardrails-commit-guard-spawns ceiling is 21

    Automated refinement by the lanes App. Admission counts only criteria a listed human wrote: to confirm these, post them as your own comment whose first line is **Decision recorded.**, which sends the issue back through intake.

  13. removed
    needs-owner-decision
    on Oct 25, 2026
  14. kyle-sexton commented on Oct 25, 2026

    @kyle-sexton
    MemberAuthor

    Released for re-triage under the owner's 2026-10-24 rule: an issue stops for a person only for an intent or vision question, a security call, a host or attended run, or spend outside prepaid credit. The hold label came off and intake triage runs again now; it re-applies a hold, with a numbered question, when one of those applies.

    To hold this issue again, add needs-human (or status: needs-decision) and say why in a comment.

  15. github-actions commented on Oct 26, 2026

    @github-actions
    Contributor

    The triage sweep dispatched intake triage for this issue (attempt 1 of 2).

  16. added
    status: ready
    on Oct 26, 2026
  17. added
    agent-ready
    on Oct 27, 2026
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-readystatus: ready

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions