Skip to content

FIX-1788 P1: check every session at create; server-owned session data - #2850

Merged
jhoffner merged 9 commits into
mainfrom
fix/FIX-1788-p1
Oct 7, 2026
Merged

jhoffner merged 9 commits into
mainfrom
fix/FIX-1788-p1

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

The problem

Today anyone who creates a session decides what is in it. The create request takes the caller's state and stores it, falling back to the raw value when the flow's schema refuses it, and an action sent to an unused session id creates one with no questions asked. That is fine for a draft or a preference. It is not fine for the thing the workforce epic needs a session to carry: which worker it runs. A caller who can write that value can point their session at someone else's worker, or move a running session onto another one. Workers can't become private until a session's binding is checked once, when it is created, and can't move after.

What this does

The binding is ordinary session state, held in a field the flow's session stateSchema declares with zod's .readonly(). The engine enforces three things on every path that brings a session into existence:

  • On a flow that binds its sessions, the schema validates the starting state. A flow binds its sessions when it declares a top-level .readonly() field or a createCheck. Its starting state must match the schema or the create is refused with a 400 naming the field, and nothing is written. Most such flows need nothing more than the schema. Every other flow keeps today's behaviour: the state is kept as sent and validated when an action runs.
  • A readonly field never changes. Set at create; any write that changes it fails, naming the field, and the stored value stays.
  • createCheck (optional) is for a rule the schema can't express, one that depends on who is creating the session or on what exists in the store. It runs after the schema, with the parsed state and the verified caller, can read the caller's own user- or org-scoped collections, and accepts or refuses. serverOwned still names fields a caller may not seed.

The five ways a session comes into existence (the create request, an action sent to an unused id, a webhook delivery, fsdev run, a dispatch into a child session) all go through one birth function, so none of this can be skipped by adding a sixth. Around it: createSession({ state }) is the only way to set the binding; listSessions({ state: { workerId: "w1" } }) and ?state.<field>=<value> list by a readonly field, filtered in each store's query; dispatcher() takes session: { key, state } and a task dispatcher takes state; blocks read ctx.session.state.<field>. The link container, the client's and useFlow's worker, and fsdev run --worker are gone, with no alias (epic D9).

flowchart LR
  A["create request · action on a new id · webhook · fsdev run · dispatcher()"] --> B["one birth function"]
  B --> S{"stateSchema"}
  S -->|refused, on a flow that binds its sessions| D["400 naming the field · nothing written"]
  S -->|parsed| C{"createCheck, if declared"}
  C -->|refused| D2["4xx · nothing written"]
  C -->|accepted| E["session · readonly fields fixed for life"]
  E --> F["every turn reads ctx.session.state · a write that changes a readonly field fails"]
Loading

What's asked of you

Nothing to decide on direction: this reworks S1 of the approved spec (FIX-1788) to the shape the product owner chose on this PR (binding from initial state, fixed fields declared .readonly(), createCheck optional). One thing to know: the create-time schema refusal is opt-in, on flows that bind their sessions. Making it universal broke 53 workforce tests, because the mailbox and project rooms create sessions half-filled on purpose. Widening it is a follow-up below.

Parts worth reviewing closely

  1. packages/engine/src/context/session-birth.ts. The birth function: schema parse (refuse on a flow that binds its sessions, keep as sent otherwise), serverOwned, createCheck on the parsed state, tombstone reclamation, create-if-absent. The check runs on a miss only, and a lost race adopts the winner without re-checking.
  2. The readonly guard. createScopeStateOps takes a guard that wraps every session mutation (stores/state-container.ts), wired in createExecutionContext from getReadonlyStateKeys (core helpers/zod-introspect.ts). It compares each readonly field against what the session was created with, on every mutation the session's state operations apply, rather than on one write verb.
  3. getReadonlyStateKeys reads zod 3 and zod 4. Core is on zod 3 and an app (the CLI's fixtures) can hand it zod 4. Only a plain object root counts; a union, lazy or wrapped root has no readonly fields, and a state filter on such a flow is refused rather than guessed.
  4. The list filter is in the query. Memory and filesystem stores share matchesStateFilter; SQLite uses json_extract with a bound path, Postgres #>> with a bound text[] path. The route admits only readonly fields of the named flow, and refuses anything else with a 400.
  5. fsdev run --seed-session births the session through the same function, and on an existing session refuses a seed that changes a readonly field or sets a server-owned one, including after losing a create race.

Links: spec specs/issues/FIX-1788/ · FIX-1788 · epic FIX-1786 · stack: P1 of three, based on main; P2 (the worker model) builds on this branch, then P4 (the switch). Merges.

Follow-ups: Widen the create-time schema refusal to every flow once FIX-1792 removes the mailbox's half-filled sessions.

How to review this

How to review this. This implements an approved spec — the approach and the numbered
decisions in its DECISIONS.md are already signed off by a human, so please review the
code against that direction, not the direction itself. The canonical set is retained
at specs/issues/FIX-1788/ on main; Linear links to it and the original merged spec
PR, which keeps review history. Follow-up amendment PRs explain later direction changes.
Current architecture docs remain the authority for shipped behavior (BP-037).

Most valuable here: correctness on the second path (the legacy shape, the null
boundary, the concurrent case, the cancel path), anything deriving an auth or routing
decision from caller-controllable input, and a behaviour the tests assert around
rather than on.

Already settled upstream: the approach and every decision in the spec's DECISIONS.md
(human-approved — if one is wrong, say so as a spec finding and it gets folded back; don't
re-argue it inline), and the conventions in docs/contributing/best-practices.md.

Engineering calls
  • Fixed fields are .readonly(), top-level only. A readonly field with a default is still fixed. .readonly() deeper inside a field's value doesn't make the field fixed. A non-object root has none.
  • The check sees parsed state, typed Readonly<Record<string, unknown>>. It accepts or refuses and can't rewrite the state, so what a caller creates with is what is stored and listed by.
  • The action path refuses at admission (runAction) on a flow with a check, before anything is registered, so an action on an unused id is a 400 with no 202 first. The birth inside the context runs the same checks again if the session is still absent there.
  • A session deleted mid-run errors the run. The record writer no longer re-creates a vanished session from its held copy. A test pins that no engine source other than the birth writes a session at "absent".
  • Refusal status. The check picks 400, 403 or 404 (default 400). One route helper (sessionCreateRefusedResponse) turns a refusal into the response for the create, action and webhook routes, with field when one field was the reason.
  • The state filter takes strings only, matched exactly. A number or boolean in state never matches; readonly bindings are ids.
  • useFlow sends no initial state. With worker removed, its createSession and autoCreateSession are refused on a flow whose sessions need a readonly field; the docs say to create through the session client and selectSession the result. Workforce's client (P2) maps its worker to state: { workerId }.
  • Dispatch. An internal dispatcher()'s { key } session takes state, an object or (input, ctx) => object; a task dispatcher takes state beside session, an object or (task, ctx) => object handed the row's assignee, id and input (resolveTaskState), and the hand-off forwards it. A target's refusal is the DispatchRefusal "create-refused". An existing child is adopted with no check and keeps its state.
  • dispatcher() session callbacks are typed from inputSchema, by a first overload for an internal dispatcher that declares one; pinned by dispatcher-session-inference.type-test.ts.
  • Webhook-born sessions start at version 0, as every other path does.
  • ctx.session.lineageId stays, for FIX-1794's partition; session.serverOwned stays.
  • Not in this PR. The testing helpers (createTestContext, testFlow) and the DevTeam lab host still seed session records directly; they are fixtures, not creators a caller reaches. The lab host moves in P4.
Everything else

Verification (BP-003). Each check was seen red before green, by mutating the code and running the named suite (script kept out of the repo).

Check Evidence Red state
Schema, serverOwned and createCheck run on the create route, action path, webhook resolver, fsdev run and a dispatched child packages/engine/test/session-birth.test.ts (27), packages/cli/test/run-command.integration.test.ts › --seed-session Refusal off on every flow: 5 of 27 fail
A flow with neither a readonly field nor a check keeps a schema-rejected starting state as sent, through the create route session-birth.test.ts › "keeps a state the schema rejects as sent…" Refusal on every flow: fails
A readonly field can't be changed by a block, through the HTTP action or runAction, while other fields still write session-birth.test.ts › "a readonly state field" Guard off: 2 fail
fsdev run --seed-session refuses a readonly change, including after a lost race run-command.integration.test.ts Readonly list emptied: 2 of 49 fail
The list filters on readonly state, in every store, never past the owner; non-readonly, no-flow and no-readonly-flow filters are 400 session-birth.test.ts › listing; list-option-widenings in engine (memory, filesystem), store-sqlite, store-postgres Memory filter ignored: 4 fail
The client sends state as state.<field> packages/client/test/sessions.test.ts Not sent: fails
A public dispatcher() and a task dispatcher create the child with their state, and the target refuses without it session-birth.test.ts › dispatch
Readonly detection on zod 3 and zod 4; none under non-object roots packages/core/test/readonly-state-keys.test.ts
No writer outside the birth function session-birth.test.ts › "is the only engine source that creates a session record"
The worked example in the docs runs as written the page's flows, blocks and calls, run verbatim against the engine (temporary test, not committed): 201 for owner and shared user, 404 for anyone else, 400 naming projectId with and without a check, list filter, loadProject output ctx.user.identity.id as owner: 404 for the owner, so the page uses userId

Run locally on fa76e459b: the engine typecheck, the docs build, and the suites of engine, client, fsdev, store-sqlite, store-postgres, orchestration, workforce (1420/1420), testing and integration-tests, all passing. Core and react, unchanged by the last commit, passed on c5325da38 with a full pnpm typecheck. CI on the current head is the live answer.

Docs. "Creating sessions" and the worked example in apps/docs/docs/fundamentals/state-and-scopes.md lead with the schema (z.object({ projectId: z.string().readonly() })) and add createCheck only for "this project is yours or shared with you"; the stateSchema and createCheck rows in configuration/flow.md; the api pages for the client, React and the CLI; { key, state } and create-refused in server/background-work.md; the task dispatcher's state in orchestration/task-board.md; README entries in core, engine and client; docs/architecture/state-and-scopes.md for the birth function and readonly fields. I can't dispatch the docs-writer or docs-editor agents from here; I wrote these myself and the coordinator runs those passes.

Changeset. One fragment, minor for engine, core, client, fsdev, orchestration, store-sqlite and store-postgres: link and worker are removed and state filtering, readonly fields and dispatcher state are new.

Files.

  • core: types/session-create.ts (the check's types), types/flow.ts (createCheck, serverOwned, readonly fields), types/scope.ts (ctx.session.lineageId), types/dispatch.ts ({ key, state? }, TaskStateTarget, resolveTaskState, "create-refused"), blocks/dispatcher.ts, helpers/zod-introspect.ts (getReadonlyStateKeys).
  • engine: context/session-birth.ts (birthSession, checkSessionCreate, parseInitialSessionState, ensureSessionRecord, refuseServerOwnedState, refuseReadonlyStateChange, ReadonlySessionStateError, SessionCreateRefusedError), stores/state-container.ts (the guard), the create, action, list and webhook routes, admission, the dispatch seam, and the two in-process stores.
  • store-sqlite, store-postgres: the state filter.
  • client: listSessions({ state }); cli: --worker removed, --seed-session through the birth; orchestration: the hand-off forwards state. react is back to main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV


Generated by Claude Code


Note

High Risk
Centralizes session creation and enforces binding/auth rules (createCheck, readonly, serverOwned) across HTTP, CLI, webhooks, and dispatch—incorrect checks or race handling could block legitimate sessions or leak access decisions.

Overview
Adds session binding at create time: flows can declare session.createCheck, block caller-seeded fields with session.serverOwned, and fix top-level fields for a session’s life via .readonly() in session.stateSchema. On flows that bind sessions (readonly field or create check), invalid initial state is refused with 400 (and field when applicable) on every create path; other flows still accept raw state as today.

All new session records go through a single birthSession path (session-birth.ts, replacing the old ensure-session-record helper): schema parse, server-owned/readonly rules, create check (with scoped readCollectionItem), tombstone reclamation, and create-if-absent. ensureSessionRecord now takes a SessionCreateRequest beside the record builder; exports include SessionCreateRefusedError, ReadonlySessionStateError, and refusal helpers used by routes, CLI, and execution.

Runtime behavior: session state mutations get a guard that blocks changes to readonly fields; listSessions / GET …?state.<field>= filter only readonly fields (client sends state.<field>; memory/filesystem/SQLite/Postgres filter in-query). Dispatchers can pass session: { key, state } or task state; refusal surfaces as create-refused. fsdev run --seed-session births sessions through the same checks and refuses bad seeds on existing sessions.

Docs, changesets, and tests cover the create route, action admission, webhooks, CLI seed-session races, listing, and dispatcher child creation.

Reviewed by Cursor Bugbot for commit da53df6. Configure here.

…a out of callers' hands (FIX-1788 P1)

A flow can declare `session.createCheck` and `session.serverOwned`. Every
path that writes a new session record (the create route, an action on an
unused id, a webhook delivery, `fsdev run`, a dispatch into a key-derived
child) goes through one birth function that runs the check, reclaims the
id's resource-state tombstones and writes create-if-absent. The check's
answer is stored as the record's `link`, which nothing writes afterwards;
a create that seeds a server-owned state field is refused with a 400
naming it.

The client takes `worker` on `createSession` and `listSessions` (sent as
`link`), `useFlow` passes it to both, `fsdev run` takes `--worker`, the
session listing filters on `link` in all four store adapters, flow code
reads `ctx.session.link`, and `requireRequestHost(ctx).sessionFacts(id)`
reads one of the caller's own sessions' server-written facts by id.

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

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

Request Review

@cursor

cursor Bot commented Oct 7, 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: 7f857766-4cd1-4c28-bee0-dff99d98fb8a)

@jhoffner
jhoffner marked this pull request as ready for review October 7, 2026 18:27
@cursor

cursor Bot commented Oct 7, 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: 54ecec4b-1ab1-4280-89d3-0f55a72a7c6e)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 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-07T19:04:58.219612Z 715ef49 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.

