ADR-0067 Architecture decision record
An Effect is an actor slot, and runs at most once unless marked idempotent
An Effect is work a Machine does outside itself. A Machine already runs Agents and Gates as actors (ADR-0049); work such as running the tests had no place of its own, so an author either asked an Agent to do it (and trusted its word) or wrote a raw xstate promise that a restart ran again. jr2 builds four kinds: command, run a program in the Workspace; http, call a URL — with a JSON or text body, or a Worktree file as its body; push, push the Workspace's branch to its Repo Slot's Binding; and dispatch, start a run of a registered Workflow, on this Orchestrator or another's (ADR-0071). An Effect that holds a secret runs in an Effector (ADR-0068). A command whose env names a secret — the credentialed command — runs there too, its child confined (below). A dispatch with no target runs in the Orchestrator's own process, the one Effect that does: it starts the run through the run host and holds no secret.
Decision
- An Effect is an actor slot beside
agent().actors: { tests: command(["pnpm", "test"]) }, invoked assrc: "tests", with anonDonethat routes on its output. xstate gives the rest: the Effect stops when its state exits, its input persists with the snapshot, asrctypo is a compile error, and.provide()is the unit-test seam. The slot carries its parts as plain data — kind, placement, timeout; acommand's argv, Repo Slot and the secrets its env names; anhttpEffect's method, fixed host, the names of the secrets it names and whether its body is a Worktree file; apush'spin,sign,squashandforce— whichjr2 upprints and the Machine doc carries, read without running anything. A packaged Machine may leave anhttpurl (whatever its body) or acommand's argv Open (openin its place), and the name of one secret its auth, a header or a command's env names (secret(open); never in a url), for the composer to bind once withcustomize(machine, { effects: { <slot>: { url } | { argv } | { secret } } })— one object with both keys for an Effect with two Open parts (ADR-0054); the slot then carries the Effect built again with the bound parts, and an Effect still Open runs nothing: its state'sonError. An Effect written inline (invoke: { src: http({...}) }) is refused at build and at load, with the slot form in the message: xstate gives it a generated key that moves when a state is renamed, so the ledger, the report and the Machine doc would name it by a number, andcustomize()—provide, keyed onactors— could not reach it. The same rule holds foragent()andworkspace()(ADR-0049): a Part is a key ofactors, and every Effect kind is one (the brandisEffectreads). - Between a pick and its work:
fromPick,paramsOf,answer. All optional; a plain mapper is legal.fromPick(def, fill)is theinputof a state a pick enters: the pick's params flow into the Effect's input by name,fillreturns only what the Machine adds, and the sum is checked against the Effect's input type — the security boundary in one expression (what the Agent supplies, what the Machine adds). The type check catches a missing or mistyped key; it accepts an extra one, so the load walk refuses a param that is no key of the input (below). An Open argv's input is one string per key, so the type check catches neither for it: a slot the bound argv names that the input does not supply faults when the Effect starts (ADR-0054). The state a pick enters is a child of the Agent's state when the Agent must read the Effect's output as its answer, or a sibling when the pick ends the Agent's work (the Turn ends before the Effect runs, and no Agent reads the output). A child state is necessary but not sufficient: the route after the Effect must also stay in the Agent's state (onDone: "ready"), because a route that leaves it ends the Turn when the Effect ends, and no Agent reads the output. ThefromPickdocs show both shapes, the child one with a route back toreadyand afinishpick, because one shape alone left the author to guess the other. The alternative, a child state whoseonDoneleaves, is rejected for the example: it behaves almost as the sibling does, and an author who copies it to see a result gets nothing.paramsOf(event, def)reads the same params for a plain mapper.answer(({ context, event, chain }) => …)is an xstate action that sets what the Agent reads when its pick is answered (ADR-0024);chainis every reply since the pick, oldest first, each a link typed by its slot ({ kind: "output", src, output }) or by the Machine's events ({ kind: "event", event }); its order and length are not typed. A link is a reply from outside the Machine; the events it sent itself are skipped. The value is JSON on the wire and in the hold; one with no JSON form sets nothing. Ananswershapes only the pick of the Agent whose state it is written below (on a state's entry or exit, or on a transition of a state, at or below that Agent's state). On a transition below no Agent's state it shapes the pick of the Agent whose event took the transition — the sender of a pick, or the Agent whose pick started the child whose done or error event it is — and the other Agent's pick keeps its default answer; when one Agent slot is invoked in two regions, it shapes the pick at the same invoke as the pick that sent the event or started the child, and none when that pick is not being answered; an event that names no Agent shapes the pick in its own send, and outside one shapes no pick while two Agents' states are active; on an entry or an exit below no Agent's state it sets nothing. One action object written in several places runs from each by that place's rule alone, never by their sum (ADR-0024): as each Machine's actor is created, before its first state is entered, the run host gives each place a copy of its own (placeAnswers,packages/orchestrator/src/pick.ts). AnansweranenqueueActionsenqueues runs from the place the enqueuing action is written: the copy given to that place hands each action itscollectenqueues, at any depth, the same seat. The load walk cannot see inside anenqueueActions, so one enqueued on an entry or exit below no Agent's state sets nothing and is not warned. That writes xstate internals — a state node'sentryandexitlists, theactionsof the transition objects xstate selects fromtransitions,alwaysandinitial, and anenqueueActions'scollect— as ADR-0007's re-arm reads the timer table; raw-xstate tests that pin those shapes are the canary for an xstate bump. A child's error is no link, and by default the Agent is not told (ADR-0024); an author who wants it told writesanswer(...)on theonErrorroute. An Effect never takes that route for an outcome: every outcome is output. A Machine that decides from an outcome that its work did not succeed fails withfail()(ADR-0073), whose Failure also arrives ononError, at the invoke of a child Machine;isFailuretells it from a defect. - argv, never shell text. Each entry is one argument;
arg("x")is one argument filled from the invoke's input. The Harness spawnsargv[0]with no shell.sh -cis the author's explicit choice, in the argv, and its result is not a trusted verdict. - Placement follows the kind and what it names; it is never authored. A
commandthat names no secret, anhttpEffect whose body is not a Worktree file, and apusheach have one place: the Harness container, the Instance Effector, and the Sandbox Effector of the Workspace whose body invokes it. Acommandthat names a secret, and anhttpwhose body is a Worktree file, are placed in that Sandbox Effector — the command runs there with its child confined (below). Adispatchwith no target runs in the Orchestrator's own process, the fourth Placement,orchestrator, and the one Effect that has it; with a target it runs in the Instance Effector (ADR-0071). There is noplacement:key and no kind per placement: naming a secret places a command, the body places anhttp, and the target places adispatch— one name per thing, so there is nouploadkind beside it (ADR-0068). - A
commandthat names no secret runs in the Harness container of its Workspace's Sandbox, as a child of the Harness process: the Agent's user, the Sandbox Image's tools, the same Stand-ins as the Agent'sbash(ADR-0059), and no credential of its own. The Harness serves it on/exec/:id, behind the same bearer as every Harness route (ADR-0058); the Instance Harness holds no Workspace and refuses it (ADR-0031). Outside aworkspace()a command is refused at invoke. Its cwd is a Repo Slot's Worktree: the one slot, or the slot it names (slot); several and none named is refused (ADR-0051). In a Workspace with no Repo Slot its cwd is/work, which the Workspace's steps share — named in the start, never left to the Harness, whose own cwd is the Sandbox Image'sWORKDIR. - Every outcome is output:
exited | timeout | killed | unknownfor acommand(killedwith the signal that ended it; a stopped credentialed command's isexitedwith the stop's signal, D1);response | unreachable | refused | unknownfor anhttpEffect;pushed | rejected | diverged | unknownfor apush. A command not found isexited127. A start over the bytes an Effector reads (ADR-0068) is sent nowhere and settles as its kind's own outcome — anhttprefused, apushrejectedat stagestart(nothing pushed), a credentialedcommandexited127 with the reason in its tail, the Effector's own form for a command that could not start — since an Agent's param (a squash message, an argv part) can reach the bound; a path segment that is.,..or empty, and a file body's path that is a symlink, leaves the Worktree, is absolute, is a FIFO or has more than one link, arerefusedwith nothing sent — an Agent's param can cause each.onErroris only a jr2 or config defect: no Workspace, an argv slot with no value, an input that misses the definition's schema, no Effector to send to, an Open part nobody bound. - An
httpEffect is a definition plus one function.http({ method, url, headers?, auth?, input?, request?, body?, timeout?, maxBody?, idempotent? }). The url's scheme and host are literal — a secret, named withsecret("name"), may sit only in its path, through thetexttemplate, and one after a?or a#is refused when the Machine loads — so the host is fixed by the definition and never a param. A url left Open is fixed by the composer'scustomize()instead, once and before any run, under the same rules (ADR-0054); a file body does not change that rule.authisbearer(secret(…)),basic(user, password)or atext. A secret the auth or a header names may besecret(open), whose name the composer binds once in the same way; one in the url is refused.request(input)returns the run's part alone:pathsegments and a JSON or text body. So an Agent's param reaches a path segment or a body, never the host, a header or a secret. It runs in the Instance Effector, which builds the request and holds the secrets (ADR-0068); the Orchestrator signs the call and holds none. Its body may instead be a Worktree file,body: file(path, { slot?, segments?, contentType? }): the file's path relative to the Repo Slot's Worktree (the one slot, or the oneslotnames) — or to/workitself in a Workspace with no Repo Slot (ADR-0051), the folder its steps share — and the url's path segments — each a value or a function of the input; norequestis written beside it, sincefile()carries the run's part. Such anhttpis placed in the Sandbox Effector of the Workspace whose body invokes it, andjr2 uprefuses one that noworkspace()invokes, where no Worktree exists to read. It is sent withPUT,POSTorPATCH. The Sandbox Effector opens the file withopenat2beneath the work root —RESOLVE_BENEATH,RESOLVE_NO_SYMLINKS,RESOLVE_NO_MAGICLINKS,RESOLVE_NO_XDEV, non-blocking — thenfstat: a symlink at any component (one that stays inside included),.., an absolute path, a FIFO, a directory and a file with more than one link are refused, in words, as output. The content type isfile()'scontentTypeor acontent-typeheader of the definition's, not both: a definition with both is refused when the Machine loads ("write one of them", as forauthbeside anauthorizationheader). With neither it isapplication/octet-stream. A later body form (a multipart file and fields) is one more body onhttp, never a kind. - A credentialed
command:command(argv, { env: { NAME: secret("x") | secret("x").path }, pin? }). Naming a secret is what places it: it runs in the Sandbox Effector of the Workspace whose body invokes it, with noplacement:key — and so does an env that namessecret(open), whose name the composer binds (ADR-0054). Its child runs as the Effector's uid beside the Effector's key, the secrets it does not name and the push credentials, and its argv may run a file the Agent wrote, so the Effector confines the child with Landlock beforeexecve(ADR-0068): it may read and run the image's system paths, read and write its own scratch (itsHOMEand itsTMPDIR; never/tmp, which every child would share), and read the secret files it names — nothing else. A node whose kernel cannot confine it runs none: the Effector of a Workspace that holds one does not become ready there, and the provision fails naming the node (ADR-0068). It runs against one commit: the Agent's branch tip when it starts, or — withpin— the commit the Effect's input names ({ sha }, one a Gate approved). That commit is checked out into a fresh scratch of the Effect's own by the push's import procedure (below), so the Agent's uncommitted edits are never seen; the answer carriesdirty: truebeside the output when the Worktree held some (a status in jr2's clean repository over a copy of the Worktree's index, against the Worktree's own HEAD — never the pin, so the commits the Agent made after an approved one are not edits — read as data; when it cannot tell, it says dirty). The child's env is what the author named — a secret's value, or its file's path — plusPATH,HOMEandTMPDIR, and nothing else;PATHis the Effector container's own, as its image set it (the tools are the author's), andargv[0]is looked up there;HOMEandTMPDIRare the scratch's, and the scratch is removed once the outcome is read. Its output is scrubbed as it streams, before it is cut to its tail (ADR-0068). The Agent's files are the author's choice to run — a tool's plugins, alocal-exec, acredential_process— so "no program the Agent's files name runs" is not claimed for it. Its claims are three: the Agent never reads or spends the secret (a container it cannot exec in, and a child confined from the files of every other secret and of the Effector's key), the tool sees a pinned commit and not the live Worktree, and the output is scrubbed. Landlock governs files, notconnect(), and a GPG-signed push holds the signing key on agpg-agentsocket while it signs; so the Sandbox Effector never runs the two at once: one lock over two classes,gpgandcommand, and a waiter that settles timed out past its own timeout (ADR-0068). A Workspace may hold both. A Workspace with no Repo Slot has no commit to run it against, so there it is refused — byjr2 upand at invoke, with the fix: declare a slot, or name no secret, and it runs in/workbeside the Agent (ADR-0051). A run of the live files under a credential is the claim this kind exists not to make. - A
pushpushes the Workspace's branch to its Repo Slot's Binding, from the Sandbox Effector, with no input:push({ pin?, sign?, squash?, force?, slot?, timeout? }). Its credential is the push credential of thegit.credentialsentry the Repo Slot's url falls under (ADR-0051): the provision matches the url the run binds — static, per-run orcustomize()-bound, one path — and names that entry's push Secret on the Sandbox, and the Effector, which holds only the entries named there, matches the push's url as the fence does. git never runs with the Agent's repository as its repository: each call makes a new bare repository in the Effector's scratch, configured by jr2 under a cleared environment; it reads the Agent's branch as data (a loose ref orpacked-refs, opened beneath with no symlink, bounded); it imports the Agent's objects as data — onepack-objectsover the Agent's object store with a deadline (a FIFO in place of an object blocks an open forever),index-pack --strict, and a connectivity check — borrowing only from the node's Repo cache; and it pushes<commit>:refs/heads/<branch>to the Binding url, never to a remote of the Agent's config, and never to a local path (git's local transport runs that repository's config and hooks, and a path in the pod can be the Agent's own repository; only the binary's tests can allow one). So no config, hook, attribute or program of the Agent's runs; a test plants each in the Agent's repository and proves none ran. A token goes Basic over https through a credential helper only — anhttp://url with a token isrejectedwith nothing sent — and the helper is the Effector binary (effector git-credential), which reads the token's file when git asks for the Binding's own host over https and answers nothing for any other; the clean repository follows no redirect, so neither the push nor the token reaches an origin outside the entry; an ssh key is copied into the call's directory (a Secret mount's mode is one ssh refuses), withknown_hostschecked strictly. The commit is pinned when the push starts: the Agent's branch tip, or withpinthe commit the input names ({ sha }); the Effector's first answer names it, and it is written to the intent row. A pinned commit the Agent pruned fails the import and is never substituted.squashmakes one commit with the input's{ message }, on the published base: the Agent's tree, its author line and date, the Machine's message. It is a new commit, so it needs a committer. Withsign, the signer is the committer, as for every signed copy. Without it (signing is optional, andsquashis an option of its own), the matchinggit.credentialsentry'scommitter: { name, email }commits it, at the Effector's clock — or, when the entry names no committer, itssignfield's name and email.jr2 uprefusessquashwithoutsignonly when the matched entry has neithersignnorcommitter, naming both fixes (acommitter, or a signed push and itssignfield), and the provision refuses it the same way for a slot the run or acustomize()binds.forcereplaces what the remote holds. A Workspace with no Repo Slot has no branch to push, so apushthere is refused, byjr2 upand at invoke (ADR-0051). sign: nothing unsigned leaves. The Effector re-creates the Agent's commits, each signed with the entry'ssignkey — ssh (ssh-keygen -Y sign) by default, GPG allowed; a GPG key with a passphrase is refused, by name. The author line, its date included, stays the Agent's; the committer is the entry's name and email at the Effector's clock. The new commits are found by ancestry: the published tip must be an ancestor of the Agent's tip. When it is not, a read-only fallback pairs the published commits with the Agent's —pair, the newest of the ledger's pushes whose published commit is the remote's tip (its published commit and its source), thencherry, each published commit after the merge base paired with one Agent commit by a stable patch-id, author line and message (a merge by its tree and its non-first parents as mapped by the pairs made before it, the rule the map below keys a merge by) — and when nothing pairs cleanly the push isdivergedand nothing is pushed — withforcetoo:forcereplaces a remote branch that moved, and never stands in for a pairing. One case is neither: a squash push whose published tip is this squash's exact image — the source's tree, author line and encoding, the Machine's message, as its one parent the newest pair's published commit (on a first push, the merge base with the base), the committer name and email of jr2's squash committer (the signer withsign, else the entry'scommitter, above), and withsigna signature that verifies against the slot's signing key — is this push's own commit, sent again by a restore after the Effector lost it while the push in flight had no settled row; it settlespushed,unchanged, with the sync bundle and its ownsquashed. A full comparison of those fields, not a pairing. Dates and signature bytes are not compared: the restore sends the push at a later clock, and a signature need not be deterministic. A tip with this squash's tree, parent, author line and message under another committer, or withsignand no signature that verifies against the slot's key, is not jr2's own: the push isrejected, with no sync bundle and nothing pushed, and its reason says which. Then, on every push and before anything is signed, the same map runs over the new commits, oldest first, and a commit that has a published twin is replaced by that twin in the rewritten history; only the unmapped commits are signed. The twin is a ledger pair, taken as it is — each names the one exact commit a push published for its source, a signed copy or a squashed commit; the pairs of every push of the Repo Slot are read, each only while the remote still holds its published commit, the newest push's when two name one source — or else a published commit after the commit's merge base with the remote's tip, each taken once, that has the commit's cherry key, read with the commit's parents as mapped so far (a merge of the Agent's own side branch keys on the published copies of its non-first parents), and is a faithful image of it: the commit's tree, and as parents the commit's own parents as mapped so far. Every commit the remote lacks must be one the call signed, or the push isdiverged.pushedcarries the published commit, its source, what the remote held before, how the new commits were found (ancestry | pair | cherry),unchangedwhen the remote already held it,newCommits(how many commits the published commit adds to what jr2 found held, the remote's branch and the Repo cache's refs as the push read them;0when jr2 found the published commit already held — the remote's branch or the Repo cache),squashed: signed | unsignedwhen the published commit is one squashed commit (absent for signed copies; it names what the published commit is, not what the push's options ask for: a commit the call made is named by its options, and the published tip that an earlier push made, whichpairorcherrymaps, by that push's ownsquashed, which its pair carries), and — whenever the published commit is not the Agent's own — the published commits as a bundle for the sync step (git bundle createof the published tip, with the Agent's tip as its prerequisite: the new commits, and the trees and blobs git adds beside them, which the Agent's store may already hold). A push that publishes nothing new carries one too: whenpairorcherrymaps the published tip itself (a restore that sends a pinned push again, a push after a sync that did not finish), or the published tip is this squash's own (a restore that sends a squash push again), the Agent's branch still holds its own commits. The bundle never reaches the Machine. A push sends every pair the ledger holds for its Workspace and Repo Slot — one branch on one remote — oldest push first (pairs, omitted when there is none): each push that published, with its published commit, its source and itssquashed; the Effector stays stateless. The pair stands for the published tip only while the remote still holds that push: a remote that moved past it (another writer) is paired bycherryor isdiverged, never grafted onto. The Agent is never told to rebase: a rebase repair loses a reworded message and duplicates empty commits and merges. A published commit is never signed twice, for every signer and key type: a side branch the Agent made before the push and merges later carries the unsigned original of a commit the remote holds signed, which ancestry calls new, and the map replaces it by its twin — a merge the Agent made before the first push included, and, through the ledger's pairs, a side branch made before a squash and merged by any later push, whose commits the squashed commit stands for: the squash's pair maps its source to the squashed commit however many pushes came after it, so a side branch merged by one push and a branch made on it merged by the next publish only what is new. The pair maps a squash's SOURCE only, and that is a named limit: a side branch made at an earlier commit of the squashed range publishes the commits it descends from as signed copies beside the squashed commit. Those commits were never published, none is signed twice, and the trees are the Agent's; such a commit has no faithful twin, and mapped to the squashed commit the push would publish a false diff. The committer date stays the Effector's clock; a deterministic re-sign (the Agent's committer date) was rejected, since it rests on one key type's property, not GPG's or ECDSA's. A key alone does not pair: a commit the Agent reverts and applies again with cherry-pick has the key of the first one, and the first one's published copy has older parents, so paired with it the push would offer that older copy as the new tip —rejectedas non-fast-forward withoutforce, a rewind of the remote with it. The faithful image is the rule; the cherry fallback keeps its own, that the last paired commit holds the published tip's tree. The map's cost is bounded by the push's size.- The sync: after every push whose published commit is not the Agent's own, the Agent's branch moves to it — signed copies, or one squashed commit, signed or not; the decision keys on
published≠source, never onsign— in the Harness container (POST /sync, behind the Harness bearer, ADR-0058), from the bundle the Effector wrote, which the Orchestrator relays — never a shared volume: the Worktree stays read-only on the credentialed side. Under a cleared environment and a config that names no hook, no fsmonitor, no alternate-refs command and no maintenance, the Harness verifies and unbundles the bundle (objects only), checks that the published tip is a commit with the source's tree (it reads no signature), answersbusywhen a rebase of the branch, or a merge, cherry-pick, revert or sequence in a worktree whose HEAD is the branch, is in progress, and otherwise copies each commit the Agent made after the source as its raw object with only its parents changed, then moves the branch with onegit update-ref <new> <old>— a compare-and-swap, tried again from the new tip at most 3 times — so files, index, HEAD and stash do not change. Its answer is a field of the push's output beside the outcome:sync: synced | already | skipped | busy | not-synced, withsyncReasonwhen it moved nothing (a push that published the Agent's own commit isskipped, with no call and no bundle; every other push is synced, one that published nothing new included, so a plain push of the slot after a squash is a fast-forward of the squashed commit). A Harness that cannot be reached answersnot-synced; the push stayspushed. When the last push of a Repo Slot answeredbusyornot-synced, jr2 runs its sync again before that slot's next push, in that slot's Worktree and with that push's bundle, which its row keeps until a sync finished or a newer push of the slot published. The push never trusts the sync's answer: the Agent owns its repository and can move the branch at any time, so the next push derives everything again from the remote and the Agent's objects. After such a push the Agent reads, beside the output, what moved — signed copies of its commits with new ids, or its commits squashed into one commit, named "signed" only when it is — and that jr2 moved its branch to it, or did not and why; that its files, index and stash did not change; and that amending, rebasing or resetting the pushed commits makes the next pushdiverged. The Harness keys that paragraph on a synced push whose published commit is not the Agent's, and its words onsquashed. A push in which jr2 counted no new commit (newCommits: 0) is stillpushed, because the push ran and the remote's branch may have moved (a new branch at a commit the remote held on another branch). Butpushedalone does not tell the Agent that its work did not go out: in a real Haiku 5.5 run, the model sent agit committhat failed and the push in one answer, the push published the branch at a commit the remote already held, and the model readpushedas its work published. So beside the output the Agent reads that jr2 counted no new commit in this push, that it found the published commit already on the remote or in jr2's copy of the remote, and that a change it did not commit before the push is not in this push. The words name where jr2 looked because the count reads the Repo cache, which fetches without pruning: a commit the remote dropped can stay there, and then a count of 0 is not a fact about the remote, which is why the first clause names what jr2 counted. No @model claim reachesnewCommits: 0, so no measurement has read these words. When the signed-copies or squash paragraph above also applies, it names "an earlier push" as the one that signed or squashed, so the two do not contradict. The Harness keys the sentence onnewCommits: 0alone, and says nothing with no count. The count is optional on the wire: a live Sandbox keeps the runtime it started with (ADR-0037), so afterjr2 upits older Effector answerspushedwith nonewCommits, and a required field would fault a push that reached the remote. The count's input togit rev-list --stdinis revisions only (^<sha>for each tip the remote held), never--not: git takes an option there only from 2.42, and the Sandbox Effector runs its image's git — the Sandbox Image's, unless theworkspace()names one — which can be older (Debian bookworm's is 2.39). A distinct outcome (unchanged,up-to-date) was rejected: every consumer of a push keys onpushed(the ledger's pairs, the sync, the Machines' guards), and a push that made a new branch did change the remote. - The process group ends with the exec. Each exec leads its own group; its timeout, a kill, and its top process's exit each SIGKILL the group, so nothing that stays in the group outlives it. In the Harness container a descendant that leaves the group (
setsid) is not killed; it holds no credential. A credentialed command's descendant cannot leave: its Effect's keeper and the Sandbox Effector are subreapers, and every process an Effect started, asetsidescapee included, is killed and reaped before the Effect settles, while a live command's daemon is not another Effect's to kill (ADR-0068). A descendant that keeps the output open does not hold the outcome. A bounded tail (default 4096 characters) is the output; the full stream goes to the run's feed (Instance-token band). - A write-ahead ledger; no second fire the author did not mark. One row per Effect in the run's blob (ADR-0007, ADR-0065): an
intentrow saved at the write, with the snapshot that holds the Effect, before the request leaves; asettledrow with the output, saved at the write just before the transition it drives and kept by the save that carries that transition, so a restart that loses the transition's save still delivers the output and runs nothing. On restore: settled → the output is delivered; no row → nothing was sent, so it starts; intent → per kind. Acommandthat names no secret re-attaches to the exec by id, or settlesunknownwhen the Harness no longer knows it (it restarted); it is never run again by jr2: it runs the Agent's code, which may spend a Stand-in. Apushintent row names its Sandbox and, once the Effector's first answer names it, the pinned commit: a restore asks the Effector for the id and follows it, and when the Effector no longer holds it the push is sent again with only that commit — never the Agent's tip now — because its run is a function of the commit and its credential, what the intent row records; with no commit recorded it settlesunknown. A credentialed command follows the push's rule: its intent row names its Sandbox and, once the first answer names it, the pinned commit, and one the Effector lost is sent again with only that commit, since its run is a function of (commit, argv, secrets). Anhttpintent row names its placement — the Instance Effector, or the Sandbox of a file-bodyhttp— and no replica: the Effect asks every replica of that Effector for its id and follows the one that holds it; when none does, it is sent again only when the author marked itidempotent, and any other settlesunknown. Retry is the author's choice — a route back into the state, oridempotentfor a call that carries its own idempotency key or only reads. No row is dropped: each settled or aborted row keeps the Effect's id, kind and outcome for the run's life, the record of what the run's Effects did. A settled row's output tail is dropped once the save that carries its transition is on disk; the full stream is on the feed. Anhttpresponse's body and headers are its tail: the row keeps the outcome, the status, the content type and the size, and the settled line on the feed carries the whole response. Apushrow keeps its Repo Slot, its published commit, its source, itssquashedand its sync's answer whole — every later push of its Workspace and Repo Slot sends them as one of its pairs, and the newest push's sync, when it did not finish, runs again — and drops git's words; it drops its bundle once its sync answeredsynced,alreadyorskipped, and keeps it while the sync isbusyornot-syncedonly as long as it is the newest push of its Repo Slot that published, because the sync that runs again moves the branch from it and only the newest push's sync runs again. Once a newer push of the slot published, the older row's bundle goes at the next save: one bundle per Repo Slot at most. So an Effect in a loop grows the ledger by one short row per pass, never by its tails. One exception, bounded by one pick: while a pick is outstanding, its hold keeps thechainwhole, tails included, because anansweraction may read it after a restore; a loop below the Agent's state then grows the hold by one tail per pass. The hold drops its chain when the pick is answered. - A start is sent once where it may have arrived. A Harness runs one id once only within its own process; a restarted Harness knows no id. So the Orchestrator sends a start again only when it certainly never left (the connection was refused, the name did not resolve). Any other failure — a reset, a 5xx, no answer — may follow a start the Harness ran: the Orchestrator reads the exec by id instead, follows it when the Harness knows it, and settles
unknownwhen it does not. It then sends a kill for that id, which keeps a start still on the wire from running. Anhttpstart follows the same rule over the Effector's replicas: one that was never reached, or that answered it is stopping (it starts nothing then), is sent to another; any other failure asks every replica first, and the restore rule above decides when none holds it. A replica that stops answering for an Effect it was followed on — gone, or restarted — is the same case. - D1: an Effect is stopped when its state exits. A
commandthat names no secret: the exec's group is killed. The kill is sent again until the Harness keeps it, for at most the command's timeout (past it the Harness's own timer has ended the group); a kill that never reaches it is said on the feed. A fast exit can send the kill while the start is still on the wire: the Harness keeps a kill of an id it does not know, and the start that arrives after it runs nothing. A credentialedcommand: when its actor stops before its process ends — the state exits, or the run is cancelled — the Orchestrator sends oneDELETE /effects/<id>on the Effect's own path to its Sandbox Effector, signed like every Effector request (ADR-0068), so nothing in the Harness container can send it. The Effector sends SIGTERM to the command's process group, waits 5 s, then sends SIGKILL, and runs its settle loop (ADR-0068's subreaper rule), so no process the command started outlives it; the Effect settlesexitedwith the signal the stop sent last — SIGTERM, or SIGKILL past the wait — and, when the program caught SIGTERM and exited, with its code too. A stop that comes before the program starts — while the command waits for a GPG-signing push of its Sandbox Effector to end, or while its pinned commit is checked out — signals nothing: the Effect settlesunknown, "its state exited before the command started; it did not run". What the DELETE answers is said on the feed after the abort's line: "its Sandbox Effector stopped it: exited with SIGTERM"; "its Sandbox Effector stopped it:" and the Effector's reason, for one that did not run; the outcome it had already ended with; that the Effector had not settled it when the stop answered, outcome unknown; that no replica held the Effect, so a start still on the way runs nothing; or that the stop did not reach the Effector and the command may run until its timeout. A run that has ended (a cancel, a final state) has no feed: the line goes to the Orchestrator's log, as does a kill that never reached a Harness. The abort goes to the ledger (aborted, saved with the transition that exited the state — a cancel's final save carries it) and the feed, "outcome unknown"; the Machine does not get it — the state that asked has left. AnhttpEffect has no stop route: its state's exit stops the polling, and the abort goes to the ledger and the feed the same way, "the Effector may still send it; outcome unknown". The Effector finishes the call and drops an outcome nobody reads. A file-bodyhttpand apushhave none either: each is one request that ends on its own, and one a state exit cut runs on in the Sandbox Effector to its end; the abort says "the Sandbox Effector may still run it; outcome unknown". Two stops are not exits: the host parking the run (hostStopping, ADR-0024) and an Orchestrator shutdown (it stops no actor). Neither stops a command; the Effect then re-attaches on restore, or settlesunknown. There is no "finally": cleanup is a state. - Must-finish is a pattern. An Effect that must not be cut goes in its own state, whose only exit is its
onDone, and that state handles the ancestor's events itself. - No fire-and-forget form. Two patterns keep D1: an Effect in its own state; or a second invoke with no
onDonebeside the state's work — it fires on state entry, a fast exit can cut it, and below an Agent's state it holds Rest until it settles.spawnChildis not used for an Effect: it is not stopped on exit, it runs again on restore, and it is orphaned after a final state — each breaks D1 or the ledger. Adispatchwithoutwaitis not the exception it looks like: the Effect is the START, which settles when the run is accepted; the run it started is a run of its own, not the Effect's child, and D1 never reached it (ADR-0071). - Rest counts an Effect like any child. A running Effect below an Agent's state holds the Agent's pick (ADR-0024); a settled Effect with no
onDoneis Rest. An Effect is not a long-lived invoke, and the load walk does not warn on one. - The load walk checks what a pick hands an Effect (ADR-0015): a pick param nothing reads — per state, so any invoke of the state may read it, a second invoke beside the Effect included (with
fromPick, one that is no key of the Effect's input and thatfilldoes not read; a guard on the entering transition and anassigncount as reads; a pick enters what an eventlessalwaysmoves on to; across anafter, only a guard orassignbefore the timer reads it; a Gate's event is no pick and is not checked) and afillthat overwrites a param are refused; code the probe cannot or does not run — a mapper that throws in it, an action other than anassign— and a pick that targets a history state that may enter an Effect's state are a warning; a state below an Agent's state that invokes something and that nothing enters is refused; and anansweron an entry or an exit below no Agent's state, which shapes no pick, is a warning that names the Agent states it could be moved under. An Open argv's slots are unknown when the Machine is built, so every param counts as read by it then;customize()runs the pick-param check again when it binds the argv, refuses there a param the bound argv does not read, and gives the bound Machine the warnings the walk gives for that argv (ADR-0054).
Considered options
- Run every command in the Sandbox Effector. Rejected: a command that names no secret runs the Workspace's own code with the Sandbox Image's tools and the Agent's user, and gains nothing from a container the Agent cannot reach. Only a command that names a secret is placed there, because a tool that signs with its credential (
terraform apply,awswith SigV4) cannot be given a Stand-in (ADR-0059); there its child is confined from the Effector's mount (above). - A
placement:key on a command. Rejected: naming a secret is the placement, and a key could disagree with it. - A trailer on each signed commit naming its source. Rejected: forges show it, and the map must be read off every published commit or an unsigned one leaks; ancestry, the sync and the read-only fallback need no stored map.
- Take a command as a shell string. Rejected: an Agent's param in a string is a shell injection.
- Repeat a command whose outcome is unknown. Rejected for a command that names no secret: it may have acted (a push from a script, a spent Stand-in), and its run is the live Worktree's, which no row records. The Machine gets
unknownand decides. A credentialed command runs against a pinned commit its intent row holds, so a restore that found no Effect sends it again with that commit (above). - Sync through a volume the Effector writes and the Harness container reads. Rejected: the Worktree is read-only on the credentialed side so that nothing there is a channel into the Agent's container; the bundle rides the Orchestrator's one call instead.
- Tell the Agent to rebase onto the published commits. Rejected: measured on a real repository, a rebase repair loses a reworded message, drops a re-applied commit, and duplicates empty commits and merges.
- A fire-and-forget Effect (
spawnChild, or a flag). Rejected for the reasons above; nothing the Machine starts may outlive the state that asked for it. - An
upload()kind besidehttp({ body: file() }). Rejected: two spellings of one Effect, and a kind that, not a body, decided the placement. One kind,http, whatever its body.
Consequences
- A command a Harness restart cut settles
unknown; the stream before the restart is on the feed. - An Orchestrator restart mid-command gives one run: the restored Effect reads the exec from its current end and settles with its output.
- An
httpcall an Orchestrator restart caught in flight gives one send: the restored Effect finds it on the replica that holds it. One the Effector lost givesunknown, or a second send when it isidempotent. - A push the Orchestrator restart caught in flight gives one push of the pinned commit; one the Effector lost is pushed again with that commit alone. A credentialed command the Effector lost runs again with its pinned commit, so its tool can run twice against one commit.
- A squash push sent again takes as its own only a remote tip that jr2's squash committer could have made: another writer's copy of the squash is
rejected, never synced. The committer name and email are text anyone can write, so an unsigned squash's own commit is told from a copy by its content and that text alone; a signed one's also by a signature that only the slot's key makes. - A state exit stops a credentialed command where it runs, and not a file-body
httpor apush: the Effector's stop route is the command's alone (ADR-0068), so for those two D1 holds for the Machine — it does not get the output — and not for the outside world. The stop is sent once, at the exit: a DELETE that reaches the Effector before the command's start (a fast exit while the start is still on the wire) is kept there, and the start that arrives after it runs nothing (ADR-0068), as a Harness keeps a kill. - The Orchestrator reaches a Sandbox Effector by a headless Service the provision writes beside its key, owned by the Sandbox CR (
fx-in place of the Sandbox name'sws-): its name resolves to the pod's own address, the one each request is signed for (ADR-0068), and it publishes that address while the pod is not ready, so a restore can ask the Effector for an Effect while the Harness beside it restarts. The operator's Service names the Harness's port only and is unchanged. - The
@kindtier pushes to a remote of its own: the seed's sshd serves a push remote, and the tier's scenarios push signed over ssh and verify the published commit with the signing key as the one allowed signer, read the Agent's branch and Worktree after the sync, and push again after the Agent amended the pushed commit (diverged). A token push over https has no remote there. Its credentialed-command scenarios read the secret from env and from its file, scrubbed, saydirtyover an uncommitted edit, show a child of the child denied the Effector's key, and show a command whose state exited gone from the Effector container.