Skip to content

Receipts: public card, transaction lines, Rekor anchors and a receipt-first viewer - #2426

Merged
abrichr merged 11 commits into
mainfrom
feat/receipt-surfaces
Nov 22, 2026
Merged

abrichr merged 11 commits into
mainfrom
feat/receipt-surfaces

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

This PR closes the coordinator's pre-release gaps for receipts. It is stacked on #2410, which is stacked on #2394, so retarget it to main after those two merge.

Draft, not for merge. Nothing in it releases until #2394, #2410 and this PR are on main. The release order is privacy 1.1.4, Flow 3.4.0, types 0.25, Flow 3.5 with the pin raised to >=0.25, then launcher 1.25.

What it adds

  • Public card. Flow now writes receipt.card.json: the same signed envelope with only allow-listed values opened. It always opens the Flow version, and opens the program name only for the synthetic tutorial. It is never re-signed, and openadapt verify checks it.
  • Transaction checks as lines.
    • Each tx-receipt.cose and *.receipt.cbor in a run folder becomes one line of the run's receipt, with evidence: {kind, sha256}.
    • The line copies the receipt's own verdict: CONFIRMED and REFUTED map to themselves, and anything else is not_checked/uncertain.
    • The receipt file verifies on its own.
    • evidence is optional and left out when absent, so the existing vectors are byte-identical.
  • Rekor anchoring for receipts.
    • local-seal anchor RUN_DIR also anchors receipt.json and writes receipt.anchor.json. It reuses the Seal anchor's record path and logs the payload's SHA-256, so a later countersignature doesn't change what was logged.
    • openadapt verify adds "Logged publicly at ".
    • An anchor file that doesn't verify refuses the receipt.
  • Viewer checks receipt.json first.
    • The offline page embeds receipt.json and a role registry, and verifies the receipt in the browser. The receipt must name the exact report bytes.
    • The signer line comes from the receipt. The Raw tab says "Format: record/run/v1".
    • seal.json is used, labelled "older format", only when the run has no receipt.
    • The browser verifier (src/lib/receiptRecord.mjs) is openadapt-web's, extended to the full schema. It passes all shared vectors.
    • "Change the outcome in the receipt" now changes the signed payload.

Not in this PR

receipt publish still uploads the older public-seal/v1 card. It will upload receipt cards once cloud#532 accepts them, and that change will land together with Cloud's; coordination is in openadapt-internal#211.

Tests

  • Launcher suite: 2232 passed and 9 skipped locally.
  • Types: 822 passed. The Receipts: counterparty confirmations in record/run/v1 #2410 vectors, chains included, also pass.
  • Flow: the anchor, receipt, task and capability tests pass, 315 in total. test_write_receipt.py didn't run locally because cwt isn't installed here.
  • Viewer: vitest 54 passed, including every shared vector. The browser tests run in headless Chromium: 28 passed, including a receipt-first page, a tampered report, a tampered receipt and an unpinned key.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: cedd7a8

The signed receipt, public card and offline viewer need to agree on what the signer actually verified.

  1. Verify each write before counting it. evidence_lines decodes the COSE payload and promotes its verdict to a signed read-back claim. Decoding checks the container shape. The transaction and write verifiers separately check the issuer, signature and claims. The recursive scan also stops after 64 files, and the writer slices the combined list again before computing totals. Verify and associate each receipt with the run before promoting its verdict. Refuse a run receipt when all its write lines cannot fit. The producer in Sign settled Flow reports and verify their public callback records #2412 already refuses incomplete line coverage. Evidence extraction and tally
  2. Bind public disclosures to this run. On re-entry, the writer checks the report digest inside the existing envelope, then copies openings from the private sidecar without verifying the envelope or the sidecar’s payload digest and commitments. An unsigned run-summary marker controls whether the workflow name is disclosed. Verify the pinned signer, report and openings before writing a card. Require the tutorial provenance to match the signed report before disclosing the name. Sign settled Flow reports and verify their public callback records #2412 already validates the existing envelope and openings. Card recovery · Disclosure decision
  3. Keep the viewer verdict and display bound to one record. withRecord overwrites a failed required anchor or authorization check with success when the receipt signature and report digest pass. The Raw tab then labels the result record/run/v1 while reading its outcome, signer and signature from the legacy seal. The launcher also requires a legacy seal before reading a receipt, and the browser drops the supplied receipt anchor. Support a receipt-only run, preserve required evidence failures and derive the displayed signed fields from the verified receipt. Reserve legacy fallback for an absent receipt or a recognized older summary. Verdict · Raw fields · Viewer inputs
  4. Verify the signing key before public anchoring. anchor_receipt compares the local key ID with the envelope’s list of IDs, then calls the log submission path. Verify the DSSE signature over the exact payload with the selected key before submitting anything. Anchor precondition

