Repository navigation
Conversation
… an Editor Agree On (#1510) Closes #1503. A validator is only as strict as the comparison its value eventually meets, and three defects of that shape were found in three files in one day. #1504 fixed the environment name and branch for whitespace, and the issue then measured why that cannot close the class: `str.strip()` removes the 29 characters Python calls whitespace and leaves U+200B, U+200C, U+200D, U+2060, U+FEFF, U+00AD and U+180E standing. Each of those is invisible, and each is exactly as unmatchable by `select(.name == $n)` as a trailing space. A padded name is refused and its zero-width twin is accepted, and both fail in the same place for the same reason. ## A grammar per field, stated positively `spec/validate.py` now declares three patterns and applies them instead of a `.strip()` comparison. Stated positively a grammar admits nothing invisible in either direction, needs no notion of whitespace, and cannot drift when a Python release changes what `str.isspace()` answers. The fields need separate grammars rather than one, because their consumers differ. A deployment environment `name` is one line of printable ASCII with no leading or trailing space, an interior space admitted since GitHub documents no character restriction beyond length and uniqueness. A deployment branch policy name is a ref *pattern*, so `releases/*` is legitimate and the grammar admits every visible ASCII character rather than the alphabet the three names the registry declares today happen to use: a grammar fitted to `pypi`, `production` and `staging` would pass every test and every live value, and refuse the first adopter declaring a release line. A `groundTruthBranch` is concatenated raw into a request path and a `?ref=` query value, so it admits only the RFC 3986 unreserved characters plus `/`. ## The schema is advisory, so it answers to the validator No gate runs `registry/repos.schema.json`. `.github/actions/validate` runs `spec/validate.py` and nothing else, and the only thing resolving the schema is an editor, in ECMA-262. Its `description` pattern carried a `$comment` claiming it was kept in sync with `description_errors()`, and it was out of sync in two directions at once, measured rather than predicted: pattern ^\S(?:[^\n\r]*\S)?$ "desc\n" Python re: matches ECMA-262: does not "\ufeffdesc" (a BOM) Python re: matches ECMA-262: does not "desc\ufeff" (a BOM) Python re: matches ECMA-262: does not So the pattern admitted a trailing newline the validator refuses, while an editor refused a value the gate allows. The three patterns the schema now copies are the exact strings `spec/validate.py` declares, and a test fails if they ever stop being identical. Every pattern in the file is written in what the two engines share: `(?![\s\S])` rather than `$`, which is end-of-string in only one of them, and literal ASCII ranges rather than `\s` or `\S`, which name a different set in each. Measured across all four patterns and 33 values, including every invisible character above, the two engines disagree on nothing. The `description` pattern stays the schema's own statement rather than a copy, deliberately looser than the validator, because a description may legitimately carry a tier-2 or tier-3 non-ASCII character that no portable positive grammar enumerates. A test asserts that direction over a corpus. `exclusionReason` loses its `\S` pattern for the same reason and keeps `minLength`. #1504 reverted an editor-side copy for leaving the editor stricter than the gate, and agreement measured in both engines is what makes this one safe. ## The sweep, and the two findings it turned up that are fixed here The issue asks which declared fields are consumed by an exact comparison or concatenated into a URL or a path, and whether each is validated to the strictness that consumer requires. The name-into-path shape is the highest-consequence one, and both instances are fixed: `url` reached `spec/audit.py`'s `repo_slug()`, which took the last two path segments of the raw value. The gate matched on `.strip()` and made a trailing `.git` optional, stripping it for the identity only, so `https://github.com/<owner>/<repo>.git` passed and then addressed `repos/<owner>/<repo>.git/...` in fifteen reads, plus a Docker Hub URL whose 404 is skipped by design and so silently stops checking anything. Rather than adding a second check, `repo_slug()` now calls the validator's own `github_identity()`. One parse means the validator cannot be looser than the consumer by construction. `groundTruthBranch` had no validation at all, in the validator or the schema, while `spec/audit.py`, `spec/fidelity_honesty.py` and `spec/workflow_reuse.py` each concatenate it into a path segment and a `?ref=` value. Every reader defaults on absence rather than falsiness, so a declared `""` survives and reads the branch *list*, and `main?ref=x` sends a different request rather than failing. The `url` field's own grammar already excludes `?` and `#`; the field landing in the same URLs had nothing. Also fixed, since it is three lines inside the loop being rewritten: `environment_errors_for_repo` accepted a branch declared twice inside one `custom` set. `configure.sh` sorts and joins both sides, so the duplicate makes the declaration longer than any live set can be and reports as drift on an environment that has none. The issue lists this as out of scope, and it is named here rather than left in a function this change rewrites around it. The sweep's lower-ranked findings are filed rather than fixed here. ## What the local strict review pass changed It raised twelve findings and every one that held is answered here rather than filed. Three are worth naming, because the first draft was wrong about each: `repo_slug()` raised on a url the grammar does not parse. `spec/audit.py` wraps `audit_repo` in `except Exception` and survives that, but `spec/fidelity_honesty.py` and `spec/workflow_reuse.py` call it on every entry with no handler, so one malformed url aborted a whole fleet report that previously 404'd and bucketed it. It now falls back to the old segment split, because this module is not the gate: `spec/validate.py` refuses such a url, nothing runs it before an audit, and the finding belongs on the gate rather than on the report. `GITHUB_URL_RE` still ended in `$`, the exact trap the rest of this change adds a test to forbid, so a newline-padded url parsed while a space-padded one did not. It ends in `(?![\s\S])` now. `repo_identity()` held a byte-identical second copy of that regex behind a comment claiming the two were in sync. It calls `github_identity()` instead, and it keeps its `.strip()`, deliberately and one-directionally: this is the function that decides whether a live repo has an entry at all, so a padded url refusing to resolve here would report the repo as having no entry, a DEFECT naming the wrong problem. The selftest case that pins this is what caught the first attempt to remove it. Also from that pass: `--branch` reaches the same path segment and `?ref=` value the registry field does, and had no check, so `--branch 'main?per_page=1'` retargeted every read. The branch grammar's first character was alphanumeric for no reason a consumer has, which refused the legal `_wip` while the error message listed `_` as allowed, so both ends now admit everything except a `.` and a `/`, and the message says exactly that. The two `groundTruthBranch` fields reach one `$def` rather than two literals. And four tests were passing on code they did not constrain, each now proven by mutation: dropping the check's wiring into `main()`, restoring the `.strip()`, widening the branch grammar to admit `?`, and making `repo_slug()` raise again each fail at least one test, where before all four left the suite green. Verified: ruff format and check, mypy, 1350 tests, `spec/validate.py`, `spec/audit.py --selftest`, the prose gate, and the EOL gate. All five patterns the tree now holds agree across Python `re` and ECMA-262 on 43 values, including every invisible character named above. ## What the second pass changed `GROUND_TRUTH_BRANCH_PATTERN` admitted `..`, and the live API resolves it. Measured: `gh api "repos/ptr727/ProjectTemplate/branches/a/../../../../../zen"` returns 200 with GitHub's `/zen` body, and `branches/x/../../../../../repos/ptr727/PlexCleaner/branches/main` returns PlexCleaner's head, which `audit_repo` would then take as this repository's ground-truth head. A value the first draft accepted read a different repository. A positive character class cannot say "no two of these adjacent", so the grammar now opens with `(?![\s\S]*\.\.)`, a whole-string negation both engines read identically. The `--branch` override had the same hole and the same fix. `~` was admitted on the strength of RFC 3986 calling it unreserved, and `git check-ref-format refs/heads/~x` rejects it, so the grammar promised a name no repository can hold and a test asserted it as valid. It is excluded, and the grammar is now stated as the intersection of the two rule sets rather than as one of them. Checked against git directly: `_wip`, `wip-` and `a.b` are legal and pass, `~x`, `a..b` and `a/../x` are rejected by git and refused here. The shape sentence the error messages print was a hand-written literal in two modules, in a change whose thesis is one definition. It is `GROUND_TRUTH_BRANCH_SHAPE`, and a test fails if the two messages ever stop quoting it. `defaults.groundTruthBranch` got the schema pattern and no gate check, so the advisory schema was briefly the stricter of the two, the direction this change forbids everywhere else. The gate checks that key now. `repo_slug()` still raised for an absent or non-string url, which `spec/workflow_reuse.py` reaches by constructing `{"name": HUB_NAME}` as its own fallback and calling this with no handler. It answers with the entry's name instead, which 404s like any other unparseable slug and names the entry in the message. `import audit` at module scope ran `git config` while importing, so a host with no git on `PATH` failed all of this file's cases including the ones that never touch audit. It is a local import in the one class that needs it. `assert_portable` refused the `[\s\S]` union in a lookahead body, which is the portable idiom rather than a divergent construct, and it only ever checked three constructs by shape. It strips that union first, and a new test executes every schema pattern in node against a 45-value corpus and asserts Python and ECMA-262 return the same verdict for each, so a future `\d`, `\w` or `(?P<name>...)` is caught by measurement rather than by enumeration. Reverted rather than kept: an attempt to hold the registry entry `name` to the same printable-ASCII grammar. `spec/validate.py`'s own dedupe tests deliberately declare `Straße` to pin the casefold normalizer, GitHub allows such a repository name, and an ASCII floor there refuses a legal value to fix an invisible-character case that has a filed issue instead. Six mutations, each of which left the suite green before this round, now fail at least one test: admitting `..`, re-admitting `~`, deleting the `--branch` guard, deleting the defaults check, raising on a missing url, and letting the two shape sentences drift. ## Deferred, filed rather than fixed here - #1508 carries the sweep's remaining six findings, each local to a different consumer. - #1509 carries the one documentation gap the `--branch` guard opens, in a carried canonical unit whose edit owes its own whole-unit review pass. ## Verification `ruff format --check`, `ruff check`, `mypy`, 1356 tests, `python3 spec/validate.py`, `python3 spec/audit.py --selftest`, the prose gate, the EOL gate, and `canonical_review.py check` are all clean on this head. Every schema pattern is executed in both Python `re` and ECMA-262 by a test in the suite, not only measured by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added validation for printable environment names, deployment branches, and ground-truth branches. - Added duplicate-branch detection and checks for invalid branch values in registry defaults and repositories. - Added consistent GitHub repository URL and identity validation. - **Bug Fixes** - Improved handling of padded, malformed, or non-string repository URLs. - Added clearer validation messages for invalid names and branches. - Updated schema rules to match validation behavior across supported engines. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe changes align registry schema patterns with validator grammars, add validation for environment names, branches, URLs, and ChangesRegistry validation and audit consistency
Estimated code review effort: 4 (Complex) | ~60 minutes Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Audit fallback handling avoids plausible slugs for malformed URLs, but unusual entry names with path-like segments may still influence audit request paths. This is a bounded, low-severity risk requiring hardening or explicit acceptance. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The changes satisfy the positive-grammar, branch-pattern, duplicate-branch, URL, and ground-truth-branch objectives in [ Resolution Remove [ Full details: Docstring CoverageExplanation Docstring coverage is 67.19% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 64 functions across 3 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
|
There was a problem hiding this comment.
🟢 Approval recommended
The changes are cohesive and well-tested; the only remaining feedback is a small wording fix in a new schema $comment.
Pull request overview
This PR promotes develop to main while hardening fleet-registry validation by replacing whitespace-based checks with portable, positive regex grammars that match what downstream consumers actually compare/concatenate, and by ensuring the schema, validator, and audit tool share the same parsing rules.
Changes:
- Introduces portable, positive grammar regexes in
spec/validate.pyfor deployment environment names, deployment branch policy patterns, andgroundTruthBranch, plus a sharedgithub_identity()parser. - Updates
spec/audit.pyto reuse the validator’s URL parsing and to validate the--branchoverride against the samegroundTruthBranchgrammar. - Expands the test suite to assert validator/schema byte-identity and cross-engine regex agreement, and updates
registry/repos.schema.jsonto mirror the portable patterns.
File summaries
| File | Description |
|---|---|
| spec/validate.py | Adds portable positive grammars and centralizes URL-to-identity parsing to align validation with consumers. |
| spec/audit.py | Reuses shared parsing/validation to prevent URL/path retargeting and avoid drift between audit and validator. |
| scripts/tests/test_spec_validate.py | Adds regression and cross-engine portability tests that pin schema/validator agreement. |
| registry/repos.schema.json | Mirrors validator patterns via $defs so editor validation matches gate behavior. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ts Below Its Reference (#1514) Copilot, on the #1513 promotion pull request: the environmentName $comment said a zero-width space "is already trimmed", which reads as str.strip() removing it, while the tests in the same change assert the opposite. The first attempt at that sentence was longer and wrong in two new ways, found by the local pass over it. "A name carrying one is already in trimmed form" is false in general, since " <zws>pypi" is not, and it holds only for the narrower case the tests assert, where the zero-width character is the whole padding. And inserting "a padding check" gave "that comparison" a nearer antecedent than the one it meant, so the sentence read as saying a check accepts the value and then that the value fails that same check. The sentence is shorter instead of more qualified. It says str.strip() does not remove a zero-width space, that a name ending in one survives a padding test, and that it then matches no live environment, which is the consequence named rather than referred to. It also attributes the ASCII floor to CODESTYLE.md "Character set", which is where spec/validate.py locates it, rather than to the zero-width case, which argues for a grammar over a negative test and not for the ASCII bound. Two defects from #1510 in the same file go with it, since both are stated here and nowhere else. The sibling $comment said "the two patterns below" after that change moved the name pattern into $defs, so the reference below it is a $ref rather than a pattern, and its first sentence duplicated the one now in $defs/environmentName. Wording only. No pattern, no check and no test changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🟢 Approval recommended
The changes appear correct and well-tested, with only minor comment/maintainability nits remaining.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
spec/validate.py:353
- The comment cites
https://github.com/../rate_limitas a URL that "passed the gate", but with the newGITHUB_URL_REowner grammar that URL no longer matches at all. Rewording avoids tying the rationale to an example that is now rejected earlier by the regex.
spec/validate.py:357 - The dot-only-segment guard redundantly checks
owner.strip('.') == '', but the owner group inGITHUB_URL_RE([A-Za-z0-9-]+) cannot contain.. Dropping the unreachable branch keeps this logic aligned with the URL grammar and avoids implying owners can be dot segments.
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Lite
…lready Refuses (#1515) Copilot raised both of these as suppressed low-confidence findings on the #1513 promotion pull request, and both hold. The owner half of the guard is unreachable. GITHUB_URL_RE's owner group is `[A-Za-z0-9-]+`, which cannot match a dot at all, so `owner.strip(".")` is never empty and the branch says an owner can be a dot segment when the grammar two lines above already settles that it cannot. The comment's example was misattributed for the same reason. `https://github.com/../rate_limit` no longer reaches the guard, it is refused by the owner class, so citing it as a url that "passed the gate" next to the guard credited the wrong half of the fix. The comment now names each position with the evidence that belongs to it, and the two differ. The owner position is where the traversal actually resolved: `repos/../rate_limit` returns 200 with the rate-limit document and `repos/../..` returns the API root. The repo position is refused for a narrower reason, measured while answering this: `repos/ptr727/../rate_limit` returns 404 rather than a different document, so the claim is not that it traverses but that the normalization eats a segment either way, which leaves what a read addresses decided by the shape of that read rather than by the declaration. The test corpus keeps both positions rather than trusting whichever half holds, since they are now refused by different halves. Dropping the remaining guard fails three of its cases. Both were suppressed findings, which open no thread, so this pull request is where they are answered. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
Answering the two suppressed findings from the round on
Correct, and it credited the wrong half of the fix. That url is refused by the owner character class and never reaches the guard the comment sat above.
Correct and unreachable, so the branch is gone. Answering these turned up something the change had wrong in a way neither finding names. The two positions do not behave alike, and the comment had been treating them as one hazard. Measured against the live API while answering: |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are cohesive, security-motivated, and come with comprehensive tests that pin both validator behavior and schema/editor portability.
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Lite
Promotes
developtomain.Closes #1503.
Validate a Registry Value by a Positive Grammar Both Its Consumer and an Editor Agree On (#1510)
A validator is only as strict as the comparison its value eventually meets. #1504 fixed a deployment environment name and its branch set for whitespace, and #1503 then measured why that cannot close the class:
str.strip()removes the 29 characters Python calls whitespace and leaves U+200B, U+200C, U+200D, U+2060, U+FEFF, U+00AD and U+180E standing. Each is invisible and each is exactly as unmatchable by an exact comparison as a trailing space, so refusing padding admits the zero-width twin that fails in the same place for the same reason.Three grammars replace those tests, stated positively so they admit nothing invisible in either direction, need no notion of whitespace, and cannot drift when a Python release changes
str.isspace(). They differ because their consumers differ: a deployment environment name is one line of printable ASCII, a deployment branch policy name is a ref pattern soreleases/*is legitimate, and agroundTruthBranchis concatenated raw into a request path and a?ref=value so it admits only what is both unreserved in RFC 3986 and legal in a git ref name.registry/repos.schema.jsonis advisory, since no gate runs it, so it carries the validator's exact pattern strings through$defs and a test fails if they stop being identical. Itsdescriptionpattern claimed a sync it did not have, in two directions at once:"desc\n"matched in Python and not in ECMA-262, and a BOM-prefixed value matched in Python and not in ECMA-262, so the pattern admitted a trailing newline the validator refuses while an editor refused a value the gate allows. Every pattern is now written in what the two engines share, and a test executes each one in both and asserts they agree.What the review rounds found, which is most of the value here
Five rounds, three local adversarial passes and two Copilot rounds, each finding something the round before it had introduced or missed. The two that matter most were both proven against the live API:
GROUND_TRUTH_BRANCH_PATTERNadmitted... A branch read whose ref traverses upward returns another repository's head with a 200, andspec/audit.pywould take that as this repository's ground-truth head. Percent-encoding is no defense, since the encoded form normalizes the same way, so the grammar refuses the sequence outright.The same hole sat on the url field, and there it passed the gate:
GITHUB_URL_RE's segments were[^/\s?#]+, which admits a segment that is nothing but dots, so a traversing url parsed,spec/validate.pyprinted "Spec validation OK", and the audit's first read returned a non-repository document with a 200 instead of failing. The two segments now name GitHub's own character sets, and a dot-only segment is refused ingithub_identity, which leaves.github,v1.0anda..bresolving.spec/audit.py'srepo_slug()andrepo_identity()each held a looser parse of their own, which is how the url field came to be validated by one rule and addressed by another. Both callgithub_identity()now. Its fallback for a url that does not parse went through three shapes before landing: taking the url's last two path segments produced a plausible slug that read an unrelated repository, percent-encoding those segments left a one-segment value that shifted every later path component up one, and a dots-only entry name re-entered the traversal through the name. It answers with two segments that cannot name a repository.Also from those rounds: the
--branchoverride reaches the same path segment and?ref=value the declared field does and had no check; the grammar's first character was alphanumeric for no reason a consumer has, refusing a legal_wipwhile the error message listed_as allowed; the shape sentence was a hand-written literal in two modules in a change whose thesis is one definition;defaults.groundTruthBranchbriefly had a schema pattern and no gate check, making the advisory schema the stricter of the two; andimport auditat module scope ran a git command while importing, so a host without git failed every case in the test file.An attempt to hold the registry entry
nameto the same printable-ASCII grammar was reverted on measurement:spec/validate.py's own dedupe tests deliberately declare a non-ASCII name to pin the casefold normalizer, GitHub allows such a repository name, and an ASCII floor there refuses a legal value. It is #1508 instead.Verification
Thirteen mutations that leave the suite green without this change now fail it, including admitting a dot segment, widening the url classes back, deleting the
--branchguard, and every earlier shape of the fallback slug.ruff format --check,ruff check,mypy, 1359 tests,spec/validate.py,spec/audit.py --selftest, the prose gate, the EOL gate, andcanonical_review.py checkare clean.Follow-ups filed rather than fixed
AUDIT.mdclause the--branchguard leaves incomplete, in a carried canonical unit whose edit owes its own whole-unit review pass.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests