tools/jev/ — JEV¶
The fleet's harness-level AI agent logic engine: conflict-free numbering (ids assigned at merge, never in a pull request), tiered pull-request conflict triage and resolution, loop step specs that CI and a local run render alike, the local loop runner that runs them, and recursive harness refinement (the surface check, the Propose–Probe–Compose plan and evidence tree, the experience library).
JEV is the fleet's planned agent logic layer (bamr87/it-journey PRD.md, Roadmap 2027 Q1). This directory holds its first two working capabilities, the headless executor layer, and the second one's local runner built on it. The first answers one question the fleet asks several times a week: a pull request says This branch has conflicts that must be resolved — now what?
The second, loop step specs, gives each agent step one spec that CI and a local run render the same bytes from. The first capability's answer has two halves. The first removes the conflicts that should never have existed (numbering). The second resolves what is left, at the cheapest tier that can finish the job (the conflict engine). Full operator doc: docs/JEV.md. The rules it is held to: amendment 0002.
Quick reference¶
python3 -m tools.jev number next # the next free id in every series
python3 -m tools.jev number plan # what the pending fragments would be assigned
python3 -m tools.jev number apply # assign, compile, consume the fragments
python3 -m tools.jev number lint --base origin/main # reject a hand-picked next number
python3 -m tools.jev ratify plan # records a maintainer's merge decided that still say otherwise (GETs only)
python3 -m tools.jev ratify plan --json --out plan.json # … as the JSON the ratify job applies and checks
python3 -m tools.jev ratify apply --plan plan.json # write exactly that plan; refuses on any mismatch
python3 -m tools.jev ratify check-diff --base origin/main [--plan plan.json] # HEAD differs from base by the plan and nothing else
python3 -m tools.jev ratify pr-body --plan plan.json # the record PR's body (--title for its title)
python3 -m tools.jev ratify select --plan plan.json # the job's own record PR: create, update or hold
python3 -m tools.jev ratify guard --pr 563 --sha <head> --plan plan.json # may the job merge it? 0 go, 3 not yet, 4 refuse, 5 re-cut, 6 stop
python3 -m tools.jev conflicts scan # every CONFLICTING open PR in the fleet
python3 -m tools.jev conflicts scan --repo bamr87/bamr87
python3 -m tools.jev conflicts triage --pr bamr87/bamr87#437
python3 -m tools.jev conflicts resolve --pr bamr87/bamr87#437 --dry-run
python3 -m tools.jev conflicts budget --scheduled # month to date against the cap
python3 -m tools.jev steps check # every step spec against its workflow and fleet.yml
python3 -m tools.jev steps render repo-scout scout --set NWO=bamr87/beta --set REPO_NAME=beta \
--set BRANCH=main --set BRIEF=scout-workorder-beta.md # the exact prompt bytes one leg gets
python3 -m tools.jev loop list # steps with a local: block (also: tools/dash loop …)
python3 -m tools.jev loop doctor # $0 host checks + the credential-free isolation probe, every local step
python3 -m tools.jev loop doctor fleet-pulse # … for one loop's step(s)
python3 -m tools.jev loop doctor --live # + the one-time canary, ≤ $0.10 per step (the maintainer's yes)
python3 -m tools.jev loop plan repo-scout --target SCHEMA # per item, no clone, no model
python3 -m tools.jev loop run repo-scout --target SCHEMA --rehearse # everything up to the model call, $0
python3 -m tools.jev loop run repo-scout --target SCHEMA --rehearse --context off # no context pack (CI-identical)
python3 -m tools.jev loop run repo-scout --target SCHEMA # one capped attempt + the dry-run preview
python3 -m tools.jev loop run repo-scout --target SCHEMA --apply # … and file the preview in the same run
python3 -m tools.jev loop publish <run_id> --apply # file a reviewed earlier dry run (once)
python3 -m tools.jev loop plan fleet-pulse # the fleet doctor: today's queue, one item per candidate
python3 -m tools.jev loop run fleet-pulse --target bamr87/law-ai:.github/workflows/ci.yml --rehearse # one candidate, $0
python3 -m tools.jev loop run fleet-pulse --target bamr87/law-ai:.github/workflows/ci.yml # one capped attempt ($40): the patch + the filing it asked for, previewed; --apply files it (§ 11.8)'s publish step
python3 -m tools.jev loop plan repo-evolution # the evolution agent: today's opted-in targets, one open pass per repo
python3 -m tools.jev loop run repo-evolution --target README --rehearse # one target, $0
python3 -m tools.jev loop run repo-evolution --target README # one capped attempt ($20): the patch + the draft PR body, previewed; a budget hit is previewed flagged
python3 -m tools.jev loop show --latest
python3 -m tools.jev loop budget # the month against budget.loops and budget.jev; exit 1 when together they exceed harnesses.budget.monthly_ai_usd
python3 -m tools.jev refine surface check [ROOT] # a repository's harness surface (context files, skills, agents, hooks, MCP): exit 1 on an error
python3 -m tools.jev refine surface census [ROOT] [--json] # the eight-component inventory
python3 -m tools.jev refine plan repo-scout --target SCHEMA [--k 1] [--mode parallel|sequential] # one Propose–Probe–Compose step: schedule, R=4k/P=3k, ceiling vs budget.loops, $0
python3 -m tools.jev refine evidence repo-scout --item bamr87/SCHEMA [--run ID]… [--stage compose] # the redacted evidence tree a proposer reads, from real local attempts
python3 -m tools.jev refine missions list|render NAME --set TOKEN=value … # the five stage prompts and the reflector's
python3 -m tools.jev refine library list|show|add|check|index … # the experience library (_data/harness_library)
python3 -m tools.jev refine reflect --rehearse # the incident reflector's evidence and argv, stopped before the model ($0)
python3 -m tools.jev refine reflect # ONE capped session ($2 stage cap, budget.loops): candidate lessons, validated, PREVIEW.md
python3 -m tools.jev refine reflect publish <stamp> [--apply] # file a reviewed preview as a draft PR (a person's yes; never scheduled)
python3 -m tools.jev refine reflect doctor [--live --yes] # the reflector's $0 probe, and its ≤ $0.10 read-fence canary
Run from the repository root — tools.jev is imported as a package, so python3 tools/jev/conflicts.py will not work.
Ratification records¶
ratify.py records what a merge decided. From one commit's state it plans: every amendment whose **Status:** is still proposed although the PR that added it was merged by the maintainer (→ ratified, **Ratified by:** that PR, its date and merger, the index cell); every ADR - **Status**: proposed line, header or phase, whose introducing PR (git blame) the maintainer merged (→ accepted, - **Accepted in**:, the index cell for the header); and every accepted ADR whose - **Tracking**: #N epic closed as completed with all sub-issues closed (→ - **Completed**:). A trigger from one of the hub's automation branches or by a bot decides nothing, a completion needs the maintainer to have closed the epic, and Status lines inside code fences are never touched. Each edit carries its trigger evidence and the key of the decision it records; everything else is listed as skipped with the reason, and a GitHub read that failed skips only its record (read_error). Records are read and written as bytes. guard is the merge decision, moved out of the workflow shell so it is tested: the PR is the job's own, its head is one commit on main's live tip, no hold label, every check on that SHA passed, it is mergeable, and the diff is exactly the plan it was built from with every trigger still holding. The module reads GitHub with GETs only and writes nothing remote: the ratify job in jev-number.yml pushes chore/jev-ratify, opens the PR and merges it with a merge commit on the guard's go (amendment ratification-records; docs/JEV.md).
Loop step specs¶
spec.py loads the specs under steps/: one <step>.yml plus its <step>.prompt.txt per agent step a loop workflow runs. The spec holds what has no other home — the hard-rules prompt, the caller-filled {{TOKEN}} inputs, the tool allowlist, the wall clock, the workspace contract and the § 13.6 risk tags — and references _data/fleet.yml for the model, the turn cap and the call-site dollar cap. The model must resolve to an exact id in ai_models.allowed; an alias is refused. steps check holds every literal the workflow still carries (--max-turns, --max-budget-usd, the cost step's budget-usd, timeout-minutes, --allowedTools, the artifact paths, no GitHub token in the agent step's effective env — workflow, job and step — its github_token input or an earlier $GITHUB_ENV export) equal to the resolved spec, requires the agent step's JEV_STEP_SHA256 to equal the spec pair's content hash, reports each declared workspace.exceptions gap (claude-code-action's own OIDC App token is outside the step's env, so it is declared there until the ADR 0002 follow-up closes it), and fails when the prompt orders a tool the allowlist does not grant. steps render prints the prompt byte-exact, rendered in one pass. Decision record: ADR 0002.
The headless executor¶
headless.py is the layer a local loop attempt runs headless Claude Code through (jev conflicts' tiers 1–2 still build their own argv; they move onto it before either tier is enabled). It is P1's first slice (ADR 0002): the executor is dash-gen's tools/dash ai run, extended rather than forked, and it imports this module lazily — this directory never imports dash-gen.
- Session isolation (
claude_flags):--restricted(no user, project or local settings file is read, so a target repo's hooks,envblock and permission rules never load),--safe-mode(no CLAUDE.md, memory, skills, plugins, mods or hooks),--toolslimited to the spec's tool families (each one in theGRANTABLE_TOOLSallowlist),--permission-mode dontAsk --permission-prompts none, the spec's allowlist verbatim plusDENY_TOOLS, an empty strict MCP config, no slash commands, no session persistence, theLOCAL_RUNNER_NOTEappended to the system prompt and a debug file. - The sandbox (
settings_doc): Seatbelt for Bash and its children,failIfUnavailable, no unsandboxed escape, no auto-approval,allowedDomains: []withstrictAllowlist, the home and mount roots read-fenced (the working directories re-opened), this account's Claude temp roots (the per-user temp directory'sclaude-<uid>included), the per-user temp directory (lifted for a work root inside it, whichlifted_private_readsputs in the posture template, so that work root never reuses a cached probe or canary) and aJEV_DOTENVfile read-denied,filesystem.disabled: falsepinned, and every credential variable and file denied; other paths outside home (/opt,/etc) stay readable, as the CLI's own fence leaves them.Posture("reduced")(no Bash at all; PR-B exposes it asloop run --posture reduced) is the only fallback. - The environment (
agent_env): built from scratch — PATH, HOME, the locale, offline git/npm/pip settings,TMPDIRandCLAUDE_CODE_TMPDIRinside the clone, and at most ONE Claude credential, chosen bychoose_authinCLAUDE_AUTH_ORDER(env → stored login → hub.env, the first present wins, no in-run fallback);pinned_authtakes exactly the source a caller already chose (the loop engine's--auth-source) or refuses.CLAUDE_CODE_SUBPROCESS_ENV_SCRUBis deliberately absent: on 2.1.308 it forces the permission mode todefault, overridingdontAsk. - The run (
stream,classify): a process group read line by line, a redacted and size-capped trace, a SIGINT-first wall clock that any ofFORWARDED_SIGNALS(INT, TERM, HUP, QUIT and the other asynchronous signals that would end ai-run: USR1, USR2, ALRM, VTALRM, PROF, XCPU) sent to ai-run starts too (not a HUP inherited ignored:honoured_signals, sonohupholds here and in the engine),held_signalsfor the bookkeeping after it, and an outcome in claude-cost's order —budget_hit, thentimeoutandinterrupted(a cancel is never read as a rejected credential),usage_limit,credential_rejected, then the rest — where a run that may have spent but left no figure is charged at its cap asestimated.init_problemsis the per-run posture check on a session's init record (exact toolset, all grantable,dontAsk, no MCP, no skill). The tee and the outcome detail are redacted before they are clipped, as the trace is. The sandbox runtime's own stderr lines ([SandboxDebug] [Sandbox macOS] Applied restrictions - network: …, read: …, write: …, one per wrapped command) are kept inInvocation.sandbox_lines(redacted,STDERR_KEEP_LINES) and written to the outcome file: on 2.1.308 the runtime prints that line only there and only withSRT_DEBUGset, whichagent_envsets (#560, decision 4c).posture_linesjoins them with the reduced debug log for every posture check. - Proof before trust (
preflight_parse,probe_isolation): $0 checks against the installed CLI, both inprobe_env— the run's own environment with no credential and a scratch, logged-outCLAUDE_CONFIG_DIR, refused if it is logged in. The preflight runs the real argv (run_prefix+claude_flags) with stdin/dev/nulland must get "Input must be provided", which proves every flag parses, and nothing it prints or logs may report the--settingsdocument skipped — a negative check, since an unwritten debug log passes it: the positiveflagSettingsproof is the probe's, and which settings keys the CLI honours only the canary proves. The probe runs in a fixture that plants a hook, anenvblock, an output style, an MCP server, a skill, a CLAUDE.md and an AGENTS.md (and a user settingsenvblock in its scratch config dir), three times: plain (the control, which must show the hook, the server, the output style, the skill and the userenvkey, or the detector is stale), isolated (which must passinit_problems, run no hook or server, apply no user env, and log the--settingsdocument's read fence — 2.1.308'sSandbox: blockReadsOutsideWorkingDirectories: … stays under an existing denyReadline naming one of the document's owndenyReadpaths, absent without--settingsor with an emptydenyRead— and "project memory is off"; the reduced posture's document has no sandbox and no such $0 proof, so its probe fails closed) and restricted (the isolation flags minus--safe-mode, whose default output style proves--restrictedalone ignored the project settings file). Memory content has no $0 check; it rests on--safe-modeand the canary.posture_template_shais the cache key a probe pass is stored under; a canary pass is also keyed by the credential variable the session carried (credential_exposure). Both are code here; running them against the real CLI is the maintainer's deploy step (§ 10.5), not a test. The canary's judge (judge_canary) was recalibrated on 2.1.308's trace (#560): the socket command spells its marker apart ('NET=' + 'open') and_printeddrops the source line a Python traceback quotes, so an echo is never a network success; eachcathas a python twin (CAT_TWINS), and acatthe permission layer refused underdontAskcounts only when the twin reached Seatbelt and was refused there; the planted files carry neutral names (fixture.txt), since a model asked to read asecretmay decline on its own and a skipped read is inconclusive; and the session must show the--settingsread-fence line (settings_fence_problems) as well as the per-command line, both failing closed.
tools/dash ai run --call-site repo-scout.yml:scout --stream --timeout 1800 --isolate \
--cwd <clone> --prompt-file <prompt.txt> --trace <trace.jsonl> --result-file <result.json> \
--outcome-file <outcome.json> --usage-limit skip -- <headless.claude_flags(…)>
The loop runner¶
loop.py is capability two's runner (P1's second slice, ADR 0002; operator doc docs/JEV.md). It has no loop-specific code: a step spec's optional local: block names the adapter, the kill switch, and the planner and publish argv templates, and steps check holds the switch equal to the workflow's gating if:. Every verb that could spend or file (run, run --apply, publish --apply, the doctor --live canary), manual or scheduled, first honours the fleet-wide pause: _data/fleet.yml switches: (constitution § 17; the global level, the group and entry of the step's workflow, the hub's and each item's switches.repos level, the most restrictive winning), then the hub's vars.FLEET_AGENTS_PAUSED, read only; a paused run exits 5 before any clone, claude process or ledger row, while plan and --rehearse still run. Per item it runs the gates, the host checks, the planner (the same tools/dash-gen scout CI runs, with the prompt held byte-equal to the spec's render), tier 0 and classify at $0, then a workspace — a hardened clone under ~/.cache/jev/work/<run_id>/, outside the hub, whose .git configuration the engine's own git never reads once an agent could have touched it (status and checkout run on an engine-held copy of the fresh GIT_DIR's config, hooks, index and attributes, sharing only the object store through objects/info/alternates, with no global or system config, and refuse a tampered clone; a tampered clone is destroyed even with --keep-workspace) — and prepares the prompt, the --settings document, the isolation flags and the exact tools/dash-gen ai-run command an attempt runs.
run --rehearse stops before the model call and proves the planned command with ai-run --dry-run on an empty stdin and without its prompt file, at $0. A live run makes one attempt per item through tools/dash-gen ai-run --isolate (ledgered, capped at the step's budget.call_sites entry and passed that exact cap, pinned to the credential method and source the host check chose, held to the month's budget.loops ceiling by ledger.BudgetState and, for an item in an active expedite sprint's repositories, to that sprint's ceiling and switch (sprints.py; a tripped breaker is a sprint-stop event in run.json), re-read under a lock beside the AI ledger just before the model call, after tier 0), then checks the session BEFORE reading anything it left — the clone untampered (else the item fails, exit 1, destroyed with no git run in it), then the credential the outcome names and the init record the probe proved, no user settings env applied, the --settings document's own read-fence line and no skipped document, and, whenever Bash executed, the per-command sandbox line — from the debug log, or from the runtime's stderr lines the outcome carries (2.1.308 under SRT_DEBUG) — with both its read and its write fence (any gap: outputs destroyed unread, exit 4) — then harvests, validates and writes the dry-run preview (publish-plan.md, bodies/). --apply, typed by the maintainer, files that preview in the same run after a live recheck, and the filer is held to it (--reviewed-bodies: no body that is not byte-identical to a reviewed one, nothing without its own open-issue dedupe); loop publish <run_id> --apply files a reviewed earlier one, once. A usage limit stops the queue's model calls (exit 0, a warning; a $0 tier-0 reuse still runs), a rejected credential stops the run (exit 3), a budget hit is discarded, and a run with no result is charged at the cap — durably, in <ledger>.loops-unledgered.jsonl, when ai-run left no ledger row, so the next run's ceiling counts it. doctor --live is the one-time canary (≤ $0.10), implemented here and run only with the maintainer's approval; canary_flags appends the probe grants (CANARY_GRANTS: cat, python3) a narrower step allowlist lacks, so the probes reach Seatbelt rather than the permission layer, and the verdict records them. Records go to the gitignored .fleet/runs/<run_id>/ (0700: run.json, attempts.jsonl, summary.md, plan/, items/<item dir>/); the newest 30 runs are kept and older run directories are pruned at the end of each run; JEV_RUNS_DIR and JEV_WORK_ROOT override the two roots. Exit codes: 0 clean, 1 attention (a failed item, or an unexpected error, recorded failed before the traceback), 2 usage, a refused option (--scheduled on a step with no switch included), a missing or malformed --plan-file, a reused --run-id or a missing run, 3 credential, 4 host safety (including a work root inside the hub or a Claude temp root, for doctor and run alike, checked before anything runs), 5 paused (§ 17's switch map or vars.FLEET_AGENTS_PAUSED), 127 no claude CLI, 130 interrupted (Ctrl-C, SIGTERM or SIGHUP, unless nohup ignores it; the engine passes it on to ai-run and waits for its outcome and ledger row, then records the in-flight item); loop plan reports host problems without exiting on them (a work root inside the hub is one, and the CLI and credential are still read past it). For a local.harvest: patch step (the doctor, P3) the agent's edits are the output: the clone may carry its own branch and commits (those .git entries are outside the tamper baseline; config, hooks and the object redirects are not), the engine diffs the clone against the fresh HEAD with its own git into outputs/changes.patch, and the adapter pairs it with the filing the agent asked gh for. The planner's argv may run only a read-only dash-gen subcommand (spec.PLANNER_COMMANDS) and the publish argv only a filer (spec.PUBLISH_COMMANDS, which also pins the filer's apply flag, so a spec cannot rename it), neither carrying --apply, the spec's apply flag, the filer's reviewed flag (spec.PUBLISH_REVIEWED_FLAGS) or any prefix argparse would read as either; the engine alone adds the apply and reviewed flags, under --apply.
The context pack¶
context.py is the loop runner's context pack, engine half (#486; operator doc docs/JEV.md). A local attempt's agent is sealed, so before an attempt the host assembles a read-only, capped, redacted, freshness-stamped context.md (and its context.json twin, both 0600, in the item's run directory) from the planes — tools/dash-gen context (fleet-context/v1: the lake, the code index, the telemetry), reached through ctx.dash_gen, never imported — plus a history section of this loop's earlier agent attempts on the item (rehearsals, tier-0 skips and the engine's blocks are left out). render drops the controls, the invisible format characters and every other default-ignorable code point (the whole tag block, U+E0000–E0FFF, included) and the basic variation selectors' hidden runs (_CTRL, the planes' rule), puts every row inside a fenced block no row can close and cuts rows, lowest priority first, to the 16,000-character cap; redact masks secrets, the home, the work root and the host name in both files, field by field (redact_obj, which keeps the document's own words, SCHEMA_WORDS, as the planes keep fleet_context.DOC_WORDS) and then line by line (redact_lines, which keeps the engine's own fences, section headings and title prefix, and masks only the values in its header sentences and provenance prefixes, so a host named text, Code or never still gets a whole pack and an intact data-not-instructions rule), and a pack that loses the structure the engine wrote (structure_problem, redaction_problem) keeps only its header. Modes: auto notes an unavailable plane, require fails the item before any spend (Pack.blocked), off is a CI-identical run. pointer() is the fixed paragraph the engine appends to the clone's copy of the brief. loop run builds the pack per item after tier 0, classify and the clone, before the budget lock (offline: into the item directory only), with the adapter's context_request (scout: queries from its brief), the clone's realpath as its target_dir (sent as --target-dir, checked by check_target_dir and again by the planes, so the target's code hits are checked against the files the agent reads; none offline) and the spec's local.context (mode, file, providers, cap, deadline, window), and places it as <brief_dir>/<file> beside the brief, the clone's brief written once as the plan's bytes plus the pointer; the plan's brief, and so tier 0's reuse key, never changes. Both are new files under directories lstat-ed as real ones (workspace.place_bytes: O_EXCL, no link followed). --context auto|off|require overrides the spec for one run (off: nothing built or placed, the CI-identical attempt; require: an unavailable plane fails the item as context-blocked before any spend); --refresh-context runs the lake's local session import (dash-gen lake sessions --claude-dir=…, from $CLAUDE_CONFIG_DIR/projects or ~/.claude/projects, never lake sync) once before the first pack, never with --scheduled. The item's run.json entry, every later attempt row (context_sha256, context_status), argv.json (context_sha256, prompt_sha256 unchanged) and summary.md record it; loop plan previews each item's statuses and ages, and loop doctor shows the hub's planes (an unavailable one with its reason, a stale one with its refresh command, the code index as up when its probe search answers) without changing its exit code.
Harness refinement¶
Capability three (docs/HARNESS-REFINEMENT.md, ADR 0004): the Harness² method on the hub's loops, at $0 in this release. surface.py reads a repository's harness as Harness²'s eight components (the context-file chain always on and capped, settings.json permissions and hooks, agents, skills and commands, hook scripts, instructions, .mcp.json) and validates it with the rules the production harnesses converge on: a skill without description frontmatter or with a name that is not its directory is dropped silently, a hooks block of the wrong shape never fires, a script a component names must exist, injection phrasing in a context file is flagged. library.py is the experience library under _data/harness_library/<loop>/<domain>/<entry>/ (experience.yml + harness.diff), written on a branch only and held to its schema and to the context pack's redaction; context.py's library provider puts a domain's lessons beside the brief of every local attempt. refine.py is the step itself: the schedule in both modes with its R = 4k / P = 3k identity and the ledger that asserts it, the plan with the ceiling from the step's own cap judged against budget.loops, the evidence tree built from real .fleet/runs attempts (every file redacted, the hard rules read-only, the tunable half the tree a candidate edits), and the five missions under missions/ rendered one-pass. reflect.py is the one stage that calls a model today, the incident reflector (refine reflect, ADR 0004 P1 part one): from the lake's review of local sessions and CI agent runs, the trip wires, the local runs and the library it builds a redacted evidence tree, runs ONE Read/Glob/Grep session through dash-gen ai-run --isolate under the loop runner's posture, budget lock and ledger, validates every candidate lesson itself and previews; a person files the preview as a draft PR (publish <stamp> --apply), and a --scheduled run never does. The Propose–Probe–Compose sessions are P1's next part.
The merge driver¶
.gitattributes marks every generated file merge=jev-regen. Git cannot install a merge driver from .gitattributes (by design: a repository must not be able to run a program on your machine just because you cloned it), so each clone opts in once:
git config merge.jev-regen.name "keep ours, regenerate"
git config merge.jev-regen.driver "tools/jev/merge-regen.sh %O %A %B %P"
GitHub ignores this driver. Its mergeability check runs its own merge, so a driver only helps a local clone. That is why CATALOG.md and docs/README.md are also marked jev-main-only: pull requests do not edit them at all — .github/workflows/jev-number.yml regenerates and commits them on main after every push, and drift-check.yml fails a pull request that edits one:
python3 -m tools.jev generated list # main-only files and generated spans
python3 -m tools.jev generated guard --base origin/main # what CI runs on a pull request
python3 -m tools.jev generated regen # what the post-merge job runs on main
If the guard fails your branch: git checkout origin/main -- CATALOG.md docs/README.md, commit, and change the generator's source instead. Generated spans in hand-written files (PRD feature block, README AUTO:projects, the docs/DASH.md CLI reference) are regenerated by the same job; on a pull request their drift checks only warn (JEV_SPANS_ADVISORY=1). Option (a), gitignoring the files and building them in CI, was rejected because they are linked and browsed on GitHub. Full rationale: docs/JEV.md. For a main-only file the driver takes main's copy (theirs, when main is merged into your branch).
With it configured, a conflict in any other generated file resolves to ours, and the path is appended to .git/jev-regen-pending — your to-do list for the regeneration that actually decides the content. Without it, git falls back to its default text merge: safe, but it gives you back the hand-merge the driver exists to avoid. Either way a wrong generated file never reaches main: main-only files and spans are rewritten there after merge, and every other generated file still fails CI on drift.
merge=union is set on two append-only files — docs/amendments/README.md (the index table) and _data/jev_resolutions.yml (the ledger's record list). Union takes both sides of a conflicting hunk, in order, and does not deduplicate, so it is correct only where a repeated or reordered line is harmless and nothing is read positionally. Do not extend it to a file with front matter, a header block, or a list whose order means something.
The tier ladder¶
Tiers are decided by classify.py from the trial merge alone — conflicted files, their kinds, hunk and line counts, and how many attempts have already failed. The same pull request always triages the same way, and the reason is printable without a transcript.
| Tier | Cost | What it handles | How |
|---|---|---|---|
| 0 | $0, no model | Every conflicted file is generated, a fragment, union-safe, a pure append to an append_paths list (_data/roadmap.yml), or an id collision |
regenerate · main's copy (main-only, or compiled from fragments) · union · append (main's entries, then the branch's; refused when an entry was edited, the YAML breaks or both sides claim one id) — numbering stays on main |
| 1 | ≤ $0.25/attempt, Haiku 4.5 | ≤ 3 files, ≤ 40 conflicted lines, nothing under .github/workflows/, no auth/secret, migration or lockfile |
a capped headless claude -p |
| 2 | ≤ $1.50/attempt, Sonnet | ≤ 15 files or ≤ 400 conflicted lines, or tier 1 failed | the same, with a stronger model |
| 3 | $0 | Anything larger; binary or lockfile; a workflow/secret semantic conflict; a squash-only repo; two failed attempts; the monthly cap | label jev:needs-human + the triage report as a comment |
In an active expedite sprint's repositories (sprints.py, _data/fleet.yml budget.sprints) the ladder is the same with two additions: tiers 1 and 2 run only while the sprint's ceiling can absorb the tier's full cap on top of what the sprint has spent, and past it the conflict goes to jev:needs-human as at the monthly cap; and on a --scheduled run the sprint's switch (vars.EXPEDITE_SPRINT_ENABLED = 'false') leaves the sprint's pull requests alone, tier 0 included.
Every tier resolves the same way: merge the base into the head with a merge commit, then validate by running whichever of the repository's own checks it carries (check-drift.sh, schema_lint.py, governance_lint.py, docs_index.py --check, run-all-tests.sh) plus a clean git diff --check and a sweep for leftover conflict markers. A failed validation is discarded — git merge --abort — and the next tier starts from the same clean trial merge. Nothing half-resolved is ever pushed.
What JEV will not do¶
- Never merges a pull request.
common.assert_no_admin, which everyghcall JEV makes itself goes through, is an allowlist of thegh <noun> <verb>commands JEV issues, named by the argv's first two words:gh pr merge, any--admin, an issue close, a secret or variable write or delete (theremovealias included), arepo sync, a flag before the verb (gh pr -R o/r merge) and any unlisted command are refused, and so is everygh apicall but a GET or an inline GraphQL query (no mutation, no--inputor@filebody; a shorthand bundle such as-iXPUTis read as gh reads it).common.assert_safe_gitis an allowlist of the subcommands, global options and-ckeys JEV uses (no alias, autocorrect,send-pack,--config-env,remote.*/push.*/alias.*key or override of the hook, fsmonitor and pager settings the wrapper pins, and throughenvonly theGIT_*names JEV hands git, withHOMEandXDG_CONFIG_HOMEmoved only when the global config is/dev/null), holdsclone(andgh repo clone's passthrough),init,fetch,remoteandgit configwrites to the options and keys JEV uses, so no call plants a delete refspec, mirror flag or include, and refuses a force-push, a mirror push and a remote ref delete in any flag spelling (bundled short flags, long-option prefixes); a push names an explicit<src>:<dst>refspec, and every push and fetch names git's own pack program, so config never steers it, in everycommon.gitcall. The loop runner's planner and filer aretools/dash-gensubprocesses outside these guards, bounded by the spec's pinned argv and the § 13.6 gate. - Never force-pushes and never rebases. The pull request's history belongs to whoever opened it; a force-push would detach review comments from their commits.
- Never touches settings, secrets or branch protection.
- Only same-repo branches, only listed authors. A fork's branch and a human collaborator's branch are tier 3 by policy (
jev.allowed_authors), because JEV pushes to the head branch. - Runs only the tiers it is given.
jev.auto_tiers(today[tier0]) — anything above is labelledjev:needs-humanrather than sent to a model. - Stops at the money.
budget.jev.monthly_usdis the ceiling; a scheduled run stops atscheduled_stop_pctof it so a human's manual run still has budget on the 28th. A ceiling or tier cap that is not a finite number above 0, a stop outside 1..100, and a ledgercost_usdthat is not a finite figure of 0 or more are refused, never read as room. An expedite sprint's ceiling sits inside it and never raises it (constitution § 27.4).
Cost¶
Each attempt is appended to _data/jev_resolutions.yml with its tier, model, outcome and cost_usd, and whether that figure was reported by the CLI (total_cost_usd) or estimated — the ledger reports the estimated share separately rather than presenting a measured half as a whole (the lesson of HUB-032 / NFR10). The same records carry call_site: jev-conflicts so the fleet's wider Claude accounting can read them.
Swapping the model is a one-line change in _data/fleet.yml jev.tiers.<tier>.model; docs/JEV.md lists the alternatives that fit each tier's envelope, including local inference.
Tests¶
python3 tools/test_jev_number.py # the compiler: assignment, slug refs, consumption, the lint
python3 tools/test_jev_ratify.py # ratify: triggers, skips, accept/complete, bytes, apply, check-diff, select, every guard branch, the PR body, the job
python3 tools/test_jev_classify.py # the tier ladder and the file-kind rules
python3 tools/test_jev_adapter_fleet_pulse_doctor.py # the doctor's adapter (P3): the planner's plan mode, the patch + filing document, the filer
python3 tools/test_jev_adapter_repo_evolution_evolve.py # the evolution agent's adapter (P3): the planner offline, the patch + report document, publish-flagged, the filer
python3 tools/test_jev_conflicts.py # eligibility, validation, the no-merge/no-admin guard
python3 tools/test_jev_ledger.py # the ledger and the monthly cap
python3 tools/test_jev_sprints.py # the expedite sprint's ceiling: load refusals, WIP 1, the gate, the switch, spend from every ledger
python3 tools/test_jev_generated.py # the main-only guard and the tier-0 main-only resolution
python3 tools/test_jev_spec.py # step specs: byte identity, parity, the #89 lint, loader refusals
python3 tools/test_jev_headless.py # the isolation argv, sandbox settings, agent env, auth choice, classifier, probes
python3 tools/test_jev_workspace.py # the hardened clone, the tamper baseline, the no-follow harvest
python3 tools/test_jev_adapter_repo_scout.py # the scout adapter and the engine's source guard
python3 tools/test_jev_loop.py # the runner end to end against a stub claude and gh: every verb, live attempts, the gate, the context pack
python3 tools/test_jev_context.py # the context pack: history, gather, the fenced render and its cap, redaction, modes
python3 tools/test_jev_surface.py # the harness surface: every rule on fixtures, the hub's own surface clean, the CLI
python3 tools/test_jev_library.py # the experience library: round trip, refusals, leaks, check, the registry domain, the pack's section
python3 tools/test_jev_refine.py # the refinement step: the schedule and its identity, the ledger, the config, the missions, the plan, the evidence tree
python3 tools/test_jev_reflect.py # the incident reflector: gather, the drops, the budget stop, rehearse, the canary and a live run through ai-run, --apply against a bare origin, the schedule's job
They are standalone scripts — no pytest, no network, no gh — and tools/run-all-tests.sh and .github/workflows/python-tests.yml pick them up automatically.