Skip to content

Bound Workflow listings, cleanup, and replay resources - #20

Merged
cnluzhang merged 4 commits into
mainfrom
perf/workflow-resource-bounds
Sep 12, 2026
Merged

cnluzhang merged 4 commits into
mainfrom
perf/workflow-resource-bounds

Conversation

@cnluzhang

@cnluzhang cnluzhang commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Workflow definition pagination with per-worker quotas of 1024 retained names / 1 MiB, bounded source snapshots, and 8 MiB response pages. Reuse the existing Lua snapshot for atomic route validation and byte accounting, preserving active/retired semantics.
  • Cap instance-list JSON at 8 MiB while preserving payloads and rank cursors. Retain serialized rows and forward successful bytes unchanged under a five-second Control backend deadline. Share persisted result/params validation before parsing or restart mutation. Payload failures carry bounded instance/ref diagnostics in server logs only; public 5xx messages remain generic.
  • Bound deletion preflight with guarded scan pages, 20-member fenced mutation batches, failed-slot rereads, and a final empty-index check. Control enforces a 16-page / ten-second budget including lock renewal. Total-budget expiry and rescan-required responses return workflow_lifecycle_check_incomplete; completed cleanup is retained without automatic rescan. Explicit per-call timeout selection is required, and the limiting deadline is fixed at request setup so delayed rejection cannot change its classification.
  • Account retained, detached, and in-flight replay data under 64 MiB per Runtime isolate, retaining the 16 MiB cross-request cache cap. Saturation retries without turning replay hits into fresh claims. Controller closure cancels pending reads and releases reservations synchronously.
  • Add configurable system_runtime_desired_count (default one; zero permitted for maintenance), pin CLI 1.9.0, and align fixtures, tests, bilingual documentation, and version diagnostics. Remove obsolete Workflows V2 wording and simplify the single-worker definition builder.

API And Rollout

  • Upgrade definition-list clients before deploying the paginated Control endpoint. Companion CLI 1.9.0 is released with cursor support and empty-page continuation. WDL declares it as the minimum complete CLI and pins it in CI/Quick Start; /whoami.minCliVersion remains diagnostic metadata, not request enforcement. Upgrading WDL services does not upgrade installed clients.
  • Follow cursors through short or empty pages. Definition ordering is page-local, not global; concurrent namespace changes can repeat entries or require restarting after metadata contention. Cursors are capped at 2048 ASCII bytes; native route-scan pages are capped at 512 pairs / 128 KiB. Raising compact-hash thresholds can cause fail-closed rejection; no mandatory Valkey parameter change is introduced.
  • Deploy Workflows before Control/system-runtime for the instance-list byte ceiling. Older Control may conservatively reject unfinished lifecycle pages during overlap; quiesce deletion if uninterrupted deletion is required. This PR introduces no persisted-state migration.
  • workflow_lifecycle_check_incomplete requires a fresh deletion request. The ten-second budget covers Workflow preflight, not the whole delete path. Dry-run remains read-only and need not converge over stale indexes. Replay gauges count accounted bytes, not RSS. Definition quotas include retired names.
  • Scaling only system-runtime to zero stops Control/Auth and __system__ Workers, not necessarily tenant traffic served by other pools.

Details: Workflow contract and rollout notes.

Validation

  • Final candidate: 1240100b3ffcaeccd1110dc2a0d30088bb69ac81.
  • Local checks: JavaScript unit suite 2853/2853 at concurrency four; Workflows Rust 235/235; lint, all three typechecks, unused checks, Clippy, Rust/Terraform formatting, workerd configuration compilation, and diff checks passed.
  • Published CLI 1.9.0 qualification at 0924e52: rebuilt-image integration 10/10 files, 84/84 tests passed, covering all nine CLI files plus auth/whoami.
  • Rescan/diagnostic follow-up: rebuilt-image runtime-core/retention/delete integration 3/3 files, 58/58 tests passed, including the production final-SCARD branch and recovery. This run preceded the final timeout-selection fixes; those fixes were verified with regression tests and static checks, not another integration run. All isolated stacks were removed.
  • The complete suite previously passed 58/58 files at 7f42b52 with CLI 1.8.1. Full integration has not been rerun on the final commit; the targeted runs above do not constitute a new full-suite pass.

Deliberately Deferred

  • Instance listing still reads all candidate state records before byte-limited truncation; fixed-size state batches remain a separate optimization.
  • No new indexes, generic deadline framework, or additional repair-only checks are introduced. No matched performance benchmark was run.

Bound definition and instance listings with quotas, byte budgets, cursor continuation, and consolidated snapshots.
Bound lifecycle preflight and batched cleanup while preserving deletion fences and validating restart params.
Account for retained, detached, and in-flight replay bytes and release reservations when controllers close.
Expose configurable system-runtime maintenance capacity and align fixtures, tests, and bilingual documentation.

Signed-off-by: Lu Zhang <lu@wdl.dev>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-12T22:15:04.861179Z 90af20c New commits
🔒 Security Review Completed 2026-09-10T05:07:45.917847Z 7f42b52 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Rollout documentation incorrectly claims deferred CLI pagination support is included.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds bounded resource handling across Workflow listing, deletion, replay, and persisted payload paths, with synchronized contracts, tests, and infrastructure controls.

Changes:

  • Adds paginated, byte-limited Workflow definition and instance listing.
  • Bounds lifecycle cleanup and Runtime replay memory while validating persisted payloads.
  • Adds system-runtime capacity configuration and updates documentation/tests.
File summaries
File Description
tests/unit/workflow-replay-cache.test.js Tests replay accounting and admission.
tests/unit/workflow-definitions.test.js Tests definition quotas and snapshots.
tests/unit/style-contracts.test.js Pins fixtures and Terraform wiring.
tests/unit/runtime-dispatch-workflows.test.js Tests replay cancellation and saturation.
tests/unit/control-shared.test.js Tests bounded Workflow transport and lifecycle pagination.
tests/unit/control-handlers-workflows.test.js Tests definition and instance listing.
tests/unit/control-deploy-watch.test.js Tests quota-aware deploy reads.
tests/unit/control-delete-handler.test.js Updates delete-lock expectations.
tests/integration/workflows-runtime-retention.test.js Tests restart validation and cleanup paging.
tests/integration/workflows-runtime-core.test.js Tests replay pressure and bounded lists.
tests/integration/workflows-metadata.test.js Tests definition pagination and quotas.
tests/integration/helpers/workflows-scenarios.js Adds lifecycle test helpers.
tests/helpers/workflow-definitions.js Adds definition-module test adapter.
tests/helpers/load-control-shared.js Wires bounded-response dependencies.
tests/helpers/load-control-lib.js Wires definition module into tests.
tests/helpers/control-shared-stub.js Exposes Workflow reader helpers.
tests/fixtures/workflow-limits.json Adds params and instance response limits.
tests/fixtures/workflow-lifecycle-check.json Defines lifecycle pagination contract.
test-workers/workflow-replay-lifetime/src/root.js Adds replay-lifetime root probe.
test-workers/workflow-replay-lifetime/src/metrics.js Adds probe metric storage.
test-workers/workflow-replay-lifetime/src/index.js Tests cross-JSRPC replay cleanup.
test-workers/workflow-replay-capacity/src/index.js Generates concurrent replay pressure.
terraform/variables.tf Adds system-runtime desired count.
terraform/terraform.tfvars.example Documents maintenance scaling.
terraform/README.md Documents capacity controls.
terraform/modules/compute/variables.tf Declares module capacity input.
terraform/modules/compute/system_runtime_service.tf Applies configurable desired count.
terraform/main.tf Passes the new capacity input.
rust/workflows/src/server.rs Returns typed instance-list responses.
rust/workflows/src/api/tick.rs Bounds persisted params reads.
rust/workflows/src/api/status.rs Builds byte-limited instance pages.
rust/workflows/src/api/pending_create.rs Shares fenced cleanup primitives.
rust/workflows/src/api/payload.rs Centralizes persisted payload validation.
rust/workflows/src/api/model.rs Adds raw rows and lifecycle cursors.
rust/workflows/src/api/limits.rs Defines shared response limits.
rust/workflows/src/api/lifecycle/restart.rs Validates params before restart mutation.
rust/workflows/src/api/lifecycle/cleanup.rs Adds bounded, resumable cleanup.
rust/workflows/src/api.rs Re-exports new Workflow primitives.
runtime/dispatch/workflow-step.js Adds replay leases and cancellation.
runtime/dispatch/workflow-replay-cache.js Enforces replay working-set limits.
runtime/config-system.capnp Embeds the definition module.
README.zh.md Removes obsolete V2 terminology.
README.md Removes obsolete V2 terminology.
docs/source-map.zh.md Records definition-module ownership.
docs/source-map.md Records definition-module ownership.
docs/security.zh.md Updates residual-risk terminology.
docs/security.md Updates residual-risk terminology.
docs/redis-key-layout.zh.md Documents definition quotas.
docs/redis-key-layout.md Documents definition quotas.
docs/protocol-contracts.zh.md Documents new Workflow fixtures.
docs/protocol-contracts.md Documents new Workflow fixtures.
docs/modules/workflows.zh.md Expands Workflow resource contracts.
docs/modules/workflows.md Expands Workflow resource contracts.
docs/modules/runtime.zh.md Documents replay accounting.
docs/modules/runtime.md Documents replay accounting.
docs/modules/log-tail-observability.zh.md Documents replay metrics.
docs/modules/log-tail-observability.md Documents replay metrics.
docs/modules/infra.zh.md Documents desired-count controls.
docs/modules/infra.md Documents desired-count controls.
docs/modules/control-auth.zh.md Documents bounded Workflow transport.
docs/modules/control-auth.md Documents bounded Workflow transport.
docs/modules/cli.zh.md Removes obsolete V2 terminology.
docs/modules/cli.md Removes obsolete V2 terminology.
docs/compatibility.zh.md Updates Workflow compatibility wording.
docs/compatibility.md Updates Workflow compatibility wording.
control/workflows-client.js Adds bounded response readers and deadlines.
control/workflow-definitions.js Implements quotas and Redis snapshots.
control/shared.js Adds bounded lifecycle continuation.
control/handlers/workflows.js Implements paginated definition/list forwarding.
control/handlers/versions.js Passes version-delete lock token.
control/handlers/deploy.js Enforces retained-definition quotas.
control/handlers/delete.js Passes worker-delete lock token.
control/bundle.js Bounds Workflow declarations.
CHANGELOG.md Summarizes Workflow resource bounds.
Review details
  • Files reviewed: 74/74 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md Outdated
Comment thread docs/modules/workflows.md
Comment thread docs/modules/workflows.zh.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f42b52296

ℹ️ 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".

Comment thread control/shared.js Outdated
Return the retryable incomplete error for lifecycle checks requiring a fresh scan.
Cover rescan responses in shared fixtures and Rust/Control regression tests.
Pin CLI 1.9.0 and align support diagnostics, CI, and bilingual rollout guidance.
Clarify configurable system-runtime capacity and zero-replica maintenance.

Signed-off-by: Lu Zhang <lu@wdl.dev>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-tier pagination, Redis cleanup fencing, and concurrent replay-memory accounting warrant final human review.

Review details
  • Files reviewed: 80/80 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Keep per-call and total-deadline failures distinct and require explicit timeout selection.
Add bounded server-only payload diagnostics and production-path rescan coverage.
Clarify scan limits, dry-run behavior, and system-runtime maintenance effects.

Signed-off-by: Lu Zhang <lu@wdl.dev>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The coordinated Redis, Rust, Runtime memory, pagination, and rollout changes warrant final human validation despite extensive coverage.

Review details
  • Files reviewed: 80/80 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Verify published CLI pagination through empty and short pages in text and JSON output.
Keep replay resource assertions mandatory while making Docker RSS sampling optional.
Update CLI documentation and calibrate fallback scheduling from the complete 58-file integration run.

Signed-off-by: Lu Zhang <lu@wdl.dev>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It spans stateful cross-tier protocols, lifecycle deletion, and Runtime memory admission, while the final commit did not receive a complete integration-suite run.

Review details
  • Files reviewed: 80/80 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It spans coordinated Control, Runtime, Rust, Redis, CLI, and Terraform contracts without a full final-commit integration run.

Review details
  • Files reviewed: 83/83 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@cnluzhang
cnluzhang merged commit 66fa73f into main Sep 12, 2026
15 checks passed
@cnluzhang
cnluzhang deleted the perf/workflow-resource-bounds branch September 12, 2026 22:17
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.

2 participants