Skip to content

Derive MAJOR_RELEASE from the manifest instead of pinning it - #679

Merged
brettheap merged 2 commits into
mainfrom
fix/credential-validator-major-release
Sep 5, 2026
Merged

brettheap merged 2 commits into
mainfrom
fix/credential-validator-major-release

Conversation

@brettheap

@brettheap brettheap commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-1 (openXfactory-1)
Claim: #634 (comment)

Closes #634

The drift

scripts/validate-credential-contracts.py pinned MAJOR_RELEASE = "contract-v3.0", the release every one of its eleven deprecation messages names as where the consumer-block warnings become refusals. contract-v3.0 was cut on 2026-09-01 without any of the acts landing, followed by v3.1 (#616, defective) and v3.2 (#624), and docs/contract-versioning-policy.md's own restatement rule moved the removal target to contract-v4.0 at 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_RELEASE names the release the deprecation window ends at, not the line currently shipping. The policy doc (§ Deprecations Currently In Force) confirms this is currently contract-v4.0 for both entries this validator emits messages for: the consumer block's eight shape codes and the add-requirement-ref-resolution-integrity pair, which the policy states share one deprecation window. Both entries were independently restated from contract-v3.0 to contract-v4.0 at 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_RELEASE is now derived: read contracts/manifest.yaml's contract_bundle_version (currently contract-v3.4) and name one major past it — contract-v4.0 today. 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 derived MAJOR_RELEASE still 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:

ERROR at contract-v3.0   ->   ERROR at contract-v4.0

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 (submodule openXwallet initialized first; an unrelated pre-existing failure in tests/trust-anchor/ from a missing submodule checkout disappears once initialized, confirmed present on unmodified origin/main too).
  • 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 from origin/main (no docs touched).

🤖 Generated with Claude Code

https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv

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
Copilot AI lite review requested due to automatic review settings September 5, 2026 14:06

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

@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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_RELEASE from contracts/manifest.yaml: contract_bundle_version by 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.

Comment on lines +144 to +156
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 AI review requested due to automatic review settings September 5, 2026 14:13
@brettheap

Copy link
Copy Markdown
Contributor Author

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@brettheap

Copy link
Copy Markdown
Contributor Author

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 a2459bad: all nine checks SUCCESS incl. release-tag-gate (short-circuit, no release surface touched) and lane-line. Codex absent (usage limit) — absence, not clearance; Copilot findings dispositioned on the PR. Self-authored PR → admin merge (standing pattern B2).

🤖 Generated with Claude Code

https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv

@brettheap
brettheap merged commit 1be0cc2 into main Sep 5, 2026
10 checks passed
brettheap added a commit that referenced this pull request Sep 5, 2026
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
@brettheap

Copy link
Copy Markdown
Contributor Author

Copilot's second-round findings, disposition in f9a854d:

  • manifest-not-a-mapping guard in _major_release() — taken.
  • _resolution_integrity_target()'s unbounded end-of-document search, and the same class of risk in _consumer_block_target() — taken (both now bounded/uniqueness-checked).
  • spec_from_file_location()'s loader may be None — declined: identical unmodified pattern already used by test_consumer_block_phasing.py and test_requirement_ref_resolution.py; fixing it only here would diverge from the established convention for this test-only import helper.

brettheap added a commit that referenced this pull request Sep 5, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants