Skip to content

Share the bounded read in scaffold and the blocked exit in doctor - #179

Draft
Deicyde wants to merge 3 commits into
mainfrom
golf/scaffold-doctor-duplicates
Draft

Deicyde wants to merge 3 commits into
mainfrom
golf/scaffold-doctor-duplicates

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #96. No behaviour change: 3 files, +23/-66, one commit per item.

  • _read_at_most (scaffold.py). _read_bounded_regular_file and _read_gitignore_descriptor each had their own chunked loop that read in 64 KiB pieces until end of file or one byte past the limit. The two now share one loop. The .gitignore reader used to raise inside its loop once the total passed _MAX_GITIGNORE_BYTES. It now checks the length after the read, which covers the same bytes and raises the same error.
  • Doctor's blocked exits (doctor.py). The graph-validation exit and the runtime-projection exit each appended the references, audit and lean targets checks by hand. The blueprint-resolution exit already used _blocked_result, which fills the remaining checks in _CHECK_NAMES order with the same names and text. All three exits now use it.
  • Scaffold test imports (tests/test_scaffold.py). 18 tests imported autoform_cli.scaffold as scaffold_module inside the function, although the module already imports it at line 21.

Noticed, not changed:

  • _blocked_lean_check now has only one caller, _blocked_result.
  • No test checks the references and audit details on the two exits that moved. Their output is unchanged, because _blocked_result builds the same checks.
  • The size check after the read in _read_bounded_regular_file fires only if the file grows between the stat and the read. No test reaches it, on this branch or on main.

Overlaps with open PRs:

Validation at exact head 39ce5f88: ruff check autoform_cli servers tests is clean. tests/test_scaffold.py (105), tests/test_doctor.py (14), tests/test_cli.py (5) and tests/test_project_create.py (257) pass.

_read_bounded_regular_file and _read_gitignore_descriptor each had a
loop that reads at most one byte past the limit, in two shapes. Both
now call _read_at_most, which issues the same os.read sizes. The
.gitignore reader raises its size error after the read instead of
inside the loop, still before the identity checks.
The graph-failure and runtime-failure exits spelled out the references,
audit and lean targets checks that _blocked_result already appends for
the blueprint-failure exit. Both now call it with the same reasons.
18 tests re-imported autoform_cli.scaffold as scaffold_module, which the
module already imports at the top.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant