Skip to main content

bloqade_lanes_bytecode/policy/
output.rs

1//! Shared output formatting for `eval-policy` and `trace-policy`.
2
3#![allow(dead_code)]
4
5use serde::Serialize;
6
7#[derive(Serialize)]
8pub struct EvalEnvelope<'a> {
9    pub v: u32,
10    pub kind: &'static str, // "move" or "target"
11    pub policy: &'a str,
12    pub problem: &'a str,
13    pub status: &'a str,
14    pub halt_reason: Option<&'a str>,
15    pub expansions: u64,
16    pub max_depth: u32,
17    pub wall_time_ms: f64,
18}
19
20#[derive(Serialize)]
21pub struct TargetEvalEnvelope<'a> {
22    pub v: u32,
23    pub kind: &'static str, // "target"
24    pub policy: &'a str,
25    pub problem: &'a str,
26    pub ok: bool,
27    pub num_candidates: usize,
28    pub first_candidate_size: usize,
29    pub wall_time_ms: f64,
30}
31
32pub fn print_human_move(env: &EvalEnvelope) {
33    println!("status         {}", env.status);
34    if let Some(r) = env.halt_reason {
35        println!("halt_reason    {r}");
36    }
37    println!("expansions     {}", env.expansions);
38    println!("max_depth      {}", env.max_depth);
39    println!("wall_time      {:.1} ms", env.wall_time_ms);
40}
41
42pub fn print_human_target(env: &TargetEvalEnvelope) {
43    println!("ok                       {}", env.ok);
44    println!("num_candidates           {}", env.num_candidates);
45    println!("first_candidate_size     {}", env.first_candidate_size);
46    println!("wall_time                {:.1} ms", env.wall_time_ms);
47}