Repository navigation
Derive MAJOR_RELEASE from the manifest instead of pinning it - #679
Conversation
scripts/validate-credential-contracts.py hard-pinned MAJOR_RELEASE to "contract-v3.0" — the release named by all eleven of its deprecation messages as where the consumer-block warnings become refusals. That major was cut on 2026-09-01 (followed by v3.1 and v3.2) without any of the acts landing, and docs/contract-versioning-policy.md's own restatement rule moved the target to contract-v4.0 at that cut. The constant lagged, so every message named an already-cut release. Replace the literal with a derivation: read contracts/manifest.yaml's contract_bundle_version and name one major past it. The policy document restates a spent target to exactly "one major past the one just cut" every time this has happened so far, so the derived value tracks the governed target without a future cut having to remember to move a string. Add tests/credential_contracts/test_major_release_matches_policy.py, which reads the two policy entries this validator's messages depend on (the consumer-block shape codes and the requirement-ref resolution-integrity pair) and asserts the derived MAJOR_RELEASE still names what they name — so a restatement that breaks the "next major" pattern, rather than merely advancing it, fails loudly instead of drifting again. No refusal/warning behavior changed; only the release name inside existing messages. Fixes #634 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 ✨
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
🟢 Approval recommended
The change is small and low-risk, and the added tests directly enforce the intended policy/code alignment going forward.
Pull request overview
This PR removes drift between scripts/validate-credential-contracts.py deprecation messaging and the governed deprecation target in docs/contract-versioning-policy.md by deriving MAJOR_RELEASE from the current contract bundle version (as declared in contracts/manifest.yaml) instead of pinning a literal.
Changes:
- Derive
MAJOR_RELEASEfromcontracts/manifest.yaml: contract_bundle_versionby computing “next major” (e.g.,contract-v3.4→contract-v4.0). - Add a pytest that parses the policy document’s “Deprecations Currently In Force” entries and asserts they match the derived
MAJOR_RELEASE.
File summaries
| File | Description |
|---|---|
| scripts/validate-credential-contracts.py | Replaces pinned MAJOR_RELEASE with a manifest-derived “next major” computation. |
| tests/credential_contracts/test_major_release_matches_policy.py | Adds policy-parsing tests to ensure MAJOR_RELEASE stays aligned with the deprecation targets the policy declares. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def _major_release() -> str: | ||
| """The release every deprecation below names, DERIVED rather than pinned | ||
| (openxFactory#634). A hand-pinned string went stale the moment | ||
| `contract-v3.0` — the release it named — was cut without the eight acts it | ||
| describes: `docs/contract-versioning-policy.md` § Deprecations Currently In | ||
| Force RESTATES the removal target to the NEXT major every time the current | ||
| one arrives without them, so the correct name is always "one major past the | ||
| one this bundle has cut", never a literal a future cut has to remember to | ||
| move. `tests/credential_contracts/test_major_release_matches_policy.py` | ||
| checks the derivation against that section's own text, so a restatement | ||
| that changes the pattern — rather than merely advancing it — is caught | ||
| there instead of here. | ||
| """ |
…omments Copilot review on PR #679 (#634): the two requirement-ref-resolution-integrity warning fixtures still had narrative comments saying "the refusal lands at contract-v3.0" — the same stale release the validator's MAJOR_RELEASE constant carried. These comments are documentary only (not read by any test or the validator itself, and not digest-tracked in contracts/manifest.yaml), but leaving them unfixed here would have been the same drift issue #634 exists for, one file over. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv Lane: openXfactory-1
|
Copilot's finding taken: both fixture comments' stale "contract-v3.0" release mentions updated to contract-v4.0 (restated from contract-v3.0, openxFactory#634) in a2459ba. |
There was a problem hiding this comment.
🔵 Needs a closer look
The core behavior looks correct, but there are a couple of small robustness issues in the new manifest/policy parsing logic that should be tightened to avoid unclear failures and future false matches.
Review details
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
scripts/validate-credential-contracts.py:158
- _major_release() assumes contracts/manifest.yaml always parses to a mapping; if the YAML is empty or the top-level value isn’t a dict, this will raise an AttributeError on .get() (and the resulting failure won’t point at the manifest shape). Consider validating the loaded type and exiting with a clear message instead.
tests/credential_contracts/test_major_release_matches_policy.py:34 - _validator_module() assumes spec_from_file_location always returns a spec with a loader; if it ever returns None (e.g., path renamed), the test will fail with a less-informative AttributeError. Adding an explicit assertion makes failures clearer and avoids None-dereference.
This issue also appears on line 55 of the same file.
tests/credential_contracts/test_major_release_matches_policy.py:59
- _resolution_integrity_target()’s comment says it limits the search to “up to the next bullet or section”, but the current code searches from the marker to the end of the document. That can produce false matches if another “removal target RESTATED to …” appears later in the policy. Consider bounding the searched substring to this entry’s block before running the regex.
marker = "A `requirement_ref` that RESOLVES TO NOTHING"
assert text.count(marker) == 1, f"expected exactly one {marker!r} bullet"
section = text.split(marker, 1)[1]
found = re.search(r"removal target RESTATED to (contract-v\d+\.\d+)", section)
assert found, "resolution-integrity entry's restated removal target not found"
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Lane: openxfactory-1 (openXfactory-1; session 5e783e4d) Provenance for the admin merge of #679 (plain fix PR for #634; no OpenSpec change — the validator's refuse/warn behaviour is unchanged, only the release it names). Word: Brett Heap, 2026-09-05 — "do both as a batch on one word". Head 🤖 Generated with Claude Code |
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
|
Copilot's second-round findings, disposition in f9a854d:
|
…release-hardening Lane: openxfactory-1 (openXfactory-1) Follow-up to #679 (1be0cc2): manifest-shape guard in _major_release() and a bounded policy-text search in the cross-check test. Refs #634. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv
Lane: openxfactory-1 (openXfactory-1)
Claim: #634 (comment)
Closes #634
The drift
scripts/validate-credential-contracts.pypinnedMAJOR_RELEASE = "contract-v3.0", the release every one of its eleven deprecation messages names as where the consumer-block warnings become refusals.contract-v3.0was cut on 2026-09-01 without any of the acts landing, followed by v3.1 (#616, defective) and v3.2 (#624), anddocs/contract-versioning-policy.md's own restatement rule moved the removal target tocontract-v4.0at that cut. The constant lagged behind the policy it is supposed to mirror.Reading taken
The message semantics are "refuses at the next MAJOR" —
MAJOR_RELEASEnames the release the deprecation window ends at, not the line currently shipping. The policy doc (§ Deprecations Currently In Force) confirms this is currentlycontract-v4.0for both entries this validator emits messages for: the consumer block's eight shape codes and theadd-requirement-ref-resolution-integritypair, which the policy states share one deprecation window. Both entries were independently restated fromcontract-v3.0tocontract-v4.0at the v3.0 cut, by the same rule: a spent target that arrives unexecuted is restated to exactly one major past the one that just cut.Fix
Rather than hand-move the string at each cut (or add a test that merely fails when it's stale),
MAJOR_RELEASEis now derived: readcontracts/manifest.yaml'scontract_bundle_version(currentlycontract-v3.4) and name one major past it —contract-v4.0today. Since the policy's own restatement rule has, every time so far, moved a spent target forward by exactly one major, this derivation tracks the governed value without a future cut needing to remember to move anything.Added
tests/credential_contracts/test_major_release_matches_policy.py, which reads the policy document's own text for both entries and asserts the derivedMAJOR_RELEASEstill names what they name — so a restatement that ever breaks the "next major" pattern (rather than merely advancing it) fails loudly here instead of drifting silently again.Before / after, run against a binding missing its
consumer:block:No change to what the validator refuses vs. warns — only the release name inside existing messages. No OpenSpec change: the validator's reported findings (codes, severities, and which shapes warn vs. refuse) are unchanged; only a message's embedded release name derives instead of being pinned.
Gates
pytest tests/ -q -k credential— 281 passed (submoduleopenXwalletinitialized first; an unrelated pre-existing failure intests/trust-anchor/from a missing submodule checkout disappears once initialized, confirmed present on unmodifiedorigin/maintoo).python3 scripts/validate-credential-contracts.py .(its own packaged self-test, run via any repo argument) —self-test: 8 positive + 19 negative + 13 warning example(s) confirmed, 11 deprecation code(s) probed.python3 scripts/doc-health.py --single-repo .— unchanged fromorigin/main(no docs touched).🤖 Generated with Claude Code
https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv