Skip to content

feat(tasks): metadata option for ctx.schedule - #107

Open
psteinroe wants to merge 1 commit into
mainfrom
feat/schedule-metadata
Open

psteinroe wants to merge 1 commit into
mainfrom
feat/schedule-metadata

Conversation

@psteinroe

Copy link
Copy Markdown
Owner

ctx.schedule() takes a metadata option, the same as ctx.invoke(), ctx.invokeAndWait(), ctx.signalWithStart() and ctx.emit(): an object or a function of the current metadata, resolved through childMetadata() (validated against the Conductor's metadata schema and the 8 KB limit). Without it, occurrences keep inheriting the scheduling execution's metadata, as before.

Every occurrence

No SQL change was needed. _private_schedule() stores the resolved metadata on the pending occurrence (and updates it when the schedule is replaced), and _private_schedule_next_occurrence() copies each occurrence's metadata to its successor, so the scheduled metadata flows through the whole chain. A function runs once, at scheduling time. Calling ctx.schedule() again with the same name replaces the metadata for the pending and later occurrences; a running occurrence keeps its own. Replay behaviour is unchanged (not memoized, a replay replaces the pending occurrence).

Verification

The previous timing-based ctx.schedule metadata test is replaced by one on the test clock covering default inheritance, an override, the function form, a schema-validation failure, the first three occurrences of each schedule, and a replacement between the second and third. It failed before the change. just lint, just format, pnpm typecheck and the full pnpm test (615 tests) pass.

Docs: api/task-context.md (schedule) and the execution metadata guide; AGENTS.md updated.

This branch has not been deployed

No deployments
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.

1 participant