Generality and evidence. The affected paths contain no app-specific engine behavior. These are shared signing, disclosure and verification defects across transaction and write receipts and across CLI and browser consumers. I reviewed the source and committed tests against stack base 15d87bde and compared #2412’s producer. I ran no new tests. The positive signed transaction fixture and existing browser cases leave mixed-validity inputs, over-limit evidence and receipt-only rendering unqualified. The author can cover these cases with local synthetic fixtures.

The protected check reports that this draft targets a non-main branch. Carry the upstream approval-history correction when updating the stack, then retarget after the prerequisite lands. Protected check · Upstream review

Evidence lines join the write lines before the line limit, so every one of
them decides the outcome; the pre-seal disclosure and the report-required
check keep the public-log anchor line. Viewer rebuilt from the merged source.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: 6c82b91

I checked the changes specific to #2426 against 4ab5ce04 and revisited the previous four findings. The pre-seal merge resolution is correct. A successful anchor check preserves the note identifying which report the receipt covers, and the CLI prints it. Verification path

  1. Write evidence. The merge now counts the returned evidence lines before applying the 256-line limit. However, evidence_lines first slices the discovered files to 64. A run with 65 receipts can still receive a verified outcome without the last receipt in either its tally or its overflow decision. The function still promotes a decoded payload verdict without verifying the evidence signature or association with the run. Account for every file and verify each promoted verdict. Receipt collection and grading
  2. Card disclosure. During recovery the writer still compares a digest from the existing envelope and feeds the private sidecar’s openings straight to the card builder. An unsigned summary marker still authorizes the workflow name. Verify the signer, report, sidecar binding and commitments before producing the card, and tie tutorial disclosure to this report’s provenance. Recovery · Disclosure
  3. Viewer. A valid receipt and matching report still overwrite a required authorization or anchor failure. The receipt anchor is omitted from browser inputs, the renderer still requires a legacy seal, and the Raw tab shows the legacy outcome and signature under the receipt format. The adapter also labels every external legacy-registry key as this computer’s key. Verify the required evidence and render the fields and signer role supported by the selected receipt. Verdict · Raw tab · Registry and page inputs
  4. Public anchoring. The anchoring helper is unchanged from the previous review. It finds the selected signer’s key ID in the envelope, hashes the payload and proceeds to log submission. Verify the DSSE signature over that payload with the selected key before calling the submitter. Submission precondition

These findings concern shared receipt behavior across two evidence formats and the CLI and browser readers. This was a source and test review. I ran no new tests and submitted nothing to a public log. The current fixtures leave the 65-receipt boundary, mismatched recovery sidecars and mixed-validity viewer inputs unqualified.

…viewer and anchoring

Instance fixes, named by class until the shared fail-open harness lands:
- truncation: every evidence receipt in the run counts; no cut at 64.
- unverified evidence: a tx or write receipt's verdict is promoted only
  when its signature verifies (the run's tx workdir key, this computer's
  key); a receipt is anchored only after its DSSE signature verifies.
- unverified reuse: an existing receipt is kept only if it verifies with
  its sidecar; a card opens only committed values; the tutorial name opens
  only when the signed report carries the tutorial approval source.
