Merge feat/agent-legacy-worker (unreviewed, integration base)
This commit is contained in:
commit
6e090b0be5
28 changed files with 6223 additions and 5 deletions
|
|
@ -176,6 +176,35 @@ window and last location as private readout state; report `stimulusRemainingMs`;
|
||||||
legacy rate-role names (`command_0`, `macro_*`, which are not `Id`s) to `AgentGraph.rateRoles`,
|
legacy rate-role names (`command_0`, `macro_*`, which are not `Id`s) to `AgentGraph.rateRoles`,
|
||||||
which that contract leaves open.
|
which that contract leaves open.
|
||||||
|
|
||||||
|
**2026-09-23 (AGENT-01 built, `feat/agent-legacy-worker`).** `LegacyAgentWorker`
|
||||||
|
(`fly-session/src/legacy_agent.rs`) serves the legacy profile under the launcher in all three
|
||||||
|
execution modes (`legacy-agent` subcommand). Its parity harness (`legacy_parity.rs`) drives
|
||||||
|
`NeuralAgent` directly in `Sim::step_frame` order from recorded inputs. On the committed toy
|
||||||
|
connectome, the worker's records match that reference exactly in every mode, including a
|
||||||
|
rollback and a restore, and are pinned as goldens. A gated FAFB run
|
||||||
|
(`FLY_AGENT01_FAFB=1`) shows the same on `gameboy-legacy-fafb-v783-v1`. The rate-role mapping
|
||||||
|
turned out to be the identity: the legacy names are already `Id`s. It is recorded in
|
||||||
|
[legacy-gameboy-v1](legacy-gameboy-v1.md) section 13, with the other agent-adapter choices. The
|
||||||
|
harness's `ReferenceSource` is the seam for FND-01's `FLY_TRACE`.
|
||||||
|
|
||||||
|
**2026-09-29 (AGENT-01 rebased onto v0.6.5 and checked against FND-01's trace).** The rebase onto
|
||||||
|
main had no conflicts. Main changed nothing the worker reads except the adapter id in the
|
||||||
|
fixtures (v7). The toy goldens and the FAFB reference digest are unchanged. `FLY_TRACE` carries
|
||||||
|
the frames only as digests and not the `{boot, bound, location}` context, so it checks a worker
|
||||||
|
and cannot drive one. `legacy_parity::read_frame_trace` and `check_against_trace` hold a run's
|
||||||
|
records to it: ticks, clock, exact remainder, rates digest, spike-set digest and decision. The
|
||||||
|
script is checked too: the same sugar, frames, reward events and rollback.
|
||||||
|
`flysim/tests/agent_trace_parity.rs` is the host. It runs `LegacyFrame` on the ROM with the trace
|
||||||
|
on, records the missing inputs and checks the worker (in-process, thread and process) and the
|
||||||
|
direct reference against the trace:
|
||||||
|
|
||||||
|
- the toy connectome in raw mode from power-on, for every ROM run;
|
||||||
|
- `gameboy-legacy-fafb-v783-v1` in macros mode from stream checkpoints (`FLY_AGENT01_FAFB=1`),
|
||||||
|
with sugar and a ratchet rollback, the worker seeded from the checkpoint's agent state.
|
||||||
|
|
||||||
|
Both are identical. Found on the way: a `FLYSIM01` import must start `learning.updates` at the
|
||||||
|
legacy `plasticity.updates` (legacy-gameboy-v1 section 13, amendment of 2026-09-29).
|
||||||
|
|
||||||
**Implement:** adapter over existing LIF, plasticity, retina and fixed readout primitives;
|
**Implement:** adapter over existing LIF, plasticity, retina and fixed readout primitives;
|
||||||
reference-first composition/goldens; independently seeded agent state and shared immutable data.
|
reference-first composition/goldens; independently seeded agent state and shared immutable data.
|
||||||
Avoid using the old whole-frame `tick` wrapper if it changes the specified phase ordering.
|
Avoid using the old whole-frame `tick` wrapper if it changes the specified phase ordering.
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,8 @@ interface GameboyReadoutContext {
|
||||||
```
|
```
|
||||||
|
|
||||||
`ChannelName` is `^[a-z][a-z0-9_]{0,63}$`. Decoder channel and rate-role names carry `_`, so
|
`ChannelName` is `^[a-z][a-z0-9_]{0,63}$`. Decoder channel and rate-role names carry `_`, so
|
||||||
they are not `Id`s. The context is what the task hands the decoder with each Prepare (the
|
they are not `Id`s (corrected 2026-09-23, AGENT-01: they are; see the section 13 amendment).
|
||||||
|
The context is what the task hands the decoder with each Prepare (the
|
||||||
`initialDecisionContext`, then every `nextDecisionContext`). `bound` is an ordered subset of the
|
`initialDecisionContext`, then every `nextDecisionContext`). `bound` is an ordered subset of the
|
||||||
composition's `macroChannels`.
|
composition's `macroChannels`.
|
||||||
|
|
||||||
|
|
@ -351,6 +352,79 @@ stale files.
|
||||||
valid `Id`s, while `AgentGraph.rateRoles` and `AgentTelemetry.rates[].roleId` are `Id`s. The
|
valid `Id`s, while `AgentGraph.rateRoles` and `AgentTelemetry.rates[].roleId` are `Id`s. The
|
||||||
mapping belongs to the agent adapter. This contract does not choose it.
|
mapping belongs to the agent adapter. This contract does not choose it.
|
||||||
|
|
||||||
|
**Amendment, 2026-09-23 (AGENT-01): the rate-role mapping `legacy-rate-role-id-v1`.** The
|
||||||
|
premise above is wrong. The session `Id` grammar is `^[a-z0-9][a-z0-9._-]{0,63}$`
|
||||||
|
([session RPC](ipc-v1.md) section 1, `flybus::wire::is_id`, `isId` in `@flybrain/session-types`),
|
||||||
|
and it admits `_`. Every role `data/fafb-v783` declares, including the 31 `macro_*` populations
|
||||||
|
merged after the fingerprint, and every role the kernel tracks, is already an `Id`; so is every
|
||||||
|
`ChannelName`, whose grammar is a subset. The mapping is therefore the identity:
|
||||||
|
|
||||||
|
- a legacy rate-role name `n` is published as `roleId = n` when `n` is an `Id`, and a `roleId`
|
||||||
|
names the rate role of the same spelling. The mapping is reversible by construction;
|
||||||
|
- a name that is not an `Id` has no `roleId`. The agent refuses to initialize over a dataset
|
||||||
|
that tracks one (`INCOMPATIBLE_STATE`), rather than invent an encoding no consumer could read
|
||||||
|
back. No shipped dataset has one;
|
||||||
|
- the published list keeps the kernel's tracked-role order and its bounds: at most 64
|
||||||
|
(`MAX_RATE_ROLES`, the kernel's role bitmask) and unique. On `fafb-v783` it is 45 roles.
|
||||||
|
|
||||||
|
`gameboy::rate_role_id`, `rate_role_name` and `rate_role_ids` in `fly-session-types`, and
|
||||||
|
`rateRoleId`, `rateRoleName` and `rateRoleIds` in `@flybrain/session-types`, implement it.
|
||||||
|
`fixtures/gameboy-rate-roles.json` holds both languages to the same accepted and refused names and
|
||||||
|
records the FAFB tracked list, which `fly-session`'s gated FAFB test recomputes from the
|
||||||
|
committed dataset. The mapping changes no schema, digest or fixture digest.
|
||||||
|
|
||||||
|
**Amendment, 2026-09-23 (AGENT-01): what the legacy agent reports and captures.** These are
|
||||||
|
agent-adapter choices that the sections above leave open. `LegacyAgentWorker`
|
||||||
|
(`fly-session/src/legacy_agent.rs`) implements them:
|
||||||
|
|
||||||
|
- *Seed.* The kernel version `lif-1ms-f64-v2` hashes the LIF seed. Every seed except the legacy
|
||||||
|
default `22222` gives a different kernel version, so the profile pins the seed.
|
||||||
|
`Agent.Initialize` refuses any other seed (`INCOMPATIBLE_STATE`) before it builds a model. The
|
||||||
|
coordinator of this composition passes `22222`. It does not use a seed derived under
|
||||||
|
[seed-derivation-v1](seed-derivation-v1.md).
|
||||||
|
- *Learning telemetry.* `AgentTelemetry.learning` requires `changed <= updates`. The legacy
|
||||||
|
counters mean something else, so they map as follows. `updates` is the number of reinforcement
|
||||||
|
calls the agent has applied: one per commit while the rule is enabled, zero sums included.
|
||||||
|
`changed` is the legacy `plasticity.updates`: the reinforcements that moved at least one gain.
|
||||||
|
`signal` is `plasticity.signal`. The legacy per-synapse count (`LearningStats.changed`, the
|
||||||
|
gains away from 1.0) is not carried. It can still be read from a captured state.
|
||||||
|
`stimulusRemainingMs` is the network's `reward_remaining` after the operation.
|
||||||
|
*Amended 2026-09-29 (AGENT-01 rebase):* `FLYSIM01` records `plasticity.updates` but not the
|
||||||
|
reinforcement calls. An agent imported from a `FLYSIM01` agent state therefore starts
|
||||||
|
`updates` at that state's `plasticity.updates`, which is a lower bound on the calls made. Starting
|
||||||
|
it at zero makes the first telemetry violate `changed <= updates`: on the live fly `changed` is
|
||||||
|
in the thousands. `legacy_parity::legacy_reinforcements` is the rule. The import that ENV-01
|
||||||
|
or STATE-01 ships must apply it.
|
||||||
|
- *Spikes.* Each `Agent.Commit` reply carries the attachment `telemetry.spikes`, with content type
|
||||||
|
`application/x-fly-spike-bitset`. It uses the legacy feed's layout: bit *i* is neuron *i*,
|
||||||
|
`ceil(neurons/8)` bytes. It covers the transition's ticks: a neuron is set when its last spike
|
||||||
|
is at or after the brain time before that transition's Prepare ticked. The mapping of bit
|
||||||
|
*i* is the graph's `indexDigest`.
|
||||||
|
- *Graph.* `datasetDigest` is the SHA-256 of the schema-1 fingerprint string. `indexDigest` is the
|
||||||
|
SHA-256 of `fly-session/legacy-agent-index-v1`, the fingerprint, the neuron count and every
|
||||||
|
`macro_*` population's members. The macro populations are the profile's declared
|
||||||
|
`macro-roles-outside-fingerprint` exception. Two datasets that relabel them differently
|
||||||
|
therefore get the same fingerprint and different index digests.
|
||||||
|
- *Initialize.* The readout transient starts as it does in a fresh legacy process: no held
|
||||||
|
channel, no last location, and a blocked window from 0 ms. `initialDecisionContext.location`
|
||||||
|
is **not** taken as the last location. The legacy loop reads a location only at the end of a
|
||||||
|
frame, so the window first restarts on it at the first commit, as it does in the legacy loop.
|
||||||
|
- *Capture.* The `State.Capture` payload is a `flybrain-core` checkpoint envelope with magic
|
||||||
|
`FLYAGT01`. Its manifest and chunks are exactly `agent_to_chunks`, with the frame remainder
|
||||||
|
taken from the session accumulator, as `Sim::checkpoint` does. It adds one `session` member: the
|
||||||
|
accumulator, the context, the profile, the seed, the reinforcement count, the macro channels
|
||||||
|
and the decoder configuration digest. It does not carry the readout transient (section 14). It
|
||||||
|
is not FLYSIM01. Writing a FLYSIM01 export from it and from the environment's state is still
|
||||||
|
STATE-01/ENV-01 work (section 16).
|
||||||
|
- *Restore.* `State.StageRestore` builds a replacement network over the same dataset, imports
|
||||||
|
the state and refuses any mismatch between the state's clock and the accumulator.
|
||||||
|
`ActivateRestore` then installs the state and resets the readout transient, as a fresh legacy
|
||||||
|
process does. The visual drive is the restored `visualDrive` chunk. Legacy `try_restore`
|
||||||
|
instead re-projects the saved framebuffer, and the two are the same values (the parity
|
||||||
|
harness compares the full state after a restore).
|
||||||
|
- *Decision.* `macro` is the first channel in the context's `bound` order that the decode holds.
|
||||||
|
This is the channel the legacy macro layer's `asked` would start.
|
||||||
|
|
||||||
## 14. Restore `legacy-transient-reset`
|
## 14. Restore `legacy-transient-reset`
|
||||||
|
|
||||||
The legacy composition declares that a restore (a FLYSIM01 load today, and any group restore
|
The legacy composition declares that a restore (a FLYSIM01 load today, and any group restore
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import { digestOf, fail } from './canonical';
|
||||||
import { readRational, readSchemaRef } from './common';
|
import { readRational, readSchemaRef } from './common';
|
||||||
import { Reader, readArtifactRef, requireUnique, u64 } from './reader';
|
import { Reader, readArtifactRef, requireUnique, u64 } from './reader';
|
||||||
import type { ArtifactRef, Digest, Id, RationalNs, SchemaRef, TypedValue } from './scalar';
|
import type { ArtifactRef, Digest, Id, RationalNs, SchemaRef, TypedValue } from './scalar';
|
||||||
import { isDigest } from './scalar';
|
import { isDigest, isId } from './scalar';
|
||||||
import { type AssetRef, readAssetRef } from './workers';
|
import { type AssetRef, MAX_RATE_ROLES, readAssetRef } from './workers';
|
||||||
import { MAX_SLOTS, ROLLBACK_POLICY, SLOTS_CAPABILITY } from './extensions';
|
import { MAX_SLOTS, ROLLBACK_POLICY, SLOTS_CAPABILITY } from './extensions';
|
||||||
|
|
||||||
export const PROFILE_ID = 'gameboy-legacy-fafb-v783-v1';
|
export const PROFILE_ID = 'gameboy-legacy-fafb-v783-v1';
|
||||||
|
|
@ -93,7 +93,10 @@ export const PAYLOAD_SCHEMAS: readonly SchemaRef[] = [
|
||||||
/** The legacy profile document's AssetRef digest: SHA-256 of its canonical JSON. */
|
/** The legacy profile document's AssetRef digest: SHA-256 of its canonical JSON. */
|
||||||
export const PROFILE_DIGEST = '41e5d1ac62ab23f1b2d7252d52faac08b269c85e6b4c9ed7a370c74032c60878';
|
export const PROFILE_DIGEST = '41e5d1ac62ab23f1b2d7252d52faac08b269c85e6b4c9ed7a370c74032c60878';
|
||||||
|
|
||||||
/** `ChannelName`: a decoder channel or rate-role name. Not an Id: legacy names carry '_'. */
|
/**
|
||||||
|
* `ChannelName`: a decoder channel or rate-role name, `^[a-z][a-z0-9_]{0,63}$`. A subset of the
|
||||||
|
* `Id` grammar (which admits '_'); see `rateRoleId` below (amendment 2026-09-23).
|
||||||
|
*/
|
||||||
export function isChannelName(value: unknown): value is string {
|
export function isChannelName(value: unknown): value is string {
|
||||||
return typeof value === 'string' && /^[a-z][a-z0-9_]{0,63}$/.test(value);
|
return typeof value === 'string' && /^[a-z][a-z0-9_]{0,63}$/.test(value);
|
||||||
}
|
}
|
||||||
|
|
@ -558,3 +561,40 @@ export function decoderConfigForm(config: DecoderConfigLike): unknown {
|
||||||
export function decoderConfigDigest(config: DecoderConfigLike): Digest {
|
export function decoderConfigDigest(config: DecoderConfigLike): Digest {
|
||||||
return digestOf(decoderConfigForm(config));
|
return digestOf(decoderConfigForm(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rate roles: legacy-rate-role-id-v1 (amendment 2026-09-23, AGENT-01) ----------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mapping from a legacy rate-role name to `AgentGraph.rateRoles` / `rates[].roleId`.
|
||||||
|
*
|
||||||
|
* The contract left it open on the premise that `command_0`, `macro_go_item` and the rest are
|
||||||
|
* not `Id`s; they are, because the `Id` grammar `^[a-z0-9][a-z0-9._-]{0,63}$` admits '_'. So the
|
||||||
|
* mapping is the identity on the `Id` grammar and a name outside it has no roleId: the agent
|
||||||
|
* refuses such a dataset. `fly-session-types/src/gameboy.rs` is the twin and
|
||||||
|
* `fixtures/gameboy-rate-roles.json` holds both to it.
|
||||||
|
*/
|
||||||
|
export const RATE_ROLE_MAPPING = 'legacy-rate-role-id-v1';
|
||||||
|
|
||||||
|
/** The roleId of a legacy rate-role name: the name itself, when it is an Id. */
|
||||||
|
export function rateRoleId(name: string): Id {
|
||||||
|
if (!isId(name)) {
|
||||||
|
fail(`${RATE_ROLE_MAPPING}: rate role ${JSON.stringify(name)} is not an Id and has no roleId`);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The legacy rate-role name a roleId stands for: the inverse of `rateRoleId`. */
|
||||||
|
export function rateRoleName(roleId: string): string {
|
||||||
|
if (!isId(roleId)) fail(`${RATE_ROLE_MAPPING}: ${JSON.stringify(roleId)} is not a roleId`);
|
||||||
|
return roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Maps a tracked-role list in order, holding it to `AgentGraph.rateRoles`' bounds. */
|
||||||
|
export function rateRoleIds(names: readonly string[]): Id[] {
|
||||||
|
const ids = names.map(rateRoleId);
|
||||||
|
if (ids.length > MAX_RATE_ROLES) {
|
||||||
|
fail(`${RATE_ROLE_MAPPING}: ${ids.length} tracked rate roles; AgentGraph.rateRoles holds at most ${MAX_RATE_ROLES}`);
|
||||||
|
}
|
||||||
|
requireUnique(ids, 'rateRoles');
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,3 +174,24 @@ test('the decoderConfigDigest vectors are what the TypeScript oracle preset comp
|
||||||
assert.equal(example.decoderConfigDigest, cases[1]!.digest);
|
assert.equal(example.decoderConfigDigest, cases[1]!.digest);
|
||||||
assert.deepEqual(example.executor.macroChannels, cases[1]!.macroChannels);
|
assert.deepEqual(example.executor.macroChannels, cases[1]!.macroChannels);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('legacy-rate-role-id-v1 is the identity on the Id grammar and refuses the rest', () => {
|
||||||
|
const file = fixtures.load('gameboy-rate-roles.json') as Record<string, any>;
|
||||||
|
assert.equal(file.mapping, gameboy.RATE_ROLE_MAPPING);
|
||||||
|
assert.ok(file.accepted.length > 0);
|
||||||
|
for (const { name, roleId } of file.accepted as { name: string; roleId: string }[]) {
|
||||||
|
assert.equal(gameboy.rateRoleId(name), roleId, name);
|
||||||
|
assert.equal(gameboy.rateRoleName(roleId), name, `${roleId} maps back`);
|
||||||
|
}
|
||||||
|
for (const { name } of file.refused as { name: string }[]) {
|
||||||
|
assert.throws(() => gameboy.rateRoleId(name), `${JSON.stringify(name)} has no roleId`);
|
||||||
|
assert.throws(() => gameboy.rateRoleName(name));
|
||||||
|
}
|
||||||
|
const tracked = file.fafbTrackedRoles as string[];
|
||||||
|
assert.deepEqual(gameboy.rateRoleIds(tracked), tracked);
|
||||||
|
for (const role of tracked.filter((r) => r.startsWith('macro_'))) {
|
||||||
|
assert.ok(gameboy.isChannelName(role));
|
||||||
|
}
|
||||||
|
assert.throws(() => gameboy.rateRoleIds(Array.from({ length: 65 }, (_, i) => `role_${i}`)));
|
||||||
|
assert.throws(() => gameboy.rateRoleIds(['command_0', 'command_0']));
|
||||||
|
});
|
||||||
|
|
|
||||||
3
services/flysim/Cargo.lock
generated
3
services/flysim/Cargo.lock
generated
|
|
@ -439,7 +439,9 @@ dependencies = [
|
||||||
name = "fly-session"
|
name = "fly-session"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"flate2",
|
||||||
"fly-session-types",
|
"fly-session-types",
|
||||||
|
"flybrain-core",
|
||||||
"flybus",
|
"flybus",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
|
@ -500,6 +502,7 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
"clap",
|
"clap",
|
||||||
|
"fly-session",
|
||||||
"fly-session-types",
|
"fly-session-types",
|
||||||
"flybrain-core",
|
"flybrain-core",
|
||||||
"flybrain-gb",
|
"flybrain-gb",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,332 @@
|
||||||
|
{
|
||||||
|
"description": "legacy-rate-role-id-v1 (legacy-gameboy-v1 section 13, amendment 2026-09-23, AGENT-01): the roleId of a legacy rate-role name is the name itself when it matches the session Id grammar, and a name outside it has no roleId. fafbTrackedRoles is the rate-role list the kernel tracks on data/fafb-v783 in network order (AgentGraph.rateRoles order); fly-session's gated test recomputes it from the committed dataset. Both languages must map every accepted name to itself and back, and refuse every refused name.",
|
||||||
|
"mapping": "legacy-rate-role-id-v1",
|
||||||
|
"idPattern": "^[a-z0-9][a-z0-9._-]{0,63}$",
|
||||||
|
"fafbTrackedRoles": [
|
||||||
|
"backward",
|
||||||
|
"command_0",
|
||||||
|
"command_1",
|
||||||
|
"command_2",
|
||||||
|
"command_3",
|
||||||
|
"command_4",
|
||||||
|
"command_5",
|
||||||
|
"command_6",
|
||||||
|
"command_7",
|
||||||
|
"forward",
|
||||||
|
"proboscis",
|
||||||
|
"reward_pam",
|
||||||
|
"steer_left",
|
||||||
|
"steer_right",
|
||||||
|
"macro_go_objective",
|
||||||
|
"macro_go_out",
|
||||||
|
"macro_go_warp",
|
||||||
|
"macro_go_route",
|
||||||
|
"macro_go_item",
|
||||||
|
"macro_go_npc",
|
||||||
|
"macro_go_frontier",
|
||||||
|
"macro_go_shop",
|
||||||
|
"macro_go_heal",
|
||||||
|
"macro_talk",
|
||||||
|
"macro_menu",
|
||||||
|
"macro_next",
|
||||||
|
"macro_yes",
|
||||||
|
"macro_no",
|
||||||
|
"macro_close",
|
||||||
|
"macro_confirm",
|
||||||
|
"macro_back",
|
||||||
|
"macro_move_1",
|
||||||
|
"macro_move_2",
|
||||||
|
"macro_move_3",
|
||||||
|
"macro_move_4",
|
||||||
|
"macro_switch",
|
||||||
|
"macro_item",
|
||||||
|
"macro_throw_ball",
|
||||||
|
"macro_run",
|
||||||
|
"macro_buy_potion",
|
||||||
|
"macro_buy_ball",
|
||||||
|
"macro_buy_antidote",
|
||||||
|
"macro_buy_repel",
|
||||||
|
"macro_heal",
|
||||||
|
"macro_leave"
|
||||||
|
],
|
||||||
|
"accepted": [
|
||||||
|
{
|
||||||
|
"name": "backward",
|
||||||
|
"roleId": "backward"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_0",
|
||||||
|
"roleId": "command_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_1",
|
||||||
|
"roleId": "command_1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_2",
|
||||||
|
"roleId": "command_2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_3",
|
||||||
|
"roleId": "command_3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_4",
|
||||||
|
"roleId": "command_4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_5",
|
||||||
|
"roleId": "command_5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_6",
|
||||||
|
"roleId": "command_6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "command_7",
|
||||||
|
"roleId": "command_7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "forward",
|
||||||
|
"roleId": "forward"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "proboscis",
|
||||||
|
"roleId": "proboscis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "reward_pam",
|
||||||
|
"roleId": "reward_pam"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "steer_left",
|
||||||
|
"roleId": "steer_left"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "steer_right",
|
||||||
|
"roleId": "steer_right"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_objective",
|
||||||
|
"roleId": "macro_go_objective"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_out",
|
||||||
|
"roleId": "macro_go_out"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_warp",
|
||||||
|
"roleId": "macro_go_warp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_route",
|
||||||
|
"roleId": "macro_go_route"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_item",
|
||||||
|
"roleId": "macro_go_item"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_npc",
|
||||||
|
"roleId": "macro_go_npc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_frontier",
|
||||||
|
"roleId": "macro_go_frontier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_shop",
|
||||||
|
"roleId": "macro_go_shop"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_go_heal",
|
||||||
|
"roleId": "macro_go_heal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_talk",
|
||||||
|
"roleId": "macro_talk"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_menu",
|
||||||
|
"roleId": "macro_menu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_next",
|
||||||
|
"roleId": "macro_next"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_yes",
|
||||||
|
"roleId": "macro_yes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_no",
|
||||||
|
"roleId": "macro_no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_close",
|
||||||
|
"roleId": "macro_close"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_confirm",
|
||||||
|
"roleId": "macro_confirm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_back",
|
||||||
|
"roleId": "macro_back"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_move_1",
|
||||||
|
"roleId": "macro_move_1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_move_2",
|
||||||
|
"roleId": "macro_move_2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_move_3",
|
||||||
|
"roleId": "macro_move_3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_move_4",
|
||||||
|
"roleId": "macro_move_4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_switch",
|
||||||
|
"roleId": "macro_switch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_item",
|
||||||
|
"roleId": "macro_item"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_throw_ball",
|
||||||
|
"roleId": "macro_throw_ball"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_run",
|
||||||
|
"roleId": "macro_run"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_buy_potion",
|
||||||
|
"roleId": "macro_buy_potion"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_buy_ball",
|
||||||
|
"roleId": "macro_buy_ball"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_buy_antidote",
|
||||||
|
"roleId": "macro_buy_antidote"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_buy_repel",
|
||||||
|
"roleId": "macro_buy_repel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_heal",
|
||||||
|
"roleId": "macro_heal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_leave",
|
||||||
|
"roleId": "macro_leave"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "up",
|
||||||
|
"roleId": "up"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "down",
|
||||||
|
"roleId": "down"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "left",
|
||||||
|
"roleId": "left"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "right",
|
||||||
|
"roleId": "right"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"roleId": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"roleId": "b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "start",
|
||||||
|
"roleId": "start"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "select",
|
||||||
|
"roleId": "select"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kenyon",
|
||||||
|
"roleId": "kenyon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mbon",
|
||||||
|
"roleId": "mbon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "visual_l1",
|
||||||
|
"roleId": "visual_l1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "descending",
|
||||||
|
"roleId": "descending"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "motor",
|
||||||
|
"roleId": "motor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sensory",
|
||||||
|
"roleId": "sensory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "7th.role-x",
|
||||||
|
"roleId": "7th.role-x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "0",
|
||||||
|
"roleId": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
|
||||||
|
"roleId": "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"refused": [
|
||||||
|
{
|
||||||
|
"name": "Command_0",
|
||||||
|
"why": "uppercase"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_command",
|
||||||
|
"why": "leading underscore"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "-x",
|
||||||
|
"why": "leading hyphen"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"why": "empty"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "steer left",
|
||||||
|
"why": "space"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macro_é",
|
||||||
|
"why": "non-ASCII"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
|
||||||
|
"why": "65 characters"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -413,6 +413,60 @@ pub fn extension_set_digest() -> String {
|
||||||
canonical::digest_of(&extension_set()).expect("canonicalizable")
|
canonical::digest_of(&extension_set()).expect("canonicalizable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// Rate roles: `legacy-rate-role-id-v1` (amendment 2026-09-23, AGENT-01)
|
||||||
|
|
||||||
|
/// The name of the mapping from a legacy rate-role name to `AgentGraph.rateRoles` /
|
||||||
|
/// `AgentTelemetry.rates[].roleId`.
|
||||||
|
///
|
||||||
|
/// `legacy-gameboy-v1` section 13 left this to AGENT-01 on the premise that the legacy names
|
||||||
|
/// (`command_0`, `macro_go_item`, `steer_left`, ...) are not `Id`s. They are: the session `Id`
|
||||||
|
/// grammar is `^[a-z0-9][a-z0-9._-]{0,63}$` (`ipc-v1` section 1), which admits `_`, and every
|
||||||
|
/// role `data/fafb-v783` declares or the kernel tracks matches it. So the mapping is the identity
|
||||||
|
/// on the `Id` grammar, trivially reversible, and a name outside the grammar is not mapped at
|
||||||
|
/// all: the agent refuses to initialize on such a dataset rather than invent an encoding that
|
||||||
|
/// no consumer could read back. `fixtures/gameboy-rate-roles.json` pins it in both languages.
|
||||||
|
pub const RATE_ROLE_MAPPING: &str = "legacy-rate-role-id-v1";
|
||||||
|
|
||||||
|
/// The `roleId` a legacy rate-role name is published under: the name itself, when it is an
|
||||||
|
/// `Id`. Anything else is refused.
|
||||||
|
pub fn rate_role_id(name: &str) -> Result<String> {
|
||||||
|
if is_id(name) {
|
||||||
|
Ok(name.to_owned())
|
||||||
|
} else {
|
||||||
|
err(format!(
|
||||||
|
"{RATE_ROLE_MAPPING}: rate role {name:?} is not an Id (^[a-z0-9][a-z0-9._-]{{0,63}}$) and has no roleId"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The legacy rate-role name a `roleId` stands for: the inverse of [`rate_role_id`].
|
||||||
|
pub fn rate_role_name(role_id: &str) -> Result<String> {
|
||||||
|
if is_id(role_id) {
|
||||||
|
Ok(role_id.to_owned())
|
||||||
|
} else {
|
||||||
|
err(format!("{RATE_ROLE_MAPPING}: {role_id:?} is not a roleId"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Maps a tracked-role list, in order, and holds it to `AgentGraph.rateRoles`' own bounds:
|
||||||
|
/// at most 64 (`MAX_RATE_ROLES`, the kernel's role bitmask) and unique.
|
||||||
|
pub fn rate_role_ids<'a>(names: impl IntoIterator<Item = &'a str>) -> Result<Vec<String>> {
|
||||||
|
let ids = names
|
||||||
|
.into_iter()
|
||||||
|
.map(rate_role_id)
|
||||||
|
.collect::<Result<Vec<String>>>()?;
|
||||||
|
if ids.len() > crate::workers::MAX_RATE_ROLES {
|
||||||
|
return err(format!(
|
||||||
|
"{RATE_ROLE_MAPPING}: {} tracked rate roles; AgentGraph.rateRoles holds at most {}",
|
||||||
|
ids.len(),
|
||||||
|
crate::workers::MAX_RATE_ROLES
|
||||||
|
));
|
||||||
|
}
|
||||||
|
require_unique(ids.iter().map(String::as_str), "rateRoles")?;
|
||||||
|
Ok(ids)
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
// Scalars and helpers
|
// Scalars and helpers
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -348,3 +348,44 @@ fn the_extension_methods_check_their_scope() {
|
||||||
assert_eq!(SLOTS_CAPABILITY, "gameboy-slots-v1");
|
assert_eq!(SLOTS_CAPABILITY, "gameboy-slots-v1");
|
||||||
assert_eq!(ROLLBACK_CAPABILITY, ROLLBACK_POLICY);
|
assert_eq!(ROLLBACK_CAPABILITY, ROLLBACK_POLICY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `legacy-rate-role-id-v1`: every accepted name is its own roleId and maps back; every refused
|
||||||
|
/// name has none. The TypeScript twin reads the same file.
|
||||||
|
#[test]
|
||||||
|
fn the_rate_role_mapping_is_the_identity_on_the_id_grammar_and_refuses_the_rest() {
|
||||||
|
let file = fixtures::load("gameboy-rate-roles.json").expect("gameboy-rate-roles.json");
|
||||||
|
assert_eq!(file["mapping"].as_str(), Some(gameboy::RATE_ROLE_MAPPING));
|
||||||
|
let accepted = file["accepted"].as_array().expect("accepted");
|
||||||
|
assert!(!accepted.is_empty());
|
||||||
|
for case in accepted {
|
||||||
|
let name = case["name"].as_str().expect("name");
|
||||||
|
let role_id = case["roleId"].as_str().expect("roleId");
|
||||||
|
assert_eq!(gameboy::rate_role_id(name).expect(name), role_id, "{name}");
|
||||||
|
assert_eq!(gameboy::rate_role_name(role_id).expect(role_id), name, "{role_id} maps back");
|
||||||
|
}
|
||||||
|
for case in file["refused"].as_array().expect("refused") {
|
||||||
|
let name = case["name"].as_str().expect("name");
|
||||||
|
assert!(gameboy::rate_role_id(name).is_err(), "{name:?} must have no roleId");
|
||||||
|
assert!(gameboy::rate_role_name(name).is_err(), "{name:?} is no roleId either");
|
||||||
|
}
|
||||||
|
// The FAFB tracked list fits AgentGraph.rateRoles as it stands: <= 64, unique, in order.
|
||||||
|
let tracked: Vec<&str> = file["fafbTrackedRoles"]
|
||||||
|
.as_array()
|
||||||
|
.expect("fafbTrackedRoles")
|
||||||
|
.iter()
|
||||||
|
.map(|v| v.as_str().expect("a role name"))
|
||||||
|
.collect();
|
||||||
|
let ids = gameboy::rate_role_ids(tracked.iter().copied()).expect("the FAFB roles map");
|
||||||
|
assert_eq!(ids, tracked);
|
||||||
|
// Every decoder channel is a ChannelName, and every ChannelName is an Id, so a macro
|
||||||
|
// channel's role is its own roleId too.
|
||||||
|
for role in &tracked {
|
||||||
|
if role.starts_with("macro_") {
|
||||||
|
assert!(gameboy::is_channel_name(role));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The list bound and uniqueness are the contract's, not the mapping's convenience.
|
||||||
|
let many: Vec<String> = (0..65).map(|i| format!("role_{i}")).collect();
|
||||||
|
assert!(gameboy::rate_role_ids(many.iter().map(String::as_str)).is_err());
|
||||||
|
assert!(gameboy::rate_role_ids(["command_0", "command_0"]).is_err());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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" }
|
||||||
|
# AGENT-01: the legacy agent worker is an adapter over the existing neural core (LIF kernel,
|
||||||
|
# plasticity, retina, fixed readout, checkpoint chunks). Pure Rust, no emulator.
|
||||||
|
flybrain-core = { path = "../flybrain-core" }
|
||||||
|
# The toy connectome fixture is written as gzipped `.binz` arrays, the dataset loader's format.
|
||||||
|
flate2 = { workspace = true }
|
||||||
|
|
||||||
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 one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,276 @@
|
||||||
|
{
|
||||||
|
"scenario": "toy-macros",
|
||||||
|
"macroChannels": [
|
||||||
|
"macro_go_out",
|
||||||
|
"macro_talk",
|
||||||
|
"macro_menu",
|
||||||
|
"macro_next"
|
||||||
|
],
|
||||||
|
"records": 263,
|
||||||
|
"digest": "5139fb8a99c6503ac2315f5a5ed754a6054e6eb8068acdd2b649931ccd40a02f",
|
||||||
|
"rows": [
|
||||||
|
"0 initialize b0 t2500 bt2500 m-- - p0 d676a54ce95aef0e",
|
||||||
|
"1 frame b1 t16 bt2516 m61 - p0 42a0dfdbf7fe8f55",
|
||||||
|
"2 frame b2 t17 bt2533 m61 - p0 bc0b415d8f485283",
|
||||||
|
"3 frame b3 t17 bt2550 m71 - p0 b953d63ad5548f84",
|
||||||
|
"4 frame b4 t16 bt2566 m71 - p0 5c6d3fef3c75b7e0",
|
||||||
|
"5 frame b5 t17 bt2583 m31 - p0 81b637fc70c20259",
|
||||||
|
"6 frame b6 t17 bt2600 m31 - p0 94e77ebf0653ed58",
|
||||||
|
"7 frame b7 t17 bt2617 m11 - p0 e9dc82d6837e1251",
|
||||||
|
"8 frame b8 t16 bt2633 m11 - p0 0997f4d5d11c3b28",
|
||||||
|
"9 frame b9 t17 bt2650 m01 - p0 ba71c1d68725ebd8",
|
||||||
|
"10 frame b10 t17 bt2667 m01 - p0 eb276406234e10c3",
|
||||||
|
"11 frame b11 t17 bt2684 m01 - p0 f51fa31f018683e7",
|
||||||
|
"12 frame b12 t16 bt2700 m01 - p0 91bfe963a2c0b0a4",
|
||||||
|
"13 frame b13 t17 bt2717 m01 - p0 6cb4d3b49ec11d37",
|
||||||
|
"14 frame b14 t17 bt2734 m01 - p0 7fb10c988bdfaafa",
|
||||||
|
"15 frame b15 t17 bt2751 m01 - p0 0277076d6c3855b1",
|
||||||
|
"16 frame b16 t16 bt2767 m01 - p0 f6b44b410581a903",
|
||||||
|
"17 frame b17 t17 bt2784 m01 - p120 5d5605f21806a2e8",
|
||||||
|
"18 frame b18 t17 bt2801 m01 - p103 e19f8f734ab1f79b",
|
||||||
|
"19 frame b19 t17 bt2818 m01 - p86 08c3045b0edda21d",
|
||||||
|
"20 frame b20 t16 bt2834 m01 - p70 70183eb4539388c6",
|
||||||
|
"21 frame b21 t17 bt2851 m01 - p53 ee10901597a34ff7",
|
||||||
|
"22 frame b22 t17 bt2868 m01 - p36 083b83cf159f8210",
|
||||||
|
"23 frame b23 t17 bt2885 m01 - p19 8e145a0fbe7439c6",
|
||||||
|
"24 frame b24 t16 bt2901 m01 - p3 b78dce0e1c9a4943",
|
||||||
|
"25 frame b25 t17 bt2918 m01 - p283 dfb93db9b8f19e8d",
|
||||||
|
"26 frame b26 t17 bt2935 m01 - p266 0c06868a06292d58",
|
||||||
|
"27 frame b27 t17 bt2952 m01 - p249 db4407e92950062d",
|
||||||
|
"28 frame b28 t16 bt2968 m01 - p233 c1eb8900546ebae6",
|
||||||
|
"29 frame b29 t17 bt2985 m01 - p216 0713b6bacce29e09",
|
||||||
|
"30 frame b30 t17 bt3002 m21 - p199 9e9fdbd1da35dddf",
|
||||||
|
"31 frame b31 t17 bt3019 m21 - p182 a67b8a9886ed6406",
|
||||||
|
"32 frame b32 t16 bt3035 m31 - p166 5de0bb3548fa8221",
|
||||||
|
"33 frame b33 t17 bt3052 m31 - p149 e443c6858ccfeefd",
|
||||||
|
"34 frame b34 t17 bt3069 m31 - p132 aad26ee01fcd8305",
|
||||||
|
"35 frame b35 t16 bt3085 m31 - p116 cbccd5cba4cf7428",
|
||||||
|
"36 frame b36 t17 bt3102 m11 - p99 2cb0a9bb493b3125",
|
||||||
|
"37 frame b37 t17 bt3119 m11 - p82 2c7d70fcdcfe1837",
|
||||||
|
"38 frame b38 t17 bt3136 m01 - p65 fbf14295f4fe432d",
|
||||||
|
"39 frame b39 t16 bt3152 m01 - p49 451f9f5b82706d20",
|
||||||
|
"40 frame b40 t17 bt3169 m01 - p32 683611e4e6578d1a state",
|
||||||
|
"41 frame b41 t17 bt3186 m01 - p15 83171b3ea9a7ea1e",
|
||||||
|
"42 frame b42 t17 bt3203 m01 - p0 05132a48c701a11b",
|
||||||
|
"43 frame b43 t16 bt3219 m01 - p0 32f1b389f783cfea",
|
||||||
|
"44 frame b44 t17 bt3236 m01 - p0 4399da53e142a8f7",
|
||||||
|
"45 frame b45 t17 bt3253 m01 - p0 83549f68a27e4a9f",
|
||||||
|
"46 frame b46 t17 bt3270 m01 - p0 8694cd49107aed69",
|
||||||
|
"47 frame b47 t16 bt3286 m01 - p0 b25ba2454528cca3",
|
||||||
|
"48 frame b48 t17 bt3303 m01 - p0 2623228af9f21266",
|
||||||
|
"49 frame b49 t17 bt3320 m02 - p0 6c82e578ef54c4c6",
|
||||||
|
"50 frame b50 t17 bt3337 m02 - p200 fa26f4f2b6e85a66",
|
||||||
|
"51 frame b51 t16 bt3353 m02 - p184 a6519d51e6a73409",
|
||||||
|
"52 frame b52 t17 bt3370 m02 - p167 804482d83c7ab25c",
|
||||||
|
"53 frame b53 t17 bt3387 m02 - p150 470afd9213bc9c69",
|
||||||
|
"54 frame b54 t17 bt3404 m02 - p133 672eb341bbee0c13",
|
||||||
|
"55 frame b55 t16 bt3420 m02 - p117 c6fdf33189fdb90a",
|
||||||
|
"56 frame b56 t17 bt3437 m02 - p100 a8b9177d330a06e1",
|
||||||
|
"57 frame b57 t17 bt3454 m02 - p83 0a96ab3adaf4ad87",
|
||||||
|
"58 frame b58 t17 bt3471 m02 - p66 89a10bb29ad693b6",
|
||||||
|
"59 frame b59 t16 bt3487 m22 - p50 d21f628e694c9a30",
|
||||||
|
"60 frame b60 t17 bt3504 m22 - p33 1a90f7e1f39f8a9d",
|
||||||
|
"61 frame b61 t17 bt3521 m32 macro_go_out p16 6b4e16812d8e4f98",
|
||||||
|
"62 frame b62 t17 bt3538 m32 macro_go_out p0 6617f27084cbb4c4",
|
||||||
|
"63 frame b63 t16 bt3554 m32 macro_go_out p0 352dde16702d22e1",
|
||||||
|
"64 frame b64 t17 bt3571 m32 macro_go_out p0 f91ec167d9a58161",
|
||||||
|
"65 frame b65 t17 bt3588 m12 macro_go_out p0 e2bbebc4ae5bb7c4",
|
||||||
|
"66 frame b66 t17 bt3605 m12 macro_go_out p0 71c1ebb6dfd44c1d",
|
||||||
|
"67 frame b67 t16 bt3621 m02 macro_go_out p0 6eb754b6d554ba64",
|
||||||
|
"68 frame b68 t17 bt3638 m02 macro_go_out p120 df0f4262f12a1cf7",
|
||||||
|
"69 frame b69 t17 bt3655 m02 macro_go_out p103 86c885bef55e8a76",
|
||||||
|
"70 frame b70 t16 bt3671 m02 macro_go_out p87 2de699b76b49ab85",
|
||||||
|
"71 frame b71 t17 bt3688 m02 macro_go_out p70 c73ebc28ca5f17ef",
|
||||||
|
"72 frame b72 t17 bt3705 m02 macro_go_out p53 5183a17558475ba4",
|
||||||
|
"73 frame b73 t17 bt3722 m02 macro_go_out p36 89a85c2d5f3a00dc",
|
||||||
|
"74 frame b74 t16 bt3738 m02 macro_go_out p20 504f6dca39cd12b9",
|
||||||
|
"75 frame b75 t17 bt3755 m02 macro_go_out p3 a23856ba2da98a74",
|
||||||
|
"76 frame b76 t17 bt3772 m02 macro_go_out p0 ff33e61ab59ca37e",
|
||||||
|
"77 frame b77 t17 bt3789 m02 macro_go_out p60 2e8876d54628e0da",
|
||||||
|
"78 frame b78 t16 bt3805 m02 macro_go_out p44 dbeca8ee685d0192",
|
||||||
|
"79 frame b79 t17 bt3822 m02 macro_go_out p27 3e2b6d875dba48c8",
|
||||||
|
"80 frame b80 t17 bt3839 m02 macro_go_out p10 31db168c0f6eef32 state",
|
||||||
|
"81 frame b81 t17 bt3856 m02 macro_go_out p0 af13492eb695dca6",
|
||||||
|
"82 frame b82 t16 bt3872 m02 macro_go_out p0 f9dca4bdd2edc20f",
|
||||||
|
"83 frame b83 t17 bt3889 m02 macro_go_out p0 19e59572d5922d09",
|
||||||
|
"84 frame b84 t17 bt3906 m02 macro_go_out p0 75e97690028f994d",
|
||||||
|
"85 frame b85 t17 bt3923 m02 macro_go_out p120 c68320e6515dd1d5",
|
||||||
|
"86 frame b86 t16 bt3939 m02 macro_go_out p104 89f1b529935223dc",
|
||||||
|
"87 frame b87 t17 bt3956 m02 macro_go_out p87 14bc1a0bbc7c9f48",
|
||||||
|
"88 frame b88 t17 bt3973 m22 macro_go_out p70 a04f92a4392e353c",
|
||||||
|
"89 frame b89 t17 bt3990 m22 macro_go_out p53 7ebb5b12ec25c397",
|
||||||
|
"90 frame b90 t16 bt4006 m32 macro_go_out p37 27ac565dda76999b",
|
||||||
|
"91 frame b91 t17 bt4023 m32 macro_go_out p20 61796a4ab7529877",
|
||||||
|
"92 frame b92 t17 bt4040 m32 macro_go_out p3 1f3dbcc2c303ff24",
|
||||||
|
"93 frame b93 t17 bt4057 m32 macro_go_out p0 84de4dd82b9054d6",
|
||||||
|
"94 frame b94 t16 bt4073 m12 macro_go_out p0 4ad0f5fe4ec4e4e8",
|
||||||
|
"95 frame b95 t17 bt4090 m12 macro_go_out p0 f3c60e6d7467e642",
|
||||||
|
"96 frame b96 t17 bt4107 m02 macro_go_out p0 f152704b374b54d2",
|
||||||
|
"97 frame b97 t17 bt4124 m08 macro_go_out p0 db6caba8900aa0f8",
|
||||||
|
"98 frame b98 t16 bt4140 m08 macro_go_out p0 750ec56c0611e86d",
|
||||||
|
"99 frame b99 t17 bt4157 m08 macro_go_out p0 20ed8618ae84ea7b",
|
||||||
|
"100 frame b100 t17 bt4174 m08 macro_go_out p0 9f3c88a1d3080276",
|
||||||
|
"101 frame b101 t17 bt4191 m08 macro_go_out p0 37f0f8de463d1ea4",
|
||||||
|
"102 frame b102 t16 bt4207 m08 macro_go_out p120 c637dc590b738a73",
|
||||||
|
"103 frame b103 t17 bt4224 m08 macro_go_out p103 acd289090f10e216",
|
||||||
|
"104 frame b104 t17 bt4241 m08 macro_go_out p86 27ff70ebeb16accd",
|
||||||
|
"105 frame b105 t16 bt4257 m08 macro_go_out p70 f6391347be381599",
|
||||||
|
"106 frame b106 t17 bt4274 m08 macro_go_out p53 dce3a6ea9772cad6",
|
||||||
|
"107 frame b107 t17 bt4291 m08 macro_go_out p36 e0c159d74b32179e",
|
||||||
|
"108 frame b108 t17 bt4308 m08 macro_go_out p19 59f328f318d4159c",
|
||||||
|
"109 frame b109 t16 bt4324 m08 macro_go_out p3 8183d6905016268b",
|
||||||
|
"110 frame b110 t17 bt4341 m08 macro_go_out p0 2e4f1cae9730fd38",
|
||||||
|
"111 frame b111 t17 bt4358 m08 macro_go_out p0 93374d1d064911e7",
|
||||||
|
"112 frame b112 t17 bt4375 m08 macro_go_out p0 3970042f6f7aeada",
|
||||||
|
"113 frame b113 t16 bt4391 m08 macro_go_out p0 453c35f7fe1df367",
|
||||||
|
"114 frame b114 t17 bt4408 m08 macro_go_out p0 84122d1a4bb5d5e4",
|
||||||
|
"115 frame b115 t17 bt4425 m08 macro_go_out p0 01155fce277003d9",
|
||||||
|
"116 frame b116 t17 bt4442 m08 macro_go_out p0 b7b1aa630e0d7422",
|
||||||
|
"117 frame b117 t16 bt4458 m28 macro_go_out p0 36283b05d8e8d580",
|
||||||
|
"118 frame b118 t17 bt4475 m28 macro_go_out p0 717afeaef5a9d808",
|
||||||
|
"119 frame b119 t17 bt4492 m38 macro_go_out p120 e3e15c15455f12ef",
|
||||||
|
"120 frame b120 t17 bt4509 m38 macro_go_out p103 25384a06ed1ab907 state",
|
||||||
|
"121 rollback b120 t0 bt4509 m-- - p103 f04a32eda0fc7403",
|
||||||
|
"122 frame b121 t16 bt4525 m08 macro_go_out p87 d07e3db7b97d3c37",
|
||||||
|
"123 frame b122 t17 bt4542 m08 macro_go_out p70 de23a79c7027df50",
|
||||||
|
"124 frame b123 t17 bt4559 m08 macro_go_out p53 f9e8c1261be94efb",
|
||||||
|
"125 frame b124 t17 bt4576 m08 macro_go_out p36 d0f1d3a30b26834b",
|
||||||
|
"126 frame b125 t16 bt4592 m08 macro_go_out p20 07a54c7f905d51b7",
|
||||||
|
"127 frame b126 t17 bt4609 m08 macro_go_out p3 4f86202774d47232",
|
||||||
|
"128 frame b127 t17 bt4626 m08 macro_go_out p0 f81252ea7dfd5cd6",
|
||||||
|
"129 frame b128 t17 bt4643 m08 macro_go_out p0 c655922ec21d8af7",
|
||||||
|
"130 frame b129 t16 bt4659 m08 macro_go_out p0 00113d916da36b19",
|
||||||
|
"131 frame b130 t17 bt4676 m08 macro_go_out p0 b29c32b34131610a",
|
||||||
|
"132 frame b131 t17 bt4693 m08 - p0 03c2ac6516de6340",
|
||||||
|
"133 frame b132 t17 bt4710 m08 - p0 0f317ebc1c7b2dfd",
|
||||||
|
"134 frame b133 t16 bt4726 m08 - p0 82c898d80cef5165",
|
||||||
|
"135 frame b134 t17 bt4743 m08 - p0 e1f447fe884f0035",
|
||||||
|
"136 frame b135 t17 bt4760 m08 - p0 03cce25fe0406708",
|
||||||
|
"137 frame b136 t17 bt4777 m08 - p120 30ab44aeb9ac184a",
|
||||||
|
"138 frame b137 t16 bt4793 m08 - p104 ecaf6653c64f1604",
|
||||||
|
"139 frame b138 t17 bt4810 m08 - p87 b660e701b0879c98",
|
||||||
|
"140 frame b139 t17 bt4827 m08 - p70 5371979c169470f3",
|
||||||
|
"141 frame b140 t16 bt4843 m08 - p54 5445a7a361444935",
|
||||||
|
"142 frame b141 t17 bt4860 m08 - p37 057f91929f6d91b4",
|
||||||
|
"143 frame b142 t17 bt4877 m08 - p20 46c238c00d482155",
|
||||||
|
"144 frame b143 t17 bt4894 m08 - p3 f0584e9063d8fc90",
|
||||||
|
"145 frame b144 t16 bt4910 m08 - p0 0b4ddd703fcf5a54",
|
||||||
|
"146 frame b145 t17 bt4927 m08 - p0 dbd0b0a86b336bfa",
|
||||||
|
"147 frame b146 t17 bt4944 m08 - p0 2e8c45f2c2c49320",
|
||||||
|
"148 frame b147 t17 bt4961 m08 - p0 63d766cee52d420c",
|
||||||
|
"149 frame b148 t16 bt4977 m08 - p0 ce85563509e81dd3",
|
||||||
|
"150 frame b149 t17 bt4994 m38 - p0 5a5ed80dd7cdd643",
|
||||||
|
"151 frame b150 t17 bt5011 m38 - p0 2c2fe0f7265f9558",
|
||||||
|
"152 frame b151 t17 bt5028 m38 - p0 a3b63cdb6fd5cdb4",
|
||||||
|
"153 frame b152 t16 bt5044 m38 - p0 3f61ef5c3aa330bb",
|
||||||
|
"154 frame b153 t17 bt5061 m38 - p120 25a4fe291121ee26",
|
||||||
|
"155 frame b154 t17 bt5078 m38 - p103 543b851caad059e1",
|
||||||
|
"156 frame b155 t17 bt5095 m08 - p86 65aa23cddd7cb9e4",
|
||||||
|
"157 frame b156 t16 bt5111 m08 - p70 51ea9900cc7266c5",
|
||||||
|
"158 frame b157 t17 bt5128 m08 - p53 5e11712fb96da006",
|
||||||
|
"159 frame b158 t17 bt5145 m08 - p36 7051c00f84b30f6b",
|
||||||
|
"160 frame b159 t17 bt5162 m08 - p19 a68b2bc24c5348ab state",
|
||||||
|
"161 frame b160 t16 bt5178 m08 - p3 0ae35caf8548b14c",
|
||||||
|
"162 frame b161 t17 bt5195 m08 - p0 1d1a3536795012c9",
|
||||||
|
"163 frame b162 t17 bt5212 m08 - p0 fdd488a6cd816ee8",
|
||||||
|
"164 frame b163 t17 bt5229 m08 - p0 847aaf2c8540f821",
|
||||||
|
"165 frame b164 t16 bt5245 m08 - p0 4d0cf08f6ad85698",
|
||||||
|
"166 frame b165 t17 bt5262 m08 - p0 fd181536e34fc9d2",
|
||||||
|
"167 frame b166 t17 bt5279 m08 - p0 4e92f250e74a306a",
|
||||||
|
"168 frame b167 t17 bt5296 m08 - p0 35d5376db498ad57",
|
||||||
|
"169 frame b168 t16 bt5312 m08 - p0 c7584d3a45a5e773",
|
||||||
|
"170 frame b169 t17 bt5329 m04 macro_talk p0 b095f08524a7fb63",
|
||||||
|
"171 frame b170 t17 bt5346 m04 macro_talk p483 0ad3bf47cf3a9a9d",
|
||||||
|
"172 frame b171 t17 bt5363 m04 macro_talk p466 38257a6752c8e9ce",
|
||||||
|
"173 frame b172 t16 bt5379 m04 macro_talk p450 b09ba9a0d5ea49f3",
|
||||||
|
"174 frame b173 t17 bt5396 m04 macro_talk p433 1ac57d8b95f38072",
|
||||||
|
"175 frame b174 t17 bt5413 m04 macro_talk p416 123bc0e305bc3745",
|
||||||
|
"176 frame b175 t16 bt5429 m04 macro_talk p400 5305ecb6f1b5e620",
|
||||||
|
"177 frame b176 t17 bt5446 m04 macro_talk p383 e495eb473a3a2803",
|
||||||
|
"178 frame b177 t17 bt5463 m04 macro_talk p366 7e018a67f3b3eb57",
|
||||||
|
"179 frame b178 t17 bt5480 m34 macro_talk p349 bcd058f091970946",
|
||||||
|
"180 frame b179 t16 bt5496 m34 macro_talk p333 25b9e2c4cd50a5fa",
|
||||||
|
"181 frame b180 t17 bt5513 m34 macro_talk p316 1512b0fb16669893",
|
||||||
|
"182 frame b181 t17 bt5530 m34 macro_talk p299 3e808e0829436112",
|
||||||
|
"183 frame b182 t17 bt5547 m34 macro_talk p282 94e9a537eaf6f5d0",
|
||||||
|
"184 frame b183 t16 bt5563 m34 macro_talk p266 bd54d070787ccd2a",
|
||||||
|
"185 frame b184 t17 bt5580 m04 macro_talk p249 1c1cd476fca4e267",
|
||||||
|
"186 frame b185 t17 bt5597 m04 macro_talk p232 9907b3274367cbf5",
|
||||||
|
"187 frame b186 t17 bt5614 m04 macro_talk p215 38e5f8b325bb16b1",
|
||||||
|
"188 frame b187 t16 bt5630 m04 macro_talk p199 fb3d645fdde535a1",
|
||||||
|
"189 frame b188 t17 bt5647 m04 macro_talk p182 7d641ad4221b0747",
|
||||||
|
"190 frame b189 t17 bt5664 m04 macro_talk p165 8856a5a3a7ea0bd0",
|
||||||
|
"191 frame b190 t17 bt5681 m04 macro_talk p148 8729465d0c93729d",
|
||||||
|
"192 restore b190 t0 bt5681 m-- - p- 8f949318d4bb63eb state",
|
||||||
|
"193 frame b191 t16 bt5697 m04 macro_talk p132 45792c108b658d08",
|
||||||
|
"194 frame b192 t17 bt5714 m04 macro_talk p115 2e86ee32ef98edcb",
|
||||||
|
"195 frame b193 t17 bt5731 m04 macro_talk p98 70133bde0d47d8ac",
|
||||||
|
"196 frame b194 t17 bt5748 m04 macro_talk p81 14aee6172d1e8f12",
|
||||||
|
"197 frame b195 t16 bt5764 m04 macro_talk p65 760f253d0b98cffc",
|
||||||
|
"198 frame b196 t17 bt5781 m04 macro_talk p48 dc2fcd053a28f245",
|
||||||
|
"199 frame b197 t17 bt5798 m04 macro_talk p31 1838d2ac9c5a10b1",
|
||||||
|
"200 frame b198 t17 bt5815 m04 macro_talk p14 c92a4879ba2b7755 state",
|
||||||
|
"201 frame b199 t16 bt5831 m04 macro_talk p0 51ddb25342248c72",
|
||||||
|
"202 frame b200 t17 bt5848 m04 macro_talk p0 3f4b549fcfd40302",
|
||||||
|
"203 frame b201 t17 bt5865 m04 - p0 1ab673841a089025",
|
||||||
|
"204 frame b202 t17 bt5882 m04 - p0 9146ba27774f5937",
|
||||||
|
"205 frame b203 t16 bt5898 m04 - p0 d1c891868e0c48b4",
|
||||||
|
"206 frame b204 t17 bt5915 m04 - p120 1aa382cede74d36a",
|
||||||
|
"207 frame b205 t17 bt5932 m04 - p103 692f94397750c3b6",
|
||||||
|
"208 frame b206 t16 bt5948 m04 - p87 5d9ac6f1fa771385",
|
||||||
|
"209 frame b207 t17 bt5965 m34 - p70 0e96c0743aec05c7",
|
||||||
|
"210 frame b208 t17 bt5982 m34 - p53 d91b236ebe272fa3",
|
||||||
|
"211 frame b209 t17 bt5999 m34 - p36 4ad5374d47cdcdae",
|
||||||
|
"212 frame b210 t16 bt6015 m34 - p20 b37529a0105ba2c0",
|
||||||
|
"213 frame b211 t17 bt6032 m34 - p3 504d9d86dae0cb35",
|
||||||
|
"214 frame b212 t17 bt6049 m34 - p0 886a90e8c0b58461",
|
||||||
|
"215 frame b213 t17 bt6066 m04 - p0 9cc25421d7118f7f",
|
||||||
|
"216 frame b214 t16 bt6082 m04 - p0 b44009171671ff67",
|
||||||
|
"217 frame b215 t17 bt6099 m04 - p0 20c0af1b486dcce7",
|
||||||
|
"218 frame b216 t17 bt6116 m04 - p0 5f62d7ce7aaf7cba",
|
||||||
|
"219 frame b217 t17 bt6133 m02 macro_menu p0 3479097cfe92a45e",
|
||||||
|
"220 frame b218 t16 bt6149 m02 macro_menu p0 58da0f5bf3e746bc",
|
||||||
|
"221 frame b219 t17 bt6166 m02 macro_menu p0 c727e2ee2f68ab43",
|
||||||
|
"222 frame b220 t17 bt6183 m02 macro_menu p0 3cd2936775dfaa42",
|
||||||
|
"223 frame b221 t17 bt6200 m02 macro_menu p120 1618166702443d2a",
|
||||||
|
"224 frame b222 t16 bt6216 m02 macro_menu p104 cac3e979b5094f7e",
|
||||||
|
"225 frame b223 t17 bt6233 m02 macro_menu p87 6bc80216cd9307d0",
|
||||||
|
"226 frame b224 t17 bt6250 m02 macro_menu p70 158808c3270826e2",
|
||||||
|
"227 frame b225 t17 bt6267 m02 macro_menu p53 e864eee9eaed3100",
|
||||||
|
"228 frame b226 t16 bt6283 m02 macro_menu p37 2f4831892562df6c",
|
||||||
|
"229 frame b227 t17 bt6300 m02 macro_menu p20 f94333f42fb868e5",
|
||||||
|
"230 frame b228 t17 bt6317 m02 macro_menu p3 62b950c98af5ea1e",
|
||||||
|
"231 frame b229 t17 bt6334 m02 macro_menu p0 3995bffa513087f5",
|
||||||
|
"232 frame b230 t16 bt6350 m02 macro_menu p0 83ed01c9a19409db",
|
||||||
|
"233 frame b231 t17 bt6367 m02 macro_menu p0 7cad1b56d3abcd86",
|
||||||
|
"234 frame b232 t17 bt6384 m02 macro_menu p0 1e4f6b123bf7b16b",
|
||||||
|
"235 frame b233 t17 bt6401 m02 macro_menu p0 961794680cc8d12e",
|
||||||
|
"236 frame b234 t16 bt6417 m02 macro_menu p0 4452a80712b7eef8",
|
||||||
|
"237 frame b235 t17 bt6434 m02 macro_menu p0 5dde31f090f929dd",
|
||||||
|
"238 frame b236 t17 bt6451 m32 macro_menu p0 10016921e0075703",
|
||||||
|
"239 frame b237 t17 bt6468 m32 macro_menu p0 3c71e55a03bcff56",
|
||||||
|
"240 frame b238 t16 bt6484 m32 macro_menu p120 94bd075f6fa74a82 state",
|
||||||
|
"241 frame b239 t17 bt6501 m32 macro_menu p103 d2d653c50d3d61ab",
|
||||||
|
"242 frame b240 t17 bt6518 m72 macro_menu p86 e0eb01fdec42ae6b",
|
||||||
|
"243 frame b241 t16 bt6534 m72 macro_menu p70 819891d76b93ffb3",
|
||||||
|
"244 frame b242 t17 bt6551 m42 macro_menu p53 48e684dbcaa34252",
|
||||||
|
"245 frame b243 t17 bt6568 m42 macro_menu p36 6b5f7974c612b7a3",
|
||||||
|
"246 frame b244 t17 bt6585 m02 macro_menu p19 66184ee2c6b219d1",
|
||||||
|
"247 frame b245 t16 bt6601 m02 macro_menu p3 d2b0395a6f2d92ed",
|
||||||
|
"248 frame b246 t17 bt6618 m02 macro_menu p0 202c87574e9d0ebc",
|
||||||
|
"249 frame b247 t17 bt6635 m02 macro_menu p0 c021f470cca581d9",
|
||||||
|
"250 frame b248 t17 bt6652 m02 macro_menu p0 590e9ba836d9b1c8",
|
||||||
|
"251 frame b249 t16 bt6668 m02 macro_menu p0 5da2d0bac5889de6",
|
||||||
|
"252 frame b250 t17 bt6685 m02 macro_menu p0 b294d92e2460443b",
|
||||||
|
"253 frame b251 t17 bt6702 m02 macro_menu p0 6af20af6bb0d75c8",
|
||||||
|
"254 frame b252 t17 bt6719 m02 macro_menu p0 ee5b8463e04ddfaa",
|
||||||
|
"255 frame b253 t16 bt6735 m02 macro_menu p0 33ad8e7c4a740c20",
|
||||||
|
"256 frame b254 t17 bt6752 m02 macro_menu p0 2c8afafa80388840",
|
||||||
|
"257 frame b255 t17 bt6769 m02 macro_menu p120 e78d398f5e177908",
|
||||||
|
"258 frame b256 t17 bt6786 m02 macro_menu p103 a2bad8c1a35197c9",
|
||||||
|
"259 frame b257 t16 bt6802 m02 macro_menu p87 476decc6c7fdb03c",
|
||||||
|
"260 frame b258 t17 bt6819 m02 macro_menu p70 fb61281ced140083",
|
||||||
|
"261 frame b259 t17 bt6836 m02 macro_menu p53 eb14e0e8da15899c",
|
||||||
|
"262 frame b260 t17 bt6853 m02 macro_menu p36 14a5132bd706cea1 state"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
{
|
||||||
|
"scenario": "toy-raw",
|
||||||
|
"macroChannels": [],
|
||||||
|
"records": 82,
|
||||||
|
"digest": "b732f959c51784f833c8ce413f896845dd706d9f2b8a87871fc3fdf4b305bcfe",
|
||||||
|
"rows": [
|
||||||
|
"0 initialize b0 t2500 bt2500 m-- - p0 d676a54ce95aef0e",
|
||||||
|
"1 frame b1 t16 bt2516 m61 - p0 4faf42ac1ad6bcb9",
|
||||||
|
"2 frame b2 t17 bt2533 m71 - p0 8486caa267aec201",
|
||||||
|
"3 frame b3 t17 bt2550 m71 - p0 b0d966a6997b1c97",
|
||||||
|
"4 frame b4 t16 bt2566 m71 - p0 64327c9a3acaab25",
|
||||||
|
"5 frame b5 t17 bt2583 m31 - p0 3798452f3ebb8d14",
|
||||||
|
"6 frame b6 t17 bt2600 m31 - p0 179c8090e3478edf",
|
||||||
|
"7 frame b7 t17 bt2617 m11 - p0 764ac5a70eaa61d5",
|
||||||
|
"8 frame b8 t16 bt2633 m01 - p0 4eebfeadc843551c",
|
||||||
|
"9 frame b9 t17 bt2650 m01 - p0 3a4d8b850a579039",
|
||||||
|
"10 frame b10 t17 bt2667 m01 - p233 2e0f5a9335fabcc1",
|
||||||
|
"11 frame b11 t17 bt2684 m01 - p216 463c0780050cad58",
|
||||||
|
"12 frame b12 t16 bt2700 m01 - p200 3cd1021570919827",
|
||||||
|
"13 frame b13 t17 bt2717 m01 - p183 1d94880645b962aa",
|
||||||
|
"14 frame b14 t17 bt2734 m01 - p166 46fe4904b3422551",
|
||||||
|
"15 frame b15 t17 bt2751 m01 - p149 fce03793e22fb350",
|
||||||
|
"16 frame b16 t16 bt2767 m01 - p133 e31bc8f885260567",
|
||||||
|
"17 frame b17 t17 bt2784 m01 - p116 fa18c9ba0836e754",
|
||||||
|
"18 frame b18 t17 bt2801 m01 - p99 1599f79d81c26afb",
|
||||||
|
"19 frame b19 t17 bt2818 m01 - p82 118a390d17e1bd1c",
|
||||||
|
"20 frame b20 t16 bt2834 m01 - p66 9ec9aa11d1798516",
|
||||||
|
"21 frame b21 t17 bt2851 m01 - p49 b204db618f624d2c",
|
||||||
|
"22 frame b22 t17 bt2868 m01 - p32 a23457482b2939ef",
|
||||||
|
"23 frame b23 t17 bt2885 m01 - p15 a8c14ddada3e932e",
|
||||||
|
"24 frame b24 t16 bt2901 m01 - p0 ba33d0462ebddaf1",
|
||||||
|
"25 frame b25 t17 bt2918 m01 - p0 67cc2d1bd2b9bb9b",
|
||||||
|
"26 frame b26 t17 bt2935 m01 - p120 14a2110ff7cab560",
|
||||||
|
"27 frame b27 t17 bt2952 m01 - p103 05a3fedc4ee71492",
|
||||||
|
"28 frame b28 t16 bt2968 m01 - p87 5f56e91792a8cde7",
|
||||||
|
"29 frame b29 t17 bt2985 m01 - p70 8c4a2900dd3c57a9",
|
||||||
|
"30 frame b30 t17 bt3002 m21 - p53 0a10535b52bfd50f state",
|
||||||
|
"31 frame b31 t17 bt3019 m31 - p36 719b19d5d7d38811",
|
||||||
|
"32 frame b32 t16 bt3035 m31 - p20 016145fcf339c081",
|
||||||
|
"33 frame b33 t17 bt3052 m31 - p3 3aaf41e08109ca4b",
|
||||||
|
"34 frame b34 t17 bt3069 m31 - p0 a8234c793afb94c9",
|
||||||
|
"35 frame b35 t16 bt3085 m31 - p0 58327823fc61314a",
|
||||||
|
"36 frame b36 t17 bt3102 m11 - p0 bcf2610c93f2ccbc",
|
||||||
|
"37 frame b37 t17 bt3119 m01 - p0 e1595a5774be4e17",
|
||||||
|
"38 frame b38 t17 bt3136 m01 - p0 16b1e96a6229a022",
|
||||||
|
"39 frame b39 t16 bt3152 m01 - p120 4a36e5436f44c5f5",
|
||||||
|
"40 frame b40 t17 bt3169 m01 - p103 1f3d420fa5f95980",
|
||||||
|
"41 frame b41 t17 bt3186 m01 - p86 b548ce6125948fa3",
|
||||||
|
"42 frame b42 t17 bt3203 m01 - p69 7750b42e6bad3b0e",
|
||||||
|
"43 frame b43 t16 bt3219 m01 - p53 05a53fc43e61453b",
|
||||||
|
"44 frame b44 t17 bt3236 m01 - p36 8a69135634af3790",
|
||||||
|
"45 frame b45 t17 bt3253 m01 - p19 eb08c832eae97b32",
|
||||||
|
"46 frame b46 t17 bt3270 m01 - p2 e6be429be207a75a",
|
||||||
|
"47 frame b47 t16 bt3286 m01 - p0 563592a0452cb518",
|
||||||
|
"48 frame b48 t17 bt3303 m01 - p0 ed298d7a151a5576",
|
||||||
|
"49 frame b49 t17 bt3320 m02 - p0 345c64ffddd498d7",
|
||||||
|
"50 frame b50 t17 bt3337 m02 - p0 f6b66191b92e78a6",
|
||||||
|
"51 frame b51 t16 bt3353 m02 - p0 5636f8375e2bd7af",
|
||||||
|
"52 frame b52 t17 bt3370 m02 - p120 a8379efb27af6c0b",
|
||||||
|
"53 frame b53 t17 bt3387 m02 - p103 a3ea7fd0062ef0f7",
|
||||||
|
"54 frame b54 t17 bt3404 m02 - p86 409e243195a1f031",
|
||||||
|
"55 frame b55 t16 bt3420 m02 - p70 18e41167f8ee76b5",
|
||||||
|
"56 frame b56 t17 bt3437 m02 - p53 2452a659ce895028",
|
||||||
|
"57 frame b57 t17 bt3454 m02 - p36 aea6a3b31521a657",
|
||||||
|
"58 frame b58 t17 bt3471 m02 - p19 abb6c797c4179f73",
|
||||||
|
"59 frame b59 t16 bt3487 m22 - p3 7f8278ec59a44a45",
|
||||||
|
"60 frame b60 t17 bt3504 m32 - p0 79f6fa3a61d3852c",
|
||||||
|
"61 rollback b60 t0 bt3504 m-- - p0 3a769108c95f6734",
|
||||||
|
"62 frame b61 t17 bt3521 m01 - p0 2d9f2dc819137ea8",
|
||||||
|
"63 frame b62 t17 bt3538 m01 - p0 4351b16cfffe379d",
|
||||||
|
"64 frame b63 t16 bt3554 m01 - p0 39286c3fcd1e0dfb",
|
||||||
|
"65 frame b64 t17 bt3571 m01 - p0 3c935521f3e6f9c1",
|
||||||
|
"66 frame b65 t17 bt3588 m01 - p120 fde92192bd9c3827",
|
||||||
|
"67 frame b66 t17 bt3605 m01 - p103 fe7a4a2e4bc2caea",
|
||||||
|
"68 frame b67 t16 bt3621 m01 - p87 a1e2ee1ff05cf73c",
|
||||||
|
"69 frame b68 t17 bt3638 m01 - p70 d676cc814f51c4e5",
|
||||||
|
"70 frame b69 t17 bt3655 m01 - p53 57e50efd3f7c7ece",
|
||||||
|
"71 frame b70 t16 bt3671 m01 - p37 2d286c3b9c9bdad5",
|
||||||
|
"72 frame b71 t17 bt3688 m01 - p20 3bdaad14aeafd436",
|
||||||
|
"73 frame b72 t17 bt3705 m01 - p3 d24ecab576a63abd",
|
||||||
|
"74 frame b73 t17 bt3722 m01 - p0 92344f9026ff8e6a",
|
||||||
|
"75 frame b74 t16 bt3738 m01 - p0 67296ab770e3083a",
|
||||||
|
"76 frame b75 t17 bt3755 m01 - p0 07a568151228ddd8",
|
||||||
|
"77 frame b76 t17 bt3772 m01 - p0 62d33c55f40ef71f",
|
||||||
|
"78 frame b77 t17 bt3789 m01 - p0 506824f70aec7fd2",
|
||||||
|
"79 frame b78 t16 bt3805 m01 - p120 b594e6a96e31d900",
|
||||||
|
"80 frame b79 t17 bt3822 m01 - p103 b11dd400cc4d2499",
|
||||||
|
"81 frame b80 t17 bt3839 m01 - p86 edab6faae36ee227 state"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -22,14 +22,16 @@ use std::process::ExitCode;
|
||||||
use crate::agent::AgentFaults;
|
use crate::agent::AgentFaults;
|
||||||
use crate::environment::EnvironmentFaults;
|
use crate::environment::EnvironmentFaults;
|
||||||
use crate::launcher::{
|
use crate::launcher::{
|
||||||
AgentLaunch, EnvironmentLaunch, ExecutionMode, Started, flags, serve_one,
|
AgentLaunch, EnvironmentLaunch, ExecutionMode, LegacyAgentLaunch, Started, flags, serve_one,
|
||||||
};
|
};
|
||||||
|
use crate::legacy_agent::LegacyProfileKind;
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
|
||||||
const USAGE: &str = "\
|
const USAGE: &str = "\
|
||||||
fly-session <command> [options]
|
fly-session <command> [options]
|
||||||
|
|
||||||
agent serve one agent worker on a launcher-created endpoint
|
agent serve one agent worker on a launcher-created endpoint
|
||||||
|
legacy-agent serve one legacy Game Boy agent worker (AGENT-01) on a launcher endpoint
|
||||||
environment serve the environment worker on a launcher-created endpoint
|
environment serve the environment worker on a launcher-created endpoint
|
||||||
measure compare the execution modes and print the measurement table
|
measure compare the execution modes and print the measurement table
|
||||||
measure-row measure one row and print it as JSON (one child per row)
|
measure-row measure one row and print it as JSON (one child per row)
|
||||||
|
|
@ -47,6 +49,8 @@ Worker options (agent and environment):
|
||||||
--warmup-ticks N [--prepare-delay-ms N] [--commit-delay-ms N]
|
--warmup-ticks N [--prepare-delay-ms N] [--commit-delay-ms N]
|
||||||
[--fail-commit-at-step N]
|
[--fail-commit-at-step N]
|
||||||
[--fail-stage-restore 0|1] [--fail-activate-restore 0|1]
|
[--fail-stage-restore 0|1] [--fail-activate-restore 0|1]
|
||||||
|
legacy-agent: --agent ID --port ID --dataset DIR --profile production|toy
|
||||||
|
--macro-channels c1,c2 (empty in raw mode)
|
||||||
environment: --worker ID --ports p1,p2 --step-numerator N --step-denominator N
|
environment: --worker ID --ports p1,p2 --step-numerator N --step-denominator N
|
||||||
[--advance-delay-ms N] [--omit-view-at-boundary N]
|
[--advance-delay-ms N] [--omit-view-at-boundary N]
|
||||||
[--fail-stage-restore 0|1] [--fail-activate-restore 0|1]
|
[--fail-stage-restore 0|1] [--fail-activate-restore 0|1]
|
||||||
|
|
@ -75,6 +79,8 @@ pub fn main() -> ExitCode {
|
||||||
let result = match command.as_str() {
|
let result = match command.as_str() {
|
||||||
"agent" => Options::parse(&rest, &[flags::COMMON, flags::AGENT_ONLY])
|
"agent" => Options::parse(&rest, &[flags::COMMON, flags::AGENT_ONLY])
|
||||||
.and_then(|o| serve(&command, &o)),
|
.and_then(|o| serve(&command, &o)),
|
||||||
|
"legacy-agent" => Options::parse(&rest, &[flags::COMMON, flags::LEGACY_AGENT_ONLY])
|
||||||
|
.and_then(|o| serve(&command, &o)),
|
||||||
"environment" => Options::parse(&rest, &[flags::COMMON, flags::ENVIRONMENT_ONLY])
|
"environment" => Options::parse(&rest, &[flags::COMMON, flags::ENVIRONMENT_ONLY])
|
||||||
.and_then(|o| serve(&command, &o)),
|
.and_then(|o| serve(&command, &o)),
|
||||||
"measure" => Options::parse(&rest, &[flags::MEASURE]).and_then(|o| measure(&o)),
|
"measure" => Options::parse(&rest, &[flags::MEASURE]).and_then(|o| measure(&o)),
|
||||||
|
|
@ -220,6 +226,18 @@ fn serve(role: &str, options: &Options) -> Result<(), String> {
|
||||||
client_id: client_id.clone(),
|
client_id: client_id.clone(),
|
||||||
service: service.clone(),
|
service: service.clone(),
|
||||||
}),
|
}),
|
||||||
|
"legacy-agent" => Started::LegacyAgent(LegacyAgentLaunch {
|
||||||
|
session_id,
|
||||||
|
agent_id: options.id(flags::AGENT)?,
|
||||||
|
port_id: options.id(flags::PORT)?,
|
||||||
|
incarnation_id,
|
||||||
|
worker_threads: threads,
|
||||||
|
dataset_dir: options.path(flags::DATASET)?,
|
||||||
|
profile: LegacyProfileKind::parse(options.required(flags::PROFILE)?)?,
|
||||||
|
macro_channels: parse_channels(options.required(flags::MACRO_CHANNELS)?)?,
|
||||||
|
client_id: client_id.clone(),
|
||||||
|
service: service.clone(),
|
||||||
|
}),
|
||||||
_ => Started::Environment(EnvironmentLaunch {
|
_ => Started::Environment(EnvironmentLaunch {
|
||||||
session_id,
|
session_id,
|
||||||
worker_id: options.id(flags::WORKER)?,
|
worker_id: options.id(flags::WORKER)?,
|
||||||
|
|
@ -259,6 +277,20 @@ fn serve(role: &str, options: &Options) -> Result<(), String> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_channels(value: &str) -> Result<Vec<String>, String> {
|
||||||
|
value
|
||||||
|
.split(',')
|
||||||
|
.filter(|part| !part.is_empty())
|
||||||
|
.map(|part| {
|
||||||
|
if fly_session_types::gameboy::is_channel_name(part) {
|
||||||
|
Ok(part.to_owned())
|
||||||
|
} else {
|
||||||
|
Err(format!("--macro-channels: {part:?} is not a channel name"))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_ports(value: &str) -> Result<Vec<Id>, String> {
|
fn parse_ports(value: &str) -> Result<Vec<Id>, String> {
|
||||||
value
|
value
|
||||||
.split(',')
|
.split(',')
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ use flybus::{Client, ClientConfig, Router, ServiceConfig, Transport, UnixListene
|
||||||
|
|
||||||
use crate::agent::{AgentConfig, AgentFaults, FakeAgentWorker};
|
use crate::agent::{AgentConfig, AgentFaults, FakeAgentWorker};
|
||||||
use crate::environment::{CounterEnvironment, EnvironmentConfig, EnvironmentFaults};
|
use crate::environment::{CounterEnvironment, EnvironmentConfig, EnvironmentFaults};
|
||||||
|
use crate::legacy_agent::{LegacyAgentConfig, LegacyAgentWorker, LegacyProfileKind};
|
||||||
use crate::rpc::WorkerRef;
|
use crate::rpc::WorkerRef;
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
use crate::worker::{StatusCell, WorkerHandle, serve};
|
use crate::worker::{StatusCell, WorkerHandle, serve};
|
||||||
|
|
@ -257,6 +258,26 @@ pub struct EnvironmentLaunch {
|
||||||
pub service: String,
|
pub service: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// What one legacy agent participant (AGENT-01) is started with.
|
||||||
|
///
|
||||||
|
/// Everything crosses a process boundary as argv, like the synthetic agent's configuration: a
|
||||||
|
/// dataset directory, the profile it serves and the composition's macro channels. The seed,
|
||||||
|
/// the profile `AssetRef` and the first frame arrive in `Agent.Initialize`, not here.
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct LegacyAgentLaunch {
|
||||||
|
pub session_id: Id,
|
||||||
|
pub agent_id: Id,
|
||||||
|
pub port_id: Id,
|
||||||
|
pub incarnation_id: Id,
|
||||||
|
pub worker_threads: usize,
|
||||||
|
pub dataset_dir: PathBuf,
|
||||||
|
pub profile: LegacyProfileKind,
|
||||||
|
/// `executor.macroChannels` in composition order; empty in raw mode.
|
||||||
|
pub macro_channels: Vec<String>,
|
||||||
|
pub client_id: String,
|
||||||
|
pub service: String,
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
// A launched participant
|
// A launched participant
|
||||||
|
|
||||||
|
|
@ -581,6 +602,38 @@ impl Launcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Starts one legacy agent (AGENT-01), in the launcher's configured mode, and identifies it.
|
||||||
|
pub async fn launch_legacy_agent(
|
||||||
|
&mut self,
|
||||||
|
spec: LegacyAgentLaunch,
|
||||||
|
) -> Result<WorkerIdentity, DomainError> {
|
||||||
|
let threads = self.budget.allocate(&spec.agent_id, spec.worker_threads)?;
|
||||||
|
let identity = WorkerIdentity {
|
||||||
|
session_id: spec.session_id.clone(),
|
||||||
|
client_id: spec.client_id.clone(),
|
||||||
|
service: spec.service.clone(),
|
||||||
|
worker_id: spec.agent_id.clone(),
|
||||||
|
incarnation_id: spec.incarnation_id.clone(),
|
||||||
|
role: Role::Agent,
|
||||||
|
port_id: Some(spec.port_id.clone()),
|
||||||
|
worker_threads: threads,
|
||||||
|
};
|
||||||
|
let started = self
|
||||||
|
.start_participant(&identity, Started::LegacyAgent(spec.clone()), threads)
|
||||||
|
.await;
|
||||||
|
match started {
|
||||||
|
Ok(worker) => {
|
||||||
|
let identity = worker.identity.clone();
|
||||||
|
self.workers.insert(spec.agent_id.clone(), worker);
|
||||||
|
Ok(identity)
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
self.budget.release(&spec.agent_id);
|
||||||
|
Err(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Starts the environment, in the launcher's configured mode, and identifies it.
|
/// Starts the environment, in the launcher's configured mode, and identifies it.
|
||||||
pub async fn launch_environment(
|
pub async fn launch_environment(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -690,6 +743,12 @@ impl Launcher {
|
||||||
let status = endpoint.status();
|
let status = endpoint.status();
|
||||||
(serve(client, service, endpoint), status)
|
(serve(client, service, endpoint), status)
|
||||||
}
|
}
|
||||||
|
Started::LegacyAgent(spec) => {
|
||||||
|
let endpoint =
|
||||||
|
LegacyAgentWorker::new(legacy_agent_config(spec, identity.worker_threads));
|
||||||
|
let status = endpoint.status();
|
||||||
|
(serve(client, service, endpoint), status)
|
||||||
|
}
|
||||||
Started::Environment(spec) => {
|
Started::Environment(spec) => {
|
||||||
let endpoint = CounterEnvironment::new(environment_config(spec));
|
let endpoint = CounterEnvironment::new(environment_config(spec));
|
||||||
let status = endpoint.status();
|
let status = endpoint.status();
|
||||||
|
|
@ -1250,6 +1309,10 @@ pub(crate) mod flags {
|
||||||
pub const OMIT_AUDIO_AT_BOUNDARY: &str = "omit-audio-at-boundary";
|
pub const OMIT_AUDIO_AT_BOUNDARY: &str = "omit-audio-at-boundary";
|
||||||
pub const OVERLAPPING_AUDIO_AT_BOUNDARY: &str = "overlapping-audio-at-boundary";
|
pub const OVERLAPPING_AUDIO_AT_BOUNDARY: &str = "overlapping-audio-at-boundary";
|
||||||
|
|
||||||
|
pub const DATASET: &str = "dataset";
|
||||||
|
pub const PROFILE: &str = "profile";
|
||||||
|
pub const MACRO_CHANNELS: &str = "macro-channels";
|
||||||
|
|
||||||
pub const MODE: &str = "mode";
|
pub const MODE: &str = "mode";
|
||||||
pub const AGENTS: &str = "agents";
|
pub const AGENTS: &str = "agents";
|
||||||
pub const STEPS: &str = "steps";
|
pub const STEPS: &str = "steps";
|
||||||
|
|
@ -1281,6 +1344,8 @@ pub(crate) mod flags {
|
||||||
FAIL_STAGE_RESTORE,
|
FAIL_STAGE_RESTORE,
|
||||||
FAIL_ACTIVATE_RESTORE,
|
FAIL_ACTIVATE_RESTORE,
|
||||||
];
|
];
|
||||||
|
/// What only a legacy agent (AGENT-01) is given.
|
||||||
|
pub const LEGACY_AGENT_ONLY: &[&str] = &[AGENT, PORT, DATASET, PROFILE, MACRO_CHANNELS];
|
||||||
/// What only the environment is given, media options included.
|
/// What only the environment is given, media options included.
|
||||||
pub const ENVIRONMENT_ONLY: &[&str] = &[
|
pub const ENVIRONMENT_ONLY: &[&str] = &[
|
||||||
WORKER,
|
WORKER,
|
||||||
|
|
@ -1313,6 +1378,7 @@ fn arg(name: &str, value: impl std::fmt::Display) -> (String, String) {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum Started {
|
pub(crate) enum Started {
|
||||||
Agent(AgentLaunch),
|
Agent(AgentLaunch),
|
||||||
|
LegacyAgent(LegacyAgentLaunch),
|
||||||
Environment(EnvironmentLaunch),
|
Environment(EnvironmentLaunch),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1320,6 +1386,7 @@ impl Started {
|
||||||
pub(crate) fn subcommand(&self) -> &'static str {
|
pub(crate) fn subcommand(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Started::Agent(_) => "agent",
|
Started::Agent(_) => "agent",
|
||||||
|
Started::LegacyAgent(_) => "legacy-agent",
|
||||||
Started::Environment(_) => "environment",
|
Started::Environment(_) => "environment",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1350,6 +1417,17 @@ impl Started {
|
||||||
}
|
}
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
|
Started::LegacyAgent(spec) => vec![
|
||||||
|
arg(flags::SESSION, &spec.session_id),
|
||||||
|
arg(flags::AGENT, &spec.agent_id),
|
||||||
|
arg(flags::PORT, &spec.port_id),
|
||||||
|
arg(flags::INCARNATION, &spec.incarnation_id),
|
||||||
|
arg(flags::DATASET, spec.dataset_dir.display()),
|
||||||
|
arg(flags::PROFILE, spec.profile.label()),
|
||||||
|
// An empty list is raw mode; the flag is always written so the parser never
|
||||||
|
// has to guess which one a missing flag meant.
|
||||||
|
arg(flags::MACRO_CHANNELS, spec.macro_channels.join(",")),
|
||||||
|
],
|
||||||
Started::Environment(spec) => {
|
Started::Environment(spec) => {
|
||||||
let mut args = vec![
|
let mut args = vec![
|
||||||
arg(flags::SESSION, &spec.session_id),
|
arg(flags::SESSION, &spec.session_id),
|
||||||
|
|
@ -1405,6 +1483,18 @@ pub(crate) fn agent_config(spec: &AgentLaunch, worker_threads: usize) -> AgentCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn legacy_agent_config(spec: &LegacyAgentLaunch, worker_threads: usize) -> LegacyAgentConfig {
|
||||||
|
LegacyAgentConfig {
|
||||||
|
session_id: spec.session_id.clone(),
|
||||||
|
agent_id: spec.agent_id.clone(),
|
||||||
|
incarnation_id: spec.incarnation_id.clone(),
|
||||||
|
worker_threads,
|
||||||
|
dataset_dir: spec.dataset_dir.clone(),
|
||||||
|
profile: spec.profile,
|
||||||
|
macro_channels: spec.macro_channels.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn environment_config(spec: &EnvironmentLaunch) -> EnvironmentConfig {
|
pub(crate) fn environment_config(spec: &EnvironmentLaunch) -> EnvironmentConfig {
|
||||||
EnvironmentConfig {
|
EnvironmentConfig {
|
||||||
session_id: spec.session_id.clone(),
|
session_id: spec.session_id.clone(),
|
||||||
|
|
@ -1441,6 +1531,11 @@ pub(crate) async fn serve_one(
|
||||||
service,
|
service,
|
||||||
FakeAgentWorker::new(agent_config(spec, worker_threads)),
|
FakeAgentWorker::new(agent_config(spec, worker_threads)),
|
||||||
),
|
),
|
||||||
|
Started::LegacyAgent(spec) => serve(
|
||||||
|
client,
|
||||||
|
service,
|
||||||
|
LegacyAgentWorker::new(legacy_agent_config(spec, worker_threads)),
|
||||||
|
),
|
||||||
Started::Environment(spec) => {
|
Started::Environment(spec) => {
|
||||||
serve(client, service, CounterEnvironment::new(environment_config(spec)))
|
serve(client, service, CounterEnvironment::new(environment_config(spec)))
|
||||||
}
|
}
|
||||||
|
|
@ -1528,6 +1623,21 @@ mod flag_tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn legacy_agent_launch() -> LegacyAgentLaunch {
|
||||||
|
LegacyAgentLaunch {
|
||||||
|
session_id: id("demo"),
|
||||||
|
agent_id: id("fly-a"),
|
||||||
|
port_id: id("p1"),
|
||||||
|
incarnation_id: id("fly-a-inc-1"),
|
||||||
|
worker_threads: 1,
|
||||||
|
dataset_dir: PathBuf::from("/nonexistent/legacy-toy"),
|
||||||
|
profile: LegacyProfileKind::Toy,
|
||||||
|
macro_channels: vec!["macro_talk".to_owned()],
|
||||||
|
client_id: "worker-fly-a".to_owned(),
|
||||||
|
service: "agent.fly-a".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Both halves of the command line name the same constants, and this proves it for every
|
/// Both halves of the command line name the same constants, and this proves it for every
|
||||||
/// argument a launch can produce: a flag the launcher writes that the parser does not
|
/// argument a launch can produce: a flag the launcher writes that the parser does not
|
||||||
/// accept would be a silently ignored option, which is what the parser now refuses.
|
/// accept would be a silently ignored option, which is what the parser now refuses.
|
||||||
|
|
@ -1539,6 +1649,10 @@ mod flag_tests {
|
||||||
[flags::COMMON, flags::ENVIRONMENT_ONLY],
|
[flags::COMMON, flags::ENVIRONMENT_ONLY],
|
||||||
),
|
),
|
||||||
(Started::Agent(agent_launch()), [flags::COMMON, flags::AGENT_ONLY]),
|
(Started::Agent(agent_launch()), [flags::COMMON, flags::AGENT_ONLY]),
|
||||||
|
(
|
||||||
|
Started::LegacyAgent(legacy_agent_launch()),
|
||||||
|
[flags::COMMON, flags::LEGACY_AGENT_ONLY],
|
||||||
|
),
|
||||||
] {
|
] {
|
||||||
let arguments = started.arguments();
|
let arguments = started.arguments();
|
||||||
assert!(!arguments.is_empty());
|
assert!(!arguments.is_empty());
|
||||||
|
|
|
||||||
1796
services/flysim/crates/fly-session/src/legacy_agent.rs
Normal file
1796
services/flysim/crates/fly-session/src/legacy_agent.rs
Normal file
File diff suppressed because it is too large
Load diff
1990
services/flysim/crates/fly-session/src/legacy_parity.rs
Normal file
1990
services/flysim/crates/fly-session/src/legacy_parity.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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_agent;
|
||||||
|
pub mod legacy_parity;
|
||||||
pub mod measure;
|
pub mod measure;
|
||||||
pub mod media;
|
pub mod media;
|
||||||
pub mod metrics;
|
pub mod metrics;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
885
services/flysim/crates/fly-session/tests/legacy_agent.rs
Normal file
885
services/flysim/crates/fly-session/tests/legacy_agent.rs
Normal file
|
|
@ -0,0 +1,885 @@
|
||||||
|
//! AGENT-01: the legacy agent worker against the neural core driven directly, on the committed
|
||||||
|
//! toy connectome, under the launcher in every execution mode.
|
||||||
|
//!
|
||||||
|
//! `FLY_UPDATE_FIXTURES=1` rewrites the toy dataset and the goldens; otherwise the committed
|
||||||
|
//! files must be exactly what this build computes.
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use fly_session::ExecutionMode;
|
||||||
|
use fly_session::legacy_agent::{LegacyProfileKind, TOY_FINGERPRINT};
|
||||||
|
use fly_session::legacy_parity::{
|
||||||
|
self, DirectSource, LegacyRig, LegacyScript, ParityRecord, ReferenceSource, RigAgent, toy,
|
||||||
|
};
|
||||||
|
use fly_session::types::id;
|
||||||
|
use flybrain_core::dataset::load_brain_dataset_from_dir;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
fn updating() -> bool {
|
||||||
|
std::env::var_os("FLY_UPDATE_FIXTURES").is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn toy_agent(agent_id: &str, script: &LegacyScript) -> RigAgent {
|
||||||
|
RigAgent {
|
||||||
|
agent_id: id(agent_id),
|
||||||
|
port_id: id("p1"),
|
||||||
|
dataset_dir: toy::dir(),
|
||||||
|
profile: LegacyProfileKind::Toy,
|
||||||
|
macro_channels: script.macro_channels.clone(),
|
||||||
|
worker_threads: 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reference(script: &LegacyScript) -> Vec<ParityRecord> {
|
||||||
|
let dataset = Arc::new(load_brain_dataset_from_dir(toy::dir()).expect("the toy dataset loads"));
|
||||||
|
DirectSource { dataset }
|
||||||
|
.records(script)
|
||||||
|
.expect("the reference runs")
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn on_worker(mode: ExecutionMode, script: &LegacyScript) -> Vec<ParityRecord> {
|
||||||
|
let root = tempfile::tempdir().expect("a temporary directory");
|
||||||
|
let mut rig = LegacyRig::start(root.path(), mode, &[toy_agent("fly-a", script)])
|
||||||
|
.await
|
||||||
|
.expect("the rig starts");
|
||||||
|
let records = legacy_parity::run_on_worker(&mut rig, &id("fly-a"), script)
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| panic!("{}: {e}", mode.label()));
|
||||||
|
rig.stop().await;
|
||||||
|
records
|
||||||
|
}
|
||||||
|
|
||||||
|
fn golden(script: &LegacyScript, records: &[ParityRecord]) {
|
||||||
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
|
.join("fixtures")
|
||||||
|
.join(format!("{}.golden.json", script.name));
|
||||||
|
let mut text =
|
||||||
|
serde_json::to_string_pretty(&legacy_parity::golden_json(script, records)).expect("json");
|
||||||
|
text.push('\n');
|
||||||
|
if updating() {
|
||||||
|
std::fs::write(&path, &text).expect("write the golden");
|
||||||
|
}
|
||||||
|
let found = std::fs::read_to_string(&path).expect("the committed golden");
|
||||||
|
if found != text {
|
||||||
|
let want: Value = serde_json::from_str(&found).expect("golden json");
|
||||||
|
let got: Value = serde_json::from_str(&text).expect("json");
|
||||||
|
let rows = |v: &Value| -> Vec<String> {
|
||||||
|
v["rows"]
|
||||||
|
.as_array()
|
||||||
|
.map(|a| {
|
||||||
|
a.iter()
|
||||||
|
.map(|r| r.as_str().unwrap_or("").to_owned())
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
|
};
|
||||||
|
let first = rows(&want)
|
||||||
|
.into_iter()
|
||||||
|
.zip(rows(&got))
|
||||||
|
.find(|(a, b)| a != b);
|
||||||
|
panic!(
|
||||||
|
"{} is stale (first differing row: {first:?}); rerun with FLY_UPDATE_FIXTURES=1",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_committed_toy_dataset_is_what_the_generator_writes() {
|
||||||
|
let dir = toy::dir();
|
||||||
|
if updating() {
|
||||||
|
toy::write(&dir).expect("write the toy dataset");
|
||||||
|
}
|
||||||
|
for (name, bytes) in toy::files() {
|
||||||
|
let found = std::fs::read(dir.join(&name)).unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||||
|
assert_eq!(
|
||||||
|
found, bytes,
|
||||||
|
"{name} is stale; rerun with FLY_UPDATE_FIXTURES=1"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let dataset = load_brain_dataset_from_dir(&dir).expect("the toy dataset loads");
|
||||||
|
assert_eq!(
|
||||||
|
dataset.fingerprint.as_deref(),
|
||||||
|
Some(TOY_FINGERPRINT),
|
||||||
|
"the toy profile embeds it"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The macros-mode scenario, in all three execution modes, against the direct reference and
|
||||||
|
/// the committed golden.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||||
|
async fn the_macros_scenario_matches_the_reference_in_every_mode() {
|
||||||
|
let script = legacy_parity::toy_macros_script(260);
|
||||||
|
let want = reference(&script);
|
||||||
|
golden(&script, &want);
|
||||||
|
for mode in ExecutionMode::all() {
|
||||||
|
let got = on_worker(mode, &script).await;
|
||||||
|
legacy_parity::compare(&want, &got).unwrap_or_else(|e| panic!("{}: {e}", mode.label()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Raw mode: no macro group, `bound` never masks, the decision never names a macro.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||||
|
async fn the_raw_scenario_matches_the_reference_in_every_mode() {
|
||||||
|
let script = legacy_parity::toy_raw_script(80);
|
||||||
|
let want = reference(&script);
|
||||||
|
golden(&script, &want);
|
||||||
|
assert!(want.iter().all(|r| {
|
||||||
|
r.decision
|
||||||
|
.as_ref()
|
||||||
|
.is_none_or(|d| d.macro_channel.is_none())
|
||||||
|
}));
|
||||||
|
for mode in ExecutionMode::all() {
|
||||||
|
let got = on_worker(mode, &script).await;
|
||||||
|
legacy_parity::compare(&want, &got).unwrap_or_else(|e| panic!("{}: {e}", mode.label()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A second fly's script: the same shape, other frames and no rewards, so any gain, trace, RNG
|
||||||
|
/// or hold shared between the two would show in one of them.
|
||||||
|
fn quiet_twin(script: &LegacyScript) -> LegacyScript {
|
||||||
|
let mut twin = script.clone();
|
||||||
|
twin.name = format!("{}-twin", script.name);
|
||||||
|
for step in &mut twin.steps {
|
||||||
|
if let legacy_parity::ScriptStep::Frame {
|
||||||
|
frame,
|
||||||
|
rewards,
|
||||||
|
sugar,
|
||||||
|
..
|
||||||
|
} = step
|
||||||
|
{
|
||||||
|
*frame = (*frame + 3) % 8;
|
||||||
|
rewards.clear();
|
||||||
|
sugar.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
twin
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn step_one(
|
||||||
|
driver: &mut legacy_parity::AgentDriver,
|
||||||
|
index: usize,
|
||||||
|
step: &legacy_parity::ScriptStep,
|
||||||
|
) -> ParityRecord {
|
||||||
|
match step {
|
||||||
|
legacy_parity::ScriptStep::Frame {
|
||||||
|
sugar,
|
||||||
|
frame,
|
||||||
|
rewards,
|
||||||
|
next_context,
|
||||||
|
} => driver
|
||||||
|
.frame(index + 1, sugar, *frame, rewards, next_context)
|
||||||
|
.await
|
||||||
|
.expect("a frame"),
|
||||||
|
legacy_parity::ScriptStep::Rollback { frame, context } => driver
|
||||||
|
.rollback(index + 1, *frame, context)
|
||||||
|
.await
|
||||||
|
.expect("a rollback"),
|
||||||
|
legacy_parity::ScriptStep::Restore => unreachable!("the pair scripts do not restore"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Two flies in one composition, dispatched concurrently and then in reversed order, one of
|
||||||
|
/// them sweeping on two threads: each is exactly its own solo reference. No gains, RNG, holds
|
||||||
|
/// or pulse cross between agents, and neither dispatch order nor worker count moves a result.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||||
|
async fn two_agents_share_nothing_whatever_the_dispatch_order_or_thread_count() {
|
||||||
|
let a_script = legacy_parity::toy_raw_script(60);
|
||||||
|
let b_script = quiet_twin(&a_script);
|
||||||
|
let a_want = reference(&a_script);
|
||||||
|
let b_want = reference(&b_script);
|
||||||
|
assert_ne!(a_want, b_want);
|
||||||
|
for (mode, reversed) in [
|
||||||
|
(ExecutionMode::Thread, false),
|
||||||
|
(ExecutionMode::Process, true),
|
||||||
|
] {
|
||||||
|
let root = tempfile::tempdir().expect("a temporary directory");
|
||||||
|
let mut a_agent = toy_agent("fly-a", &a_script);
|
||||||
|
a_agent.worker_threads = 2;
|
||||||
|
let mut b_agent = toy_agent("fly-b", &b_script);
|
||||||
|
b_agent.port_id = id("p2");
|
||||||
|
let rig = LegacyRig::start(root.path(), mode, &[a_agent, b_agent])
|
||||||
|
.await
|
||||||
|
.expect("the rig starts");
|
||||||
|
let mut a = rig.driver(&id("fly-a"), &a_script);
|
||||||
|
let mut b = rig.driver(&id("fly-b"), &b_script);
|
||||||
|
let mut a_got = vec![a.initialize(a_script.initial_frame).await.expect("a")];
|
||||||
|
let mut b_got = vec![b.initialize(b_script.initial_frame).await.expect("b")];
|
||||||
|
for index in 0..a_script.steps.len() {
|
||||||
|
let (ra, rb) = if reversed {
|
||||||
|
let rb = step_one(&mut b, index, &b_script.steps[index]).await;
|
||||||
|
let ra = step_one(&mut a, index, &a_script.steps[index]).await;
|
||||||
|
(ra, rb)
|
||||||
|
} else {
|
||||||
|
tokio::join!(
|
||||||
|
step_one(&mut a, index, &a_script.steps[index]),
|
||||||
|
step_one(&mut b, index, &b_script.steps[index])
|
||||||
|
)
|
||||||
|
};
|
||||||
|
a_got.push(ra);
|
||||||
|
b_got.push(rb);
|
||||||
|
}
|
||||||
|
// Checkpoints are compared on the solo runs; here the per-step records are.
|
||||||
|
let strip = |records: &[ParityRecord]| -> Vec<ParityRecord> {
|
||||||
|
records
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(|mut r| {
|
||||||
|
r.state = None;
|
||||||
|
r
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
|
legacy_parity::compare(&strip(&a_want), &a_got)
|
||||||
|
.unwrap_or_else(|e| panic!("{} fly-a: {e}", mode.label()));
|
||||||
|
legacy_parity::compare(&strip(&b_want), &b_got)
|
||||||
|
.unwrap_or_else(|e| panic!("{} fly-b: {e}", mode.label()));
|
||||||
|
rig.stop().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod refusals {
|
||||||
|
use super::*;
|
||||||
|
use fly_session::legacy_agent::LegacyAgentProfile;
|
||||||
|
use fly_session::types::*;
|
||||||
|
use fly_session_types::extensions::{
|
||||||
|
AgentRollbackParams, ROLLBACK_CAPABILITY, ROLLBACK_POLICY,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn code(reply: Result<fly_session::rpc::DomainReply, DomainError>) -> ErrorCode {
|
||||||
|
match reply {
|
||||||
|
Err(e) => e.code,
|
||||||
|
Ok(reply) => match reply.result() {
|
||||||
|
Err(e) => e.code,
|
||||||
|
Ok(v) => panic!("expected a refusal, got {v}"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn rig_with(root: &std::path::Path, agent: RigAgent) -> LegacyRig {
|
||||||
|
LegacyRig::start(root, ExecutionMode::InProcess, &[agent])
|
||||||
|
.await
|
||||||
|
.expect("the rig starts")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_params(
|
||||||
|
driver: &legacy_parity::AgentDriver,
|
||||||
|
input: SensoryInput,
|
||||||
|
profile: AssetRef,
|
||||||
|
seed: i32,
|
||||||
|
) -> serde_json::Value {
|
||||||
|
AgentInitializeParams {
|
||||||
|
agent_id: id("fly-a"),
|
||||||
|
profile,
|
||||||
|
seed,
|
||||||
|
initial_input: input,
|
||||||
|
initial_decision_context: driver.context().clone(),
|
||||||
|
worker_threads: 1,
|
||||||
|
}
|
||||||
|
.to_json()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialize refuses another profile, a dataset that is not the profile's, a seed the
|
||||||
|
/// kernel version does not allow, and a context naming a channel the composition lacks.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn initialize_checks_the_profile_the_dataset_the_seed_and_the_context() {
|
||||||
|
let script = legacy_parity::toy_macros_script(4);
|
||||||
|
let root = tempfile::tempdir().expect("tmp");
|
||||||
|
let rig = rig_with(root.path(), toy_agent("fly-a", &script)).await;
|
||||||
|
let mut driver = rig.driver(&id("fly-a"), &script);
|
||||||
|
let scope = driver.current_scope();
|
||||||
|
let (input, frame) = driver.input(0, 0).await.expect("a frame");
|
||||||
|
let production = LegacyAgentProfile::production().asset;
|
||||||
|
let params = init_params(
|
||||||
|
&driver,
|
||||||
|
input.clone(),
|
||||||
|
production,
|
||||||
|
legacy_parity::LEGACY_SEED,
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Initialize",
|
||||||
|
Some(scope.clone()),
|
||||||
|
params,
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::IdentityMismatch,
|
||||||
|
"another profile"
|
||||||
|
);
|
||||||
|
let toy_profile = driver.profile().clone();
|
||||||
|
let params = init_params(&driver, input.clone(), toy_profile.clone(), 7);
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Initialize",
|
||||||
|
Some(scope.clone()),
|
||||||
|
params,
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::IncompatibleState,
|
||||||
|
"seed 7 would be another kernel version"
|
||||||
|
);
|
||||||
|
let mut params = init_params(
|
||||||
|
&driver,
|
||||||
|
input.clone(),
|
||||||
|
toy_profile.clone(),
|
||||||
|
legacy_parity::LEGACY_SEED,
|
||||||
|
);
|
||||||
|
let bad = fly_session_types::gameboy::ReadoutContext {
|
||||||
|
boot: true,
|
||||||
|
bound: vec!["macro_heal".to_owned()],
|
||||||
|
location: None,
|
||||||
|
};
|
||||||
|
params["initialDecisionContext"] = bad.to_typed().to_json();
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Initialize",
|
||||||
|
Some(scope.clone()),
|
||||||
|
params,
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::InvalidArgument,
|
||||||
|
"a bound channel outside the composition"
|
||||||
|
);
|
||||||
|
// Every refusal above was made before a model existed: the worker still initializes.
|
||||||
|
driver
|
||||||
|
.initialize(0)
|
||||||
|
.await
|
||||||
|
.expect("the worker is still uninitialized and accepts a good request");
|
||||||
|
rig.stop().await;
|
||||||
|
|
||||||
|
// A worker configured for the production profile, pointed at the toy connectome.
|
||||||
|
let root = tempfile::tempdir().expect("tmp");
|
||||||
|
let mut agent = toy_agent("fly-a", &script);
|
||||||
|
agent.profile = LegacyProfileKind::Production;
|
||||||
|
let rig = rig_with(root.path(), agent).await;
|
||||||
|
let mut driver = rig.driver(&id("fly-a"), &script);
|
||||||
|
let (input, frame) = driver.input(0, 0).await.expect("a frame");
|
||||||
|
let params = init_params(
|
||||||
|
&driver,
|
||||||
|
input,
|
||||||
|
LegacyAgentProfile::production().asset,
|
||||||
|
legacy_parity::LEGACY_SEED,
|
||||||
|
);
|
||||||
|
let scope = driver.current_scope();
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Initialize",
|
||||||
|
Some(scope),
|
||||||
|
params,
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::IdentityMismatch,
|
||||||
|
"the toy connectome is not the dataset the production profile embeds"
|
||||||
|
);
|
||||||
|
rig.stop().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prepare refuses another cadence and an undeclared stimulus kind; a retried Prepare
|
||||||
|
/// replays its decision without ticking again; Rollback refuses the wrong epochs and a
|
||||||
|
/// prepared agent; StageRestore refuses another fly's compatibility.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn step_rollback_and_restore_refuse_what_they_must() {
|
||||||
|
let script = legacy_parity::toy_macros_script(4);
|
||||||
|
let root = tempfile::tempdir().expect("tmp");
|
||||||
|
let rig = rig_with(root.path(), toy_agent("fly-a", &script)).await;
|
||||||
|
let mut driver = rig.driver(&id("fly-a"), &script);
|
||||||
|
let hello = HelloParams {
|
||||||
|
session_id: id("legacy"),
|
||||||
|
expected_worker_id: id("fly-a"),
|
||||||
|
role: Role::Agent,
|
||||||
|
supported_majors: vec![1],
|
||||||
|
};
|
||||||
|
let hello: HelloResult = driver
|
||||||
|
.call_raw("Worker.Hello", None, hello.to_json(), &[])
|
||||||
|
.await
|
||||||
|
.expect("hello")
|
||||||
|
.parse()
|
||||||
|
.expect("a hello result");
|
||||||
|
assert!(
|
||||||
|
hello.capabilities.iter().any(|c| c == ROLLBACK_CAPABILITY),
|
||||||
|
"{:?}",
|
||||||
|
hello.capabilities
|
||||||
|
);
|
||||||
|
driver.initialize(0).await.expect("initialize");
|
||||||
|
let scope = driver.current_scope();
|
||||||
|
let prepare = |interval: RationalNs, kind: &str| PrepareParams {
|
||||||
|
agent_id: id("fly-a"),
|
||||||
|
profile_digest: driver.profile().digest.clone(),
|
||||||
|
interval,
|
||||||
|
decision_context_digest: driver.context().digest(),
|
||||||
|
pre_step_stimulations: vec![Stimulus {
|
||||||
|
id: id("s1"),
|
||||||
|
kind_id: kind.to_owned(),
|
||||||
|
duration_ms: 50.0,
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
let sixty = hz(60).expect("60 Hz");
|
||||||
|
let frame_interval = fly_session_types::gameboy::step_duration();
|
||||||
|
let bad_cadence = prepare(sixty, "reward-pulse").to_json();
|
||||||
|
let bad_kind = prepare(frame_interval, "arena.milestone").to_json();
|
||||||
|
let good = prepare(frame_interval, "reward-pulse").to_json();
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw("Agent.Prepare", Some(scope.clone()), bad_cadence, &[])
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::InvalidArgument
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw("Agent.Prepare", Some(scope.clone()), bad_kind, &[])
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::Unsupported
|
||||||
|
);
|
||||||
|
let first = driver
|
||||||
|
.call_raw("Agent.Prepare", Some(scope.clone()), good.clone(), &[])
|
||||||
|
.await
|
||||||
|
.expect("prepare");
|
||||||
|
let prepared: PreparedDecision = first.parse().expect("a decision");
|
||||||
|
let again = driver
|
||||||
|
.retry_raw(
|
||||||
|
first.request_id.clone(),
|
||||||
|
"Agent.Prepare",
|
||||||
|
Some(scope.clone()),
|
||||||
|
good,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("a replay");
|
||||||
|
let replayed: PreparedDecision = again.parse().expect("the same decision");
|
||||||
|
assert_eq!(
|
||||||
|
prepared, replayed,
|
||||||
|
"a duplicate Prepare returns the same decision"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Rollback while Prepared.
|
||||||
|
let (input, frame) = driver.input(2, 0).await.expect("a frame");
|
||||||
|
let rollback = |prior: &str| AgentRollbackParams {
|
||||||
|
agent_id: id("fly-a"),
|
||||||
|
prior_epoch: id(prior),
|
||||||
|
policy: ROLLBACK_POLICY.to_owned(),
|
||||||
|
input: input.clone(),
|
||||||
|
decision_context: driver.context().clone(),
|
||||||
|
};
|
||||||
|
let next_epoch = scope_at("legacy", "e2", 0);
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Rollback",
|
||||||
|
Some(next_epoch.clone()),
|
||||||
|
rollback("e1").to_json(),
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::InvalidPhase,
|
||||||
|
"a prepared agent is mid-transition"
|
||||||
|
);
|
||||||
|
rig.stop().await;
|
||||||
|
|
||||||
|
let root = tempfile::tempdir().expect("tmp");
|
||||||
|
let mut rig = rig_with(root.path(), toy_agent("fly-a", &script)).await;
|
||||||
|
let mut driver = rig.driver(&id("fly-a"), &script);
|
||||||
|
driver.initialize(0).await.expect("initialize");
|
||||||
|
let (input, frame) = driver.input(2, 0).await.expect("a frame");
|
||||||
|
let context = driver.context().clone();
|
||||||
|
let params = |prior: &str| {
|
||||||
|
AgentRollbackParams {
|
||||||
|
agent_id: id("fly-a"),
|
||||||
|
prior_epoch: id(prior),
|
||||||
|
policy: ROLLBACK_POLICY.to_owned(),
|
||||||
|
input: input.clone(),
|
||||||
|
decision_context: context.clone(),
|
||||||
|
}
|
||||||
|
.to_json()
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Rollback",
|
||||||
|
Some(scope_at("legacy", "e3", 0)),
|
||||||
|
params("e2"),
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::StaleEpoch,
|
||||||
|
"the prior epoch is not the one this worker is in"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
code(
|
||||||
|
driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Rollback",
|
||||||
|
Some(scope_at("legacy", "e1", 0)),
|
||||||
|
params("e0"),
|
||||||
|
&[("view.lcd", &frame)]
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
),
|
||||||
|
ErrorCode::StaleEpoch,
|
||||||
|
"a rollback moves to a new epoch"
|
||||||
|
);
|
||||||
|
let first = driver
|
||||||
|
.call_raw(
|
||||||
|
"Agent.Rollback",
|
||||||
|
Some(scope_at("legacy", "e2", 0)),
|
||||||
|
params("e1"),
|
||||||
|
&[("view.lcd", &frame)],
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("a rollback");
|
||||||
|
first.result().expect("applied");
|
||||||
|
let replay = driver
|
||||||
|
.retry_raw(
|
||||||
|
first.request_id.clone(),
|
||||||
|
"Agent.Rollback",
|
||||||
|
Some(scope_at("legacy", "e2", 0)),
|
||||||
|
params("e1"),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("a replay of the same rollback");
|
||||||
|
assert_eq!(
|
||||||
|
replay.result().expect("replayed"),
|
||||||
|
first.result().expect("applied"),
|
||||||
|
"a lost reply replays, it does not roll back twice"
|
||||||
|
);
|
||||||
|
|
||||||
|
// A capture restored with someone else's compatibility is refused before staging.
|
||||||
|
driver.bump_epoch();
|
||||||
|
let captured = driver.capture().await.expect("capture");
|
||||||
|
let target = rig.replace(&id("fly-a")).await.expect("a replacement");
|
||||||
|
let mut forged = captured.result.clone();
|
||||||
|
forged.compatibility_digest = digest_of_bytes(b"another fly");
|
||||||
|
let forged = legacy_parity::Captured {
|
||||||
|
result: forged,
|
||||||
|
artifact: captured.artifact.clone(),
|
||||||
|
bytes: captured.bytes.clone(),
|
||||||
|
scope: captured.scope.clone(),
|
||||||
|
};
|
||||||
|
let refused = driver
|
||||||
|
.restore_into(target, &forged)
|
||||||
|
.await
|
||||||
|
.expect_err("another fly's compatibility");
|
||||||
|
assert!(refused.contains("IncompatibleState"), "{refused}");
|
||||||
|
rig.stop().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The real dataset, an explicit job: `FLY_AGENT01_FAFB=1` with `data/fafb-v783` checked out.
|
||||||
|
/// Release mode is the sensible way to run it.
|
||||||
|
mod fafb {
|
||||||
|
use super::*;
|
||||||
|
use fly_session::legacy_parity::{RewardEvent, ScriptStep, fafb_dir, frame_pool};
|
||||||
|
use fly_session_types::gameboy::{Location, ReadoutContext};
|
||||||
|
|
||||||
|
fn enabled() -> Option<std::path::PathBuf> {
|
||||||
|
if std::env::var_os("FLY_AGENT01_FAFB").is_none() {
|
||||||
|
eprintln!("skipping: FLY_AGENT01_FAFB is not set");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let dir = fafb_dir();
|
||||||
|
if dir.is_none() {
|
||||||
|
eprintln!("skipping: data/fafb-v783 is not present in this checkout");
|
||||||
|
}
|
||||||
|
dir
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pokered_channels() -> Vec<String> {
|
||||||
|
let file =
|
||||||
|
fly_session_types::fixtures::load("gameboy-decoder-config.json").expect("vectors");
|
||||||
|
file["cases"][1]["macroChannels"]
|
||||||
|
.as_array()
|
||||||
|
.expect("the Pokemon Red macro group")
|
||||||
|
.iter()
|
||||||
|
.map(|c| c.as_str().expect("a channel").to_owned())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The live macros-mode composition's shape on the real connectome, with recorded inputs.
|
||||||
|
fn script(frames: usize) -> LegacyScript {
|
||||||
|
let channels = pokered_channels();
|
||||||
|
let bound = |k: usize| -> Vec<String> {
|
||||||
|
let take: &[usize] = match k {
|
||||||
|
0..20 => &[],
|
||||||
|
20..50 => &[0, 1, 9],
|
||||||
|
_ => &[1, 4, 5, 6],
|
||||||
|
};
|
||||||
|
take.iter().map(|i| channels[*i].clone()).collect()
|
||||||
|
};
|
||||||
|
let mut steps = Vec::new();
|
||||||
|
for k in 1..=frames {
|
||||||
|
steps.push(ScriptStep::Frame {
|
||||||
|
sugar: if k == 12 { vec![400.0] } else { vec![] },
|
||||||
|
frame: k % 6,
|
||||||
|
rewards: if k % 11 == 0 {
|
||||||
|
vec![RewardEvent {
|
||||||
|
value: 0.5,
|
||||||
|
stimulation_ms: 120.0,
|
||||||
|
}]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
},
|
||||||
|
next_context: ReadoutContext {
|
||||||
|
boot: k < 10,
|
||||||
|
bound: bound(k),
|
||||||
|
location: (k > 5).then_some(Location {
|
||||||
|
area: 12,
|
||||||
|
x: 3 + (k / 40) as u32,
|
||||||
|
y: 7,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if k == 60 {
|
||||||
|
steps.push(ScriptStep::Rollback {
|
||||||
|
frame: 2,
|
||||||
|
context: ReadoutContext {
|
||||||
|
boot: false,
|
||||||
|
bound: bound(k),
|
||||||
|
location: None,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if k == 75 {
|
||||||
|
steps.push(ScriptStep::Restore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let last = steps.len() - 1;
|
||||||
|
LegacyScript {
|
||||||
|
name: "fafb-macros".to_owned(),
|
||||||
|
macro_channels: channels,
|
||||||
|
frames: Arc::new(frame_pool(6, 783)),
|
||||||
|
initial_frame: 0,
|
||||||
|
initial_context: ReadoutContext {
|
||||||
|
boot: true,
|
||||||
|
bound: vec![],
|
||||||
|
location: None,
|
||||||
|
},
|
||||||
|
steps,
|
||||||
|
checkpoints: [30, last].into_iter().collect(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The tracked rate roles on the committed dataset are the fixture's list, and each is
|
||||||
|
/// published as itself (`legacy-rate-role-id-v1`).
|
||||||
|
#[test]
|
||||||
|
fn the_fafb_rate_roles_are_the_fixture_list() {
|
||||||
|
let Some(dir) = enabled() else { return };
|
||||||
|
let dataset = Arc::new(load_brain_dataset_from_dir(&dir).expect("the dataset loads"));
|
||||||
|
let config = flybrain_core::agent::AgentConfig::with_decoder(
|
||||||
|
flybrain_core::decoder::gameboy::gameboy_decoder_config(),
|
||||||
|
);
|
||||||
|
let agent = flybrain_core::agent::NeuralAgent::new(dataset, config).expect("the agent");
|
||||||
|
let tracked: Vec<String> = agent.network.rates.keys().cloned().collect();
|
||||||
|
let file = fly_session_types::fixtures::load("gameboy-rate-roles.json").expect("fixture");
|
||||||
|
let want: Vec<String> = file["fafbTrackedRoles"]
|
||||||
|
.as_array()
|
||||||
|
.expect("list")
|
||||||
|
.iter()
|
||||||
|
.map(|v| v.as_str().expect("a name").to_owned())
|
||||||
|
.collect();
|
||||||
|
assert_eq!(tracked, want);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Recorded inputs through the worker (in-process and as a process) against `NeuralAgent`
|
||||||
|
/// driven directly, on `gameboy-legacy-fafb-v783-v1` itself.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn the_fafb_scenario_matches_the_direct_reference() {
|
||||||
|
let Some(dir) = enabled() else { return };
|
||||||
|
let script = script(90);
|
||||||
|
let started = std::time::Instant::now();
|
||||||
|
let dataset = Arc::new(load_brain_dataset_from_dir(&dir).expect("the dataset loads"));
|
||||||
|
let want = DirectSource { dataset }
|
||||||
|
.records(&script)
|
||||||
|
.expect("the reference runs");
|
||||||
|
eprintln!(
|
||||||
|
"reference: {} records in {:?}",
|
||||||
|
want.len(),
|
||||||
|
started.elapsed()
|
||||||
|
);
|
||||||
|
let summary = legacy_parity::golden_json(&script, &want);
|
||||||
|
eprintln!("reference digest {}", summary["digest"]);
|
||||||
|
for mode in [ExecutionMode::InProcess, ExecutionMode::Process] {
|
||||||
|
let started = std::time::Instant::now();
|
||||||
|
let root = tempfile::tempdir().expect("tmp");
|
||||||
|
let agent = RigAgent {
|
||||||
|
agent_id: id("fly-a"),
|
||||||
|
port_id: id("p1"),
|
||||||
|
dataset_dir: dir.clone(),
|
||||||
|
profile: LegacyProfileKind::Production,
|
||||||
|
macro_channels: script.macro_channels.clone(),
|
||||||
|
worker_threads: 1,
|
||||||
|
};
|
||||||
|
let mut rig = LegacyRig::start(root.path(), mode, &[agent])
|
||||||
|
.await
|
||||||
|
.expect("the rig");
|
||||||
|
let got = legacy_parity::run_on_worker(&mut rig, &id("fly-a"), &script)
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| panic!("{}: {e}", mode.label()));
|
||||||
|
rig.stop().await;
|
||||||
|
legacy_parity::compare(&want, &got).unwrap_or_else(|e| panic!("{}: {e}", mode.label()));
|
||||||
|
eprintln!(
|
||||||
|
"{}: {} records identical in {:?}",
|
||||||
|
mode.label(),
|
||||||
|
got.len(),
|
||||||
|
started.elapsed()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for row in summary["rows"].as_array().expect("rows").iter().step_by(10) {
|
||||||
|
eprintln!(" {}", row.as_str().expect("a row"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// FND-01's `FLY_TRACE` reader and check, without a ROM: a trace written in flysim's line shape
|
||||||
|
/// from the reference's own records is accepted, and each kind of disagreement is refused. The
|
||||||
|
/// real traces are `flysim/tests/agent_trace_parity.rs`.
|
||||||
|
mod frame_trace {
|
||||||
|
use super::*;
|
||||||
|
use fly_session::legacy_parity::{
|
||||||
|
ScriptStep, check_against_trace, read_frame_trace, toy_raw_script, trace_rates_digest,
|
||||||
|
};
|
||||||
|
use fly_session::types::{DomainType, digest_of_bytes};
|
||||||
|
use flybrain_core::decoder::gameboy::GAMEBOY_BUTTONS;
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
/// `flysim::trace` lines for a script and its records.
|
||||||
|
fn trace_of(script: &LegacyScript, records: &[ParityRecord]) -> Vec<Value> {
|
||||||
|
let mut lines: Vec<Value> = Vec::new();
|
||||||
|
for (index, step) in script.steps.iter().enumerate() {
|
||||||
|
let record = &records[index + 1];
|
||||||
|
match step {
|
||||||
|
ScriptStep::Frame {
|
||||||
|
sugar,
|
||||||
|
frame,
|
||||||
|
rewards,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
let decision = record.decision.as_ref().expect("a decision");
|
||||||
|
let mut active: Vec<&str> = GAMEBOY_BUTTONS
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter(|(bit, _)| decision.buttons[*bit])
|
||||||
|
.map(|(_, name)| *name)
|
||||||
|
.collect();
|
||||||
|
if let Some(channel) = &decision.macro_channel {
|
||||||
|
active.push(channel);
|
||||||
|
}
|
||||||
|
lines.push(json!({
|
||||||
|
"behaviour": {
|
||||||
|
"step": (lines.len() as u64).to_string(),
|
||||||
|
"admissions": sugar.iter().map(|d| json!({"kind": "sugar", "durationMs": d})).collect::<Vec<_>>(),
|
||||||
|
"ticksAdvanced": record.ticks.to_string(),
|
||||||
|
"brainTicks": record.brain_ticks.to_string(),
|
||||||
|
"remainder": record.remainder.to_json(),
|
||||||
|
"ratesDigest": trace_rates_digest(record.telemetry.as_ref().expect("telemetry")).expect("rates"),
|
||||||
|
"spikesDigest": record.spikes.clone().expect("spikes"),
|
||||||
|
"spikeCount": 0,
|
||||||
|
"decision": active,
|
||||||
|
"mask": decision.mask(),
|
||||||
|
"macroEvents": [],
|
||||||
|
"framebufferDigest": digest_of_bytes(&script.frames[*frame]),
|
||||||
|
"wramDigest": "",
|
||||||
|
"rewards": rewards.iter().map(|r| json!({"kind": "toy", "value": r.value, "stimulationMs": r.stimulation_ms})).collect::<Vec<_>>(),
|
||||||
|
"rank": 0,
|
||||||
|
"acknowledgedBoundary": (lines.len() as u64 + 1).to_string(),
|
||||||
|
"boundaryActions": [],
|
||||||
|
},
|
||||||
|
"operational": {"captures": []},
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
ScriptStep::Rollback { .. } => {
|
||||||
|
let last = lines.last_mut().expect("a frame before the rollback");
|
||||||
|
last["behaviour"]["boundaryActions"]
|
||||||
|
.as_array_mut()
|
||||||
|
.expect("a list")
|
||||||
|
.push(json!({"kind": "rollback", "slotId": "best", "stateDigest": null}));
|
||||||
|
}
|
||||||
|
ScriptStep::Restore => unreachable!("the raw script has no restore"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lines
|
||||||
|
}
|
||||||
|
|
||||||
|
fn text(lines: &[Value]) -> String {
|
||||||
|
let mut out = json!({"format": "flysim-legacy-frame-trace-v1"}).to_string();
|
||||||
|
out.push('\n');
|
||||||
|
out.push_str(&json!({"boundary": "0", "operational": {"captures": [{"checkpointId": "g1", "afterActions": 0}]}}).to_string());
|
||||||
|
for line in lines {
|
||||||
|
out.push('\n');
|
||||||
|
out.push_str(&line.to_string());
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_trace_of_the_reference_checks_and_every_disagreement_is_refused() {
|
||||||
|
let script = toy_raw_script(80);
|
||||||
|
let records = reference(&script);
|
||||||
|
let lines = trace_of(&script, &records);
|
||||||
|
let trace = read_frame_trace(&text(&lines)).expect("the trace reads");
|
||||||
|
assert_eq!(trace.len(), 80);
|
||||||
|
let check = check_against_trace(&script, &records, &trace).expect("the reference checks");
|
||||||
|
assert_eq!(
|
||||||
|
(check.transitions, check.sugar, check.rollbacks),
|
||||||
|
(80, 1, 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
let refused = |edit: &dyn Fn(&mut Vec<Value>)| {
|
||||||
|
let mut lines = lines.clone();
|
||||||
|
edit(&mut lines);
|
||||||
|
let trace = read_frame_trace(&text(&lines)).expect("the trace reads");
|
||||||
|
check_against_trace(&script, &records, &trace).expect_err("a disagreement")
|
||||||
|
};
|
||||||
|
let e = refused(&|l| l[30]["behaviour"]["spikesDigest"] = json!("00"));
|
||||||
|
assert!(e.contains("spikesDigest"), "{e}");
|
||||||
|
let e = refused(&|l| l[30]["behaviour"]["brainTicks"] = json!("1"));
|
||||||
|
assert!(e.contains("brainTicks"), "{e}");
|
||||||
|
let e = refused(&|l| {
|
||||||
|
l[30]["behaviour"]["remainder"] = json!({"numerator": "0", "denominator": "1"})
|
||||||
|
});
|
||||||
|
assert!(e.contains("remainder"), "{e}");
|
||||||
|
let e = refused(&|l| l[30]["behaviour"]["ratesDigest"] = json!("00"));
|
||||||
|
assert!(e.contains("ratesDigest"), "{e}");
|
||||||
|
let e = refused(&|l| l[30]["behaviour"]["decision"] = json!(["select"]));
|
||||||
|
assert!(e.contains("decision"), "{e}");
|
||||||
|
let e = refused(&|l| l[9]["behaviour"]["admissions"] = json!([]));
|
||||||
|
assert!(e.contains("admitted"), "{e}");
|
||||||
|
let e = refused(&|l| {
|
||||||
|
l[9]["behaviour"]["admissions"] = json!([{"kind": "reward", "value": 1.0}])
|
||||||
|
});
|
||||||
|
assert!(e.contains("RewardPulse"), "{e}");
|
||||||
|
let e = refused(&|l| l[5]["behaviour"]["framebufferDigest"] = json!("00"));
|
||||||
|
assert!(e.contains("frame"), "{e}");
|
||||||
|
let e = refused(&|l| {
|
||||||
|
for line in l.iter_mut() {
|
||||||
|
line["behaviour"]["boundaryActions"] = json!([]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assert!(e.contains("rollback"), "{e}");
|
||||||
|
let e = refused(&|l| {
|
||||||
|
l.pop();
|
||||||
|
});
|
||||||
|
assert!(e.contains("ended"), "{e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -55,6 +55,9 @@ unicode-normalization = "0.1"
|
||||||
# The legacy profile's pinned identities (`tests/legacy_profile_identity.rs`): test-only, so the
|
# The legacy profile's pinned identities (`tests/legacy_profile_identity.rs`): test-only, so the
|
||||||
# service itself does not link the session types.
|
# service itself does not link the session types.
|
||||||
fly-session-types = { path = "../fly-session-types" }
|
fly-session-types = { path = "../fly-session-types" }
|
||||||
|
# AGENT-01's worker checked against this loop's FLY_TRACE (`tests/agent_trace_parity.rs`):
|
||||||
|
# test-only as well. fly-session does not depend on flysim, so this is no cycle.
|
||||||
|
fly-session = { path = "../fly-session" }
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
# `default-features = false` drops the remote-reference resolver (and with it reqwest and a
|
# `default-features = false` drops the remote-reference resolver (and with it reqwest and a
|
||||||
# TLS stack): `packages/feed/src/schema.json` is self-contained, so nothing has to be fetched.
|
# TLS stack): `packages/feed/src/schema.json` is self-contained, so nothing has to be fetched.
|
||||||
|
|
|
||||||
422
services/flysim/crates/flysim/tests/agent_trace_parity.rs
Normal file
422
services/flysim/crates/flysim/tests/agent_trace_parity.rs
Normal file
|
|
@ -0,0 +1,422 @@
|
||||||
|
//! AGENT-01 against FND-01: the legacy agent worker, and the direct reference, checked against the
|
||||||
|
//! `FLY_TRACE` of the legacy frame the stream runs (`flysim::frame::LegacyFrame`).
|
||||||
|
//!
|
||||||
|
//! The trace records what the loop did to the brain as digests -- ticks, clock, exact remainder,
|
||||||
|
//! rates, the spike set, the decision -- but not everything a worker needs to be driven: the
|
||||||
|
//! frames (only their digests), and the `{boot, bound, location}` context the executor and the
|
||||||
|
//! adapter produced. So this test is the host: it runs `LegacyFrame` on the real emulator with the
|
||||||
|
//! trace on, records those inputs beside it as a `LegacyScript`, then drives the same script
|
||||||
|
//! through `LegacyAgentWorker` in every execution mode and through `DirectReference`, and holds
|
||||||
|
//! each record to its trace line (`fly_session::legacy_parity::check_against_trace`). The script
|
||||||
|
//! is checked against the trace as well: the same admissions, frames, reward events and rollback.
|
||||||
|
//!
|
||||||
|
//! Two runs, both explicit ROM jobs (`. bin/rom-env.sh`, never a download):
|
||||||
|
//!
|
||||||
|
//! - `toy_raw_from_power_on`: `FLY_ROM` only. The committed toy connectome in raw mode from
|
||||||
|
//! power-on, with two sugar admissions. Cheap enough for every ROM run of the workspace.
|
||||||
|
//! - `fafb_macros_from_a_checkpoint`: also `FLY_AGENT01_FAFB=1` and `data/fafb-v783`. The live
|
||||||
|
//! composition -- `gameboy-legacy-fafb-v783-v1`, macros mode -- restored from a stream
|
||||||
|
//! checkpoint (`FLY_AGENT01_TRACE_CHECKPOINT`, else `FLY_DOOR_CHECKPOINT`), with sugar and one
|
||||||
|
//! ratchet rollback onto the checkpoint's slot. The worker starts from the checkpoint's agent
|
||||||
|
//! state (`AgentDriver::seed_from_legacy_state`).
|
||||||
|
//!
|
||||||
|
//! `FLY_AGENT01_TRACE_FRAMES` sets the length (default 600 toy, 240 FAFB). The worker program for
|
||||||
|
//! process mode is the workspace's `fly-session` binary; a build that did not produce it skips
|
||||||
|
//! that mode and says so.
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use fly_session::ExecutionMode;
|
||||||
|
use fly_session::fly_session_types::gameboy::{Location, ReadoutContext};
|
||||||
|
use fly_session::legacy_agent::LegacyProfileKind;
|
||||||
|
use fly_session::legacy_parity::{
|
||||||
|
self, DirectSource, LegacyRig, LegacyScript, ParityRecord, ReferenceSource, RestoredSource,
|
||||||
|
RewardEvent, RigAgent, ScriptStep, TraceCheck, TraceTransition, toy,
|
||||||
|
};
|
||||||
|
use fly_session::types::{digest_of_bytes, id};
|
||||||
|
use flybrain_core::agent::{AgentConfig, AgentState, NeuralAgent};
|
||||||
|
use flybrain_core::dataset::{BrainDataset, load_brain_dataset_from_dir};
|
||||||
|
use flybrain_core::decoder::gameboy::gameboy_decoder_config_with_macros;
|
||||||
|
use flybrain_gb::adapter::GameAdapter;
|
||||||
|
use flybrain_gb::pokemon_red::PokemonRedReward;
|
||||||
|
use flybrain_gb::ratchet::Ratchet;
|
||||||
|
use flybrain_gb::{AdapterLedger, DEFAULT_AUDIO_FRAMES, DEFAULT_AUDIO_FREQUENCY, Emulator};
|
||||||
|
use flysim::config::Config;
|
||||||
|
use flysim::frame::{LegacyFrame, Parts};
|
||||||
|
use flysim::macros::{MacroLayer, macro_layer};
|
||||||
|
use flysim::snapshot::MacroMode;
|
||||||
|
use flysim::trace::FrameTrace;
|
||||||
|
|
||||||
|
fn rom() -> Option<Vec<u8>> {
|
||||||
|
let Some(path) = std::env::var_os("FLY_ROM") else {
|
||||||
|
eprintln!("skipping: FLY_ROM is not set (source bin/rom-env.sh)");
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
Some(std::fs::read(&path).unwrap_or_else(|e| panic!("FLY_ROM {path:?}: {e}")))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn frames(default: usize) -> usize {
|
||||||
|
std::env::var("FLY_AGENT01_TRACE_FRAMES")
|
||||||
|
.ok()
|
||||||
|
.and_then(|v| v.parse().ok())
|
||||||
|
.unwrap_or(default)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn context(adapter: &dyn GameAdapter, macros: Option<&MacroLayer>) -> ReadoutContext {
|
||||||
|
ReadoutContext {
|
||||||
|
boot: adapter.boot(),
|
||||||
|
bound: macros.map(MacroLayer::bound_channels).unwrap_or_default(),
|
||||||
|
location: adapter
|
||||||
|
.location()
|
||||||
|
.map(|(area, x, y)| Location { area, x, y }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Frames by content, so a still screen is stored once.
|
||||||
|
#[derive(Default)]
|
||||||
|
struct Pool {
|
||||||
|
frames: Vec<Vec<u8>>,
|
||||||
|
index: HashMap<String, usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pool {
|
||||||
|
fn add(&mut self, frame: &[u8]) -> usize {
|
||||||
|
let digest = digest_of_bytes(frame);
|
||||||
|
*self.index.entry(digest).or_insert_with(|| {
|
||||||
|
self.frames.push(frame.to_vec());
|
||||||
|
self.frames.len() - 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How the legacy run starts.
|
||||||
|
enum Start<'a> {
|
||||||
|
/// `LegacyFrame::initialize`: one frame with no button, then the warm-up on it.
|
||||||
|
PowerOn,
|
||||||
|
/// `LegacyFrame::restore` from a stream checkpoint, as `Sim::try_restore` does.
|
||||||
|
Checkpoint(&'a flysim::store::Checkpoint),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LegacyRun {
|
||||||
|
script: LegacyScript,
|
||||||
|
trace: Vec<TraceTransition>,
|
||||||
|
/// The agent state the run started from, for a restored start.
|
||||||
|
start: Option<AgentState>,
|
||||||
|
rewards: Vec<&'static str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The stream's frame on the real emulator with `FLY_TRACE` on, recording the script beside it.
|
||||||
|
///
|
||||||
|
/// Sugar is admitted the way `Sim::stimulate` admits it (stimulate, then the trace), at the top of
|
||||||
|
/// the frame. `rollback_at` forces the ratchet's rollback at that boundary when the ratchet holds a
|
||||||
|
/// slot and did not roll back itself: `LegacyFrame::rollback` is exactly what `boundary` runs when
|
||||||
|
/// the ratchet fires, and whether it fires is the task's decision, not the agent's.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
fn run_legacy(
|
||||||
|
rom: &[u8],
|
||||||
|
data: &Arc<BrainDataset>,
|
||||||
|
start: Start<'_>,
|
||||||
|
mode: MacroMode,
|
||||||
|
frames: usize,
|
||||||
|
sugar: &[(usize, f64)],
|
||||||
|
rollback_at: Option<usize>,
|
||||||
|
trace_path: &Path,
|
||||||
|
) -> LegacyRun {
|
||||||
|
let mut emulator = Emulator::new(rom, DEFAULT_AUDIO_FREQUENCY, DEFAULT_AUDIO_FRAMES)
|
||||||
|
.expect("binjgb should accept the cartridge");
|
||||||
|
let mut adapter = PokemonRedReward::new();
|
||||||
|
let mut ratchet = Ratchet::with_policy(adapter.recovery_policy());
|
||||||
|
let mut config = Config::default();
|
||||||
|
config.loop_.game = "pokemon-red".to_string();
|
||||||
|
config.macros.mode = mode;
|
||||||
|
let channels = if mode.dealt() {
|
||||||
|
flybrain_gb::macro_channels("pokemon-red")
|
||||||
|
} else {
|
||||||
|
Vec::new()
|
||||||
|
};
|
||||||
|
let preset = gameboy_decoder_config_with_macros(&channels);
|
||||||
|
let hold_ms = preset
|
||||||
|
.macros
|
||||||
|
.as_ref()
|
||||||
|
.or(preset.exclusive.as_ref())
|
||||||
|
.expect("the preset has a group")
|
||||||
|
.hold_ms;
|
||||||
|
let mut agent_config = AgentConfig::with_decoder(preset);
|
||||||
|
agent_config.warmup_ms = config.loop_.warmup_ms;
|
||||||
|
assert_eq!(
|
||||||
|
config.loop_.warmup_ms,
|
||||||
|
fly_session::fly_session_types::gameboy::WARMUP_MS,
|
||||||
|
"the stream's warm-up is the profile's"
|
||||||
|
);
|
||||||
|
let mut agent = NeuralAgent::new(Arc::clone(data), agent_config).expect("a valid agent");
|
||||||
|
let mut frame =
|
||||||
|
LegacyFrame::new().with_trace(Some(FrameTrace::create(trace_path).expect("a trace file")));
|
||||||
|
let start_state = match start {
|
||||||
|
Start::PowerOn => {
|
||||||
|
frame
|
||||||
|
.initialize(&mut emulator, &mut agent)
|
||||||
|
.expect("the first frame and the warm-up");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
Start::Checkpoint(checkpoint) => {
|
||||||
|
frame
|
||||||
|
.restore(
|
||||||
|
&mut Parts {
|
||||||
|
agent: &mut agent,
|
||||||
|
emulator: &mut emulator,
|
||||||
|
adapter: &mut adapter,
|
||||||
|
ratchet: &mut ratchet,
|
||||||
|
macros: None,
|
||||||
|
},
|
||||||
|
checkpoint,
|
||||||
|
)
|
||||||
|
.expect("the checkpoint should restore");
|
||||||
|
Some(checkpoint.agent.clone())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// `Sim::boot`: the macro layer is built after the restore or warm-up, seeded from the network
|
||||||
|
// as it then stands, and observes once before the first frame.
|
||||||
|
let mut macros = macro_layer(&config, hold_ms, agent.network.rng_state() as u32);
|
||||||
|
if let Some(layer) = macros.as_mut() {
|
||||||
|
let ledger = AdapterLedger(&adapter);
|
||||||
|
let _ = layer.observe(&mut emulator, &ledger, agent.network.ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut pool = Pool::default();
|
||||||
|
let initial_frame = pool.add(&frame.frame_buffer);
|
||||||
|
let initial_context = context(&adapter, macros.as_ref());
|
||||||
|
let mut steps = Vec::new();
|
||||||
|
let mut kinds = Vec::new();
|
||||||
|
for k in 1..=frames {
|
||||||
|
let mut admitted = Vec::new();
|
||||||
|
for (_, duration) in sugar.iter().filter(|(at, _)| *at == k) {
|
||||||
|
agent.network.stimulate(*duration);
|
||||||
|
if let Some(trace) = frame.trace_mut() {
|
||||||
|
trace.sugar(*duration);
|
||||||
|
}
|
||||||
|
admitted.push(*duration);
|
||||||
|
}
|
||||||
|
let mut parts = Parts {
|
||||||
|
agent: &mut agent,
|
||||||
|
emulator: &mut emulator,
|
||||||
|
adapter: &mut adapter,
|
||||||
|
ratchet: &mut ratchet,
|
||||||
|
macros: macros.as_mut(),
|
||||||
|
};
|
||||||
|
let transition = frame.transition(&mut parts, &mut ()).expect("a frame");
|
||||||
|
let produced = pool.add(&frame.frame_buffer);
|
||||||
|
let rewards: Vec<RewardEvent> = transition
|
||||||
|
.evaluated
|
||||||
|
.rewards
|
||||||
|
.iter()
|
||||||
|
.map(|event| {
|
||||||
|
kinds.push(event.kind);
|
||||||
|
RewardEvent {
|
||||||
|
value: event.value,
|
||||||
|
stimulation_ms: f64::from(event.stimulation_ms),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
// The next context is read after the evaluation and before the ratchet: what the task
|
||||||
|
// hands `Agent.Commit`.
|
||||||
|
let next_context = context(&*parts.adapter, parts.macros.as_deref());
|
||||||
|
let boundary = frame
|
||||||
|
.boundary(&mut parts, &transition.evaluated.progress, transition.ms)
|
||||||
|
.expect("the boundary");
|
||||||
|
steps.push(ScriptStep::Frame {
|
||||||
|
sugar: admitted,
|
||||||
|
frame: produced,
|
||||||
|
rewards,
|
||||||
|
next_context,
|
||||||
|
});
|
||||||
|
let mut rolled_back = boundary.rollback.is_some();
|
||||||
|
if !rolled_back && rollback_at == Some(k) && parts.ratchet.game().is_some() {
|
||||||
|
frame.rollback(&mut parts).expect("the forced rollback");
|
||||||
|
rolled_back = true;
|
||||||
|
}
|
||||||
|
if rolled_back {
|
||||||
|
let restored = pool.add(&frame.frame_buffer);
|
||||||
|
steps.push(ScriptStep::Rollback {
|
||||||
|
frame: restored,
|
||||||
|
context: context(&*parts.adapter, parts.macros.as_deref()),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frame.finish_trace();
|
||||||
|
drop(frame);
|
||||||
|
let text = std::fs::read_to_string(trace_path).expect("the trace reads back");
|
||||||
|
let trace = legacy_parity::read_frame_trace(&text).expect("a flysim-legacy-frame-trace-v1");
|
||||||
|
LegacyRun {
|
||||||
|
script: LegacyScript {
|
||||||
|
name: format!("flysim-{}", mode.as_str()),
|
||||||
|
macro_channels: channels.iter().map(|c| (*c).to_owned()).collect(),
|
||||||
|
frames: Arc::new(pool.frames),
|
||||||
|
initial_frame,
|
||||||
|
initial_context,
|
||||||
|
steps,
|
||||||
|
checkpoints: Default::default(),
|
||||||
|
},
|
||||||
|
trace,
|
||||||
|
start: start_state,
|
||||||
|
rewards: kinds,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn worker_modes() -> Vec<ExecutionMode> {
|
||||||
|
let mut modes = vec![ExecutionMode::InProcess, ExecutionMode::Thread];
|
||||||
|
let program = fly_session::launcher::default_worker_program();
|
||||||
|
if program.is_file() {
|
||||||
|
modes.push(ExecutionMode::Process);
|
||||||
|
} else {
|
||||||
|
eprintln!(
|
||||||
|
"process mode skipped: no worker program at {} (build the fly-session binary, or set {})",
|
||||||
|
program.display(),
|
||||||
|
fly_session::launcher::WORKER_PROGRAM_ENV
|
||||||
|
);
|
||||||
|
}
|
||||||
|
modes
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn on_worker(
|
||||||
|
mode: ExecutionMode,
|
||||||
|
run: &LegacyRun,
|
||||||
|
dataset_dir: PathBuf,
|
||||||
|
profile: LegacyProfileKind,
|
||||||
|
) -> Vec<ParityRecord> {
|
||||||
|
let root = tempfile::tempdir().expect("tmp");
|
||||||
|
let agent = RigAgent {
|
||||||
|
agent_id: id("fly"),
|
||||||
|
port_id: id("p1"),
|
||||||
|
dataset_dir,
|
||||||
|
profile,
|
||||||
|
macro_channels: run.script.macro_channels.clone(),
|
||||||
|
worker_threads: 1,
|
||||||
|
};
|
||||||
|
let mut rig = LegacyRig::start(root.path(), mode, &[agent])
|
||||||
|
.await
|
||||||
|
.expect("the rig");
|
||||||
|
let records =
|
||||||
|
legacy_parity::run_on_worker_from(&mut rig, &id("fly"), &run.script, run.start.as_ref())
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| panic!("{}: {e}", mode.label()));
|
||||||
|
rig.stop().await;
|
||||||
|
records
|
||||||
|
}
|
||||||
|
|
||||||
|
fn report(what: &str, check: &TraceCheck) {
|
||||||
|
eprintln!(
|
||||||
|
"{what}: {} transitions identical to FLY_TRACE ({} sugar, {} reward events, {} rollbacks, \
|
||||||
|
{} macro decisions, {} pressed, {} spikes)",
|
||||||
|
check.transitions,
|
||||||
|
check.sugar,
|
||||||
|
check.rewards,
|
||||||
|
check.rollbacks,
|
||||||
|
check.macro_decisions,
|
||||||
|
check.pressed,
|
||||||
|
check.spikes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_all(
|
||||||
|
run: &LegacyRun,
|
||||||
|
reference: Vec<ParityRecord>,
|
||||||
|
dataset_dir: PathBuf,
|
||||||
|
profile: LegacyProfileKind,
|
||||||
|
) {
|
||||||
|
let check = legacy_parity::check_against_trace(&run.script, &reference, &run.trace)
|
||||||
|
.unwrap_or_else(|e| panic!("the direct reference against FLY_TRACE: {e}"));
|
||||||
|
report("direct reference", &check);
|
||||||
|
for mode in worker_modes() {
|
||||||
|
let started = std::time::Instant::now();
|
||||||
|
let got = on_worker(mode, run, dataset_dir.clone(), profile).await;
|
||||||
|
let worker = legacy_parity::check_against_trace(&run.script, &got, &run.trace)
|
||||||
|
.unwrap_or_else(|e| panic!("{} against FLY_TRACE: {e}", mode.label()));
|
||||||
|
assert_eq!(worker, check);
|
||||||
|
// And record for record, telemetry included, the worker is the reference.
|
||||||
|
legacy_parity::compare(&reference, &got)
|
||||||
|
.unwrap_or_else(|e| panic!("{} against the direct reference: {e}", mode.label()));
|
||||||
|
report(
|
||||||
|
&format!("worker {} ({:?})", mode.label(), started.elapsed()),
|
||||||
|
&worker,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn toy_raw_from_power_on() {
|
||||||
|
let Some(rom) = rom() else { return };
|
||||||
|
let data = Arc::new(load_brain_dataset_from_dir(toy::dir()).expect("the toy dataset"));
|
||||||
|
let dir = tempfile::tempdir().expect("tmp");
|
||||||
|
let n = frames(600);
|
||||||
|
let run = run_legacy(
|
||||||
|
&rom,
|
||||||
|
&data,
|
||||||
|
Start::PowerOn,
|
||||||
|
MacroMode::Raw,
|
||||||
|
n,
|
||||||
|
&[(40, 300.0), (n / 2, 500.0)],
|
||||||
|
None,
|
||||||
|
&dir.path().join("trace.jsonl"),
|
||||||
|
);
|
||||||
|
assert_eq!(run.trace.len(), n);
|
||||||
|
let reference = DirectSource { dataset: data }
|
||||||
|
.records(&run.script)
|
||||||
|
.expect("the direct reference runs");
|
||||||
|
check_all(&run, reference, toy::dir(), LegacyProfileKind::Toy).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn fafb_macros_from_a_checkpoint() {
|
||||||
|
let Some(rom) = rom() else { return };
|
||||||
|
if std::env::var_os("FLY_AGENT01_FAFB").is_none() {
|
||||||
|
eprintln!("skipping: FLY_AGENT01_FAFB is not set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let Some(dataset_dir) = legacy_parity::fafb_dir() else {
|
||||||
|
eprintln!("skipping: data/fafb-v783 is not present in this checkout");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(path) = std::env::var_os("FLY_AGENT01_TRACE_CHECKPOINT")
|
||||||
|
.or_else(|| std::env::var_os("FLY_DOOR_CHECKPOINT"))
|
||||||
|
else {
|
||||||
|
eprintln!("skipping: neither FLY_AGENT01_TRACE_CHECKPOINT nor FLY_DOOR_CHECKPOINT is set");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let checkpoint = flysim::store::load(Path::new(&path)).expect("a FLYSIM01 checkpoint");
|
||||||
|
let data = Arc::new(load_brain_dataset_from_dir(&dataset_dir).expect("the dataset"));
|
||||||
|
let dir = tempfile::tempdir().expect("tmp");
|
||||||
|
let n = frames(240);
|
||||||
|
let started = std::time::Instant::now();
|
||||||
|
let run = run_legacy(
|
||||||
|
&rom,
|
||||||
|
&data,
|
||||||
|
Start::Checkpoint(&checkpoint),
|
||||||
|
MacroMode::Macros,
|
||||||
|
n,
|
||||||
|
&[(10, 400.0), (n / 2, 250.0)],
|
||||||
|
Some(n / 3),
|
||||||
|
&dir.path().join("trace.jsonl"),
|
||||||
|
);
|
||||||
|
eprintln!(
|
||||||
|
"legacy loop: {n} frames from {} in {:?}; reward events {:?}",
|
||||||
|
Path::new(&path).display(),
|
||||||
|
started.elapsed(),
|
||||||
|
run.rewards
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
run.script
|
||||||
|
.steps
|
||||||
|
.iter()
|
||||||
|
.any(|s| matches!(s, ScriptStep::Rollback { .. })),
|
||||||
|
"the checkpoint holds no ratchet slot to roll back onto"
|
||||||
|
);
|
||||||
|
let reference = RestoredSource {
|
||||||
|
dataset: data,
|
||||||
|
state: run.start.clone().expect("a restored start"),
|
||||||
|
}
|
||||||
|
.records(&run.script)
|
||||||
|
.expect("the direct reference runs");
|
||||||
|
check_all(&run, reference, dataset_dir, LegacyProfileKind::Production).await;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue