fly-session: LegacyGameboyEnvironment, the ENV-01 Game Boy environment worker

The emulator half of flysim's LegacyFrame behind the environment methods:
the one-frame setup scaffold, one joypad batch per Advance, f32le audio
(sample/255, unfiltered), the per-boundary memory image behind the MEM-01
seam (read between an export and an import, because emulator_read_mem syncs
OAM/VRAM/timer/STAT/LY), gameboy-slots-v1 SaveSlot/RestoreSlot, capture and
staged restore, and the world's half of FLYSIM01. SaveSlot, RestoreSlot and
Agent.Rollback are step mutations under the ipc-v1 operation key. The parity
harness (toy cartridge, direct reference in LegacyFrame order, bus driver,
FLY_TRACE replay) is in legacy_env_parity.
This commit is contained in:
acamilo 2026-09-29 13:16:22 +00:00
parent 9f2345dba7
commit e28b0d8999
6 changed files with 3187 additions and 0 deletions

View file

@ -440,6 +440,8 @@ name = "fly-session"
version = "0.1.1" version = "0.1.1"
dependencies = [ dependencies = [
"fly-session-types", "fly-session-types",
"flybrain-core",
"flybrain-gb",
"flybus", "flybus",
"serde_json", "serde_json",
"tempfile", "tempfile",

View file

@ -23,6 +23,11 @@ path = "src/bin/fly-session.rs"
# Everything else this crate needs is std or Tokio. # Everything else this crate needs is std or Tokio.
fly-session-types = { path = "../fly-session-types" } fly-session-types = { path = "../fly-session-types" }
flybus = { path = "../flybus" } flybus = { path = "../flybus" }
# ENV-01: the legacy Game Boy environment worker drives the binjgb emulator through
# flybrain-gb's safe wrapper, and flybrain-core's frozen envelope layout reads and writes the
# world's half of a FLYSIM01 checkpoint. (AGENT-01 adds flybrain-core for the agent as well.)
flybrain-core = { path = "../flybrain-core" }
flybrain-gb = { path = "../flybrain-gb" }
serde_json = { workspace = true } serde_json = { workspace = true }
# `rt-multi-thread` is not only for the tests: a worker process and a dedicated-thread # `rt-multi-thread` is not only for the tests: a worker process and a dedicated-thread

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,8 @@ pub mod dedup;
pub mod environment; pub mod environment;
pub mod harness; pub mod harness;
pub mod launcher; pub mod launcher;
pub mod legacy_env;
pub mod legacy_env_parity;
pub mod measure; pub mod measure;
pub mod media; pub mod media;
pub mod metrics; pub mod metrics;

View file

@ -606,6 +606,13 @@ async fn execute<E: WorkerEndpoint>(
fn classify_default(method: &str) -> Option<OpClass> { fn classify_default(method: &str) -> Option<OpClass> {
match method { match method {
"Agent.Prepare" | "Agent.Commit" | "Environment.Advance" => Some(OpClass::StepMutation), "Agent.Prepare" | "Agent.Commit" | "Environment.Advance" => Some(OpClass::StepMutation),
// The extension methods of `workers-v1` section 7 are mutations under the step operation
// key (`legacy-gameboy-v1` section 11): `SaveSlot` at `(e, k)`, `RestoreSlot` and
// `Agent.Rollback` at the new epoch `(e', k)`. A lost reply replays from the same cache
// rather than rolling back twice.
"Agent.Rollback" | "Environment.SaveSlot" | "Environment.RestoreSlot" => {
Some(OpClass::StepMutation)
}
// `ipc-v1` section 5 retains lifecycle *and capture* replies until // `ipc-v1` section 5 retains lifecycle *and capture* replies until
// `Worker.Acknowledge`. The restore methods join them: their replies carry a // `Worker.Acknowledge`. The restore methods join them: their replies carry a
// once-only token and, for an environment, the restored observation's artifact, and a // once-only token and, for an environment, the restored observation's artifact, and a