Repository guide
What is in each folder, and how to work on the code.
Layout
causal-repair/
├── causalrepair/ the library (this is what `pip install` gives you)
│ ├── guard.py Guard and Session: check each call, pick an option, record it
│ ├── policy.py Policy, Rule and the built-in rules
│ ├── interventions.py the options, their distances, the menu and the nearest repair
│ ├── types.py ToolCall, Violation, Trace, Decision, ToolResult, Veto
│ ├── learn.py Artifact: fit a learned guard from collect logs
│ ├── certify.py certified plans: FiniteModel, Evidence, Plan, certify, BudgetPlanner
│ └── adapters.py helpers for OpenAI-style and Anthropic messages
├── examples/ five programs that run offline (see Examples)
├── benchmark/ the paper's experiments on public benchmarks (see Run the benchmarks)
│ ├── tau2/ τ²-bench: tasks, policy, episode loop, timeouts, runner, replay
│ ├── dtap/ DecodingTrust-Agent: tasks, policies, simulator clients, runner, replay
│ ├── agentdojo/ AgentDojo and AgentDyn: tasks, trusted plans, pipeline, runner, replay
│ ├── common/ shared code: paths, guard settings, records, model endpoints, judge
│ ├── fetch.py download the benchmarks at pinned versions
│ ├── fit.py fit and freeze a learned guard
│ └── summarize.py harm and safe completion for each guard setting
├── tests/ tests of the library and of the benchmark code
├── docs/ this website, the figures of the README, and the logo
├── pyproject.toml package settings
└── README.md a short overview
The library in one picture
- Your code calls the session (
session.tools,run,call, orreview). Session.reviewasks thePolicyfor the broken rules.interventions.menulists the allowed options, and the mode (or a fittedArtifact) picks one.- If the pick runs the call, the session runs it and records the result in the
Trace. - The decision is added to
session.records.session.finishturns the records into one episode for the log.
Work on the code
git clone https://github.com/vicky157/causal-repair.git
cd causal-repair
pip install -e ".[test]"
pytest
Some benchmark tests are skipped when a benchmark is not installed, or when they need the paper’s recorded runs.
The examples are a quick check that nothing is broken:
for f in examples/*.py; do python "$f" > /dev/null && echo "ok $f"; done
The README figures
docs/figures/make_figures.py builds the four figures of the README, each in a light and a dark version. It needs Google Chrome and pip install pymupdf. The numbers of the paper that two of the figures show are kept in docs/figures/data.json.
python docs/figures/make_figures.py
docs/figures/make_logo.py builds the logo in docs/assets/images/: the mark, the mark with the name for light and dark backgrounds, and the icons for the browser tab. It needs the same tools.
python docs/figures/make_logo.py
This website
GitHub Pages builds this website from the docs/ folder with the Just the Docs theme. The settings are in docs/_config.yml.
To turn the website on (once): on GitHub, open Settings, then Pages. Under Build and deployment, pick Deploy from a branch, then the branch main and the folder /docs, and save. After each push to main, the site is built again, at https://vicky157.github.io/causal-repair/.
To add a page, add a Markdown file to docs/ that starts with a short header:
---
title: My new page
nav_order: 15
---
title is the name in the menu, and nav_order is its place. Link to other pages by their file name, for example [Get started](/causal-repair/getting-started.html). The links then work both on GitHub and on the website.