Requirements: Chez Scheme, igropyr, and libuv. No build step when run from source; objects are one command.
Chez Scheme 10.1.0, 10.3.0, 10.4.0 or 10.4.1 (the datum printer is measured identical on these; any other version refuses the verbs that print a datum with (error unsupported-printer-version)).
Platforms: the ones with a measured row in platform-numbers.sc -- macOS on arm64 and on x86_64, Linux on x86_64 and on aarch64 with glibc, and FreeBSD on amd64 (the row was measured on FreeBSD 15, and it is chosen by machine type alone, so another FreeBSD release on amd64 gets it too). On any other platform (another architecture, macOS on x86_64 or under Rosetta, a Linux with musl) every program writes (error platform-unmeasured ...) and exits 75 before it does anything else.
macOS: brew install chezscheme libuv Debian / Ubuntu: apt install chezscheme libuv1-dev Fedora: dnf install chez-scheme libuv-devel Arch: pacman -S chez-scheme libuv FreeBSD: pkg install chez-scheme libuv
On macOS and Linux, a Homebrew tap installs everything in one step:
brew tap guenchi/theourgia
brew install theourgianpm i -g theourgia installs the wrapper scripts and the sources. It only checks the requirements; when one is missing it prints the platform's install line.
The Homebrew tap and the npm package are not published yet; until they are, install from source as below.
Get a tagged tarball of Theourgia and place igropyr beside it under one library root:
library-root/
theourgia/
igropyr/Compile both into one output directory. On a Homebrew machine the interpreter is chez; the lines below say scheme for the upstream build.
scheme --script theourgia/build.ss library-root objectsThe three wrapper scripts -- theourgia, theourgia-mcp, and theourgiad -- expect CHEZSCHEMELIBDIRS set to the objects directory and CHEZSCHEMELIBEXTS set to .so.
Objects start about twelve times faster than source (measured: 50 ms from objects, 572 ms from source). Never place them in the source tree -- a stale .so beside a .sc is resolved in preference to it.
Create the store first, once: theourgia init --store <path>. The MCP shell has no local route and does not offer init as a tool. Then register theourgia-mcp --store <path> in the client's MCP configuration. One store per project or per person, on one machine.
theourgia init --template projectOne store is one project. The project template gives it four roots and seven relations, and records them in the store as its template block, which template export prints:
| Root | What goes there |
|---|---|
design | The document design.md; record each decision as a block of kind decision under it. |
tasks | The document tasks.md; record each task as a block of kind task under it, with a status of todo, doing, done or dropped. |
docs/ | Documents for readers are top-level docs whose path starts with docs/. |
code/ | Code is imported so that the paths of its files start with code/. |
The relations are implements (a task or code → the decision it carries out), depends-on (a task or code → one it needs first), supersedes (a decision → the one it replaces), refutes (a decision or doc → one it shows is wrong), verifies (a test → the code or decision it checks), conflicts-with (two decisions that cannot both hold) and documents (a doc → the code or decision it explains). Each is a name link accepts; any other relation name still links, and these are the ones the template names. describe, answered by the daemon, lists the store's roots and relations, and the MCP tools that write carry the roots' sentences after the writing protocol.
The built-in templates are project and memory; --template-file takes one of your own. theourgia init without a template is the advanced form: the store has no shape until you give it one.
template apply <name>, or template apply --file <template-file>, gives an existing store a template: it creates the template block and each document root the store does not have, and never changes a block that exists. A root is found by its slug and its path. When something else holds a root's place -- a template already, two blocks with the slug, a block with the slug that is not a top-level document at that path, or a document without the slug at the path -- it refuses and creates nothing.
The template is data in its block: change it with write and commit like any block, and insert a new root's document; nothing else needs to change. template apply also installs the template's relation declarations and rules: the project template declares documents as a listed relation with no effect, and the rule cover, citation coverage (see "Relations and rules"). A template block that cannot be read is listed by conflicts, and every verb then behaves as in a store without one. Importing a document does not make decisions or tasks.
A decision is a block of kind decision. It is owed until a block implements it -- theourgia link <impl> implements <decision> -- or its status reads done or dropped. commitments lists the decisions still owed, and --all every decision. An implementation has drifted when its own fields changed at a cut that neither its implements link nor the decision's latest edit covers: it was edited after it was linked. --drifted keeps the decisions with such an implementation, --since <cut> those whose creation the cut does not cover, and --under <id> those in a block's subtree. A write to a bookkeeping field (status, batch, keywords, class, slug) is not a change: a task set to done after it was linked has not drifted.
tasks lists the blocks of kind task, each with its status, its batch, what it implements, and (unlinked) when it implements no live decision; --status and --batch filter them. A task's implements edge discharges its decision only once the task is done.
In a store with a template, both verbs list by default what is under the template's root -- design for decisions and tasks for tasks in the project template -- and end with (scope <root-id> (outside <n>)), n being how many more rows --under root would list. In a store without a template nothing is narrowed and no scope clause is added. Neither verb writes.
A store is a directory, and everything in it is a plain file. meta.sexp names the store. Each writer owns a directory under writers/, holding one numbered segment file per run of writing: one record per line, a CRC and an S-expression, readable by a person and diffable by git. Large payloads go to blobs/. A writer's published.sexp records which of its segments have been handed to other machines.
store/
meta.sexp the store's identity
instance.sexp which machine and directory this copy is
lock zero bytes; only its existence is used
.gitignore written by init: what stays out of git
writers/
f0sjkuzn/
owner.sexp who this writer is
000001.sexp one record per line: a CRC and an S-expression
published.sexp which segments have been handed to other machines
incoming/ published segments kept but not installed
working/ this writer's drafts -- not part of the log
blobs/ payloads too large to sit in a record
snap/ a cached reduction; delete it and it is rebuilt
derived/ facts an editor supplied; the next supply rebuilds themA block is the smallest unit of content. It has a stable id, written <writer>.<base36 ordinal> -- f0sjkuzn.au is one. It has fields: kind, title, src, keywords, and whatever else its kind calls for. It has a position: a parent and an ordinal among that parent's children. And it has edges: named, directed relations to other blocks.
$ theourgia read f0sjkuzn.au
(ok ((id . "f0sjkuzn.au")
(deleted . #f)
(fields (keywords . "retry, supervisor, worker")
(kind . section)
(src . "...")
(title . "Why the retry is three deep"))
(position "f0sjkuzn.a" . 3)
(edges ((ref . "f0sjkuzn.b2")))))State is a deterministic reduction over a fixed set of events. Given the same log you get the same state, on any machine, in any order of reading. Everything else -- the snapshot in snap/, the search index, an outline, a markdown export -- is derived. Deleting a derived artifact costs a rebuild and nothing else, which is why none of them has to be kept correct by hand.
del retires a block: the reduction stops treating it as live, and the record of its life stays in the log. A block that was written by mistake can be taken out of the view without taking it out of the history, and what was written before the mistake is still readable at an earlier cut.
log gives every event its cut: cut is the causal cut right after the event, and past the one right before it -- the event's premises, each with its own premises, and nothing a writer did without depending on it. read <id> --cut <cut> gives a block as it was at a cut, written out as (("writer" . 12) ...) or as a tag name, and diff <past> <cut> gives what an event changed. A block that did not exist yet answers unknown-id. A cut naming an event not received, a writer twice, or an event without its premises is refused cut-unavailable; --working, --working-info, --writer and --signature ask about the present and are refused with --cut. Each such read replays the log from its beginning to the cut.
The split between a code repository and a documentation store is a filesystem accident, not a property of the knowledge. A section of a design, a Scheme macro, a function in another language and a decision record are all blocks: each has its own id, its own history and its own edges, and each can be read without reading whatever it sits next to. import-code reads a directory of source into the store; with --datum it reads Scheme as data rather than as text, and with --symbols it splits a first import at the symbols an editor collected. A Scheme definition imported as a library block is a block the store can evaluate against and follow by name; for other languages the editor supplies what its language server knows (signatures, keywords, call edges, diagnostics), and every answer built on those facts names the editor that supplied them and counts the facts the source has since outrun.
Every verb answers with one line: an S-expression that begins with ok or error. --wire asks for the machine-facing spelling of it. There is no second, prettier output mode that an agent has to parse differently, and no rendering markup in the way -- the reply is the same data the store holds, and the agent can judge the size of what it is about to read before it reads it.
A read of the committed store ends with a receipt: (cut <cut>), the state the answer was read from, and (versions ((<id> . "<hash>") ...)), the version of each block it shows. A version is the token --if-unchanged compares, so a block read and written back with it is refused if it changed in between. read (plain, --md, --recursive, --ast), refs, commitments, tasks, names and uses carry both clauses; search, grep and whereis, which already give their cut, add the versions; outline and reach carry the cut only. A working read, a draft listing, log, diff, conflicts, check, diagnostics, describe and the exports carry none. The human output shows the receipt only for a plain read and for reach. Recall does not need either clause; a write that must not overwrite a later change does.
A committed write can say what it rests on with --premises: a list of block versions and query digests, or the receipt that context prints; README gives the forms. Every committed write takes the option: insert, set, move, del, link, unlink, tag, batch, commit, import-code, import-md, def and template apply. The store checks the premises under its lock before the write's first record, and when they no longer hold, nothing is written and the write is refused by name. A retry of a request that was already written is not checked again, and its answer says (premises not-checked ...).
A block's class says what kind of statement it is: observation, inference, ruling, verification or external. With no class, a decision is a ruling and anything else an observation. Observations, rulings and verifications are authoritative; inferences and external material are not.
Blocks are linked with six relations: supersedes, refutes, depends-on, implements, verifies and conflicts-with. From those links each block has a validity, valid, needs-review, superseded or refuted; README's "Class and validity" gives the rules. Only an authoritative block can supersede or refute another. From any other block, supersedes, refutes and conflicts-with are only proposals.
A plain read of a block that is not valid adds a (validity ...) clause, and read never hides a block. search, grep and whereis leave out superseded and refuted blocks; the (excluded ...) clause that counts them is in the --wire answer only, and the human output shows the hits in force and nothing else -- nothing at all when every hit was left out, except an (incomplete ...) line if the store missed a writer. --all-validity leaves nothing out and names every hit that is not valid. A store that links none of the six relations answers as before.
query <goal> answers every binding of a goal's variables over the committed state at one cut. Its facts are 26 relations the store already answers -- a block's kind, class, validity, version, title and fields, edges, parents and text references, libraries, a code block's file holder and a text file's header imports, definitions, name use, the lifecycle's reasons and states, and search scores -- with 4 tests, and 21 relations defined by the library's 43 rules combine them; query --relations lists them, then the store's declared and stored relations. The language is Manteia (below). A query reads no log, runs no code and writes nothing, and one whose new work passes its budget is refused, never answered in part. An answer carries a digest of its rows, which a write can give back as a premise. Through the daemon, query and context are answered from the daemon's publication, made current first when the disk has moved past it, so a query after a write made outside the daemon sees that write.
A Scheme file stored in text mode takes its library and imports from its header, read by the store's own bounded reader from its pieces joined in order: a code block in no library block is in-library its file's library, and a script's pieces see the libraries it imports and no others. A definition in no library serves only the pieces of its own file, the code blocks with the same holder. Name use reads such a block as forms where its text reads, (name-use syntactic (reading forms)), and falls back to its tokens, (lexing whole-text) with a reason, where it does not.
context --for <id> --budget <tokens> answers what to read before working on a block, within a budget counted as four bytes a token of the answer as the wire prints it, its cut left out: the blocks it must show, with their roles and validity, the decisions still unsettled for the block, implementations in review and contradictions in its scope, then definitions, evidence, dependents, the users of the block's unit and ancestors as the budget allows. The users are a clause of their own after background, (users (listed <k>) (of <n>) ...): the live code blocks outside the unit that use a name the unit defines, by the name-use table uses reads, each listed whole or counted under the excluded counter users. The clause is reserved at the counters' digits, so it never changes which of the blocks that must be shown are shown, or how. A count above 999999 is shown as 999999 and its clause ends with (capped). Its receipt holds a premise for every block it had to show and the digests of the five queries that chose them, so a commit given that receipt is refused if any of that has changed; what it adds as the budget allows is not in the receipt. A verification whose target has moved past it is named in the notes as (stale-verification <m> verifies <c>), and its target is held by the receipt. The human output prints the receipt on one line, exactly as --wire writes it, ready for commit --premises.
--working answers over the request writer's working view instead, the one read --working reads: the committed state at the drafts' cut with that writer's drafts laid over it, in a fresh query session, never the one the daemon keeps. The answer carries (working "<writer>") after for, counted in the budget. A refusal of the view (writer-required, invalid-working-writer, working-unavailable, working-draft-unreadable) is the answer, and an id the view does not hold is answered as read answers it over that view. The view holds the writer's new files and hides its deleted ones, as read --working reads them: a piece of a new file can be the target, and a committed block that uses a name the piece defines finds it among that name's definitions. A working view changes block text and the names it uses, not validity: drafts are not changes, so the five queries answer the committed rows. Its premises for drafted blocks are the overlay's versions and are not handed to a commit; a committed answer's are. Without --working context writes nothing; with it, it reads the writer's drafts under the writer's draft lock, and for a writer with no draft area it creates nothing.
When a name the block uses has more than two definitions left, context shows the first two and counts the rest in (folded ...). --names <name>, repeated, enters the definitions of each given name in the block's scope before anything else that is optional, and (asked ...) says which are defined only in a block that must be shown or nowhere; for a file block, or any block that is not code, the scope is that of every code block under it. --budget min+<t> asks for the smallest budget the request needs plus t tokens, and the budget clause shows the number it came to.
Manteia is the store's query and rule language: the goals query answers, the goals a rule and a stored relation are written in, and the library's own rules. A term is a constant (a string, a symbol or an exact integer), a variable (a symbol beginning with ?), or _, which matches anything and is never reported. A goal is a fact relation, a relation of the library, a stored relation, a test (=, /=, string<, member on values already bound), or (and <goal> ...), solved left to right; a variable named twice takes one value, compared by equal?, so the string "x" and the symbol x are two values.
The forms (not <goal>), (count ?n <goal>), (sum ?s ?x <goal>), (min ?m ?x <goal>) and (max ?m ?x <goal>) take any goal, in a query, a rule or a stored relation's clause, never in the library's. A form's goal is a scope of its own: a variable bound before it is the group, one first bound inside it is local and is not visible after it. A stored relation may not depend on itself through a not or an aggregate; one that does is unavailable as unstratified, and derive refuses a declaration that would make one.
A fact speaks only of what the store has settled: a field two writers wrote without seeing each other gives no field row until a writer who has seen both writes it again, and conflicts lists it. A query reads the committed state at one cut, never a draft and never the log, and its answer names that cut. README's chapter "The query and rule language, construct by construct" gives each construct with an example.
relation <name> --as <kind> declares what a relation name does in this store: it follows one of the six relations with an effect, or with --as nothing it is a listed edge with no effect. --from and --to say which blocks each end is meant for, and a write that adds an edge whose end does not match is refused. A selector is (kind doc), or (kind doc) (field slot "result"); a field's value is a literal (a string, a symbol or an exact integer) or _, which holds for any value of the field the block carries (a contested field holds none), and a new declaration that writes a variable there is refused selector-value-not-literal. --retire makes the name a plain edge again.
rule <name> --on <kind> [--where <goal>] --must <goal> (or --must-not) declares a rule of this store in the query language, ?w standing for the block a write touches. Every committed write made after it, on every route, is judged against the rules before anything is written: the write runs once against a copy of the store's state, is judged, and then runs for real; one that fails a rule writes nothing and is refused rule-violation, naming each failing rule and block. A rule that cannot be evaluated -- the write's one budget of query work spent, or a query refused -- refuses the write rule-unevaluable, never answers ok; a write fact such as field+ is charged the rows it matches each time it is asked, so asking it at every target of a large write does not charge the whole relation at each. A delete counts the live far end of each of the deleted block's edges among the blocks it touches, so a rule over a review that cites a result judges the deletion of that result. rule cover --builtin citation-coverage enables the built-in rule: a write that carries --premises and links a block, by a relation of kind depends-on, to one its premises do not hold is refused. A declaration and a rule are records: two writers who declare one name differently without seeing each other leave it contested, with no effect, until a writer who has seen both declares it again. A store with no rule and no declared relation judges nothing.
derive <name> <value> declares a stored relation: a relation of this store, given a head with every column's kind and clauses in Manteia, that queries, rules and other stored relations name as they name the library's. It is data checked where it is used: a goal naming one is answered at the cut its session reads, and refused relation-unavailable, never answered empty, when the relation is contested, retired or its own clauses fail there.
Every agent and every person writes drafts under a writer id. Every record in the log also carries the actor that wrote it, a name the client states (--actor, else THEOURGIA_ACTOR, else the login name); nothing proves it, and a block id does not say who wrote the block. One writer id is held by one live agent at a time -- that is a rule in the documentation, not a mechanism in the code; a later session may bind the same id and carry on with its drafts. The store's own log writer -- the one its writes, position, a commit's cursor and adopt extend -- is chosen by ownership: a live writer whose owner.sexp names the instance this copy's instance.sexp records, never one copied in from another checkout, whichever sorts first. Only when no live writer names this instance is it the first local writer in name order.
write puts a proposed next version of a block into a writer's own slot. It is not in the log, and a read sees it only when it asks for that writer's drafts. commit, in describe's own words, installs a writer's drafts into the store as one change; the process that owns the store carries commits out one at a time, so the outcome of a race is decided rather than interleaved. A draft records the version it was made against; if the block has moved on since, the commit is refused.
A draft stands still while the store moves on. Every committed record moves the store's applied cut, whoever wrote it and whatever block it is on -- a review letter as much as a code change; a draft never moves it. When a commit changed the drafted block itself, the draft is behind: drafts --writer W reads it (fresh #f) and names it again after its items, (behind <block> (based-on <v>) (committed <v>)). A commit on other blocks only moves the cut, and leaves no draft behind.
A draft can also create a file or delete one: a new file is a path and its bytes, named by a provisional id, new- and the first 56 hex digits of the sha256 of the path; a deleted file is its holder. commit takes them only when named, --working-new <provisional>=<version> and --working-delete <holder>=<version>, in the same write as the block drafts, and its answer maps each provisional id to the block it made, (created ...), and each piece to its id, (pieces ...). Until then a provisional id names no committed block. The writer's own working view (read --working, context --working, outline --working) shows the new file as the blocks its commit would make, the holder named by the provisional id after the last top-level holder and its pieces <provisional>/<K>, and leaves a deleted file's blocks out, which asked for with --working are (error unknown-id <id> (reason deleted-in-working) (holder <holder>)); over any other view -- without --working, in another writer's view, and after the commit -- a provisional id is answered (error provisional-id (id "<id>") (reason not-committed)) (a refusal of the view comes first).
A refused commit does not simply say no. It answers stale-baseline, and it names the version the draft was made against, the version the block carries now, and the records applied since -- the winner's content among them. The agent that lost the race does not have to go and fetch the new state to find out what happened: it already has what it needs to merge and send the commit again.
One store per project or per person, on one machine. The machine registry tracks which stores live where; adopt transfers a store after a move or a restore.
Every verb can run standalone: open the store, answer, exit. For a session that sends many verbs, serve holds the store open and answers over a unix socket. The client finds the socket by the same rule the daemon used to create it, so nothing needs to be told where it is. The daemon's answer is the CLI's answer, byte for byte; both call the same dispatcher, and no verb or answer shape exists in one and not the other, except eval, scope and collect: the daemon does not run them -- sent over the socket, they are answered unknown-verb -- and the CLI runs them in its own program (eval in core.sc as its own child). A plain command never starts a daemon: when none is listening, the CLI starts core.sc --frame beside itself as a child, writes it the request frame a daemon would have been sent, and reads the child's answer as it reads a daemon's (the same 32 MiB ceiling, and no answer deadline, so the request waits for the store's lock); nothing is left running after it. A daemon is started by serve, or by the MCP shell for the session it serves. Answered in a child, a request meets the in-process route's differences: describe adds no template clause, the store's lock is waited for rather than refused store-busy after five seconds, the store is read as it is rather than as last published, --rev is refused no-published-state and subscribe needs-daemon. THEOURGIA_LOCAL=1 skips the socket and answers in process even when a daemon is there, for debugging. The daemon answers reads from the state it last folded, and can be one commit behind an outside change: a read that notices a record appended by another process, or a segment a git pull brought in, is still answered from that state and asks for a fresh fold, and the reads after the fold see the change. query and context are the exception: they make the publication current first. A write is never answered from that state: it is decided on the store as it stands under the lock. While a daemon serves a store, write through it.
A client waiting on a daemon gives up on silence, not on a clock: when nothing has arrived for 30 s since the last byte that moved, it answers (error transport-unknown (reason silent) (window 30000) (elapsed <ms>)); the request may have been carried out and is never sent again. There is no total bound: while a request's work reports progress (an export or an import per file, a commit per intent, a fold per segment) the daemon writes one keepalive space every 5 s, which the client strips before the answer's first byte. A verb or step with no progress point, one unit of work longer than 30 s, and a request queued behind another still go silent after 30 s, and a subscription gets no keepalive. A client asks for keepalives by sending envelope version 2, as the command line, channel, the MCP shell and the stream client do; a daemon that predates it refuses the frame malformed-envelope, and on exactly that refusal the client sends the request once more at version 1 on a new connection.
The daemon keeps one query session across query and context requests: a request over the same publication reuses what earlier requests derived, the session is advanced when the publication moves forward, and a fresh one replaces it otherwise. Every answer is the one a fresh session would give, with one exception: a query whose budget a fresh session would exhaust may be answered, since the kept session has done some of the work already. serve --session-size <entries> bounds the kept session (0 keeps none). A store whose directory disappears is drained, and the daemon exits with (exiting (reason store-gone)).
The socket path is a symbolic link to the daemon's private socket, <socket>.d/<pid>, in a directory of the daemon's own whose .endpoint marker reserves it for that endpoint; a client connects through the link as it always has. A start reclaims what an earlier daemon of the same endpoint left; it is refused serve-path-occupied when the socket path or <socket>.d is something it does not own, serve-path-reserved when its socket's directory is inside another endpoint's marked directory, serve-name-derived (exit 1, before anything is made or locked) when its name is spelled as another endpoint's lock, .<name>.lock or <name>.d.reserve, under the case rule of its directory, and socket-path-too-long (exit 2, before anything is created) when the path leaves no room for the private name. README's serve section gives the namespace's rules, the <socket>.d.reserve file that serialises a reservation, and the windows it accepts.
serve --idle-exit <seconds> makes a daemon leave by itself after that long with no connection open and no request running; an open subscription is an open connection, and 0 or no option means never. When the window runs out the daemon unlinks its public link first, so from then on a client finds no daemon and sends nothing; for the grace, --idle-grace-ms (default 200, at most 5000), it still takes the connections the kernel had already completed, then exits 0 with (idle-exit (after <seconds>) (refused-accepts <n>) (callback-raised <n>)) if none came. A late connection cancels the exit: the daemon binds and publishes again, logs (idle-resumed (socket <path>)), and answers it once the resume is done. A resume that cannot happen drains the daemon: the late requests are answered draining and it exits 75 with (idle-exit (reason resume-failed <cause>)). Every drain waits for the listener to hand over each connection it accepted, so a connection accepted just before a drain is answered draining, or served when its request was already running, never closed with nothing.
A client of the daemon can follow what changes. theourgia subscribe changes 0 prints an acceptance, then one line for every publication the daemon makes: blocks added and removed, fields, positions and parents changed, conflicts entered and resolved, edges added and removed. A commit made by another process reaches subscribers within about a second. Subscribe first, then read what you follow with read --rev, which names the publication the answer came from, and apply each frame whose revision is the next one; a frame further ahead is a gap, and the remedy is to read again. A resume, subscribe changes <rev> <token>, replays the frames the daemon still holds: at most the last 256, and only publications made while someone was subscribed; a resume that would skip one is refused window. The MCP shell is request and response and does not offer the stream; without a daemon, subscribe answers needs-daemon.
A store is plain files: meta.sexp, the lock, each writer's numbered segments with one record per line and its owner.sexp and published.sexp, and the blobs. Committing them commits the store itself. There is no export step, nothing to project, and nothing that has to be kept in step with the content, because the content is what was committed. A segment file's diff is the records that were appended: the revision of these pages that corrected four figures shows up in git as 15 added lines and no deleted ones, the log being append-only.
init writes <store>/.gitignore, which keeps out what belongs to this copy of the store rather than to its history:
/instance.sexp
/request-index.sexp
/snap/
/derived/
/writers/*/working/
/writers/*/draft.lock
*.tmp-*
!/writers/*/incoming/*instance.sexp is this copy's identity. request-index.sexp and snap/ are rebuilt from the log, and derived/ by the next supply. The working areas and draft locks are one machine's drafts. The *.tmp-* files are what an atomic write keeps after a failure -- except under a writer's incoming/, which the last line brings back, because a candidate kept there is evidence a replay is answered from.
A .gitignore already in the directory keeps every byte it has: init appends only the lines it lacks, each whole and on its own line, and writes nothing when it holds them all; a line ending in one carriage return holds the line, as git reads it. supply adds its line by the same rule. A .gitignore that is not a regular file -- a link, a directory -- is refused before anything is written, gitignore-not-a-file.
Track the lock. It is zero bytes and only its existence is used, but a clone without it answers store-busy to every verb, reads included -- and init will not create it in a store that exists.
Add the store as a whole, never named files -- git add <store> -- because a segment rolls over after 1 MiB, and a list of named files misses the one that rolled since.
$ git clone <repository> site && cd site
$ theourgia outline --store store
- 8pniyrtk.j Home
- 8pniyrtk.k Why not markdown
...
$ theourgia insert --store store --under root --title "..."
(error refused (instance inode))
$ theourgia adopt --store store
(ok (from "8pniyrtk") (to "x9a3vtll") (prefix 1 68042 113) (reason identity))
$ theourgia insert --store store --under root --title "..."
(ok (events (("x9a3vtll" . 1))) (state (("x9a3vtll.1" . "bf28cd40..."))) ...)What adopt does to a clone instance.sexp binds a store to the machine and the directory it was made in, so the first write from a clone is refused rather than accepted into a second copy of the same writer's log. A clone that carries another copy's instance.sexp is refused for the mismatch, as above; a clone without one -- what the .gitignore init writes gives -- is refused
(error refused no-instance (remedy adopt)). adopt mints a new writer id and leaves the history where it is: the clone keeps every block it was given, and its own records go under the new id from then on. A writer directory copied in from another checkout is read, never extended, while a live writer of this instance is there: a writer is this instance's when its owner.sexp names the(machine nonce)this copy's instance.sexp records, so a store holding both its own writer and another checkout's writes as its own, whichever sorts first, and adopt answersnot-needed. A writer whose owner.sexp cannot be read is not passed over: its write is refusedowner-unreadable. A request whose writer comes to be passed over while it runs -- this instance's writer copied in, or instance.sexp rewritten, during it -- is refused(writer-superseded (writer <w>) (by <o>) (remedy reopen)), and the next request writes as<o>.checksays whose writers the store holds, in four lines that leave its verdict alone:(writer-owner-foreign <w>)for a writer whose owner names another instance,(writer-owner-unverified <w>)for one whose owner carries no instance field or does not parse,(instance-absent (remedy adopt))for a store with owners and no instance.sexp, and(instance-unavailable (path <p>) (reason <r>))when instance.sexp could not be read; a writer an adopt retired is not listed. A remount is not a move: the device number is the kernel's for the volume and a reboot can change it, so the device is compared last, and when it is the only field that differs a write takes it for a remount -- instance.sexp rewritten with the live device under the store lock, the change kept in a history of the last eight remounts -- and goes on, with no writer derived or retired; adopt on such a store does the same and answers(ok (reason remount) (device <old> <new>)). A copy that keeps the original's inode number on another volume -- a block-level clone of a whole volume, a restore that preserves inode numbers -- is therefore taken for a remount too; to keep such a copy as a store of its own, copy it with a tool that makes new files (cp -R), whose inode then differs, and adopt that copy.checkreports the identity as(instance (machine <m>) (device <d>) (inode <i>) (nonce <n>) [(remounts ...)]), and a writer whose highest segment is empty after its last record's segment as(empty-segment <n>), a legal state; neither changes its verdict. Reading never needed any of this -- outline, read, search and eval answer from a fresh clone straight away. Every answer above came from a clone of this site; the outline is abridged and the titles passed to insert are left out, and nothing else is changed.
A change made in the store reaches a git repository, and commits made in git reach the store, through scripts rather than verbs, in tools/:
edit-export and edit-sync let an agent that edits files work on an export of its writer's working view: the sync turns each edited, added or removed file back into the writer's drafts, and refuses, writing nothing, when a hunk does not fall in exactly one block or a block it touches has moved since the export. The directory is folded to one name lexically, in edit-export, edit-sync and landing-freeze --tree alike, so ., dir/. and dir/x/.. name the same directory and find the same sidecar beside it.drafts-dump and drafts-restore keep a writer's drafts, which do not travel with a store's git; landing-freeze first brings every draft onto the store's applied cut -- one that is not behind is written again at the new cut, one that is behind is merged with the committed change line by line, and a new-file or delete draft at another cut is moved there when it still applies unchanged (a new file whose path no live file holds at the applied cut, a delete whose file's baseline there is still the draft's base), rewritten in place under one hold of the writer's draft lock and only while it is the version the freeze judged, so that a draft written again since, or a write that fails, leaves the entry where it was and refuses the freeze, structural-move-refused; when the two changes touch the same or adjacent lines, or a new file's path is taken or a deleted file is gone or changed at the applied cut, nothing is written and the freeze stops, drafts-behind-conflict, naming the blocks and the structural keys -- then freezes them with the working view for a landing's review; with --tree <edit-dir> the frozen tree must equal the tested edit directory byte for byte, dot-named names skipped, or the freeze is refused tree-differs. landing-freeze --check <dir> judges a freeze already made against the store as it is now (current, refreeze, or the conflict), and landing-commit commits them only if nothing the files are made of has changed since the freeze's cut, optionally tagging the landing's start. A cut moved only by records on other blocks -- a review letter, a landing's decision block, a tag -- is not a move; after a change to the files, a freeze made again rebases them.publish-landing publishes the files a landing changed as one git commit, its message held in a landing block, after checking that the worktree's base equals the store's export at the start tag. It publishes the text projection only, what export-code --raw writes: a landing in which a datum library differs between the cuts is refused, datum-not-published, rather than published without it.import-git absorbs a git range into the store as committed blocks and tags the result, the next landing's start; a file whose bytes are text at no end it exists at is skipped and named in the answer, and one that starts or stops being text is added or removed.README's chapters "Publishing a landing", "Editing a working view as files", "Keeping drafts, and landing them at their cut" and "Importing a git range" give each script's checks and refusals.
Every verb below, with its usage line and its one-sentence description, is rendered from what the store answers to describe. Nothing on this page is typed by hand, so it cannot drift from the binary that produced it. The tag on the right of each signature says where the verb runs: local in the client process, daemon over the socket, or child: a process the caller runs itself, so the store's server never runs user code.
read <id> [--md] [--recursive] [--ast] [--writer <name>] [--working] [--working-info] [--signature] [--cut <cut>] [--rev]Read one block: its fields, or its text. With --signature, the signature an editor supplied for it, of the committed store or, with --working, of the writer's working view. With --cut, the block as it was at a causal cut (a literal or a tag name): the same answer over that cut's state, or unknown-id where the block did not exist yet. With --ast, the body of a block the markdown projection writes, as a markdown tree, each reference carrying its live target. (daemon)
refs <id>List the relations a block takes part in. (daemon)
search <query> [--all] [--all-validity]Find blocks whose title, keywords or text match every word given. (daemon)
grep <pattern> [--under <id>] [--all] [--all-validity]List the lines that contain a pattern, literally. (daemon)
whereis <name> [--all-validity]Say where a name is defined, and which libraries carry it. (daemon)
log [<id>]Show the changes recorded, for the store or for one block. (daemon)
outline [--depth <n>] [--with-keywords] [--with-signatures] [--working]List the blocks as a tree of titles. (daemon)
tag [<name>] [--premises <datum>]Name the current cut, or list the names already given. (daemon)
diff <cut> <cut>Report what changed between two cuts. (daemon)
describeList the verbs, what each is for, and the writing protocol. (daemon)
commitments [--open] [--all] [--drifted] [--since <cut>] [--under <id>]List the decisions still owed: by default those neither implemented (an incoming implements edge) nor marked done or dropped; with --all every decision. --drifted keeps those with an implementation whose latest change was seen neither by its implements link nor by the decision's latest edit. (daemon)
tasks [--status <status>] [--batch <batch>] [--under <id>]List the tasks: by default those under the root the store's template names for tasks, else every task; each with its status (todo, doing, done or dropped), its batch, what it implements, and (unlinked) when it implements no live decision. (daemon)
names <id>Which names a code block uses, as its stored code shows them, and which libraries a library block imports. A datum block's body is walked as data: a symbol is a use unless something in the form binds it, and an unknown macro's operands count as uses. A text block of a language with a reader (Scheme's) is read as forms first, each walked as a datum block's body is, so comments and strings are not names; when any part of it does not read, the whole block falls back to the tokens, as every other text block's uses are: every token its language's identifier pattern matches, comments and strings included. No name is resolved. (daemon)
uses <name> [--under <id>]The live code blocks that use a name, compared whole and exactly, one row per block with its library and mode; with --under, those inside that block. It is not find-references: a use is listed whether or not anything defines the name, and a text block that defines the name also lists it. (daemon)
query [<goal>] [--relations]Answer one goal of the query language over the committed state: every binding of its variables, one row each, sorted by their bytes, with a digest of the rows. A goal is a fact relation, a rule of the library, a test, or (and <goal> ...). --relations lists the fact relations and the rules. (daemon)
context --for <id> --budget <tokens> [--names <name>] ... [--all-validity] [--working]The material to read before working on a block, within a budget of tokens. What must be shown is the answer of five queries, each block placed once: for, constraints, evidence or to-verify by its validity and class; what else fits follows in a stated order (counterexamples, background). The receipt covers every block that must be shown, whether it fitted or not, and commit --premises takes it back; under --working, the premises of a drafted block are the overlay's versions and are not handed to a commit. A name with more than two definitions left shows two and says so in folded. --names <name>, repeated, enters the definitions of each given name in the block's scope first and says in asked which are defined only in hard blocks or nowhere; --budget min+<t> is the minimum the request needs plus t. --working answers over the request writer's working view (its drafts over the committed state at the drafts' cut) and says so in (working <writer>) after for. (daemon)
positionSay the local log writer's last sequence, the cursor a tracked request may name: (position (<writer> . <n>)), 0 before its first record. The writer is the store's log writer, not a draft writer. (daemon)
locate <path> [--writer <name>] [--cut <cut>] [--bytes <s:e>] [--lines <a:b>] [--hunk <hunk>]Name the blocks holding a byte range, a line range or one unified-diff hunk's old side of a text file's raw bytes (what export-code --raw writes), each whole with its span: (items (block <id> <start> <end>) ...). Give one of --writer (that writer's working view) or --cut; a hunk is meaningful at the cut its diff was taken against. --hunk - reads the hunk from standard input. (daemon)
changed-files <cut> <cut>List the files whose exported bytes or presence differ between two cuts, each as content, added or removed; a title, a level, a link or a language changes no file. Paths a case- or normalisation-insensitive volume would merge are listed as case-ambiguous or normalisation-ambiguous groups. (daemon)
subscribe <stream> <rev> [<token>]Follow the store's publications: <stream> is changes, and every publication after <rev> arrives as a line naming what changed, until the stream ends. 0 starts from now; a resume names the daemon token its acceptance gave. (stream)
scope <dir> --roots <id> --for <actor> [--cut <cut>] [--freeze <dir>] [--packet <packet-file>] [--home <dir>]Make a new store at <dir> holding a letter to <actor> and a copy of each block under the roots as it was at the cut, each copy carrying origin (the block's id here) and origin-cut; the edges between copies are copied, an edge leaving the roots is dropped and listed, and a contested field is listed and not copied. The letter copy's baseline is the new store's cut after the copies. --roots is given once per root, or as all, every top-level block. One record is written here: the letter, at the top level, with to, status, cut, roots and scope. With --freeze, a landing freeze, the cut is its pinned cut, each copy the freeze has a draft of holds the draft's bytes with the committed src in a before section under it, and nothing is written here: collect-into --letter new writes the letter after the landing. --packet writes a file's sections under the letter copy. --home makes the new store under that machine home, beside it, so a reader whose sandbox holds both can write there. An existing <dir> is refused before anything is written, and so is a block or edge the write would refuse. It runs in the caller's own program -- the command line's, or the MCP shell's child -- never in a store's server. (child)
review-resultsIn a scoped store, list the review results as one datum: each live block the letter's reviewer created that is not a copy, with its parent, settled fields and the actor of each, and its about targets; a finding with no about and a verdict missing a condition field are listed. For a scope of a freeze it answers pending while there is no verdict and results-incomplete for the first field missing (a source must be a copy, the scope's own blocks listed beside them not counting), and the results carry the letter's fields and the proposals, the copies whose src the reviewer changed. (daemon)
collect-into [<letter-id>] --results <datum> [--letter <new>] [--map <map-file>] [--to-writer <writer>]Write a review-results datum under a letter: the blocks not collected before, then the about edges not present, as the reviewer's records. Answers how many were inserted, linked and already linked, and every field another actor set. A candidate's datum is refused unless complete; --letter new makes its letter, --map reads a landing's answer for the ids it gave provisional origins, and --to-writer makes each proposal a draft for that writer. (daemon)
collect <dir> [--map <map-file>] [--to-writer <writer>] [--home <dir>]Bring a scoped store's review results back under its letter here: the blocks the letter's reviewer created in <dir>, with their settled fields, under the reviewer's name, and their about edges, to the origin of a copy or to the collected block. A candidate's results are collected with --letter new, and --map and --to-writer are passed on; --home reads <dir> under the home it was made under. A second collect writes nothing new. It runs in the caller's own program -- the command line's, or the MCP shell's child -- never in a store's server. (child)
init [--template <name>] [--template-file <template-file>]Create a store in this directory; with --template (a built-in such as project) or --template-file, then apply that template to it. (local)
template <action> [<name>] [--file <template-file>] [--premises <datum>]Apply a template to this store (apply <name>, or apply --file <template-file>): create the template block and each document root the store lacks, changing nothing that exists. Or print the store's template (export). (daemon)
insert [--under <id>] [--after <id>] --title <text> [--text <text>] [--keywords <text>] [--premises <datum>]Add a block under a parent, with a title and optional text. (daemon)
set <id> <field> <value> [--if-unchanged <version>] [--based-on <version>] [--premises <datum>]Replace one field of one block. (daemon)
move <id> <parent> [--after <id>] [--premises <datum>]Move a block to another parent, optionally after a sibling. (daemon)
del <id> [--premises <datum>]Retire a block. Its history stays. (daemon)
link <from> <rel> <to> [--premises <datum>]Record a named relation between two blocks. (daemon)
unlink <from> <rel> <to> [--premises <datum>]Remove a named relation between two blocks. (daemon)
def <name> [--under <library>] <source> [--premises <datum>]Define one named definition in a datum library, after its last child. A name one of the library's children already defines is refused (name-exists); def does not replace a definition. (daemon)
relation <name> [--as <kind>] [--from <selector>] [--to <selector>] [--retire] [--premises <datum>]Declare what a relation name does: --as one of the six relations with an effect (supersedes, refutes, depends-on, implements, verifies, conflicts-with), whose rules its edges then follow, or nothing, a listed edge with no effect. --from and --to name the blocks each end is for: a write that adds an edge whose end its selector does not match, or retypes such an end, is refused relation-endpoint. With --retire the name is a plain edge again. The same declaration again answers (ok (unchanged)) and writes nothing. (daemon)
rule <name> [--on <kind>] [--where <goal>] [--must <goal>] [--must-not <goal>] [--builtin <name>] [--retire] [--premises <datum>]Declare a rule of the store: on writes to blocks of the --on kinds (repeated for several), selected by --where when given, the --must goal must have a row for the block, or the --must-not goal none; ?w stands for the block. --builtin names a built-in rule (citation-coverage); --retire ends a rule. A goal is a query goal over the stored facts; one that reads outside the log is refused. Every committed write after it is judged before anything is written; a write that fails is refused rule-violation, naming every failing pair. The same rule again answers (ok (unchanged)) and writes nothing. (daemon)
derive <name> [<value>] [--retire] [--premises <datum>]Declare a stored relation of the store: <value> is ((head (<name> <kind> ...)) (clause (<name> <term> ...) <goal> ...) ...), the head giving every column's kind, each clause a pattern and goals in the query language (facts, tests, library relations, other stored relations, itself). A query, a rule and another stored relation may then name it. Its clauses are checked where they are used: a goal naming one contested, retired or failing its own check there is refused relation-unavailable. --retire ends it. The answer carries (affects (rule ...) (derive ...)) when the write changes what settled rules and stored relations can answer. The same value again answers (ok (unchanged)) and writes nothing. (daemon)
write <block> <bytes> [--writer <name>] [--based-on <version>] [--working-cut <cut>] [--working-parent-writer <name>] [--working-parent <version>] [--rebase]Save a draft of a block in a writer's own space, without committing it. (daemon)
restore <version> [--writer <name>]Take an earlier version of a draft back into a writer's space. (daemon)
drafts [--writer <name>]List the drafts a writer is holding. (daemon)
discard <block> [--writer <name>]Throw away a writer's draft of a block, or a structural draft by its key (a new file's provisional id, or delete- and the holder). (daemon)
commit [<block> ...] [--writer <name>] [--working-version <block>=<version>] [--working-new <provisional>=<version>] [--working-delete <holder>=<version>] [--premises <datum>]Install a writer's drafts into the store as one change. (daemon)
import-md <dir> [--allow-delete] [--premises <datum>]Read a directory of markdown into the store. (daemon)
export-md <dir> [--with-ids] [--working] [--writer <name>] [--cut <cut>]Write the store out as markdown. (daemon)
import-code <dir> [--allow-delete] [--datum] [--symbols <symbols-file>] [--premises <datum>]Read a directory of source into the store. With --datum, the whole-line ; comments directly above a form become its doc; a ; comment inside a form is dropped, and the answer warns with its line and column. A #| |# block comment, and any comment inside a datum discarded with #;, is dropped with neither. With --datum, only Scheme files are read: those the language table gives to Scheme by extension (ss, sc, scm, sls, matched exactly); every other file the directory walk returns (it does not enter a name that starts with a dot) is listed, in the order it was walked, in the answer's skipped clause, which is there only when something was skipped. A file the reader refuses is named in the refusal's path clause. Text mode, without --datum, skips a file that is not UTF-8 text or that holds a NUL byte, and lists it in the same skipped clause; it is decided by the bytes, not the name, so a source file in a legacy 8-bit encoding or in UTF-16 is skipped and listed, not imported, unless its bytes happen to be valid UTF-8 with no NUL. With --symbols, a file an editor's symbols file names is split on its first import at the cuts split-suggest gives those symbols, the comment lines above a definition going with it; what follows a symbol up to the next block is a block of its own only when it holds code, the symbol's end moved forward to where the scanner sees top-level code begin; a file that already carries markers follows them, and the answer lists it as symbols-ignored. A file with a symbol whose start the scanner does not see at the top level is not imported, and the answer lists it with its refusal, which names the symbol, as symbols-refused; an end is never refused. A file whose cuts could not be checked at all (symbols-unchecked: no language entry or suggest profile; symbols-unscanned: the scanner cannot follow it) is imported whole, as one block, and listed with its refusal as symbols-imported-whole. The skipped clause and the three symbols clauses are printed after the items without --wire too, one line each. (daemon)
export-code <dir> [--raw] [--datum] [--working] [--writer <name>] [--cut <cut>]Write the store's source back out to a directory. (daemon)
split-suggest <file> [--output <review-file>] [--symbols <symbols-file>]Propose where a long file could be divided into blocks. With --symbols, the cuts come from an editor's list of the file's top-level symbols instead of the language's definition patterns; the answer's cuts-from says which. (daemon)
checkRead the whole store and report whether it is sound. (daemon)
snapshotRecord the current state as a reduction that can be reopened quickly. (daemon)
adoptTake in records that are on disk but not yet in the log. (daemon)
conflictsList blocks whose writers disagree. (daemon)
publish <writer> <segment> <file> [<sha256>]Publish a segment of a writer's log. (daemon)
batch <intents> [--premises <datum>]Carry out several changes as one request. (daemon)
eval [--lang <language>] [--cut <cut>] [--under <library-id>] [--working] [--latest] [--writer <name>] [--timeout-ms <n>] [--memory-bytes <n>] [--output-bytes <n>] <source>Evaluate source against the store, or against a writer's working view with --working: Scheme by default, another language with --lang, whose runner runs only where the operator has set THEOURGIA_RUNNERS=on. It runs as a child process of the caller, never in the store's server. (child)
supply <kind> <file> [--for <writer>] [--clear]Keep facts an editor computed from an export-code projection -- signatures, calls, diagnostics -- in the store's directory under derived/, outside the event log. The header carries the digests of the projected files it was computed from; every file it lists is checked against the store's own re-projection, of the committed state or, with --for, of that writer's working view. A fact is used only while the blocks it depends on still project as they did. With --clear, the table the header names is removed. (daemon)
reach <id> [--rel <rel>] [--depth <n>]List the blocks a block reaches over the edges an editor supplied (calls, by default), outward, up to --depth hops (1 by default); the block itself is at depth 0. (daemon)
diagnostics [--writer <name>]List the diagnostics an editor supplied for a writer's working view, by block and then by start, each at a byte range of its block's own src; one whose range cannot be mapped onto a single block's src is listed with (at unmappable). (daemon)
These are accepted by every verb, and are left out of each usage line above.
| Option | What it does |
|---|---|
--store <dir> | Which store. Falls back to THEOURGIA_STORE, then . |
--actor <name> | Who the request is from. Falls back to THEOURGIA_ACTOR, then USER, then cli |
--socket <path> | Reach a daemon at this path instead of the default |
--wire | Print the answer as one S-expression per line rather than for a person to read |
--req <id> | The request's identity, so a retry is recognised as the same request rather than a second one |
--cursor <w:n> | The position this request is composed against |
A request that reaches a server naming --store, --actor, --wire or --socket inside it is refused transport-option-in-rpc: those say where a request goes, and it has already gone.
| Variable | What it does |
|---|---|
THEOURGIA_STORE | The store when --store is absent |
THEOURGIA_ACTOR | Who the requests are from when --actor is absent |
THEOURGIA_SOCKET | For scope and collect, the main store's daemon socket when --socket is absent |
THEOURGIA_WRITER | Whose drafts a request reads and writes when --writer is absent |
THEOURGIA_HOME | Where the machine registry and its lock live. Falls back to $HOME/.theourgia, or /tmp/.theourgia when HOME is unset |
THEOURGIA_RUN | The run root holding daemon sockets. Falls back to $HOME/.theourgia/run |
THEOURGIA_LOCAL | 1 answers in process even when a daemon is there. Unset, a command with no daemon listening is still answered in process, by a core.sc --frame child |
THEOURGIA_SCHEME | The Chez binary eval starts its child with. Falls back to scheme |
THEOURGIA_EVAL_SLOTS | How many evaluations one run root runs at once. Falls back to the number of online processors |
THEOURGIA_RUNNERS | on turns on eval --lang's runners for another language |
THEOURGIA_RUNNER_CHEZ | The operator's runner for eval --lang chez, replacing the language table's fields |
THEOURGIA_RUNNER_TYPESCRIPT | The operator's runner for eval --lang typescript, a whole runner in place of the default |
THEOURGIA_RUNNER_GO | The operator's runner for eval --lang go, a whole runner in place of the default |
THEOURGIA_RUNNER_RUST | The operator's runner for eval --lang rust, a whole runner in place of the default |
THEOURGIA_RUNNER_C | The operator's runner for eval --lang c, a whole runner in place of the default |
THEOURGIA_RUNNER_JAVA | The operator's runner for eval --lang java, a whole runner in place of the default |
THEOURGIA_TRACE | 1 writes filesystem and dispatch events to stderr, and from a daemon each query session decision and what each query or context call built |
Nine more variables are for tests only and are read only by a build made with THEOURGIA_INJECT=on; an ordinary build does not read them. Among them THEOURGIA_PROBE=off starts a daemon without its once-a-second probe for outside changes.
theourgia-mcp --store <path> [--socket <path>] [--actor <name>] [--writer <name>] speaks MCP 2025-11-25 over stdio. Create the store with theourgia init first, then register the shell once:
claude mcp add theourgia -- theourgia-mcp --store /path/to/store --actor <name>Or in a client's JSON configuration:
{
"mcpServers": {
"theourgia": {
"command": "theourgia-mcp",
"args": ["--store", "/path/to/store", "--actor", "<name>"]
}
}
}One tool per verb the shell can carry out -- every verb routed to the daemon, and eval -- named theourgia_<verb>, each taking {"argv": [...]} with the command line's own arguments as an array of strings. The shell asks the store's daemon for the catalogue on every call and never caches it, so a verb added to a newer build appears without restarting the server. theourgia_insert and theourgia_write carry the core's writing protocol in their descriptions.
The core's answer arrives as S-expression text, byte for byte. A core refusal is a successful tool result, not a JSON-RPC error: (error unknown-id ...) is the store's answer to the question asked, delivered with isError: false. Only the shell's own failures use the JSON-RPC error channel: a frame it could not parse, a frame past the size limit, or a connection that was made and then lost. A lost connection says the request may have been carried out, because it may have been; a request that reached nobody says it was not. A store condition the shell meets before the verb runs -- a daemon that would not start, a refused or unreadable catalogue -- is a tool result with isError: true and the refusal in _meta.refusal: read the text, not the flag.
eval is offered as theourgia_eval. The shell runs core.sc eval as its own child, not through the daemon: the store's server never runs user code. The call's optional stdin string becomes the child's standard input; without one it reads /dev/null. Transport options (--store, --wire, --socket, --actor) are refused with transport-option-in-rpc; the writer defaults to the session's unless --writer is given; a language other than Scheme runs only where the shell was started with THEOURGIA_RUNNERS=on; a lost evaluation is a protocol error naming the reason. init is not offered, because the store must exist before the MCP server starts.
The catalogue comes from whichever daemon is serving the store, and a client may read tools/list only once per session. After a core upgrade, stop the store's daemon first — the shell's next request starts one from the new core, where a plain command starts none — then restart the agent's session. A session restarted while the old daemon still runs is given the old catalogue and sees none of the new verbs.
The shell is the opener: with nobody listening it starts the store's daemon, and the daemon it starts leaves when idle. It passes --idle-exit with the seconds in THEOURGIA_IDLE_EXIT (1800 when unset, 0 for never) and --idle-grace-ms 200; a value that is not a non-negative integer is that call's answer, (error bad-environment (reason not-a-count) (variable "THEOURGIA_IDLE_EXIT") (value "<v>")), and no daemon is started. Two shells on one store share its daemon with no counting, and the one that finds it gone starts it again on its next request. A request has one deadline and at most two attempts: a start that meets a daemon leaving or resuming (serve-busy) is tried again after 100 ms, a connect first each time, and a request whose daemon left between its start and its own connect is tried once more; after that the answer is connect-failed with (carried-out no). A tool call whose daemon went silent, nothing having arrived for 30 s since the last byte that moved, is answered with the JSON-RPC error -32603 and the data object {"reason":"silent","window":<ms>,"elapsed":<ms>}; the request may have been carried out. A request that was written is never sent again.
describe carries this text once, beside the verbs, and the MCP shell puts it in the descriptions of theourgia_insert and theourgia_write; in a store with a template, the tools that write carry the roots' sentences after it:
A block is the unit of writing: one block should answer one question on its own.
Keep a block under about 800 tokens (roughly 3000 bytes); split a longer one.
Give every block a one-sentence title.
Give every block 3 to 8 keywords, comma separated, with --keywords.
Place a block under the parent its source or subject puts it under, with --under.
Do not rewrite the source bytes: splitting a document must not edit its prose.
Change a block with write and then commit, through a draft, rather than replacing it.
Hold a writer id from one agent at a time: a later session may bind the same id and carry on with its drafts, but two agents writing one draft at once overwrite each other silently.
Record a decision as a block of kind decision, and link each block that implements it with link <block> implements <decision>.
Open a session with commitments --open, which lists the decisions not yet implemented, done or dropped.
Set class with set <id> class inference for what you concluded and did not verify, and with set <id> class external for material from outside; neither is ever treated as a ruling.
To replace a ruling, write the new one and link <new> supersedes <old>; to record that something is wrong, link <evidence> refutes <claim>.
Say what your work rests on with link <work> depends-on <premise>: when the premise changes, the work is marked for review.
After checking that an implementation still carries out its decision, link <impl> implements <decision> again: linking again is how you say you checked.A writer id is held by one live agent at a time. On the command line it is --writer, else THEOURGIA_WRITER; with neither, a draft verb is refused writer-required. The MCP shell decides it once, when it starts: THEOURGIA_WRITER when set and not empty, else --writer, else one derived for the session, <actor>-<start>-<pid> -- the actor reduced to what a writer id may hold, the start in milliseconds in base 36, the shell's process id. The initialize response names it, and a tool call's own --writer overrides it for that call only. A name a writer cannot have (1 to 128 characters of a-z, 0-9, ., _, -, and not . or ..) stops the shell at start with its usage line, exit 2.
A later session may bind the same id and carry on with its drafts, by starting with THEOURGIA_WRITER=<that name>, but two agents writing under one id at the same moment overwrite each other silently. There is no lock and no refusal: the rule is stated here, and the failure it prevents is silent. Derived writers differ between sessions, so the risk comes from a fixed name: a host that sets one --writer or THEOURGIA_WRITER for several agents makes them share it.
There is one refusal, for another checkout's writer: a draft writer is a name of your own. While this copy has a live writer of its own, the verbs that change drafts -- write, restore, discard of a draft that is there, commit, and the structural drafts a landing tool writes -- refuse a --writer whose owner.sexp names another instance: (error foreign-writer (writer <w>) (remedy draft-writer)). A session's draft writer has no owner.sexp and is accepted as before; reading such a draft (read --working, drafts), the replay of a tracked commit and the completion of a persisted plan are answered as before.
Sessions on one machine -- of any vendor, through the command line or the MCP shell -- talk to each other through a store. There is no message verb: a message is a block of kind doc with to, the reader's actor name, and status, "unread" when sent and "read" once the reader has read it, and reading one's mail is a query:
query '(and (field ?m "to" "codex") (field ?m "status" "unread"))'A review goes through a store made for the reader. scope <dir> --cut <cut> --roots <id> --for <actor> makes a new store holding exactly the blocks under the roots as they were at the cut, a letter copy that names the reader, and nothing else -- the authors' notes, ledgers and earlier rounds are not in it -- and writes one letter in this store. The reader, in a fresh session pointed at <dir>, writes a verdict under the letter copy, with model, approval, sandbox and effort, and a finding under the verdict for each finding, each with an about edge to the copy it concerns. collect <dir> brings them back under the letter here, each about edge on the original block; review-results, run in the scoped store, and collect-into are the two halves it is made of. scope and collect run in the command line's own program or as the MCP shell's child, never in a daemon.
A change can be reviewed before it lands. scope --freeze <dir> takes a landing freeze: the copies hold the drafts' bytes, a before section under a changed copy holds the committed text, --packet adds sections such as the questions, each with any number of texts, joined in packet order with one empty line between two, --roots all copies every top-level block as the store is now (refused roots-all-at-another-cut when the scope's cut is another), and no main letter is written until the landing. A candidate's results are strict: review-results answers pending until a verdict exists, and a verdict must name its sources, at least one of them a copy. After the landing, collect --map <file> reads the landing's mapping of provisional ids, writes the letter then (--letter new, once), and with --to-writer <W> turns each proposal -- a candidate copy whose src the reader changed -- into a draft for W, which W keeps, rewrites or discards; nothing is committed by it. --home <h> makes the scoped store under its own machine home, so a reader confined to a review directory holding both can write in it; collect --home <h> reads it.
Codex reaches a store through the MCP shell (codex mcp add theourgia -- <the command that starts the shell>, with THEOURGIA_ACTOR=codex). contrib/ holds what tells it about mail: codex-hooks.json runs mail-hook.sh on PostToolUse and UserPromptSubmit, which prints the reader's unread mail as the hook's answer, and exits 1 with a line when its query fails, since a failed query is not an empty mailbox; doorbell.sh types one line into a tmux pane when mail arrives for a reader idle at its prompt; AGENTS.md is the reader's side of the discipline. Claude Code reads its mail the same way: contrib/claude-hooks.json is the hooks section of its settings.json, running the same handler with THEOURGIA_ACTOR=claude.
The scoped store keeps a cooperating reader from seeing more than its roots. A reader's edits to the copies are not collected, except as the proposals of a frozen candidate's review. It does not keep out a reader that opens the main store's directory or states another actor's name: on one machine the user owns every session, and an actor is a stated name. This program speaks over a local socket and the local filesystem; a store kept in git is read on any clone, and writing one store from two machines is not built.
One store per project or per person, on one machine. The machine registry records which stores are where. Moving a store to another machine requires adopt, which transfers its entry in the registry. Two machines writing one store is not supported.
To use a store as persistent memory for Claude Code sessions: turn off the built-in auto-memory (CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 or in settings.json), register the store as an MCP server, and inject an outline at session start with a SessionStart hook that runs theourgia outline --depth 1. CLAUDE.md then carries the recall and write instructions: search to find, read to retrieve, insert to add (under the right section, with title, keywords, and text following the block protocol), and write+commit to update an existing block rather than duplicating it. The full recipe is in docs/claude-code-memory.md in the repository.
The extension drives the Theourgia core installed on the machine, and needs VS Code 1.138.0 or later. Install the core first (from source for now: the Homebrew tap and the npm package are not published yet), then configure the settings:
| Setting | What it is |
|---|---|
theourgia.corePath | The directory holding the core: a checkout, or a directory built by the core's build.ss. The extension tells which by looking for client.sc or client.so, and refuses a directory with neither. Required. |
theourgia.libDirs | Extra directories for CHEZSCHEMELIBDIRS, after corePath. The directory holding corePath is searched after them (the extension adds it itself), so a copy named here comes first. The core imports igropyr, so the directory holding igropyr belongs here, unless it is the one holding corePath. |
theourgia.store | The store directory, passed as --store. Required. |
theourgia.actor | The name recorded with every write. Defaults to the OS user name. |
theourgia.writer | Passed to the core as THEOURGIA_WRITER, and the writer whose working view Supply Diagnostics reads. Defaults to the actor. |
theourgia.scheme | The Chez Scheme executable. Defaults to scheme. |
theourgia.timeoutMs | How long to wait for one request before killing the child process (SIGTERM, then SIGKILL two seconds later). Defaults to 30000. |
Until corePath names a checkout or a built directory and store is set, the outline is empty, the status bar shows a gear whose tooltip names each setting at fault, and every command answers that they have to be set first. store is only checked for being set: a path that does not exist passes, and the requests go to the core.
Each request runs the core's client as a child process, <scheme> --script <corePath>/theourgia.sc <verb> ... --store <store> --actor <actor>, with CHEZSCHEMELIBDIRS, CHEZSCHEMELIBEXTS, THEOURGIA_ACTOR, THEOURGIA_WRITER and THEOURGIA_SCHEME set from the settings. The client starts no daemon: when none is running, each request is answered by a core.sc --frame child the client starts for it, and a daemon started by serve or by an MCP shell on the same store is used while it is there. A core that cannot find a library is answered with advice to add its directory to libDirs; a platform the core has no row for is answered with the core's own remedy.
Install the .vsix package for your platform from the command line:
code --install-extension theourgos-darwin-arm64.vsixThe packages are named theourgos-<target>.vsix. On the Visual Studio Marketplace the extension's id is theourgia.theourgos -- publisher theourgia, package theourgos -- and it installs with code --install-extension theourgia.theourgos. Its commands and settings keep the theourgia. prefix, and its view and activity-bar container keep their theourgia names.
An outline tree of the store appears in the side bar. Expanding a node lists the blocks directly under it; a row shows the block's keywords, and an icon for a conflict, an orphan or an unknown mark. Clicking a block opens it. A prose block opens as a markdown buffer: its heading, then this window's working draft of its body. The heading is not edited there -- a save that changed it is refused prefix-changed.
Saving writes a working draft first, under a writer of this window's own (window-<session>), reads it back, and then sends a commit carrying the draft's version. The request id, cursor and record are written to disk before the commit is sent, so a save whose answer is lost -- a timeout, a lost connection -- stays pending and is retried: at startup, on a settings change, or with "Retry Pending Saves". A commit is refused stale-baseline when the block itself has changed since the draft's baseline. When other writers have written since, but not to this block, the commit is accepted and the save names those writers; the number shown beside each, worded as records since the save's baseline, is that writer's latest record number, not a count of the records added since. A commit the core refuses (stale-baseline, working-version-changed, changed) is shown as an error naming the refusal and its clauses, and says the text is still in the file and has not been saved; nothing is merged for you. Before anything is sent, a save is refused for a byte-order mark, bytes that are not UTF-8, a file on disk that differs from the editor, or a changed heading.
"Reconcile Block" is for a block file holding a version neither this window nor the store wrote. If the file still begins with the block's heading, it keeps the text as a draft against the store without asking. Otherwise it offers two choices -- keep my text, with the block's heading in front of it, or take the store's version -- and publishes a new version either way; nothing is deleted.
Right-clicking a node and choosing "Open as Document" composes the block and everything under it into one read-only markdown document. The opened block's heading is level 1 and each level under it one deeper, down to level 6; headings inside a body are shifted down with it, and each block is preceded by a <!-- theourgia block <id> depth <n> --> marker. A block that is deleted, cannot be placed, appears twice or is not text refuses the whole document rather than leaving a gap. The document is composed again each time the command runs.
The tree has a second mode, Files, showing the directory tree that export would write, with a group for blocks that are in no file. A store whose root blocks carry paths opens in Files mode; "Show Files" and "Show Outline" switch, and the choice is kept per store. "New File Here" creates a root doc block with that path (.md appended) and title. "Move to Directory" and "Rename File" read the block's version when they run and set its path with --if-unchanged: a block that changes before the answer is refused, and the view refreshes.
A text-mode code block opens as its source in the language its lang field names, or as plain text without one. A datum-mode block -- a library import-code --datum made, or one definition in it -- opens read-only: the library's file as export-code --datum writes it, at the block's own place, with a note saying why. The extension cannot write a datum block yet, and nothing is written or committed for it; Go to Definition on a datum definition opens the same view at its (define ...). "Go to Definition", as a command and as the editor's own, asks the store's whereis which block defines a name, offers a choice when several do, and the nearest names when none does. "Suggest a Split" asks the core where a source file on disk could be divided into blocks, using the editor's own symbols for the cuts when it has them and the language's patterns otherwise, and opens the review file the core wrote; nothing is recorded in the store.
Resting the pointer on a name in a block's file, a composed document or a datum view adds, beside the language's own hover, what the store holds about it: blocks that link to the block under the pointer or to the block that defines the name (with the relation), blocks that refer to them in their text, and prose blocks -- documents, sections, decisions, tasks -- that mention the name as a whole word. Each line gives the title, the kind and the first sentence, and opens the block; past five lines, the last one lists them all. The hover only reads, from the store the document came from, and its answers are kept for fifteen seconds, or until this window saves, changes the tree or its settings.
"Search Blocks" asks for words that must all match: one hit opens straight away, several give a list with scores. "Show Store Status" and the status bar show the store, actor, conflict count, pending and blocked saves. "Other Sessions" lists the unsent saves another window left behind, to take over or discard. "Migrate Legacy Block Files" moves verified block files of an earlier version into a recovery archive. The store is checked with check each time the extension connects to it -- at start and after a settings change -- and a bad verdict is warned about once per session; the extension's log is the "Theourgia" output channel.
When a writer's log cannot be read, the outline shows the blocks the other writers' logs can still place -- a block whose records depend on the unreadable writer's stays pending and is not shown -- and says which one is missing, the path and the reason. The note is carried by the outline, the status bar, search, Go to Definition and the banner of an opened block or document, and it belongs to the last reading: the next complete reading clears it.
Three commands hand the store facts that the editor's language support computes: "Theourgia: Supply Signatures and Keywords", "Theourgia: Supply Calls" and "Theourgia: Supply Diagnostics". Each projects the store's code with export-code into the extension's own storage, asks VS Code's providers for that language (symbols, hover, call hierarchy, diagnostics), and hands the facts to the core with supply, which keeps them beside the blocks with the editor and version they came from. The language's own extension must be installed: for C, clangd.
Signatures, keywords and calls are taken from the committed store. A block's signature is the detail of its most representative top-level symbol -- a function, method or constructor, then a type, then anything else -- else the first line of code in that symbol's hover; a call into the same block gives no edge. Diagnostics are theourgia.writer's, taken from its working view, and are collected once the analysis has been quiet for a second, at most after ten; a supply taken at the cap says the analysis may be incomplete. Facts are grouped by VS Code's language id, and VS Code files .h under C++, so a header's facts sit in the cpp table. A run stops if a projected file or document changes, or the store changes, while it is collecting. The supply file is removed afterwards, except one the core refused supply-malformed, which is kept to be read.
An agent reads the facts through MCP; from the command line they come back from read <id> --signature, refs <id>, reach <id>, search <word> and diagnostics --writer <w>. Each answer names the source of its facts (via) and how many of them are stale (stale). The facts are as fresh as the last supply: after a source changes, supply again.
1.0 does not show these facts inside the editor; that is a later release.
Packages are built for macOS on Apple Silicon and on Intel, and Linux on x86_64 and arm64. The core has a measured row for each of them. The extension takes a file lock through a small native module (flock) built on each target's own runner. There is no Windows package.
Two agents on one writer id: silent overwrite, no detection. The rule is in the documentation; the code does not enforce it.
Two machines on one store: not supported. A store belongs to one machine's registry; moving it to another requires adopt.
Platforms: only those with a measured row run -- macOS on arm64 and on x86_64, Linux on x86_64 and aarch64 with glibc, FreeBSD on amd64 (measured on FreeBSD 15; the row is chosen by machine type, not by release). Anything else exits 75 with platform-unmeasured; the remedy is to run test/probe/layout.c there and add its row.
Exports at a cut: export-md and export-code take --cut, resolved and judged as read --cut is, and their answer names the cut served. A past cut has no working export: --cut with --working or --writer is refused (incompatible-cut-options).
Runners (--lang): the Scheme evaluator runs in a sandboxed child process with no filesystem and no network. A runner for another language (javascript and typescript with node, python with python3, shell with sh, go with go run, rust and c compiled and then run, java with its single-file launch, or chez, which runs Scheme outside the sandbox with the store's libraries on its path) gets a projected copy of the store's code files in a temporary directory and the machine's own tools, so it has the reach of a local script. Runners are off by default (THEOURGIA_RUNNERS=on).