Skip to documentation
SLOP

tiny.machine.profile.capacity

Reference tiny.machine profile capacity

Defined in profile.

API (5)

Actions

Public operations.

Types and contracts

Public types and contracts.

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

Source

Called byCallsNo direct callsprofile.capacityusagetest sourcelib.machine.src.profile.testtest: every profile capacity accepts ...profile.capacitycapacity
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.machine.src.instance.ownervalidateProfileGeometrytest sourcelib.machine.src.profile.testtest: fixed instance geometry rejects...profile.capacitygeometry
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallstest sourcelib.machine.src.profile.testtest: every profile capacity accepts ...profile.capacitycapacityprofile.capacityusage
Static calls · unresolved targets: 1 · external targets: 1.

Source: lib/machine/src/profile/capacity.zig

zig
const std = @import("std");const profile = @import("root.zig");/// The ten bounded resources one profile pins, so a caller names one to ask for/// its bound: instances, checkpoint candidates, admissions, request records, event/// records, and the byte bounds for terminal, entropy, semantic, effect-request,/// and effect-result payloads.pub const Capacity = enum(u8) {    instances,    checkpoint_candidates,    admissions,    request_records,    event_records,    terminal_bytes,    entropy_bytes,    semantic_bytes,    effect_request_bytes,    effect_result_bytes,};/// A requested value per bounded resource, held as one fixed array with a getter/// and a setter so a caller fills one in to have a whole set of requests checked/// at once. Every value starts at zero.pub const Usage = struct {    values: [std.meta.tags(Capacity).len]u32 = @splat(0),    pub fn get(self: Usage, kind: Capacity) u32 {        return self.values[@backingInt(kind)];    }    pub fn set(self: *Usage, kind: Capacity, value: u32) void {        self.values[@backingInt(kind)] = value;    }};/// Returns the contract's bound for one resource, so a caller sizes a buffer before/// asking for anything. Each bound is read straight from the contract, either from/// a limit field or from the transport sizes.pub fn capacity(value: profile.Profile, kind: Capacity) u32 {    return switch (kind) {        .instances => value.contract.instance_limit,        .checkpoint_candidates => value.contract.checkpoint_candidate_limit,        .admissions => value.contract.admission_limit,        .request_records => value.contract.transport.request_records,        .event_records => value.contract.transport.event_records,        .terminal_bytes => value.contract.transport.terminal_bytes,        .entropy_bytes => value.contract.transport.entropy_bytes,        .semantic_bytes => value.contract.transport.semantic_bytes,        .effect_request_bytes => value.contract.transport.effect_request_bytes,        .effect_result_bytes => value.contract.transport.effect_result_bytes,    };}/// Checks the profile first, then refuses a request larger than the bound that profile/// sets, so a caller checks a whole request set before committing to it. Every one/// of the ten resources is checked, and the first one over its bound rejects.pub fn usage(value: profile.Profile, requested: Usage) profile.Error!void {    try profile.validate(value);    for (std.meta.tags(Capacity)) |kind| {        if (requested.get(kind) > capacity(value, kind)) {            return error.CapacityExceeded;        }    }}/// Checks the profile first, then refuses a geometry unequal to the one the contract/// pins, so a caller proves its own memory layout matches the profile before constructing/// an instance. The comparison covers all four fields, so a changed vCPU count,/// page size, base address, or byte count rejects.pub fn geometry(value: profile.Profile, requested: profile.Geometry) profile.Error!void {    try profile.validate(value);    if (!std.meta.eql(value.contract.geometry, requested)) {        return error.IncompatibleGeometry;    }}

Source: lib/machine/src/profile/root.zig:46

zig
pub const capacity = @import("capacity.zig");

Audit

Definitions4
Public names4
Members0
Version26.7.0
Revisiondaab053ee433