- dropped requirement: the viewer never lets a receipt override a failed
  required authorization or anchor, or stand in for one.
- trust label: a supplied older Seal registry never vouches for a receipt
  as this computer's; a receipt with no role registry fails closed.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

How each item in Codex's review at 6c82b917 was handled. New head: bec707159ab4540eba0f044bf0249796a6dd44b4.

# Item Status
1 evidence_lines cut at 64 files; verdicts promoted without verifying Fixed. Every evidence file counts, so the caller's 256-line rule decides overflow. A tx receipt's verdict is promoted only when verify_tx_receipt passes with the signing key of its own tx workdir inside this run. A write receipt's verdict is promoted only when write_receipt.verify passes against this computer's key. Anything else is not_checked. Test: test_an_evidence_receipt_that_does_not_verify_is_not_promoted.
2 Recovery feeds unverified openings to the card; an unsigned marker opens the name Fixed. An existing receipt is kept only if verify_receipt passes with its sidecar (signer, binding, commitments); otherwise existing_unverified. A card opens only values that match the receipt's commitments. The program name opens only when the summary says tutorial and the signed report carries governed_approval_source: openadapt-flow-tutorial. Tests: test_rewriting_an_existing_receipt_verifies_it_first, test_an_unsigned_tutorial_marker_never_opens_the_program_name.
3 Viewer: a receipt overrides a required failure; legacy keys labelled this computer Fail-open parts fixed. A failed required authorization or anchor stays failed, and a receipt can't stand in for one (sealOk from checkReceipt). A supplied older Seal registry no longer becomes a this_computer registry (receipt_registry(..., own=False) is None), and a receipt with no role registry fails as unknown signer. Tests: test_a_supplied_older_registry_never_vouches_for_a_receipt, updated receipt-first tests. Display-only parts (browser anchor, receipt-only render, Raw tab) are filed in #2479.
4 Anchoring submits before verifying the signature Fixed. anchor_receipt verifies the signer's DSSE signature over the payload before anything is sent. Test: test_a_receipt_with_a_bad_signature_is_never_sent_to_the_log.

Tests: test_receipt_verify.py 43, test_seal_view.py 30, test_seal_anchor.py 49, vitest 54, all passed; mypy clean on the touched modules.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: bec7071

I checked the single commit since the previous review. It removes the 64-file cut, verifies evidence signatures, preserves required authorization and anchor failures, and stops assigning a local signer role to supplied legacy keys. Item 4 is fixed: the public-log submitter is reached only after the selected key verifies the receipt’s DSSE signature over its payload.

Three correctness gaps remain in the scoped changes.

  1. Item 1, evidence attribution. The write-receipt path uses only the authenticated verdict. It never compares the signed write identity with the current run. Thus another write signed by the same machine can count toward this run’s confirmed tally. The transaction path additionally reads the file twice: the first snapshot supplies the line digest and the verifier reopens the path for the verdict. Match the subject to retained run evidence and take the digest and verdict from the same verified bytes. An unmatched receipt should remain not_checked. Evidence selection · Signed write identity
  2. Item 2, disclosure permission. Recovery now checks the envelope and supplied openings, and the card checks the revealed value’s commitment. The tutorial decision still rereads report.json after the writer has matched or signed an earlier snapshot. If the file changes between those reads, a different report can authorize disclosure of the first report’s committed program name. Use the parsed report whose exact bytes matched the envelope’s report digest to decide which fields to open. Initial snapshot · Disclosure decision
  3. Item 3, malformed-receipt fallback. The launcher discards any present receipt that lacks a literal "payloadType" marker. An unrecognized or truncated receipt can therefore skip receipt verification and receive the older seal’s successful verdict. Limit fallback to an absent file or a parsed, recognized legacy summary. A present, unreadable or unrecognized receipt should fail. Launcher · Browser dispatch

