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.
Adds public APIs for database time, so consumers that enforce absolute deadlines no longer call the private
pgconductor._private_current_time().Reading the time
conductor.now(): Promise<Date>reads_private_current_time()exactly: database time, following the test clock / fake offset. Each call is one query.ctx.now(): Datereturns the worker clock the context already has. That is local time corrected by the sampled database offset, the same clock time windows,ctx.checkpoint()and cron use. It needs no round trip and followscreateTestClockthrough the Conductorclockoption.ctx.step()for a value that is stable across replays.emittedAton awaited eventsctx.waitForEvent(), subscriptionwait()andctx.waitForAny()event branches now return{ name, payload, emittedAt: Date }.emittedAtis the dispatch execution'screated_at, the timestamp dispatch already compares with the wait's expiry. Dispatch stores it in the wait's step result, so replays return the same value, and the context revives the stored string as aDate. The change is additive (ReceivedEvent<TDef>is exported). Steps stored before this change have noemittedAt. Under the in-place migration policy that is not handled.Verification
testing.test.ts(public API): with the test clock set and then advanced,conductor.now()andctx.now()follow it.wait-for-event.test.ts: under fake and real time,emittedAtfromwaitForEventand from awaitForAnyevent branch equals the event's storedcreated_at, and a retry replays the same value. A deadline test approves an event emitted before an absolute deadline and rejects one emitted after the clock advances past it.emittedAton all three APIs and the types ofctx.now()/conductor.now(). Existing exact-equality assertions on stored events and winners now includeemittedAt.just lint,just format,pnpm typecheckandpnpm test(71 files, 619 tests) pass.Docs:
api/task-context.md(ctx.now(),emittedAt),api/conductor.md(conductor.now()) and the events guide (crafting-tasks/triggers.md, new "Event Times" section with a deadline example). AGENTS.md is updated.