Skip to main content

Crate newt_interaction

Crate newt_interaction 

Source
Expand description

Newt Markup interaction protocol — the renderer-neutral model (A2, #1828).

ADR: docs/decisions/newt_markup_interaction_architecture.md. This crate is the model half of that MVC variation: an immutable, semantic InteractionDefinition, a host-minted, out-of-band InteractionInstance, and a typed Response. It defines the records and the STATES; the controller that drives transitions is A3’s, and no renderer lives here or ever will.

Dependency direction is binding. This is the inward layer: it takes no Ratatui, crossterm, Axum, HTMX, ammonia, browser, mobile, filesystem, or application dependency, and no newt-* crate. newt-core depends on this crate; never the reverse. tests/guard.rs arms that as a test rather than a comment — one half over the resolved dependency closure, one over this crate’s own source — and each half carries an anti-vacuous twin, because a guard that cannot fail is decoration.

Identity is derived, never assigned. Every record here is a canonical structured value, so its identity is a ContentId minted through ContentAddressable + canonical::to_canonical_dagcbor — the codec makes determinism a property of the encoder, not of caller discipline. Nothing in this crate hand-rolls a digest or a canonical encoding. The single deliberate exception is the instance NONCE, which is fresh and unguessable rather than content-derived: it is a locator that travels beside the address, and possession of it authorizes nothing. IDs route; they are not credentials.

This file is a manifest: composition only, no logic.

Re-exports§

pub use binding::validate_response;
pub use binding::Accepted;
pub use binding::HandlerId;
pub use binding::Refusal;
pub use binding::RegisteredAction;
pub use binding::ResolvedAction;
pub use binding::ResponderContext;
pub use definition::controls_are_decision_shaped;
pub use definition::ChoiceOption;
pub use definition::Control;
pub use definition::ControlKind;
pub use definition::FeatureDemand;
pub use definition::InteractionDefinition;
pub use definition::InteractionKind;
pub use definition::PathKind;
pub use definition::Requirement;
pub use definition::SemanticRole;
pub use definition::SurfaceFeature;
pub use definition::TemporalPrecision;
pub use definition::DEFINITION_SCHEMA_V1;
pub use downgrade::decode_definition;
pub use downgrade::decode_instance;
pub use downgrade::decode_response;
pub use downgrade::plan_presentation;
pub use downgrade::Decoded;
pub use downgrade::Degradation;
pub use downgrade::Presentation;
pub use downgrade::RawRecord;
pub use downgrade::UnknownReason;
pub use error::ProtocolError;
pub use ids::ControlId;
pub use ids::DefinitionId;
pub use ids::IdempotencyKey;
pub use ids::InstanceId;
pub use ids::Nonce;
pub use ids::OptionId;
pub use ids::ResponseId;
pub use ids::Revision;
pub use instance::Audience;
pub use instance::InteractionInstance;
pub use instance::LifecycleState;
pub use instance::Provenance;
pub use instance::ResponderPolicy;
pub use instance::Scope;
pub use instance::INSTANCE_SCHEMA_V1;
pub use lifecycle::publish;
pub use lifecycle::HostMint;
pub use lifecycle::Lifecycle;
pub use lifecycle::LifecycleError;
pub use resolution::IdempotencyConflict;
pub use resolution::Resolution;
pub use resolution::ResolutionError;
pub use resolution::ResolutionRecord;
pub use resolution::ResolutionStore;
pub use response::AssertionKind;
pub use response::ControlValue;
pub use response::ResponderProvenance;
pub use response::Response;
pub use response::SecretRef;
pub use response::Submission;
pub use response::RESPONSE_SCHEMA_V1;
pub use tag::DefinitionTag;
pub use tag::InstanceTag;
pub use tag::ResponseTag;

Modules§

binding
Fail-closed response validation (A3, #1837).
definition
The immutable, semantic definition of one interaction.
downgrade
Reading a record this build may not have been written for, and presenting one a surface may not be able to satisfy.
error
Protocol errors. Fail closed: none of these fall back to guessing.
ids
Identifiers. Three content-derived ids, and the locators that travel beside them.
instance
The host-minted offer: the binding of a definition to an audience, kept OUT of the definition so definition bytes stay immutable (ADR law 12).
lifecycle
The host-minted lifecycle (A3, #1837).
resolution
Exactly-once resolution: the contract, not the storage (A3, #1837).
response
The typed response: what a responder submitted, bound to exactly what they were offered.
tag
The versioned type tag, as a TYPE.