This review used immutable source and the committed assertions. I ran no new tests. The new tests cover a copied transaction with no local key, a mismatched opening and an invalid anchor signature. The same-key cross-run case and the two snapshot changes above remain uncovered. The display work remains in #2479.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: e457571

The three findings at bec70715 remain open. I compared the PR against its base before and after this merge. Its patch ID is identical. The only change in the receipt writer is an inherited type annotation, and the viewer files are byte-identical to the reviewed head.

The owner still needs to bind write evidence and its digest to the current run and verified bytes, use the bound report snapshot to authorize card disclosures, and refuse a present, unrecognized receipt before falling back to a legacy seal. The earlier public-anchor signature fix is intact. This was a merge-delta review. I ran no tests.

Base automatically changed from feat/receipt-counterparty-line to main November 21, 2026 23:10
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: e457571

Gemini run on e457571 (gemini-3.1-pro-preview via the API). It reviewed the PR's diff against its base, with the earlier findings and the filed follow-ups given as context. It was asked to report only fail-open items, since this PR is past its two-round cap. Posted as Gemini returned it. Gemini returned only its verdict line, with no findings.

@abrichr
abrichr marked this pull request as ready for review November 22, 2026 00:39
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: e457571

Ports this branch's receipt surfaces onto main's settled-run writer
(#2412): verified evidence-receipt lines join the write lines under the
limit, the public card is written (and rewritten on verified reuse), the
public-log anchor line is checked in verify_run_receipt, and the Flow
version is committed by default again. Anchor test fixtures gain ordered
results.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 85e7bff

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 85e7bff

Gemini run on 85e7bff (gemini-3.1-pro-preview via the API). It reviewed the PR's diff against its base, with the earlier findings and the filed follow-ups given as context. It was asked to report only fail-open items, since this PR is past its two-round cap. Posted as Gemini returned it. This is a delta after the main merge, which ported this PR onto the settled-run writer. Gemini returned only its verdict line.

…writer

The seal-view CI job runs against the released openadapt-flow, which has no
openadapt_flow.receipt_record yet; the receipt-first tests now skip there,
as tests/test_receipt_verify.py does.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 725e036

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 725e036

Gemini run on 725e036 (gemini-3.1-pro-preview via the API). It reviewed the PR's diff against its base, with the earlier findings and the filed follow-ups given as context. It was asked to report only fail-open items, since this PR is past its two-round cap. Posted as Gemini returned it. This is a delta review since 85e7bff: a merge of main, which left this PR's receipt, viewer and seal-view source files unchanged, plus one test-only commit.

The provided delta introduces a single line to tests/test_seal_view.py: pytest.importorskip("openadapt_flow.receipt_record").

This change is safe and does not introduce a fail-open vulnerability in the shipped code for the following reasons:

  1. Test-Only Scope: The modification is strictly confined to the test suite (tests/test_seal_view.py) and specifically within a test helper function (_with_receipt). It does not alter the runtime execution, access control, or verification logic of the actual application.
  2. Appropriate CI Environment Handling: The seal-view CI job runs against an older, released version of openadapt-flow that does not yet contain the receipt_record module. Without this skip, the test suite crashes with an ImportError.
  3. No Hidden Verification Paths: Skipping the test when the module is absent does not bypass a valid security check in production. If the released code lacks the receipt_record module, it cannot execute receipt verification anyway. When the test suite runs against a newer version of the package where the module does exist, importorskip will silently succeed, and the receipt verification tests will execute as intended.

The merge delta simply brings in upstream changes and does not interact maliciously with this test fix.

@abrichr
abrichr merged commit 4228302 into main Nov 22, 2026
56 of 58 checks passed
@abrichr
abrichr deleted the feat/receipt-surfaces branch November 22, 2026 05:35
abrichr added a commit that referenced this pull request Nov 22, 2026
Main now carries #2426's receipt surfaces; the handoff confirmation lines
and the guarded awaiting-counterparty receipt attach after build_statement
with evidence lines, the card is written, then the handoff sidecar is
recorded. Viewer rebuilt.
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.

1 participant