Skip to main content

the TRUGS runner records and checks work against a fixed graph.

License: Apache 2.0 check run

An agent can fail by leaving the declared path or by taking a permitted step that is wrong. A rail is a TRUG that a person orders in advance, declaring the steps, permissions and evidence needed to move on. The TRUGS runner validates and captures the rail once at the start and never lets a run change it. Gates admit evidence, not claims. A deterministic oracle decides completion by checking conditions written down in advance; it never judges the quality of the work.

Install

You need Python 3.11 or later. The project's own checks run on Linux.

To use the runner as a library, install the published package:

python3 -m pip install trugs-runner

The package installs two Python modules: executable_trug, the engine and its command line, which you run as python3 -m executable_trug, and trugs_runner, the library for building rails in Python. It also installs jsonschema and trugs-tools.

The walkthrough below uses the examples in this repository, which are not part of the package. To follow it, clone the repository and install it into a new virtual environment:

git clone https://github.com/TRUGS-LLC/TRUGS-RUNNER.git
cd TRUGS-RUNNER
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -e .
python3 -m executable_trug --help

The last command prints the command's help, beginning usage: executable-trug.

Run it

export PYTHONPATH=src
G=examples/letter-classification/letter-classification.trug.json
W="$PWD/examples/letter-classification/workers/deterministic_worker.py"

python3 -m executable_trug pin $G                      # record what each program is
python3 examples/letter-classification/driver.py --worker-command "python3 $W" \
  --run-dir /tmp/run --word Strawberry --head-file letter-head.json

The worker command uses an absolute path because capabilities run from the captured snapshot directory. External workers are explicit driver adapter resources, separate from the declared definition files.

It classifies each character of the word as R or not-R, one agent call per character, and exits 0.

A run that stops part way — the driver killed, the machine restarted — retains its committed record. The head file is saved only when the driver returns, so after an interruption it may be absent or stale. First stop and wait for the old driver and all capability/worker processes and their descendants; killing the driver alone does not establish that they stopped. After a restart, confirm none survived or were restarted. Keep other drivers and external writers stopped during recovery. --processes-stopped declares your confirmation; it does not stop processes for you.

Recover the current head by verifying the record without executing an action, then continue with that exact external head:

python3 examples/letter-classification/driver.py --run-dir /tmp/run --recover-head --processes-stopped --head-file letter-head.json
python3 examples/letter-classification/driver.py --worker-command "python3 $W" --run-dir /tmp/run --expected-head letter-head.json --head-file letter-head.json --processes-stopped

Recovery requires --head-file and --processes-stopped, and cannot be combined with --expected-head or person input. Invalid record/content is refused. Continue still refuses a stale head; it never refreshes the supplied head automatically.

An action whose observation is committed is routed without invoking it again. An unsafe action with a committed intent but no accepted observation reports invocation_unresolved (exit 2), preserving its effect and state rather than repeating it. Recover the newly recorded halt head using the first command again; continuation at that head returns the same halt (exit 21). An operator must separately choose retry or abandon through the public continuation surface; this driver never chooses a recovery resolution automatically.

The part that matters

Run it again with a worker that always answers record_r:

python3 examples/letter-classification/driver.py --worker-command "python3 $W --always-record-r" \
  --run-dir /tmp/wrong --word Strawberry

Same number of steps. Every receipt written. Every gate passed. Exit 21 — the oracle caught it.

That split is the design. The per-step gate asks only did the required thing happen?, which is cheap enough to run every step. Whether the conditions the task stated now hold is a separate question, answered once at the end by something exact.

Note what the oracle is never asked. It does not judge whether the work was good — correctness is a judgment about intent, and anything that forms judgments is an opinion rather than an instrument. It checks completion: conditions written down in advance. And it only ever checks conditions it can decide without running what the agent produced, because an artifact that has to be run to be judged authors every input to the verdict. This oracle reads receipts; it executes nothing the agent wrote. See CONCEPTS.md.

Scope

This software does not include self-modifying TRUGS: graphs that change their own structure while they run.

Honest limits

