Skip to content

repo_shape.py: NamingPolicy reads a name with .match against patterns that end in $, so a name that ends in a line feed is classified as the name without it, and validate-repository-naming.py exits 0 over such a leg repository (#1166 follow-up) #1202

Closed

Description

@brettheap

(lane openRepoShape-5, 2026-10-23)

Goal: a repository name that ends in a line feed matches no family of the naming policy, as it matches none that it should not, and validate-repository-naming.py refuses it by name.

Problem

#1139's Goal says that every ^...$ pattern that reads a value from a file with .match refuses a value that ends in a line feed. #1166 (#1139) ends the seven module-level patterns of the two validators, scripts/family.py, scripts/shape_advisory.py and update-shape.py in \Z, and reads the three ids with fullmatch. It does not touch NamingPolicy, whose patterns come from contracts/repository-naming.yaml, every one ^...$, and are read with .match. In Python $ also matches just before a trailing line feed, and the YAML reader reads a double-quoted "...\n" as the text and a line feed. Found by lane 5's independent review of #1166, finding 1 (#1166 issuecomment-6352173084).

Where, on main 961640c6:

  • scripts/repo_shape.py:2264 (descendant_referents, family["_re"].match(name)), :2266 (family["_split_re"].match(name)), :2432 (matches, role["_re"].match(name)) and :2435 (family["_re"].match(name)).
  • scripts/repo_shape.py:2228: topic_pattern, ^xf-project-[a-z0-9][a-z0-9-]*$ by default. Nothing outside tests/test_naming_policy.py:422 reads it at main, and the data's topic.pattern and topic.id_pattern (contracts/repository-naming.yaml:481-482) are read by no tool.
  • The data's patterns: contracts/repository-naming.yaml lines 125, 182, 202, 221 (split_pattern), 336, 345, 353, 359, 376 and 412.

Which readers can be handed a name that ends in a line feed:

The cost is small: a hand-edited manifest or a $'Atlas\n' argument. But the answer is wrong in two places. The gate exits 0 for a name that no family spells, and its table splits the name from its family over two lines.

Measured

On main 961640c6 and at #1166's head 2593952c, in scratch clones of the shared repository, Python 3.12.3, git 2.43.0, a stub gh and no network.

In process (NamingPolicy.load(contracts/repository-naming.yaml)). Each of these names, with a trailing line feed, gives the same matches and classify as without it, at main and at #1166's head alike (scripts/repo_shape.py is not in #1166's diff):

Name classify(name) with and without \n
Atlas ('project-leg', 'assembly')
Atlas-spec, Atlas-code ('project-leg', 'spec'), ('project-leg', 'code')
openFoo ('neutral-product', 'assembly')
Thing-Install ('install', None)
user-wip ('workspace', None)
InkxRouter, MedxScribe ('project-leg', 'assembly'), and descendant_referents gives ('openRouter', 'openxRouter') and ('openScribe', 'openxScribe')

Atlas-Spec (a capital S) is None with and without the line feed. topic_pattern.match('xf-project-atlas\n') is a match.

The gate over a manifest (validate-repository-naming.py --project project.yaml in a scaffolded root, one leg's repository: written "testorg/Atlas\n"):

Run Naming gate validate-manifest.py
main, leg testorg/Atlas\n exit 0; ' Atlas', then ' project-leg/assembly' on the next line manifest ok, exit 0
main, testorg/Atlas-spec\n and testorg/Atlas-code\n exit 0, the same split manifest ok, exit 0
#1166's head, the same three exit 0, the same split exit 1, FINDING manifest-leg-repository: leg 'assembly': repository is 'testorg/Atlas\n', expected <org>/<Name>

So after #1166 the project's gate as a whole still fails, through the manifest check, but the naming step passes and prints the split table.

Argv: validate-repository-naming.py $'Atlas\n' and $'Atlas-spec\n' exit 0 at main and at #1166's head, each name and its family on two lines. The same name from stdin is stripped and gives the family on one line.

The fix probed. In a scratch clone of main (commit 2776736ec, never pushed), .fullmatch in place of .match at the four sites of repo_shape.py (:2264, :2266, :2432, :2435) gives:

  • every name above, with a line feed, has matches == [], classify is None and no referents; the names without it are unchanged;
  • the naming gate over the three manifests above exits 1, FINDING naming-unclassified: Atlas (and Atlas-spec, Atlas-code); over argv the same;
  • validate-manifest.py at main, run beside that repo_shape.py, also says FINDING naming-unclassified: leg 'assembly': 'Atlas\n' matches no family in the naming policy, exit 1, so this one change closes the leg-repository gap in both gates, for a project whose own repo_shape.py is updated;
  • tests/test_naming_policy.py, tests/test_pinned_copy_text.py, tests/test_path_guard_hygiene.py and tests/test_repo_hygiene.py pass, with the probe rows: 504 passed, 18 deselected, in 50.38s.

Suggested fix

Verify

  • Rows for each of the four sites, table-driven over policy.families and each family's roles, so a family added to the data is covered: a name that ends in a line feed gives matches == [], classify is None and descendant_referents == (). Each row fails on main.
  • A row for the gate: validate-repository-naming.py --project over a manifest whose leg repository: ends in a line feed, for each of the three roles, exits 1 with naming-unclassified; and one over an argv name.
  • Names without a line feed give the answers they gave: tests/test_naming_policy.py passes unchanged.
  • Mutants: each of the four sites put back to .match is killed by a row.
  • tests/test_pinned_copy_text.py, tests/test_path_guard_hygiene.py, tests/test_repo_hygiene.py, tests/test_agents_md_codes.py and tests/test_cli_reference.py pass. No new refusal code is needed, so nothing in AGENTS.md changes.

Found by lane 5's independent review of #1166 (#1139), finding 1 (#1166 issuecomment-6352173084), and re-measured at main 961640c6.

Milestone: none; it lands after the v1.2.0 tag (Brett Heap's 10:32:04Z ruling of 2026-10-21).

Lane: openreposhape-5 (openRepoShape-5)

Activity

  1. added this to the v1.2.1 milestone on Oct 23, 2026
  2. brettheap commented on Nov 8, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-5, session 50cede29-ab82-4ca3-9f67-d98e1a58c8d2@Eagle, 2026-11-08T16:05:52Z, for #1202

    Logged in lanes/log/openRepoShape-5.md at 8b3e487116b3f11412fff0ab9e6c5371cddb1c86.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#1202:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#1202"`, kept where the row or its body names `#1202`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `1202` as a whole token:
       none
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions