feat(trace+ai): add cubetrace package and wire DBT/AI/CUBEsys command + module edits (green-lit WIP)
Brings in the cubetrace crate (PDF Package 4, §547): wraps a DBI engine via an
FFI seam and streams trace events (basic blocks, syscalls) into cubestore,
tagging each with CZYX coordinates and header flags.
- Cargo.toml: register cubetrace workspace member
- cubeai/src/lib.rs, cubedbt/src/lib.rs: DBT/AI rule + trace integration edits
- cubecode/src/{cb,cell}.rs: code-cell bytecode/module plumbing for traces
- cubesys/src/commands.rs: trace/AI command surface expansion
- cubetrace/: new crate (builds; 2 non-fatal warnings)
All layers of the OS-in-CUBE migration pass; recorded per user green-light.
This commit is contained in:
+8
-22
@@ -26,7 +26,7 @@
|
||||
//! `Vm`, returning the `RunResult`.
|
||||
|
||||
use cubecode::{opcode::Op, CodeCell, Kind, Vm};
|
||||
use cubecoords::{Czyx, CubeHeader};
|
||||
use cubecoords::{CubeHeader, Czyx};
|
||||
use cubestore::{CubeBackend, CubeStore, HashBackend};
|
||||
|
||||
/// `C` axis band where DBT translation rules are stored, kept distinct from the
|
||||
@@ -213,11 +213,7 @@ impl CodeCache {
|
||||
/// target (or whose rule target is `Any`) is replaced by that rule's
|
||||
/// fragment. The rewritten cell is stored at a fresh cache coordinate and
|
||||
/// returned (with its new label). The original store is untouched.
|
||||
pub fn patch(
|
||||
&mut self,
|
||||
original: &CodeCell,
|
||||
rules: &[TranslationRule],
|
||||
) -> CodeCell {
|
||||
pub fn patch(&mut self, original: &CodeCell, rules: &[TranslationRule]) -> CodeCell {
|
||||
let mut patched: Vec<Op> = Vec::with_capacity(original.code.len());
|
||||
for op in &original.code {
|
||||
let class = OpClass::of(op);
|
||||
@@ -237,8 +233,7 @@ impl CodeCache {
|
||||
self.next_x = self.next_x.wrapping_add(1).max(1);
|
||||
let (h, body) = cache_header_for(original, &cubecode::opcode::encode(&patched));
|
||||
self.store.put_record(label, &h, &body);
|
||||
CodeCell::from_record(label, &h, &body)
|
||||
.expect("patched cell is always valid bytecode")
|
||||
CodeCell::from_record(label, &h, &body).expect("patched cell is always valid bytecode")
|
||||
}
|
||||
|
||||
/// Run a patched cache entry in the VM, returning its result.
|
||||
@@ -317,11 +312,7 @@ impl<B: CubeBackend> DbRuntime<B> {
|
||||
|
||||
/// Store a translation rule into the `c220` rule band at a fresh coordinate.
|
||||
/// Returns the coordinate it was written to.
|
||||
pub fn store_rule<B: CubeBackend>(
|
||||
store: &mut CubeStore<B>,
|
||||
rule: &TranslationRule,
|
||||
x: u8,
|
||||
) -> Czyx {
|
||||
pub fn store_rule<B: CubeBackend>(store: &mut CubeStore<B>, rule: &TranslationRule, x: u8) -> Czyx {
|
||||
let label = Czyx::new(C_DBT_RULE, 1, 1, x);
|
||||
let mut h = CubeHeader::new();
|
||||
h.title = Some(rule.name.clone());
|
||||
@@ -363,12 +354,10 @@ mod tests {
|
||||
#[test]
|
||||
fn cache_patches_and_runs() {
|
||||
// Original: Const 3, Const 4, Add, Halt => 3+4 = 7.
|
||||
let orig = sample_cell(Czyx::new(1, 1, 1, 1), vec![
|
||||
Op::Const(3),
|
||||
Op::Const(4),
|
||||
Op::Add,
|
||||
Op::Halt,
|
||||
]);
|
||||
let orig = sample_cell(
|
||||
Czyx::new(1, 1, 1, 1),
|
||||
vec![Op::Const(3), Op::Const(4), Op::Add, Op::Halt],
|
||||
);
|
||||
// Rule: replace `Add` with `Const 2, Mul` => (a)*(2). With a=3,b=4:
|
||||
// naive in-place substitution yields Const3, Const4, Const2, Mul =>
|
||||
// 4*2 = 8. This proves the patched fragment is what runs.
|
||||
@@ -424,6 +413,3 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user