Skip to documentation
SLOP

tiny.machine.admission

Reference tiny.machine admission

Defined in tiny.machine.

Replaying a run requires feeding the guest exactly the inputs the first run saw, in the same order, and this namespace records each one so a later reader can check the whole history from the receipts alone.

API (27)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.machineadmission
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/machine/src/admission/canon.zig:13

zig
/// A caller matches on these rejections of admission material to tell a malformed/// input apart from one that arrived out of order. Every variant means one of four/// things failed: validation of a field, a payload bound, the ordering against a/// frontier, or the recomputation of a digest.pub const Error = error{    ContractDigestInvalid,    EffectFrontierExhausted,    EffectRequestInvalid,    EffectRequestPending,    EffectReceiptInvalid,    EffectOutputRootInvalid,    EntropyGenerationExhausted,    EntropyGenerationMismatch,    InputFrontierExhausted,    DeliveryFenceInvalid,    DeliveryFenceMismatch,    NoncanonicalDelivery,    NoncanonicalRecord,    PayloadCapacityExceeded,    PayloadEmpty,    SourceRootInvalid,    TerminalOffsetExhausted,    TerminalOffsetMismatch,    VirtualTimeMismatch,};

Source: lib/machine/src/admission/types.zig:117

zig
/// One admitted record with everything needed to recheck it: the contract fingerprint,/// the source root, the input position, the frontiers before it, the record, the/// frontiers expected after it, the outstanding effect before and after, and the/// committing receipt./// Verification rebuilds the whole value from the basis and the record, then compares/// that rebuild against the stored one.pub const Admission = struct {    contract: profile.ContractFingerprint,    source_root: Digest,    position: u64,    frontiers: Frontiers,    record: Record,    expected: Frontiers,    outstanding_effect: ?EffectRequest,    expected_outstanding_effect: ?EffectRequest,    receipt: Receipt,};

Source: lib/machine/src/admission/types.zig:99

zig
/// The authenticated position an input is admitted against, naming the source root/// in force, the contract fingerprint, the five frontiers, and any effect still/// outstanding./// A basis with an all-zero contract digest, an all-zero source root, or an out-of-order/// outstanding request is rejected.pub const Basis = struct {    contract: profile.ContractFingerprint,    source_root: Digest,    frontiers: Frontiers,    outstanding_effect: ?EffectRequest,};

Source: lib/machine/src/admission/types.zig:133

zig
/// One admission joined to an activation fence and to the source root that follows,/// in the form written into the guest's request ring./// The delivery receipt commits the admission receipt, the next source root, and/// all three fence fields.pub const Delivery = struct {    admission: Admission,    next_source_root: Digest,    fence: os.abi.ActivationFence,    receipt: DeliveryReceipt,};

Source: lib/machine/src/admission/types.zig:141

zig
/// The digest committing one delivery.pub const DeliveryReceipt = struct {    digest: Digest,};

Source: lib/machine/src/admission/types.zig:61

zig
/// One outstanding guest request: the digest of its receipt and its correlation/// value./// The correlation must be the effect frontier plus one, so requests answer in order.pub const EffectRequest = struct {    receipt: EffectRequestReceipt,    correlation: u64,};

Source: lib/machine/src/admission/types.zig:67

zig
/// The receipt digest that names one guest effect request.pub const EffectRequestReceipt = struct {    digest: Digest,};

Source: lib/machine/src/admission/types.zig:50

zig
/// One admitted result for outside work, bound to the request it answers: the request,/// the effect status, the output root, the payload length, and fixed payload storage./// The carried request must equal the outstanding effect, and admitting the result/// clears that effect.pub const EffectResult = struct {    request: EffectRequest,    status: os.abi.EffectStatus,    output_root: Digest,    length: u16,    storage: [effect_result_bytes_max]u8,};

Source: lib/machine/src/admission/types.zig:40

zig
/// One admitted entropy block: its generation, its payload length, and fixed payload/// storage./// The generation must be the entropy frontier plus one.pub const Entropy = struct {    generation: u64,    length: u16,    storage: [entropy_bytes_max]u8,};

Source: lib/machine/src/admission/types.zig:86

zig
/// The five counters that fix the order of admitted inputs and only rise, one for/// the input position, one for the terminal offset, one for the time tick, one for/// the entropy generation, and one for the effect count./// Every counter moves forward under overflow-checked arithmetic, and an exhausted/// counter rejects the admission.pub const Frontiers = struct {    input: u64,    terminal_input_offset: u64,    virtual_time_tick: u64,    entropy_generation: u64,    effect: u64,};

Source: lib/machine/src/admission/types.zig:107

zig
/// The receipt digest taken over one admission.pub const Receipt = struct {    digest: Digest,};

Source: lib/machine/src/admission/types.zig:74

zig
/// One record of an input crossing into the guest./// The four kinds are terminal bytes, a virtual-time advance, an entropy block,/// and an effect result.pub const Record = union(enum) {    terminal: Terminal,    virtual_time: VirtualTime,    entropy: Entropy,    effect_result: EffectResult,};

Source: lib/machine/src/admission/types.zig:23

zig
/// One terminal input after admission, holding where its bytes sit in the terminal/// stream, how many bytes it carries, and the fixed storage those bytes occupy./// The offset must equal the terminal frontier at admission, and admitting the record/// moves that frontier forward by the payload length./// Every storage byte past the payload length is zero.pub const Terminal = struct {    offset: u64,    length: u16,    storage: [terminal_bytes_max]u8,};

Source: lib/machine/src/admission/types.zig:32

zig
/// One clock advance after admission, holding the tick it leaves and the strictly/// greater tick it moves to./// The source tick must equal the time frontier at admission.pub const VirtualTime = struct {    from_tick: u64,    to_tick: u64,};

Source: lib/machine/src/admission/canon.zig:160

zig
/// Joins one admission with a fence it has validated and with the source root that/// follows, then hashes the whole into a delivery receipt, so a caller can produce/// the delivery form the guest accepts. An all-zero next source root is rejected,/// and so is a fence with a zero generation, an all-zero world, or an all-zero token.pub fn bindDelivery(    value: types.Admission,    next_source_root: types.Digest,    fence: os.abi.ActivationFence,) Error!types.Delivery {    try validateDigest(next_source_root, error.SourceRootInvalid);    os.abi.wire.validateFence(fence) catch        return error.DeliveryFenceInvalid;    var result: types.Delivery = .{        .admission = value,        .next_source_root = next_source_root,        .fence = fence,        .receipt = .{ .digest = undefined },    };    result.receipt.digest = deliveryDigest(result);    return result;}
Called byCallsadmissionverifyDeliveryprivate sourcelib.machine.src.admission.canondeliveryDigestprivate sourcelib.machine.src.admission.canonvalidateDigestadmissionbindDelivery
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/machine/src/admission/canon.zig:83

zig
/// Copies the caller's bytes into fixed storage for a caller answering the outstanding/// guest request, pairing them with the receipt and correlation of the request being/// answered, the status of the effect, and the root of its output. A payload longer/// than the effect-result bound is rejected. By contrast, an empty payload is accepted,/// so a result that reports a status and carries no bytes passes.pub fn effectResult(    request_receipt: types.Digest,    correlation: u64,    status: os.abi.EffectStatus,    output_root: types.Digest,    bytes: []const u8,) Error!types.Record {    if (bytes.len > types.effect_result_bytes_max) {        return error.PayloadCapacityExceeded;    }    var value: types.EffectResult = .{        .request = .{            .receipt = .{ .digest = request_receipt },            .correlation = correlation,        },        .status = status,        .output_root = output_root,        .length = @intCast(bytes.len),        .storage = @splat(0),    };    @memcpy(value.storage[0..bytes.len], bytes);    return .{ .effect_result = value };}

Source: lib/machine/src/admission/canon.zig:66

zig
/// Builds an entropy record for one generation from the caller's bytes so a caller/// can hand the guest a recorded block of randomness, copying them into the record's/// fixed storage. An empty payload is rejected, and so is one longer than the entropy/// bound.pub fn entropy(generation: u64, bytes: []const u8) Error!types.Record {    if (bytes.len == 0) return error.PayloadEmpty;    if (bytes.len > types.entropy_bytes_max) return error.PayloadCapacityExceeded;    var value: types.Entropy = .{        .generation = generation,        .length = @intCast(bytes.len),        .storage = @splat(0),    };    @memcpy(value.storage[0..bytes.len], bytes);    return .{ .entropy = value };}

Source: lib/machine/src/admission/canon.zig:113

