Skip to content

fix(goals): task-session-stays-open and the restart journey match today's board and reopen (FIX-1979, FIX-1981) - #3346

Merged
jhoffner merged 2 commits into
mainfrom
claude/project-thread-atoa7o
Oct 14, 2026
Merged

jhoffner merged 2 commits into
mainfrom
claude/project-thread-atoa7o

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

Before: on main 7739ad25, goals/coordinators/task-session-stays-open was broken twice over. Its new-session control could not run, because FIX-1872 (#3232) rewrote the line it patches. And the plain run failed every attempt at a:names-region, a:one-completed and b:names-ticket. Since FIX-1764 (#3297), leg b's question on the finished task reopens it, but leg a was still graded on the reopened row. The restart journey J4 (goals/hand-offs/survives-a-restart-and-runs-once/legs/parked.mts) asks the same question, so it failed the same way, at j:one-completed, j:still-answers and j:row-unchanged.

After: both plain runs pass. new-session fails at a:names-ticket and c:names-ticket, with exactly the co-failures the closure goal's table lists. drop-answer fails at a:names-region alone. J4's fresh-store fails at j:answered, with every later j:* red too and kill:parked green.

How:

  • The control now patches the hand-off's return { key: taskSessionKey(claim?.followUpOf ?? task.taskId, worker) };.
  • task-session-stays-open snapshots the task row when leg a ends and grades leg a on that snapshot. Completed notices are counted up to that row's attempt.
  • Leg b now checks the reopen FIX-1764 decided: the run door answers { reopened: <taskId> }, and the task completes again in its own session with an output naming the ticket.
  • J4 gets the same treatment. j:row-unchanged contradicts the reopen outright, so it becomes j:reopened: completed again, one attempt later, in the session that parked. The runner's tag list is updated to match.
  • Each goal.md has its signal text and verdict log updated.

Evidence, on 7739ad25 + this change, openai/gpt-5.4-mini through the gateway, after pnpm packages:build and pnpm build:assets:

  • stays-open plain: PASS on attempt 1, run twice, the second after the review nits.
  • stays-open new-session: FAIL, red at a:names-ticket and c:names-ticket as required, plus a:same-session, b:names-ticket, c:same-session and c:one-draw.
  • stays-open drop-answer: FAIL at a:names-region only.
  • J4 plain: PASS on attempt 1. J4 fresh-store: FAIL, j:answered failed, as it must.

No changeset: goals are private.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RFPYtuYGMJ8xuLNDReeJT4

…IX-1764's reopen (FIX-1979, FIX-1981)

The new-session control's patch matched a line FIX-1872 rewrote, so the
control could not apply. It now patches the hand-off's
`return { key: taskSessionKey(...) }` line.

Since FIX-1764, leg b's question on the finished task reopens it, so the
plain run graded leg a on the reopened row and failed. Leg a is now graded
on the row as it stood before leg b, and leg b checks the reopen: the task
completes again in its own session, naming the ticket.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RFPYtuYGMJ8xuLNDReeJT4
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 14, 2026 1:38pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 14, 2026 1:38pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 14, 2026 1:38pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

FIX-1979

FIX-1981

@jhoffner jhoffner self-assigned this Oct 14, 2026
@cursor

cursor Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: ae91dcf6-e343-4fd4-a512-d1fad96b8368)

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass

Verdict: the approach is right; no blocking findings. Snapshotting the row at the end of leg a and grading a on it is the smallest honest fix. It leaves the legs independent and adds no new harness mechanism. Alternatives I considered (running leg b on a separate task, or loosening the a-assertions to tolerate the reopened row) are worse. The first changes the scenario's meaning, and the second makes the red state weaker. The new leg b grades the reopen contract FIX-1764 decided ({ reopened } + second completion in the same session), which is the behaviour the goal exists to pin.

I checked these and they hold:

  • noticeKey is ${taskId}:${attempt}:${ending} (packages/orchestration/src/tasks/notice/task-notice.ts:172), so attemptOf (.at(-2)) parses it correctly.
  • The new-session control regex matches board.ts:310 as it stands on this head.
  • The reopen wait requires attempts to increase and a terminal status, so it can't return early on the stale completed row.

Optional, not blocking:

  1. Terminal-status list is now copied twice in drive() (["completed","errored","cancelled"], run.mts ~L160 and the new L169). The PR adds the second copy, so it's the natural moment to hoist a TERMINAL set next to the existing RUNNING set. Roughly a three-line change, and it's the only refactor I'd take in this PR.
  2. b:names-ticket now covers three failures (wrong session, no { reopened }, reopened attempt didn't complete naming the ticket). The failure message prints all three, so it's diagnosable, but split tags (b:reopened, b:names-ticket) would make a red run readable from the tag alone, consistent with how a/c are tagged. This changes goal.md's tag list, so only do it if you want the finer signal.
  3. Ignored waitFor result for the reopen (run.mts L169). If the reopen never happens, the run spends the full 120 s before grading, then fails b. That's acceptable, but a one-line note (or capturing the boolean for the failure message) would save the next debugger a guess.

Not in scope, so I'd leave it: the control patches are regexes over board.ts source text, and assertPatched catches drift only at run time on demand. That coupling is what broke this goal in the first place (FIX-1872). A fix would be structural (a test seam in the board) and isn't justified by this change.


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/simplify review

Verdict: The extra machinery here is proportional to the product change, not an over-built test harness. FIX-1764 makes leg b reopen the task and complete on a new attempt, so the goal had to stop grading leg a from the live row after leg b and stop treating leg b as assistant message text in the worker session. Snapshot (endedRow), a post-run wait for the reopened attempt to settle, and attempt-scoped completed notices are the smallest faithful adaptation I see—not a simpler design that still matches goal.md and store-oracle grading.

What would have been “simpler” (and why it doesn’t work)

Alternative Why it falls short
Keep leg b on items(..., "message") + textOf Reopen returns { reopened: taskId } quickly; the ticket lives on the task row after the new attempt, not necessarily as the run action’s assistant message.
Grade leg a from rows.find(taskId) at grade time Leg b mutates the same row (attempts, output, second completed notice)—leg a tags would flake or need heavier filtering anyway.
Single a:one-completed without attemptOf After leg b you get two :completed keys; you need the taskId:attempt:ending attempt slot (same shape as orchestration noticeKey).
Import noticeKey from @flow-state-dev/orchestration Would DRY the key shape but breaks the usual goals convention (SQLite store oracle, no package coupling). Reasonable to cite the format in a comment instead.
Third-party helper for polling waitFor/quiet are already copied across coordinator goals; extracting shared lib is a wider refactor than this PR.

Approach smell check

  • Directory / imports: Still one goal folder + shared files-tasks-down-the-owners-chain/store.mts; no new cross-package graph. Dropping textOf is a net simplification.
  • Control patch: Re-anchoring new-session to return { key: taskSessionKey(...) } matches current board.ts—brittle by design for module-patch goals, same as siblings.
  • Related debt (out of scope): goals/hand-offs/survives-a-restart-and-runs-once/legs/parked.mts still grades leg b as “session answers without row change” (j:still-answers / j:row-unchanged). If FIX-1764 applies there too, that goal will need the same class of update—not a reason to block this PR.

Optional tighten-ups (non-blocking)

  1. Fail-fast on leg b: If asked === null, the new waitFor still polls 120s with a predicate that can never pass—worth guarding to shorten red runs (DX only).
  2. attemptOf: A one-line comment that keys are taskId:attempt:ending would document why split(":") index -2 is the attempt.
  3. Naming: reply in leg b is now task output; reopenOutput (or similar) would reduce confusion with the old message-based check.

No performance or production concerns; this is a sequential goal script dominated by the model and HTTP.

Approval: Direction looks right for FIX-1979 / FIX-1981; I don’t see a materially cleaner change set without weakening the signal.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Snob — tried a rewrite, it tied. No POC.

I read goals/coordinators/task-session-stays-open/run.mts and goal.md.

I hoisted the three ["completed", "errored", "cancelled"] checks into taskDone, inlined attemptOf, and shortened the leg b comment to // Leg b.. Against 7739ad25, run.mts stays net +10 (+21/−11, was +20/−10). The helper is one new line; dropping attemptOf gives that line back and leaves .at(-2) on the filter. Folding reopenedRan into the if wraps to the same length.

The snapshot, the reopen wait's attempts clause, and the { reopened } check are the contract. goal.md's three new verdict rows are the run log.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

…FIX-1981)

J4 asked the finished task's session the same question leg b does, and
graded the row as unchanged after it. Since FIX-1764 the question reopens
the task, so j:one-completed counts up to the answered attempt,
j:still-answers checks the reopen and the reopened output, and
j:row-unchanged becomes j:reopened. Also folds the review's optional nits
on task-session-stays-open (fail-fast wait, notice-key comment, naming).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RFPYtuYGMJ8xuLNDReeJT4
@cursor

cursor Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 72944dec-976f-416d-a785-70040060bb4d)

@jhoffner jhoffner changed the title fix(goals): task-session-stays-open matches today's board and reopen (FIX-1979, FIX-1981) fix(goals): task-session-stays-open and the restart journey match today's board and reopen (FIX-1979, FIX-1981) Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T13:48:32.220262Z 8108e66 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8108e660e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jhoffner
jhoffner merged commit 9be7186 into main Oct 14, 2026
20 of 21 checks passed
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.

2 participants