1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Cross-cutting run helpers: the sync/async bridge, the turn counter, the
//! checked timestamp, and the shared run constants.
use ;
use crate::;
/// Maximum nested `execute()` depth (inclusive of the first call).
pub const MAX_EXECUTE_DEPTH: usize = 8;
/// The prompt language major this executor implements.
pub const SUPPORTED_MAJOR: u32 = 1;
/// Bridges a section's synchronous Lua host call (`model:infer`, `execute`,
/// `fanout`) into the async runtime.
///
/// The Lua VM runs synchronously on the worker thread, so a nested async host
/// call must block that worker via [`tokio::task::block_in_place`] +
/// [`tokio::runtime::Handle::block_on`]. `block_in_place` panics on a
/// current-thread runtime; rather than let it panic, this detects that
/// unsupported runtime and returns a concrete [`Error::Internal`] BEFORE
/// entering the bridge (F3). The bridged future already yields
/// [`Error::Interrupted`] on cancellation, so a typed interruption is preserved
/// through this seam (F2's cancellation contract).
pub
/// Advances the shared turn counter with saturation, returning the 1-based
/// index of the turn just started.
///
/// Uses `fetch_update` so the STORED counter saturates at [`u32::MAX`] rather
/// than wrapping through `fetch_add`. A wrapped counter would reuse a turn index
/// and desynchronize debug capture; saturation makes that unrepresentable. The
/// closure never returns `None`, so the update never fails.
pub
/// The current UTC time as an RFC 3339 string.
///
/// # Errors
/// Returns [`Error::TimestampFormat`] when the well-known RFC 3339 formatter
/// fails to render the current time, preserving the concrete
/// [`time::error::Format`] cause instead of coercing it to an empty timestamp
/// or a source-free internal error.
pub