|
oc_chat
|
Classes | |
| class | FlatLeg |
| class | WalkLeg |
| class | Step |
| class | Composed |
Functions | |
| FlatLeg | _repeat_leg (int index) |
| FlatLeg | _perm_leg (str key) |
| dict[str, str] | permuted_criteria (str key) |
| Path | sandbox_root () |
| str | slice_text (str node) |
| str | whole_policy (Path|None root=None) |
| str|None | node_state_text (str node, str leaf_state=DEFAULT_LEAF_STATE, str|None policy_text=None) |
| Callable[[int, str, str], str] | node_instructions (str node) |
| dict[str, Any] | build_node_request (str node, Sequence[str] commands, bool with_policy=True, str leaf_state=DEFAULT_LEAF_STATE, str|None policy_text=None) |
| str | node_of_request (Mapping[str, Any] body) |
| Composed | compose (Sequence[Step] steps, str remainder=DEFAULT_EARLY_STOP_REMAINDER) |
| dict[str, float] | _spread (str verdict, float probability, Mapping[str, float]|None leaf_probs, str remainder_rule=DEFAULT_EARLY_STOP_REMAINDER) |
| dict[str, str] | gate_node_labels (str command, Path|None root=None) |
| str | _gate_structure (str command, Any decision) |
| list[dict[str, Any]] | walk (list[dict[str, Any]] cases, bool with_policy, int batch=DEFAULT_BATCH, str|None key=None, dict[str, Any]|None usage=None, float timeout=DEFAULT_TIMEOUT, int retries=DEFAULT_RETRIES, Callable[..., Any]|None opener=None, Callable[[float], None] sleep=time.sleep, Callable[[str], None]|None progress=None, str leaf_state=DEFAULT_LEAF_STATE, str remainder=DEFAULT_EARLY_STOP_REMAINDER) |
| dict[str, Any] | _walked_row (dict[str, Any] case, list[Step] steps, float ms, int requests, str remainder=DEFAULT_EARLY_STOP_REMAINDER) |
| str | _composition_note (str remainder) |
| dict[str, Any] | run_leg (WalkLeg leg, list[dict[str, Any]] cases, int batch=DEFAULT_BATCH, str|None key=None, float timeout=DEFAULT_TIMEOUT, int retries=DEFAULT_RETRIES, Callable[..., Any]|None opener=None, Callable[[float], None] sleep=time.sleep, Callable[[str], None]|None progress=None) |
| dict[str, Any] | run_flat_leg (FlatLeg leg, list[dict[str, Any]] cases, str|None policy_text, int batch=DEFAULT_BATCH, str|None key=None, float timeout=DEFAULT_TIMEOUT, int retries=DEFAULT_RETRIES, Callable[..., Any]|None opener=None, Callable[[float], None] sleep=time.sleep, Callable[[str], None]|None progress=None) |
| float|None | _top_probability (Mapping[str, Any] row) |
| int | _agreement (Sequence[Mapping[str, Any]] rows) |
| int | _granted_more (Sequence[Mapping[str, Any]] rows) |
| dict[str, Any] | noise_band (Sequence[tuple[str, dict[str, Any]]] payloads) |
| dict[str, Any] | permutation_table (Sequence[tuple[str, dict[str, Any]]] payloads) |
| list[dict[str, Any]] | per_node_table (Sequence[Mapping[str, Any]] rows, Path|None root=None) |
| str | render_noise_table (Mapping[str, Any] band) |
| str | render_permutation_table (Mapping[str, Any] table) |
| str | render_per_node_table (Sequence[Mapping[str, Any]] table) |
| list[dict[str, Any]] | leaf_control_table (Sequence[tuple[str, dict[str, Any]]] payloads, Path|None root=None) |
| str | render_leaf_control_table (Sequence[Mapping[str, Any]] table) |
| dict[str, Any] | remainder_comparison (dict[str, Any] pinned, dict[str, Any] escalating, float threshold=DEFAULT_THRESHOLD) |
| list[dict[str, Any]] | pinned_rule_rows (Sequence[Mapping[str, Any]] rows) |
| str | render_remainder_table (Mapping[str, Any] result) |
| str | render_walk_cost_table (Sequence[tuple[str, dict[str, Any]]] payloads) |
| list[tuple[str, dict[str, Any]]] | _read_payloads (Path results_dir, Iterable[str] names) |
| int | _analyse (Path results_dir) |
| argparse.ArgumentParser | _build_parser () |
| int | _run_flat (Sequence[FlatLeg] legs, Path base, Path out_dir, str key, argparse.Namespace args, dict[str, float] spent) |
| WalkLeg | _resolved_leg (WalkLeg leg, argparse.Namespace args) |
| int | _run_walks (Sequence[WalkLeg] legs, Path base, Path out_dir, str key, argparse.Namespace args, dict[str, float] spent) |
| int | main (list[str]|None argv=None) |
Variables | |
| str | ROUTE = "typesafe-walk" |
| dict | PERMISSIVENESS = {"deny": 0, "confirm": 1, "allow": 2} |
| str | FALLBACK_LABEL = "deny" |
| tuple | LEAF_STATES = ("slice", "whole", "none") |
| str | DEFAULT_LEAF_STATE = "slice" |
| tuple | EARLY_STOP_REMAINDERS = ("none", "next") |
| str | DEFAULT_EARLY_STOP_REMAINDER = "none" |
| dict | NEXT_MOST_PERMISSIVE = {"deny": "confirm"} |
| float | SPEND_CAP_USD = 2.0 |
| tuple | _STRUCTURE_SENTENCES |
| tuple | _CASING |
| tuple | _PROGRAM_SENTENCES |
| tuple | _QUOTED_METACHAR |
| tuple | _BARE |
| tuple | _UNKNOWN_OPTIONS |
| dict | POLICY_SLICES |
| dict | NODE_OPTIONS |
| tuple | NODE_ORDER |
| frozenset | LEAF_NODES = frozenset({"listing", "echo", "where", "pip"}) |
| dict | STOP_VERDICTS |
| dict | NEXT_NODE |
| dict | PROGRAM_CLASSES |
| dict | NODE_CRITERIA |
| dict | NODE_VERBS |
| dict | CRITERIA_ORDERS |
| dict | WORD_CRITERIA = {label: label for label in LABELS} |
| dict | REPEAT_LEGS |
| dict | PERM_LEGS = {key: _perm_leg(key) for key in CRITERIA_ORDERS} |
| name | |
| model | |
| case_file | |
| policy_file | |
| criteria | |
| note | |
| dict | WALK_LEGS |
| tuple | PLAN_296_WALK_LEGS = ("hand", "hard", "hard_nopolicy") |
| tuple | PLAN_301_WALK_LEGS |
| tuple | CONTROL_LEGS = ("hard", "hard_rep1", "hard_whole", "hard_none") |
Jev as a walk of small typed questions, composed in code -- plus plan 296's
run-to-run noise band and its label-permutation legs.
Purpose
-------
Plan 293 measured Jev as ONE flat three-way choice with the whole 2207-character
policy in the state: 276 of 300 on the hard set, 7 errors granting more
permission than the gate. Two outside observations since then say that shape is
not neutral. Archer Hume's black-box analysis (2026-09-17) measured that adding
an irrelevant option shifts the log-odds between the existing options by about
0.28 and that an answer placed last among the options is chosen far more often
than the same answer placed first. And a developer on the TypeSafe Discord runs
Jev as a greedy walk over declared children with a per-node threshold and
composes the result in code -- which is the shape of the M8 gate itself:
metacharacter rule, then program class, then the per-program rule.
This module measures all three things the flat number cannot separate.
**The noise band (P1).** Plan 293's ``hard`` leg run twice more, unchanged, so
every later difference is read against how much the model moves when nothing
does.
**The label permutation (P2).** The same flat choice with the three criteria in
each of the six insertion orders, and one wording variant that keeps the
plan-293 order and reduces the criteria to the single words ``allow``,
``confirm`` and ``deny``. Order and wording move separately or they do not move
at all, and only running both says which.
**The walk (P3/P4).** A fixed three-deep tree, composed IN CODE. Node
``structure`` asks whether the command is clean, has a metacharacter outside
quotes, or is unterminated/NUL/empty. Node ``program`` asks which class the
program falls in. The four continuing classes each have one leaf asking that
class's own rule. Every node's state carries ONLY the policy sentences that
node needs -- pinned constants here, each a verbatim substring of
``policy.txt`` -- plus the batch of commands. The composition is a pure
function, and :mod:`test_296_walk` asserts it against ``classify_command``
itself on every leaf and every early stop.
That is a different trust shape from the flat choice. The model grounds atoms;
the gate's control flow stays in code where it can be read and tested.
**The slice control (plan 301 P1).** Plan 296 measured the ``where`` leaf at 8
of 13 with its slice and 12 of 13 with no policy text at all, and could not say
whether those three sentences are WRONG or whether that node simply does better
with less text. ``--leaf-state`` answers it by running the same walk with every
LEAF's state replaced by the whole of ``policy.txt`` and again with no policy
text, holding the two shared nodes at their slices -- plan 296 measured those
two as identical with and without, command for command, so moving them would put
a second variable inside a control. ``slice`` is the default and is plan 296's
request byte for byte.
**The remainder rule (plan 301 P2).** The composition places a path's leftover
belief by the leaf's own distribution, and on ``deny`` where the path never
reached a leaf. For an early stop that composes to ``deny`` that hands the
label the whole mass, so the row is filed at probability 1.0 however unsure the
node was and a WRONG early denial cannot escalate at any threshold.
``--early-stop-remainder next`` puts that remainder on the next most permissive
label instead. ``none`` is the default and is plan 296's arithmetic exactly.
Why the permutation and repeat legs live in this module rather than in a third
one: plan 296 P5 authorises exactly two baseline modules to change, this new
one and a helper extraction in :mod:`jev_direct`, so a separate
``jev_permute.py`` is not on the table. All three sets of legs share the
request, the post, the key and the row parse, which are imported rather than
copied.
Run it under the PROJECT venv from the subproject root, in a shell where the
operator has set ``TYPESAFE_API``::
python bench/argv_policy/baselines/jev_walk.py --all
python bench/argv_policy/baselines/jev_walk.py --control
python bench/argv_policy/baselines/jev_walk.py --analyse
The key is read from the process environment through :func:`jev_direct.api_key`
and from nowhere else. This module never opens a key file, never logs a key,
never writes one into a result file and never prints one.
Responsibilities
----------------
- :data:`NODE_OPTIONS` / :data:`NODE_CRITERIA` / :data:`POLICY_SLICES` -- the
tree, its typed options and the policy sentences each node sees.
- :func:`slice_text` / :func:`node_state_text` / :func:`build_node_request` /
:func:`node_of_request` -- one node's state and question under a given leaf
state, and the route back from a body to its node.
- :func:`compose` -- the pure composition: path to verdict and distribution,
under either remainder rule.
- :func:`gate_node_labels` -- what the gate's own decision implies each node
should have answered, which is what the per-node table is scored against.
- :func:`walk` / :func:`run_leg` -- a case set to scorable rows and a payload.
- :func:`run_flat_leg` -- one flat-choice leg (a P1 repeat or a P2 permutation).
- :func:`noise_band` / :func:`permutation_table` / :func:`per_node_table` --
the three analyses ``score.py`` cannot produce from a single file.
- :func:`leaf_control_table` / :func:`remainder_comparison` -- plan 301's two:
each leaf under each leaf state, and what the remainder rule moves.
- :func:`main` -- the CLI.
Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
L2 - run lifecycle (leg started, node requests sent, files written)
L3 - per-node routing, per-leg agreement, retries taken
L4 - module load
Contracts
---------
- Standard library only, exactly as the rest of this bench is, plus the gate
itself (:mod:`oc_chat.tools._argv_policy`), which is the oracle every label
on this bench already comes from. No dependency enters any ``pyproject.toml``.
- ``score.py`` is NOT changed and NOT imported: a walked row is the plan-288
row shape, so the unchanged scorer reads it. Two of the scorer's lines --
the top probability and the permissiveness order -- are restated here for
the analyses below, for the same reason :mod:`jev_direct` restates the first:
a baseline module stays runnable from the baselines directory on its own.
- Latency per walked decision is the SUM along its path of each node request's
wall time divided by that request's batch size, so it is comparable with the
flat legs' per-decision figure and counts every hop the walk actually made.
- A node the API does not answer produces a row with ``pred`` of ``None`` and
no probabilities rather than an invented verdict.
- Console output is ASCII only; commands are printed through :func:`ascii`.
- The only network host this module contacts is ``api.typesafe.ai``.
Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.tools._argv_policy (classify_command, the gate oracle each node's reference answer is derived from)
- baselines.jev_direct (the shared request builder, API key, post, answer parse, case reader, result writer and flat-leg evaluator)
|
protected |
How many rows match the gate, restated from ``score.py``'s one line.
Definition at line 1214 of file jev_walk.py.
|
protected |
Print P1's, P2's and P4's tables from the result files already on disk.
Definition at line 1661 of file jev_walk.py.
|
protected |
Construct the CLI argument parser.
Definition at line 1728 of file jev_walk.py.
|
protected |
The provenance sentence describing the arithmetic a leg actually used. Two result files whose rows differ only by a composition rule have to be told apart by something inside them, not by their file names.
Definition at line 1077 of file jev_walk.py.
|
protected |
Node 1's reference answer, from the gate's pre-parse denials. NUL is checked first because the gate reports it through the metacharacter denial while the tree files it with the other unparseable inputs, which is where a reader of the policy text would put it: the sentence that names NUL says it denies "wherever it appears", quoted or not, and that is not the outside-quotes rule the other branch asks about.
Definition at line 926 of file jev_walk.py.
|
protected |
How many errors granted MORE permission than the gate. The scorer's rule verbatim: an unrecognised prediction counts as granting more, because understating this column is the one direction a bench must never round in.
Definition at line 1220 of file jev_walk.py.
|
protected |
P2's permutation leg for insertion order *key*.
Definition at line 569 of file jev_walk.py.
|
protected |
Load the named result files that are on disk, skipping those that are not.
Definition at line 1647 of file jev_walk.py.
|
protected |
P1's *index*-th repeat of plan 293's ``hard`` leg, byte-identical to it.
Definition at line 544 of file jev_walk.py.
*leg* under the CLI's levers, refusing a flag that contradicts a pinned one. A leg that pins a lever is the reproducible object behind a plan-301 tag. Running it under a contradicting flag would write a file whose model name says one condition and whose rows are another, which is worse than not running it at all -- so it raises rather than choosing a winner.
Definition at line 1820 of file jev_walk.py.
|
protected |
Run a set of flat legs, writing one result file each.
Definition at line 1784 of file jev_walk.py.
|
protected |
Run a set of walked legs, writing one result file each.
Definition at line 1851 of file jev_walk.py.
|
protected |
The three-label distribution for one composed verdict. *leaf_probs* is absent exactly when the path stopped before a leaf, which is the only case *remainder_rule* can reach: a leaf hands its own distribution over and that is used under both rules.
Definition at line 868 of file jev_walk.py.
|
protected |
The row's top forecast probability, or ``None`` when it has none.
Definition at line 1204 of file jev_walk.py.
|
protected |
One result row from one command's path through the tree.
Definition at line 1044 of file jev_walk.py.
| dict[str, Any] jev_walk.build_node_request | ( | str | node, |
| Sequence[str] | commands, | ||
| bool | with_policy = True, | ||
| str | leaf_state = DEFAULT_LEAF_STATE, | ||
| str | None | policy_text = None ) |
One request body asking *node*'s question about a batch of *commands*. By default the state carries that node's slice and nothing else: not the whole policy, not another node's sentences. That is the measurable difference between this and the flat choice, so it is asserted by the witnesses rather than merely intended here. *leaf_state* is plan 301's control and moves the LEAVES only; see :func:`node_state_text`. *with_policy* still wins over it, so plan 296's withheld leg withholds from every node whatever the control says -- that leg is a different measurement and this plan does not touch it.
Definition at line 743 of file jev_walk.py.
| Composed jev_walk.compose | ( | Sequence[Step] | steps, |
| str | remainder = DEFAULT_EARLY_STOP_REMAINDER ) |
The pure composition: a path through the tree to one scorable verdict. The verdict is the gate's own control flow applied to the nodes' answers. Its probability is the PRODUCT of the chosen branch probabilities along the path. The distribution the scorer reads puts that product on the composed label and places the remainder by the leaf's own distribution where the path reached a leaf, and on ``deny`` where it did not. One consequence of that rule is worth stating plainly rather than leaving to be discovered in a table: when the walk stops EARLY at ``deny`` -- a metacharacter outside quotes, an unterminated quote, an unknown program -- there is no leaf distribution, so the remainder goes on ``deny`` as well and the row is filed at probability 1.0 however unsure the node was. Those rows carry no escalation signal at all. ``test_296_walk`` pins it and the findings document reports what it costs. *remainder* is plan 301 P2's lever over exactly that case. Under ``next`` an early stop composing to ``deny`` keeps the product on ``deny`` and puts the leftover on ``confirm``, so an unsure early denial falls below an escalation threshold instead of reading as certainty. Under the default ``none`` the arithmetic is plan 296's, unchanged. Nothing else moves: a path that reached a leaf has a distribution and uses it under both rules, and an early ``confirm`` at ``tier2`` keeps its fail-closed remainder. A choice outside its node's options, or a path that never reaches a stop, yields no verdict rather than a guess; a node that answered without probabilities yields the verdict with no distribution, exactly as a missing forecast is handled on the flat legs.
Definition at line 792 of file jev_walk.py.
| dict[str, str] jev_walk.gate_node_labels | ( | str | command, |
| Path | None | root = None ) |
What the gate's own decision implies each node on its path should answer. This is the reference the per-node table is scored against, and it is built from what ``classify_command`` EXPOSES -- its decision, its parsed program and its reason -- rather than from a second copy of the gate's internals. The mapping is only defined for the nodes the gate's path actually visits, so a command that stops at node 1 has one entry and not three.
Definition at line 900 of file jev_walk.py.
| list[dict[str, Any]] jev_walk.leaf_control_table | ( | Sequence[tuple[str, dict[str, Any]]] | payloads, |
| Path | None | root = None ) |
P1: every leaf under every condition, one entry per leaf and file. The four conditions are read side by side per LEAF rather than per file, because the question is what one node does with more or less text and a per-file table buries that under three nodes that did not move. The two shared nodes are reported too, and they are the control's own control: if they move between conditions, something other than the leaf state did.
Definition at line 1455 of file jev_walk.py.
| int jev_walk.main | ( | list[str] | None | argv = None | ) |
CLI entry point: run the pinned legs, or analyse what is on disk.
Definition at line 1886 of file jev_walk.py.
| Callable[[int, str, str], str] jev_walk.node_instructions | ( | str | node | ) |
The instruction writer for *node*, in :func:`jev_direct.build_request`'s shape. The suffix is the builder's, so a withheld run loses the four words "under the policy" here exactly as it does for the flat choice, and the withheld walk cannot depend on a policy text it did not send.
Definition at line 725 of file jev_walk.py.
| str jev_walk.node_of_request | ( | Mapping[str, Any] | body | ) |
Which node built *body*, read back out of its instruction verb. The criteria keys cannot do this: ``listing``, ``echo`` and ``where`` all offer exactly ``allow`` and ``deny``, so an option set identifies three nodes at once. The verb is distinct per node, and it is text the request already carries for the model's sake -- which is better than adding a routing field to a body whose shape is otherwise plan 293's.
Definition at line 773 of file jev_walk.py.
| str | None jev_walk.node_state_text | ( | str | node, |
| str | leaf_state = DEFAULT_LEAF_STATE, | ||
| str | None | policy_text = None ) |
The policy text *node* sees under *leaf_state*, or ``None`` for no text. The two shared nodes keep their slices whatever the leaf state is. A leaf gets its slice under ``slice``, the whole policy under ``whole``, and no text at all under ``none``. An unrecognised *leaf_state* raises rather than falling back to the default: a typo that silently ran the default condition would produce a result file whose name says ``whole`` and whose rows are ``slice``, which is the one failure a control cannot survive. *policy_text* is the whole policy when the caller already has it; the fallback reads it from the bench directory so a witness can build one request without threading the file through.
Definition at line 692 of file jev_walk.py.
| dict[str, Any] jev_walk.noise_band | ( | Sequence[tuple[str, dict[str, Any]]] | payloads | ) |
P1: how far the same request moves across repeated runs. Every later comparison in this plan is read against this. The files must cover the same commands in the same order; anything else is a band that looks fine and measures different commands, so it raises.
Definition at line 1240 of file jev_walk.py.
| list[dict[str, Any]] jev_walk.per_node_table | ( | Sequence[Mapping[str, Any]] | rows, |
| Path | None | root = None ) |
P4: how many commands each node saw, stopped, and got right. A node's agreement is against :func:`gate_node_labels` -- the answer the gate's own decision and reason imply -- so it says whether the model got the ATOM right, independently of whether the composed verdict came out right. A walk can reach the correct verdict through a wrong program class, and a per-node table is the only place that shows up. ``granted_more`` counts the rows that STOPPED at this node and whose composed verdict grants more permission than the gate's. Plan 301 reads it per leaf, where stopping is the same thing as arriving, so the column says what a leaf's errors cost in the direction this bench is graded by rather than only how many there were.
Definition at line 1336 of file jev_walk.py.
| dict[str, Any] jev_walk.permutation_table | ( | Sequence[tuple[str, dict[str, Any]]] | payloads | ) |
P2: what the label order costs, per order and per command.
Definition at line 1290 of file jev_walk.py.
| dict[str, str] jev_walk.permuted_criteria | ( | str | key | ) |
Plan 293's three criteria in insertion order *key*. The VALUES are untouched -- this is a permutation of the mapping's key order and of nothing else, which is the whole point of P2. A reworded criterion would make the leg a wording experiment rather than an order one, and the two are separated here by running each alone.
Definition at line 656 of file jev_walk.py.
| list[dict[str, Any]] jev_walk.pinned_rule_rows | ( | Sequence[Mapping[str, Any]] | rows | ) |
*rows* from a ``next`` run, refiled as the pinned rule would have filed them. This is what makes the remainder rule measurable rather than merely reported. Two RUNS of the same request differ by the model's own movement, which on this bench is worth about six commands, so a ``next`` file against a ``slice`` file measures the rule plus the noise and cannot separate them. The rule is a function of the composed row, though, so one run's answers can be filed both ways: an early stop that composed to ``deny`` keeps its verdict and takes the whole mass back, which is exactly what ``none`` does. Everything else is already identical under both rules and is copied unchanged. The derivation runs in this direction only. A ``next`` row carries the path's product on ``deny``; the ``none`` row it corresponds to carries 1.0 and has forgotten it, so a pinned file cannot be turned into an escalating one.
Definition at line 1562 of file jev_walk.py.
| dict[str, Any] jev_walk.remainder_comparison | ( | dict[str, Any] | pinned, |
| dict[str, Any] | escalating, | ||
| float | threshold = DEFAULT_THRESHOLD ) |
P2: what the remainder rule moves, counted on the rows it can reach. The rule can only touch rows that stopped before a leaf, so the counts that matter are over those rows and not over the file. ``wrong_now_escalating`` is the number the plan asks for by name: early-stopped commands whose verdict disagrees with the gate and which the pinned rule filed at a probability no threshold could catch. The two files must cover the same commands in the same order; anything else is a table that looks fine and compares different runs, so it raises.
Definition at line 1508 of file jev_walk.py.
| str jev_walk.render_leaf_control_table | ( | Sequence[Mapping[str, Any]] | table | ) |
P1's control table as markdown, grouped by node.
Definition at line 1492 of file jev_walk.py.
| str jev_walk.render_noise_table | ( | Mapping[str, Any] | band | ) |
P1's table as markdown.
Definition at line 1391 of file jev_walk.py.
| str jev_walk.render_per_node_table | ( | Sequence[Mapping[str, Any]] | table | ) |
P4's per-node table as markdown.
Definition at line 1438 of file jev_walk.py.
| str jev_walk.render_permutation_table | ( | Mapping[str, Any] | table | ) |
P2's table as markdown.
Definition at line 1419 of file jev_walk.py.
| str jev_walk.render_remainder_table | ( | Mapping[str, Any] | result | ) |
P2's table as markdown.
Definition at line 1598 of file jev_walk.py.
| str jev_walk.render_walk_cost_table | ( | Sequence[tuple[str, dict[str, Any]]] | payloads | ) |
P4's request, token and cost columns, which the scorer does not carry.
Definition at line 1622 of file jev_walk.py.
| dict[str, Any] jev_walk.run_flat_leg | ( | FlatLeg | leg, |
| list[dict[str, Any]] | cases, | ||
| str | None | policy_text, | ||
| int | batch = DEFAULT_BATCH, | ||
| str | None | key = None, | ||
| float | timeout = DEFAULT_TIMEOUT, | ||
| int | retries = DEFAULT_RETRIES, | ||
| Callable[..., Any] | None | opener = None, | ||
| Callable[[float], None] | sleep = time.sleep, | ||
| Callable[[str], None] | None | progress = None ) |
Run one flat three-way choice leg -- a P1 repeat or a P2 permutation. The evaluation itself is :func:`jev_direct.evaluate`, unchanged, reached through its ``criteria`` seam. Only the provenance block is written here, because it has to name plan 296, the criteria order actually sent and what the leg was for, none of which plan 293's block can say.
Definition at line 1145 of file jev_walk.py.
| dict[str, Any] jev_walk.run_leg | ( | WalkLeg | leg, |
| list[dict[str, Any]] | cases, | ||
| int | batch = DEFAULT_BATCH, | ||
| str | None | key = None, | ||
| float | timeout = DEFAULT_TIMEOUT, | ||
| int | retries = DEFAULT_RETRIES, | ||
| Callable[..., Any] | None | opener = None, | ||
| Callable[[float], None] | sleep = time.sleep, | ||
| Callable[[str], None] | None | progress = None ) |
Run one walked leg and build the payload the scorer reads.
Definition at line 1091 of file jev_walk.py.
| Path jev_walk.sandbox_root | ( | ) |
The oc_chat subproject root: the root every gate label here is computed against.
Definition at line 668 of file jev_walk.py.
| str jev_walk.slice_text | ( | str | node | ) |
The policy text *node* is given: its sentences, one per line.
Definition at line 674 of file jev_walk.py.
| list[dict[str, Any]] jev_walk.walk | ( | list[dict[str, Any]] | cases, |
| bool | with_policy, | ||
| int | batch = DEFAULT_BATCH, | ||
| str | None | key = None, | ||
| dict[str, Any] | None | usage = None, | ||
| float | timeout = DEFAULT_TIMEOUT, | ||
| int | retries = DEFAULT_RETRIES, | ||
| Callable[..., Any] | None | opener = None, | ||
| Callable[[float], None] | sleep = time.sleep, | ||
| Callable[[str], None] | None | progress = None, | ||
| str | leaf_state = DEFAULT_LEAF_STATE, | ||
| str | remainder = DEFAULT_EARLY_STOP_REMAINDER ) |
Walk every case through the tree and return rows in the bench schema. Commands are batched PER NODE, not per command: every command still at node 1 goes in one set of requests, then every command that reached node 2 goes in the next, and so on down the four leaves. A node is therefore one request per eight commands whatever the depth, and a command that stops at node 1 costs exactly one request's share. The row is plan 288's schema plus four keys the flat legs have no analogue for: ``stopped_at``, ``requests``, ``path`` and ``node_confidence``. ``ms`` is the sum along the path, so it is the wall time one walked decision actually took at a batch of *batch*. *leaf_state* and *remainder* are plan 301's two levers and default to plan 296's behaviour. The whole policy is read once here rather than per request, so a ``whole`` run sends one text it read one time.
Definition at line 950 of file jev_walk.py.
| str jev_walk.whole_policy | ( | Path | None | root = None | ) |
The whole of ``policy.txt``, read the way every runner on this bench reads it. Stripped, because that is what :func:`jev_direct.read_policy` and the flat legs send; a leaf under ``whole`` has to receive the same bytes the flat choice receives or the control measures a second difference as well.
Definition at line 680 of file jev_walk.py.
|
protected |
Definition at line 277 of file jev_walk.py.
|
protected |
Definition at line 248 of file jev_walk.py.
|
protected |
Definition at line 255 of file jev_walk.py.
|
protected |
Definition at line 270 of file jev_walk.py.
|
protected |
Definition at line 236 of file jev_walk.py.
|
protected |
Definition at line 283 of file jev_walk.py.
| jev_walk.case_file |
Definition at line 588 of file jev_walk.py.
| tuple jev_walk.CONTROL_LEGS = ("hard", "hard_rep1", "hard_whole", "hard_none") |
Definition at line 632 of file jev_walk.py.
| jev_walk.criteria |
Definition at line 590 of file jev_walk.py.
| dict jev_walk.CRITERIA_ORDERS |
Definition at line 483 of file jev_walk.py.
| str jev_walk.DEFAULT_EARLY_STOP_REMAINDER = "none" |
Definition at line 209 of file jev_walk.py.
| str jev_walk.DEFAULT_LEAF_STATE = "slice" |
Definition at line 202 of file jev_walk.py.
| tuple jev_walk.EARLY_STOP_REMAINDERS = ("none", "next") |
Definition at line 205 of file jev_walk.py.
| str jev_walk.FALLBACK_LABEL = "deny" |
Definition at line 193 of file jev_walk.py.
| frozenset jev_walk.LEAF_NODES = frozenset({"listing", "echo", "where", "pip"}) |
Definition at line 359 of file jev_walk.py.
| tuple jev_walk.LEAF_STATES = ("slice", "whole", "none") |
Definition at line 199 of file jev_walk.py.
| jev_walk.model |
Definition at line 587 of file jev_walk.py.
| jev_walk.name |
Definition at line 586 of file jev_walk.py.
| dict jev_walk.NEXT_MOST_PERMISSIVE = {"deny": "confirm"} |
Definition at line 216 of file jev_walk.py.
| dict jev_walk.NEXT_NODE |
Definition at line 381 of file jev_walk.py.
| dict jev_walk.NODE_CRITERIA |
Definition at line 404 of file jev_walk.py.
| dict jev_walk.NODE_OPTIONS |
Definition at line 341 of file jev_walk.py.
| tuple jev_walk.NODE_ORDER |
Definition at line 353 of file jev_walk.py.
| dict jev_walk.NODE_VERBS |
Definition at line 466 of file jev_walk.py.
| jev_walk.note |
Definition at line 591 of file jev_walk.py.
| dict jev_walk.PERM_LEGS = {key: _perm_leg(key) for key in CRITERIA_ORDERS} |
Definition at line 584 of file jev_walk.py.
| dict jev_walk.PERMISSIVENESS = {"deny": 0, "confirm": 1, "allow": 2} |
Definition at line 188 of file jev_walk.py.
| tuple jev_walk.PLAN_296_WALK_LEGS = ("hand", "hard", "hard_nopolicy") |
Definition at line 623 of file jev_walk.py.
| tuple jev_walk.PLAN_301_WALK_LEGS |
Definition at line 626 of file jev_walk.py.
| jev_walk.policy_file |
Definition at line 589 of file jev_walk.py.
| dict jev_walk.POLICY_SLICES |
Definition at line 289 of file jev_walk.py.
| dict jev_walk.PROGRAM_CLASSES |
Definition at line 391 of file jev_walk.py.
| dict jev_walk.REPEAT_LEGS |
Definition at line 563 of file jev_walk.py.
| str jev_walk.ROUTE = "typesafe-walk" |
Definition at line 184 of file jev_walk.py.
| float jev_walk.SPEND_CAP_USD = 2.0 |
Definition at line 219 of file jev_walk.py.
| dict jev_walk.STOP_VERDICTS |
Definition at line 363 of file jev_walk.py.
| dict jev_walk.WALK_LEGS |
Definition at line 600 of file jev_walk.py.
| dict jev_walk.WORD_CRITERIA = {label: label for label in LABELS} |
Definition at line 495 of file jev_walk.py.