@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 — already tight. No POC.

I read packages/engine/src/context/session-birth.ts, ensure-session-record.ts, packages/core/src/types/session-create.ts, the five birth call sites (session-routes.ts, createExecutionContext.ts, runAction.ts, transports/webhook/session-resolver.ts, create-request-host.ts), packages/cli/src/commands/run.ts, packages/client/src/session-client/sessions.ts, packages/react/src/hooks/useFlow.ts, and the link predicate in the memory, filesystem, sqlite, and postgres session stores.

The shared contract is already one function. Each caller only keeps what differs: 409 versus adopt versus evaluateAdoption, and an HTTP status versus a CLI error versus DispatchRefusal. Folding those policies into birthSession moves the branches; it does not delete them. readCollectionItem is a point read before any session row exists. getPersistedData loads a whole scope off a session and is the wrong call. The four list filters are one equality in each store's existing dialect. Client worker mapped to wire link is the name split this PR already recorded. The admission checkSessionCreate in runAction is the refuse-before-a-request-is-written path; dropping it changes when the 400 happens.

A rewrite would not shrink the contract.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97894aa55c

ℹ️ 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".

Comment thread packages/core/src/types/dispatch.ts Resolved
Comment thread packages/cli/src/commands/run.ts Resolved
Comment thread packages/react/src/hooks/useFlow.ts Resolved
Comment thread packages/react/src/hooks/useFlow.ts Resolved

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

