tiny.trace.TraceReaderStorage
Defined in tiny.trace.
API (16)
Actions
Public operations.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/trace/src/store/reader/storage.zig:37
zig
pub const Storage = struct { phase: alloc_phase.capacity.Phase, capacity: capacity_mod.Capacity, bytes: []u8, in_use: bool = false, pub const Limits: type = capacity_mod.Limits; pub const Capacity: type = capacity_mod.Capacity; pub const Exhaustion: type = @import("storage.zig").Exhaustion; pub const InitError = std.mem.Allocator.Error || capacity_mod.DeriveError; pub const claim: alloc_phase.capacity.Declaration = .{ .source = .{ .id = "trace.trace_reader_storage", .kind = .phase_static, .limit_source = .caller, .storage = .{ .covered = &.{ .{ .id = "retained_trace_root_path", .lifetime = .steady, .detail = "retained trace root path", }, .{ .id = "phase_shared_bounded_manifest_and_binary_event_block_input", .lifetime = .steady, .detail = "phase-shared bounded manifest and binary event-block input", }, .{ .id = "joined_path_construction_and_manifest_json_nesting_bits", .lifetime = .steady, .detail = "joined-path construction and manifest JSON nesting bits", }, .{ .id = "bounded_lib_sql_pager_and_read_heap", .lifetime = .steady, .detail = "bounded lib/sql pager and read heap", }, }, .excluded = &.{ "filesystem implementation and kernel file state", "replay Session state and consumer-owned event clones", "trace writer encoding storage", }, }, .capacity = .{ .inputs = &.{ alloc_phase.capacity.bindInput(Limits, "chunk_bytes", "chunk_bytes"), alloc_phase.capacity.bindInput(Limits, "event_bytes", "event_bytes"), alloc_phase.capacity.bindInput(Limits, "json_nesting", "json_nesting"), alloc_phase.capacity.bindInput(Limits, "root_path_bytes", "root_path_bytes"), }, .type_selectors = &.{}, .nodes = &.{ .{ .input = 0 }, .{ .input = 1 }, .{ .input = 2 }, .{ .input = 3 }, .{ .add = .{ .left = 0, .right = 1 } }, .{ .add = .{ .left = 4, .right = 2 } }, .{ .add = .{ .left = 5, .right = 3 } }, }, .assertions = &.{.{ .scope = .closure_total, .measure = .retained, .relation = .upper_bound, .expression = 6, }}, }, .overload = .{ .kind = .reject_before_mutation, .detail = "open rejects root path and manifest event/chunk limits at max plus one before publishing reader state", }, .risks = .{ .transitive = .{ .status = .witnessed, .detail = "open, SQL block identity admission, binary event decoding, logical chunk rollover, and verification consume only acquired reader regions after activation", }, .foreign = .{ .status = .excluded, .detail = "filesystem calls and kernel buffering remain effects outside the caller allocator and this storage owner", }, }, .dependencies = &.{ "sql.wal_writer", "sql.file_transaction_staging" }, .obligations = &.{ .{ .key = "trace_trace_reader_capacity", .role = .capacity_model }, .{ .key = "trace_trace_reader_acquisition", .role = .custom }, .{ .key = "trace_trace_reader_oom", .role = .custom }, .{ .key = "trace_trace_reader_boundary", .role = .overload }, .{ .key = "trace_trace_reader_nesting", .role = .overload }, .{ .key = "trace_trace_reader_open_atomic", .role = .overload }, .{ .key = "trace_trace_reader_sealed", .role = .transitive_risk }, .{ .key = "trace_trace_reader_rollover", .role = .foreign_risk }, .{ .key = "trace_trace_reader_root", .role = .custom }, .{ .key = "trace_trace_reader_tuning", .role = .custom }, }, }, .bindings = .{ .owner = @This(), .seal = .{ .family = alloc_phase.capacity.selector(@This().activate), .premise = .{ .class = .checked_semantic_fact, .authority = .checker, }, }, .teardown = .{ .family = alloc_phase.capacity.selector(@This().deinit), .premise = .{ .class = .checked_semantic_fact, .authority = .checker, }, }, }, }; pub fn init(allocator: std.mem.Allocator, limits: Limits) InitError!Storage { const capacity = try Capacity.derive(limits); return .{ .phase = .initialization, .capacity = capacity, .bytes = try allocator.alloc(u8, capacity.storage_bytes), }; } pub fn activate(self: *Storage) void { std.debug.assert(self.phase == .initialization); std.debug.assert(self.bytes.len == self.capacity.storage_bytes); self.phase = .steady; } pub fn acquire(self: *Storage, usage: Usage) Storage.Exhaustion!Regions { std.debug.assert(self.phase == .steady); if (self.in_use) return error.ReaderStorageInUse; if (usage.root_path_bytes > self.capacity.root_path_bytes) return error.RootPathCapacityExceeded; self.in_use = true; return .{ .root_path = self.region(self.capacity.root_path_offset, usage.root_path_bytes), .input = self.region(self.capacity.input_offset, self.capacity.input_bytes), .path = self.region(self.capacity.path_offset, self.capacity.path_bytes), .json_stack = self.region(self.capacity.json_stack_offset, self.capacity.json_stack_bytes), .sql = self.region(self.capacity.sql_offset, self.capacity.sql_bytes), }; } pub fn admit(self: *const Storage, limits: format.Limits) Storage.Exhaustion!void { std.debug.assert(self.phase == .steady); std.debug.assert(self.in_use); if (limits.max_event_bytes > self.capacity.event_bytes) return error.EventCapacityExceeded; if (limits.max_chunk_bytes > self.capacity.chunk_bytes) return error.ChunkCapacityExceeded; } pub fn release(self: *Storage) void { std.debug.assert(self.phase == .steady); std.debug.assert(self.in_use); self.in_use = false; } pub fn status(self: *const Storage) Status { return .{ .phase = self.phase, .in_use = self.in_use, .storage_bytes = self.capacity.storage_bytes, .event_bytes = self.capacity.event_bytes, .chunk_bytes = self.capacity.chunk_bytes, .block_bytes = self.capacity.block_bytes, .json_nesting = self.capacity.json_nesting, .sql_bytes = self.capacity.sql_bytes, }; } pub fn deinit(self: *Storage, allocator: std.mem.Allocator) void { std.debug.assert(self.phase != .teardown); std.debug.assert(!self.in_use); std.debug.assert(self.bytes.len == self.capacity.storage_bytes); self.phase = .teardown; allocator.free(self.bytes); self.bytes = &.{}; } fn region(self: *Storage, offset: usize, count: usize) []u8 { return self.bytes[offset..][0..count]; }};Source: lib/trace/src/root.zig:61
zig
pub const TraceReaderStorage = store.ReaderStorage;Also reachable as
Audit
| Definitions | 12 |
|---|---|
| Public names | 24 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |