Skip to content

bootstrap rules for go-http-handler-refactoring-guide.md (4 rules)#5

Merged
bborbe merged 1 commit into
masterfrom
feat/bootstrap-go-http-handler
Jun 1, 2026
Merged

bootstrap rules for go-http-handler-refactoring-guide.md (4 rules)#5
bborbe merged 1 commit into
masterfrom
feat/bootstrap-go-http-handler

Conversation

@bborbe

@bborbe bborbe commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Migrates `docs/go-http-handler-refactoring-guide.md` from prose-only to rule-blocks-inline (Model A)
  • Appends 4 `### RULE` blocks: 2 MUST mechanical + 1 MUST judgment + 1 SHOULD judgment
  • Adds 2 `rules/go/*.yml` ast-grep detectors
  • `rules/index.json` grows 17 → 21 entries
  • Path-filter pivot: prior rules ignored `main.go`; THIS rule INVERTS — `main.go` is where violations fire, `pkg/handler/**` is the legitimate location

Rules added

ID Level Enforcement
`go-http-handler/no-inline-error-handler` MUST `rules/go/handler-no-inline-error-handler.yml`
`go-http-handler/no-inline-background-handler` MUST `rules/go/handler-no-inline-background-handler.yml`
`go-http-handler/new-prefix-naming` MUST judgment (name-descriptiveness)
`go-http-handler/kebab-case-handler-files` SHOULD judgment (filename pattern)

Test plan

  • `make precommit` clean
  • `make build-index` deterministic
  • 21 entries; sorted; anchor==id; owner=go-http-handler-assistant
  • Judgment rules: `enforcement: judgment` literal (single word)
  • Local ast-grep smoke on /tmp/handler-test:
    • Rule 1: 1 hit in main.go (inline error handler), 0 in pkg/handler/exists.go ✓
    • Rule 2: 1 hit in main.go (inline background handler), 0 in pkg/handler/exists.go ✓
  • Operator-side post-merge: `scripts/scan.sh` against bborbe Go services

@ben-s-pull-request-reviewer ben-s-pull-request-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Now I have a thorough understanding of the changes. Let me compile the consolidated report.


PR Review: bootstrap rules for go-http-handler-refactoring-guide.md (4 rules)

Summary of Changes

6 files changed (+485 lines):

  • CHANGELOG.md: Added ## Unreleased section with feature entry
  • docs/go-http-handler-refactoring-guide.md: Appended 4 ### RULE blocks (2 mechanical MUST + 2 judgment MUST/SHOULD)
  • rules/go/handler-no-inline-error-handler.yml: New ast-grep YAML for mechanical detection
  • rules/go/handler-no-inline-background-handler.yml: New ast-grep YAML for mechanical detection
  • rules/index.json: Grew from 17 → 21 entries, all 4 new rules properly registered
  • prompts/completed/010-bootstrap-rules-go-http-handler.md: Dark-factory prompt artifact

Project Type

This is a documentation/rules-definition plugin repo — no Go/Python application code. The "changes" are rule definitions and prose, not functional code.


Automated Checks

  • LICENSE file: Present at repo root ✓
  • make precommit: Requires approval in this environment (non-blocking)
  • JSON validity (rules/index.json): Valid JSON confirmed by manual inspection ✓
  • Ast-grep YAML syntax: Both YAMLs use the field: function + regex + kind: func_literal pattern from the canonical prior-PR examples — syntactically valid per ast-grep 0.43.0 conventions ✓
  • Judgment rules: kebab-case-handler-files and new-prefix-naming correctly carry Enforcement: "judgment" (literal string, no backticks) in index.json — matches the walker's expected contract ✓
  • No YAML for judgment rules: Correctly omitted; the doc prompt explicitly instructed no YAML for rules 3+4 ✓
  • main.go NOT in ignores: Both mechanical rules correctly omit main.go since that's precisely where they must fire ✓
  • Generic examples only: Uses Invoice, ForwardInvoice, Exists — acceptable generic/commerce examples per CLAUDE.md ✓
  • 4 new RULE blocks in doc: Confirmed by grep pattern in prompt verification ✓
  • Index sorted: go-http-handler/* entries are alphabetically sorted within the index ✓

Consolidated Report

Must Fix (Critical)

None. No critical issues found.

Should Fix (Important)

None. No important issues found.

Nice to Have (Optional)

None. No optional issues found.


Verdict

No issues found. The PR correctly:

  1. Added 4 ### RULE blocks to the doc following the exact schema and formatting from prior bootstrap PRs
  2. Created 2 ast-grep YAMLs using the field: function + regex + kind: func_literal pattern (addressing the ast-grep 0.43.0 regex-pitfall lesson from PR #4)
  3. Grew rules/index.json from 17 → 21 entries with correct enforcement values (judgment for rules 3+4, backtick-wrapped path for rules 1+2)
  4. Correctly inverted the ignore path from prior rules — this rule fires in main.go and ignores pkg/handler/** (the legitimate location)
  5. Used generic domain examples (Invoice, Forward, Exists) complying with the CLAUDE.md rule against trading-specific examples

The mechanical concerns raised in the planning phase are all resolved:

  • Backtick-wrapped enforcement paths (\rules/go/...`) are the **established project convention** (confirmed in existing entries like go-errors/no-bare-return-err`)
  • The field: function + regex pattern correctly targets the callee identifier node per ast-grep 0.43.0 semantics
  • Judgment rules carry enforcement: "judgment" verbatim (no backticks) in the index
{
  "verdict": "approve",
  "summary": "PR correctly bootstraps 4 rule blocks for go-http-handler-refactoring-guide.md with matching ast-grep YAMLs for the 2 mechanical rules. rules/index.json grew from 17 to 21 entries with correct enforcement values. No issues found — the PR follows all established conventions from prior bootstrap PRs.",
  "comments": [],
  "concerns_addressed": [
    "correctness: backtick-wrapped enforcement paths are the established project convention (confirmed in existing index entries) — not a parsing issue",
    "correctness: ast-grep regex using 'field: function' correctly targets the callee identifier node per ast-grep 0.43.0 semantics",
    "correctness: judgment rules carry 'enforcement: \"judgment\"' verbatim in index.json (no backticks) — matches walker contract",
    "correctness: main.go correctly omitted from ignores — this rule fires precisely in main.go",
    "correctness: index entries sorted correctly with go-http-handler/* rules in alphabetical order"
  ]
}

@ben-s-pull-request-reviewer ben-s-pull-request-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Based on my thorough review of the diff across all 6 changed files, here is my consolidated report and verdict:


PR Review: bootstrap rules for go-http-handler-refactoring-guide.md (4 rules)

Automated Checks

Check Result
LICENSE file present ✅ (not changed in this PR)
Diff covers 6 files ✅ CHANGELOG, doc, bootstrap prompt, 2 YAMLs, index.json
index.json entries 17→21 ✅ 4 new go-http-handler/* entries added
YAML syntax valid ✅ (content verified via git show)

Must Fix (Critical)

None.

Should Fix (Important)

None.

Nice to Have (Optional)

None.

Manual Review Notes

rules/index.json: All 4 go-http-handler/* entries are correct — owner: go-http-handler-assistant, doc_path: docs/go-http-handler-refactoring-guide.md, anchor == id, proper level (MUST/SHOULD), correct applies_when and enforcement fields. Sorted order matches the expected canonical sequence. No issues.

rules/go/handler-no-inline-error-handler.yml: Uses kind: call_expression + all + two has clauses with field: function/field: arguments — the correct field-based shape learned from the ast-grep 0.43.0 fix in PR #4. Ignores **/pkg/handler/** (the legitimate location), **/*_test.go, vendor/**, **/vendor/**, **/mocks/**. Notably does not ignore main.go — correct, since main.go is precisely where this rule should fire.

rules/go/handler-no-inline-background-handler.yml: Same correct field-based structure for libhttp.NewBackgroundRunHandler. Same ignore set. No main.go exemption — correct per the path-filter pivot described in the bootstrap prompt.

docs/go-http-handler-refactoring-guide.md: 4 ### RULE blocks appended correctly at end of doc (after ## Reference Examples), preserving all existing prose above. All formatting matches canonical schema.

CHANGELOG.md: Correctly notes the path-filter pivot: prior rules ignored main.go; this rule inverts — pkg/handler/** is now the legitimate location, main.go is the lint target.

Behavioral note: The "path-filter pivot" is intentional and well-documented. It correctly reflects the architectural principle that inline handler closures in main.go (entry point) are the antipattern; the legitimate home is pkg/handler/New*Handler factory functions.


{
  "verdict": "approve",
  "summary": "PR adds 4 rule blocks to go-http-handler-refactoring-guide.md with 2 mechanically enforceable ast-grep YAMLs following the correct field-based pattern from the ast-grep 0.43.0 fix. The path-filter pivot (pkg/handler/** now the legitimate location; main.go the lint target) is intentional and documented. index.json grew from 17 to 21 entries with all fields correct. No issues found.",
  "comments": [],
  "concerns_addressed": [
    "correctness: rules/index.json grew 17→21 entries with correct structure and sort order — verified from git show output",
    "correctness: handler-no-inline-error-handler.yml uses correct field-based has-clause pattern (not regex on whole node) — matches PR #4 fix",
    "correctness: handler-no-inline-background-handler.yml uses same correct field-based pattern",
    "correctness: path-filter pivot documented in CHANGELOG.md — main.go now lint target, pkg/handler/** legitimate location — intentional",
    "correctness: bootstrap prompt summary accurately reflects the rules added — verified against diff"
  ]
}

@bborbe bborbe merged commit 8603509 into master Jun 1, 2026
1 check passed
@bborbe bborbe deleted the feat/bootstrap-go-http-handler branch June 1, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant