Repository navigation
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds
ctx.start(key, task, payload, options). It starts an independent execution from inside a task and returns its ID right away.Why
Until now a task could start independent work only through
ctx.emitorconductor.invokeinside actx.step. The second option loses metadata inheritance and needs a hand-made dedupe key.ctx.invokealways suspends until the child settles. Fabrial'sctx.handoffandworkflow.asTool()need to start work now and maybe await it somewhere else.How
buildStartExecution) locks the starting execution (locked_bymust still match), inserts the new execution and saves the step{ id }. Retries and resumes read the memoized step. If the worker no longer holds the starter,ctx.starthangs up withsuspended, the same waywaitForEventdoes.dedupe_keyis derived from the starter's execution ID and the step key. If a crash happens after the insert but before the step is saved, the retry still lands on the same execution. A retried statement after a lost response does too.on conflict (task_key, dedupe_key, queue) do update set dedupe_key = excluded.dedupe_key, so it never supersedes or updates that execution. That differs frompgconductor.invoke(), which supersedes a running holder and would create a second execution when a retry follows a crash. A customdedupe_keytherefore works as "start or reconnect".parent_execution_idand no waiting edge. Settlement'sorphaned_childrenCTE fails a completed execution that has a parent but no waiter ("Parent timed out before child completed"), so setting that column would break started executions. Cancelling the starter doesn't cancel the started execution, because cancellation followswaiting_on_execution_idonly.ctx.invokeandctx.startnow share a smallchildMetadata()helper for resolving inherited or overridden metadata.Await or read the started execution by ID with
conductor.waitForResultorconductor.getExecution(#70).Verification
New
tests/integration/start-support.test.ts:priorityandgroup, and has no parentstartstep (simulating a crash between the insert and the step save), return the same ID, and only one execution exists. Swapping the default key for a random one makes this test fail.dedupe_keyheld by a runningconductor.invokeexecution returns that ID and neither supersedes it nor runs it twiceType test:
ctx.startreturnsstringand checks metadata types.just lint,just format,bun run typecheckand the fullbun test(405 pass) all pass.Follow-ups
ctx.waitForAnywith an{ execution: id }branch: feat/wait-for-any has not merged yet. Once it lands, add that branch on top, reusing the settlement path that wakesctx.invokeparents.docs/content/api/task-context.mddocumentsctx.executionId, butTaskContextdoesn't expose it. Out of scope here.