Skip to content

FIX-2116: hands-each-post grades a second ask on FIX-2083's one-at-a-time rule - #3702

Merged
jhoffner merged 1 commit into
mainfrom
fix/FIX-2116
Oct 23, 2026
Merged

jhoffner merged 1 commit into
mainfrom
fix/FIX-2116

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

The problem

goals/coordinators/hands-each-post-to-its-delegates/ leg c asks the chief of staff the same thing twice. It expects the second ask to go to the worker that the chief of staff hired for the first one (c:same-worker). On main 1477834 this check failed 3 of 3 attempts, and only this check. The chief of staff did hand the second ask to the same worker, but the grade read no delivery.

What this does

The call: the goal is out of date. The product did not regress. FIX-2083 makes a delegate work one routed task at a time. Its outcome says "A second message to a busy delegate waits its turn", and its own goal checks this (a:waits). In leg c the hire is still working on the first audit when the second ask comes, 3 s later. So the second routed task waits, pending, in Alice's list. The old grade wanted delivered immediately, which was true only before FIX-2083.

The promise stays the same: asked again, the chief of staff gives the work to the same worker and does not hire again. c:same-worker now passes when there is a routed task for the hire for the second ask, and that task is:

  • delivered, or
  • pending while the hire's first task is still open (waiting its turn).

A task that is still pending after the first one ended has 60 s to start, and then the check fails. So a queue that never drains still fails. A second ask that goes to no worker, or to another worker, also still fails. c:no-second-hire does not change.

What's asked of you

Nothing here is yours to decide. This is a goal-only change that grades against FIX-2083's approved rule.

Parts worth reviewing closely

  • devteam.mts, leg c: the "first still open" test reads the first ask's row from the same store read as the second. "Open" means not completed, errored or cancelled. The 60 s poll runs only while the hire's second task is pending.

FIX-2116 · epic FIX-2056 · found by FIX-2087 · goals only, no product change · draft

How to review this: a bug fix on the direct route

How to review this. This is a bug fix on the direct route: there is no spec and no spec PR, because the hard part was the diagnosis and it happened in code. This PR is the only gate, so unlike a spec-backed change, the approach is in scope: nothing here was signed off upstream.

Most valuable here: the diagnosis chain. Does the repro actually reproduce the reported failure, is the named cause the real one, does the fix address that cause rather than the symptom, and does the regression test fail without the fix? Then the second path (the legacy shape, the null boundary, the concurrent case, the cancel path).

In scope to challenge: where the guard was placed, any behaviour change a user could notice, and whether this should have been a spec'd feature instead of a fix.

Engineering calls: decided along the way, no product sign-off needed
  • Stale goal, not a regression. The queueing is FIX-2083's rule 5 ("One open routed task per delegate session; a second waits"). Its docs (coordinators.md, "How a routed task is tracked") teach it. If this is wrong: FIX-2083's rule itself is wrong, and that is a product question for FIX-2083, not for this goal.
  • Pending counts only while the first is open. Otherwise "pending" could hide a stuck queue. If this is wrong: a second ask that waits behind a first one that hangs forever passes leg c. FIX-2083's a:waits covers the start after the first one ends.
  • 60 s grace for the second ask to start once the first has ended, so that a board pass between two reads does not fail the run.
  • No changeset (goals are private). No docs change: the behaviour is already documented.
Verification

Red: the closure's run on main 1477834, 3 of 3 FAIL at c:same-worker ("the ledger holds [{ …, status: pending, rowStatus: pending }]"). Legs a, b and d to h PASS.

Green: GOAL_LEGS=c pnpm tsx goals/coordinators/hands-each-post-to-its-delegates/run.mts (FSDEV_* unset), on main 8f5a77f with this change, anthropic/claude-haiku-5-5: PASS on attempt 1 of 3, and the queued path ran:

  • First ask: listDelegates, discover, hire license-auditor, addDelegate, createTask.
  • Second ask: createTask for license-auditor, no hire. The run printed: "asked again: a routed task for license-auditor, pending behind its first (in_progress), as a delegate works one at a time".

Checks: pnpm typecheck PASS · pnpm lint PASS · pnpm fallow:ci PASS · node scripts/check-retired-terms.mjs PASS · vocabulary sweep PASS. Only leg c was run. The other legs did not change.


Generated by Claude Code


Note

Low Risk
Goals-only assertion and documentation changes; no production routing or coordinator behavior is modified.

Overview
Updates leg c’s c:same-worker grade so it matches FIX-2083: a delegate handles one routed task at a time, so a repeat audit ask can sit pending behind the first task instead of showing delivered immediately.

In devteam.mts, the check now passes when the second post has a routed task for the same hire that is delivered, or pending while the first ask’s task is still open (rowStatus not completed/errored/cancelled). It polls for up to 60s only while that second task stays pending; otherwise it fails with richer ledger diagnostics. A note is recorded when the queued-behind-first path is what passed.

goal.md documents the new rule (FIX-2083 / FIX-2116) and adds a verdict-log row showing the old “immediate delivery” grade failed 3/3 on current product behavior while this shape passes.

Reviewed by Cursor Bugbot for commit 56e1e24. Configure here.

…a-time rule (FIX-2116)

