Repository navigation
Description
User need and decision
An operator shortening retention should be able to see which existing history will become eligible for irreversible pruning before applying the policy. durable-workflow/durable-workflow.github.io#264 correctly documented that current policy applies retroactively. Keep that truthful documentation, and add a supported prospective impact plan and guarded apply path.
Current NamespaceController::update persists the policy immediately; retentionStatus inspects the already-active policy. The enforcer can subsequently prune newly eligible history. This is an additive data-safety improvement, not a claim that documented retroactive behavior is a defect.
Acceptance
- Provide a read-only prospective-policy plan scoped to the exact namespace and current policy revision. Show affected retained/pruned history, bounded example identities, count/scan completeness and archive/forever/backup-hold exclusions. Unknown/incomplete counts are explicit.
- Preview must not mutate policy, mark rows, fetch payload objects or trigger pruning. Preserve original fingerprints in the qualification.
- Add an explicit guarded apply that confirms retrospective deletion scope and rejects stale policy/plan versions. State what may change between a preview and cleanup; do not describe a non-atomic scan as an exact immutable deletion snapshot.
- Preserve old clients through an additive/versioned path. Do not silently change the current API's activation contract or weaken holds.
- Test policy shortening/lengthening, archived/forever/held runs, concurrent policy changes and incomplete scans on published artifacts. Publish the operator journey in CLI/API/UI documentation as applicable.
Existing #500 and durable-workflow/workflow#852/#856 concern distinct retention/summary/export defects. #520 owns independent archives, not permission to prune. Priority P3; no implementation is delivered here. General owns PHP work after the normal source-window agreement; native adoption is separate.
Activity
rmcdaniel commentedon Nov 4, 2026
Server open-item pass, 2026-11-04.
Owner: Server for native prospective-policy read/guarded apply; CLI/Waterline for the eventual operator journey, General for policy compatibility. The existing retroactive activation contract remains true; this is additive protection, not a silent change to old clients.
Next artifact defines namespace/policy revision binding, bounded examples and count completeness, exclusions and explicit stale-plan refusal. Preview must make zero writes and no provider/object requests. Guarded apply confirms retrospective scope without calling a non-atomic scan an immutable deletion set. General: review that versioned compatibility boundary; Server then prepares shortening/lengthening/hold/concurrent-change source controls. No retention preview, policy change or prune was executed.
rmcdaniel commentedon Nov 11, 2026
Triage 2026-11-11: still open; no preview path in native retention. Owner: server. Backlog after #633 and #500.
rmcdaniel commentedon Nov 25, 2026
Current state on native Server 3.28.0: a namespace update still activates
retention_mode/retention_daysimmediately (rust/src/runtime/namespaces.rs).GET /api/system/retentionandPOST /api/system/retention/passinspect or apply only the active policy. There is no prospective plan and no guarded apply. The documented retroactive behavior is unchanged and accurate.Scope update: PHP Server is frozen at 2.11.8, so this is native-only.
Remaining:
Next action: server implements the read-only plan endpoint, with tests for shortening, lengthening and held runs.
Add a read-only native retention plan (Refs #522)
Prepare native Server 3.30.0
Prepare native Server 3.30.0
Prepare native Server 3.30.0
Prepare native Server 3.30.0
rmcdaniel commentedon Nov 26, 2026
#522 complete: acceptance met
POST /api/namespaces/{ns}/retention-plan,retention-plan.v1)POST /api/namespaces/{ns}/retention-plan/apply,retention-apply.v1,plan_revision,confirm_retroactive_pruning)PUT /api/namespaces/{ns}is unchanged (row 9 below). Holds are still checked at prune time (row 10).docs/server-reference.md(#1350, precision fixed in #1364). Docs site: durable-workflow.github.io#620, all 7 locales. CLI: durable-workflow/cli#178 (dw namespace:retention-plan,dw namespace:retention-apply). Waterline UI: no retention-policy UI exists to extend.One precision point came out of the qualification and is now documented (#1364, #620).
policy_revisionincludes the namespace'supdated_at, which PostgreSQL and MySQL round to the whole second and MariaDB truncates. Any change to the retention mode or days always produces a new revision. A non-retention namespace update that stores the same second does not.Published-artifact qualification: retention plan + guarded apply (native Server 3.30.0)
Artifact:
ghcr.io/durable-workflow/server@sha256:b7bb6007e2cfeb76823fdaf497e279656e3d10cf441c735b7181c72f698087bd(the same digest asdurableworkflow/server:3.30.0). Release label3.30.0, revisione00022c9./api/cluster/inforeportsversion: 3.30.0, implementation: rust. The image was pulled by digest, not built from source, and no release was touched.Backends: each backend ran in a fresh database with the same script and the same seed.
/app/database/database.sqlite), single containerpostgres:17-alpine)DB_CONNECTION=pgsql,schema-bootstrapmysql:8.0)DB_CONNECTION=mysql,schema-bootstrap. Root applied the checkpoint DDL, which is the documented compose path: bootstrap answerednative_child_checkpoint_trigger_privilege_required.Common setup: token auth with
DW_AUTH_TOKENplus role tokens. Plans and applies used the admin token andX-Durable-Workflow-Control-Plane-Version: 2over real HTTP. An operator token gets403 forbidden(allowed_roles: ["admin"]) on both plan and apply.DW_RUST_MAINTENANCE_LOOP=0was set so the background retention loop could not prune between steps or move fingerprints. Enforcement was then exercised explicitly withPOST /api/system/retention/pass(row 10).Seed: namespace
q522, bounded, 30 days. Runs were seeded with raw worker HTTP on protocol 1.20: start, poll, thencomplete_workfloworfail_workflow.age40-completedage20-completedage20-failedage10-completedage3-completedage0-completedage20-archivedPOST /api/workflows/{id}/archiveage40-archivedPOST /api/workflows/{id}/archiveage20-heldopen-runage20-heldscheduled an activity withcancellation_policy: "abandon". Its run was then closed by canonical cooperative cancellation:request-cancellation, thendeliver-cancellation, thencomplete_workflow. That givesWorkflowCancelled, runcancelled, and the activity stillpending.Deviation: close ages were backdated directly in the database. Native 3.30.0 has no supported path to backdate a close time and no clock override. After each run closed through the API, the script ran
UPDATE workflow_runs/workflow_run_summaries SET closed_at=<now − N days − 1 h> WHERE id=<run>. Those are the only direct writes, and they all happened before the "before" fingerprint. Every other state was produced through the API.Scenario results (identical on SQLite, PostgreSQL and MySQL; 40/40 checks each)
{"retention_days":7}retention-plan.v1,read_only: true,retroactive: true,complete: true.newly_eligiblecount 4: age20-completed, age20-failed, age20-held, age10-completed.unchanged_eligible1 (age40).unchanged_retained2 (age3, age0).no_longer_eligible0.policy_revisionandplan_revisionaresha256:….falseretention_pruning_confirmation_required,retroactive: true. Policy stays at 30.confirm_retroactive_pruning: trueretention-apply.v1,retroactive: true,confirmed_retroactive_pruning: true, newpolicy_revision. Namespace is now 7. Re-sending the same apply gives 409retention_policy_revision_stale, so a plan cannot be applied twice.retroactive: false,no_longer_eligible4,newly_eligible0. Apply: 200,retroactive: false, namespace 30.retroactive: false,exclusions.forever7 (every closed, unarchived run, including the held one). Apply: 200, modeforever.retroactive: true,newly_eligible1 (age40). Apply without flag: 422retention_pruning_confirmation_required, mode staysforever. Apply with flag: 200, now bounded 30.exclusions.archivedcount 2 (age20-archived, age40-archived). Neither appears in anychangescount or example.exclusions.detached_activity_holdcount 1, exampleage20-held.hold_inspection.inspected: 5, complete: true.exclusions.not_terminal1 (open-run).PUT {"retention_days":14}, then apply with the old revisionsretention_policy_revision_stale. The answer carries the new currentpolicy_revision. Namespace stays at 14 from the PUT.PUT {"description":…}, then applyretention_policy_revision_staleretention_days: 5with that plan's revisionsretention_plan_revision_mismatch. Namespace unchanged.validation_failed(policy_revisionandplan_revisionrequired)scan_limit: 1, hold_scan_limit: 1complete: false.newly_eligible,unchanged_retainedandexclusions.archivedare{count: null, lower_bound: 1, complete: false}. The three hold counts are{count: null, lower_bound: 0, complete: false}withhold_inspection.inspected: 1.incompletelists 3 ×scan_limit_reachedand 3 ×hold_scan_limit_reached. Counts within the bound stay exact (unchanged_eligible1,not_terminal1).PUT {"retention_days":3}at 14 days, which is retroactiveGET /api/system/retentionshows the 3-day cutoff withexpired_run_count6.POST /api/system/retention/passprocessed 5, pruned 4, skipped 1. Pruned: age40, age20-completed, age20-failed, age10. age20-held skipped withdetached_activity_still_open. Archived runs were not candidates. A plan made afterwards still reports the held run indetached_activity_hold, and archived 2.Preview fingerprints (scenario 8)
Between the two fingerprints the script ran:
scan_limit 1 / hold_scan_limit 1, and 30→7 again.confirm_retroactive_pruning: false, both 422.Each fingerprint has two parts:
GET /api/workflows/{id}for all 10 runs,GET /api/workflowsandGET /api/system/retention..dumpof a copy ofdatabase.sqlitewith its-waland-shmfiles. PostgreSQL:pg_dump, with the random per-dump\restricttoken lines removed. MySQL:mysqldump --skip-dump-date --order-by-primary --hex-blob.56c8f67667014c7cf1bdd2b17e85fce18785de71b200be768e1530c6975378506ca4e682c210c40573c06d6fb3d450660fb997f5b4b65a6a064149fa0a7a97cc(171,677 B)e52ee28caacfedd00d50c207dcbdc383728f96077cef29a330975ebd27c6e2f17b7120c5ad7613b748a21e90e73ffc263099f7529d6d99df1683b2832e9d8719(272,525 B)d207d7a63b8531f3e4269bd38a0fe232b578614c008696ee99670972c1c141d9615c7f00f19bf64d64a41d5fff6dcb6bc381d2adaf5be5f5081deabd5221f26c(255,103 B)Observation (low severity; docs precision, not a safety gap)
On PostgreSQL and MySQL,
workflow_namespaces.updated_atistimestamp(0)(whole seconds). A description-only PUT in the same second as the previous namespace write therefore leavespolicy_revisionunchanged.PUT {"description":…}, then an unconfirmed apply. PG and MySQL answered 422retention_pruning_confirmation_required, which means the revision check passed. SQLite (millisecondupdated_at) answered 409retention_policy_revision_stale. Nothing was written in either case.updated_attoo, so they also produce a new revision" holds only at one-second granularity on PG and MySQL.Per backend, from the 30 → 7 plan:
policy_revisionplan_revisionsha256:c198c26c…2628f9sha256:467859a4…e844bsha256:4a713e09…7ed0sha256:b8c47de8…d83fsha256:4216f92e…c112sha256:1d9bcbd1…129b