HaltMonitor core model #
A minimal, self-contained model of the stream_output loop in
src/director_ai/core/runtime/kernel.py. The Python loop consumes a
token generator, queries a coherence callback for each token, and
halts if the returned score drops below hard_limit.
We abstract that into a function on List (Token × Score) and prove
three safety properties in HaltMonitor.Properties:
- Halt is irrevocable. Once a token fails the threshold, the
output is the
haltedprefix — later tokens cannot recover. - Emitted tokens always pass the threshold. If a token appears
in the emitted prefix, its score was
≥ hard_limit. - Soundness w.r.t. a failing score. If any input token's score
is
< hard_limit, the output ishalted(notemitted).
The model intentionally ignores timeouts, callbacks, and the mutable
_active flag from the Python class. Those are orchestration
details; the threshold check is the safety core and the only part
that benefits from a formal guarantee.
Token type — a single unit of output. The HaltMonitor in Python treats tokens as strings, but the model is polymorphic.
Instances For
Coherence score. Rational so the model stays decidable and
runnable; the production Python implementation uses Float but that
is a boundary-precision concern, not a safety one.
Instances For
Input item: a token with its scorer output.
Instances For
The result of running the HaltMonitor on a stream.
emitted ts means the monitor walked the entire input and every
token's score was ≥ hard_limit, so ts is exactly the input
token list.
halted ts means the monitor emitted the prefix ts and then hit
a token whose score was < hard_limit. The failing token is NOT
present in ts, matching the Python behaviour where the halt
message is returned instead of the offending token.
Instances For
Instances For
Predicate: the output is an emitted result.
Instances For
Any input item's score passes the threshold.