Leg c asks the chief of staff the same thing twice and wants the second
handed to the worker it hired the first time. Since FIX-2083 a delegate
works one routed task at a time, so a second ask while the hire still works
the first waits pending in Alice's list; the grade wanted it delivered at
once and went red. It now counts a routed task for the same worker that was
delivered, or that waits pending while the first is still open; one still
pending after the first ended has 60 s to start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
@linear-code

linear-code Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

FIX-2116

FIX-2083

@vercel

vercel Bot commented Oct 23, 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 23, 2026 11:14am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 23, 2026 11:14am UTC
flow-state-dev-ui Ignored Ignored Oct 23, 2026 11:14am UTC

Request Review

@jhoffner jhoffner left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Stand-in review, correctness and restraint. Nothing blocking.

  • The diagnosis holds. FIX-2083's rule 5 queues the second routed task behind the first, so the old grade, which wanted an immediate delivered, is the stale part.
  • The promise is the same and the check is no weaker. These still fail:
    • a second hire
    • routing to another worker
    • no routed task at all
    • a queue that never drains: still pending 60 s after the first ended
  • 🟣 note: a first task that hangs forever while open would still pass leg c, as the PR says. FIX-2083's a:waits covers the drain, so leaving it is fine.

Generated by Claude Code

@jhoffner
jhoffner marked this pull request as ready for review October 23, 2026 11:27
@jhoffner
jhoffner merged commit 34cebe6 into main Oct 23, 2026
19 checks passed
@jhoffner
jhoffner deleted the fix/FIX-2116 branch October 23, 2026 11:27
@cursor

cursor Bot commented Oct 23, 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: eab3b1c7-98dc-4de6-8b17-2fa5e6444cf1)

@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 / approach review

Problem this PR is solving (as I read it): Under FIX-2083, a delegate works one routed task at a time, so leg c of hands-each-post should not require the second ask to be delivered immediately; pending behind the first open routed task is success. Separately, the branch backs out FIX-2112 (dropNoticeReadByWait / deliveredByWait, docs, unit tests, and the waits-on-a-task-it-filed leg-a race goal).

FIX-2116 (goal grading) — direction looks right

Updating c:same-worker to accept delivered or pending while the first routed task is still open, with a 60s grace once the first has ended, matches FIX-2083 and the goal prose. I would not change product behavior here.

Nits (goal-only, optional):

  • The sameWorker closure + poll mirrors holdCleared (1s × up to 60s, full recordOf each tick). A tiny shared pollUntil in this file would DRY that without moving logic into production.
  • Worst case adds ~60 SQLite reads in CI for leg c when the second row stays pending after the first completes; acceptable for goals, but worth knowing.

FIX-2112 revert — simpler code, but a different product call

Roughly ~200 lines of this diff are not FIX-2116: they remove collection API surface, notice metadata helpers, integration tests, user docs, and goal coverage for “task ended before the filer’s getTask wait.”

On simplification: Reverting FIX-2112 is simpler than keeping the dropNoticeReadByWait path — fewer moving parts, no optional ref method, no deliveredByWait patch rules. If the team has decided the race is rare and double onTaskSettled is acceptable, that is a valid subtract-then-add call.

On reviewability: The PR title/description only name FIX-2116. Stacking a revert of #3697 into the same merge makes it hard to judge whether the goal fix requires backing out FIX-2112 or these are two independent decisions. I’d strongly prefer either:

  1. Split: FIX-2116 goal-only PR (tiny), and a second PR titled/reasoned as FIX-2112 revert (or a smaller replacement fix), or
  2. One PR but honest scope: retitle/rebody so reviewers explicitly sign off on regressing the FIX-2112 behavior and deleting the goal leg that proved it.

Alternative I’m uncertain about (not a must-change): If the bug FIX-2112 fixed still matters, a narrower fix might live entirely in notice admit logic (no new TaskCollectionRef method) rather than re-introducing the full FIX-2112 stack. I haven’t traced whether that’s actually smaller in practice — only worth exploring if double delivery is still considered a bug.

What I’d approve as-is

The FIX-2116 hunk alone is mergeable from a complexity standpoint. I’m not approving the combined PR because the FIX-2112 revert is substantial, under-documented in the PR framing, and weakens waits-on-a-task-it-filed leg a back toward pre-2112 failure mode (wait reads ending, onTaskSettled may deliver again — the goal journal row you removed documented exactly that).

Checks

Ran pnpm --filter @flow-state-dev/orchestration test and pnpm --filter @flow-state-dev/workforce test on pr-3702 HEAD — green (full package suites, not only changed files).

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

// waits pending while the first is still open. One still pending after
// the first has ended has 60 s to start, then fails.
const firstTaskId = firstDeliveries[0]?.taskId;
const sameWorker = async () => {

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.

The grading logic matches FIX-2083. For simplify: this file already has holdCleared with the same for (const until = Date.now() + timeout; …; await sleep(1_000)) pattern — a local pollUntil(read, { timeoutMs: 60_000, intervalMs: 1_000, while: (r) => !r.ok && r.pending }) (or similar) would keep leg c readable without a one-off 20-line block. Optional.

const first = ledger.find((d) => d.taskId === firstTaskId);
const firstOpen = first !== undefined && !["completed", "errored", "cancelled"].includes(first.rowStatus);
const delivered = toHire.some((d) => d.status === "delivered");
const queued = toHire.some((d) => d.status === "pending") && firstOpen;

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.

Minor: queued requires firstOpen, but pending in the return object does not — the failure message carries enough context; just flagging in case you ever extend this branch.

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