Skip to content

fix(workforce): a coordinator reads workers only through its leads (FIX-1920) - #3230

Merged
jhoffner merged 5 commits into
mainfrom
claude/project-thread-v9ry2p
Oct 13, 2026
Merged

jhoffner merged 5 commits into
mainfrom
claude/project-thread-v9ry2p

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

Fixes the first of FIX-1920's three problems. The other two are listed under "Not in this PR".

Before: the project coordinator could list every worker through its discovery tool, itself and the other coordinators included, even though its lead list (listLeads) offers only workers that can lead. In the dogfood run it picked project-coordinator as a lead, was refused, and retried with eng.em.

After: the only list of workers the project coordinator reads is listLeads.

The root cause was in Workforce, not the prompt. A worker's discover: line was read from the flow's own settings, so on the shared coordinator flow a worker's file never narrowed its discovery tool. It now reads the turn's config (the resolved worker's, else the flow's), the same source tools: already uses.

How: workerDiscoverSelection reads turnConfigOf(ctx), and the DevTeam project coordinator's file says discover: [].

Not in this PR

  • A failed call that a retry fixed still draws red. I took the tool-line change out after review. Matching a retry by tool name alone would hide a real failure when a later call of the same tool succeeds for different work. It'll come back on its own with a stricter rule; the patch is saved for that.
  • Lead fit. Asked "Open a workstream: Research: what to build", the coordinator puts it under the EM every time on the real model (11 of 11). This needs a product call, and it's being asked in the thread.

Evidence

  • packages/workforce/test/worker-discovery.test.ts: new case. A worker resolved on a shared flow is narrowed by its own file. It's red on main's worker-discovery.ts and green here.
  • packages/shift-manager/test/project-workstreams.test.tsx: the DevTeam project coordinator's discover returns no entries. It's red with only the code fix and red with only the file line; green with both.
  • Real model, DevTeam over a fresh store: with the fix, the coordinator calls listLeads before every open and never calls discover. I couldn't reproduce the original project-coordinator pick on main in 12 runs, so for that half the evidence is that the path is gone, not a red-to-green run.
  • pnpm typecheck is green for workforce and shift-manager. Workforce tests: 1254 of 1255 pass. The one failure is split-down-the-chain, a 5 s timeout that is also red on main here.
  • Changeset included: discover: now works on coordinator workers in the published @flow-state-dev/workforce.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HJZMq1XGNsUeycFS4dXqh9


Note

Medium Risk
Changes which manifest domains workers can see at runtime; mis-resolution could hide needed discovery, but scope is limited to the discover tool and aligns with existing turnConfigOf usage for tools.

Overview
Worker discovery on shared flows now respects each worker's WORKER.md instead of only the shared flow config. workerDiscoverSelection reads discover: from turnConfigOf(ctx) (the resolved worker's settings), so coordinators on the shared coordinator flow are narrowed like other workers.

The DevTeam project coordinator sets discover: [], blocking worker discovery via discover and steering lead selection to listLeads only. Its instructions now state explicitly that listLeads is the sole list of workers that can lead a workstream.

Tests cover an empty discover result for the project coordinator in Shift Manager and a workforce unit case where a resolved worker on a shared flow is narrowed by its own file. A changeset patches @flow-state-dev/workforce for this behavior.

Reviewed by Cursor Bugbot for commit 6ad026c. Configure here.

…h its leads (FIX-1920)

A worker's `discover:` line was read from the flow's own settings, so on
the shared `coordinator` flow a worker's file never narrowed its discovery
tool: the project coordinator could list every worker, itself and the
coordinators included, and pick one that can't lead. The door now reads the
turn's config (the resolved worker's), and the DevTeam project coordinator
names no domains, so `listLeads` is the only list of workers it reads.

Shift Manager's tool line reads a failed call that a later call of the same
tool retried with success as "Tried <tool>", and doesn't mark the run failed.

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

vercel Bot commented Oct 13, 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 13, 2026 12:24pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 13, 2026 12:24pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 13, 2026 12:24pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

FIX-1920

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

cursor Bot commented Oct 13, 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: ae4caed7-503f-41ee-80f7-4188abe977e7)

Copy link
Copy Markdown
Collaborator Author

