#2606

cluster-controller: drive due checks and paced rolling issuance

Draftgilalon-pplxwants to merge intofrom

Summary

Turns the canary-only firewall rules driver into the rollout's paced controller. Before this, the driver issued the canary's one target and never looked at it again. Nothing checked the canary, so nothing marked it done, and nothing issued rolling work.

Each tick, firewall_rules_rollout (renamed from firewall_rules_issue, now private) reads the unfinished rollout and its phase again, trusting nothing from an earlier tick:

  • Paused: it does nothing.
  • Canary with nothing issued: it leases and issues one target with issue_canary_and_release, the only way a canary is issued.
  • Otherwise:
    • redrives lapsed leases with redrive_expired(…, max_attempts);
    • leases due checks and, in rolling, first assignments up to active_limit;
    • judges each check with check_target;
    • issues each first assignment with issue_and_release.

Every lease a tick takes ends before the tick returns, through one table from outcome to ending:

  • Checks that end their own lease (asked, waiting, done, retried, failed): nothing more to do.
  • Not due, or the rollout paused mid-tick: released.
  • Check lease lost or lapsed: left alone; a later redrive charges it.
  • Epoch mismatch, or a check whose store call failed: waits uncharged at revisit_in.
  • Superseded, LaterGeneration, NotIssued, NotATarget: retried at revisit_in, charged, with a typed last_error. The item fails through fail_target once its attempts reach max_attempts.
  • Any issuance result other than Issued: released. The release only matches the controller's own lease token, so a lease that has passed to someone else is left alone. This includes a node that went offline while issuance waited, which is released uncharged.

The gate is a failure hold, not a proof gate. While any item is failed, rolling leases only due checks (lease_checks). A check that fails mid-tick releases the first assignments leased with it, unissued. The header phase doesn't change, and promotion stays an operator action: the controller never writes the phase.

The wakeup is now enqueue_unless_held_tx, a new trigger-queue verb. It leaves a held trigger row (dead, or backing off) exactly as it is, still locked, because wakeup_held_tx locks nothing when a row is missing and a held row can be inserted before the wakeup runs. The controller counts a held node as woken; the node learns of the change from the first check that asks once its trigger is no longer held. The firewall store's test support gains lapse and supersede, and its check tests call wakeup_held_tx instead of an inlined copy of the predicate.

Validation

At this head:

  • cargo fmt --all --check passes.
  • clippy -D warnings is clean on the three touched crates.
  • cargo check --all-targets --all-features is clean on their dependents (pplx-space-api, pplx-space-cluster-reconciler, pplx-space-internal-api-server).
  • cargo arch has no findings, and scripts/check-rust-error-policy.sh passes.
  • nextest with SPACE_CI_REQUIRE_TEST_DEPS=1 on a freshly migrated database runs 1561 tests in the three crates, all passing, none skipped.

The 9 controller tests each take under 0.15 s and use database-clock backdating and lock-wait barriers, not sleeps. Each was mutation-checked: removing the behaviour it names makes it fail. Kind was not run; the controller is off in every deployment.

  • Replaced tests:
    • one_tick_issues_one_canary_and_later_ticks_leave_it_alone asserted that a due canary check is left alone, which is the behaviour this PR replaces. the_canary_is_issued_then_asked_and_proved now covers the check, and keeps the first-check delay, the released and uncharged lease and the single assignment.
    • the_wakeup_queues_firewall_rules_changed is extended as the_wakeup_queues_firewall_rules_changed_and_leaves_a_held_trigger_alone. the_loop_runs_only_when_configured_and_stops_on_shutdown is unchanged.
    • racing_ticks_issue_one_canary is removed: the store's in_canary_the_first_committed_issuance_pins_the_canary, racing_controllers_share_one_node_and_one_slot and only_an_unissued_lapsed_claim_is_taken_back already prove one canary under racing controllers.
    • The offline canary case is covered by the store's after_an_assignment_commits_only_the_issued_canary_is_leased and a_claim_rechecks_eligibility_at_the_write; the offline node in the rolling test by only_online_targets_of_a_leasing_rollout_are_leased.
    • The EpochMismatch step of the blocked-checks test is covered by every_step_ends_its_lease_as_the_table_says, and its check-error step runs the same uncharged wait.

