Docs / Guides / Replay and export a run

Replay and export a run

A recorded run replays offline: swarmlabre replay rebuilds every report file and compares each with its hash. swarmlabre export packs a run into a folder that replays on another machine.

Replay a run#

$ python3 -m swarmlabre replay demo/sfaef16e6
replay takes a run folder, an exported bundle or a run id, which it looks up under runs/ in the state folder. It rebuilds the board and every report file offline, with no model and no Docker, compares each file with the SHA-256 in the manifest and prints the checks as JSON. It exits 0 only when everything is identical, 1 when something differs and 2 when the folder cannot be replayed at all. Reproducibility describes each check. --out DIR also writes the rebuilt files into a folder:
$ python3 -m swarmlabre replay demo/sfaef16e6 --out rebuilt/

The folder then holds the eight output files, which are the ones the manifest names.

The replay levels#

A recorded runa sealed run folderor an exportedbundleIs the sample there?the file input/sampleis in the folder and--no-sample was notgivenfullSample present: theboard's checks run againfrom the recorded inputs,and the sample must be theone the manifest names.downstreamNo sample: the board istaken from the record, andnothing is checked againsta sample.Rebuild and compareThe Reporter'ssummary and everyoutput file arerebuilt and comparedwith the manifest.The result names thelevel. A recorded runa sealed run folder or an exported bundleIs the sample there?the file input/sample is in the folder and--no-sample was not givenfullSample present: theboard's checks runagain from therecorded inputs, andthe sample must be theone the manifestnames.downstreamNo sample: the boardis taken from therecord, and nothing ischecked against asample.Rebuild and compareThe Reporter's summary and every output file arerebuilt and compared with the manifest. The resultnames the level.
The two replay levels. The result of the command names the level that ran, and it never claims more than it checked.
fulldownstream
Whenthe run folder holds input/sample and --no-sample is not giventhe sample is not in the folder, or --no-sample is given
The boardrebuilt from inputs.jsonl: the bytes at each offset, the cited calls, duplicates and caps are checked againtaken from board.jsonl
YARA rulesmatched against the sample againtaken from the record
checks.sampleidentical, or differs from the manifest when the file is another onenot kept
checks.boardidentical or differsa note that the board was taken from the record

Both levels rebuild the Reporter's summary, its lint result and its assessment, rebuild every output file and compare each with the manifest. --no-sample runs a bundle that has the sample at the downstream level:

$ python3 -m swarmlabre replay demo/sfaef16e6 --no-sample

A run exported without its sample also replays at the downstream level. Downstream is the weaker claim and the result says so. With keep_sample = false in the configuration SwarmLabRE deletes the run's copy of the sample once the report is written, and the run can then replay at the downstream level only.

Export a run#

$ python3 -m swarmlabre export demo/sfaef16e6 bundles/
$ python3 -m swarmlabre export demo/sfaef16e6 bundles-full/ --with-sample
export RUN DEST copies what a replay needs into DEST/<run id>/ and prints one JSON line with the folder and whether the sample is in it. The run needs a manifest.json, so a run from before recording cannot be exported. The command stops with exit code 2 when the folder in DEST already exists. The bundle holds:
  • the run record, swarm.json, and manifest.json;
  • the board's inputs and decisions, inputs.jsonl and board.jsonl;
  • layout.json, events.jsonl, detection.json and windows.json;
  • the model trace, model-trace.jsonl.gz, and the run's task key, nonce.key;
  • the prepared files in prep/ and the outputs in out/, so that the bundle can be compared as well as rebuilt;
  • input/sample, only with --with-sample.

The agents' transcripts and thoughts, the container folders and the clip are never copied. A link, a device or a pipe in the folder is skipped, and a folder over 4 GiB or nested deeper than 8 levels is refused. Replay a bundle on any machine with Python 3.12:

$ python3 -m swarmlabre replay bundles/sfaef16e6
$ python3 -m swarmlabre replay bundles-full/sfaef16e6

The first replays at the downstream level and the second at the full level. A bundle with the sample holds a copy of the file you analysed, so share it only with people who may have that file.

The recorded demo run is itself a bundle, and the Pages workflow builds the static demo from it. The web UI shows what the static build does with it.

Watch a replay#

python3 -m swarmlabre serve --replay RUN plays a sealed run folder or a bundle through the web UI, with no model and no Docker. It refuses a recording that does not replay byte for byte. The web UI describes the clock and its options.

Replay through the containers#

$ python3 -m swarmlabre run SAMPLE --replay RUN

This starts the containers as usual and answers every model request from the recorded trace of RUN, using the recorded task key and, unless --brief is given, the recorded brief. It needs Docker and the two images. It makes a new run, so its files differ from the recording in the run id and the times, and the result adds replay_diverged, the number of requests that had no recorded reply. Reproducibility reports what that count was in a measurement.

SwarmLabRE alpha 0.1.0Edit this page on GitHub