Repository navigation
fix(orchestration): a wait that finds its task ended is the filer's one hearing of it (FIX-2112) #3697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix(orchestration): a wait that finds its task ended is the filer's one hearing of it (FIX-2112) #3697
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
da86f88
fix(orchestration): a wait that finds its task ended is the filer's o…
claude 6708b3d
test(goals): FIX-2112's verdict on waits-on-a-task-it-filed
claude 07cbbbf
docs(orchestration): scope a wait's one hearing to a notice that wait…
claude efdaea3
Merge origin/main into fix/FIX-2112
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@flow-state-dev/orchestration": patch | ||
| --- | ||
|
|
||
| A `getTask({ id, wait: true })` on a task that already ended returns it at once, and that answer is the filer's delivery: when the flow's `onTaskSettled` waits behind the turn that filed the task, as Workforce's turns make it, the ending's notice request still runs but no longer calls your block. Task collection refs gain an optional `dropNoticeReadByWait(id)`, which both built-in backings implement; a ref without it keeps the old behaviour (FIX-2112). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,8 @@ | |
| * any already below the task it waits on, counted by the engine. A wait | ||
| * that waits again at its deadline counts again before each new park, | ||
| * except a drain on a row it handed over, whose wait already exists. | ||
| * A task already ended is returned at once. | ||
| * A task already ended is returned at once, and the notice its ending | ||
| * owes the filer is dropped: this answer delivered it (FIX-2112). | ||
| * 2. **Take the row's wait slot** in one conditional write (`markWait`): a | ||
| * second request waiting on the same task is refused. | ||
| * 3. **Park** on the one wait gate (`parkOnWait`), whose deadline the engine | ||
|
|
@@ -66,7 +67,7 @@ import type { TaskCollectionRef } from "../collection/types"; | |
| import type { TaskClaimTicket } from "../claim-ticket"; | ||
| import { resolveResourceCollection } from "../collection/resolve-resource-collection"; | ||
| import { getOrCreateTaskCollection } from "../collection/get-or-create"; | ||
| import { holdsAnEnding, LAPSED_SLOT_CHECK_CAP_MS, LAPSED_SLOT_CHECK_MS } from "../notice/task-notice"; | ||
| import { deliveredByWait, holdsAnEnding, LAPSED_SLOT_CHECK_CAP_MS, LAPSED_SLOT_CHECK_MS } from "../notice/task-notice"; | ||
| // The running request's own task, as the claim and the gate know it. Reached by | ||
| // path, not through the task-board barrel, which imports this module. | ||
| import { currentWorkerClaim } from "../../task-board/flow-policy-wiring"; | ||
|
|
@@ -481,14 +482,35 @@ function claimBoardOf(ctx: BlockContext, collectionId: string) { | |
| } | ||
| } | ||
|
|
||
| /** The waited-on row ended: clear what it owes the resume, and return it. */ | ||
| /** | ||
| * The waited-on row ended: clear what it owes the resume, and return it. An | ||
| * ending that came before the wait owes its filer a notice; when the filer is | ||
| * the one waiting, this answer delivers it, so it is dropped (FIX-2112). | ||
| */ | ||
| async function ended(ctx: BlockContext, collection: TaskCollectionRef, taskId: string): Promise<TaskWaitResult> { | ||
| await clearMarker(collection, taskId); | ||
| const task = collection.get(taskId)!; | ||
| await deliverHeldEnding(ctx, collection, task); | ||
| await deliverEndedBeforeWait(ctx, collection, collection.get(taskId) ?? task); | ||
|
jhoffner marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small readability win: |
||
| return { ok: true, task: collection.get(taskId) ?? task, ended: true }; | ||
| } | ||
|
|
||
| /** | ||
| * Drop the notice an ending owes its filer, when the filer's own wait read it | ||
| * (FIX-2112). Never fails the call: a drop that fails leaves the notice owed, | ||
| * and the filer hears the ending a second time. | ||
| */ | ||
| async function deliverEndedBeforeWait(ctx: BlockContext, collection: TaskCollectionRef, task: Task): Promise<void> { | ||
|
jhoffner marked this conversation as resolved.
Resolved
|
||
| const filer = collection.filerOf?.(task) ?? task.filer?.sessionId; | ||
| if (filer === undefined || filer !== ctx.session.identity.id) return; | ||
| if (Object.keys(deliveredByWait(task)).length === 0) return; | ||
| try { | ||
| await collection.dropNoticeReadByWait?.(task.id); | ||
| } catch (error) { | ||
| console.warn(`[orchestration] wait "${task.id}": its ending's notice stays owed: ${(error as Error).message}`); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Clear the row's resume-owed marker. Never fails the call: a clear that fails | ||
| * leaves the marker, and the next touch clears it, the gate already resolved. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional
dropNoticeReadByWaitmeans a customTaskCollectionRefthat implements waits but not this method keeps pre-2112 double-delivery on the fast path. The doc comment calls that out — worth a one-line note in package README’s “implementing a collection” area if such hosts exist, so it’s not only discoverable from the type.