Context Rail v3
An agentic project workspace: the files are the truth, a rebuildable SQLite index is only a cache, and every change goes through one write path.
A CTO agent runs a project through the rail, sub-agents get narrow, role-specific context, and a human approves the boundary, the quality bar and irreversible actions. The store it manages is plain Markdown you commit to git; the package ships the CLI, the MCP server and a loopback UI over one tool table.
Requirements
- Python 3.11 or newer (CI covers 3.11 and 3.13 on Windows and Ubuntu).
- Git, for anything that launches or integrates work.
- For the agent loop: an approved charter and the Factory
droidCLI onPATH. Reading and editing the store needs neither.
Install
py -m pip install context-rail
On macOS or Linux use python instead of py. This installs two equivalent
entry points, rail and ctx-rail; every example below also works as
py -m context_rail.
Quick start
From the project you want to manage:
rail init --pack basic # writes ./context-rail/
rail add goal "Ship v3"
rail add task "Write the first task" --rel part_of=ship-v3
rail status
rail cto brief
Every command prints one JSON envelope ({"ok": true, "value": ...} or
{"ok": false, "error": {...}}) and exits 0 on success, 1 on a refusal, 2 on an
infrastructure failure.
Notes that are easy to trip over:
--storeand--actorare global options: they go before the command, e.g.rail --store path/to/context-rail status.addtakes positional arguments:rail add <preset> "<title>".- Without
--store, the nearestcontext-railfolder above the current directory is used.
Onboarding a whole project
rail init --pack basic writes only the skeleton (rail.yaml, .gitignore,
empty folders). For a picture, the profiles and the agent files:
rail init --interview # or --answers-file FILE --confirm "APPROVE charter"
rail approve charter --confirm "APPROVE charter" --confirmer "Ada"
rail adapters sync # AGENTS.md + .agents/skills/
rail sync --install # optional: git merge drivers
--interviewand--answers-fileneed thehumanactor; a CTO may only propose with--draft-file, and a draft records no approval.init --answers-filewrites the picture but leaves approvalmissing; theapprovestep is what records it.adapters syncmirrors the workspace profiles and skills intoAGENTS.mdand.agents/skills/(orCLAUDE.md,.cursor/,GEMINI.md). It is a separate step today; re-run it when a skill changes.
Useful read commands:
rail status # counts, executable items, blockers, stuck items
rail digest # activity, waits, decisions, quality, usage
rail cto brief # the bounded brief a CTO session starts from
rail find --rel part_of=ship-v3
rail show <slug>
rail doctor # store integrity issues
rail ci # doctor issues plus the approval and done gates
Skills
Four operator skills under skills/ teach an agent the rail itself, so it does
not have to read the engine to answer "what can this do?" or "how do we change
the workflow?":
context-rail-v3— mental model, quick start, command mapcontext-rail-v3-workflows— packs, statuses, transitions, BA/PO stepscontext-rail-v3-loop— dispatch → verify → review → merge, refusalscontext-rail-v3-ops— doctor, reindex, recovery, budgets, test lanes
Install them into your agent's skill directory:
Copy-Item -Recurse skills\context-rail-v3* "$HOME\.agents\skills\"
See skills/README.md for the difference from the pack skills that are
installed into a store's workspace.
Human gates and the agent loop
Work that launches an agent, or changes the picture's meaning, is gated. The brief reports the current state; nothing executes until a human approves the charter:
rail approve charter --confirm "APPROVE charter" --confirmer "Ada"
Once the charter is approved, the loop uses isolated git worktrees:
rail dispatch <item> --expect <etag> --key <idempotency-key>
rail review <item> --run <run-id> --key <idempotency-key>
rail merge <item> --run <run-id> --expect <etag> --key <idempotency-key>
rail cto tick --key <idempotency-key> starts one bounded CTO session behind a
single-instance lock. It must be the outer session, so it refuses to start when
RAIL_ACTOR is already set.
Where state lives
- Store:
<project>/context-rail/, a plain directory of Markdown documents plusrail.yaml. It is the product's only source of truth and is meant to be committed to git. - Index: a rebuildable SQLite cache under the worktree's git dir, or
<store>/.rail-local/outside git. Never in the repository tree; deleting it only costs a rebuild. - Control files: dispatch/tick/merge progress and key bindings live in the same local dir, written atomically, so a crash leaves either the old file or the new one and never a partial document.
Command surface
- Store:
init,add,update,link,move,rename,relocate,show,find,reindex,doctor,ci - Views:
status,digest,cto brief,ledger - Checks and quality:
check,verify,report,triage,review - Agent loop:
dispatch,merge,cto tick,approve - Packs, profiles and adapters:
pack list|use|create,rollback,adapters sync(AGENTS.md,.agents/skills/,CLAUDE.md,.cursor/) - Measurement:
measure fix|versions - Interop:
migrate(v1/v2 import),sync(clones and git drivers),mcp serve(MCP over stdio),ui serve(loopback HTTP)
rail <command> --help is the authoritative list; the CLI, MCP server and UI
are all generated from one tool table (src/context_rail/gateway/tools.py).
Testing
From a checkout, install it in editable mode with the test dependencies:
py -m pip install -e .[test]
Then run one lane at a time:
py -m pytest -q -m "not slow and not perf" # functional lane
py -m pytest -q -m "perf and not slow" -p no:xdist # speed budgets, serial
py -m pytest -q -m slow -p no:xdist # 10k-document stores
The speed budgets are fixed: a change that needs more time is a bug in the
change, never a reason to raise the budget. py -m pytest -q on its own also
collects the perf tests, so use the lanes above when the machine is busy.
Layout
src/context_rail/
kernel/ pure rules: structure, budgets, gates, timestamps (no I/O)
model/ manifest, pack, policy and field validation
core/ result, util and the fixed primitive names
store/ the only write path, the SQLite cache, queries, sync
runner/ dispatch, review, merge, droid protocol, control files
gateway/ tool table, handlers, permissions, JSON envelope
context/ the computed CTO views (brief, status, digest)
doctor/ integrity checks
packs/ the built-in pack with its profiles, skills and templates
ui/ the loopback HTTP UI
cli.py thin argparse surface: stdlib plus the tool table at import
Design
- Visual guide (diagrams and from-zero-to-daily walkthrough):
docs/context-rail-v3-guide.html - Interactive engine graph (primitives, relations, one write path and the agent loop):
docs/context-rail-v3-engine-graph.html - Spec:
docs/superpowers/specs/2026-10-28-context-rail-v3-design.md - Architecture:
library/arch-stage-3.md - Working rules and engine invariants:
AGENTS.md
Engine invariants worth knowing before changing code:
- Every store mutation goes through
context_rail.store.write.commit. - Reads never execute commands and never hash source trees.
context_rail.kernelis pure: no file, git, process or index access.- Unknown manifest schema, pack version, key or policy field is refused, never guessed.
Metadata
Release files for context-rail 3.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| context_rail-3.0.2.tar.gz | 281.3 kB | Without provenance | Details for context_rail-3.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| context_rail-3.0.2-py3-none-any.whl | Python 3 | none | any | Details for context_rail-3.0.2-py3-none-any.whl |
Total release size: 626.8 kB
Release files / context_rail-3.0.2.tar.gz
| Download URL | context_rail-3.0.2.tar.gz |
|---|---|
| Size | 281.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
466b17ad5b5a8663c6bf4795658d807eb58ee63915464b733ab503a241acdb4c
|
|
BLAKE2b-256 checksum How to use checksums |
f11726ce44ae7b5dede8a2f3c72943d45a165986687db5eb8ab5e25a90269314
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / context_rail-3.0.2-py3-none-any.whl
| Download URL | context_rail-3.0.2-py3-none-any.whl |
|---|---|
| Size | 345.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3dd2c38abefe9d8328ea6fde9c6841c0d1054a36b676279ab3c548e2fd223c2
|
|
BLAKE2b-256 checksum How to use checksums |
791fe76d68f1c291f363249e4ea03ebc9d8295c8ad54fb4d93ec01875078ec53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for context-rail 3.0.2
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.