Skip to content

fix(session): a joined task ended by its run's stop reads stopped, not finished - #2367

Open
CloudCorpRecords wants to merge 2 commits into
Agent-Field:devfrom
CloudCorpRecords:fix/1828-joined-stop-report
Open

CloudCorpRecords wants to merge 2 commits into
Agent-Field:devfrom
CloudCorpRecords:fix/1828-joined-stop-report

Conversation

@CloudCorpRecords

@CloudCorpRecords CloudCorpRecords commented Nov 4, 2026 •

Copy link
Copy Markdown

What changed

Fixes #1828 — the stop-outcome defect.

When several tasks join one run and all are stopped in one batch of concurrent stop calls, a joined task whose stop reached the store after the run's stop was reported as "has already finished; there is nothing to stop", even though its worker was mid-work and was in fact ended by the run's stop (plandb.Store.StopRoot cancelling every open task in the run). The answer depended on the order the concurrent stops reached the store.

  • stopJoinedRow (internal/session/stoprun.go): a terminal joined task is now told apart by its ending. Cancelled under a person's stop reason (planStopReason), with the run's root cancelled under the same reason, it answers task N (title) was already stopped with task M (run title), whose run it shared. Cancelled under the stop reason while its run is still open, it answers was already stopped. "Already finished" is now said only for a task that landed or failed on its own.
  • endedBeltRow: a settled run row that reads stopped (TaskNotice.Stopped) now answers "was already stopped" instead of "already finished", so a batch stop that arrives after the run has settled agrees with the row it is looking at.

Scope: this PR fixes the stop reporting in the issue (the first defect and the acceptance sentences). The joined card where: folder and the joined receipt's copy wording named in the same issue are not changed here.

How it was checked

New regression tests in internal/session/stoprun_joined_batch_test.go (deterministic: the run's stop is written before the joined stop is issued, and separately all stops are issued concurrently — no timing luck):

  • Red on dev (f4db1f4): go test ./internal/session/ -run 'TestStopJoinedRow|TestStoppingRunThenJoined|TestStoppingBatch' -count=1 -v -> 3 failed with the exact reporter sentence task 72 (task D) has already finished; there is nothing to stop; the landed-task guard test passed.
  • Green with the fix: same command -> 4 passed.
  • Race: same tests with -race -count=3 -> 12/12 passed, no race reports.
  • Existing stop family: all 8 tests in stoprun_test.go passed; cancel/stop-boundary tests passed (11).
  • Pre-existing failures on this Windows machine, proven identical on a pristine dev worktree at the same commit and unrelated to this change (no plandb code is touched): the plandb StopRoot/Cancel tests fail in TempDir cleanup with plan.json: The process cannot access the file because it is being used by another process (3/3 on both trees), and 5 job/stopwork tests fail with belt has no "bash" tool on both trees.
  • gofmt -l on both changed files: clean.
  • Full make pr-ready / make test-quick were not run; the focused suites above are what was run, per the repo's focused-test guidance.

Checklist

  • A change entry — docs/changes/unreleased/2367-joined-stop-reads-stopped.md, created with make changelog-new PR=2367 KIND=fixed SLUG=joined-stop-reads-stopped in the follow-up commit on this branch (the number only exists once the PR does); changelog-check passes (105 entries, all well formed).
  • The manual knows about it — no slash command, key, tool, default, limit or refusal moved; the corrected stop sentence is not quoted in internal/manual/chat/ (searched), and the manual's account of stopping tasks already describes this behaviour.
  • Only my own paths are staged — two files, pushed via the Git Data API (no git add -A).

Disclosure: this change was prepared with AI assistance.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@CloudCorpRecords
CloudCorpRecords force-pushed the fix/1828-joined-stop-report branch from ce03c45 to 10a7ae6 Compare November 15, 2026 00:22

Copy link
Copy Markdown
Member

Hey, thanks for the PR. Could you sign the CLA when you get a chance so we can review it?

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.

tasks: stopping a batch reports joined tasks as "already finished" when its run's stop killed them

3 participants