Repository navigation
tests/test_value_pattern_line_break.py: ID_READERS gives adopt-project.py's argv --id the reason that holds (match, then validate-manifest.py refuses a line feed), a row proves it, and the guard says a new reader needs a row, fullmatch too - #1243
brettheap wants to merge 1 commit into
Conversation
…ject.py`'s argv `--id` the reason that holds (`match`, then validate-manifest.py refuses a line feed), a row proves it, and the guard says a new reader needs a row, `fullmatch` too #1166's table and module docstring said every argv `--id` of the three tools "holds the id to `checked_value`". It holds for `scaffold-project.py` and `family.py init` (`tests/test_derived_id_refusals.py`'s `TOOLS` are those two), and not for `adopt-project.py`: `plan` asks the id with `match` (`PROJECT_ID_RE.match(project_id)` in `_refuse_bad_id`), which takes `northwind` and a line feed, and calls `checked_value` on `--project` only. The line feed is still refused, by another door: the project's own validate-manifest.py, as `adopt-manifest-invalid` naming `--id`. The module docstring's bullet and the `adopt-project.py` row of `ID_READERS` say so now, and one new row runs `adopt-project.py plan --id` with a trailing line feed and asserts exit 2, that refusal in its first line, and no plan written. It is measured for `plan` only. The docstrings also said a new reader that asks with `fullmatch` passes the guard. It does not: the guard is a dict equality over every (module, method), so any reader added needs a row and a reader taken away loses its row. Both docstrings say that, and the assert has a message that names `ID_READERS` and says to add, change or drop the row the diff shows. The docstrings also say the guard reads spellings: an alias of the pattern is outside it. No production file changes. Closes #1229 Lane: openreposhape-5 (openRepoShape-5) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Reviewer's GuideUpdates the line-break pattern tests so each File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
|
Independent review of #1243 (#1229) for lane openRepoShape-5, by rv1243 (sonnet), at f92338e: READY The review is complete except one cell. I did not re-measure the hygiene five on git 2.47.1, because LAST STEP arrived first. Those five did pass on git 2.43 (337 passed). The writer's own log (
Refs at the start. Run discipline. For about a minute I had three of my runs live at once (the five, the plant driver and a small probe), one over the limit of two. The probe was a single test of about 40 s and I let it finish. Nothing else was affected. What I checked1. Every sentence the PR changes is true.
2. The issue's Verify plants. Each ran against the guard plus the new row, via run9.sh, in the scratch worktree
3. The new row.
4. Test runs (through run9.sh,
The slow times were load from other lanes. The writer's runs took 26 s and 111 s unloaded. 5. Hygiene of the diff.
6. Merge-trees (
FindingsMUST: none. SHOULD (PR body, not the code; the coordinator edits bodies)
NIT
Lane: openreposhape-5 (openRepoShape-5) |



Goal
tests/test_value_pattern_line_break.pysays only what is true of the readers ofPROJECT_ID_RE: no row ofID_READERSgives a reason that does not hold for the tool it names, and the guardtest_every_reader_of_the_id_pattern_is_in_the_tabletells the author of a new reader, in its docstrings and in its failure message, that the one way to pass is a row inID_READERS, whichever method the reader calls.This is #1229, the follow-up of #1166 (#1139): rc1166b's NIT 1, NIT 2 and NIT 4 (#1166 issuecomment-6371408915). Wording, one assert message and one row, in the test file only. No production file changes.
Stacked on #1166 at 5102b42 (branch
fix/1139-anchored-patterns, full sha5102b42945baf3682bc51244a64050e654d25e32, read again at the push). The test file is not on main, so this branch is built on #1166's head, and its one commit isf92338ef6. Until #1166 lands, this PR's diff against main also carries #1166's eight files. Against #1166's head it is one file, 56 lines added and 16 removed. After #1166 lands, restack with three merges, never a rebase: #1166's final head, then its squash commit on main (keeping THIS branch's side,ours, fortests/test_value_pattern_line_break.py, the one add/add conflict: the squash's side would drop every #1229 edit without a marker), then main.What held at #1166's head (
5102b4294)ID_READERSrows said every argv--idofscaffold-project.py,family.py initandadopt-project.py"holds the id tochecked_valueafter the pattern". That holds for the first two, andtests/test_derived_id_refusals.py'sTOOLSpins it for those two only.adopt-project.pynever callschecked_valueon--id:_refuse_bad_idasksPROJECT_ID_RE.match(project_id)of the idplantakes, passed or derived, andargs.idreaches nochecked_valuecall (git grep -n 'args\.id\b' -- adopt-project.py; its calls are for--project, the tracking branch,--pin-owner, the leg paths and--org). A line feed is still refused, by another door, the project's ownvalidate-manifest.py.fullmatchis enough" (rc1166b NIT 1). Both docstrings said a new reader "asks withfullmatch, or it is listed inID_READERS". The guard isassert id_pattern_calls() == expected, a dict equality over every (module, method), exact both ways, so a newfullmatchreader fails it too, and so does a listed reader taken away. The assert had no message, so the author of a sibling PR saw only a dict diff._ID = PROJECT_ID_REthen_ID.match(value)passes it, and so doesfrom repo_shape import PROJECT_ID_RE as X. Nothing in validate-manifest.py, validate-family.py, family.py and update-shape.py: anid:, a date or arepository:ending in a line feed is refused by name, and a pin'ssource_repository:that is no path orowner/reponame is named as the pin's (#1139) #1166 says that is false, and nothing says it.What changed
All in
tests/test_value_pattern_line_break.py.scaffold-project.pyandfamily.py initonly, withTOOLSas the proof, and a new bullet saysadopt-project.py's argv--idis NOT held tochecked_value:planasks it withmatchand callschecked_valueon--projectand never on the id, sonorthwind\npasses the pattern, and the project's ownvalidate-manifest.pyrefuses it asadopt-manifest-invalidnaming--id, inmanifest-id's words, exit 2, no plan written (the row below, "measured forplanonly"). Theadopt-project.pyrow ofID_READERSbegins with that reason in place of "argv--id, as above". Thescripts/family.pyandscaffold-project.pyrows are as they were.test_adopt_plan_names_a_passed_id_that_ends_in_a_line_break_as_an_idrunsadopt-project.py plan --idwith a trailing line feed (conftest'swrite_planover itssource_repo, oneplanrun of about a second) and asserts exit 2, the first stderr lineREFUSED adopt-manifest-invalid: --id is 'northwind\n', which the project's own validate-manifest.py refuses: manifest-id: id is 'northwind\n'; it must match ^[a-z0-9][a-z0-9-]*$., and that no plan file was written. It also importswrite_planfromconftest.--idand--id=...gave the same lines when measured.fullmatch, or": a new reader,fullmatchincluded, is listed inID_READERSwith the reason a line feed cannot reach it, or the test fails; the table is exact both ways, so a reader taken away loses its row. The comment aboveID_READERSsays a reader added later needs its row whichever method it calls.ID_READERSlists every call of a method ofPROJECT_ID_REoutsidetests/,fullmatchincluded, by module and method. Add, change or drop the row of the module and method the diff below shows, and give amatchorsearchreader the reason a line feed cannot reach it." Pytest prints it above the dict diff.PROJECT_ID_REor an attribute of that name) and stops there, with the two aliases named as outside it. S1 to S3 below measure exactly that.git grep -n 'checked_value' -- tests/test_value_pattern_line_break.pynow shows thechecked_valuereason only againstscaffold-project.pyandscripts/family.py(lines 43, 171, 173); the module docstring'sadopt-project.pybullet and theadopt-project.pyrow namevalidate-manifest.pyandadopt-manifest-invalidfor it, and sayadopt-project.pyis not held tochecked_value.Rows
The new row fails on main (
50869f384). The test file is #1166's, so it was copied from this head onto a detached worktree at main, and only the new row was run (git 2.43.0): it fails, because on main the manifest validator'sidpattern still takesnorthwindand a line feed ($matches before the line feed), and the line feed is refused only through the topic:So the row holds the claim that
manifest-idis the refusal, which is #1166's own change tovalidate-manifest.py, and it passes at #1166's head plus this commit (31 passed below). That is why this PR is stacked.Mutants and plants
Each applied alone to a scratch worktree (detached at
f92338ef6), run, restored by writing the original bytes back, and the sha256 compared (restored=Trueeach time,git statusclean after each). Production files only; the test file is not touched by a plant. Node ids: the guard istest_every_reader_of_the_id_pattern_is_in_the_table, the row is the new one above. Baseline before any plant: both pass (2 passed).update-shape.pydef _rc_probe(value): return PROJECT_ID_RE.fullmatch(value)appendedID_READERS;Left contains 1 more item: {('update-shape.py', 'fullmatch'): 1}update-shape.py.matchID_READERSupdate-shape.py.searchID_READERSadopt-project.pyif False:in place of the plan-id:test at line 6791ID_READERS;{('adopt-project.py', 'match'): 2} != {('adopt-project.py', 'match'): 3}adopt-project.pyfullmatchin place ofmatchat line 5140 (_refuse_bad_id)ID_READERS) and the row fails:REFUSED adopt-bad-id: --id 'northwind\n' must match ^[a-z0-9][a-z0-9-]*$adopt-project.pychecked_value('--id', project_id)added before line 5140REFUSED unsafe-value: --id is 'northwind\n', which is not a value this tool will put on a git or gh command lineadopt-project.pyif False:in place ofif values is not None:in_refuse_unholdable_values, so no manifest checkupdate-shape.py_ID = PROJECT_ID_REthen_ID.match(value)update-shape.pyfrom repo_shape import PROJECT_ID_RE as XthenX.match(value)update-shape.pyPROJECT_ID_RE.match(value)in a comment and in a stringNo mutant survives: G1 to G4 and R1 to R3 each fail where they should. R2 shows the new row also fails if
adopt-project.pyever does hold the id tochecked_value, which makes the module docstring's sentence false, so whoever adds that call is sent to the wording.Runs
All through the lane's runner
run9.sh(stubghfirst on PATH,GIT_SSH_COMMAND=false,GIT_CONFIG_GLOBAL=/dev/null,EMAILexported), on the committed headf92338ef6withdirty=0, Python 3.12.3,git --versionprinted into each log.tests/test_value_pattern_line_break.py: 31 passed on git 2.43.0 (25.78 s) and 31 passed on git 2.47.1 (31.21 s), the 30 of validate-manifest.py, validate-family.py, family.py and update-shape.py: anid:, a date or arepository:ending in a line feed is refused by name, and a pin'ssource_repository:that is no path orowner/reponame is named as the pin's (#1139) #1166's head plus the new row.test_pinned_copy_text.py,test_path_guard_hygiene.py,test_repo_hygiene.py,test_agents_md_codes.py,test_cli_reference.py): 337 passed on git 2.43.0 (111.39 s) and 337 passed on git 2.47.1 (264.87 s), that is 31 and the five's 306.git diff --checkis clean. The diff touches only the test file, adds no line over 79 columns (the file's own width) and no non-ASCII line, and the file has noassertthat joins conditions withandoror(anastscan for aBoolOpin any assert: none).Merge-trees
Main
50869f384(re-fetched just before the push), this headf92338ef6:git merge-tree --write-tree origin/main HEAD: clean (exit 0).git merge-tree --write-tree 5102b4294 HEAD(validate-manifest.py, validate-family.py, family.py and update-shape.py: anid:, a date or arepository:ending in a line feed is refused by name, and a pin'ssource_repository:that is no path orowner/reponame is named as the pin's (#1139) #1166's head): clean (exit 0).git merge-tree --write-tree origin/main 5102b4294(validate-manifest.py, validate-family.py, family.py and update-shape.py: anid:, a date or arepository:ending in a line feed is refused by name, and a pin'ssource_repository:that is no path orowner/reponame is named as the pin's (#1139) #1166 alone with main): clean (exit 0). The merge base of main and validate-manifest.py, validate-family.py, family.py and update-shape.py: anid:, a date or arepository:ending in a line feed is refused by name, and a pin'ssource_repository:that is no path orowner/reponame is named as the pin's (#1139) #1166's head is038dafba9.Of the 51 open PRs (
gh pr list --json number,headRefName,headRefOid,files), only #1166 touchestests/test_value_pattern_line_break.py. Not checked: whether a PR that touchesadopt-project.py(26 do) adds or removes a call of a method ofPROJECT_ID_RE; that is the guard's own job once #1166 lands, and #1166's body found none among the open PRs. A PR that makesplanhold--idtochecked_valuewould fail the new row (R2), which is the row doing its work.Closes #1229
Lane: openreposhape-5 (openRepoShape-5)
🤖 Generated with Claude Code
Summary by Sourcery
Make the line-break reader tests accurately account for adopt-project.py's argv ID validation and require complete, justified coverage for all PROJECT_ID_RE readers.
Bug Fixes:
Enhancements:
Documentation:
Tests: