Repository navigation
Add config validation: every rule and its sentinel (GH-21) - #60
Merged
Merged
Conversation
internal/config/validate.go implements the design's validation table in full, offline, and fails at the first broken rule with its sentinel wrapped in %w so KindOf keeps naming it in JSON output. LoadFile runs it, so a *Config that reaches the planner has passed every rule; Parse deliberately does not, which is what lets the normalisation tests drive fragments that were never meant to be whole files. Both length bounds count Unicode code points via utf8.RuneCountInString. len() would reject a valid 100-emoji description as though it were 400 while passing every ASCII test written to check it — the boundary cases the #18 probe measured are in the table by name. Names and colours are compared case-insensitively, and so are both rename rules, per the #16 spike: a rename whose "from" is itself a configured label is rejected, which makes a case-only rename an error rather than a redundant entry, since step 5 converges casing drift on its own. Colour uniqueness is global rather than per-repository. That is deliberately conservative and carries a comment saying so. The emoji-only name rule strips emoji, variation selectors, zero-width joiners, and whitespace and asks whether anything is left. Its range table errs towards not matching: a pictograph it misses only lets an emoji-only name through to the 422 it would have hit anyway, whereas one it wrongly matched would reject a name GitHub accepts.
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 free
to 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.
Closes #21.
Summary
internal/config/validate.go: every rule in the design's validation table, offline, first broken rule wins, each wrapped in its sentinel with%wsoKindOfkeeps naming it.LoadFilenow runsValidate, so a*Configreaching the planner has passed.Parsedeliberately does not, which keeps the normalisation goldens able to drive fragments.utf8.RuneCountInString), per the Spike: determine label description behaviour on length overflow #18 probe; names and colours — and both rename rules — fold case, per the Spike: confirm GitHub rejects case-variant label names in one repository #16 spike.Notes on scope
ValidateintoLoadFileis slightly beyond the issue's literal scope — without it nothing would call the rules, and the design says validation happens at config load.