Skip to content

fix: generate capability declaration schemas - #67

Merged
carolinerg1 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/project-credential-identity-defs
Sep 4, 2026
Merged

fix: generate capability declaration schemas#67
carolinerg1 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/project-credential-identity-defs

Conversation

@vishkaty

@vishkaty vishkaty commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Re-derived 2026-09-02 against current main 688b627 (v0.5.1) and reduced to one
change. Head f0cafb3.

This PR originally carried two fixes. #61 superseded the first: generate_models.sh
now globs schemas/common/types/*.json at lines 191 to 193, so the four payment
credential subtype files generate without this PR. Thank you to @segiodongo, and
a glob rather than a list of names means later common/types files are covered
too. That half is withdrawn.

What remains is capability declaration schemas.

Observed

A capability may redeclare the platform_schema, business_schema and
response_schema roles that capability.json defines, under a $defs key equal to
its own reverse domain name. No path in generate_models.sh reaches those
declarations.

Handing the file to quicktype whole does not help. These files are bare $defs
containers with no root type, no properties and no root $ref, so quicktype
generates only what the root references, drops the rest, and exits 0. The
omission is silent.

Measured on 688b627, four files declare this way and none of their declarations
were generated:

  • common/identity_linking.json, passed only as $defs/provider and
    $defs/scope_policy at generate_models.sh:149 to 151. Those two do generate.
    The platform_schema and business_schema in the same file generate nothing.
  • shopping/permalink.json, passed whole at generate_models.sh:129 to 131.
    Permalink appears 0 times in src/spec_generated.ts.
  • shopping/fulfillment.json, never passed itself. Only its projected create,
    update and response variants are, as $defs/checkout attachments.
  • common/payment_split_payments.json, passed only as $defs/instrument_group,
    $defs/payment_instrument and $defs/checkout. Its config content does reach the
    output separately through common/types/business_split_payments_config.json, so
    the effect there is smaller than for the other three.

Expected

The declarations generate the way other capability shapes do.

The change

Discovery is keyed on the shape, never on file names, so a capability added to
the spec later is picked up with no edit to this repo.

The declarations are generated in their own isolated quicktype invocation and
merged. That matters: quicktype assigns names globally across one invocation, so
adding sources to the shared invocation re-picks disambiguating names for
unrelated existing types. An earlier attempt did exactly that and renamed
DescriptionClassSchema and MultiDestinationSchema, which is a breaking change to
the public API. Isolation removes that possibility by construction rather than by
inspection.

quicktype structurally unifies declarations that differ only in annotations and
keeps one title name, so identity_linking and permalink platform declarations
collapse to one type. A completeness gate re-derives the declaration set from the
schema tree independently of discovery, aliases any unified away name to its
surviving structural sibling, and fails the build if a declaration produced
nothing. The gate runs unconditionally: guarding it on whether discovery found
anything would make it blind to discovery finding nothing, which is the precise
failure quicktype exit 0 produces.

Verification

Re-measured 2026-09-02 on f0cafb3, based on main 688b627:

  • src/spec_generated.ts +218 and -0. The change is additive only: no existing
    line is changed, moved or removed, and 307 exports become 318. Three of the
    four inserted hunks land mid file because the normalizer places aliases next to
    their targets, so this is additive rather than strictly appended.
  • npm test 141 passing, 0 failing.
  • tsc --noEmit clean. pre-commit run --all-files, every hook passing.
  • Regeneration deterministic: two consecutive runs byte identical at 117990
    bytes, and byte identical to the committed file, so the drift job stays green.
  • Kill test: neutralising discovery makes the build exit 1 and name all eight
    missed declarations, rather than exiting 0 as it does today.

One rough edge, stated rather than hidden: when the gate fails, src/spec_generated.ts
has already been written by the normalize step, so a failed run leaves that file
modified. Regeneration restores it byte identically.

Thank you to @ptiper for flagging the capability $defs gaps in the #61 review and
asking for tracking issues so the remainder could land right after 0.5.0.

Fixes #66

@google-cla

google-cla Bot commented Aug 31, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@vishkaty
vishkaty force-pushed the fix/project-credential-identity-defs branch from 04b5797 to eaf3eae Compare August 31, 2026 17:17
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Aug 31, 2026
@vishkaty
vishkaty force-pushed the fix/project-credential-identity-defs branch from eaf3eae to 49c81ca Compare September 1, 2026 14:09
@carolinerg1 carolinerg1 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Sep 1, 2026
A capability may redeclare the platform_schema, business_schema and
response_schema roles that capability.json defines, under a $defs key equal to
its own reverse domain name. Nothing in the --src list reaches those
declarations, and handing the file to quicktype whole generates nothing for
them either: these files are bare $defs containers with no root type,
properties or $ref, so quicktype generates only what the root references,
drops the rest, and exits 0. The omission is silent.

Four files declare this way at 2026-08-25: common/identity_linking.json,
shopping/fulfillment.json, shopping/permalink.json and
common/payment_split_payments.json. None of their declarations were generated.

Discovery is keyed on the shape, never on file names, so a capability added
later is picked up with no edit here. The declarations are generated in their
own isolated quicktype invocation and merged, which leaves the main
invocation's inputs untouched so existing export names cannot move. The
generated change is additive only: no existing line is changed, moved or
removed.

quicktype structurally unifies declarations that differ only in annotations,
keeping one title's name. A completeness gate re-derives the declaration set
from the schema tree independently of discovery, aliases any unified away name
to its surviving structural sibling, and fails the build if a declaration
produced nothing.
@vishkaty
vishkaty force-pushed the fix/project-credential-identity-defs branch from 49c81ca to f0cafb3 Compare September 3, 2026 00:44
@vishkaty vishkaty changed the title fix: project credential subtypes and declaration capabilities generically fix: generate capability declaration schemas Sep 3, 2026
@carolinerg1
carolinerg1 merged commit 1dd6de1 into Universal-Commerce-Protocol:main Sep 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

identity_linking, permalink, and fulfillment declaration schemas generate no models

4 participants