Deduplicate watchdog pre-abort threshold derivation - #3914
Conversation
Extract the duplicated `(abort * 3 / 4).max(1)`-else-0 pre-abort threshold formula into a single module-level `const fn derive_pre_abort_threshold_secs` and call it from both `WatchdogSnapshot::pre_abort_threshold_secs()` and `emit_watchdog_started_line()`, removing the documented drift risk. The floor is expressed without `Ord::max` (not const-stable). Adds a direct unit test pinning the formula (120->90, 0->0, 1->1, 2->1). Refs #3912 Co-authored-by: Claude Code <claude-code@anthropic.com>
🔍 Reviewer: CorrectnessVerdict: APPROVE Summary: Provably-equivalent DRY refactor extracting a duplicated pre-abort threshold formula into one Full reviewCycle 1 (no prior Correctness verdict) — complete review. Correctness / equivalence
Test coverage (kind: refactor / cleanup)
Readability / error handling
No concerns. |
🔍 Reviewer: RiskVerdict: APPROVE Summary: Pure internal refactor of a single non-parity crate ( Full reviewCycle 1 (no prior Risk verdict) — complete review. Regression risk: None. The extracted Perf: Negligible/none — a API / data-format: No public API change. Parity note: Security / operational: None. No concerns. |
Review: Bounce-Back Cycle 1Reason: CI failed (unrelated, will rebase) Reviewer A: APPROVE — provably-equivalent DRY refactor; boundary cases pinned by a new direct unit test. Both agent reviewers approve. The only non-green check is a single environmental cancellation, unrelated to this Rust-only diff:
Routing back to |
tomerweller
left a comment
There was a problem hiding this comment.
Do: Mode B — CI re-trigger (no code change)
Both agent reviewers APPROVED. The only red check was the test (testnet, core,horizon, ...) Quickstart shard, which ran ~55 min against live testnet and hit its per-shard timeout — the environmental testnet sync-probe cancellation class (#3272), not diff-attributable (this PR touches only a const fn extraction in crates/app, no wire/RPC/CLI surface).
Rebase onto origin/main is a no-op — main has not moved since the branch was cut, so there is nothing to rebase and no code change is warranted. Re-ran the failed testnet job in run 32602231531 to clear the transient cancellation. All 40 other checks are green.
Ready for re-review.
Do: Re-trigger CI (Mode B, bounce cycle 1)Both agent reviewers APPROVEd; the only non-green check was the environmental testnet Quickstart shard cancellation (unrelated to this
Ready for re-review once CI settles. |
tomerweller
left a comment
There was a problem hiding this comment.
Addressed bounce reason (re-triggered transient testnet CI; no code change needed). Ready for re-review.
Review: Unrelated CI Red — BlockedReviewer A (Correctness): APPROVE — Why blocked (not bounced again): The failing shard is environmental, not diff-attributable. It was killed by This same shard already triggered Bounce-Back Cycle 1, after which To clear: an operator can re-run only the failed testnet shard (run |
Closes #3912
Summary
The pre-abort near-miss threshold formula
(abort_threshold_secs * 3 / 4).max(1)-else-0 was duplicated inWatchdogSnapshot::pre_abort_threshold_secs()andemit_watchdog_started_line(), with both documented as needing to stay in sync. This extracts a single private module-levelconst fn derive_pre_abort_threshold_secsas the source of truth and delegates both call sites to it, removing the drift risk. No behavior change — the rendered field values are byte-identical.Plan reference
Converged Plan comment
Test plan
Deviations from plan
.max(1), butOrd::maxis not yet const-stable, soconst fncompilation fails with it. The floor is expressed with an explicitif pre > 1 { pre } else { 1 }instead — same value, still aconst fn.derive_pre_abort_threshold_secs_formula: 120->90, 0->0, 1->1, 2->1) the plan flagged as a nice-to-have, locking the single source of truth.🤖 Generated with Claude Code