oc_chat
Loading...
Searching...
No Matches
jev_walk Namespace Reference

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")

Detailed Description

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)

Function Documentation

◆ _agreement()

int jev_walk._agreement ( Sequence[Mapping[str, Any]] rows)
protected
How many rows match the gate, restated from ``score.py``'s one line.

Definition at line 1214 of file jev_walk.py.

Here is the caller graph for this function:

◆ _analyse()

int jev_walk._analyse ( Path results_dir)
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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _build_parser()

argparse.ArgumentParser jev_walk._build_parser ( )
protected
Construct the CLI argument parser.

Definition at line 1728 of file jev_walk.py.

Here is the caller graph for this function:

◆ _composition_note()

str jev_walk._composition_note ( str remainder)
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.

Here is the caller graph for this function:

◆ _gate_structure()

str jev_walk._gate_structure ( str command,
Any decision )
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.

Here is the caller graph for this function:

◆ _granted_more()

int jev_walk._granted_more ( Sequence[Mapping[str, Any]] rows)
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.

Here is the caller graph for this function:

◆ _perm_leg()

FlatLeg jev_walk._perm_leg ( str key)
protected
P2's permutation leg for insertion order *key*.

Definition at line 569 of file jev_walk.py.

◆ _read_payloads()

list[tuple[str, dict[str, Any]]] jev_walk._read_payloads ( Path results_dir,
Iterable[str] names )
protected
Load the named result files that are on disk, skipping those that are not.

Definition at line 1647 of file jev_walk.py.

Here is the caller graph for this function:

◆ _repeat_leg()

FlatLeg jev_walk._repeat_leg ( int index)
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.

◆ _resolved_leg()

WalkLeg jev_walk._resolved_leg ( WalkLeg leg,
argparse.Namespace args )
protected
*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.

Here is the caller graph for this function:

◆ _run_flat()

int jev_walk._run_flat ( Sequence[FlatLeg] legs,
Path base,
Path out_dir,
str key,
argparse.Namespace args,
dict[str, float] spent )
protected
Run a set of flat legs, writing one result file each.

Definition at line 1784 of file jev_walk.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _run_walks()

int jev_walk._run_walks ( Sequence[WalkLeg] legs,
Path base,
Path out_dir,
str key,
argparse.Namespace args,
dict[str, float] spent )
protected
Run a set of walked legs, writing one result file each.

Definition at line 1851 of file jev_walk.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _spread()

dict[str, float] jev_walk._spread ( str verdict,
float probability,
Mapping[str, float] | None leaf_probs,
str remainder_rule = DEFAULT_EARLY_STOP_REMAINDER )
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.

Here is the caller graph for this function:

◆ _top_probability()

float | None jev_walk._top_probability ( Mapping[str, Any] row)
protected
The row's top forecast probability, or ``None`` when it has none.

Definition at line 1204 of file jev_walk.py.

Here is the caller graph for this function:

◆ _walked_row()

dict[str, Any] jev_walk._walked_row ( dict[str, Any] case,
list[Step] steps,
float ms,
int requests,
str remainder = DEFAULT_EARLY_STOP_REMAINDER )
protected
One result row from one command's path through the tree.

Definition at line 1044 of file jev_walk.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_node_request()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compose()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gate_node_labels()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ leaf_control_table()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ node_instructions()

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.

Here is the caller graph for this function:

◆ node_of_request()

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.

◆ node_state_text()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ noise_band()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ per_node_table()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ permutation_table()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ permuted_criteria()

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.

◆ pinned_rule_rows()

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.

Here is the caller graph for this function:

◆ remainder_comparison()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_leaf_control_table()

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.

Here is the caller graph for this function:

◆ render_noise_table()

str jev_walk.render_noise_table ( Mapping[str, Any] band)
P1's table as markdown.

Definition at line 1391 of file jev_walk.py.

Here is the caller graph for this function:

◆ render_per_node_table()

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.

Here is the caller graph for this function:

◆ render_permutation_table()

str jev_walk.render_permutation_table ( Mapping[str, Any] table)
P2's table as markdown.

Definition at line 1419 of file jev_walk.py.

Here is the caller graph for this function:

◆ render_remainder_table()

str jev_walk.render_remainder_table ( Mapping[str, Any] result)
P2's table as markdown.

Definition at line 1598 of file jev_walk.py.

Here is the caller graph for this function:

◆ render_walk_cost_table()

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.

Here is the caller graph for this function:

◆ run_flat_leg()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_leg()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sandbox_root()

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.

Here is the caller graph for this function:

◆ slice_text()

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.

Here is the caller graph for this function:

◆ walk()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ whole_policy()

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.

Here is the caller graph for this function:

Variable Documentation

◆ _BARE

tuple jev_walk._BARE
protected
Initial value:
1= (
2 "Bare \"pip install\" is confirm, bare \"python\"/\"pytest\"/\"oct\" are "
3 "confirm, bare \"where\"/\"which\" deny, and bare \"echo\"/\"dir\"/\"ls\" allow."
4)

Definition at line 277 of file jev_walk.py.

◆ _CASING

tuple jev_walk._CASING
protected
Initial value:
1= (
2 # OCT-LINT: disable=no_hardcoded_secrets reason="plan 296: verbatim policy.txt casing sentence pinned as a node slice (witness W2 asserts it is a substring of the file); 4.58 bits/char of English prose with embedded quotes, no credential (operator ruling 2026-09-18)"
3 "The PROGRAM name is case-insensitive and a .exe suffix is stripped, but "
4 "pip SUBCOMMANDS are case-sensitive and must be lowercase (\"Pip List\" "
5 "denies because \"List\" is not a known subcommand)."
6)

Definition at line 248 of file jev_walk.py.

◆ _PROGRAM_SENTENCES

tuple jev_walk._PROGRAM_SENTENCES
protected
Initial value:
1= (
2 "deny: everything else.",
3 "Unknown programs (git, cat, type, grep, findstr, curl, wget, bash, sh, "
4 "powershell, pwsh, node, del, copy, move, ren, md, rmdir, rm) are denied: "
5 "reads go through the filesystem tools and git through oct_git_*.",
6 _CASING,
7)

Definition at line 255 of file jev_walk.py.

◆ _QUOTED_METACHAR

tuple jev_walk._QUOTED_METACHAR
protected
Initial value:
1= (
2 "A metacharacter only inside quotes is allowed as data for the Tier-2 "
3 "programs (python, python3, py, pytest, oct) but denies for everything "
4 "else including echo, dir, ls."
5)

Definition at line 270 of file jev_walk.py.

◆ _STRUCTURE_SENTENCES

tuple jev_walk._STRUCTURE_SENTENCES
protected
Initial value:
1= (
2 "Any shell metacharacter | & ; < > $ backtick % or a newline outside "
3 "quotes denies for every program, and NUL denies wherever it appears.",
4 "An unterminated quote denies.",
5 "An empty or whitespace-only command denies.",
6)

Definition at line 236 of file jev_walk.py.

◆ _UNKNOWN_OPTIONS

tuple jev_walk._UNKNOWN_OPTIONS
protected
Initial value:
1= (
2 "Unknown options anywhere deny (for example ls -R, dir /s, ls --sort, "
3 "pip list -q)."
4)

Definition at line 283 of file jev_walk.py.

◆ case_file

jev_walk.case_file

Definition at line 588 of file jev_walk.py.

◆ CONTROL_LEGS

tuple jev_walk.CONTROL_LEGS = ("hard", "hard_rep1", "hard_whole", "hard_none")

Definition at line 632 of file jev_walk.py.

◆ criteria

jev_walk.criteria

Definition at line 590 of file jev_walk.py.

◆ CRITERIA_ORDERS

dict jev_walk.CRITERIA_ORDERS
Initial value:
1= {
2 "acd": ("allow", "confirm", "deny"),
3 "adc": ("allow", "deny", "confirm"),
4 "cad": ("confirm", "allow", "deny"),
5 "cda": ("confirm", "deny", "allow"),
6 "dac": ("deny", "allow", "confirm"),
7 "dca": ("deny", "confirm", "allow"),
8}

Definition at line 483 of file jev_walk.py.

◆ DEFAULT_EARLY_STOP_REMAINDER

str jev_walk.DEFAULT_EARLY_STOP_REMAINDER = "none"

Definition at line 209 of file jev_walk.py.

◆ DEFAULT_LEAF_STATE

str jev_walk.DEFAULT_LEAF_STATE = "slice"

Definition at line 202 of file jev_walk.py.

◆ EARLY_STOP_REMAINDERS

tuple jev_walk.EARLY_STOP_REMAINDERS = ("none", "next")

Definition at line 205 of file jev_walk.py.

◆ FALLBACK_LABEL

str jev_walk.FALLBACK_LABEL = "deny"

Definition at line 193 of file jev_walk.py.

◆ LEAF_NODES

frozenset jev_walk.LEAF_NODES = frozenset({"listing", "echo", "where", "pip"})

Definition at line 359 of file jev_walk.py.

◆ LEAF_STATES

tuple jev_walk.LEAF_STATES = ("slice", "whole", "none")

Definition at line 199 of file jev_walk.py.

◆ model

jev_walk.model

Definition at line 587 of file jev_walk.py.

◆ name

jev_walk.name

Definition at line 586 of file jev_walk.py.

◆ NEXT_MOST_PERMISSIVE

dict jev_walk.NEXT_MOST_PERMISSIVE = {"deny": "confirm"}

Definition at line 216 of file jev_walk.py.

◆ NEXT_NODE

dict jev_walk.NEXT_NODE
Initial value:
1= {
2 ("structure", "clean"): "program",
3 ("program", "tier1_listing"): "listing",
4 ("program", "tier1_echo"): "echo",
5 ("program", "tier1_where"): "where",
6 ("program", "pip"): "pip",
7}

Definition at line 381 of file jev_walk.py.

◆ NODE_CRITERIA

dict jev_walk.NODE_CRITERIA

Definition at line 404 of file jev_walk.py.

◆ NODE_OPTIONS

dict jev_walk.NODE_OPTIONS
Initial value:
1= {
2 "structure": ("clean", "metachar_outside_quotes",
3 "unterminated_or_nul_or_empty"),
4 "program": ("tier1_listing", "tier1_echo", "tier1_where", "pip", "tier2",
5 "unknown"),
6 "listing": ("allow", "deny"),
7 "echo": ("allow", "deny"),
8 "where": ("allow", "deny"),
9 "pip": ("allow", "confirm", "deny"),
10}

Definition at line 341 of file jev_walk.py.

◆ NODE_ORDER

tuple jev_walk.NODE_ORDER
Initial value:
1= ("structure", "program", "listing", "echo",
2 "where", "pip")

Definition at line 353 of file jev_walk.py.

◆ NODE_VERBS

dict jev_walk.NODE_VERBS
Initial value:
1= {
2 "structure": "Classify the STRUCTURE of command",
3 "program": "Classify the PROGRAM of command",
4 "listing": "Classify the VERDICT of the dir/ls command",
5 "echo": "Classify the VERDICT of the echo command",
6 "where": "Classify the VERDICT of the where/which command",
7 "pip": "Classify the VERDICT of the pip command",
8}

Definition at line 466 of file jev_walk.py.

◆ note

jev_walk.note

Definition at line 591 of file jev_walk.py.

◆ PERM_LEGS

dict jev_walk.PERM_LEGS = {key: _perm_leg(key) for key in CRITERIA_ORDERS}

Definition at line 584 of file jev_walk.py.

◆ PERMISSIVENESS

dict jev_walk.PERMISSIVENESS = {"deny": 0, "confirm": 1, "allow": 2}

