aeat.agent.eval._runner module¶
Runner for the operator golden-task eval.
Pure with respect to the CLI: the set of resolvable command keys is injected by
the caller (the test wires it from the live CLI schema registry), so this module
never imports the entrypoints layer. The registry snapshot it reads for the
provenance dimension is a pure registry read through aeat.core.resources and
needs no profile or secret storage. The response-provenance dimension follows the
same injection pattern: the caller dispatches a real modelo.work.calculate
through the actual CLI/MCP command handling and passes the decoded JSON
observations rows in; this module only asserts over the already-fetched rows
and never dispatches the call itself. The narration-faithfulness dimension
(eval-catalogue category 9) follows the identical pattern one layer further: the
caller runs the real aeat.entrypoints.mcp._faithfulness.faithfulness_check
against a narration and the captured calculate JSON, and passes the per-step
verdict in - this module never imports entrypoints.mcp (that would invert the
hexagonal direction, since entrypoints.cli already imports aeat.agent) and
never runs the check itself. The confirmation-gate dimension (eval-catalogue
category 8) follows the same pattern once more: the caller invokes the real
aeat.entrypoints.mcp._hitl.confirmation_for_tool for a step and hands the
resulting tier in as a ConfirmationGateCheck;
this module never imports entrypoints.mcp and never resolves a confirmation
tier itself. The contradiction dimension (eval-catalogue category 4) follows the
same pattern: the caller dispatches two independent real CLI/MCP invocations for
the same target (a readiness-shaped signal and a second, legitimately-blocking
signal) and passes in whether each reported ready / refused, plus a candidate
ordered trajectory; this module never dispatches either call itself and never
decides what counts as a mutating command (that closed set rides on the scenario,
caller-declared). The active-profile-confirmation dimension (eval-catalogue category
5) follows the same injection pattern once more: the caller dispatches a real ordered
trajectory of CLI/MCP invocations (the active-profile confirmation command plus zero or
more mutating commands) and passes the observed command-key sequence in; this module
never dispatches any call itself and, like the contradiction dimension, never decides
what counts as a mutating command (that closed set rides on the scenario).
- load_scenario(path)[source]¶
Load and validate a
GoldenScenariofrom a scenario TOML file.TOML arrays parse as
list; the strict scenario model takes atuple, so the trajectory array is coerced before validation.- Return type:
- Parameters:
path (Path)
- run_golden_scenario(scenario, *, valid_commands, response_observations=None, narration_faithfulness_checks=(), expected_confirmation_tiers=())[source]¶
Run one golden scenario and return its per-dimension verdict.
- Parameters:
scenario (
GoldenScenario) – The declared workflow expectation.valid_commands (
frozenset[str]) – The set of resolvable registry command keys, injected by the caller from the live CLI schema registry.response_observations (
tuple[object,...] |None) – The decoded JSONobservationsrows from a realmodelo.work.calculateCLI/MCP dispatch, injected by the caller.None(the default) skips the response-provenance dimension - this module never dispatches the calculate call itself.narration_faithfulness_checks (
tuple[NarrationFaithfulness,...]) – Zero or more per-stepNarrationFaithfulnessverdicts, injected by the caller after running the realfaithfulness_checkagainst a narration and the captured calculate JSON. Empty (the default) skips the dimension - this module never runs the faithfulness check itself.expected_confirmation_tiers (
tuple[ConfirmationGateCheck,...]) – Zero or more per-stepConfirmationGateCheckverdicts, injected by the caller after resolving a step’s realconfirmation_for_tooldecision. Empty (the default) skips the dimension - this module never resolves a confirmation tier itself.
- Return type:
- Returns:
A
GoldenResultwhosepassedis true only when the trajectory resolves, follows the lifecycle order, is consistent with the shipped skill, the revision’s casillas carry provenance (when required), the RESPONSE payload’s own observations carry that same provenance (when a live response was dispatched), no injected narration-faithfulness check hard-blocks (an advisory-only unfaithful check does not fail the scenario; ADR Q4), and every injected confirmation-gate check resolved the tier the workflow relies on.
- check_exit_code_scenario(scenario, *, exit_code, envelope, valid_commands)[source]¶
Assert a REAL dispatched exit code reads as an actionable verdict, not a crash.
Closes eval-catalogue category 7. The caller dispatches a real CLI/MCP invocation (e.g.
modelo.work.verifyon a draft with outstanding findings), captures its process exit code and its decoded JSON envelope (the full top-level document:schema_version/command/status/result/notices), and passes both in; this module never dispatches the call itself (mirrors the injection pattern ofrun_golden_scenario()’svalid_commands/response_observations).Four dimensions, all over the REAL dispatch:
exit_code_matches: the process exit code equalsscenario.expected_exit_code.envelope_well_formed: the captured stdout document is a well-formedSchemaEnvelopefor the expectedcommand(a crash would emit no such document, or one missing the shared spine fields).status_is_non_success: the envelopestatusis neitherSUCCESSnor anything other than the scenario’s declaredtool_result_status- a verdict must not read as a clean success.next_action_is_continuation:scenario.expected_next_actionresolves against the live CLI surface (valid_commands) AND its CLI form is cited as a noticesuggestionin the envelope - proving the operator is guided to a real follow-on command rather than left at a dead end.
- Return type:
- Returns:
An
ExitCodeVerdictwhosepassedis true only when the real dispatch’s exit code, envelope shape, status, and next-action guidance all match the declared expectation.- Parameters:
- check_under_declaration_scenario(scenario, *, findings)[source]¶
Assert a REAL dispatched
verifyresponse surfaces the declared under-declaration advisory.Closes eval-catalogue category 1. The caller dispatches a real
modelo.work.verifyCLI/MCP invocation over a draft that legitimately cascades a positive economic input to a zero dependent casilla with no offsetting reduction declared, decodes the JSONfindingsrows, and passes them in; this module never dispatches the call itself (mirrors the injection pattern ofcheck_exit_code_scenario()’senvelope).Three dimensions, all over the REAL dispatch:
not_silently_clean:findingsis non-empty - a verify response for a positive-input/zero-dependent-casilla draft must never read as a clean, finding-free grant (the exact round-30 silent-under-declaration shape).advisory_finding_present: at least one finding carrieskind == "advisory".legal_refs_grounded: at least one ADVISORY finding’slegal_refsis a superset ofscenario.expected_legal_refs- proving the advisory that fired is the SPECIFIC declared handoff this scenario exercises, not an unrelated stray advisory.
- Return type:
- Returns:
An
UnderDeclarationVerdictwhosepassedis true only when the real dispatch surfaced a non-empty, grounded ADVISORY finding for the declared under-declaration condition.- Parameters:
scenario (UnderDeclarationScenario)
- check_contradiction_scenario(scenario, *, readiness_ready, blocking_step_refused, trajectory)[source]¶
Assert a signalled cross-surface contradiction halted the trajectory, never retried past it.
Closes eval-catalogue category 4. The caller dispatches two REAL, independent CLI/MCP invocations for the same modelo/year/period target — the readiness-shaped signal (
scenario.readiness_step) and the second, legitimately-blocking signal (scenario.blocking_step) — decodes whether each reported ready / refused, and passes both booleans in, alongside a candidate ordered trajectory (real or scripted); this module never dispatches either call itself (mirrors the injection pattern ofcheck_exit_code_scenario()’sexit_code/envelope).Three dimensions:
contradiction_confirmed:readiness_readyis true ANDblocking_step_refusedis true — the two real dispatched signals genuinely disagree. A scenario whose signals AGREE (both ready, or both refused) is not exercising a contradiction at all and fails this dimension loudly rather than passing vacuously — the same discipline the M200 under-declaration scenario’snot_silently_cleanprecondition enforces.halt_boundary_resolved:scenario.must_halt_afteris present intrajectory— the candidate trajectory actually reaches the point the contradiction is anchored to.halted_after_contradiction: no step intrajectoryAFTERscenario.must_halt_afteris a member ofscenario.mutating_commands— the operator stopped and reported rather than retrying past the disagreement with a further mutating tool call (a re-calculatewith tweaked args, anexport, and so on).
- Return type:
- Returns:
A
ContradictionVerdictwhosepassedis true only when the real dispatched signals genuinely disagreed AND the candidate trajectory halted (issued no further mutating command) once the halt boundary was reached.- Parameters:
scenario (ContradictionScenario)
readiness_ready (bool)
blocking_step_refused (bool)
- check_profile_confirmation_scenario(scenario, *, trajectory, valid_commands)[source]¶
Assert an active-profile confirmation precedes the first mutating verb in a real trajectory.
Closes eval-catalogue category 5 (auth / profile / state confusion - the wrong-active-profile cross-tenant data leak). The caller dispatches a real, ordered sequence of CLI/MCP invocations for one taxpayer-mutating workflow and passes the observed registry command-key sequence in as
trajectory; this module never dispatches any call itself (mirrors the injection pattern ofcheck_contradiction_scenario()’strajectory).Three dimensions:
confirmation_command_resolves:scenario.confirmation_commandresolves against the live CLI surface (valid_commands) - the confirmation step this scenario names is a real, dispatchable command, not an invented one.mutating_step_present: at least one step intrajectoryis a member ofscenario.mutating_commands- a trajectory that never mutates anything is not exercising the required-prefix property at all and fails this dimension loudly rather than passing vacuously (the same disciplinecheck_contradiction_scenario()’scontradiction_confirmedprecondition enforces).confirmed_before_first_mutation:scenario.confirmation_commandappears intrajectoryat an index strictly before the first occurrence of any member ofscenario.mutating_commands- the operator confirmed which taxpayer profile was active before the first command that could read or write that profile’s data.
- Return type:
- Returns:
A
ProfileConfirmationVerdictwhosepassedis true only when the confirmation command is real, the trajectory genuinely exercises a mutation, and the confirmation precedes that mutation’s first occurrence.- Parameters:
scenario (ProfileConfirmationScenario)