Port the pr-explain report validator to Go (parse-shaped carve-off) #142
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools#142
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story: So that every new report-grammar rule is a tokenizer visitor instead of a hand-built awk parser, the PR explanation validator should migrate to Go alongside the other program-shaped bash tools.
Part of the "Migrate program-shaped bash tools to Go" arc — refs #98, which predates this tool and does not list it.
pr-explain/lib.shis now ~2,400 lines, and nearly all of it is one program shape: a parser-linter that enforces a deliberately narrow HTML grammar with grep/awk over raw bytes. It is the single largest bash-tax payer in the repo, and the redesign on #141 is still adding rules (objective coverage, layer ordering, slop linting), each one a fresh chance to write a subtly wrong regex.The evidence is already on the branch: the first attended v2 run explained #141 itself and was rejected by its own validator, because the report quoted
PR_EXPLAIN_PROVIDER_PID=""inside a codewalk and the E3 identifier census, grepping raw bytes case-insensitively, countedPID=""as an id attribute. The body was valid; the validator was wrong. The fix was to hand-build a tag tokenizer in awk — that is, to start writing the Go program in the wrong language. A real tokenizer deletes that bug class instead of patching one instance of it.Scope:
pr_explain_validate_reportand its helpers) and thevalidate-reportentry point to a Go binary, standard library only. Build a strict tokenizer for the one-tag-per-line grammar; do not use a lenient HTML parser that normalizes what the validator exists to reject.validate-reportCLI (3- and 9-argument forms), theallod pr _validate-reportsurface, one diagnostic per line with theE*/W*codes, warnings-versus-errors semantics, and exit codes. The ~104-probe conformance suite intests/pr-explain/validation.shmust pass unchanged against the binary; that suite is the port's acceptance test.pr-explain/explain(env sanitization, traps, snapshot verification, provider invocation). That is pipeline-shaped bash and stays bash, per the #98 boundary.Sequencing: after the #141 redesign slices land. The grammar is still moving; porting a moving target buys a merge conflict, not a tokenizer. Reasonable slot: alongside or after #98 Phase 1 (
forge), since the two ports share no code and can proceed independently.Implementation PRs should use
Refs allod/tools#<this>; the cutover PR that switchesallod pr _validate-reportto the binary carries the closing keyword.