Skip to main content

emit_contracts_manifest

Function emit_contracts_manifest 

Source
pub fn emit_contracts_manifest(
    provides: &BTreeMap<String, String>,
    expects: &BTreeMap<String, BTreeMap<String, String>>,
    foreign: &BTreeMap<String, BTreeMap<String, String>>,
    shapes: &Shapes,
) -> Option<String>
Expand description

Render a context’s contract manifest: what it provides, and what it expects of each context it consumes.

Both halves are needed, and they are not the same fact:

  • provides is this context’s own constant per on call service — what its entry enforces. deploy records it when the Worker is pushed, so the ledger knows what is live.
  • expects is this context’s compiled view of each dependency’s contract — the constant it stamps at each call site. deploy compares it against the ledger’s provides for that dependency, which is exactly the runtime check moved earlier.

A gate built on provides alone could not work: it would compare a context against itself.

Absent rather than empty when a context neither exposes nor calls an on call service: a project that never crosses a context boundary must not grow a file into every worker directory for a feature it does not use — and “no file” is the same answer as “empty” to a driver that must tolerate a build tree from a compiler predating this file anyway.

I4 (#1970): foreign is the third half, what each declared foreign caller’s generated client embeds — actor → service → hash, the services that actor may call. A foreign caller has no bynk-contracts.json of its own to state its expects, so deploy holds this against the pin the callee’s project records for it (bynk.foreign.toml) and refuses a build that would break it (design/archive/retired-tracks.md, interop track D3, Q6). Additive within version 1, and absent when empty, so every manifest of a context with no foreign caller is byte-identical to before.