docs: STATE-02, the reinforcement count in FLYSIM01 and the import's ids

This commit is contained in:
acamilo 2026-09-29 17:18:10 +00:00
parent f0981825a0
commit 0d41cc2003
2 changed files with 29 additions and 8 deletions

View file

@ -378,14 +378,25 @@ string changes.
the shipped form of AGENT-01's `seed_from_legacy_state` prototype. It builds the `FLYAGT01`
payload a replacement agent stages, using the same encoder the worker's own capture uses
(`legacy_agent::encode_payload`). The accumulator is `{remainder, executedTicks = network.ms,
warmupOffset = 2500}`, and `learning.updates` starts at `plasticity.updates`
(`legacy_reinforcements`, section 13 amendment). The payload also carries the file's
warmupOffset = 2500}`. `learning.updates` is the file's `reinforcements`. A file from before
that member starts at `plasticity.updates` once (`legacy_reinforcements`, section 13
amendment). The checkpoint id is the file's generation (`flysim01-g<N>`). No template worker
is involved. This fixes the four points the AGENT-01 review raised against the prototype:
template dependence, borrowed ids, no compatibility gate (the gate is `restore_from_store`'s,
below), and the count falling back on every round trip. The payload also carries the file's
`framebuffer` as an `inputFrame` chunk, which `State.StageRestore` installs as the next input.
`LegacyFrame::restore` re-projects the framebuffer and does not keep the saved visual drive,
and the two differ on the row 65 yard survey checkpoint (found here; see the section 13
amendment). `world_payload` is ENV-01's `FLYENV01` from
the same world. The source scope of both is `(session, "legacy", emulatorFrame - 1)`.
`legacy_parity` now seeds its workers through this import.
- **`reinforcements`, an optional `FLYSIM01` manifest member.** `LegacyFrame` now counts
reinforcement calls the way the agent worker does: one per commit while the rule is enabled,
zero sums included. `Sim` writes the count, and `LegacyFrame::restore` reads it (falling back
to `plasticity.updates`), so the count survives every round trip in either runtime. Readers
that predate it ignore it. The member changes no behaviour and not the compatibility string,
but it does change legacy checkpoint bytes: a file written from now on is the old layout plus
this member.
- **Store policy.** `LegacyCheckpointer` follows `Sim` at each call site:
- one generation counter over both stores, starting above the highest either has allocated;
- a hot copy every `hot_seconds`, and a durable one every `checkpoint_seconds`, which also
@ -401,6 +412,8 @@ string changes.
on *any* refusal, including a participant's `State.StageRestore`. It reports `Fresh` when no
candidate exists, and `Refused` when every candidate failed. In that case the runtime must exit
as `Sim::restore_or_warm_up` does.
- **The agent worker** now refuses a conflicting stage (a restore already staged, or a token
already activated) before it builds a replacement network (AGENT-01 review).
- **Sugar journal** (the FND-01 review note, before SHADOW-01). A per-process boot header
records the runtime, start frame, brain ms, restore origin, generation and compatibility. The
journal rotates at 4 MiB and keeps three files; every rotated-in file starts with a
@ -430,10 +443,12 @@ coordinator (TASK-01); this slice ships the pieces and proves them on the worker
into the real environment worker and captured again. The agent goes through the imported
`FLYAGT01` payload and the task through the Pokémon adapter and the ratchet. Every export is
byte-identical to the legacy loop's own restore outcome of the same file, checkpointed at once.
Six exports are byte-identical to the file itself. The other twelve differ in named fields
only. Eleven were written by adapters v5 or v6, and the adapter's import migrates their
`reward` state. One, a survey checkpoint, also has a joypad byte in the emulator state that
its own `buttons` field does not match; both runtimes apply `buttons` on restore.
Against the files themselves, every export differs only in named fields. All 18 gain
`reinforcements`, because the files predate it. Twelve written by adapters v5 or v6 also
differ in `reward`, which the adapter's import migrates. One survey checkpoint also differs in
a joypad byte of its emulator state that its own `buttons` field does not match; both runtimes
apply `buttons` on restore. Before the counter was added, six of the 18 were byte-identical to
the file.
- *Restore then continue, toy connectome, raw mode* (every ROM run). The legacy frame writes a
checkpoint. The session runtime selects it from a store whose hot copy is torn. The legacy
loop and the session runtime then each run 600 frames from it. World: 1,800 values identical

View file

@ -544,7 +544,7 @@ current `flysim` reads, under the unchanged compatibility string. The deploy gat
checkpoint may be written beside it, but it is not what a restore selects until RETIRE-01
says so.
**Amendment, 2026-09-29 (STATE-02).** Five readings of this section, fixed by building it
**Amendment, 2026-09-29 (STATE-02).** Six readings of this section, fixed by building it
([implementation guide](implementation.md) STATE-02):
- *"A FLYSIM01 envelope that the current `flysim` reads" means the same bytes.* The session
@ -554,7 +554,8 @@ says so.
owners of the fields are: the agent (the seven agent chunks, the remainder), the environment
(`emulator`, `framebuffer`, `emulatorFrame`, `buttons`, `romHash`, and slot `best` as
`ratchetGame` and `ratchetFrame`), the task (`reward`, `ratchet`) and the host (`generation`,
`wallMs`, `compatibility`, `speed`, `rankSinceMs`, `lastEventId`).
`wallMs`, `compatibility`, `speed`, `rankSinceMs`, `lastEventId`); the agent's reinforcement
count, `reinforcements`, is new (below).
- *The milestone archive is per process, as in the legacy loop.* A rank climb is archived when
the rank is above every rank *this process* has archived. After a restart, the first climb
rewrites `milestone-<rank>` even if an older process had archived that rank. That is the
@ -573,6 +574,11 @@ says so.
the agent payload (chunk `inputFrame`), and `State.StageRestore` installs it after the import,
as `LegacyFrame::restore` does. A worker's own capture carries no such chunk and restores
exactly.
- *`learning.updates` is carried in `FLYSIM01`.* This corrects section 13's *Learning telemetry*
amendment, which started every import at `plasticity.updates` and so dropped the count on
every round trip. Both runtimes count reinforcement calls the same way and write the count
as the optional manifest member `reinforcements`. A file without it (every file from before
2026-09-29) starts at `plasticity.updates` once.
- *The sugar journal is the shadow run's input record.* It gets a per-process boot header, is
rotated at 4 MiB with three kept files, and `fly-reset-to-milestone` clears it
(`flysim-store::journal`). It is not a checkpoint and nothing restores from it.