Skip to main content

Module coverage

Module coverage 

Source
Expand description

The schema-coverage gate.

§What this gate is for

crate::core::coverage catches an operation the contract grew and the client never exposed. This one catches the quieter half of the same failure: an operation whose shape grew — a field added to SessionItem, a schema added beside it — while the models kept decoding happily, dropping the new data on the floor. Nothing fails at runtime when that happens. The response still parses; the field is simply never seen again.

So the models are held to the vendored document mechanically:

  1. Every schema is accounted for. Modelled, or allow-listed with the reason it is not — the same partition, and the same failure, as the operation gate.
  2. Every property survives a round trip. A document synthesised from the schema is decoded into the model and re-serialised; anything the model does not carry comes back missing, and is reported by path.
  3. The decoding rules hold. A schema’s optional properties really are optional (the whole document decodes from {}), a required one really is required, and a composite property really does tolerate null — see super for why each of those matters.

The synthesised document is the trick that makes this work without a hand-written description of each model. A hand-written one would be a second copy of the contract, kept by hand, which is the thing being prevented. Serde is the description: what the model can carry is exactly what survives decoding and re-encoding.

§Why the tables live here and not with the consumer

Deliberately the opposite of crate::core::coverage, and for the same reason. Coverage of operations is a statement about one client’s surface, so sharing the tables would make the gate report on a union and protect nobody. Coverage of schemas is a statement about these models, which ship in this crate — so the tables ship with them, and a consumer gets the gate by depending on the crate rather than by maintaining a copy of it.

Structs§

ClaimedEnum
One Rust enum’s claim on a contract-declared value set.
Entry
One modelled schema, and the checks its model can be put through.
SchemaReport
What a coverage run found wrong.

Constants§

UNMODELLED
Schemas this crate deliberately does not model, and why.

Functions§

check
The assertion form of report, over this crate’s own tables.
check_enums
Hold the parameter enums to the value sets the contract closes.
check_params
Hold one operation’s parameter type to the parameters the contract declares.
registry
Every schema this crate models, in one table.
report
Compare this crate’s models against the vendored contract’s schemas.

Type Aliases§

Table
A coverage table: schema name paired with prose for the reviewer.