Repository navigation
Conversation
Replaced the previous pins schema with a user state schema that defaults to an empty array for pinned items. Updated the pinsBlock handler and the definePinsFlow function to utilize the new schema for input and output, ensuring consistency in handling user state across the flow.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Second look + architecture pass (read-only; one file, +10/−8)Verdict: right direction, small and worthwhile. No better approach to pursue; a few things to fix or verify before merge. I could not run Is there a better approach?No. One schema declared once and handed to the flow's Needs attention
Minor / optional
Architecture opportunityNone to take in this PR. The unified-schema move is already the whole refactor. The only follow-up worth noting (separate issue, not here): the No changeset needed (lab, private). Generated by Claude Code |
There was a problem hiding this comment.
Simplify review
Read this as two layers: the pins typing refactor (what the title describes) and a much larger bundle (workforce defaults, DevTeam EM/harness, teammates coder brief, goals tsconfig, FIX-2490 spec amendments).
Pins (labs/claude-code-style/workforce/flows/pins.mts) — approach looks right
Hoisting userStateSchema, declaring it on handlers, reading ctx.user.state.pinned, and dropping pinnedOf + defineFlow(…) as never is the cleaner pattern the fundamentals docs and kitchen-sink already use. I would not go back to a local pinnedOf helper; that was the old escape hatch.
Optional nits only: reuse taskInput inside pinsBlock instead of re-inlining the same taskId schema, and trim the trailing whitespace on the blank line after pinsBlock.
Where complexity comes from (not the pins edit)
PR scope vs title — Most of the diff is unrelated to pins. That makes simplify review, bisect, and rollback harder. If this branch is intentionally a cleanup stack, a title/body that lists the bundled concerns (or splitting merges) would match what reviewers are actually signing off on.
Two hand-synced default-layer prompt slots — Exporting workerIdentityPrompt and calling it from em.mts is the right reuse vs copying strings. The cost is a duplicate lambda plus a “must change together” comment vs agent-worker-flow.ts (~1149), while the agent flow comment explicitly warns against widening into a compose helper before FIX-2498. A narrower middle ground (if you want less drift risk without FIX-2498): export something like workerIdentityPromptEntry(installation) that returns the same slot function both flows use — not a registry, just one callsite for the lambda shape. The new Lab integration test is a good enforcer either way; importing TOOL_USE_RULE (or a stable prefix) in shift-manager tests instead of re-stringifying the opener would tie assertions to workforce’s canonical text.
maxSteps default 50 — Simpler control flow than the old conditional spread (maxIterations: options.maxSteps ?? DEFAULT_MAX_STEPS). This is the main cost/latency knob in the PR (worst-case tool loops × prompt/tool resolution). Docs/changeset match intent; apps that relied on the old implicit cap need maxSteps: 8 explicitly.
Harness preset + tools — Moving to Claude Code’s preset: "claude_code" with append (ER-5) is the right simplification vs a plain string that replaced SDK behavior. Grep/Glob on the coder harness may add tool rounds; seems intentional for real coding work.
FIX-2490 spec/decision SVG churn — Substantive and fine, but orthogonal to pins; riding in the same PR increases review surface without simplifying runtime code.
Performance / reuse (parallel read-only pass)
No new busy-waits or obvious accidental N+1 in the diff. Identity string rebuild each loop step is pre-existing pattern, now on EM too; optional future cache if profiling says so.
Teammates vi.mock(… workerConfigOf …) duplicated across two test files — small DRY opportunity, not blocking.
Verdict
Pins: approve the direction. Whole PR: comment, not approve — not because the workforce/harness/teammates changes look wrong, but because the bundle + dual prompt-slot sync are the kind of complexity a simpler process or a tiny exported prompt-entry helper would reduce. I’m not requesting changes on merge if this stack is deliberate; the items above are what I’d simplify if tightening the diff.
Sent by Cursor Automation: Review For Best Approach
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1a088e63b
ℹ️ 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".
There was a problem hiding this comment.
Code Snob — already tight. No POC.
Head f1a088e63b5daab4b448049f1b84409d60992943. pins.mts, +10/−8. A rewrite leaves the same contract.
- One schema, three slots.
userStateSchemais the stored bag (user.stateSchema,.default([])), the handler context (userStateSchematypesctx.user.state), and the return (outputSchema).pinnedOfand theas nevercast are already gone. handler.withDefaults. A helper for{ outputSchema: userStateSchema, userStateSchema }is four lines. It removes those two keys onpinsBlockand onlistPins, also four lines. Tie, at two call sites.taskInput. Same shape as the block'sinputSchema. The action field is the optional override (runActionusesaction.inputSchema ?? action.block.inputSchema). Dropping the const leaves the block schema and both action entries.harnessinharness-thread.mtsspells that override on the action and the block.listPins. The read must notpatchState. Folding it intopinsBlockadds a branch.
Files: labs/claude-code-style/workforce/flows/pins.mts, packages/core/src/blocks/handler.ts, packages/core/src/types/flow.ts, packages/engine/src/execution/runAction.ts, labs/claude-code-style/workforce/flows/harness-thread.mts.
Left as recorded: client data in place of the read, and a shared pins resource. Both were already set aside because they came out no smaller.
Sent by Cursor Automation: Code Snob
The engine doesn't apply user.stateSchema's .default([]) to stored user state, so a first pin read ctx.user.state.pinned as undefined and threw. Keep the empty-pins fallback (pinnedOf), drop the action-level taskInput override (the block's inputSchema is used), and cover a fresh user's pin/unpin on the real engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Replies to the reviews on f1a088e; fixes are in eb1d3db. Codex P1 (first pin throws): confirmed and fixed. Details are on the inline thread. Cursor, Simplify review:
Cursor, Code Snob: no change. The review agrees nothing more is warranted. Second look:
Possible follow-up, outside this PR: |
|
Architect: not approving yet. The PR text says the — FSD Architect |
# Conflicts: # labs/claude-code-style/workforce/flows/pins.mts
|
This PR acts as an example of how we should be leveraging typed schemas more so that we don't need ugly helper methods that bloat the codebase and make things more complicated to read then they need to be. However I'm putting on hold until we both decide what to do with #4820 and the "CRUD flow" issue, as well as wait for the #4800 spec to be implemented. |
|
Keeping this on hold. We are about to do a large "Kit" addition which might break this PR, but its an example we will keep for when we do a large refactor. Now that we support proper defaults within schemas, we can likely update dozens (hundreds maybe) of instances in the codebase that use helper methods where they should rely on schema defaults and proper usage of schema like how userStateSchema does here. |


What
The lab's
pinsflow now declares its user state schema once and uses it everywhere:userStateSchema({ pinned: string[] }, defaulting to[]) is passed to the flow'suser.stateSchema, and to each handler asuserStateSchemaandoutputSchema.ctx.user.state.pinnedwith its type. ThepinnedOf(ctx)cast helper is gone.defineFlowno longer needs theas nevercast.No behaviour change: the same actions (
pin,unpin), the same read (listPins), and the same stored shape.Why
We underuse
userStateSchemaacross the codebase. This cleans it up in one place. We looked at larger simplifications here (client data in place of the read, a shared pins resource with a capability) and set them aside: none of them made this smaller.Verification
pnpm --filter @flow-state-dev/claude-code-style typecheck: cleanpnpm --filter @flow-state-dev/claude-code-style test: 23 files, 159 tests passedNo changeset:
labs/is private.🤖 Generated with Claude Code