Definition at line 188 of file jev_walk.py.

◆ PLAN_296_WALK_LEGS

tuple jev_walk.PLAN_296_WALK_LEGS = ("hand", "hard", "hard_nopolicy")

Definition at line 623 of file jev_walk.py.

◆ PLAN_301_WALK_LEGS

tuple jev_walk.PLAN_301_WALK_LEGS
Initial value:
1= ("hard_rep1", "hard_whole", "hard_none",
2 "hard_next")

Definition at line 626 of file jev_walk.py.

◆ policy_file

jev_walk.policy_file

Definition at line 589 of file jev_walk.py.

◆ POLICY_SLICES

dict jev_walk.POLICY_SLICES

Definition at line 289 of file jev_walk.py.

◆ PROGRAM_CLASSES

dict jev_walk.PROGRAM_CLASSES
Initial value:
1= {
2 "dir": "tier1_listing", "ls": "tier1_listing",
3 "echo": "tier1_echo",
4 "where": "tier1_where", "which": "tier1_where",
5 "pip": "pip",
6 "python": "tier2", "python3": "tier2", "py": "tier2",
7 "pytest": "tier2", "oct": "tier2",
8}

Definition at line 391 of file jev_walk.py.

◆ REPEAT_LEGS

dict jev_walk.REPEAT_LEGS
Initial value:
1= {
2 "rep1": _repeat_leg(1),
3 "rep2": _repeat_leg(2),
4}

Definition at line 563 of file jev_walk.py.

◆ ROUTE

str jev_walk.ROUTE = "typesafe-walk"

Definition at line 184 of file jev_walk.py.

◆ SPEND_CAP_USD

float jev_walk.SPEND_CAP_USD = 2.0

Definition at line 219 of file jev_walk.py.

◆ STOP_VERDICTS

dict jev_walk.STOP_VERDICTS
Initial value:
1= {
2 ("structure", "metachar_outside_quotes"): "deny",
3 ("structure", "unterminated_or_nul_or_empty"): "deny",
4 ("program", "unknown"): "deny",
5 ("program", "tier2"): "confirm",
6 ("listing", "allow"): "allow",
7 ("listing", "deny"): "deny",
8 ("echo", "allow"): "allow",
9 ("echo", "deny"): "deny",
10 ("where", "allow"): "allow",
11 ("where", "deny"): "deny",
12 ("pip", "allow"): "allow",
13 ("pip", "confirm"): "confirm",
14 ("pip", "deny"): "deny",
15}

Definition at line 363 of file jev_walk.py.

◆ WALK_LEGS

dict jev_walk.WALK_LEGS
Initial value:
1= {
2 "hand": WalkLeg("hand", "jev_walk_hand", "policy", "cases.json", True),
3 "hard": WalkLeg("hard", "jev_walk_hard", "policy", "cases_hard.json", True),
4 "hard_nopolicy": WalkLeg("hard_nopolicy", "jev_walk_hard_nopolicy",
5 "nopolicy", "cases_hard.json", False),
6 "hard_rep1": WalkLeg("hard_rep1", "jev_walk_hard_rep1", "policy",
7 "cases_hard.json", True, leaf_state="slice",
8 plan="301"),
9 "hard_whole": WalkLeg("hard_whole", "jev_walk_hard_whole", "whole",
10 "cases_hard.json", True, leaf_state="whole",
11 plan="301"),
12 "hard_none": WalkLeg("hard_none", "jev_walk_hard_none", "none",
13 "cases_hard.json", True, leaf_state="none",
14 plan="301"),
15 "hard_next": WalkLeg("hard_next", "jev_walk_hard_next", "next",
16 "cases_hard.json", True, leaf_state="slice",
17 early_stop_remainder="next", plan="301"),
18}

Definition at line 600 of file jev_walk.py.

◆ WORD_CRITERIA

dict jev_walk.WORD_CRITERIA = {label: label for label in LABELS}

Definition at line 495 of file jev_walk.py.