The TRUGS runner offers and records; it does not confine.

  • It is not a security boundary, and it does not contain the worker. A worker runs as an ordinary process under the host's identity, launched by a capability. It is kept from the oracle, the receipts and the result programs only by being given no path to them — not by isolation. A worker able to look can find them, and anything it does before stating its choice has happened whether or not the rail then refuses the choice. A deployment that runs an untrusted worker must contain it itself — in a VM, for example; a locked-down system is a different layer from this one. The rail is a step up from instructions a model may ignore, not a sandbox.
  • It measures no model. The bundled worker decides by comparison, not judgment. Nothing measured against it says anything about an AI model.
  • The graph never rewrites itself. It is fixed for the life of a run. See Scope.
  • The run directory is trusted. record.read_record() with its defaults, rail.read_state() and cli.inspect() verify the complete canonical entry chain and referenced content; inspection reports content loss separately. A retained earlier head supplied to complete verification anchors the verified prefix at that sequence. read_record(verify_payloads=False) verifies the chain only. Ordinary reads during start and continue resolve the position, input, state, pending links and gate operands needed for the current operation. They check format support and the supplied latest head, validate the current protocol, state and gates, and validate new entries before publication. They do not rehash earlier entries or content and report chain_integrity: null. On this path a retained head establishes agreement with the stored latest-head tuple, without establishing prefix integrity. Someone able to replace all bytes and the caller's retained head can still rewrite the history consistently. The chain does not authenticate who acted. See Record §5.
  • The actor is declared, not authenticated. Every invocation is checked against the root's actor; the rail cannot tell which process is calling it. Modal edges naming any other actor — the worker's SHALL_NOT edges included — are not checked at run time, because no other actor makes requests of the rail.
  • Definitions are captured at start. Start validates and captures the rail. Before each step, the engine compares the captured files with their recorded fingerprints and stops with a report if they differ. Installed edits affect new runs. Snapshot storage is trusted local storage, not a confinement mechanism for workers.
  • A refusal never selects a route. A permission refusal preserves the position; other ordinary execution refusals halt the run for a person. Installed edits cannot change the definitions used by that run.
  • Stops retain their reason, cursor and unresolved intent. When recovery is offered, continue accepts an explicit retry or abandon choice with the retained head and process confirmation.
  • Authoring run stops at a person pause. It carries returned heads through start/continue and reports the pause for an explicit person submission.
  • Model content has three admitted paths at this release. It proceeds only to a person inside the declared discussion form, by an exact whole-result check against independently bound input, or to unverified.
  • The pattern rails keep that boundary. The router and bounded tool loop use program workers; the evaluator-optimizer uses a person to review model drafts. They do not show a model evaluating a model, gateway tool calling, child rails or fan-out.
  • Compliance uses the pinned checker. make check includes trug compliance against the stored baseline; use the pinned checking environment to compare results.

Pattern rails

See the examples index for all four examples and four pattern rails.

  • Approve and record shows a person's exact acceptance governing a recording effect, with a custom node beside library nodes.
  • Router checks a program worker's proposed route against captured choices before invoking its declared tool.
  • Bounded tool loop alternates a program worker and a tool up to a declared return bound, then asks a person.
  • Evaluator-optimizer binds a person's recorded feedback into the next model draft and reaches a summary and person pause at the round limit.

Reference

See COMMANDS.md for authoring, gateway, record and maintenance operations. The command blocks below are kept here as executable reference examples.

Authoring and execution reference

Run from an empty working directory with the engine installed, or with an absolute PYTHONPATH pointing to this checkout's src; all commands in this block exit 0.

python3 -m executable_trug create draft
python3 -m executable_trug pin draft/rail.json
python3 -m executable_trug check draft/rail.json
python3 -m executable_trug test draft/rail.json --samples draft/samples.json > tests.json
python3 -m executable_trug run draft/rail.json --input-file draft/input.json --run-dir auto-run --snapshot-store "$PWD/snapshots" > pause.json
python3 -m executable_trug start draft/rail.json --input-file draft/input.json --run-dir run --snapshot-store "$PWD/snapshots" > start.json
python3 -c 'import json; json.dump(json.load(open("start.json"))["head"], open("head.json", "w"))'
python3 -m executable_trug continue --run-dir run --expected-head head.json > work.json
python3 -c 'import json; json.dump(json.load(open("work.json"))["head"], open("head.json", "w"))'
python3 -m executable_trug continue --run-dir run --expected-head head.json > person.json
python3 -c 'import json; json.dump(json.load(open("person.json"))["head"], open("head.json", "w"))'
python3 -m executable_trug continue --run-dir run --expected-head head.json --person-input-file draft/accept.json > terminal.json

Model gateway reference

Set GATEWAY_CONFIG to the gateway configuration's absolute path; start this in a separate terminal and wait for its ready event.

python3 -m executable_trug.gateway --config "$GATEWAY_CONFIG"

For a model rail, set GRAPH, INPUT and SAMPLES to its graph, JSON input and samples, SNAPSHOTS to its snapshot store, and GATEWAY_SOCKET to the configured control socket. These are alternative operations: the first creates a fresh run; the last uses an existing run and its complete retained head in head.json.

python3 -m executable_trug run "$GRAPH" --input-file "$INPUT" --run-dir gateway-run --snapshot-store "$SNAPSHOTS" --gateway-socket "$GATEWAY_SOCKET" > gateway-result.json
python3 -m executable_trug test "$GRAPH" --samples "$SAMPLES" --gateway-socket "$GATEWAY_SOCKET" > gateway-tests.json
python3 -m executable_trug continue --run-dir run --expected-head head.json --gateway-socket "$GATEWAY_SOCKET" > gateway-step.json

Gateway checker reference

The offline checker reads retained cases; replace the uppercase placeholders with your case and output paths, using new output and log paths.

python3 scripts/check-model-gateway.py verify OUTPUT/ordinary --expectations OUTPUT/ordinary/expectations.json
python3 scripts/check-model-gateway.py replay OUTPUT
python3 scripts/check-model-gateway.py capture CASE
python3 scripts/check-model-gateway.py bundle OUTPUT > OFFLINE.log
python3 scripts/check-model-gateway.py extract --log OFFLINE.log --output EXTRACTED

Live checks require an explicit live command and a separately started operator gateway; replace the socket, model and output placeholders with your configuration. These calls use a provider and are separate from offline verification.

python3 scripts/check-model-gateway.py live --provider sol --gateway-socket /operator/runtime/control.sock --model MODEL --output OUTPUT
python3 scripts/check-model-gateway.py live --provider local-vllm --gateway-socket /operator/runtime/control.sock --model MODEL --output OUTPUT

Local maintenance reference

These commands inspect the authoring walkthrough's paused auto-run and erase its content after explicit process and external-writer quiescence confirmations. The confirmation arguments declare that the processes have stopped; they do not stop them.

python3 -c 'import json; from executable_trug.maintenance import inspect_record; json.dump(inspect_record("auto-run"), open("inspection.json", "w"))'
python3 -c 'import json; from executable_trug.maintenance import erase; head = json.load(open("pause.json"))["head"]; json.dump(erase("auto-run", head, processes_stopped=True, external_writers_stopped=True), open("erased.json", "w"))'

What just happened

The graph is letter-classification.trug.json. For each character it ran this cycle:

  1. a capability read the next character
  2. a worker was asked for one choice — record_r or record_not_r
  3. the runtime ran the program that choice named, which wrote a receipt
  4. a gate confirmed the receipt existed
  5. the index advanced, and the cycle repeated

When the word ran out, a deterministic oracle checked every receipt against the rule the task stated, and decided whether the run had met it.

A separately configured worker can be supplied with --worker-command. The worker needs no tools and no file access. It answers with one line.

Make your own

To compose library and custom nodes on one Python page, see Author a rail.

See examples/letter-classification/README.md for the file layout and the steps. In short: author a graph using TRUGS nouns and prepositions, give every node its complete list of outcomes, name in the root's actor property the actor that drives the run and give it a MAY edge to each capability it may have invoked, install the programs the graph names, pin them, and write an oracle.

If you cannot write a deterministic oracle for a step, the specifics have not been stated precisely enough yet — a fact about the specification, not about the step. If you can only write one by running what the agent produced, see CONCEPTS.md before you rely on its verdict.

Verify

The pinned container checks use the locked image and dependency files in tests/container/. Preparation fetches prerequisites; build and checks run offline. Run the pinned checks below:

scripts/test-container prepare --python 3.11
scripts/test-container build --python 3.11
scripts/test-container run --python 3.11 -- make check
scripts/test-container prepare --python 3.14
scripts/test-container build --python 3.14
scripts/test-container run --python 3.14 -- make check

Inside the prepared environment, make check runs format, lint, tests, graph validation and compliance with the same pinned tools as CI. The examples use that environment with PYTHONPATH=src.

