Skip to content

Rust server: prune expired run history like published PHP - #595

Merged
rmcdaniel merged 2 commits into
mainfrom
rust-325-history-retention
Oct 21, 2026
Merged

rmcdaniel merged 2 commits into
mainfrom
rust-325-history-retention

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Part of #325.

What changed

Published dw 2.3.0's system:retention-status, system:retention-pass and system:activity-timeout-status received native's 501. Native's worker heartbeat also never pruned, so a bounded namespace (the default keeps 30 days) kept every closed run.

Native now serves these admin-only routes in the default or a named namespace, by the rules of published PHP 2.5.14's SystemController, HistoryRetentionEnforcer and ActivityTimeoutScanner:

  • GET /api/system/retention: the policy, cutoff and the oldest expired runs.
  • POST /api/system/retention/pass: prunes the given or expired runs.
    • It skips a run with PHP's reasons.
    • Otherwise, one transaction deletes the run's details from PHP's twenty tables and keeps the run row.
    • It answers 207 when a run failed.
  • GET /api/system/activity-timeouts: open executions past a deadline, across namespaces as in PHP.
  • The worker heartbeat runs PHP's inline pass (one run, at most once a minute per namespace) and reports it as retention.
  • Laravel's validation messages, including nested items such as run_ids.0.

Differences from PHP

  • Native does not yet clean up external payload objects or message streams. It skips a run that has either, with external_payload_cleanup_unavailable or message_stream_cleanup_unavailable, rather than delete rows that point at storage it would leave behind.
  • The inline throttle is per process. PHP's is a cache entry.
  • POST /api/system/activity-timeouts/pass is still open. Native enforces activity deadlines in its own loop.

The checkpoint is in docs/rust-server-port-checkpoints/2026-10-21-history-retention.md. Each new checkpoint is now its own file, so PRs stop conflicting at the top of the port log.

Verification

  • history_retention integration tests pass on SQLite, PostgreSQL and MySQL. The full native suite passes on SQLite.
  • The Waterline harness sent the same 31 requests to published PHP 2.5.14 and to native: registration, two runs, a cancellation with an open activity, status, explicit and empty passes, two heartbeats, validation failures and a missing namespace.
    • Every status matched.
    • Bodies matched apart from identifiers, the cutoff time and timeline_entries_deleted. That count is 0 on native, which writes no timeline entries.
  • The probe also found that PHP 2.5.14 requires capability_manifest on registration at protocol 1.19, and native does not. It is recorded as a known gap.

This branch builds on #562. Until #562 merges, the diff includes it.

🤖 Generated with Claude Code

rmcdaniel and others added 2 commits October 21, 2026 15:45
Native served 501 for the retention and activity-timeout status routes, and
its worker heartbeat never pruned, so a bounded namespace kept every closed
run forever.

Native now serves admin-only GET /api/system/retention, POST
/api/system/retention/pass and GET /api/system/activity-timeouts by the
rules of published PHP 2.5.14, in the default or a named namespace. A pass
deletes a closed run's details from PHP's twenty tables in one transaction
and keeps the run row. Each worker heartbeat runs PHP's inline pass and
reports it as `retention`.

Native does not yet clean up external payload objects or message streams,
so it skips such a run with a reason instead of deleting rows that point at
storage it would leave behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmcdaniel
rmcdaniel enabled auto-merge October 21, 2026 15:46
@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel
rmcdaniel merged commit 447bdbc into main Oct 21, 2026
10 of 22 checks passed
@rmcdaniel
rmcdaniel deleted the rust-325-history-retention branch October 21, 2026 16:06
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