Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2c3ccfc
feat(runs): runs export | import, a verified bundle of a run directory
vlad-perevezentsev Dec 1, 2026
e0befaf
docs(runs): indent the import checks as a nested list mkdocs reads
vlad-perevezentsev Dec 1, 2026
98d8986
fix(runs): refuse a bad --as store before runs import writes the run
vlad-perevezentsev Dec 1, 2026
46829bb
test(runs): pin export's refusals, a bundle with no result, a run wit…
vlad-perevezentsev Dec 1, 2026
6316d06
fix(runs): refuse at export a run whose bundle.json import would refuse
vlad-perevezentsev Dec 1, 2026
08f9b51
fix(runs): name the file that makes an existing run differ from the b…
vlad-perevezentsev Dec 1, 2026
a26e805
fix(runs): refuse a bundle that is not a regular file instead of waiting
vlad-perevezentsev Dec 1, 2026
c2ecc42
docs(runs): say the bundle's tar is the same, its gzip bytes only per…
vlad-perevezentsev Dec 1, 2026
94d84af
fix(runs): refuse a bundle.json that lists one path twice
vlad-perevezentsev Dec 1, 2026
86f04c8
fix(runs): refuse a bundle whose run.json lists a second run record
xaleryb Dec 2, 2026
34ddd5a
fix(runs): refuse a bundle that holds a file and a path under it
xaleryb Dec 2, 2026
da1cb5c
fix(runs): refuse two bundle paths that macOS reads as one name
xaleryb Dec 2, 2026
4a9f47e
fix(runs): exit 5 with one line when runs import cannot make results/
xaleryb Dec 2, 2026
d337d51
fix(runs): refuse at export a run whose bundle.json import would not …
xaleryb Dec 2, 2026
f2687a7
test(runs): pin import's refusal of a run.json that does not match it…
xaleryb Dec 2, 2026
4299448
fix(runs): name at export the run directory's files the bundle leaves…
xaleryb Dec 2, 2026
5f75c5e
docs(runs): stop offering the import address as proof of who exported…
xaleryb Dec 2, 2026
488ecca
Merge intel/main into feat/runs-export-import
vlad-perevezentsev Dec 2, 2026
a9609c6
fix(runs): refuse bundle paths and run names Windows cannot write
vlad-perevezentsev Dec 2, 2026
7f3813f
fix(runs): one import at a time looks for a run_id and writes its run
vlad-perevezentsev Dec 2, 2026
85201e4
fix(runs): runs import takes a results/ another import made meanwhile
vlad-perevezentsev Dec 2, 2026
0a960b3
fix(runs): refuse a bundle artifact runs list would not find
vlad-perevezentsev Dec 2, 2026
b09f05f
docs(runs): a pointer runs import --as cannot write exits 5, not 2
vlad-perevezentsev Dec 2, 2026
012a706
fix(runs): refuse CONIN$, CONOUT$ and COM¹-LPT³ as bundle paths
vlad-perevezentsev Dec 2, 2026
b48b6c5
test(runs): pin the exit 2 of a save the store refuses after import
vlad-perevezentsev Dec 2, 2026
11b6ad6
fix(runs): runs list does not read a run an import is still writing
vlad-perevezentsev Dec 2, 2026
c353702
fix(runs): refuse a bundle that spells one directory two ways
vlad-perevezentsev Dec 2, 2026
720d2d1
Merge intel/main into feat/runs-export-import
vlad-perevezentsev Dec 2, 2026
b0ef938
test(cli): the RUN operand of runs export is a run_id, not a path
vlad-perevezentsev Dec 2, 2026
a609097
fix(runs): a tar header tarfile cannot parse is an input error
vlad-perevezentsev Dec 2, 2026
620507d
test(runs): skip the export of a run named con on Windows
vlad-perevezentsev Dec 2, 2026
ebc628a
Merge main into feat/runs-export-import
xaleryb Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Added

- **`runs export` and `runs import`: a run directory moves to another machine
as one checked bundle** (#94 §2.3, R3), so a baseline outlives the CI runner
that made it. `runs export RUN|baseline:NAME > bundle.tgz` writes `run.json`,
the plan, the result and the run's artifacts as a gzipped tar led by
`bundle.json` (new schema `run_bundle.v1`), addressed by the plan's
`plan_digest` and the result's sha256, which `bundle.json` gives the same
on every machine. `runs import bundle.tgz` writes nothing until every member is a
regular file at a path `bundle.json` lists with its sha256, under a 256 MiB
cap, and the run passes its schemas and its plan digest; links, devices,
FIFOs, absolute and `..` paths are refused. The run goes to
`<runs root>/<name or run_id>/`; the same run already there is a no-op, and
another run with its `run_id` exits 2. `--as NAME` points a baseline at it,
with `--expect-previous` as in `runs baseline save` (exit 4 when it moved).
See `docs/runs.md`.
23 changes: 23 additions & 0 deletions dokimi/docs/reference/cli-interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,16 @@
}
}
},
"export": {
"allow_abbrev": true,
"params": [
{"key": "run", "action": "_StoreAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "argument", "nargs": null, "position": 0, "required": true, "type": null},
{"key": "--help/-h", "action": "_HelpAction", "choices": null, "const": null, "default": "==SUPPRESS==", "group_key": null, "group_required": null, "hidden": false, "is_flag": true, "kind": "option", "nargs": 0, "position": null, "required": false, "type": null}
],
"path": "dokimi runs export",
"subcommand_required": null,
"subcommands": {}
},
"gc": {
"allow_abbrev": true,
"params": [
Expand All @@ -1789,6 +1799,19 @@
"subcommand_required": null,
"subcommands": {}
},
"import": {
"allow_abbrev": true,
"params": [
{"key": "bundle", "action": "_StoreAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "argument", "nargs": null, "position": 0, "required": true, "type": null},
{"key": "--as", "action": "_StoreAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": null},
{"key": "--expect-previous", "action": "_StoreAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": null},
{"key": "--help/-h", "action": "_HelpAction", "choices": null, "const": null, "default": "==SUPPRESS==", "group_key": null, "group_required": null, "hidden": false, "is_flag": true, "kind": "option", "nargs": 0, "position": null, "required": false, "type": null},
{"key": "--json", "action": "_StoreTrueAction", "choices": null, "const": true, "default": false, "group_key": null, "group_required": null, "hidden": false, "is_flag": true, "kind": "option", "nargs": 0, "position": null, "required": false, "type": null}
],
"path": "dokimi runs import",
"subcommand_required": null,
"subcommands": {}
},
"list": {
"allow_abbrev": true,
"params": [
Expand Down
3 changes: 2 additions & 1 deletion dokimi/docs/run-directories.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ it still holds a result when the run is stopped part way: a signal, Ctrl-C or
the spend cap ([#94](https://github.com/intel/dokimi/issues/94) §2.3, stage R2).
The module that writes it is `dokimi/runs/rundir.py`. `subjects run` writes
one (see below); the other command families move to it one by one in later
PRs, each with its `--out-dir` and a run name.
PRs, each with its `--out-dir` and a run name. `runs export` and
`runs import` move one to another machine ([runs.md](runs.md#moving-a-run-runs-export-and-runs-import)).

## Layout

Expand Down
106 changes: 102 additions & 4 deletions dokimi/docs/runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
depends_on:
- dokimi/dokimi/runs/**
- dokimi/dokimi/commands/runs.py
- dokimi/dokimi/commands/runs_bundle.py
- dokimi/dokimi/schemas/run_bundle.v1.json
---
<!--
Copyright (C) 2026 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

# The runs root: `runs list`, `runs show`, `runs rm`, `runs gc` and `runs baseline`
# The runs root: `runs list`, `runs show`, `runs rm`, `runs gc`, `runs baseline`, `runs export` and `runs import`

Catalog static receipts (`catalog_eval.v1`) are supported too: the subject is the
catalog root, and `runs show` counts skill rows and problems. Point `DOKIMI_RUNS_DIR`
Expand All @@ -23,8 +25,9 @@ Most commands that run an evaluation write their artifacts under `results/` by
default (a few write elsewhere, listed below). `runs list` shows what is there,
one run's artifacts together, and `runs show` opens one artifact or one run. Both only read files: no model call, no
network access, nothing written. `runs rm` and `runs gc` remove runs from the root
([below](#removing-runs-runs-rm-and-runs-gc)), and `runs baseline` names a run
([baselines](#baselines-runs-baseline-save-list-rm)).
([below](#removing-runs-runs-rm-and-runs-gc)), `runs baseline` names a run
([baselines](#baselines-runs-baseline-save-list-rm)), and `runs export` and `runs import`
move a run directory to another machine ([moving a run](#moving-a-run-runs-export-and-runs-import)).

The runs root is `results/` in the working directory. Set `DOKIMI_RUNS_DIR` to
read another directory.
Expand Down Expand Up @@ -305,6 +308,96 @@ saved baseline skill/a@main -> 20261029T140211Z-3f9a0c1e (1 artifact); before: 2
store: `runs baseline` does not read or change them. `runs gc --keep-baselines`
keeps the runs of both.

## Moving a run: `runs export` and `runs import`

A baseline under `results/` goes with the CI runner that made it. `runs export` writes one
[run directory](run-directories.md) as a file, and `runs import` puts it under the runs root of
another machine, checked first ([#94](https://github.com/intel/dokimi/issues/94) §2.3): a cache
or an artifact store a pull request can write to may hand back a poisoned bundle, so import
trusts none of it.

```text
$ python cli.py runs export baseline:main > baseline.tgz
exported run 20261123T101500Z-1a2b3c4d from nightly-7/: 4 files, 6,954 bytes; plan sha256:6bbd76a2642039efd7b9d8fee6ffe85ec785ee3ec0985f4fc0fcd56c521f2348, result sha256:fc5d04c63d4d8e3d674992d325a34a271c48cf68ffa6d08c9dedfa6d24e9062f
$ python cli.py runs import baseline.tgz --as main # on the next runner
imported run 20261123T101500Z-1a2b3c4d into results/nightly-7/: 4 files, 6,954 bytes; plan sha256:6bbd76a2642039efd7b9d8fee6ffe85ec785ee3ec0985f4fc0fcd56c521f2348, result sha256:fc5d04c63d4d8e3d674992d325a34a271c48cf68ffa6d08c9dedfa6d24e9062f
saved baseline main -> 20261123T101500Z-1a2b3c4d; before: none
```

- **`runs export RUN|baseline:NAME`** writes the bundle of one run to stdout, and what it holds
to stderr. `RUN` is a `run_id` whose artifacts include a `run.json`; `baseline:NAME` is the
run a [baseline](#baselines-runs-baseline-save-list-rm) points to. The bundle holds `run.json`
and every artifact it lists: the plan, the result and the run's own artifacts. An artifact
that carries the `run_id` but that `run.json` does not list (saved outside the directory) is
left out and named (`left out: 1 artifact ...`), and so is any other file in the run directory
that `run.json` does not list, such as a report (`left out: 1 file in the run directory ...`).
It refuses, and writes nothing to stdout, a
run with no `run.json`, more than one, a run without exactly one plan and one result (the
bundle is addressed by them), a listed file that is missing, is not a regular file or leads out
of the run directory, anything an import would refuse (below), a `bundle.json` past its
schema's caps (1000 files, a path of 1024 characters) or over the 1 MiB an import reads, and
a stdout that is a terminal.
- **The bundle** is a gzipped tar: `bundle.json` first (`run_bundle.v1`,
`dokimi/schemas/run_bundle.v1.json`), then the run's files under `run/`. `bundle.json` names
the run (`run_id`, `name`), its address, which is the plan's `plan_digest` and the sha256 of
`result.v1.json` (`result_sha256`), and the sha256 and size of every file. It holds no time,
owner or mode, so the tar of a run is the same each time. The `.tgz` is the same bytes
where the same zlib compresses it; another build (zlib-ng in CPython's Windows builds) may
compress it to other bytes. What stays the same on every machine is `bundle.json`: the
address and each file's sha256.
- **`runs import BUNDLE`** reads the bundle into memory and checks all of it before it writes
anything:

- the members: only regular files, `bundle.json` first, then exactly the files it lists, each
with its sha256 and size. A symlink, a hard link, a directory, a FIFO or a device member, an
absolute path, a `..` segment, a `\`, `:` or another character Windows refuses in a name
(`<>"|?*`), a Windows device name (`CON`, `nul.json`, `CONIN$`, `COM¹`), a segment that ends in `.` or a space, two
paths that differ only in case (one file on Windows and macOS) or in Unicode normalization
(one file on macOS), two spellings of one directory (`Sub/a.json` beside `sub/b.json`), and
a path under another listed path are refused;
- the size: the files together are at most 256 MiB once unpacked, and reading stops there, so
a small file that unpacks to much more is refused, not read;
- the run: `run.json` is a valid `run.v1` with a `run_id`, a name (or `run_id`) that can name
its directory on every platform (no `con`, nothing that ends in `.`), and lists exactly the bundle's
files; each is a valid artifact of the kind it is listed as and carries the run's `run_id`
(an input kind carries none), and is one `runs list` finds (a name that ends in `.json`,
JSON that opens with its `schema_version`, as dokimi writes it), so the run can be exported
again; the result's `plan_digest` is the digest of the plan beside it;
and `bundle.json`'s run and address are the run's.

- **Where it goes**: `<runs root>/<name>`, or `<runs root>/<run_id>` for a run with no name,
as [a run's own directory](run-directories.md#layout) is named. The run is written to a
directory beside it, then renamed into place, so a reader sees all of it or none. From the
look for its `run_id` to the rename it holds `.baselines/.lock` (made when missing), so of two
imports of one run at once the second finds the first's run. `results/`
is made when it is missing (a fresh runner; also when another import makes it meanwhile); a `DOKIMI_RUNS_DIR` that does not exist is
refused. When the run is there already with the same files, nothing is written and the exit
code is 0 (`nothing written`). An import never replaces a run: another run with the bundle's
`run_id` under the root (a file that differs, or one in another place) or a directory of that
name that holds anything exits 2 and leaves them as they are. An import killed part way can
leave the directory it was writing, `.<name>.<hex>.import` beside the run's place; remove it.
No `runs` command reads such a directory, so a run is listed and exported only once it is whole.
- **`--as NAME`** then points the baseline `NAME` at the run, as `runs baseline save NAME RUN`
does, also after an import that wrote nothing. **`--expect-previous RUN_ID`** (with `--as`
only) makes that a compare-and-swap: when `NAME` does not point to `RUN_ID` it exits 4
(`invalid`, `stale_baseline`, with `expected` and `found` under `data`), the pointer is left as
it was, and the run stays imported. A bad `--as` name, one that differs from a saved baseline
only in case, a `.baselines/` that is a link or cannot be locked, and an `--expect-previous`
that is not a run id or comes without `--as` exit 2 before anything is written. Once the run
is written, a save the store refuses (a baseline whose name differs only in case, saved
meanwhile, or a `.baselines/` that can no longer be locked) exits 2, and a pointer that cannot
be written (a full disk) exits 5; both say the run is imported (`run ... is imported, but ...`).
- `--json` prints one `cli_output.v1` document (`kind` `runs import`) with `root`, `run_id`,
`path` (the run's directory, relative to the root), `written`, `files`, `size_bytes`,
`plan_digest`, `result_sha256` and `baseline` (`name` and `previous`, `null` without `--as`)
under `data`.

The bundle proves that its files are the ones the export read, and that they make one valid
run; it does not prove who exported it. The address an import prints covers only the plan and
the result: a bundle whose `run.json` or other artifacts were edited and `bundle.json` re-signed
prints the same one. A workflow that needs to know who exported it keeps the bundle where a
pull request cannot write.

## Exit codes

| Case | Exit |
Expand All @@ -322,10 +415,15 @@ saved baseline skill/a@main -> 20261029T140211Z-3f9a0c1e (1 artifact); before: 2
| `runs baseline save`, `rm`: no root, a name that is not one or differs from a saved one only in case, a `RUN` or `--expect-previous` that is not a run id, a `RUN` no artifact carries, `rm` of a baseline that does not exist, a `.baselines/` that cannot be locked or listed (a file, no permission) or is a link; `runs baseline list`: a `DOKIMI_RUNS_DIR` that does not exist, or a `.baselines/` that cannot be listed or locked (a file, a `.lock` it may not open or that is a link) or is a link | 2 |
| `runs baseline save --expect-previous RUN_ID`: the baseline does not point to `RUN_ID` (the pointer is left as it was) | 4 |
| `runs baseline save`, `rm`: the pointer could not be written or removed | 5 |
| `runs export`: exported; `runs import`: imported, or the run is there already with the same files | 0 |
| `runs export`: no root, a `RUN` that is not a run id or has no run directory (or more than one), a missing baseline, a run without one plan and one result, a listed file that is missing, not a regular file or leads out of the run directory, a run an import would refuse, or a stdout that is a terminal | 2 |
| `runs import`: a file that cannot be read, is not a regular file (a FIFO) or is not a gzipped tar, a member or a run that fails a check (above), a bundle over the size cap, another run with its `run_id` or a directory of its name that holds anything, a `.baselines/` that cannot be locked, a `DOKIMI_RUNS_DIR` that does not exist, a bad `--as` or `--expect-previous`, or `--expect-previous` without `--as` | 2 |
| `runs import --as NAME --expect-previous RUN_ID`: the baseline does not point to `RUN_ID` (the run is imported, the pointer left as it was) | 4 |
| `runs import`: the run or the pointer could not be written | 5 |

On a file system that does not lock (`flock` fails with `ENOLCK`, as on an NFS
mount with no lock daemon), every command that takes `.baselines/.lock` exits 2
(`cannot lock: No locks available`): `save` and `rm`, and while a `.baselines/`
(`cannot lock: No locks available`): `save` and `rm`, `runs import`, and while a `.baselines/`
is there, `list` and `runs gc --keep-baselines`, `--dry-run` too. `list` refuses
rather than read without the lock, since a read it does not hold the lock for
is the one a save on Windows fails on; with no `.baselines/` there is nothing to
Expand Down
1 change: 1 addition & 0 deletions dokimi/dokimi/cli_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Concept:
Flag("--baseline-arm", "NAME", "text"),
Flag("--expect-previous", "RUN_ID", "text",
meaning="save a baseline only while it points to this run (compare-and-swap)"),
Flag("--as", "NAME", "text", meaning="the baseline to point at the run runs import writes"),
),
banned=("--baseline-json", "--plugin-json", "--base"),
),
Expand Down
2 changes: 2 additions & 0 deletions dokimi/dokimi/cli_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ class Tombstone:
Leaf(("runs", "show"), FREE),
Leaf(("runs", "rm"), FREE),
Leaf(("runs", "gc"), FREE),
Leaf(("runs", "export"), FREE),
Leaf(("runs", "import"), FREE),
Leaf(("runs", "baseline", "save"), FREE),
Leaf(("runs", "baseline", "list"), FREE),
Leaf(("runs", "baseline", "rm"), FREE),
Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/commands/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pathlib import Path

from dokimi import cli_flags
from dokimi.commands import runs_baseline
from dokimi.commands import runs_baseline, runs_bundle
from dokimi.artifacts import INPUT_KINDS, SCHEMA_VERSIONS
from dokimi.exit_codes import EXIT_INFRA
from dokimi.runs import baseline
Expand Down Expand Up @@ -478,4 +478,5 @@ def register(sub: argparse._SubParsersAction, positive_int) -> None:
help="Print cli_output.v1 on stdout (the runs removed and kept under data)")
gc_p.set_defaults(func=cmd_runs_gc, emits_cli_output=True, cli_kind="runs gc")

runs_bundle.register(runs_sub)
runs_baseline.register(runs_sub)
Loading
Loading