Skip to content

Compare a composed tier-2 issuance against the certificate it composes with - #996

Merged
brettheap merged 3 commits into
mainfrom
fix/582-issuance-evidence-certificate-check
Sep 12, 2026
Merged

brettheap merged 3 commits into
mainfrom
fix/582-issuance-evidence-certificate-check

Conversation

@brettheap

@brettheap brettheap commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-2 (openXfactory-2)

What. check_issuance() compares the composed tier-2 issuance against the
certificate it composes with, in both directions, at the point where the
binding's two references have resolved.

Why. The binding's certificate_ref and issuance_evidence_ref were each
checked for presence in their OWN pool, independently, and nothing compared the
issuance-evidence record's own certificate_ref with the binding's. A binding
naming certificate C and issuance evidence E, where E.certificate_ref is
some other certificate C', composed and verified: three records, all present,
all schema-valid, all resolvable, and the issuance act that is supposed to
evidence C's issuance evidencing something else. check_signatures() resolves
the certificate separately, from the signature side, and never closed the gap
either. The ratified add-chain-attestation scenario is explicit that the
evidence "records the controller's issuance act and references that
certificate
".

How. Two comparisons, guarded on both references having resolved so a
missing part is still reported as the missing part it is, and reported under the
EXISTING closed code forged_attestation_identity — no new code, the closed
enumeration stays closed and its packaged probe stays honest:

  • issuance_evidence.certificate_ref vs signed_binding.certificate_ref;
  • certificate_record.issuance_evidence.evidence_ref vs
    signed_binding.issuance_evidence_ref, only where the certificate records
    present: true and carries a string reference, because an honestly-absent
    evidence record is add-trust-anchor's own state and is not restated here.

The design note posted on the issue before any code states the same shape.

How verified. Both comparisons are pinned per compared field in
tests/signed_execution_chain/test_chain_reader.py by mutating the packaged
corpus in memory — the reader's own stated policy for this shape, since the
disagreement lives inside signed_binding, whose signature this reader verifies
and whose fixture key's private half is not in this repository. The matching case
is the packaged tranche-two corpus itself: all ten binding/certificate/evidence
triples agree in both directions and stay green. Reader self-test: 113 packaged
records valid across 2 corpora, 108 negatives still invalid for their intended
reason, 95/95 closed refusal codes red-proven.

Out of scope, deliberately: the bindings_by_id / inceptions last-write-wins
sibling hazard the issue raises. It is a refusal over the family's OWN
identifiers, needs its own code-or-reuse decision and its own probe, and folding
it in here would make this fix unreviewable as what it is.

refs #582

🤖 Generated with Claude Code

Summary by Sourcery

Ensure composed tier-2 issuances consistently bind certificates and issuance evidence in both directions.

Bug Fixes:

  • Validate that issuance evidence references the same certificate named by the signed binding.
  • Validate the reverse relationship between a certificate's recorded issuance evidence and the binding's issuance evidence reference.

Enhancements:

  • Preserve missing-part and honestly absent-evidence handling while reporting mismatched composition under the existing forged_attestation_identity refusal code.

Tests:

  • Add coverage for matching compositions, both mismatch directions, honest absence of issuance evidence, and unresolved references using the tranche-two corpus.

…s with

The binding's two references were checked for presence in their own pools,
independently, so a binding naming certificate C and issuance evidence E
composed and verified where E recorded the issuance of some other certificate
C'. Both directions of the binding are now compared, where both references
resolved, under the existing forged_attestation_identity code.

refs #582

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 12, 2026 02:18
@sourcery-ai

sourcery-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR closes a cross-reference integrity gap in tier-2 issuance composition by validating the certificate and issuance evidence references in both directions once their records resolve, reusing the existing forged_attestation_identity refusal code and adding targeted reader tests without changing missing-part handling or the out-of-scope identifier-collision behavior.

Sequence diagram for bidirectional tier-2 issuance reference validation

sequenceDiagram
    participant Reader
    participant View
    participant Binding
    participant Certificate
    participant Evidence
    participant Refusal

    Reader->>Binding: get(certificate_ref)
    Reader->>Binding: get(issuance_evidence_ref)
    Reader->>View: certificates.get(certificate_ref)
    Reader->>View: issuances.get(issuance_evidence_ref)
    alt both references resolve
        Reader->>Evidence: get(certificate_ref)
        alt evidence certificate_ref != binding certificate_ref
            Reader->>Refusal: error(forged_attestation_identity)
        end
        Reader->>Certificate: get(issuance_evidence)
        alt present is true and evidence_ref is a string
            alt certificate evidence_ref != binding issuance_evidence_ref
                Reader->>Refusal: error(forged_attestation_identity)
            end
        end
    else a referenced record is missing
        Reader->>Refusal: preserve missing-part refusal
    end
Loading

File-Level Changes

Change Details Files
Enforce cross-record consistency for composed tier-2 issuance references.
  • Compare the issuance evidence's certificate reference with the binding's certificate reference after both records resolve.
  • Compare the certificate's recorded evidence reference with the binding's evidence reference when the certificate explicitly records present evidence.
  • Report either mismatch using the existing forged_attestation_identity refusal code while preserving missing-record errors.
scripts/signed_execution_chain/attestation.py
Add focused regression coverage for both mismatch directions and preserve corpus validation guarantees.
  • Mutate the packaged corpus in memory to pin each comparison and verify the matching corpus remains valid.
  • Confirm existing negative cases and the closed refusal-code probes remain unchanged.
tests/signed_execution_chain/test_chain_reader.py

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

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.

🟡 Changes recommended

Add independent mutation tests covering both new mismatch checks.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds bidirectional consistency checks for tier-2 issuance composition.

Changes:

  • Validates certificate and issuance-evidence references agree.
  • Reuses forged_attestation_identity for mismatches.
File summaries
File Description
scripts/signed_execution_chain/attestation.py Adds guarded bidirectional reference validation.
Review details

Suppressed comments (2)

scripts/signed_execution_chain/attestation.py:551

  • These two new consistency predicates are not exercised by the current reader tests: the positive corpus only contains matching references, and the existing forged_attestation_identity negative covers a missing evidence record rather than either mismatch. A mutation test should independently change issuance_evidence.certificate_ref and certificate.issuance_evidence.evidence_ref while keeping all records present, otherwise either comparison could regress to a no-op while the closed-code probe still passes.
            if certificate is not None and evidence is not None:
                evidenced = evidence.get("certificate_ref")
                if evidenced != cert_ref:

scripts/signed_execution_chain/attestation.py:568

  • The reverse comparison is likewise untested: there is no reader test that mutates a certificate's issuance_evidence.evidence_ref while keeping the binding's evidence record resolvable. Add that second in-memory mutation and assert the existing refusal code, otherwise this independently introduced direction can regress unnoticed.
                if (isinstance(back, dict) and back.get("present") is True
                        and isinstance(carried, str) and carried != evidence_ref):
  • Files reviewed: 1/1 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.

…sing part missing

Five pins over the tranche-two corpus mutated in memory: the packaged
composition agrees in both directions and stays green, each compared field
refuses a mismatch under forged_attestation_identity, an honestly-absent
evidence record is not read as a disagreement, and an unresolvable reference is
still reported as one of the three records missing.

refs #582

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 12, 2026 02:26

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

Update the affected test to exercise the owning validator or accurately scope its assertion and documentation.

Review details

Suppressed comments (1)

tests/signed_execution_chain/test_chain_reader.py:1158

  • This docstring claims the mutated binding is still refused, but _validate() only runs the signed-execution-chain reader: its check_shapes() schema-validates the consumed certificate and check_issuance() has no present: false refusal. The test only asserts that the new disagreement message is absent, so it does not prove the stated refusal and can pass with zero errors. Either exercise the owning trust-anchor validator or scope the docstring to the behavior this test actually checks.
    The binding is still refused — by the rules that own the absence — but never
    as two records naming each other differently."""
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…it does

The docstring claimed the binding "is still refused" while the test runs this
reader alone, which has no refusal for an honestly absent issuance-evidence
record: the mutated corpus validates with zero errors, so the sentence named a
refusal the assertion never reached. The claim is scoped to what this test runs
and the refusal is attributed to the validator that owns it,
scripts/validate-trust-anchor.py under issuance-evidence-absent-trusted,
red-proven by the packaged negative
unexplained-certificate-recorded-as-trusted.yaml over the same shape. The
silence the guard exists for is now asserted rather than described: no
disagreement line, and no error from this reader at all.

refs #582

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 12, 2026 02:58

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 requested consistency checks and focused tests are complete with no unresolved blocking issues.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

Copy link
Copy Markdown

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

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 2 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit ff10b4f into main Sep 12, 2026
13 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-2 (openXfactory-2)
LANDED — lane openxfactory-2 (openXfactory-2), 2026-09-12T14:57:48Z, PR #996 → ff10b4f (no Rule 6 window)
Brett Heap ${WORD_WHEN:-2026-09-11, in session, multi-choice SELECTION}, verbatim: "Land all when green and thread-free, in order". --squash --admin at head c3419ae (code-owner review cannot clear on a self-authored PR; admin merge on his word, B2 pattern).

brettheap added a commit that referenced this pull request Sep 12, 2026
origin/main moved five commits ahead of this branch's fork point,
three of which touch files this PR also declares edits on:

- #995 (9e43f3d, ASK-7 window): four declared lines on the cli.py and
  serve.py rows of docs/opendox-carve-manifest.yaml, plus the four
  scripts/tests files that quote the running "862" declared-line total
  (carve_lines.py, validate-carve-manifest.py, verify-carve-arrival.py,
  tests/carve_manifest/test_carve_manifest.py).
- #984 (a1ef886): carve tooling/admissions hardening unrelated to the
  five rows this PR touches.
- #997, #996, #999: no overlap with this PR's files.

Conflict resolution, keeping both sides:

- docs/opendox-carve-manifest.yaml: the header comment block now
  carries the ASK-7 window's paragraph (landed first, 2026-09-11) ahead
  of the § 3.4 SLICE-S3 paragraph (2026-09-12), in landing order. The
  S3 paragraph's own arithmetic is untouched (it was already stated as
  a DELTA — "+40 over two rows" — precisely so a later-landing sibling
  act would not need to rewrite it); only its framing of the ASK-7
  window changed from "is in flight" to "already moved the running
  total to 866", since this merge is the event that makes ASK-7's
  landing a fact rather than a future one. The four ASK-7 row edits
  (cli.py:834, serve.py:155/725/1338) and the two S3 row edits
  (app.js's 37 lines, test_bullseye_widget.py's 3 lines) are all kept.
- scripts/carve_lines.py, scripts/validate-carve-manifest.py,
  scripts/verify-carve-arrival.py: each had a single docstring line
  citing the running declared-line total — "866" from main (ASK-7),
  "902" from this branch (which assumed the pre-ASK-7 base of 862).
  Corrected to 906 in all three: 866 (post-ASK-7) + 40 (this act's
  own delta) = 906, matching the pinned test assertion.
- tests/carve_manifest/test_carve_manifest.py: merged both narrative
  additions to test_the_real_manifest_carries_the_ruled_q_l7_amendment
  in landing order (ASK-7 then S3), corrected the final aggregate
  assertion from this branch's stale (902, 151) to (906, 151), kept
  main's per-row pinned ASK-7 checks (cli_row/serve_row) verbatim, and
  fixed their comment's citation of the aggregate from (866, 150) to
  (906, 151) to match the corrected assert two lines above. Also fixed
  a second, non-conflicting docstring in
  test_the_line_count_is_exactly_the_expression_the_validator_carried
  that still read "902".

A pre-existing defect, unrelated to the conflict, found while
resolving: the test_bullseye_widget.py row's two edits (already on
this branch's HEAD before any merge, commit 6843a25) had a blank line
splicing them apart, which left the `adapter calls` edit's `note:` key
duplicated with the `path constants` edit's original note — YAML
silently keeps the last of a duplicate key, so the S3 note was
silently discarded and the wrong note landed on the wrong edit.
Confirmed with a duplicate-key-aware loader before and after. Fixed by
restoring each edit's own note; a full-document duplicate-key scan
afterward finds none remaining anywhere in the manifest.

Verified after resolution:
- python3 scripts/validate-carve-manifest.py: OK, 456 rows, 168
  moved_verbatim / 150 moved_with_declared_edit / 138 not_moved.
- python3 scripts/verify-carve-arrival.py --destination opendox_code
  --phase B against openDox-code PR #14's head (09b42f5b): DECLARED
  src/opendox/web/app.js, DECLARED tests/test_bullseye_widget.py, 0
  refusals (three newly-created files admitted ad hoc for this local
  check only: src/opendox/view_extension.py,
  src/opendox/web/views/view_extension.js, tests/test_view_registry.py
  — the governed admissions-file entries for those belong to the
  pin-bump PR that follows #14's own landing, not this row-annotation
  PR). The one "unapplied" declared-edit row the summary counts is
  scripts/ideation_dashboard/doxbench_scope_types.py, an unrelated
  pre-existing row (successor #838, open at the carve) — not S3.
- pytest tests/carve_arrival tests/carve_manifest tests/carve_conformance -q:
  269 passed (121 + 110 + 38).

Lane: openxfactory-4-opendox-extraction
Refs #656

Co-Authored-By: Claude Sonnet 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

Development

Successfully merging this pull request may close these issues.

2 participants