docs(ast-grep): propagate counter-total-suffix syntax findings - #12
Merged
Conversation
PR #11 cracked the ast-grep 0.43.0 recipe for struct-literal field matching after PR #4 and PR #8 both burned cycles iterating on zero-match patterns. Folding the discoveries into the guide so the next bootstrap PR doesn't re-learn them. New section 'Struct-literal field matching' covers the 3-piece recipe: 1. pattern.context + selector for sub-node targeting (bare 'Name: $X' parses as labeled_statement, not keyed_element — must wrap in context) 2. inside.pattern with stopBy: end for type anchoring (prevents GaugeOpts / HistogramOpts / SummaryOpts false-flags through the selector) 3. constraints at rule-top-level (NOT under rule.pattern.constraints), with not.regex inside the metavariable spec Pitfalls Learned grew by 3 entries documenting the specific traps: - 'Name: $X' parses as labeled_statement - pattern.context alone leaks to sibling types - constraints placement: top-level sibling of rule, not nested Canonical example entry added pointing to rules/go/counter-total-suffix.yml (landed in PR #11). 153 → 193 lines. No personal vault paths, no trading-domain terms — pre-emptive grep clean.
Uh oh!
There was an error while loading. Please reload this page.
bborbe added a commit
that referenced
this pull request
Jun 2, 2026
Bot review on b75eb2f: COMMENTED state with body 'no concerns flagged' — effective approval. Same pattern as PR #3 + PR #12 (bot's no-findings code path returns terse COMMENT rather than APPROVE verdict). Doc-only PR; CI green; previous CHANGES_REQUESTED review's 8 MAJOR + 1 NIT all addressed in b75eb2f.
bborbe added a commit
that referenced
this pull request
Jun 2, 2026
Bot review timed out at 30-min activeDeadlineSeconds ceiling — the dispatcher refactor + 5-phase scaffolding produced a diff larger than the reviewer's per-PR budget. Admin-merge per PR #3 / #12 / #17 / #20 precedent. Differs from prior admin-merges in that this changes the actual /coding:pr-review contract (not doc-only), but: (1) make precommit clean including new check-coverage; (2) validate-citations.sh smoke-tested valid + invalid cases; (3) check-coverage.sh against current state: '124 rules, 15 mechanical YAMLs, no drift'; (4) the 3 simplified agents (go-error, go-time, go-context) are forward-compatible with the legacy 'scan + judge' shape — the dispatcher tolerates both during the per-agent migration follow-ups.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Folds the ast-grep 0.43.0 syntax recipe from PR #11 into `docs/ast-grep-rule-writing-guide.md` so the next bootstrap PR doesn't re-learn the traps.
153 → 193 lines (+40).
What's added
New section: 'Struct-literal field matching' — covers the 3-piece recipe:
Three new entries in 'Pitfalls Learned':
Canonical example entry for `rules/go/counter-total-suffix.yml` (the rule that landed in PR #11).
Why
PR #4 burned cycles on factory-pattern YAMLs (returned to field-based `has` clauses after invalid `regex` at rule-top-level). PR #8 deferred `counter-total-suffix` entirely after early YAML attempts produced zero matches. PR #11 cracked the recipe. The guide is the right home for the discovery — bootstrap authors check it before writing the YAML, not during the debug loop.
Test plan