Support opt-in session restarts through [wdl] session_policy - #10
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in deploy-time session restart policy to the WDL CLI/Wrangler config pipeline, ensuring the CLI both sends the policy to control and verifies control actually applied it so older control planes can’t silently run “preserve” when “restart” was requested.
Changes:
- Introduces
[wdl] session_policyparsing (preservedefault,restartopt-in), strips[wdl]from the temporary Wrangler bundle config, and sendssessionPolicyon the deploy manifest only when set torestart. - Hardens config/table validation by making
asRecordreject TOML datetimes (Date instances), preventing bare dates from being mistaken for tables. - Extends deploy/promotion validation: fails early if deploy response doesn’t echo
restart, and fails if promote response doesn’t confirmrestartplus a positiverestartSequence; updates docs/tests accordingly.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/helpers.js | Adds a shared deployPromoteFetch helper to reduce repeated controlFetch stubs in deploy tests. |
| tests/unit/cli-output.test.js | Adds coverage for formatDiagnosticValue formatting/escaping (NaN/Infinity/Date/control bytes). |
| tests/unit/cli-deploy.test.js | Adds unit coverage for session policy parsing, inheritance, wire behavior, and control-plane acknowledgement enforcement; refactors fetch mocking to use the new helper. |
| templates/AGENTS.md | Documents session policy behavior for generated/agent-facing project guidance. |
| README.md | Updates wording around the hosted offering (“hosted preview”) and clarifies expectations. |
| README-zh.md | Mirrors README hosted-preview wording in Chinese. |
| lib/wrangler/utils.js | Updates asRecord to reject Date values so TOML datetimes aren’t treated as empty tables. |
| lib/wrangler/config.js | Adds parseSessionPolicy, strips [wdl] from bundle config (including envs), and rejects hoisted session_policy outside [wdl]. |
| lib/wrangler-pack.js | Wires session policy parsing into manifest construction; only sends sessionPolicy when restart. |
| lib/output.js | Enhances diagnostic formatting for NaN/Infinity and TOML datetime (Date) values while preserving terminal escaping. |
| GUIDE.md | Documents [wdl] session_policy in the compatibility table and deploy/DO guidance, plus troubleshooting entries. |
| GUIDE-zh.md | Chinese counterpart updates to keep docs aligned with GUIDE.md. |
| docs/secrets.md | Notes that worker-level secret promotions also restart sessions when session_policy = "restart". |
| docs/secrets-zh.md | Chinese counterpart of the secrets doc update. |
| docs/README.md | Adds a docs index entry pointing session policy readers to deploy docs. |
| docs/README-zh.md | Chinese counterpart of the docs index entry. |
| docs/env-overrides.md | Clarifies [wdl] is inheritable into envs (like workers_dev). |
| docs/env-overrides-zh.md | Chinese counterpart of env override inheritance clarification. |
| docs/durable-objects.md | Adds a detailed “Session policy and facets” section explaining restart semantics. |
| docs/durable-objects-zh.md | Chinese counterpart of the DO session policy section. |
| docs/deploy.md | Adds a dedicated session policy section and adds related common-error entries. |
| docs/deploy-zh.md | Chinese counterpart of the deploy session policy documentation. |
| commands/deploy.js | Enforces deploy/promotion acknowledgement for restart policy (and refactors manifest inspection via asRecord). |
| CHANGELOG.md | Adds an Unreleased entry documenting the new opt-in session restart capability. |
| .claude/skills/wdl-deploy/SKILL.md | Updates the deploy guidance distillation to include session policy behavior and doc pointers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Parse the private [wdl] table, strip it from the temporary Wrangler config, and send sessionPolicy on the deploy manifest, verifying that control echoes the policy on deploy and confirms it with a restart sequence on promote so an older control plane cannot apply it silently. Inherit the policy into [env.<name>] like workers_dev rather than treating it as a binding, and reject a TOML datetime as a table in asRecord so a bare date can no longer stand in for [wdl], [triggers], [durable_objects], or an env table. Document the policy in the deploy chapter with facet-level detail in the Durable Objects chapter, in English and Chinese, and share one deploy-then-promote control stub across the deploy tests. Signed-off-by: Lu Zhang <lu@wdl.dev>
cefe30c to
8e77638
Compare
Override undici to ^7.29.0: every miniflare release pins 7.28.0 exactly, so no wrangler version resolves the five advisories on its own, and refresh brace-expansion to 5.0.9 for GHSA-rgw5-rvv9-x895. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Lu Zhang <lu@wdl.dev>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 25 changed files in this pull request and generated no new comments.
Suppressed comments (1)
package.json:53
- Using a caret range in
package.jsonoverrides means published installs (which don’t use the repo lockfile) may pull a newer undici minor/patch than the one you validated here. Since this override is presumably an audit/compatibility pin, consider pinning to the exact version thatpackage-lock.jsonresolves to for reproducibility.
"overrides": {
"undici": "^7.29.0"
},
Render an invalid Date as "datetime invalid" instead of letting toISOString() throw out of a formatter whose parameter contract is unknown, and describe asRecord as a config-table narrowing that rejects arrays and TOML datetimes. State the control-skew recovery the way the CLI does: re-running before upgrading control cannot help, so upgrade control and deploy again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Lu Zhang <lu@wdl.dev>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 25 changed files in this pull request and generated no new comments.
Suppressed comments (1)
lib/output.js:65
- formatDiagnosticValue can still throw because JSON.stringify throws on values like BigInt and circular structures. This contradicts the comment that diagnostics must never throw, and can turn a user-facing validation error into an unexpected crash when formatting an invalid config value.
const stamp = Number.isNaN(value.getTime()) ? "invalid" : value.toISOString();
return escapeTerminalText(`datetime ${stamp}`);
}
return escapeTerminalText(JSON.stringify(value));
}
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a855abe45
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Require both control answers to name what they did, so an unconfirmed promote reads as unknown instead of claiming it did not happen, and state each outcome without printing commands, assembled names or recovery advice. Reject a bare TOML datetime wherever a config table belongs, and give the deploy chapter sole ownership of what a failed deploy leaves behind. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Lu Zhang <lu@wdl.dev>
Report every unknown key in [wdl] at once and render them the way the binding parsers do, and narrow the promote restart sequence once instead of re-coercing it for the type checker. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Lu Zhang <lu@wdl.dev>
Summary
[wdl] session_policy(preservedefault,restartopt-in) to the Wrangler config. The CLI parses the private table, strips it from the temporary bundle config, and sendssessionPolicyon the deploy manifest.restartworker running aspreserveunnoticed.[env.<name>]likeworkers_dev; an env-level[wdl]replaces the top-level table whole.asRecordnow rejects a TOML datetime as a table, so a bare date can no longer silently stand in for[wdl],[triggers],[durable_objects], or an env table.Validation
npm run lint/typecheck/format:checknpm test— 539 pass; nine mutations of the new contracts verified to fail the suitenpm run test:integration:live) against the releasedwdl.20260804.2images — 20 passsession_policy = "restart", promotion closes the live socket with1012 service restart, and a fresh session reaches the new version🤖 Generated with Claude Code