Verdict: The multi-path problem (create route, action, webhook, CLI, dispatch child) really does want a single write funnel. Centralizing tombstone purge → create check → CAS create in birthSession / ensureSessionRecord is the cleaner alternative to sprinkling createCheck at each call site; I would not recommend “check only on POST /sessions” or a thinner wrapper without that funnel.

What looks like the right tradeoff

  • Core owns the contract (session-create.ts); engine owns enforcement (session-birth.ts). That split is easy to navigate.
  • runAction’s early checkSessionCreate (action path, link: undefined) is a deliberate “refuse at the door” gate before registration; keeping birth as the only writer of new rows is coherent.
  • Tests that pin “only session-birth does set(..., "absent")” match the intent.

Where complexity crept in (worth trimming in this PR or a fast follow-up)

  1. Parallel “initial session state” stories — Create route parses caller state through the flow schema; dispatch children use resolveSessionStateDefaults; CLI birth uses state: seedData ?? {} without defaults. Same invariant (“typed reads never see missing keys”), three implementations. A shared resolveInitialSessionState(flow, callerState?) would shrink mental load across route / dispatch / CLI.

  2. ensure-session-record.ts vs session-birth.ts — ensureSessionRecord moved into session-birth.ts while the old file is now mostly purgeStaleResourceState + essay. New readers grep the wrong module. Rename or colocate purge with birth.

  3. sessionFacts org gate — Same file already uses matchesOrgFilter for descendant checks (BP-030 null/omit semantics). sessionFacts uses strict record.orgId !== identity.orgId, which can disagree with dispatch/adoption for legacy rows. Align before callers rely on sessionFacts in production.

  4. Duplicated HTTP mapping — SessionCreateRefusedError → JSON appears in create, action, and webhook routes. A small route-utils helper (like existing concurrency refusals) would be a one-time simplification.

  5. readCollectionItemAt — Reasonable for v1, but it re-implements a slice of resource-route scoping. If a second consumer appears, extract a principal-scoped collection read next to resources/internal rather than growing session-birth.ts.

  6. Performance (non-blocking) — runAction → createExecutionContext → birthSession each session.get on first touch; passing the already-loaded miss into birth would be a larger API change. Fine to defer; worth a one-line comment at birthSession’s leading get that callers often just missed.

  7. Nits — Object.freeze on create-check input (alloc every create); webhook version: 1 vs 0 on other birth paths (confirm intentional).

Third-party packages: Nothing here obviously replaces custom logic; Zod already covers session state on the create route. createCheck is policy + scoped reads, not schema validation.

Tests: Ran pnpm --filter @flow-state-dev/engine test -- session-birth — passed.

I’m leaving comment-only (not blocking merge): the funnel is the right shape; the items above are simplifications and one consistency fix I’d prefer before heavy sessionFacts / workforce adoption, but they don’t overturn the approach.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread packages/cli/src/commands/run.ts Resolved
Comment thread apps/docs/docs/configuration/flow.md Outdated
| `retention` | `{ maxItems?, maxAge? }` | unbounded | Bounds the persisted item log. `maxAge` is milliseconds or a duration string (`"7d"`). Oldest completed requests evict first. A request stays until its run has finished, `onFinished` and any background work it started included, and for twice the configured `LIVE_TAIL_LIVENESS_MS` after (one minute by default), so a busy session can briefly exceed its limits; a request kept this way still counts toward `maxItems`, so older history is evicted in its place. Deleting a request also removes its stream events and cached step results. See [Deleting requests](/docs/persistence/overview#deleting-requests) for the edge cases and what a custom store must support. |
| `historyWindow` | `{ turns: number }` | `50` | Caps cross-turn history loaded per request. `0` or a negative number disables it. Per-call `history({ limit })` can only shrink this window. |
| `cas` | `CASOptions` | — | Optimistic-concurrency options for this scope. |
| `createCheck` | function | none | Runs before a session of this flow is written, on every path that creates one: the create request, an action sent to a session id that doesn't exist yet, a webhook delivery, `fsdev run`, and a dispatch into a child session. It receives the verified caller and the create's `link` input, and can read items of the flow's user- or org-scoped collections at that caller's own scope. It refuses the create, or returns the value stored as the session's `link`, which nothing changes afterwards. A create with no `link` input is refused. A turn on an existing session never calls it. |

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.

We need a proper example showcasing how all this works, because this doesn't really make a lot of sense to me from a docs perspective.

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.

Agreed. This section explains the mechanism but never shows it in use. The next push changes the API slightly: the check only accepts or refuses, and a dispatcher can pass its input. After that push, a worked example goes in, written from the public API alone and then edited. It will show:

  • a flow declaring a create check;
  • creating a session with the value it checks;
  • a block reading ctx.session.link;
  • listing sessions by it;
  • what a refused create looks like to the caller.

I'll leave this thread open for you to resolve.


Generated by Claude Code

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.

The worked example is in, as of da53df6, but its shape has changed from what my earlier reply described: there is no link any more.

It's at Fundamentals → State and scopes → "Example: one session per project". It shows:

  • stateSchema: z.object({ projectId: z.string().readonly() }). A readonly field is set when the session is created and never changes, and most flows need only this.
  • An optional createCheck, used only for "this project is yours or shared with you".
  • createSession({ state: { projectId } }) and listSessions({ state: { projectId } }).
  • A block reading ctx.session.state.projectId.
  • What a refused create looks like to the caller.

This section of configuration/flow.md now points to the example. I'm leaving this thread for you to resolve.


Generated by Claude Code

…8 P1)