Severity and risk

Severity: does not apply (new, disabled behaviour).

Risk is low:

  • run(None, …) in reconcilers.rs is unchanged, and only tests build a Config. No production pacing, lease, check policy or manager epoch is set.
  • enqueue_unless_held_tx is new, and its only caller is the disabled controller. Existing enqueues are unchanged.

Rollback is a revert.

Rollout

No schema, protocol or metric change. Old and new controller versions can overlap during a deploy without effect, because the controller is off in both.

Before anything enables it:

  • every reader and rollback target of the trigger queue must decode FirewallRulesChanged;
  • the manager epoch needs its owner (today it is a fixture value);
  • production pacing values need approval.

Stack

Based on main, which already contains #2206, #2581, #2584 and #2585. No open dependencies.

Not covered

  • Shutdown: a tick dropped at shutdown, or one whose requeue or fail_target call fails, leaves its remaining leases to lapse within lease. A later redrive charges each one attempt.
  • Checks on offline nodes: a check whose node goes offline after leasing is still asked. The store doesn't recheck reachability for checks.
  • Proof gate: until a failure is judged, unproven assignments spread as fast as leases turn over.
  • Fresh proof: Done evidence is never refreshed. Completion and delayed promotion need fresh proof and a follow-up issue.
  • Untested paths:
    • enqueue_unless_held_tx is tested only through the controller's wakeup test, which fails if the held row is revived or the count is wrong.
    • fail_target's result feeding the in-tick hold is untested; hard blockers come only from hand-written rows.
    • So is a scan above 16 targets.
  • Loop test: the loop test still polls every 20 ms against the real loop, as it did before this PR.

Decided by maintainers, recorded here:

  • A complete census with zero slots, or only ineligible ones, proves the assignment.
  • Hard blockers are charged until max_attempts, then failed with fail_target.
  • An epoch mismatch waits uncharged.
  • The failure hold above is the rolling gate.

AI assistance: Claude Code drafted the design, the code, the tests and this description. A separate Claude reviewer checked the design and the code, including mutation testing.

Activity

6
coderabbitai[bot]19h ago

IMPORTANT

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
Pre-merge checks: 6

Check nameStatusExplanation
Description Follows The Pr TemplateThe PR description (PR #2606, perplexityai/SPACE, author gilalon-pplx) contains all four required items with real content: 1. "## Summary": present. It states what merging does: the canary-only fi…
Bug Fixes Name A Regression TestThe check applies only when the pull request fixes a defect in application behavior under crates/, shim/, or ui/. This pull request does not fix a defect. The title is "cluster-controller: drive due c…
Weakened Safeguards Are JustifiedPR #2606 (gil/firewall-rules-rollout-controller, author gilalon-pplx) does not weaken a test, lint, CI check, guard, or allowlist without a stated reason. Diff base: I compared against 354a60aa, the p…
Agent Tooling Runs No New CommandsThe check passes because this PR changes no agent plugin manifests, skills, or guideline files. I compared HEAD with the merge-base of origin/main (354a60aa). The diff touches 12 files, all Rust sourc…
External Code Sources Need A PersonThe check does not apply to this PR's diff, so it passes. Against origin/main, the PR changes 12 files. All of them are Rust sources (.rs) or SQL inside Rust strings. The changes are in the trigger qu…
Public-Safe ContentThe title, the contributor's description, and the diff contain no credentials, tokens, private keys, internal hostnames or URLs, tracker or chat links, cloud account IDs or ARNs, real cluster or envir…
Full details: Description Follows The Pr Template

Explanation

The PR description (PR #2606, perplexityai/SPACE, author gilalon-pplx) contains all four required items with real content: 1. "## Summary": present. It states what merging does: the canary-only firewall rules driver becomes a paced rollout controller that checks targets, redrives leases, and issues rolling work. 2. "## Validation": present. It names the runs and results: cargo fmt --all --check, clippy -D warnings, cargo check --all-targets --all-features, cargo arch, scripts/check-rust-error-policy.sh, and nextest (1561 tests, all passing). 3. "## Severity and risk": present. It gives "Severity: does not apply (new, disabled behaviour)" and a risk: "Risk is low", with the reasons. 4. "AI assistance:" line: present. It reads "AI assistance: Claude Code drafted the design, the code, the tests and this description. A separate Claude reviewer checked the design and the code, including mutation testing." This names the tool and the parts it drafted. Each section has substantive text, not only template HTML comments. The check judges presence only, so the content quality does not affect the result. No missing or empty items were found. This check reads only the supplied description, so no code inspection was needed.

Full details: Bug Fixes Name A Regression Test

Explanation

The check applies only when the pull request fixes a defect in application behavior under crates/, shim/, or ui/. This pull request does not fix a defect. The title is "cluster-controller: drive due checks and paced rolling issuance." The description says the change "turns the canary-only firewall rules driver into the rollout's paced controller." It adds new behavior that is disabled in every deployment ("Severity: does not apply (new, disabled behaviour)"). It also adds a new trigger-queue verb, enqueue_unless_held_tx. The description does not describe any existing bug being corrected. The check is therefore not applicable, and the pull request passes. The Validation section is not evaluated against the regression-test requirement, because that requirement does not apply.

Full details: Weakened Safeguards Are Justified

Explanation

PR #2606 (gil/firewall-rules-rollout-controller, author gilalon-pplx) does not weaken a test, lint, CI check, guard, or allowlist without a stated reason. Diff base: I compared against 354a60aa, the parent of the PR's four commits. The local origin/main has moved past it, so origin/main as a base would include unrelated changes. Checks performed: - No added #[allow], #[expect], #[ignore], skip, xfail, continue-on-error, || true, set +e, or SPACE_TEST_DEPS_OPTIONAL lines. - No changes to Cargo.toml [lints], nextest config, CI workflows, ci/ lists, ARCHITECTURE.toml, deny.toml, or any AGENTS.md, CLAUDE.md, CONTRIBUTING.md, docs/rust, or db/README.md guideline text. The only doc edits are in db/README.md, docs/configuration.md, docs/rust/async-and-tokio.md, docs/rust/performance.md, and docs/snapshot-upload-streaming.md, and none of them touch review, risk, or approval guidance. None of these is in the diff against 354a60aa. - Deleted tests: - racing_ticks_issue_one_canary (old firewall_rules_issue/tests.rs) is removed. The description gives a reason and names store tests. I confirmed that in_canary_the_first_committed_issuance_pins_the_canary, racing_controllers_share_one_node_and_one_slot, only_an_unissued_lapsed_claim_is_taken_back, after_an_assignment_commits_only_the_issued_canary_is_leased, a_claim_rechecks_eligibility_at_the_write, and only_online_targets_of_a_leasing_rollout_are_leased exist in the store crate. I did not re-verify their assertions. - one_tick_issues_one_canary_and_later_ticks_leave_it_alone asserted the "left alone" behavior that this PR replaces. It is replaced by the_canary_is_issued_then_asked_and_proved in firewall_rules_rollout/tests.rs, which keeps the first-check delay, the uncharged released lease, and the single assignment. - the_wakeup_queues_firewall_rules_changed keeps its original assert_eq!(wake(...), 1) and reasons assertion. It is extended, not weakened, as ..._and_leaves_a_held_trigger_alone. - the_loop_runs_only_when_configured_and_stops_on_shutdown is unchanged apart from its helper call (canary() became targets(..., "canary", 1)). Its assertions are the same. - The store test helper held now calls the production wakeup_held_tx instead of an inlined copy of the same SQL predicate. This tightens the test. - Only the old test-helper lapse moved to test_support.rs. Its SQL is unchanged. - The enqueue_triggers path keeps Held::Revive, so its SQL predicate is the same as before. The new enqueue_unless_held_tx path is a new verb with its own test. No guard or safeguard was removed from production code in this diff. The module rename firewall_rules_issue to firewall_rules_rollout has no remaining references in the repository.

Full details: Agent Tooling Runs No New Commands

Explanation

The check passes because this PR changes no agent plugin manifests, skills, or guideline files. I compared HEAD with the merge-base of origin/main (354a60aa). The diff touches 12 files, all Rust sources under crates/l30_storage/cluster/trigger, crates/l30_storage/firewall/rules/store, and crates/l40_api/cluster/controller/server. None of these is a plugin.json, plugin.yaml, SKILL.md, AGENTS.md, or similar agent file, and none adds a hook, MCP server, LSP server, or frontmatter key. The repository does contain agent files under .agents/plugins/ and several AGENTS.md files. None of them appears in the diff, so the check's criteria do not apply to them. A search of the repository for inline shell substitutions (!...) found one match, in .coderabbit.yaml line 568. That match is prose describing the substitution pattern, and the file is not part of this diff. The Rust changes add a controller and a trigger-queue verb. They do not add agent-run content. The check's failure conditions do not apply.

Full details: External Code Sources Need A Person

Explanation

The check does not apply to this PR's diff, so it passes. Against origin/main, the PR changes 12 files. All of them are Rust sources (.rs) or SQL inside Rust strings. The changes are in the trigger queue, firewall rules store, and cluster controller server crates. I checked each external-source category: - Cargo.toml and Cargo.lock: no changes. No git, rev, branch, tag, registry, or external path keys were added. - Dockerfiles and container images: no changes. No FROM or image: lines were added. - Downloaded binaries or archives: no curl, wget, URL, version, or checksum additions in the diff. - Helm Chart.yaml and Chart.lock: no changes. A grep of added lines matched only SQL text, such as "(SELECT eligible FROM counts) AS eligible" and "FROM firewall_rules_node_assignments". These are not external code sources.

Full details: Public-Safe Content

Explanation

The title, the contributor's description, and the diff contain no credentials, tokens, private keys, internal hostnames or URLs, tracker or chat links, cloud account IDs or ARNs, real cluster or environment names, personal absolute paths, production logs or measurements, incident details, or unfixed vulnerability descriptions. Evidence: - Description: no URLs or file paths. It names no real cluster. "Fixture values only" and "production pacing values need approval" describe absent production values, not leaked ones. The AI attribution is plain prose ("Claude Code drafted…") with no link, so the closing-line rule does not apply. - Diff: the PR's own commits (077b98bb, de5e51be, 8ae97536 for the controller and store, and 358a82bd for the trigger queue) were scanned for URLs, personal paths, ARNs, 12-digit account IDs, key blocks, password/secret/token literals, internal domains, and chat or tracker names. The only hit was .port(listener.local_addr()?.port()), which is a false positive. - Test-only values such as sha256:000…01, http://127.0.0.1:9, and http://10.0.0.10:9802 are generic test fixtures, not internal hostnames. - Commit-message trailers (Co-authored-by noreply, "Local review: Codex + Claude") are outside the check's scope (title, description, diff), and they contain no listed sensitive value. Caveat: the local checkout's main is behind the PR base, so a full main...HEAD diff was noisy. The scan was therefore scoped to the PR-specific commits, which contain all of the controller and trigger-queue changes described.

This pull request is a draft

Merging is unavailable until it is marked ready for review.