Choosing from a second TRUG

An executable TRUG can name another TRUG as pinned data and gate a worker's choice against it: a DATA node with a path and digest, and a SUBJECT_TO edge carrying the state key it constrains and what an admissible node is — the property it must carry (requires) and, optionally, its node type. A value proposed for that key must be the id of such a node in the data TRUG, or the rail refuses it, commits nothing of it, and halts the run. Changing the data TRUG makes the graph inadmissible until re-pinned. examples/faq-answer/ shows one such choice — a question answered from an FAQ TRUG. A gate fails closed: admission refuses a malformed gate, or any other edge to DATA, rather than ignoring it.

What the rail refuses, and what it does not control

The rail constrains what the rail does with an actor's request and a worker's choice. It does not constrain what a worker program does while it runs.

Refused before anything is invoked — nothing runs:

  • an invocation the graph does not permit the programme's actor — a SHALL_NOT edge, or no SHALL or MAY edge at all. The programme position stays unchanged while the refusal is recorded;
  • an invocation the step budget leaves no room for. The run halts.

Refused after the capability ran, before an observation — a result that fails the step protocol or state admission, such as an undeclared state key. No state patch or observation from that result is committed, and the cursor does not move. The intent and refusal evidence remain, and the run halts at that node.

A route-gate halt happens after the observation and admitted state have been committed. If the gate cannot select an admitted route, the run keeps that observation and state and records a halt without a transition or cursor move. The capability, and any worker it ran, have already acted in either case; effects outside the rail are not undone. See Actions §12.

Execution refusals report a reason and retained head; recorded refusals append to record/entries/. Parser and keyword errors report before starting work. State changes refused before an observation and refused cursor moves stay uncommitted; referenced diagnostics and refusal evidence remain available in private content/objects/.

Each invocation is two-phase: an intent naming the node, capability and attempt is committed before the capability runs, and the observation after it. If a run stops between the two, whether the capability acted is unknown, so the rail never invokes it again: continue reports the unresolved invocation for a person. Safe-to-repeat actions use the retained request; retry and abandon are explicit continuation choices.

Admission also refuses a capability or data path that is absolute or resolves outside the install root, through .. or a symbolic link, and a graph in which one actor holds conflicting modals (SHALL_NOT and MAY, say) toward the same capability.

More

A TRUG is defined by the TRUGS specification; start with GETTING_STARTED.md. The validator and language come from trugs-tools. The design record names the eleven specifications.

CONCEPTS.md — what makes a graph an executable TRUG, the failure modes it addresses, and why the oracle is deterministic.

examples/faq-answer/ — one executable TRUG choosing an answer from a pinned FAQ TRUG, with the rail refusing a choice the FAQ does not hold.

examples/development-orchestration/ — seven independently runnable development-role TRUGs composed into one provider-neutral, fixture-only lifecycle that pauses for a human decision.

License

Apache 2.0. Copyright 2026 TRUGS LLC — see LICENSE and NOTICE.

Metadata

Release files for trugs-runner 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trugs-runner 0.1.1
File Size Uploaded Provenance Actions
trugs_runner-0.1.1.tar.gz 448.0 kB Without provenance Details for trugs_runner-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trugs-runner 0.1.1
File Interpreter ABI Platform Actions
trugs_runner-0.1.1-py3-none-any.whl Python 3 none any Details for trugs_runner-0.1.1-py3-none-any.whl

Total release size: 637.4 kB

Release files / trugs_runner-0.1.1.tar.gz

Download URL trugs_runner-0.1.1.tar.gz
Size 448.0 kB
Tags Source
SHA-256 checksum
How to use checksums
92aa74b5697a626c347ac9f29ba9802efb564f981c64fd2b14826b803a1947cd
BLAKE2b-256 checksum
How to use checksums
e393e8d2da3f4f212aa24dbc6a737d060763508ed2f30a94e61fa694863c008b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / trugs_runner-0.1.1-py3-none-any.whl

Download URL trugs_runner-0.1.1-py3-none-any.whl
Size 189.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16c4b84c7bb4ee607cd0396193471f5d960568e9978cefbab22523e2e3c6df6c
BLAKE2b-256 checksum
How to use checksums
319bef6e80a50c0f981155c9bacf639bd734a14e22135c9925c86a5d69a56bec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for trugs-runner 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page