mixle.substrate.harness module¶
Application harnesses around a configured reasoner.
A Harness wraps a Reasoner with
input validation, an immutable per-harness action whitelist, secret-redaction
guardrails applied at every boundary (input, action evidence, escalation
payload, retained trace), and an optional escalation callback. Each request
returns a HarnessResult whose status is refused, answered, or
escalated.
support_triage_harness and monitoring_harness provide ready-made
templates. register_harness and find_harnesses store harnesses as
scoped substrate artifacts so teams can discover reusable shells.
- class HarnessResult(status, answer=None, reason='', investigation=None, redactions=0)[source]
Bases:
objectOne request’s outcome: which gate decided (refused/answered/escalated), and the evidence.
- class Harness(reasoner, *, name, description='', validate=None, allowed_kinds=None, escalate=None, min_confidence=0.15, on_result=None)[source]
Bases:
objectSchema + whitelist + guardrails + escalation around a reasoner (see module docstring).
- Parameters:
reasoner (Reasoner) – the configured
Reasoner(answerer + substrate + skills + actions).description (str) – identity, used by the registry.
validate (Callable[[str], str | None] | None) –
(request) -> None | str– return an error string to REFUSE the request before any model runs (the input schema, as a callable so any validator plugs in).allowed_kinds (tuple[str, ...] | None) – action kinds this harness may fire (whitelist; None = all).
escalate (Callable[[str, Any], str] | None) –
(request, result) -> str– called on abstention with the REDACTED request and a redactedInvestigation; its return is the escalated answer handed back (e.g. a ticket id). None = abstentions surface as ‘escalated’ with no handler note.min_confidence (float) – the answer bar (passed through to
ask).on_result (Callable[[HarnessResult], None] | None) – optional UI hook, called with every HarnessResult (fire-and-forget).
name (str)
description
Action-view immutability:
reasoner._actionsis a shared, mutable structure – otherHarnessinstances built from the same reasoner, or a laterreasoner.add_action()call, can change it at any time. So that one harness’s whitelist can never be corrupted by another harness’s construction, or bypassed by a lateradd_action(), aHarnessnever mutatesreasoner._actionsand never re-readsreasoner.actionsafter__init__: it snapshots its own immutable action view – the whitelist-filtered (or, withallowed_kinds=None, full) action list, each action wrapped to redact its own evidence – exactly once, at construction time, and every request the harness ever serves uses only that view. Attach every action a harness should be able to use to the reasoner BEFORE constructing that harness;reasoner.add_action()calls (or another harness’s construction) after that point affect only the shared reasoner and any harnesses built afterward, never one already built. The frozen view is available for inspection asharness.actions.- property actions: tuple[Action, ...]
This harness’s own immutable, redaction-wrapped action view (frozen at construction).
- support_triage_harness(substrate, answerer, *, escalate=None, max_chars=2000)[source]
Support triage: retrieve-only over the team’s knowledge, refuse empty/oversized requests, escalate anything the knowledge base cannot support – the canonical ‘never guess at a customer’.
- monitoring_harness(reasoner, *, escalate=None)[source]
Monitoring/alerting: compute + simulate allowed (run checks, what-ifs), no delegation out.
- register_harness(substrate, harness, *, scope='local')[source]
Index a harness on the substrate as a scoped artifact – discoverable and shareable (P-scoped).