flybrain/services/flysim/crates/fly-legacy-session/examples/seed_store.rs
acamilo 98f29e47c6 fly-legacy-session: flysim-session, the session runtime as the live service
The service host (service.rs, bin flysim-session) runs the legacy composition
behind flysim::serve with flysim's own Config and keeps Sim's order and
bookkeeping: TASK-01's boot (legacy candidate order and gate), boot events,
chat sidecar, sugar journal (runtime fly-session), startup/shutdown durable
saves, queued hot/durable/milestone/after-rollback saves on the wall clock,
macro/reward/milestone/recovery/sugar/checkpoint events, the recovering
status, flysim's Pacer, sd_notify ready/watchdog, and the 30 Hz feed built
by flysim's feed_* functions from the committed view, the step's audio
through the legacy DC blocker, the OR of the commits' spike bitsets, the
task's adapter/ratchet/macro layer and the agent's Legacy.FeedStatus.

Task: FeedRecord (executed/rewards/abandoned/rollback events), the applied
mask (0 after a rollback, the checkpoint's after an import), inspect().
Composition: boot_unsaved, save_queued, the event-log watermark setter.

Tests: service_parity (legacy Sim vs session host behind flysim's router,
one scripted request set, every header/attachment/response/event/journal
line and the final checkpoint compared), journal_replay (a killed session
run's journal replayed from the seed in the legacy loop onto its last hot
checkpoint), unit tests for the audio path and the feed status;
examples/seed_store.
2026-09-29 20:31:13 +00:00

26 lines
1.1 KiB
Rust

//! Seed a FLYSIM01 store with one checkpoint file, as its own generation (a soak or rehearsal
//! starting from a pulled stream checkpoint; SERVE-01).
//!
//! ```sh
//! cargo run --release -p fly-legacy-session --example seed_store -- <file.checkpoint> <durable-dir>
//! ```
fn main() {
let args: Vec<String> = std::env::args().collect();
let [_, file, dir] = args.as_slice() else {
eprintln!("usage: seed_store <file.checkpoint> <durable-dir>");
std::process::exit(2);
};
let bytes = std::fs::read(file).expect("reading the checkpoint");
let checkpoint = flysim::store::decode(&bytes).expect("a FLYSIM01 checkpoint");
let generation = checkpoint.runtime.generation;
let store = flysim::store::Store::new(std::path::Path::new(dir), 2);
store.create().expect("creating the store");
store
.commit(generation, &bytes, None)
.expect("committing the checkpoint");
println!(
"seeded {dir} with generation {generation} (frame {}, compatibility {})",
checkpoint.runtime.emulator_frame, checkpoint.runtime.compatibility
);
}