feat(ultraplan-local): write session-state from ultraexecute session-end paths [skip-docs]

Three insertions in commands/ultraexecute-local.md so every session-end
path produces or refreshes .session-state.local.json (Handover 7):

- Phase 2.55 (Check 1, line ~376): write status=stopped on dirty-tree
  pre-flight stop before parallel session-spawn
- Phase 4 (line ~773): write status=stopped when entry condition fails
- Phase 8 (line ~1151): canonical convergence — every completed/failed/
  stopped/partial run refreshes the state file using atomicWriteJson +
  validator verification

Phase 2.3 (validate exit) and Phase 5 (dry-run) intentionally skip the
write — neither path is resumable. Validator errors warn but never block
the run; progress.json remains authoritative.

[skip-docs] rationale: README + CLAUDE.md updates land in Step 11.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 20:50:28 +02:00
commit e4a11daa68

View file

@ -373,6 +373,25 @@ To run sequentially instead: /ultraexecute-local --fg {plan-path}
Stop execution. Update progress with `status: "stopped"`.
**Also write `.session-state.local.json`** (Handover 7) — this surfaces the
stopped state to `/ultracontinue` so the next session can prompt the user to
clean the working tree before resuming. Write atomically alongside `progress.json`:
```json
{
"schema_version": 1,
"project": "{project_dir}",
"next_session_brief_path": "{project_dir}/brief.md",
"next_session_label": "{current session label, or 'Continue'}",
"status": "stopped",
"updated_at": "{ISO-8601 now}"
}
```
Verify with `node lib/validators/session-state-validator.mjs --json
{project_dir}/.session-state.local.json`. On validator failure, emit a warning
to stderr but do NOT block the stop; `progress.json` is still authoritative.
### Check 2 — Plan file is tracked by git
Run `git ls-files --error-unmatch {plan-path} 2>/dev/null`. If the plan file is
@ -751,6 +770,13 @@ Complete the prerequisite first, then re-run.
```
Update progress file with `status: "stopped"`. Stop execution.
**Also write `.session-state.local.json`** (Handover 7) with the same
`status: "stopped"` and `next_session_brief_path` pointing at the brief that
the failed entry-condition session was supposed to consume. This lets
`/ultracontinue` surface the stop in the next session. Use the same atomic
write pattern + validator check as Phase 2.55. On validator failure, warn
but do not block.
If the entry condition **passes**:
```
Entry condition: PASS
@ -1122,6 +1148,33 @@ Always produce a final report.
Update progress file: `status` to `completed`/`failed`/`stopped`, `updated_at`, `summary`.
**Also atomically write `.session-state.local.json`** (Handover 7) at this
convergence point — every successful, failed, stopped, or partial run that
reaches Phase 8 must produce or refresh the state file. Schema:
```json
{
"schema_version": 1,
"project": "{project_dir}",
"next_session_brief_path": "{determined from Execution Strategy: next session's brief path, or current brief path if last session}",
"next_session_label": "{label of next session from Execution Strategy, or 'Complete' if last}",
"status": "{same as progress.json status — completed | failed | stopped | partial}",
"updated_at": "{ISO-8601 now}"
}
```
Use `lib/util/atomic-write.mjs` (`atomicWriteJson`) — same crash-safety as
`progress.json`. Then verify: `node lib/validators/session-state-validator.mjs
--json {project_dir}/.session-state.local.json`. On validator failure, warn
to stderr but do NOT block — Phase 8 must always reach the final report.
This single insertion covers every multi-session execution path that
converges here (Path A: successful single session, Path B: `--session N`
explicit, Path C: compaction-survival recovery, Path D: standard plan
completion). Phase 2.55 and Phase 4 cover the early-stop paths E1/E2.
Phase 2.3 (validate exit) and Phase 5 (dry-run) intentionally do not write
— neither path is resumable.
```
## Ultraexecute Local Complete