Second look + architecture notes

Overall the Workforce half is the right fix at the right layer. Findings below, most important first. Nothing here blocks; items 1 and 2 are worth acting on before merge.

1. "Retried" matches on tool name only, so it can hide a real failure (ToolLine.tsx, statesInRun)
openWorkstream(id: "a") fails, then openWorkstream(id: "b") succeeds. The first now reads "Tried openWorkstream" and the run reads completed, though nothing retried the failed work. For a tool that creates things, this is exactly the case where a red line should stay red. Cheapest tightening: also require the later call's args to be deep-equal, or at minimum to share the same top-level identifying args. In the dogfood case (project-coordinator refused, then eng.em) the args differ (lead), so the PR's own motivating example would not be softened by a strict-args rule either. That suggests the UI rule is solving something different from the Workforce fix. If so, say what real case the rule covers, or drop it.

2. Two unrelated changes in one PR
The turnConfigOf fix removes the cause. The ToolLine "retried" display is a presentation policy on a different package, with its own tradeoff (hiding refusals in the transcript). With the root cause gone, the PR body says the original project-coordinator pick couldn't be reproduced on main in 12 runs, so the UI change has no demonstrated trigger. I'd split it into its own PR (or its own issue) so it can be judged on its own merits, and so the Workforce fix lands without it.

3. Opt-in discover: [] is the weak part of the design
The fix makes a worker's file narrow its door, but a coordinator that forgets the line still sees every worker. The invariant the bug report wants is "a coordinator reads workers only through its leads". That is now enforced by one line in one WORKER.md, not by the framework. Worth considering whether coordinator-flow workers should default discover to none of the worker domains. The prompt edit ("you are not one of them") then becomes unnecessary, and the DevTeam file needs no special line. Not required for this fix, but I'd record it on the issue.

4. Test ergonomics (worker-discovery.test.ts)
ctxForWorker(discover, resolved) and askDoor(cap, discover, {}, true) add a positional boolean plus an empty-object placeholder, and resolved silently changes where discover lands. An options object ({ via: "flow" | "turn" }) or a separate ctxForResolvedWorker(discover) would read better. Also note the new case only asserts the [] case; a non-empty selection through the turn config (e.g. ["workers"] narrowing to one domain) would show the config really flows through, not just that "empty stays empty".

5. Minor

  • The test in project-workstreams.test.tsx uses JSON.stringify(output).not.toContain(...). That would also pass if the output were an error or empty for an unrelated reason. Assert the output's shape (domain list/entries are empty) alongside it.
  • Boundary check on workerDiscoverSelection now reaching workers/verified-worker: it is a leaf module and the existing agent-worker-flow.ts already uses it, so no cycle. Good.
  • Changeset is appropriate (shift-manager is not private).

On the open product question (refuse a lead that doesn't fit vs. a general lead): I agree a code check beats more prompt wording, given 11/11 runs lost to the explicit ask. Prompt-only rules failing under an explicit user request is the signal that this belongs in openWorkstream's validation. I'd keep that as a separate follow-up and not fold it in here.


Generated by Claude Code

…920)

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

cursor Bot commented Oct 13, 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: de8e63eb-3d24-4887-820a-f3dc467d1e6a)

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

cursor Bot commented Oct 13, 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: 7139829a-bd3e-4ef5-a879-f1daac612e8b)

@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 (FIX-1920)

Parallel read-only passes over the diff: workforce, shift-manager UI, and reuse/patterns. Overall this is a small, correct fix with one optional UX layer that adds most of the new complexity.

What went right (keep this shape)

The coordinator bug was not missing framework machinery — it was reading config from the wrong bag. workerDiscoverSelection was the lone caller still using ctx.flow.config; the rest of worker flows already use turnConfigOf for per-turn settings (agent-worker-flow, worker-delegates). Switching to turnConfigOf(ctx)[WORKER_DISCOVER_KEY] is the minimal alignment with an existing abstraction, not a new one.

discover: [] on project-coordinator/WORKER.md is data, not more code: turnConfigOf only fixes where config is read; BR-10 still means “no key” ⇒ full scope. The empty list is the enforcement that blocks the workers manifest door while listLeads stays the intentional picker. I would not try to infer [] from flow kind coordinator in code — that would hide policy in framework logic.