zig
/// Applies one record to a basis it has validated, then hashes the outcome into/// the receipt it returns, so a caller can deliver the resulting admission and a/// verifier can recheck it. The input position is the input frontier plus one. While/// an effect request is outstanding, only its result admits. Frontier arithmetic/// is checked for overflow, so a counter at its limit rejects the record and holds/// its value.pub fn prepare(basis: types.Basis, record: types.Record) Error!types.Admission {    try validateBasis(basis);    const position = std.math.add(u64, basis.frontiers.input, 1) catch        return error.InputFrontierExhausted;    var expected = basis.frontiers;    var expected_outstanding_effect = basis.outstanding_effect;    expected.input = position;    try fold(&expected, &expected_outstanding_effect, record);    var result: types.Admission = .{        .contract = basis.contract,        .source_root = basis.source_root,        .position = position,        .frontiers = basis.frontiers,        .record = record,        .expected = expected,        .outstanding_effect = basis.outstanding_effect,        .expected_outstanding_effect = expected_outstanding_effect,        .receipt = .{ .digest = undefined },    };    result.receipt.digest = digest(&result);    return result;}
Called byCallsadmissionverifyprivate sourcelib.machine.src.admission.canondigestprivate sourcelib.machine.src.admission.canonfoldadmissionvalidateBasisadmissionprepare
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/machine/src/admission/canon.zig:39

zig
/// Builds a terminal record at one offset from the caller's bytes for each chunk/// of input bytes the caller wants the guest to read, copying them into the record's/// fixed storage. An empty payload is rejected, and so is one longer than the terminal/// bound.pub fn terminal(offset: u64, bytes: []const u8) Error!types.Record {    if (bytes.len == 0) return error.PayloadEmpty;    if (bytes.len > types.terminal_bytes_max) return error.PayloadCapacityExceeded;    var value: types.Terminal = .{        .offset = offset,        .length = @intCast(bytes.len),        .storage = @splat(0),    };    @memcpy(value.storage[0..bytes.len], bytes);    return .{ .terminal = value };}

Source: lib/machine/src/admission/canon.zig:141

zig
/// Rejects a basis whose contract digest, source root, or outstanding effect request/// fails validation, so a caller can check the basis before building a record against/// it. An all-zero contract digest and an all-zero source root are both rejected./// An outstanding request whose correlation is other than the effect frontier plus/// one is rejected.pub fn validateBasis(basis: types.Basis) Error!void {    try validateDigest(basis.contract.digest, error.ContractDigestInvalid);    try validateDigest(basis.source_root, error.SourceRootInvalid);    try validateEffectRequest(basis);}
Called byCallsadmissionprepareprivate sourcelib.machine.src.admission.canonvalidateDigestprivate sourcelib.machine.src.admission.canonvalidateEffectRequestadmissionvalidateBasis
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/machine/src/admission/canon.zig:151

zig
/// The call recomputes the expected admission from the basis and the record, then/// rejects a value that differs anywhere, so a reader holding a recorded admission/// can prove it unchanged. The comparison covers every field, receipt included,/// so a changed payload byte fails it.pub fn verify(basis: types.Basis, value: *const types.Admission) Error!void {    const expected = try prepare(basis, value.record);    if (!std.meta.eql(expected, value.*)) return error.NoncanonicalRecord;}
Called byCallsadmissionverifyDeliveryadmissionprepareadmissionverify
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/machine/src/admission/canon.zig:182

zig
/// Checks a delivery in three layers, innermost first, so a reader holding a recorded/// delivery can prove both the delivery and the admission inside it: its fence has/// to equal the one the caller names, the admission it wraps has to verify against/// the basis, and its own receipt has to hash to the stored value.pub fn verifyDelivery(    basis: types.Basis,    fence: os.abi.ActivationFence,    value: *const types.Delivery,) Error!void {    try validateDigest(value.next_source_root, error.SourceRootInvalid);    os.abi.wire.validateFence(value.fence) catch        return error.DeliveryFenceInvalid;    if (!os.abi.wire.equalFence(fence, value.fence)) {        return error.DeliveryFenceMismatch;    }    try verify(basis, &value.admission);    const expected = try bindDelivery(        value.admission,        value.next_source_root,        value.fence,    );    if (!std.meta.eql(expected, value.*)) return error.NoncanonicalDelivery;}
Called byCallsNo direct callersadmissionbindDeliveryprivate sourcelib.machine.src.admission.canonvalidateDigestadmissionverifyadmissionverifyDelivery
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/machine/src/admission/canon.zig:54

zig
/// Builds a clock advance from one tick to another so a caller can move the guest's/// clock. The clock advance is admitted only when the tick it moves to is strictly/// greater than the tick it leaves.pub fn virtualTime(from_tick: u64, to_tick: u64) Error!types.Record {    if (to_tick <= from_tick) return error.VirtualTimeMismatch;    return .{ .virtual_time = .{        .from_tick = from_tick,        .to_tick = to_tick,    } };}

Source: lib/machine/src/admission/root.zig

zig
//! Replaying a run requires feeding the guest exactly the inputs the first run saw,//! in the same order, and this namespace records each one so a later reader can//! check the whole history from the receipts alone. Four kinds of input cross into//! the guest: terminal bytes, a virtual-time advance, an entropy block, and an effect//! result. Each input is checked against where the guest stood when it arrived.//! Each input reaches the guest through its request ring, together with the authority//! to run the guest work that settles it.//!//! Terminal, entropy, and effect-result payloads are held in fixed storage sized//! by the machine ABI message bounds. While a guest request for an outside effect//! awaits its result, every other kind of input is refused until that result is//! admitted. The counters that order inputs are checked for overflow, so a counter//! at its limit rejects the input and holds its value. Verification recomputes a//! receipt from its material and rejects an input that changed. Receipts of different//! kinds must never collide.//!//! The namespace admits each recorded outside influence (an *admission*): it folds//! the influence into an authenticated position and produces a receipt committing//! the input and that position. That position (the *basis*) names the authenticated//! state in force, the identity of the shared execution rules, the five ordering//! counters, and any effect request still outstanding. `prepare` applies one input//! to a basis it has validated, then hashes the outcome into a receipt. `bindDelivery`//! joins one admission with the world, generation, and token authorized for one//! run turn (an *activation fence*), and with the authenticated state that follows.//! The guest's request ring receives that joined bundle, a *delivery*. Receipts//! are SHA-256 digests, each taken under a distinct constant string hashed before//! the value (a *domain tag*), with one tag for admissions and another for deliveries.//!//! - *record*: one input crossing into the guest.//! - *admission receipt*: the digest committing one admission.//! - *source root*: the digest naming the authenticated state a basis stands on.//! - *contract fingerprint*: the identity of the shared execution rules, computed//!   over the encoded profile with the backend field and the claim fields zeroed.//! - *frontiers*: the five counters that order admitted inputs and only rise, one//!   each for the input position, the terminal offset, the time tick, the entropy//!   generation, and the effect count.const canon = @import("canon.zig");const types = @import("types.zig");pub const Admission = types.Admission;pub const Basis = types.Basis;pub const Delivery = types.Delivery;pub const DeliveryReceipt = types.DeliveryReceipt;pub const Digest = types.Digest;pub const EffectResult = types.EffectResult;pub const EffectRequest = types.EffectRequest;pub const EffectRequestReceipt = types.EffectRequestReceipt;pub const Entropy = types.Entropy;pub const Error = canon.Error;pub const Frontiers = types.Frontiers;pub const Receipt = types.Receipt;pub const Record = types.Record;pub const Terminal = types.Terminal;pub const VirtualTime = types.VirtualTime;pub const effect_result_bytes_max = types.effect_result_bytes_max;pub const entropy = canon.entropy;pub const entropy_bytes_max = types.entropy_bytes_max;pub const effectResult = canon.effectResult;pub const bindDelivery = canon.bindDelivery;pub const prepare = canon.prepare;pub const terminal = canon.terminal;pub const terminal_bytes_max = types.terminal_bytes_max;pub const validateBasis = canon.validateBasis;pub const verify = canon.verify;pub const verifyDelivery = canon.verifyDelivery;pub const virtualTime = canon.virtualTime;

Source: lib/machine/src/root.zig:65

zig
pub const admission = @import("admission/root.zig");

Source: lib/machine/src/admission/types.zig:7

zig
/// The 32-byte digest type every root and receipt in this namespace carries./// The type comes from the machine ABI, so an admission digest and a message digest/// are one type.pub const Digest = os.abi.Digest;

Source: lib/machine/src/admission/types.zig:16

zig
/// The largest effect-result payload the machine ABI allows, in bytes./// An effect result built from more bytes than this is rejected.pub const effect_result_bytes_max: usize = os.abi.message.effect_result_bytes_max;

Source: lib/machine/src/admission/types.zig:13

zig
/// The largest entropy payload the machine ABI allows, in bytes./// An entropy record built from more bytes than this is rejected.pub const entropy_bytes_max: usize = os.abi.message.entropy_bytes_max;

Source: lib/machine/src/admission/types.zig:10

zig
/// The largest terminal payload the machine ABI allows, in bytes./// A terminal record built from more bytes than this is rejected.pub const terminal_bytes_max: usize = os.abi.message.terminal_bytes_max;

Audit

Definitions28
Public names29
Members63
Version26.7.0
Revisiondaab053ee433