Skip to content

Stop runs the previous template saved - #3343

Open
jparker2006 wants to merge 3 commits into
mainfrom
cursor/legacy-template-stop-0935
Open

jparker2006 wants to merge 3 commits into
mainfrom
cursor/legacy-template-stop-0935

Conversation

@jparker2006

Copy link
Copy Markdown
Member

Summary

A run saved by the template from before #1590 stores each turn as a pid. Wake and stop treated every turn as a supervisor object, so both failed with TypeError after stop had already marked the run stopped, and the old process kept running.

Stop now ends those pids, and only when the process still carries that run's OPENWIZ_RUN mark, before it records the run as stopped. Wake refuses that record instead of starting another turn.

Fixes #1694

Tests

python3 -I adapters/template/test_driver.py Template.test_a_run_saved_by_the_older_template_stops_and_does_not_wake and Template.test_stop_ends_what_the_turn_left_behind_after_it_exits.

Open in Web Open in Cursor 

Co-authored-by: Jake Parker <jparker2006@users.noreply.github.com>
@jparker2006

Copy link
Copy Markdown
Member Author

Review #3343 at 50d0d33

I inferred Grok (xAI) from the Cursor attribution and date. This review is from OpenAI Codex.

  • Blocking (Spec/Sweep) adapters/template/driver:308 skips a turn once its recorded harness PID has exited, even if a worker in its process group still carries the run marker. I started a run with the pre-0.1.0 KN16: the template driver never leaves an agent running or starts two #1590 driver at 5af6126, let its harness exit, and called stop twice at 50d0d33. Both calls returned stopped: true and the marked worker stayed alive. Check surviving processes using evidence that ties them to the run, and return an actionable error before recording success if shutdown cannot be confirmed.
  • Blocking (Sweep) adapters/template/driver:313 escalates from SIGTERM to SIGKILL after 50 ms. A synthetic harness that needed 250 ms to save a checkpoint on shutdown exited cleanly with the old driver. Stopping the same kind of legacy run at 50d0d33 killed the harness before it saved the checkpoint. Give legacy runs the driver's normal shutdown grace before escalating and check that they exit.
  • Nit (Spec) adapters/template/test_driver.py:627 hand-writes the PID record. Keep wake and stop working for existing template runs (follow-up for #1590, R6) #1694 asks for a regression that starts with the old driver and stops with the new one. Exercise that upgrade path and include a worker that outlives its harness.
  • Nit (Standards) changes/1694.md:3 promises that stopping ends the legacy run's processes. Match the claim to the verified behavior and list the changelog file as a supporting edit in the PR body.

Checked all three changed files against #1694 and the repo standards. #1694 has no formal owned-paths section. The driver and test are within its stated template scope, and the fleet rules cover its changelog file. All 27 template tests and five template-focused driver-kit tests passed on Linux, including the kit's simulated macOS case. The synthetic upgrade probes also confirmed that wake refuses the old record and stop ends a foreground-only harness.

VERDICT: CHANGES at 50d0d33

…confirmation (#1694)

- Find surviving legacy processes tied to recorded turn PIDs, process groups, or sessions on Linux, verify OPENWIZ_RUN only on those candidates, stop them and their descendants with the normal shutdown grace before SIGKILL, and confirm exit before recording stopped.
- Refuse before marking stopped when shutdown cannot be confirmed (surviving processes, unreadable own-process environ, or hosts without /proc).
- Exercise the pre-#1590 upgrade path with surviving workers, checkpoint grace, SIGKILL escalation, unconfirmed-shutdown refusals, and PID-reuse safety.
- Narrow changes/1694.md to the verified behavior (supporting edit: kind 2, changes/1694.md).
Live-rig's four-driver fixture appends falsy 0 to a dict turn list to simulate a failed wake while keeping stop working; matching legacy_turns only when every turn entry is an int keeps that path intact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep wake and stop working for existing template runs (follow-up for #1590, R6)

1 participant