Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions specs/issues/FIX-1788/BUSINESS-RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,38 @@ work.

| # | When | Then | Proved by |
|---|---|---|---|
| BR-10 | Alice creates a session naming her worker, on the flow it names | The server checks it at create and links the session to it, in a field only the server writes. Every turn runs as that worker | CI · VG leg a |
| BR-10 | Alice creates a session naming her worker, on the flow it names | The worker is named in the session's starting state, as its readonly `workerId` ([D5](DECISIONS.md#d5)). The server checks it at create. Every turn runs as that worker | CI · VG leg a |
| BR-11 | A create names a worker of Bob's | Refused with the same answer as a worker that doesn't exist. No session written | CI · VG leg b |
| BR-12 | A create names a worker of Alice's on another flow | Refused, naming both flows. No session written | CI · VG leg b |
| BR-13 | A turn's input carries `worker`, or any route tries to change a session's link | Refused, naming the field. The link never changes: another worker is another session | CI · VG leg b |
| BR-13 | A turn's input carries `worker`, or anything tries to change a session's `workerId`: a block, a tool, an action, `fsdev run --seed-session` on an existing session | Refused, naming the field. The worker never changes: another worker is another session | CI · VG leg b |
| BR-13a | Two `ensureWorkerSession` calls with the same criteria race | One session is created and both return it. Two plain creates make two sessions, each checked | CI |
| BR-13b | A create uses a derived worker-session id that belongs to another user | Refused. Nobody can take Alice's id before her first `ensureWorkerSession` | CI |
| BR-14 | A session on a worker flow is created with no worker, by the create, by an action on a session id that doesn't exist, or by `fsdev run` without `--worker` | Refused at the door, saying a worker must be named. No session written | CI · VG leg b |
| BR-14a | Alice calls `findWorkerSession({ worker })`, or lists with a `worker` filter | Her sessions linked to that worker, most recent first for the helper; none if there are none. Never another user's. The helper matches on the key set (S5a): it returns only sessions that carry no criteria key it did not name, so plain talk never lands in a delegate, task or workstream session. The list filter is not narrowed | CI · VG leg b |
| BR-15 | A session is created with caller state for the link or a server-written field | Refused with 400, naming the field. Nothing written | CI · VG control `caller-link` |
| BR-16 | A session is deleted and its id created again | The new session's link is what its own create named and passed. Nothing carries over | CI |
| BR-14 | A session on a worker flow is created with no worker, by the create, by an action on a session id that doesn't exist, or by `fsdev run` without a `workerId` in `--seed-session` | Refused with 400, naming `workerId`. No session written | CI · VG leg b |
| BR-14a | Alice calls `findWorkerSession({ worker })`, or lists with `state: { workerId }` | Her sessions with that worker, most recent first for the helper; none if there are none. Never another user's. The helper matches on the key set (S5a): it returns only sessions that carry no criteria key it did not name, so plain talk never lands in a delegate, task or workstream session. The list filter is not narrowed | CI · VG leg b |

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.

Same key-set note as S5a: this rule is correct but easy to implement wrong against P1’s list API. If PLAN gets a flow×lookup matrix, BR-14a could point there instead of restating semantics in the table cell.

| BR-15 | A session is created with caller state for a server-written field | Refused with 400, naming the field. Nothing written. Naming the worker in the create's state is not this case: it is how a session is created (BR-10), and the create check confirms it | CI |
| BR-16 | A session is deleted and its id created again | The new session's worker is what its own create named and the check passed. Nothing carries over | CI |
| BR-17 | Bob opens, reads or sends to a session of Alice's | Refused, as today (engine ownership) | Existing suite · VG leg b |
| BR-18 | A task or a mailbox post opens a session for a worker | It names the worker at create, through the same check as BR-10 to BR-12, on the session's user. The worker comes from the dispatching flow's code, never the post's fields | CI |
| BR-18a | A coordinator's session records its delegates after create | Held in server-written session state: flow code writes it, a caller can't (BR-15), and the link beside it stays fixed. FIX-1791 consumes it. Its delivery opens each delegate's session through `ensureWorkerSession`, with the worker and FIX-1791's coordinator-conversation key named; it can't post to a fresh id and rely on the turn (BR-14) | CI, on a fixture flow |
| BR-19 | A linked worker is fired | The turn is refused, naming it as fired. The session stays readable | CI |
| BR-19a | A linked worker's flow is no longer registered | The turn is refused. The session reads as a session of any unregistered flow reads today: this issue adds no engine read path (ER-22) | CI |
| BR-19b | Alice edits a worker to name a different flow | The link holds. A turn on a session created before the edit is refused, naming both flows. New sessions are created on the new flow: `ensureWorkerSession` finds none there and creates one at a new id | CI |
| BR-18a | A coordinator's session records its delegates after create | Held in server-written session state: flow code writes it, a caller can't (BR-15), and the worker beside it stays fixed. FIX-1791 consumes it. Its delivery opens each delegate's session through `ensureWorkerSession`, with the worker and FIX-1791's coordinator-conversation key named; it can't post to a fresh id and rely on the turn (BR-14) | CI, on a fixture flow |
| BR-18b | A task, a mailbox post or a coordinator's delivery reaches a child session that already exists, asking for another value of one of its readonly fields, such as another worker | Refused, naming the field. Nothing is written and nothing runs in that session, which keeps its worker. The mailbox wake keys each member's conversation by worker as well as by mailbox, so two workers woken by one post never ask for one session | CI |
| BR-19 | A session's worker is fired | The turn is refused, naming it as fired. The session stays readable | CI |
| BR-19a | A session's worker's flow is no longer registered | The turn is refused. The session reads as a session of any unregistered flow reads today: this issue adds no engine read path (ER-22) | CI |
| BR-19b | Alice edits a worker to name a different flow | The session keeps its worker. A turn on a session created before the edit is refused, naming both flows. New sessions are created on the new flow: `ensureWorkerSession` finds none there and creates one at a new id | CI |
| BR-19c | Alice forks a worker she already has sessions with | The fork is a new worker with no sessions. Those sessions stay with the original | CI |

## What a worker runs with

| # | When | Then | Proved by |
|---|---|---|---|
| BR-20 | Alice edits her worker | Her next turn on any session linked to it runs the edit. No restart | CI · two hosts |
| BR-20 | Alice edits her worker | Her next turn on any session of it runs the edit. No restart | CI · two hosts |
| ~~BR-21~~ | A stored configuration from an older version loads | Removed by [epic D9](../../epics/FIX-1786/DECISIONS.md#d9): nothing reads a configuration stored before this release | — |
| BR-22 | A configuration names a tool, skill or package the installation no longer registers | That turn is refused, naming it. The row is untouched | CI |
| BR-22a | A user's own worker names a flow that has since become kept for standard workers | That turn is refused with [FIX-1789](https://linear.app/fixpoint-labs/issue/FIX-1789) BR-15's sentence. The row is untouched: a flag flip must not lose a user's worker | CI |
| BR-23 | Two of Alice's workers on `agent` keep private notes | Each reads only its own. Same for every flow-isolated resource on every worker flow | CI · VG leg a |
| BR-23 | Two of Alice's workers on `agent` keep private notes | Each reads only its own. The same on every built-in worker flow | CI · VG leg a |
| BR-23a | Two of Alice's workers on a custom worker flow use data it keeps per user | Shared by both, and never another user's. Keeping it per worker is the flow's author's job; the docs show how ([D6](DECISIONS.md#d6)) | The docs example; FIX-1790 for another user |
| BR-24 | A worker's file grants it one document, read-only | Its model reaches that document and no other, and can't write it, on every turn | CI · the grants goal, rewritten |
| BR-25 | A worker reaches a resource another of Alice's workers wrote at user scope | Allowed: user scope is Alice's, shared by her workers (the concept's memory table) | CI |
| BR-25a | Two of Alice's workers on one flow write a shared resource | Each entry's `writtenBy` names Alice and, as `workerId`, the worker its session is linked to: two workers, two ids. The worker comes from the link, never the input ([FIX-1789](https://linear.app/fixpoint-labs/issue/FIX-1789) BR-20, D1) | CI |
| BR-25a | Two of Alice's workers on one flow write a shared resource | Each entry's `writtenBy` names Alice and, as `workerId`, her session's worker as the turn loaded it: two workers, two ids. The worker comes from the session, never the input or a setting ([FIX-1789](https://linear.app/fixpoint-labs/issue/FIX-1789) BR-20, D1) | CI |

## One copy per flow

Expand Down Expand Up @@ -87,6 +89,6 @@ retries, and nothing is deleted except by a fire.
## Acceptance criteria this issue owns

[The goal](SPEC.md#the-goal-and-how-well-know-its-met) passes on a scripted model with two users
and two hosts, after the same run fails under `org-scoped-workers` and `caller-link`. The epic's
and two hosts, after the same run fails under `org-scoped-workers` and `no-create-check`. The epic's
early leg-c run ([ER-30](../../epics/FIX-1786/BUSINESS-RULES.md#the-closure)) then runs on the
merge commit, in Shift Manager; that run is FIX-1797's.
Loading
Loading