Skip to content

fix(020): anchor runtime batch budgets at one dispatch instant - #170

Merged
bartekus merged 1 commit into
mainfrom
fix/020-batch-deadline
Oct 22, 2026
Merged

bartekus merged 1 commit into
mainfrom
fix/020-batch-deadline

Conversation

@bartekus

@bartekus bartekus commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Runtime-planned batch members with equal remaining budgets previously received slightly different deadlines because each member started its budget during preparation. When the earliest deadline ended the shared transport, a later member could receive a transient transport failure while its siblings expired. This is the runtime_batch CI failure seen on #169.

Implements the owner-authorized fix under spec 020's existing dispatch-budget and no-replenishment requirements: capture one monotonic instant at batch entry and derive all member deadlines from it. Preparation consumes the budget, and distinct remaining budgets stay distinct. A paused-clock regression covers preparation time and expiry; the existing batch-versus-independent loopback test is unchanged.

Validation: make gate, cargo fmt and git diff --check pass. Hosted code and binding checks pass, including the new paused-clock regression and the unchanged runtime_batch differential test. The rebased review identified an in-place normative amendment. The approved normative text is now unchanged; the implementation record explains how this fix enforces the existing requirements. AI review reports no findings on current head 9ebf3de. CI is running; auto-merge is enabled. Pushed before local workspace tests at the owner's request.

Rebased onto merged #168. Rebase #169 onto this fix after it merges. Requires current-head no-findings AI review and green CI.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed files for bugs, security issues, and inconsistencies.

budget.rs

from_start is factored out correctly. from_ms now delegates to it, preserving existing behavior. The new method is pub(crate), appropriate since it is only called from within the integration crate. The test uses tokio::time::start_paused correctly: anchoring both first and second to the same start at t=0, advancing 40 ms, then verifying second.remaining_ms() == 60, joint expiry at t=100ms, and longer still live with 50 ms left. The arithmetic and assertions are all correct.

client.rs

dispatch_start is captured once before the member loop, replacing the per-iteration Budget::start(m.cx.remaining_ms) that implicitly called Instant::now() for each member. The fix closes the race where a later member would receive a strictly later deadline than an earlier member with the same remaining_ms, causing only the earliest member to time out on a shared transport. The type of m.cx.remaining_ms (DurationMs) matches the new from_start signature.

specs/020-remote-protocol-refinements/spec.md

The normative addition (section 3.3 text) accurately describes what the code now does: one anchor instant per batch dispatch, equal budgets share a deadline, differing budgets keep individual deadlines. The implementation record entry correctly labels this as a bug fix and notes the paused-clock regression test. I cannot independently verify the owner authorization claim, but that enforcement is outside this review.

No defects found.

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

Subject: f66e2cb...ee42250, diff digest b95425d4bdb19bac755c90fbee799b57cd57f3548a03370e00eae3f4ac4e6c0a, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Code review: budget anchoring fix

The runtime fix is correct and well-tested. The new Budget::from_start(start, remaining) factory captures a single monotonic instant before member iteration in client.rs, so all members with equal remaining budgets share an identical deadline. The paused-clock test correctly validates three properties: equal-budget co-expiry, earlier expiry of the shorter budget, and correct remaining_ms math for the longer one.

The from_start method is rightly pub(crate), restricting it to the integration crate.

Spec amendment mechanism

The contract (governance context) states:

An amends edge is declared once, in the amending spec's frontmatter; the amended spec.md is not edited to record it.

The plain reading is: when normative text changes, a new spec carries amends: 020 in its frontmatter, and spec 020 itself is left unchanged. This PR instead edits spec 020 in-place with new normative prose under section 3.3 and adds an implementation-record entry, with no new amending spec in the diff. The implementation record's claim that "the owner authorized the section 3.3 amendment" is not independently verifiable here; owner ratification is enforced elsewhere, but the structural defect (direct edit without an amending spec) is visible in the diff itself.

{"head": "d94ddd60269ca7996d7584fb7fbbe37223497c19", "verdict": "findings", "findings": [{"path": "specs/020-remote-protocol-refinements/spec.md", "line": 199, "summary": "Normative text is added directly to an existing approved spec without a new amending spec carrying `amends: 020` in its frontmatter, which contradicts the contract's documented amendment convention."}]}

Subject: 563fa42...d94ddd6, diff digest b95425d4bdb19bac755c90fbee799b57cd57f3548a03370e00eae3f4ac4e6c0a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 18:01 — with GitHub Actions Error
@bartekus
bartekus force-pushed the fix/020-batch-deadline branch from d94ddd6 to 9ebf3de Compare October 22, 2026 18:02
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

The PR fixes a batch deadline race in rustev-remote-http: previously each member's budget was anchored at its own construction time, so preparation for earlier members silently extended later members' deadlines. The fix captures one dispatch_start instant at batch entry and derives every member's deadline from that common anchor.

budget.rs: from_ms now delegates to the new pub(crate) from_start(start: Instant, remaining: DurationMs). The arithmetic is correct (start + Duration::from_millis(remaining.0)). The test uses tokio::time with start_paused = true; the assertions on second.remaining_ms() == 60 (after 40 ms elapsed), co-expiry of equal-budget members, and the distinct 50 ms remaining on longer are all mathematically consistent.

client.rs: dispatch_start = tokio::time::Instant::now() is captured before the member loop. The substitution of Budget::from_start(dispatch_start, m.cx.remaining_ms) for Budget::start(m.cx.remaining_ms) is the correct application of the new API. Budget::start is not shown in the diff but is evidently an existing method in the unchanged parts of the file, so its removal from the call site is consistent with the repo compiling.

spec.md: The addition is entirely within the ## Implementation record section; no normative text is modified, which is consistent with the claim in the record itself. The description of sections 3.3 and 3.4 is referenced but not in scope to verify from the diff alone.

No bugs, security problems, or governance inconsistencies found.

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

Subject: 563fa42...9ebf3de, diff digest 9dca1c72d43eaeda9fb306520ce35de60c4147dcd97a8453adb6ff80f3ac000b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge (squash) October 22, 2026 18:05
@bartekus
bartekus merged commit 6c2dabc into main Oct 22, 2026
26 checks passed
@bartekus
bartekus deleted the fix/020-batch-deadline branch October 22, 2026 18:40
bartekus added a commit that referenced this pull request Oct 22, 2026
Adds the held-out ledger, baseline records and reproducibility checks
from spec 029 sections 3.7 to 3.9. The ledger verifies its hash chain
and bounded entries; baseline creation reproduces and checks the
supplied repeat report; reproducibility reports exceedances and unknown
evidence explicitly.

Tests cover ledger counts and tampering, bounds and round trips,
baseline bindings, exact band boundaries and unknown evidence.

This is the first part of increment 4. Section 3.10's diff document and
rendering are still to follow before candidate comparison and selection
gates. Spec 029 remains in progress. Brier per-case measures remain
absent and their interval unknown pending a concrete compatibility
decision on D-029-1.

Validation: make gate and pinned spec-spine coupling pass. AI review
reports no findings on 50e8d04. CI code
hit the existing runtime_batch deadline race, addressed separately in
#170; rebase and fresh checks follow that merge. Local code validation
is queued behind the current shared-target run; pushed before it
completes at the owner's request.

Merge order: after #168 and the runtime batch race fix #170. Auto-merge
stays off pending that order, a current-head no-findings AI review and
required checks.
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