Thing 2.0 cut 7a h2: pin the apply-before-tick order (apply-tick-order-unpinned)
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 3m12s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 3m49s

Steward decision 9 of the h2 fix brief. The frame already applied drained
results before tick; the order is now stated where it is decided and tested:
a result queued for the frame its deadline passes completes the invocation, no
InvocationTimedOut, no mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-29 00:50:34 +01:00
commit 7ac1366d0a
3 changed files with 25 additions and 0 deletions

View file

@ -132,6 +132,8 @@ impl Commands {
answered
}
/// Within a frame results apply before `tick` (`Core::frame` drains and applies, then ticks), so a
/// result queued for the frame its deadline passes wins over the timeout.
/// Move every non-terminal invocation whose deadline has come to `TimedOut`. A deadline is
/// compared with the time given: a wall clock that went backward delays a timeout, never fires one early.
pub fn tick(&mut self, now: Timestamp, port: &mut dyn StatePort, ledger: &mut Ledger) -> Vec<Diagnostic> {

View file

@ -165,6 +165,8 @@ impl Core {
None => self.held.push(resume),
}
}
// Results of this frame are applied above, before the deadline is judged: a late result that was
// already queued wins over the timeout.
diagnostics.extend(self.commands.tick(now, port, &mut self.ledger));
let commands = self.draw(viewport, scale, &mut diagnostics);

View file

@ -1423,3 +1423,24 @@ fn a_tick_also_forgets_the_terminal_invocations_past_their_time() {
assert_eq!(codes(&gone.diagnostics), vec![Code::UnknownInvocation]);
}
// ----- a result in the frame its deadline passes wins -----
#[test]
fn a_result_queued_for_the_frame_its_deadline_passes_wins_over_the_timeout() {
let provider = ProviderId::new(PROVIDER);
let document = go_surface();
let mut state = MemState::new();
state.put(&provider, &document);
let mut core = core();
core.show(provider.clone(), RecordKey::new(document.record_key()));
frame_at(&mut core, &mut state, PINNED_NOW);
core.activate(press("go"), PINNED_NOW, Ports { state: &mut state, ids: &mut SeqIds::new() });
let invocation = frame_at(&mut core, &mut state, at(1)).outbound.pop().expect("minted");
state.put(&provider, &completed(&invocation, 1, false, None));
let late = frame_at(&mut core, &mut state, at(60_000));
assert!(late.diagnostics.is_empty(), "{:?}", late.diagnostics);
assert_eq!(late.next_wake, None);
// Completed, not timed out: the button is free.
core.activate(press("go"), at(60_001), Ports { state: &mut state, ids: &mut SeqIds::new() });
assert_eq!(frame_at(&mut core, &mut state, at(60_002)).outbound.len(), 1);
}