Skip to main content

resolve

Function resolve 

Source
pub fn resolve(negotiation: Negotiation) -> FeatureProfile
Expand description

Resolves the features a negotiated session has.

Pure: the same inputs always give the same profile, and nothing here reads a clock, a socket, or global state. That is what makes the golden snapshot worth having — a profile is a function of four values, so it can be reviewed as a table rather than discovered at runtime.

A feature is on when all four of its row’s conditions hold:

  1. version is within the row’s revision window.
  2. The side that must support it actually declared the required capability, for the side that owns it.
  3. The transport, if the row names one, is defined for the version and matches.
  4. The capability the row needs is one the version’s schema defines, which stops a newer peer’s flag from switching on a feature an older revision cannot express.

§Examples

use protocol_droid::domain::{
    Capability, CapabilitySet, Feature, Negotiation, ProtocolVersion,
    TransportKind, resolve,
};

// 2024-11-05 over stdio, with everything that revision defines advertised.
let version = ProtocolVersion::V2024_11_05;
let all = CapabilitySet::all_for(version);
let profile = resolve(Negotiation {
    version,
    client_caps: all,
    server_caps: all,
    transport: TransportKind::Stdio,
});
assert!(profile.allows(Feature::Tools));
assert!(!profile.allows(Feature::Elicitation), "added in 2025-06-18");