Repository navigation
Let resume restart a run its Validator left incomplete - #174
Conversation
Since #162, a Validator that exits before acceptance (a crash, a killed tmux server, a closed terminal, an accidental /exit) retires the run with outcome incomplete, and every later `factory resume` refuses with "this run is retiring or stopped; create a new run". The run's work is stranded, where b04c32a resumed the same run. start() now moves an incomplete stop record whose teardown is verified aside (lifecycle-terminal.reopened-<observed_at>.json, kept as evidence) and starts the run again. A CI-green stop, or one whose teardown is still pending, stays final and refuses as before.
There was a problem hiding this comment.
Confidence Score: 2/5
Summary
Lets factory resume reopen a run retired incomplete once teardown is verified. Works for native-Validator runs, but kickoff-mode state (stop.json, stale external binding) is not reset, so those reopened runs are torn down again within one watcher tick.
Important Files Changed
| File | Overview |
|---|---|
| harness/run_lifecycle.py | reopen_incomplete moves verified incomplete stop aside; ignores kickoff stop.json and external binding |
| harness/run_record.py | start() reopens under lifecycle lock before _start_locked, prints stderr notice |
| tests/test_run_lifecycle.py | Four parametrized cases; _start_locked stubbed, watcher behaviour after reopen untested |
Findings
- README.md:279-283 and the CHANGELOG
Unreleasedsection still describe an incomplete retirement as final; note thatfactory resumereopens a torn-down incomplete run.
Reviewed 4bd3fde...2b96795 · ↻ Re-run review · View in Adapt
| if not os.path.lexists(path): | ||
| return False | ||
| terminal = run_record.read_json(path) | ||
| if terminal.get("outcome") != "incomplete" or terminal.get("teardown") != "stopped": |
There was a problem hiding this comment.
Reopening validator-closed keeps inbox-wake/stop.json: the fresh inbox-wake poller exits and the kickoff watcher re-retires the run on its first tick (reproduced); exclude that reason or remove the file.
| raise ValueError("this run is retiring or stopped; create a new run") | ||
|
|
||
|
|
||
| def reopen_incomplete(root: Path) -> bool: |
There was a problem hiding this comment.
Kickoff validator-exited runs keep the dead orchestrator/validator-process.json binding (bind-validator refuses overwrite), so the new watcher re-retires within ~5s; limit reopen to native Validators or reset it.
| if terminal.get("outcome") != "incomplete" or terminal.get("teardown") != "stopped": | ||
| refuse_terminal(root) | ||
| stamp = re.sub(r"[^0-9A-Za-z]", "", str(terminal.get("observed_at", ""))) or "unknown" | ||
| os.replace(path, root / f"lifecycle-terminal.reopened-{stamp}.json") |
There was a problem hiding this comment.
os.replace silently overwrites an existing reopened-<stamp>.json (always when observed_at is missing, stamp unknown); create exclusively or add a counter so repeated reopens keep every record.
|
|
||
| A crashed, killed or closed Validator must not strand the run's work: the stop record moves | ||
| aside (kept as evidence) once its teardown is verified. A CI-green stop, or one whose teardown | ||
| is still pending, stays final. Call under the lifecycle lock. |
There was a problem hiding this comment.
A watcher lost mid-teardown (host reboot) leaves teardown: pending with nothing to finish it, so resume is refused forever; consider re-running _retire from resume under the lock.
| "evidence": {}, "owned": []} | ||
| (root / run_lifecycle.TERMINAL).write_text(json.dumps(record)) | ||
| started = [] | ||
| monkeypatch.setattr(run_record, "_start_locked", lambda runs_dir, run: started.append(run)) |
There was a problem hiding this comment.
Stubbing _start_locked leaves the watcher unexercised; add a case asserting _validator_terminal returns None after reopen so the kickoff regressions above are caught.
Review: a kickoff Validator keeps its dead conversation binding and a deliberate close keeps inbox-wake/stop.json, so reopening either was torn down again on the next watcher tick. Reopen only validator-exited on a run whose Validator is its own seat; kickoff, closed, CI-green and pending-teardown stops stay final. Each reopened record gets its own file (hard link, never overwritten), so repeated crashes keep every record. README and CHANGELOG say so.
|
Addressed in 1213527:
@adaptcom review |
|
Re-reviewed 1213527: both blockers are fixed. Reopen now only applies to Non-blocking:
|
Problem
Since #162, a Validator that exits before acceptance retires the run with
outcome: incomplete. That covers a crash, a killed tmux server, a closed terminal or an accidental/exit. After that, everyfactory resumerefuses with this run is retiring or stopped; create a new run, so the run's work is stranded.Reproduced live on devshell
dev(chiron4bd3fde): start a run, kill its tmux server, runfactory resume, and it is refused permanently. The installedb04c32aresumes the same run.Change
start(), whichfactory resumegoes through, now callsrun_lifecycle.reopen_incomplete()under the lifecycle lock.incompletestop whose teardown is verified (stopped) is moved aside tolifecycle-terminal.reopened-<observed_at>.json, kept as evidence, and the run starts again.ci-greenstop, or one whose teardown is stillpending, stays final and refuses exactly as before.Tests
test_resume_reopens_only_a_run_stopped_incompletecovers four cases: validator-exited and validator-closed reopen; pending teardown and ci-green refuse. The two reopen cases fail onmain.test_run_lifecycle.pyand the retirement test files pass. ruff and mypy are clean on the changed files.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.