Skip to content

tests/test_scaffold_pin_and_reuse.py: the two descendant scaffold tests run the scaffolded project's validate-pins.py with --pin-source for the stand-in they pinned and assert the digest recomputes, so neither reaches a real gh api nor passes on a skipped digest (#272) - #274

Merged
brettheap merged 1 commit into
mainfrom
fix/scaffold-tests-pin-source
Oct 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-4 (openRepoShape-4)
Claim: #272 (comment)

Summary

test_a_declared_descendant_scaffolds_with_legs (openGlass) and test_a_descendant_that_pins_a_layer_scaffolds_through_the_chain (openXdox) ran the scaffolded project's own scripts/validate-pins.py with no arguments. validate-pins.py finds a neutral pin's source in four places and no other (resolve_neutral_pin_source): --pin-source <product>=<path>, SHAPE_PIN_SOURCE_<PRODUCT>, a checkout beside the assembly root, a bare --pin-source. The tests met none of them (run_script blanks every SHAPE_PIN_SOURCE_* the caller did not name, the stand-in sits at tmp_path/<product>, and the loop passed []), so it fell to tree_digest_from_gh, a real gh api repos/opensoft/<product>/git/trees/<sha>?recursive=1 whenever a gh is on PATH. A failed read is a skip line with exit 0, so both tests passed on a digest nobody rechecked and depended on the operator's gh login and network, against tests/conftest.py's "NO NETWORK AND NO GITHUB".

This change touches tests/test_scaffold_pin_and_reuse.py only:

  • The validate-pins.py row of each loop passes --pin-source openGlass=<stand-in> / --pin-source openXdox=<layer>, the spelling test_a_neutral_product_root_may_also_pin_a_neutral_product already used. The naming and manifest validators keep their arguments; the second test's declared-unverified assertion on them is unchanged and still holds.
  • A new helper, assert_pin_digest_recomputed, asserts that validate-pins.py's stdout carries <product>: pin commit <sha12> digest recomputes and no skip <product>: line, with a message saying the digest must be recomputed from the stand-in, never skipped. The exit code cannot tell a recompute from a skip; the stdout line can.

Not in this change (the issue's optional decision 2): a suite-wide guard so no test can reach gh unnoticed (a failing gh shim in run_script, or an autouse fixture). It touches every test on three OSes, and a Windows shim needs PATHEXT handling, so it is a possible follow-up.

Closes #272

Evidence

A gh shim first on PATH appends argv, PYTEST_CURRENT_TEST and the calling process to a log and exits 97. Command (two tests):
pytest tests/test_scaffold_pin_and_reuse.py::test_a_declared_descendant_scaffolds_with_legs tests/test_scaffold_pin_and_reuse.py::test_a_descendant_that_pins_a_layer_scaffolds_through_the_chain -q

bytes result shim log
main c3f4987 2 passed (the bug) 2 lines: api repos/opensoft/openGlass/git/trees/<sha>?recursive=1 and api repos/opensoft/openXdox/git/trees/<sha>?recursive=1, both from scripts/validate-pins.py
this branch 2 passed 0 lines
mutant: --pin-source dropped from the openGlass row only 1 failed (test_a_declared_descendant_scaffolds_with_legs, on assert_pin_digest_recomputed), 1 passed 1 line (openGlass)
mutant: --pin-source dropped from the openXdox row only 1 failed (test_a_descendant_that_pins_a_layer_scaffolds_through_the_chain, on assert_pin_digest_recomputed), 1 passed 1 line (openXdox)

Over the committed head, with the same shim: pytest tests/test_scaffold_pin_and_reuse.py tests/test_neutral_pin_validator.py tests/test_repo_hygiene.py -q gives 81 passed, 0 skipped, and the shim log is empty for all 81.

CI's three OSes (tests, tests-macos, tests-windows) are the gate; the new code adds no stdin, path-separator or shell handling beyond what the third test's --pin-source row already carries.

Summary by Sourcery

Make descendant scaffold pin validation deterministic and network-independent by supplying local pin sources and requiring digest recomputation.

Bug Fixes:

  • Ensure descendant scaffold tests validate pinned digests against their local stand-ins instead of allowing skipped checks that can fall through to GitHub API access.

Enhancements:

  • Add assertions that pin validation recomputes the expected digest and does not report a skipped product.

Tests:

  • Strengthen scaffold pin and reuse tests to verify digest recomputation and detect regressions that would invoke external GitHub access.

…ts run the scaffolded project's validate-pins.py with --pin-source for the stand-in they pinned and assert the digest recomputes, so neither reaches a real gh api nor passes on a skipped digest (#272)

`validate-pins.py` resolves a neutral pin's source from four places and
no other (`resolve_neutral_pin_source`): `--pin-source <product>=<path>`,
`SHAPE_PIN_SOURCE_<PRODUCT>`, a checkout beside the assembly root named
for the pinned repository, and a bare `--pin-source`. The two
descendant scaffold tests ran the scaffolded project's `validate-pins.py`
with no arguments and met none of them: `run_script` blanks every
`SHAPE_PIN_SOURCE_*` the caller did not name, the stand-in sits at
`tmp_path/<product>` and not beside `work/<Project>`, and the loop
passed `[]`. So it fell to `tree_digest_from_gh`, a real
`gh api repos/opensoft/<product>/git/trees/<sha>?recursive=1` whenever a
`gh` is on PATH, and a failed read is a `skip` line with exit 0: the
tests passed on a digest nobody rechecked and depended on the operator's
`gh` login and network, against tests/conftest.py's "NO NETWORK AND NO
GITHUB".

The `validate-pins.py` row of each loop now passes
`--pin-source openGlass=<stand-in>` and `--pin-source openXdox=<layer>`,
the spelling `test_a_neutral_product_root_may_also_pin_a_neutral_product`
already used. The naming and manifest validators keep their arguments,
and the second test's `declared-unverified` assertion on them is
unchanged. A new helper, `assert_pin_digest_recomputed`, asserts that
stdout carries `<product>: pin commit <sha12> digest recomputes` and no
`skip <product>:` line, with a message saying the digest must be
recomputed from the stand-in, never skipped; the exit code cannot tell
the two apart, so the tests now fail if the source stops being found.

Evidence, with a `gh` shim that logs argv and exits 97 first on PATH:
main's bytes log two `api repos/opensoft/openGlass/...` and
`.../openXdox/...` lines and both tests pass; these bytes log none and
pass, and dropping the new `--pin-source` from either test turns only
that test red, on the new assertion.

A suite-wide guard against any test reaching `gh` (the issue's decision
2) is not part of this change.

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 16 hours and 7 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The two descendant scaffold tests now point validate-pins.py at the stand-in repositories they pinned and assert the validator actually recomputes each digest, preventing false-positive passes caused by skipped checks or unintended GitHub API access.

File-Level Changes

Change Details Files
Ensure descendant scaffold tests validate pin digests against their local stand-ins instead of falling back to remote GitHub lookups.
  • Pass product-specific --pin-source arguments to the scaffolded validate-pins.py invocations.
  • Preserve existing naming, manifest, and declared-unverified assertions.
tests/test_scaffold_pin_and_reuse.py
Add explicit output-based assertions that pin digests were recomputed and not skipped.
  • Check for the expected pin commit and digest-recomputed stdout line.
  • Reject skip output because validate-pins.py can otherwise exit successfully after an unavailable gh API lookup.
  • Include diagnostic output in assertion failures.
tests/test_scaffold_pin_and_reuse.py

Assessment against linked issues

Issue Objective Addressed Explanation
#272 Ensure the two descendant scaffold tests provide the local stand-in source when running the scaffolded project's validate-pins.py, so validation recomputes the pinned digest locally instead of falling back to gh api. ✅
#272 Make the tests fail if the pinned product's digest is skipped rather than actually recomputed. ✅
#272 Prevent these tests from reaching GitHub or depending on the operator's gh login and network. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit 67a398a into main Oct 11, 2026
5 checks passed
@brettheap
brettheap deleted the fix/scaffold-tests-pin-source branch October 11, 2026 23:48
brettheap added a commit that referenced this pull request Oct 12, 2026
…, #272 via #274, #205 via #232) into fix/adopt-record-submodule-placement

Brings in 23e16ae (#251), 60588d5 (#206), 018ce0d (#207), 67a398a (#272)
and d94d155 (#205) on top of 5751460. No rebase. The first four change
none of this branch's files. d94d155 changes shape-doctor.py and
tests/test_shape_doctor.py, as this branch does.

One conflict, in shape-doctor.py's module docstring, under EXIT CODES.
Both sides added a clause to exit 1's list of findings: #205 "a manifest
is there and does not load", and #189 "or, for a submodule, a leg other
than the one `project.yaml` records for it". Both are kept: #205's in its
place in the list, and #189's after the path-policy clause it qualifies.
Only the docstring's first line reaches `--help`, so docs/cli.md is
unchanged.

Merged without a conflict, and checked:

- `check_placement`: #205 adds its `waiting_row` gate after the
  family-holder return and before `ctx.legs()`. The merged function is
  this branch's plus exactly those eight lines. So a `project.yaml` that
  does not load makes the placement row `n/a`, waiting on the `manifest`
  row, before the record is read. The record is read from `ctx.manifest`,
  which #205 now loads once, with the same `load_yaml`, so a manifest that
  loads gives the record it always gave.
- #205 removes `Context._declares`, and nothing on this branch names it.
  This branch leaves `placement_row` unchanged, and #205's gate calls it as
  (NA, reason, None, detail).
- No top-level name is bound twice in adopt-project.py,
  scaffold-project.py, scripts/repo_shape.py, scripts/shape_materialize.py,
  shape-doctor.py, validate-manifest.py or update-shape.py. Each merged
  module's names are the base's plus what either side added. Every
  definition only one side changed is that side's text. The two that both
  changed are the docstring above and `check_placement`.
- These commits leave adopt-project.py, scripts/repo_shape.py and
  scripts/shape_materialize.py untouched. So the record's writer and
  reader are the ones the round trip and the revert table ran on at
  a01ab02, and the record is still spelled by `double_quoted`.
- AGENTS.md is untouched: 472 lines, under the cap of 472.
- The branch's diff against main is still #189 alone: 12 files, +1670
  -157. The one deletion more than against 5751460 is the EXIT CODES
  sentence above, which now rewraps two of #205's lines.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…, #205, #215, #241 and #249/#250 merge with no conflict, and `_entry_findings` still hands `_leg_findings` the tree and ends with the root-symlink findings

origin/main moved 60588d5 -> b30595c while the targeted runs of 8f624aa
went: 018ce0d (#207 via #222), 67a398a (#272 via #274), d94d155 (#205
via #232), c2ff2b0 (#215 via #240), c3a9645 (#241 via #256) and b30595c
(#249 and #250 via #284). It is merged again because c2ff2b0 changes
adopt-project.py and b30595c changes scripts/shape_materialize.py's
`render`.

Conflicts: none. `git merge-tree --write-tree` gave tree be093a5, and
the merge stages the same tree.

Checked on that tree:
- `_entry_findings` still calls `_leg_findings(plan, tree)` and ends
  with `_root_symlink_findings(plan, source, tree)`.
- No top-level name is bound twice in adopt-project.py,
  scaffold-project.py, scripts/repo_shape.py or
  scripts/shape_materialize.py, none is loaded but bound nowhere (AST),
  and main changed the signature of no function this branch calls.
- Both sides are intact by +/- line sets: each side's change against the
  merge base 60588d5 reappears, line for line, against the other side.
- c2ff2b0 adds helpers to tests/conftest.py (`planned`, `GITLINK`,
  `findings` and others) and no fixture. tests/test_adopt_root_symlinks.py
  imports its conftest names one by one and none of these, so its own
  `planned` and `GITLINK` are unaffected.
- b30595c's `render` spells a double-quoted YAML value with
  `double_quoted`; this branch's walker reads `assembly_root_paths()` and
  never renders.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant