Repository navigation
Harden the derived MAJOR_RELEASE: manifest-shape guard and bounded policy-text search (follow-up to #679) - #681
Conversation
Two real findings taken from the second Copilot review round: - _major_release() now checks contracts/manifest.yaml parses to a mapping before calling .get() on it, raising a clear message instead of an unhelpful AttributeError on a malformed manifest. - The policy-parsing test helpers now bound their search to the entry each targets: _bounded_entry() stops at the next top-level bullet or section heading instead of scanning to end-of-document, and _consumer_block_target() asserts its pattern matches exactly once. Both guards exist so a future policy entry that happens to share phrasing with an existing one cannot be silently matched by mistake — the exact class of drift this test file exists to catch. Declined finding (spec_from_file_location()'s loader may be None): matches the identical, unmodified pattern already used by tests/credential_contracts/test_consumer_block_phasing.py and test_requirement_ref_resolution.py; changing it only in the new file would diverge from established convention for a test-only import helper whose path is a hardcoded literal. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv Lane: openxfactory-1
There was a problem hiding this comment.
Hi @brettheap! 👋
Your private repo does not have access to Sourcery.
Please upgrade to continue using Sourcery ✨
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped, improve robustness without altering intended behavior, and the new guards are consistent with existing error handling and test intent.
Pull request overview
This PR is a follow-up hardening pass on the MAJOR_RELEASE derivation and its policy cross-check tests (originally introduced in #679 to fix #634). It improves failure modes when contracts/manifest.yaml is malformed and tightens the policy-text parsing helpers to avoid accidental matches as the policy document evolves.
Changes:
- Add a manifest-shape guard in
_major_release()to fail with a clearSystemExitmessage ifcontracts/manifest.yamldoesn’t parse as a mapping. - Strengthen policy parsing in
test_major_release_matches_policy.pyby bounding an entry scan to a single bullet/section and requiring the consumer-block pattern to match exactly once.
File summaries
| File | Description |
|---|---|
| scripts/validate-credential-contracts.py | Adds a defensive manifest type-check to produce a clear error instead of an AttributeError when deriving MAJOR_RELEASE. |
| tests/credential_contracts/test_major_release_matches_policy.py | Makes policy parsing more robust against future document edits by bounding entry text and asserting single-match patterns. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Lane: openxfactory-1 (openXfactory-1; session 5e783e4d) Provenance for the admin merge of #681 (follow-up to #679: the two Copilot round-2 hardening fixes that reached the branch three minutes after #679's merge — the race was the coordinator's, landing on a green monitor before the author had frozen). Word: Brett Heap, 2026-09-05 — "do both as a batch on one word". Head 🤖 Generated with Claude Code |
Lane: openxfactory-1 (openXfactory-1)
Refs #634
Follow-up to #679
#679 (merge commit
1be0cc21) landed the core fix for #634 —MAJOR_RELEASEderived fromcontracts/manifest.yamlinstead of pinned, plus the policy cross-check test. While it was in flight, Copilot's automatic second-round review (triggered by that PR's second commit) posted three robustness findings. Two real ones were fixed and pushed asf9a854dfon the original branch, but the admin merge of #679 landed on heada2459badabout three minutes beforef9a854dfreached the remote — a race, not a rejection — so those two fixes never made it intomain. This PR is that same commit, cherry-picked ontoorigin/main, so they land now.What this adds
_major_release()inscripts/validate-credential-contracts.pynow checks thatcontracts/manifest.yamlparses to a mapping before calling.get()on it, raising a clear message instead of an unhelpfulAttributeErrorif the manifest is malformed or empty.tests/credential_contracts/test_major_release_matches_policy.pynow bound their search to the entry each targets:_bounded_entry()stops at the next top-level bullet or section heading instead of scanning to end-of-document, and_consumer_block_target()asserts its pattern matches exactly once. Both guards exist so a future policy entry that happens to share phrasing with an existing one cannot be silently matched by mistake — the exact class of drift this test file exists to catch.Declined finding (not carried into this PR):
spec_from_file_location()'s.loadercould in principle beNonein the test helper. Declined because it matches the identical, unmodified pattern already used bytests/credential_contracts/test_consumer_block_phasing.pyandtest_requirement_ref_resolution.py; changing it only here would diverge from established convention for a test-only import helper whose path is a hardcoded literal.No behavior change: refuse/warn logic and the messages' derived release name are unchanged from what #679 shipped — this only hardens the derivation and the guard-test against malformed input and future false matches. No OpenSpec change.
Gates
pytest tests/ -q -k credential— 281 passed.python3 scripts/validate-credential-contracts.py .(packaged self-test) —self-test: 8 positive + 19 negative + 13 warning example(s) confirmed, 11 deprecation code(s) probed.Codex not re-requested (already recorded ABSENT on #679 for the same usage limit). Real Copilot defects only, per the disposition above.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv