Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ opaque `next_cursor` with the same query to continue. JSON and JSONL preserve th
whole page, including counts. Drain or fence admissions and restart the query
before making a branch-removal decision.

## Retention changes

Before shortening a namespace's history retention, preview which closed runs
would become eligible for irreversible pruning, then apply the policy only
while that plan still holds (native Server 3.30.0+):

```bash
dw namespace:retention-plan billing --retention=7
dw namespace:retention-plan billing --retention=7 --json > plan.json
dw namespace:retention-apply billing --plan-file=plan.json --confirm-retroactive-pruning
```

The plan writes nothing. Counts that reach their scan limit are shown as
`at least N`. The apply refuses, changing nothing, if the namespace changed
since the plan, if the proposal differs from the planned one, or if a
retroactive policy is not confirmed. `namespace:update` still activates a
policy at once. See the
[retention plan reference](docs/cli-reference.md#retention-plan-and-guarded-apply).

## Automation Contract

All read and mutating commands support machine-readable output. Use
Expand Down
81 changes: 81 additions & 0 deletions docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,87 @@ dw namespace:update staging --retention=14
dw namespace:delete staging --json
```

#### Retention plan and guarded apply

`namespace:update --retention` activates the new policy at once, and the next
retention pass applies it to existing closed runs. To see what a change would
do first, preview it with `namespace:retention-plan`, then apply it with
`namespace:retention-apply` only while that plan still holds (native Server
3.30.0+, Server #522). Both need an admin token.

```bash
# Preview shortening billing's retention to 7 days; nothing changes
dw namespace:retention-plan billing --retention=7

# Preview keeping terminal history until it is deleted or archived
dw namespace:retention-plan billing --retention-mode=forever

# Apply the plan with its revisions; a retroactive policy needs the confirmation
dw namespace:retention-apply billing --retention=7 \
--policy-revision=sha256:... --plan-revision=sha256:... --confirm-retroactive-pruning

# Or save the plan and apply exactly what it planned
dw namespace:retention-plan billing --retention=7 --json > plan.json
dw namespace:retention-apply billing --plan-file=plan.json --confirm-retroactive-pruning
```

`namespace:retention-plan` takes the proposed `--retention` days,
`--retention-mode` (`bounded` or `forever`), or both. A field you leave out
keeps its current value. It shows the current and proposed policy with their
cutoffs and whether the proposal is retroactive, meaning it makes closed runs
eligible for pruning that the current policy keeps. It then counts closed,
unarchived runs in four groups: `newly_eligible`, `no_longer_eligible`,
`unchanged_eligible` and `unchanged_retained`. It also counts the runs a prune
would not delete: `archived`, `forever`, `not_terminal`, and eligible runs held
by `detached_activity_hold`, `external_payload_cleanup_unavailable` or
`backup_hold`. Each group lists up to five example runs, oldest first.

`--scan-limit` (default 1000, at most 10000) bounds each count, and
`--hold-scan-limit` (default 100, at most 1000) bounds how many eligible runs
are checked for holds. A count that reaches its bound is shown as `at least N`.
The plan is then incomplete, and `Incomplete` names each such count.

The output ends with the plan's scope and the exact `namespace:retention-apply`
command for it. That command repeats the resolved proposal and both revisions,
and adds `--confirm-retroactive-pruning` when the plan is retroactive.
`--json` returns the Server's `durable-workflow.v2.retention-plan.v1` document
unchanged.

The plan writes nothing. It changes no policy, marks no row, fetches no payload
and prunes nothing. It describes one moment: runs can close, age past the
cutoff, be archived, or gain and lose holds, and the policy can change before
the next retention pass. It is not a list of what a later prune will delete.

`namespace:retention-apply` sends the proposal with `--policy-revision` and
`--plan-revision` once and never resends it. Pass the same `--retention` and
`--retention-mode` you planned, or pass `--plan-file` with the plan's saved
`--json` output. That file supplies the proposal and both revisions, so it
cannot be combined with those four options. A retroactive proposal also needs
`--confirm-retroactive-pruning`, because pruning is irreversible. The Server
checks the revisions and updates the policy in one transaction. It refuses, and
changes nothing, in these cases. `dw` prints the reason and the next step, and
exits 2:

| Status and reason | Cause | Next step |
| --- | --- | --- |
| `409 retention_policy_revision_stale` | The namespace changed after the plan. The refusal carries the current `policy_revision`. | Plan again, review it, and apply the new plan's revisions. |
| `409 retention_plan_revision_mismatch` | The proposal sent is not the one that was planned. | Apply the plan's exact proposal, or plan this one. |
| `422 retention_pruning_confirmation_required` | The proposal is retroactive and `--confirm-retroactive-pruning` was not passed. | Review `newly_eligible`, then repeat with the confirmation. |

With `--json` a refusal keeps the usual error envelope, with `reason`,
`status_code` and the full body in `server_response`.

An accepted apply shows the previous and new policy with their revisions, and
`--json` returns `durable-workflow.v2.retention-apply.v1`. The apply changes
only the namespace's policy and prunes nothing itself. Each later retention pass
prunes the closed, unarchived runs past the cutoff at that pass. That can
include runs that closed or aged after the plan, and it skips runs archived or
held at that time.

A Server without these routes answers 404. `dw` exits 5 and says that native
Server 3.30.0 or later is needed. `namespace:update` is unchanged and still
activates a policy at once, with no plan or confirmation.

Configure external payload storage for a namespace:

```bash
Expand Down
1 change: 1 addition & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ command is ported.
| `task-queue:pause-activities`, `task-queue:resume-activities`, `task-queue:activity-dispatch`: pause, resume and read activity dispatch on one task queue (Server #577), one request each after checking cluster info for `capabilities.task_queue_activity_dispatch_pause`; `task-queue:describe` and `task-queue:list` show the state when the Server reports it | Rust-only, new |
| `task-queue:retirement`, `task-queue:retire`: inspect what still depends on one worker build (`--build-id`, `--unversioned`) or a whole task queue, and retire it only when nothing does (Server #519), one request each after checking cluster info for `capabilities.worker_build_retirement`; `--expected-revision` binds the retire to an inspected inventory, and a 409 refusal (nothing changed) prints its blockers, recovery and expected resolution and exits 2 | Rust-only, new |
| `workflow:history-archive`, `workflow:history-archive-check`: a self-contained, verified archive of one closed run (Server #520). It holds the export, the exact bytes of every external payload it references, a manifest of their digests and a receipt. The copy runs under the external payload backup hold, resumes in the same directory and releases a crashed copy's hold; verification needs nothing but the directory and agrees with the Server's v1 conformance archive | Rust-only, new |
| `namespace:retention-plan`, `namespace:retention-apply`: preview a proposed retention policy (Server #522) with counts of the closed runs it makes eligible or ineligible for pruning, exclusions, examples and explicit `at least N` for incomplete counts, then apply it once, bound to the plan's `policy_revision` and `plan_revision` (or `--plan-file`), with `--confirm-retroactive-pruning` for a retroactive policy. A stale, mismatched or unconfirmed apply (409/422) changed nothing; dw prints the next step and exits 2. A Server without the routes (404) is reported as needing native Server 3.30.0 | Rust-only, new |
| `workflow:update-outcome`: read an update's outcome later by its update ID (Server #1131, durable-workflow/.github#212), one GET after checking cluster info for `capabilities.update_outcome_reads`; pending, completed (including a null result), failed (exit 2), rejected and `update_not_found` (exit 5) are reported distinctly, and the update is never sent again. `workflow:update` points an unfinished update at it when the Server advertises the capability | Rust-only, new |

Server calls go through the `durable-workflow` crate. The unreleased native
Expand Down
Loading
Loading