- The create check now accepts or refuses, and an accepted link is stored
  as the create sent it, so callers create, list and compare by one value.
- `dispatcher()` takes `session: { key, link }`, so a public dispatcher can
  create a child on a flow that checks its creates.
- `useFlow` drops the active session when its worker changes.
- `readCollectionItem` takes parameter values for a parameterized collection.
- One `resolveInitialSessionState` for the create route, a dispatched child
  and `fsdev run --seed-session`; webhook-born sessions start at version 0.
- The tombstone reclamation moves beside the birth function; one route
  helper answers a refused create.
- `ctx.session.lineageId` beside `ctx.session.link`; the request host's
  `sessionFacts` verb is removed.
- Docs follow the editor pass.

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

cursor Bot commented Oct 7, 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: f93fc0ce-771d-4ec7-b368-d62021b6ecd3)

jhoffner commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

715ef49 changes the create-check contract: a check now accepts or refuses, and the stored link is always the input. It also adds link to dispatcher()'s { key } session, moves the tombstone purge into session-birth.ts, shares resolveInitialSessionState across the create route, dispatched children and the CLI, and adds ctx.session.lineageId. Please look closely at the birth paths and the public dispatcher.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 715ef495a6

ℹ️ 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".

Comment thread packages/core/src/blocks/dispatcher.ts Resolved
Comment thread packages/cli/src/commands/run.ts Resolved
claude added 4 commits October 7, 2026 19:09
…spatches (FIX-1788 P1)

- `dispatcher()` gains a first signature for an internal dispatcher that
  declares `inputSchema`, so `key`, `link` and `id` see the schema's input
  (they were `unknown`, for `key` too). A type test pins it.
- A task dispatcher takes `link`, a string or `(task, ctx) => string`, and
  the dispatcher and the task board's hand-off create each child with it.
- The create route and the listing take a link exactly as sent, untrimmed.
- `fsdev run` checks a session another run created first (owner and
  worker) before running on it.

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

cursor Bot commented Oct 7, 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: 62c9f5ae-d419-4eb6-ab1f-c11d85ba3dea)

claude added 2 commits October 7, 2026 20:02
…nk (FIX-1788 P1)

A session's binding is now ordinary session state in a field the flow's
session stateSchema declares .readonly(). Every create path goes through the
one birth function, which parses the initial state through the schema and
refuses a state it rejects (never stored raw), refuses caller-seeded
serverOwned fields, and runs the optional session.createCheck on the parsed
state with the caller's identity. A readonly field is fixed for the
session's life: the session state operations refuse any mutation that
changes one (ReadonlySessionStateError), and fsdev run --seed-session
refuses the same change.

listSessions({ state }) and the list route's state.<field> filter select
sessions by a readonly field, filtered in each store's query. dispatcher()
takes session: { key, state } and a task dispatcher takes state.

Removed with no alias: the link container (SessionRecord, SessionTarget,
ctx.session.link, the ?link= filter), the client's and useFlow's worker
option, and fsdev run --worker.

Docs lead with the schema and add createCheck only for a rule that depends
on the caller or the store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV
…at bind sessions (FIX-1788 P1)

A flow binds its sessions when it declares a top-level .readonly()
session-state field or a session.createCheck. Only such a flow refuses, at
create, an initial state its stateSchema rejects. Every other flow keeps
the state as sent, as before, and its actions validate it when they run:
the workforce mailbox and project rooms create sessions half-filled on
purpose. Widening the refusal to every flow waits on FIX-1792.

Adds the off-state test (a flow with neither keeps a rejected state raw,
through the create route) and narrows the docs to say it in those terms.

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

cursor Bot commented Oct 7, 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: 03e1fe46-c51a-4e0a-910c-49f769c2dcac)

Shows where a task dispatcher's `state` goes (beside `session`, with every
policy) and points the internal dispatcher's row at it; gives the client's
`state` a referent; defines "binds its sessions" where it is first used;
matches the refusal body to the table; drops a repeated point; writes
`createCheck`'s signature with its Promise.

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

cursor Bot commented Oct 7, 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: 728d6126-20b5-4a60-8052-726e30fc5d42)

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