Expand description
Per-turn memoization of turn-stable host capability reads.
Context assembly repeatedly reads the same host facts per agent-loop
iteration. harn#5190 measured ~20 identical runtime.pipeline_input
round-trips per turn; Burin H-063 later measured roughly 164 repeated
project.metadata_get calls in an ordinary context build. This module
front-runs the thread-local HOST_CALL_BRIDGE with a per-turn memo so those
reads collapse to one host round-trip per stable fact. Project metadata is
fetched once as a typed directory snapshot and namespace reads project from
it locally. The allowlist ([is_turn_stable]) is deliberately
narrow, and metadata mutations invalidate the whole memo before and after
dispatch so inherited read-after-write values cannot be stale.
The memoized value is stable only within a turn: the host re-projects
runtime.pipeline_input each turn (e.g. so a mid-session model switch is
observed on the next prompt). The memo is therefore cleared at each
agent-loop iteration boundary (iteration_start, wired in
__host_agent_emit_event) and at run/embedder boundaries via [reset].
Functions§
- lookup
- Read a turn-stable host fact from the current turn’s memo.
- lookup_
by_ name - Split a dotted
capability.operationhost-call name andlookupit. Convenience for embedderhost_callimplementations, which receive the dotted wire name rather than a split pair. - store
- Memoize a turn-stable host fact for the remainder of the current turn.
Non-allowlisted
(capability, operation)pairs are ignored, so a caller cannot widen the allowlist by calling this directly. Seelookup. - store_
by_ name - Dotted-name counterpart to
store. Seelookup_by_name.