Alternatives that would be more complex or wrong:

  • Merging resolved worker config into ctx.flow.config at resolve time (wider blast radius, duplicates turnConfigOf).
  • Using workerConfigOf here (throws when no worker; no flow fallback).
  • A third-party package — nothing applies; this is one line on an internal contract.

Where the PR grew scope (optional simplification)

The ToolLine “retried” / “Tried …” work is logically separate from discovery narrowing. The workforce + discover: [] change fixes behavior; Shift Manager would still show “one failed” on benign openWorkstream → listLeads → openWorkstream retries without this UI pass.

That is not wrong to ship together (same user-visible story, one changeset), but if the goal is smallest diff / single intent, splitting would be cleaner: (1) workforce + WORKER.md + unit/integration discover tests, (2) ToolLine retry labeling.

If you keep ToolLine in this PR, the heuristic is reasonable for coordinator turns but implicit: same toolCall.name, any later item in this group with status === "completed" (args ignored; no cross-group retries). A one-line comment on those limits would help the next reader. A linear two-pass (reverse map of latest completed index per tool name) would drop the O(n²) slice+some without changing behavior — nice-to-have, not blocking; typical grouped runs are tiny.

Note: kitchen-sink / registry flow-state/tool.tsx ToolGroup still treats any failure as group error — intentional fork per file header. No action needed unless you want parity later.

Tests & docs

  • worker-discovery.test.ts with markVerifiedWorker + empty flow config is the right reuse pattern for “shared coordinator flow, per-file discover:”.
  • Lab test via JSON.stringify(output).not.toContain(...) is easy to write but brittle if output shape changes; structured assertions on discover entries would be sturdier if the output shape is stable (soft suggestion).
  • workerDiscoverSelection JSDoc now overlaps turnConfigOf’s doc; a single @link turnConfigOf might be enough (nit).

Verdict

Approve. The workforce approach is the cleanest fix I see. The only “went too far” part is bundling ToolLine retry UX — acceptable product choice, not a design mistake. No blockers.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

…; say what counts as a retry (FIX-1920)

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

cursor Bot commented Oct 13, 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: db4c0770-c3bd-46c7-88fd-441c6e0c55fb)

@jhoffner

Copy link
Copy Markdown
Collaborator Author

Architect: not approving yet. The Workforce half (workerDiscoverSelection reading turnConfigOf, plus discover: [] on the project coordinator) is coherent and I'd approve it as is. The hold is the Shift Manager retry rule at packages/shift-manager/src/components/ToolLine.tsx:54, which treats any later successful call of the same tool name as a retry. So if openWorkstream fails for one workstream and then succeeds for a different one, the real failure reads "Tried openWorkstream" and the run shows as completed. b62af46 documents that limit but doesn't fix it.

What would unblock it: either tighten the rule so a retry has to match the failed call's identifying args (with a test where a different id still reads as failed), or move the ToolLine change into its own PR so the Workforce fix can land alone. Then CI needs to go green.

…-1920)

Matching a retry by tool name alone hides a real failure when a later call
of the same tool succeeds for different work. It goes to its own change.

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

cursor Bot commented Oct 13, 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: 54e7e8d1-317a-429e-ac60-bd3d004c60a1)

@jhoffner jhoffner changed the title fix(workforce,shift-manager): a coordinator reads workers only through its leads (FIX-1920) fix(workforce): a coordinator reads workers only through its leads (FIX-1920) Oct 13, 2026

jhoffner commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

from: fsd-claude
session: fix-1920
to: architect
kind: reply

Agreed. A retry matched by tool name alone hides a real failure when a later call of the same tool succeeds for different work. I took the Shift Manager tool-line change out of this PR in 6ad026c (its patch is saved for a follow-up with a stricter rule), so the PR is now only the Workforce fix and the discover: [] line. CI is running on the new head.


Generated by Claude Code

@jhoffner

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-13T15:09:25.198737Z 6ad026c 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. More of your lovely PRs please.

Reviewed commit: 6ad026cb4d

ℹ️ 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 a7e2a01 into main Oct 13, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants