[core] Add a retention option to start() - #3786
Closed
VaguelySerious wants to merge 2 commits into
Closed
Conversation
Records a data-retention preference on the run for the World to apply once the run finishes, as the reserved `$retention` attribute. `'default'` and omission write nothing, so a run that states the default is indistinguishable from one that says nothing. `'none'` and any World-specific string are recorded verbatim; the SDK assigns no meaning beyond validating that the value fits in an attribute. The preference rides on run attributes, so a World that cannot carry them throws rather than silently retaining data the caller asked to have dropped. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Peter Wielander <29887157+VaguelySerious@users.noreply.github.com> Co-Authored-By: Peter Wielander <29887157+VaguelySerious@users.noreply.github.com>
Contributor
🦋 Changeset detectedLatest commit: aa5f325 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The mocked tests in start.test.ts pin what the SDK sends. This pins what a World stores: that the reserved key survives validation on the way in, and that 'default' really is indistinguishable from omission on the created run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Peter Wielander <29887157+VaguelySerious@users.noreply.github.com> Co-Authored-By: Peter Wielander <29887157+VaguelySerious@users.noreply.github.com>
Member
Author
|
closed in favor of #3787 |
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.
Description
Adds
start({ retention }), a per-run data-retention preference the World applies once the run finishes. The value is recorded as the reserved$retentionrun attribute — attributes already ride along onrun_createdand on the resilient-start queue message, and are materialized onto the run entity, so the World can read the preference at finish time with no new wire field.Documented on
StartOptionsexactly as specified:Behavior notes, in the order a reader hits them:
'default'and omission are byte-identical. Neither writes an attribute, so "same as omission" is literally true rather than approximately true — no attribute slot burned, nothing for a World to interpret.$retention. Callerattributesare spread between lineage and retention, so a framework caller withallowReservedAttributescan still deliberately re-parent a run, but cannot silently weaken a retention preference. Quietly keeping data the caller asked to drop is the worse failure of the two.'none'and World-specific strings are recorded verbatim.The Vercel side of
'none'is implemented in vercel/workflow-server#858.How did you test your changes?
packages/core/src/runtime/start.test.tsgains aretentionblock: seeding on both payloads for'none'(including theallowReservedAttributesflag each needs), verbatim pass-through of a World-specific string, no attribute at all for'default'/omission, merging with caller attributes, precedence over a hand-written$retention, the pre-v4 rejection, and rejection of empty/non-string/oversized values.packages/core/src/runtime/start-retention.world.test.tsthen checks the same thing against a real World (@workflow/world-local) rather than mocks: that the reserved key survives validation on the way in, that a World-specific string is stored verbatim, and that'default'really does leave the created run's attributes identical to omission.Also ran the full
packages/coresuite (2126 passed) andpackages/world(110 passed). Two pre-existing failures in this sandbox are unrelated and reproduce onmain:src/runtime/quickjs-runtime.test.tsneeds the Rust-built QuickJS asset, andpackages/world/src/spec-version.test.tsassertsSPEC_VERSION_CURRENT === 5.PR Checklist - Required to merge
pnpm changesetwas run to create a changelog for this PR@vercel/workflowin a comment once the PR is ready, and the above checklist is complete🤖 Generated with Claude Code