tiny.machine.profile.capacity
Defined in profile.
API (5)
Actions
Public operations.
capacity: Returns the contract's bound for one resource, so a caller sizes a buffer before asking for anything.geometry: 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.usage: 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.
Types and contracts
Public types and contracts.
Capacity: 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.Usage: 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.
Source
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
| Definitions | 4 |
|---|---|
| Public names | 4 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |