tiny.machine.profile.types
Defined in profile.
API (29)
Actions
Public operations.
continuationTestV1: Produces the profile that continuation tests run under on a given backend, so a caller can treat stored roots as authoritative.interpretedContinuationTestV1interpretedReconstructV1kvmContinuationTestV1kvmReconstructV1reconstructV1: Produces the canonical reconstruct profile for one backend, so a caller can rebuild a missing root and keep going.validate: Admits a profile when it came from a canonical constructor and carries the inventory identity in force, and refuses it otherwise.
Types and contracts
Public types and contracts.
ArchitectureBackendSemanticsBootDialectCheckpointFormatContract: Holds the rules for executing a guest that every backend of one canonical kind obeys, so a caller can compare contracts to know whether two runs obeyed the same rules.CpuContractDeviceDialectEffectSemanticsEntropySemanticsErrorGeometry: The memory geometry a contract fixes gives how many vCPUs run, the page size, the base address, and the number of bytes, so a caller can check its own memory layout before constructing an instance.InstructionAdmissionMissingRootProfile: One execution contract, the backend chosen to run it, and the determinism claims that pairing makes define a profile.ProfileKind: The two canonical profile kinds, so a caller says how stored roots are treated.RootSemanticsSchedulingTimeSemanticsTransport: The transport sizes a contract takes from the machine ABI fix the encoding version, the ABI major and minor numbers, and the bounds on a frame, a ring, a record, and a payload, so a caller can size its message buffers before it talks to the guest.TransportDialect
Values and defaults
Public values and defaults.
Source
Source: lib/machine/src/profile/root.zig:48
zig
pub const types = @import("types.zig");Source: lib/machine/src/profile/types.zig
zig
const std = @import("std");const os = @import("os");const determinism = @import("determinism.zig");const os_abi = os.abi;pub const schema_major: u16 = 1;pub const schema_minor: u16 = 1;/// The two canonical profile kinds, so a caller says how stored roots are treated./// Reconstruct rebuilds a root when the stored value is absent, so a stored root/// serves only as a cache. By contrast, continuation test requires authoritative/// roots and rejects a missing one.pub const ProfileKind = enum(u8) { reconstruct_v1 = 1, continuation_test_v1 = 2,};pub const Architecture = enum(u8) { x86_64 = 1,};pub const CpuContract = os.boot.kernel.manifest.CpuContract;pub const InstructionAdmission = enum(u16) { verified_deterministic_cfg_v2 = 2,};pub const BootDialect = enum(u16) { elf64_k0_direct_v1 = 1,};pub const RootSemantics = enum(u8) { optional_cache = 1, authoritative = 2,};pub const MissingRoot = enum(u8) { reconstruct = 1, reject = 2,};pub const DeviceDialect = enum(u16) { k0_channels_v1 = 1,};pub const Scheduling = enum(u16) { cooperative_single_vcpu_boundary_v2 = 2,};pub const TimeSemantics = enum(u16) { injected_monotonic_v1 = 1,};pub const EntropySemantics = enum(u16) { injected_stream_v1 = 1,};pub const TransportDialect = enum(u16) { os_machine_v1 = 1,};pub const CheckpointFormat = enum(u16) { machine_root_v1 = 1,};pub const BackendSemantics = enum(u16) { linux_kvm_single_vcpu_v1 = 1, portable_x86_64_interpreter_v1 = 2,};pub const EffectSemantics = enum(u16) { recorded_results_only_v1 = 1,};/// The memory geometry a contract fixes gives how many vCPUs run, the page size,/// the base address, and the number of bytes, so a caller can check its own memory/// layout before constructing an instance. Every canonical profile fixes one vCPU,/// a RAM base of zero, and 67,108,864 RAM bytes.pub const Geometry = struct { vcpu_count: u16, page_bytes: u32, ram_base: u64, ram_bytes: u64,};/// The transport sizes a contract takes from the machine ABI fix the encoding version,/// the ABI major and minor numbers, and the bounds on a frame, a ring, a record,/// and a payload, so a caller can size its message buffers before it talks to the/// guest. The machine ABI supplies every one of these values.pub const Transport = struct { dialect: TransportDialect, abi_major: u16, abi_minor: u16, boot_frame_bytes: u16, message_frame_bytes: u16, ring_header_bytes: u16, request_records: u16, event_records: u16, terminal_bytes: u16, entropy_bytes: u16, semantic_bytes: u16, effect_request_bytes: u16, effect_result_bytes: u16,};/// Holds the rules for executing a guest that every backend of one canonical kind/// obeys, so a caller can compare contracts to know whether two runs obeyed the/// same rules. Enum fields name versioned semantics: the CPU model, the admitted/// instructions, direct K0 boot, root handling, the device dialect, scheduling,/// time, entropy, the checkpoint format, and effect handling. Structured and numeric/// fields fix the geometry, the transport sizes, the determinism identity, and the/// capacity limits. The determinism identity is embedded here, so a change to the/// inventory changes every contract.pub const Contract = struct { schema_major: u16, schema_minor: u16, kind: ProfileKind, architecture: Architecture, cpu: CpuContract, instruction_admission: InstructionAdmission, boot: BootDialect, root_semantics: RootSemantics, missing_root: MissingRoot, device: DeviceDialect, scheduling: Scheduling, time: TimeSemantics, entropy: EntropySemantics, geometry: Geometry, transport: Transport, checkpoint: CheckpointFormat, effects: EffectSemantics, determinism: determinism.Identity, instance_limit: u16, checkpoint_candidate_limit: u16, admission_limit: u32,};/// One execution contract, the backend chosen to run it, and the determinism claims/// that pairing makes define a profile. A caller hands one of these to an instance,/// a checkpoint, or a world so that code knows the rules.pub const Profile = struct { contract: Contract, backend: BackendSemantics, claims: determinism.Claims,};pub const Error = error{ BadMagic, UnsupportedVersion, WireBytesMismatch, UnsupportedFlags, UnknownProfileField, ReservedNonzero, IncompatibleProfile, IncompatibleGeometry, CapacityExceeded,};/// Produces the canonical reconstruct profile for one backend, so a caller can rebuild/// a missing root and keep going. Stored roots are an optional cache under this/// kind, and a missing one is rebuilt.pub fn reconstructV1(backend: BackendSemantics) Profile { return base(.reconstruct_v1, .optional_cache, .reconstruct, backend);}/// Produces the profile that continuation tests run under on a given backend, so/// a caller can treat stored roots as authoritative. Stored roots are authoritative/// under this kind, and a missing one is rejected.pub fn continuationTestV1(backend: BackendSemantics) Profile { return base(.continuation_test_v1, .authoritative, .reject, backend);}pub fn kvmReconstructV1() Profile { return reconstructV1(.linux_kvm_single_vcpu_v1);}pub fn kvmContinuationTestV1() Profile { return continuationTestV1(.linux_kvm_single_vcpu_v1);}pub fn interpretedReconstructV1() Profile { return reconstructV1(.portable_x86_64_interpreter_v1);}pub fn interpretedContinuationTestV1() Profile { return continuationTestV1(.portable_x86_64_interpreter_v1);}/// Admits a profile when it came from a canonical constructor and carries the inventory/// identity in force, and refuses it otherwise. Every entry point that takes a profile/// calls this function first, so a hand-built value goes no further. A profile whose/// determinism identity differs from the current inventory is rejected before anything/// else. The value is then compared field by field against the constructor output/// for its own kind and backend.pub fn validate(value: Profile) Error!void { if (!std.meta.eql(value.contract.determinism, determinism.inventory_identity)) { return error.IncompatibleProfile; } const expected = switch (value.contract.kind) { .reconstruct_v1 => reconstructV1(value.backend), .continuation_test_v1 => continuationTestV1(value.backend), }; if (!std.meta.eql(value, expected)) return error.IncompatibleProfile;}fn base( kind: ProfileKind, root_semantics: RootSemantics, missing_root: MissingRoot, backend: BackendSemantics,) Profile { return .{ .contract = .{ .schema_major = schema_major, .schema_minor = schema_minor, .kind = kind, .architecture = .x86_64, .cpu = .x86_64_k0_long_mode_v1, .instruction_admission = .verified_deterministic_cfg_v2, .boot = .elf64_k0_direct_v1, .root_semantics = root_semantics, .missing_root = missing_root, .device = .k0_channels_v1, .scheduling = .cooperative_single_vcpu_boundary_v2, .time = .injected_monotonic_v1, .entropy = .injected_stream_v1, .geometry = .{ .vcpu_count = 1, .page_bytes = os_abi.boot.page_bytes, .ram_base = 0, .ram_bytes = os_abi.channel.ram_bytes, }, .transport = .{ .dialect = .os_machine_v1, .abi_major = os_abi.major, .abi_minor = os_abi.minor, .boot_frame_bytes = os_abi.boot.frame_bytes, .message_frame_bytes = os_abi.message.frame_bytes, .ring_header_bytes = os_abi.ring.header_bytes, .request_records = os_abi.ring.capacity, .event_records = os_abi.ring.capacity, .terminal_bytes = os_abi.message.terminal_bytes_max, .entropy_bytes = os_abi.message.entropy_bytes_max, .semantic_bytes = os_abi.message.semantic_bytes_max, .effect_request_bytes = os_abi.message.effect_request_bytes_max, .effect_result_bytes = os_abi.message.effect_result_bytes_max, }, .checkpoint = .machine_root_v1, .effects = .recorded_results_only_v1, .determinism = determinism.inventory_identity, .instance_limit = 4, .checkpoint_candidate_limit = 1, .admission_limit = 4096, }, .backend = backend, .claims = claims(kind, backend), };}fn claims( kind: ProfileKind, backend: BackendSemantics,) determinism.Claims { return switch (backend) { .portable_x86_64_interpreter_v1 => switch (kind) { .reconstruct_v1 => determinism.portable_reconstruct_claims, .continuation_test_v1 => determinism.portable_continuation_claims, }, .linux_kvm_single_vcpu_v1 => switch (kind) { .reconstruct_v1 => determinism.kvm_reconstruct_claims, .continuation_test_v1 => determinism.kvm_continuation_claims, }, };}comptime { std.debug.assert(os_abi.boot.page_bytes == os_abi.ring.page_bytes); std.debug.assert(os_abi.boot.ring_capacity == os_abi.ring.capacity); std.debug.assert(os_abi.boot.message_bytes == os_abi.message.frame_bytes); std.debug.assert(os_abi.message.terminal_bytes_max <= std.math.maxInt(u16)); std.debug.assert(os_abi.message.entropy_bytes_max <= std.math.maxInt(u16)); std.debug.assert(os_abi.message.semantic_bytes_max <= std.math.maxInt(u16)); std.debug.assert(os_abi.message.effect_request_bytes_max <= std.math.maxInt(u16)); std.debug.assert(os_abi.message.effect_result_bytes_max <= std.math.maxInt(u16));}Audit
| Definitions | 27 |
|---|---|
| Public names | 53 |
| Members | 40 |
| Version | 26.7.0 |
| Revision | daab053ee433 |