Skip to content

impl(042): increment 4 part 3 follow-up, one invalidation pass per poll tick - #413

Merged
bartekus merged 1 commit into
mainfrom
impl/042-poll-once
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/042-poll-once

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Follow-up to #407 for its review finding. A failed poll on the tick where lag first passed max_lag_ms called invalidation_lost twice, so it invalidated the source's plans twice. The gap was counted once either way.

  • integrations/rustev-serve/src/contexts.rs: the poll loop now asks one helper, loss, for the single invalidation_lost call a tick needs, if any. A failed poll counts a gap only while a sequence was held. Lag first passing the bound adds no second call on the same tick.
  • Test: contexts::tests::a_tick_invalidates_at_most_once_even_when_failure_and_lag_coincide asserts one pass when failure and lag coincide, and checks the failure-only, lag-only and healthy ticks.
  • The spec 042 implementation record gets a dated paragraph.

Checks: make gate, scripts/check-authored-content.sh, cargo fmt --all --check, cargo clippy -p rustev-serve --all-targets -D warnings and cargo test -p rustev-serve --lib contexts:: pass locally.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Looking at the two changed files:

integrations/rustev-serve/src/contexts.rs

The old code in the Err arm computed lag independently and called service.invalidation_lost there, then a second potential call happened in the post-match lag check — on the coincident tick (failure + lag first exceeds bound), two calls fired. The refactor defers failed = true and then delegates both decisions to loss, which returns at most one Option.

Tracing the loss function:

  • over = lag > max_lag_ms && !*lagging — sets *lagging = true if newly over threshold.
  • Returns Some((lag, failed && counted)) when failed || over, None otherwise.

The key edge case (failed=true, over=true, lagging=false):

  • Old: two calls — invalidation_lost(lag, counted) then invalidation_lost(lag, false).
  • New: one call — invalidation_lost(lag, counted). The over branch's uncounted call is absorbed.

The spec note says "the gap was counted once either way" (net invalidation count unchanged), so collapsing to one call is the intended fix.

All five test assertions match the function's actual outputs (verified by manual trace). The lagging flag is set correctly whether the trigger is failure, lag, or both.

The lagging variable never resets to false after a recovery, but that is pre-existing behaviour unchanged by this PR.

specs/042-decision-service-and-remote-seams/spec.md

Adds an increment note dated 2026-10-30, naming the file, the fix, and the test. The description accurately matches the code change.

No bugs, security issues, or governance inconsistencies found.

{"head": "b876c9c42c9098e10a3d9360431c3016fac2565a", "verdict": "no-findings", "findings": []}

Subject: d2a496f...b876c9c, diff digest a6f4402e75d4e71ac19ebb8776dc29dcb353e0b3eb5909454ff778719d71c3cf, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 15dbf97 Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the impl/042-poll-once branch October 30, 2026 16:01
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