Skip to content

fix(resolver): keep the fields a schema opens - #653

Open
LKSNDRTMLKV wants to merge 1 commit into
mainfrom
fix/375-resolver-envelope-openings
Open

LKSNDRTMLKV wants to merge 1 commit into
mainfrom
fix/375-resolver-envelope-openings

Conversation

@LKSNDRTMLKV

Copy link
Copy Markdown
Member

Closes #375.

The decision, and what it turned up

The founder decided #375 as option 2: keep the resolver's hand-rolled filter as a deliberate second opinion, document that in the code, and treat the parity test as the contract. The issue rested that choice on "nothing is broken today". Checking that claim against the code before documenting it found it false.

  • The openings. Battery schemas 2.7.0, 2.8.0, 2.9.0 and 2.10.0 (the current one) open batchId and serialNumber to the public through x-public-envelope-fields. No other schema in core's catalog opens anything.
  • The vault. redact_passport composes its policy with ProductGroupAccessPolicy::for_passport, which applies those openings. So the public view the vault signs carries both fields.
  • The resolver. apply_access_tier_filter filtered the envelope with passport_default(), which opens nothing, so at Public it dropped both fields. The handler then re-attached publicJwsSignature. A battery passport at schema 2.7.0 or later was therefore served from /dpp/{dppId} (JSON) with a body its own proof does not cover.
  • Why the parity test missed it. It ran at one fixture pinned at 2.6.0, the last version before the openings.

Documenting a filter that breaks its contract as harmless would have been a false comment. So this PR makes the filter honour the contract, and only then documents it.

What changes

  • envelope_policy. The envelope pass takes its policy from the composition the vault uses, for_passport, keyed by the passport's own productGroup and schemaVersion.

    • The product group is read through core's ProductGroup and its key through catalog_key, so no mapping and no opening is restated.
    • An unreadable or unknown product group, or a schema version core does not carry, falls back to passport_default(). That fails closed, as before.
  • The filter still does not call redact_passport. It stays an independent pass over the payload the vault signed. A second opinion that called the same function would check nothing.

  • The doc comment on apply_access_tier_filter records the decision. It says the filter is:

    • a deliberate second opinion;
    • built on the same policy composition as the vault;
    • never to remove a field from a signed view.

    It names the parity test as the contract, which a change must keep rather than update.

  • The envelope's view changes only by the two openings. for_passport differs from passport_default() only in what the envelope scope does not consult, apart from public_envelope_fields. The productGroupData pass, the unknown-group backstop and the legacy pass-through are unchanged.

Tests (crates/dpp-resolver/src/handlers/resolve_json.rs)

  • this_filter_removes_nothing_from_a_view_the_vault_already_signed, the contract. It now runs at every battery schema version core embeds, read from VersionedSchemaRegistry, with batchId and serialNumber populated. It first asserts that the list reaches 2.6.0 and the catalog's current version. A schema that adds an opening is covered the day core ships it.
  • a_battery_passport_at_the_current_schema_is_served_with_batch_id_and_serial_number reads the catalog's current version.
  • an_envelope_with_a_schema_version_core_does_not_carry_fails_closed and an_envelope_with_a_product_group_core_does_not_know_fails_closed.
  • The two existing tests stay: unknown_product_group_tag_fails_closed_at_public_tier and untagged_legacy_product_group_data_passes_through.

Corrections to the issue's table

  • Proof fields. The resolver does strip them. Core's filter_by_audience removes PASSPORT_PROOF_FIELDS at the envelope root, and the handler re-attaches publicJwsSignature afterwards.
  • personalData. It is class Individual, so the resolver's envelope pass removes it at Public, and the signed Public view never carries it either. At tiers above Public, the resolver would treat statements differently from redact_passport. That is unreachable, because parse_access_tier always answers Public.

Checked

  • The gate: just check green on this branch: 1932 tests passed, 3 skipped, audit included.
  • dpp-resolver: 176 tests passed. Clippy with the full feature set is clean.
  • Bite tests:
    • passport_default() put back for the envelope pass. The contract fails at "battery schema 2.7.0", the first version with the opening. The current-schema test fails too, with the served batchId None where the signed view has "BATCH-42".
    • An envelope field the Public view keeps, dropped. The contract fails at the first version in its loop.

@LKSNDRTMLKV LKSNDRTMLKV added this to the v0.17.0 milestone Nov 19, 2026
@LKSNDRTMLKV LKSNDRTMLKV added type/defect Something published or encoded here is wrong or unbackable now urgency/backlog Owed, unscheduled surface/rules Moves a threshold or cross-field rule epic/public-surfaces What a reader sees: resolver, public reads, data carriers, public page labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

epic/public-surfaces What a reader sees: resolver, public reads, data carriers, public page surface/rules Moves a threshold or cross-field rule type/defect Something published or encoded here is wrong or unbackable now urgency/backlog Owed, unscheduled

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The resolver still hand-rolls the redaction #195 removed from the vault

1 participant