Repository navigation
feat(runs): run directories: run.json, and a result.v1 when a run is stopped - #1150
Conversation
…stop A run had no directory of its own: its plan, result and artifacts went wherever each command's output flags pointed, and a run stopped by SIGTERM, Ctrl-C or the spend cap left no result at all. dokimi.runs.rundir.open_run(root, name=None, out_dir=None) makes the run's directory, <root>/<name or run_id>/ or the given --out-dir (intel#591), and writes run.json, a new run.v1 artifact: the envelope, argv, started_at/finished_at, name, status, stop and the artifacts by path relative to the directory. A run never writes into another run's directory: an existing one is refused (an output directory may be empty), run.json is created exclusively, a name is one path segment of run id characters, and a name with an output directory is refused. RunDir.artifact_path(kind) gives <schema_version>.json in the directory, write_plan() saves plan.v1.json and record_cell() a cell's status. In a with block, a stop (KeyboardInterrupt, SpendCapReached, RunStopped, SIGTERM) writes result.v1.json with not_run on the cells left and run.json status incomplete with the reason; any other error makes it failed. SIGTERM kills the child process groups as the CLI's handler does, then the record is written and the signal goes back to the handler that was there, so the process exits as before. runs list groups a run directory as one run (scan groups by run_id). No command writes a run directory yet: the families follow (R-3...). Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A1: RunDir installed its own SIGTERM handler that copied part of process._on_signal. It raised inside process._spawn, where the CLI's handler defers the signal until the new child is in _live, so that child was never killed; with an earlier handler that returns, process._closing stayed True after the block and every later process.run raised ShuttingDown; and SIGHUP left run.json "running". dokimi.process_hooks holds callbacks the handler of install_signal_handlers runs after kill_children (and so after the spawn deferral). RunDir adds one on the main thread for the block: it raises ShuttingDown, the record is written, and the signal is delivered again through the same handler, which then resets _closing or ends the process as before. SIGHUP is recorded the same way. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A4: when code in the block caught the ShuttingDown a signal raised, __exit__ saw no exception and finished the run as complete or incomplete with no stop, though the process then died of the signal. A run a signal stopped now ends incomplete, terminated, whatever left the block. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A3: _end set the status in memory before it wrote run.json, so a stop or an error inside that write left run.json "running" for good while __exit__ took the run as ended and recorded nothing. The ended record is now written first and kept after; a failed write leaves the run running, and the stop is recorded. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A2: the parent mkdir ran outside the try, so a runs root or an output directory's parent that is a file raised a raw FileExistsError (NotADirectoryError deeper down), and a root with no write permission a PermissionError: a traceback once a leaf is wired, not exit 2. Both mkdirs now raise InputError naming the directory. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A5: record_cell checked a cell id against a list under the lock every worker shares, so recording a whole plan was O(n^2). The ids are a dict in plan order, which also drops the dedupe the result used to do. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1150 +/- ##
==========================================
+ Coverage 96.15% 96.20% +0.05%
==========================================
Files 498 501 +3
Lines 65973 66875 +902
Branches 11456 11617 +161
==========================================
+ Hits 63436 64340 +904
+ Misses 1569 1563 -6
- Partials 968 972 +4
🚀 New features to boost your workflow:
|
|
OpenCodeReview: Commit e31f070 was not reviewed. This PR has reached its review limit (6 reviews). CI at `e31f070`: 7 still running, 13 passing, 3 skipped
To review this commit: re-request review from exai-bot in the Reviewers list. Last review (4a88721): 1 mediumOpen threads from the bot: 1 |
CLI interface change detectedThis PR changes dokimi's user-facing CLI surface (commands and/or options): ~ `dokimi runs list` parameters changed:
~ changed option `--kind`: choices: ["'answers'", "'arms'", "'baseline_manifest'", "'catalog_eval'", "'checklist'", "'cli_routes'", "'cross_judge'", "'dashboard'", "'docling_sources'", "'docs_run'", "'dokimi_config'", "'effective_instructions'", "'eval'", "'eval_coverage'", "'explore_runs'", "'grounding'", "'guidance_reach'", "'headroom'", "'judge_validity'", "'judge_wording'", "'leak'", "'matrix_rollup'", "'need_graph'", "'novelty'", "'novelty_atoms'", "'novelty_retest'", "'opportunities'", "'pairwise'", "'persona_analysis'", "'personas'", "'plan'", "'plugin_delta'", "'question_panel'", "'question_quality'", "'questions'", "'ragas'", "'reach_matrix'", "'redteam'", "'repo_budget'", "'repo_environment'", "'repo_hits_judged'", "'repo_ledger'", "'repo_readiness'", "'report_qa'", "'report_summary'", "'result'", "'run_context'", "'security_report'", "'skill_coverage'", "'skill_discovery'", "'skill_evidence'", "'subject_scorecard'", "'task_inspect'", "'task_runs'", "'tool_preference'"] -> ["'answers'", "'arms'", "'baseline_manifest'", "'catalog_eval'", "'checklist'", "'cli_routes'", "'cross_judge'", "'dashboard'", "'docling_sources'", "'docs_run'", "'dokimi_config'", "'effective_instructions'", "'eval'", "'eval_coverage'", "'explore_runs'", "'grounding'", "'guidance_reach'", "'headroom'", "'judge_validity'", "'judge_wording'", "'leak'", "'matrix_rollup'", "'need_graph'", "'novelty'", "'novelty_atoms'", "'novelty_retest'", "'opportunities'", "'pairwise'", "'persona_analysis'", "'personas'", "'plan'", "'plugin_delta'", "'question_panel'", "'question_quality'", "'questions'", "'ragas'", "'reach_matrix'", "'redteam'", "'repo_budget'", "'repo_environment'", "'repo_hits_judged'", "'repo_ledger'", "'repo_readiness'", "'report_qa'", "'report_summary'", "'result'", "'run'", "'run_context'", "'security_report'", "'skill_coverage'", "'skill_discovery'", "'skill_evidence'", "'subject_scorecard'", "'task_inspect'", "'task_runs'", "'tool_preference'"]Updated on every push; the |
Review point on intel#1150: the changelog fragment and the docs index said a stopped run's directory still gets result.v1.json, but a run with no plan writes none (a result is a status per planned cell), as docs/run-directories.md and test_a_stopped_run_without_a_plan_writes_no_result say. Both now say run.json is incomplete and a run with a plan has its result. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…rror Review point on intel#1150: for an existing empty --out-dir, only FileExistsError was caught around listing it and creating run.json, so a directory without write permission (or one that cannot be listed) raised a raw PermissionError, which cli.main does not turn into exit 2. Every OSError of the claim is now an InputError naming the directory. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review point on intel#1150: write_plan saved plan.v1.json before it took the run's lock, so a finish in another thread could end the run in between, with no plan and so no result.v1.json, after which the plan was installed on the ended run. The save now happens under the lock, and an ended run refuses a plan with ValueError. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review point on intel#1150: write_plan kept the dict save_artifact returned, a shallow copy that shares nested objects with the caller's plan. A caller that changed either one after the save (a budget field) changed the in-memory plan the result is hashed from, so run.json said complete while plan.v1.json and result.v1.json did not match. The run now keeps a deep copy of what was written. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review point on intel#1150: __exit__ removed the signal hook before it wrote the end of a block that ended normally, so a SIGTERM during that write went straight to the default handler, and a Ctrl-C there had no recovery: run.json stayed "running" with no result.v1.json. The hook now stays on until the end is written, and a stop that lands while it is written ends the run as that stop (interrupted, terminated, ...) before it goes on; a signal is then delivered again as before. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A6: dc3ce18 deep-copied the plan after save_artifact had put plan.v1.json on disk and before the run took it in, so a stop landing in the copy (Ctrl-C, or ShuttingDown from the signal hook) ended the run with plan.v1.json listed and no result.v1.json. The plan is now copied before the save, and only an assignment follows it; the caller gets its own copy of what was written. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A7: 26a8d6e qualified the fragment and the docs index, but the module docstring of dokimi.runs.rundir still said every stop writes result.v1.json. It now says run.json is incomplete and, when the run has a plan, result.v1.json marks the cells left not_run, as docs/run-directories.md does. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review point on intel#1150: record_cell changed a cell after finish had written result.v1.json, so the call succeeded and the measurement never reached the result. It now raises ValueError once the run has ended, as finish and write_plan do. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…he result Review point on intel#1150: a block that ended normally chose complete or incomplete from the cells, released the lock, then wrote the result from the cells again. A cell recorded in between (a worker replacing a status) made finish refuse "complete" and the run end failed, or end incomplete beside a complete result. The status is now chosen in _end, from the same result it writes, under one lock. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review point on intel#1150: save_artifact publishes plan.v1.json with os.replace and does more before it returns, and the run took the plan in only after that. A stop in between (Ctrl-C, or ShuttingDown from the signal hook) ended the run with the plan on disk and no result.v1.json. On an exception out of the save, the run now checks whether plan.v1.json holds this plan (by its digest) and, if so, takes it before the stop goes on, so the result covers it; a stop before the publish leaves no plan and no result, and an earlier plan still on disk stays the run's. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A10: write_plan's handler for an exception out of the save called stamp(), whose run_id() raises again when DOKIMI_RUN_ID is malformed, so the caller got a fresh InputError without the note on where save_artifact kept the payload. The handler now compares the file with the plan by plan_digest, which leaves the envelope out, and takes the plan itself; nothing in it can raise a new error. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A9: no test told the digest check in write_plan's stop handler from "the file exists": a second write_plan stopped before it published took the new plan while plan.v1.json still held the first, and the result no longer matched it. The new test stops the second save before and after publishing, and checks the result matches the plan on disk (incomplete, not invalid, with that plan's cells). Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A15: since 81e0fb5 _end replaces the status with incomplete, terminated whenever a signal came, so _how_ended's own signal branch was computed and overwritten at once; two places built the same stop. The rule now lives in _end only. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A13: the signal handler killed the child groups first and reached the run's hook only after, so a worker whose child the kill ended could record its cell and finish the run complete (or incomplete with no stop) in between, before the run knew of the signal. process_hooks gains notices, which the handler calls before kill_children; a run directory's notice records the signal, so any end written from then on is incomplete, terminated. The raising hook still runs after the kills. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@napetrov Thanks. On the responsibility note: the new dokimi/process_hooks.py is in the foundation layer of tests/test_import_architecture.py next to dokimi.process, and docs/architecture.md says what it holds; dokimi.runs.rundir stays in the tracks layer with dokimi.runs. The changed surface (open_run's defaults and its InputError refusals) is pinned by tests/test_runs_rundir.py, each test citing its line of docs/run-directories.md. |
| if self._signal is not None: # read under the lock: a signal before it wins over any status chosen earlier | ||
| status, stop = "incomplete", {"reason": "terminated", | ||
| "detail": f"{signal.Signals(self._signal).name}: the run stops"} |
There was a problem hiding this comment.
Must-fix: the signal check still misses a worker already finalizing.
Impact: run.json can remain complete with stop: null after SIGTERM stopped the run.
Trigger: pause a worker's finish("complete") inside completeness or the result save, after this check; deliver/catch SIGTERM on the main thread; then release and join the worker before context exit.
Evidence: _on_notice writes _signal without taking _lock, so it can run during this locked section. The worker never checks the signal again before publishing ended, and _end_unless_ended subsequently skips the now-ended run. The existing regression covers a worker waiting before lock acquisition, not this remaining interleaving. Coordinate signal notices with terminal publication, or repair a finalization overtaken by a notice, and add an event-gated regression asserting the reloaded record is incomplete/terminated.
Workaround: finalize on the main thread while hooks remain installed.
Severity justification: medium because this is a bounded but material wrong persisted verdict and lost termination reason.
This proof replaces part of the code with stand-ins (monkeypatch): it shows the code path, not the real dependency or platform.
Shown by running: exit 1 (at the head) · exit 2 (at the merge base, which cannot run it) · exit 0 (at the head with the fix)
python -m pytest -q -p no:randomly -p no:cacheprovider tests/test_proof_c1.py
What the proof does: Pauses a worker's finish("complete") inside the run.json save, delivers the SIGTERM notice on the main thread, then checks the reloaded run.json is incomplete/terminated.
The problem shows as the output SIGNAL LOST.
Script: dokimi/tests/test_proof_c1.py (33 lines).
E assert ('complete' == 'incomplete'
E
E - incomplete
E ? --
E + complete)
tests/test_proof_c1.py:32: AssertionError
=========================== short test summary info ============================
FAILED tests/test_proof_c1.py::test_signal_during_worker_finish - AssertionEr...
1 failed in 0.57s
There was a problem hiding this comment.
I'd keep this end as it is rather than turn it terminated. It was decided under the run's lock from cells all measured before the signal, so the run had finished when it was stopped; any end that reads the signal after the notice (2d31f02, before the kills) is incomplete, terminated. docs/run-directories.md now states it: an end another thread is already writing when the signal comes is kept. Making the handler wait for that end, which I tried, can deadlock the handler and hold back the kills, so the notice stays a plain assignment; a test pins this case (complete, stop null, the signal delivered again).
Review point on intel#1150: the notice recorded the signal without the run's lock, so it could land while a worker's finish was inside _end, past its signal check, and the end was written as it had been decided with no trace of when the signal came. The notice now takes the lock: an end already being written finishes first (it was decided from cells measured before the signal, so it stands), and any end after the notice is incomplete, terminated. docs/run-directories.md says so. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fixes for A17 and A18: 255a912 made the notice take the run's lock inside the signal handler. That could deadlock (a worker in _end needs artifacts' _run_id_lock, which the main thread may hold when the signal lands), it held back kill_children for as long as a save took, and a SIGINT while waiting raised out of a notice. It also changed no recorded result: _end reads the signal once under its lock, so an end already past that read was kept before as well. The notice is a plain assignment again. The rule stays as docs/run-directories.md states it: an end another thread is already writing when the signal comes is kept. The lock-order test is replaced by one that pins that behaviour: a worker held inside its run.json save, SIGTERM returns at once, the end stays complete with no stop, the result matches the plan and the signal is delivered again. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@napetrov Following up on both requests: the stop state is now read inside the finalization lock (81e0fb5, thread r4677759326), and the run learns of the signal before the child groups are killed (2d31f02). Main is merged in 13f8ede: cli-interface.json was regenerated with both main's new commands and the run kind, and documentation-index.md keeps both main's runs rm/gc line and the run-directories entry. |
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head ab5b048)
- Contract: changed. defaults dokimi/dokimi/runs/rundir.py:40; errors dokimi/dokimi/runs/rundir.py:56
- Responsibility: candidate. policy dokimi/docs/architecture.md; policy dokimi/tests/test_import_architecture.py
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The previous cancellation case is fixed. I repeated the worker finish while the main thread held the run lock, delivered the stop notice, and got incomplete with stop.reason set to terminated. The documented rule for an end already being written also matches the tests. The four focused suites passed (306 passed, one skipped). Please resolve the current conflict with main in test_import_architecture.py and rerun CI. The Python 3.14 log reports a runner shutdown.
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@napetrov Thanks for re-running it. Main is merged in d5b8fcd: test_import_architecture.py keeps both main's dokimi.llm_sampling and dokimi.yaml_unique and the PR's dokimi.process_hooks in the foundation layer, and cli-interface.json, documentation-index.md and mkdocs.yml keep both sides too, so CI reruns on the merged head. |
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…hind Review point on intel#1150: open_run claimed the directory with an empty run.json and then saved the record; when that save failed (a full disk), the raw OSError went out of open_run, which cli.main does not turn into exit 2, and the empty run.json stayed, so the same name or output directory was refused on every retry. A failed first save now removes the empty run.json, and the directory when open_run made it, then raises; an OSError becomes an InputError naming run.json. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A22: one BaseException handler with an isinstance check for OSError wrote two cases as one. An OSError is now its own clause (released, then an InputError), and anything else is released and re-raised. No behaviour change. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Review fix for A19: only the OSError half of open_run's handler for a failed first save was tested, so narrowing it back to OSError left the suite green and a Ctrl-C there would again leave the empty run.json. The test now also interrupts the save with KeyboardInterrupt, for a named run and an empty --out-dir, and checks nothing is left and a retry works. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…han run Review fix for A20: open_run's release removed run.json only when it was still empty, so a Ctrl-C after save_artifact had published the record (its stale-file cleanup, its return) left a run.json saying running that no caller could end, and the same name was then refused for good. The claim is exclusive, so run.json is this call's own whatever it holds: the release now removes it. The test adds that case; docs/run-directories.md says a stop while run.json is written leaves nothing behind too. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…rror or a stop Review fix for A21: the docstring said any failed first write leaves nothing behind, but a record save_artifact refuses (a malformed DOKIMI_RUN_ID in library use; cli.main refuses it earlier) is kept at run.json.rejected, which the refusal names, so the directory is not empty after it. The promise now covers a filesystem error or a stop, and says where a refused record stays; a test pins that the claim is released and run.json.rejected is what is left. Refs intel#94 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 4a88721)
- Contract: changed. defaults dokimi/dokimi/runs/rundir.py:41; errors dokimi/dokimi/runs/rundir.py:62
- Responsibility: candidate. policy dokimi/docs/architecture.md; policy dokimi/tests/test_import_architecture.py
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The previous first-save issue is fixed, including interruption after the record is published. Seven focused tests passed. The exclusive creation of the run marker still has a separate retry failure, confirmed with a simulated full disk on that operation.
| if not (empty_ok and path.is_dir() and not any(path.iterdir())): | ||
| raise InputError(taken) from None | ||
| made = False | ||
| with open(path / RUN_FILE, "x", encoding="utf-8"): |
There was a problem hiding this comment.
blocking: If the exclusive creation of run.json fails after the named directory was made, _claim raises without releasing that empty directory. I simulated ENOSPC at the open(..., "x") call. Retrying open_run with the same name after restoring writes returns “already exists”. The documented first-write retry should also work here. Please remove the directory only when this invocation successfully created it and it is still empty, and cover failure at the claim step.
When the exclusive create of run.json failed (a full disk), _claim kept the directory it had just made, so a retry with the same name was refused as "already exists", against docs/run-directories.md. It now removes the directory it made; an output directory that was there stays. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
runs rm and runs gc remove a run's files and keep its directory, so the emptied results/<name>/ refused every later run with that name. A name, like an output directory, may now take an empty directory: the exclusive create of run.json still decides which run owns it. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
…lete artifact_path handed out plan.v1.json; a plan saved there stayed unknown to the run, which then ended complete with none of its cells measured, and wrote no result on a stop. It now refuses plan, result and run, the kinds the run writes itself, and points at write_plan. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
A block that left through sys.exit was recorded failed, error, even for sys.exit(0) after every cell was measured. Codes 0, None, 1 (a failed verdict) and 3 (inconclusive) now end the run by its cells, as exit_codes.py defines them; other codes stay failed. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
A ThreadPoolExecutor's exit waits for every queued item, so a signal in a pool-based block was recorded, and the process exited, only after the whole queue ran. The doc now says the block cancels pending futures. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
|
xaleryb
left a comment
There was a problem hiding this comment.
Approved on e31f070. A stopped run is recorded as stopped and never reads as complete; our commits clean up a run.json that could not be written (the open thread at rundir.py:109), let a removed run name be reused, refuse plan/result through artifact_path and grade exit codes by the cells. Left for later: cancel_futures in arm_runner when the arms family moves to run directories. Windows smoke had not started (the hosted Windows queue was stuck); every other check passed.
Summary
Refs #94 R2 (stage R, run directories; design comment R-0 on #94).
Until now a run had no directory of its own. Its plan, result and artifacts went wherever each command's output flags pointed. A run stopped by SIGTERM, Ctrl-C or the spend cap left no
result.v1at all. This PR adds the module that gives a run its own directory, plus its record kindrun.v1. No command writes a run directory yet: the command families move to it one per PR (R-3 arms, R-4 subjects, R-5 evaluate/benchmark, R-6 answers/score, R-7 diagnostics).dokimi.runs.rundir.open_run(root, name=None, out_dir=None) -> RunDirmakes the directory and writesrun.jsonwithstatus: running. A run never writes into another run's directory:out_dirmay be an empty directory;run.jsonis created exclusively, so of two runs racing for one directory only one gets it;out_diris refused;InputError.RunDir.artifact_path(kind),write_plan(plan),record_cell(cell_id, status),finish(status).finish("complete")is refused while a planned cell has no measured status, asresult.v1defines completeness.write_plansaves under the run's lock and keeps its own copy of the plan;write_planandrecord_cellare refused once the run has ended. A stop that lands onceplan.v1.jsonis published still leaves the result.As a context manager, the block's end is recorded:
statusstop.reasoncompleteincompleteincompleteterminatedKeyboardInterruptincompleteinterruptedSpendCapReachedincompletespend_cap/no_priceRunStopped(a usage limit, no login)incompleterun_stoppedfailederrorWith a plan,
result.v1.jsonis written in every case. Cells without a status arenot_run, with the stop indetail, andrunner.plan.completenessreads such a result as incomplete.Signals use the CLI's own handler; this PR adds no second one. The handler of
process.install_signal_handlerskills the child process groups as before, keeping its deferral while a child is being registered. Before the kills it tells the run that the signal came (a notice: an end that reads it afterwards is terminated, an end already being written is kept), and after them it runs the hooks in the newdokimi/process_hooks.py;process.pygains two calls. An open run directory's hook raisesShuttingDownin the block. The record is written, then the signal is delivered again through the same handler, so the process exits as it did before (died of SIGTERM, 143). Only a run opened on the main thread is stopped this way.New kind
runinSCHEMA_VERSIONSandruns/kinds.py(timestarted_at, countsartifacts), andruns list --kind runin the CLI snapshot.runs listshows a run directory as one run, because every file in it carries the run'srun_id.docs/run-directories.md(in the index and the site nav) describes the layout, the rules and the stops.Evidence
tests/test_runs_rundir.py, new (60 tests with the parametrized cases). The module is new, so on main they cannot import it. Each cites the line ofdocs/run-directories.mdit checks. They cover:run_idrefused, bad names,--out-dirempty or holding files, the exclusive-claim race, a parent that is a file, no permission;run.jsonby relative path;result.v1.jsonloaded throughload_artifact(so validated againstresult.v1) and checked withcompleteness();process.install_signal_handlers: the record is written before the earlier handler runs, andprocess._closingis back toFalseafter;_spawn, and a signal whoseShuttingDownthe block caught;returncode == -15) after writing the record;runs list --jsonlisting the directory as one run with kindsarms, plan, result, run.scripts/mutate_changed.py --base upstream/main) on the first commit: 40 mutants, 35 killed, 2 errors, 3 survived. Two survivors were flag resets in__exit__that nothing could observe; I removed those lines. The third was theparents=Trueof the parentmkdir, now killed by an out-dir two levels deep.make ci-local --offlineon cff0589d1f1, before the rebase: 0 failed. After review round 5,slot ci --quick(lint, mypy, the whole suite) on ab5b048: 0 failed, 27590 passed, 81 skipped.Open questions
plan.v1.yaml. Here it isplan.v1.json: every artifact goes throughsave_artifact, andruns listfinds a file by its leadingschema_version.run --plan FILE(L2) can still read a hand-written YAML plan. Raised in R-0 on CLI API: the evaluation loop at the top level, subject and eval groups below, one enforced flag vocabulary (proposal v2.1) #94.DOKIMI_RUN_IDshared by a CI job's steps, the second step's<root>/<run_id>exists and is refused. Should each step get<root>/<run_id>/<leaf>/instead? This is for R-3, when a leaf first opens a run directory.Not in this PR
--nameflag incli_flags.py: R-3 onwards.runs baseline save --expect-previous: R-9.--from RUN: R-8. (runs rmandruns gc --older-thancame to main in feat(runs): runs rm and runs gc --older-than --keep-baselines #1147.)run.jsonlists artifacts when the run ends, not while it runs. A SIGKILLed run keepsstatus: runningwith an empty list; its files still group byrun_id.process.install_signal_handlers()gets no record on a signal (documented).Revert
A plain revert. No command writes
run.v1yet, so no stored file depends on it. The one shared change is the hook call inprocess._on_signal, which does nothing while no hook is added.Checklist
pytestpasses:test_runs_rundir.py, plus therun.v1rows intest_runs_scan.pyandtest_runs_show.py; the whole suite passes (above)ruff,mypy, and schema checks pass:ci-localstatic and typecheck,schema_compatagainst the basedocs/run-directories.md,docs/architecture.md(process_hooks.py), index, nav, CLI snapshotAGENTS.md: mutations above,list_new_error_paths.py,check_growth.py(process.py790 of 800 lines)raise/exit and test names the doc, contract or issue it traces to:docs/run-directories.md,result.v1, CLI API: the evaluation loop at the top level, subject and eval groups below, one enforced flag vocabulary (proposal v2.1) #94 R2tests/fixtures/artifacts/run.v1.json