Skip to main content

vyre_runtime/megakernel/
mod.rs

1//! Resident work-queue protocol, host mirrors, scheduling policy, and IO.
2//!
3//! Artifact compilation and target selection live in `vyre-megakernel`.
4//! Authenticated execution and recovery live in [`crate::ArtifactSession`].
5//! This module owns only mutable queue policy and wire state.
6
7#[cfg(feature = "megakernel-batch")]
8pub mod advanced;
9pub mod automata_worklist;
10pub mod builder;
11pub mod descriptor;
12pub mod handlers;
13pub mod io;
14pub mod ir_util;
15pub mod mixed_work;
16pub mod planner;
17pub mod policy;
18pub mod protocol;
19mod protocol_api;
20pub mod readback;
21pub mod resident;
22pub mod ring;
23#[cfg(feature = "megakernel-batch")]
24pub mod rule_catalog;
25pub mod scaling;
26pub mod scheduler;
27pub mod speculation;
28mod staging_reserve;
29pub mod task;
30pub mod telemetry;
31pub mod workspace_adapter;
32pub mod workspace_layout;
33
34/// Stateless owner of resident work-queue encoding and decoding operations.
35#[derive(Clone, Copy, Debug, Default)]
36pub struct ResidentWorkQueue;
37pub use automata_worklist::{
38    AutomataStateIndex, AutomataWorklistEvidence, AutomataWorklistMode, AutomataWorklistPolicy,
39    AutomataWorklistRecommendation, AutomataWorklistRequest,
40    AUTOMATA_WORKLIST_EVIDENCE_SCHEMA_VERSION,
41};
42#[cfg(test)]
43pub use builder::build_program_with_self_loading_miss_handler;
44pub use builder::{
45    build_program, build_program_jit, build_program_jit_slots, build_program_priority,
46    build_program_priority_slots, build_program_sharded, build_program_sharded_no_io,
47    build_program_sharded_once_slots, build_program_sharded_once_slots_control_report_shared,
48    build_program_sharded_once_slots_shared, build_program_sharded_slots,
49    build_program_sharded_slots_shared, build_program_sharded_with_io_polling,
50    build_program_sharded_with_workspace_adapter, persistent_body, persistent_body_jit,
51    persistent_body_priority, persistent_body_priority_slots,
52    try_build_program_with_self_loading_miss_handler,
53};
54pub use descriptor::{
55    BatchDescriptor, BuiltinOpcode, PackedOpDescriptor, SlotDescriptor, SlotOpcode, WindowClass,
56    WindowDescriptor,
57};
58pub use handlers::OpcodeHandler;
59pub use io::{IoCompletion, IoRequest, ResidentIoQueue, IO_SLOT_COUNT, IO_SLOT_WORDS};
60pub use mixed_work::{
61    mixed_work_protocol_evidence, validate_mixed_work_protocol, MixedWorkProtocolError,
62    MixedWorkProtocolEvidence, MixedWorkProtocolPlan, MixedWorkQueueClass, MixedWorkUnit,
63    MixedWorkUnitType, OutputSlabId, ResidentArtifactId, MIXED_WORK_PROTOCOL_SCHEMA_VERSION,
64};
65#[cfg(feature = "self-substrate-adapters")]
66pub use planner::{
67    build_bellman_tn_order_program, build_kfac_autotune_step_program,
68    build_persistent_fixpoint_program, build_scallop_provenance_wide_program,
69    build_sinkhorn_clustering_program, build_sinkhorn_full_clustering_program,
70};
71pub use planner::{
72    dispatch_grid_for, padded_slot_count, worker_workgroup_size, ResidentGridLimits,
73    ResidentGridPlan, ResidentGridRequest, ResidentLaunchGeometry, ResidentQueueCapabilities,
74    ResidentQueueConfig, ResidentQueueReport, ResidentQueueTelemetry, ResidentSizingPolicy,
75    ResidentWorkItem, ResidentWorkloadHints,
76};
77#[cfg(test)]
78pub use policy::{diffuse_priority_across_siblings, diffuse_priority_across_siblings_into};
79pub use policy::{
80    try_diffuse_priority_across_siblings, try_diffuse_priority_across_siblings_into,
81    PriorityDrainReason, PriorityDrainRecommendation, PriorityRequeueAccounting,
82    ResidentExecutionMode, ResidentGraphBlasSwitchClass, ResidentLaunchCacheStats,
83    ResidentLaunchPolicy, ResidentLaunchRecommendation, ResidentLaunchRequest,
84    ResidentPromotionEvidence, ResidentPromotionRoute, ResidentQueuePressure,
85    ResidentQueueTopology, ResidentTopologyEvidence, HOT_WINDOW_PROMOTION_EVIDENCE_SCHEMA_VERSION,
86    PRIORITY_COUNTER_DRAIN_FIX, PRIORITY_COUNTER_DRAIN_HEADROOM, TOPOLOGY_EVIDENCE_SCHEMA_VERSION,
87};
88pub use protocol::{
89    control, control_byte_len, count_done_ring_slots, debug, debug_log_byte_len, encode_control,
90    encode_empty_debug_log, encode_empty_ring, opcode, read_debug_log, read_done_count, read_epoch,
91    read_metrics, read_observable, ring_byte_len, slot, try_count_done_ring_slots,
92    try_encode_control, try_encode_control_into, try_encode_empty_debug_log,
93    try_encode_empty_debug_log_into, try_encode_empty_ring, try_encode_empty_ring_into,
94    try_read_debug_log, try_read_done_count, try_read_epoch, try_read_metrics, try_read_observable,
95    DebugRecord, ProtocolError, ARG0_WORD, ARGS_PER_SLOT, CONTROL_MIN_WORDS, OPCODE_WORD,
96    PRIORITY_WORD, SLOT_WORDS, STATUS_WORD, TENANT_WORD,
97};
98pub use protocol_api::RingSlotTransition;
99pub use readback::{ResidentQueueReadback, ResidentReadbackCounters};
100pub use resident::ResidentQueueBuffers;
101#[cfg(feature = "megakernel-batch")]
102pub use rule_catalog::{BatchRuleProgram, BatchRuleRejection};
103pub use scheduler::{
104    default_priority_offsets_array, priority_partition_active_lane_count,
105    priority_partition_probe_budget, priority_partition_probe_count, priority_scan_body,
106    priority_scan_body_with_stride, write_default_priority_offsets,
107};
108pub use speculation::{PairedSpeculationSample, PairedSpeculationUpdate, PairedSpeculationWindow};
109pub use task::{TaskPriority, TaskQueueSnapshot, TaskState, TaskWorkItem};
110pub use telemetry::{
111    ControlSnapshot, CountMinSketch, ResidentRuntimeCounters, RingOccupancy, RingSlotSnapshot,
112    RingStatus, RingTelemetry, SketchTelemetry, WindowTelemetry,
113};
114pub use telemetry::{
115    ResidentRuntimeEvidence, RuntimeEvidenceMetricCoverage, RuntimeEvidenceMetricFamily,
116    TelemetryDecodeCapacityEvidence, TelemetryDecodeScratch, RUNTIME_IO_EVIDENCE_SCHEMA_VERSION,
117    TELEMETRY_DECODE_CAPACITY_SCHEMA_VERSION,
118};
119pub use workspace_adapter::ResidentWorkspaceAdapter;
120pub use workspace_layout::{
121    build_workspace_regions, first_workspace_region, next_record_workspace_region,
122    next_workspace_region, workspace_record_words, ResidentWorkspaceLayoutError,
123    ResidentWorkspaceRegion, ResidentWorkspaceRegionSpec,
124};