You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chore(go-format): document known generated-file-guard edge-case gaps (bash vs ast.IsGenerated parity) #927
plugins/go-format/hooks/go-format.sh's generated-file guard is a bash-string-matching approximation of Go's own ast.IsGenerated detector (the canonical implementation is a full AST/comment parse). Across PR #910's review, an automated Codex pass progressively found and (each time) got a real fix for: a bare marker, a //-style header before the marker, a /* */ block-comment header, an indented block-comment header, and a tab-only blank separator line. All five are now covered by regression tests (cases 5–5h in go-format.test.sh).
This is the expected shape of chasing bash-string-match parity with an AST-based detector: the gap between the two is structural, not a single fixable bug, so further narrow edge cases (particular exotic combinations of build tags, multi-line block-comment nesting, unusual Unicode whitespace, etc.) can keep surfacing indefinitely. The guard is advisory only — the hook never blocks an edit; the worst case for an unhandled shape is goimports reformatting a generated file, visible in the diff, no gate broken.
Decision
Per review discussion on #910: the guard is correct for every realistic generated-file shape a real Go code generator or license-header tool actually produces. Chasing full ast.IsGenerated parity via string-matching would mean either endless narrow patches (churn, not value) or replacing the bash approximation with something that shells out to go for a real parse (a materially bigger design change: latency per edit, a hard go toolchain dependency, - not proposed here).
No further guard patches planned unless a real-world generated file is observed defeating it. This issue exists so a future finding (bot-raised or human-observed) has a place to land without re-litigating the tradeoff, and so the known-limitation is documented rather than implicit.
If revisiting
Document the specific real-world generated-file shape that defeated the guard (not a synthetic/contrived one).
Consider whether a go toolchain shell-out (parsing via go/parser + the actual ast.IsGenerated-equivalent logic, or reusing golang.org/x/tools' own detection helper if one is exported) is now warranted, given the concrete case — that would be the actual fix for structural parity, not another bash pattern.
This was generated by AI (triage-decide lane — intake routing).
Routed status: ready. The tradeoff is already decided in the issue body (per review discussion on #910: no further guard patches; bash-string-match parity with ast.IsGenerated is a structural gap, not a fixable bug). The remaining deliverable is small and design-free: make the known limitation explicit rather than implicit.
Fix pattern (documentation only — no behavior change):
Add a short comment block at the generated-file-guard function in plugins/go-format/hooks/go-format.sh stating it is a deliberate bash approximation of Go's ast.IsGenerated (advisory-only, worst case = goimports reformats a generated file, visible in diff), and that full parity is out of scope absent an observed real-world defeating case.
Record the same known-limitation + the "if revisiting" criteria (real defeating shape, go-toolchain shell-out tradeoff) wherever go-format documents behavior (its plugin README / conventions doc if one exists).
Acceptance: a future finding (bot- or human-observed) has this issue and the in-code note as the landing spot; no new regression tests required beyond the existing cases 5–5h.
Done (2026-07-22): Documented the generated-file guard's known bash-vs-ast.IsGenerated structural gap as a maintainer-facing comment in hooks/go-format.sh (single home, not duplicated into README). Docs-only, no behavior change; existing suite 45/45, shellcheck clean.
Fixed in #937 (post-green review pass clean — both review and security-review bot passes returned no findings; flipped ready).
Will auto-close when #937 merges (Closes #927 present in the PR body).
Activity
kyle-sexton commentedon Jul 22, 2026
This was generated by AI (triage-decide lane — intake routing).
Routed
status: ready. The tradeoff is already decided in the issue body (per review discussion on #910: no further guard patches; bash-string-match parity withast.IsGeneratedis a structural gap, not a fixable bug). The remaining deliverable is small and design-free: make the known limitation explicit rather than implicit.Fix pattern (documentation only — no behavior change):
plugins/go-format/hooks/go-format.shstating it is a deliberate bash approximation of Go'sast.IsGenerated(advisory-only, worst case = goimports reformats a generated file, visible in diff), and that full parity is out of scope absent an observed real-world defeating case.go-toolchain shell-out tradeoff) wherever go-format documents behavior (its plugin README / conventions doc if one exists).Acceptance: a future finding (bot- or human-observed) has this issue and the in-code note as the landing spot; no new regression tests required beyond the existing cases 5–5h.
kyle-sexton commentedon Jul 22, 2026
kyle-sexton commentedon Jul 22, 2026
Done (2026-07-22): Documented the generated-file guard's known bash-vs-
ast.IsGeneratedstructural gap as a maintainer-facing comment inhooks/go-format.sh(single home, not duplicated into README). Docs-only, no behavior change; existing suite 45/45, shellcheck clean.Fixed in #937 (post-green review pass clean — both
reviewandsecurity-reviewbot passes returned no findings; flipped ready).Will auto-close when #937 merges (Closes #927 present in the PR body).
docs(go-format): document generated-file guard's known bash-vs-ast.Is…