| title | gs batch | |
|---|---|---|
| summary | Append an ordered chain of durable acts, loading and verifying the log once. | |
| rests_on |
|
Appends an ordered chain of acts in one process, signed as one actor.
Every other durable subcommand loads and verifies the whole log before it
appends, so a chain filed one command at a time pays that cost once per
act. batch pays it once for the chain: it opens the workroom, verifies
the log, and then appends every act against that one frontier.
| flag | default | meaning |
|---|---|---|
--repo |
. |
The repository holding the workroom. |
--as |
(required, or GITSEQ_ACTOR) |
The actor signing every act in the chain. |
--server |
Forward each act to a resident sequencer instead of writing locally. Default: the resident URL this repository publishes (see gs serve); - forces the local fold; an explicit loopback URL is honoured as given. |
|
--deadline |
10s, or GITSEQ_SUBMIT_DEADLINE |
How long the resident has to answer each submission. Raise it for a resident that is cold, loaded, or folding a large log; a value that is not a positive duration is refused before anything is signed. |
--cited-ok |
false |
Allow a supersede or retire-if-unclaimed act whose target tracked documentation still names. Guarded retirement signs this admission observation separately from its fold-enforced commitment guard. |
--no-preflight |
false |
File the act without asking the fold what it would decide first. See Refused before signing. |
The one positional argument is the file to read. -, or no argument at
all, reads standard input.
A JSON array of acts. Each entry carries an optional label, a verb of
state, ratify, supersede, retire-if-unclaimed, or
reassign-if-unclaimed, and that verb's usual fields: kind, text, body,
rests_on, target, retirement, and idempotency_key. Unknown
fields are refused.
[
{"label": "req", "verb": "state", "kind": "request", "text": "Add a changelog",
"body": {"to": "@bot", "conditions": "CHANGELOG.md exists",
"target_ref": "refs/heads/main"},
"rests_on": ["git:sha1:<genesis>#git:sha1:<event>"],
"idempotency_key": "changelog-request"},
{"label": "promise", "verb": "state", "kind": "promise", "text": "I will add it",
"rests_on": ["$req"], "idempotency_key": "changelog-promise"}
]
rests_on, target, retirement and the recognized event fields of an
entry's body each take a
short reference as well as
the canonical identifier. The whole chain is resolved against one verified
event set before the first append, so a chain carrying a reference that names
no event lands nothing at all; every resolution is named on standard error,
leaving the report on standard output unchanged.
A later act cites an earlier act of the same chain as $label, in
rests_on, target, or retirement. A label names an act the batch has yet
to mint, so it is not an event reference: it passes the resolver untouched and
resolves to the identifier minted for that act. The whole file is parsed and
every reference checked before the first append, so a malformed entry, a
duplicate label, or a label that is unknown or defined later lands nothing.
The array must be the whole input. Anything after it other than
whitespace — a stray ], a second value — is refused before the first
append.
REPO="$(mktemp -d)/project"
git init -q -b main "$REPO"
git -C "$REPO" commit -q --allow-empty -m 'Initial commit'
GENESIS=$(gs init --repo "$REPO" --operator alice \
| sed -n 's/.*"genesis": *"\([^"]*\)".*/\1/p')
gs actor-add --repo "$REPO" --as alice --name bot --kind agent >/dev/null
SEED="git:sha1:$GENESIS#git:sha1:$(git -C "$REPO" rev-parse "refs/seq/$GENESIS")"
cat > "$REPO/chain.json" <<JSON
[
{"label": "req", "verb": "state", "kind": "request", "text": "Add a changelog",
"body": {"to": "@bot", "conditions": "CHANGELOG.md exists",
"target_ref": "refs/heads/main"},
"rests_on": ["$SEED"], "idempotency_key": "changelog-request"},
{"label": "note", "verb": "state", "kind": "assert",
"text": "the changelog convention is one entry per release",
"rests_on": ["\$req"], "idempotency_key": "changelog-note"}
]
JSON
gs batch --repo "$REPO" --as alice "$REPO/chain.json"Before the first append, this command asks the fold what it would decide about every act of the chain, and refuses the whole chain when the answer for any of them is not effective. The refusal names the act by its position:
gs: act 1: the fold would rule this act ineffective: artifact state requires body.path
fix: an artifact names one file: --body path=<file>, at the exact string the merge will publish
file it as written with --no-preflight
The chain is judged in order, in a fold built for the question and thrown away.
Each act is judged against the world the acts before it would make, so a
$label is resolved to the identifier its act will be judged under and an act
resting on one is judged against it: a promise on $request is as effective
here as it will be in the log. The projection this process holds is untouched.
Refused before signing states the rest of
the rule: the reason is the fold's own, the fold decides again per act at
sequencing, and --no-preflight files the chain as written.
A retry is judged per act, because a chain is not all one thing. An act whose
idempotency_key this actor already holds is one the log has: it is not judged
again, it is already in the world the rest of the chain is judged against, and
the sequencer replays it or refuses its key. Its label names that real event, so
the acts behind it stand on what actually landed. Everything else in the chain
is new and is judged as new. So a chain whose prefix landed and whose suffix is
fresh — the ordinary way a broken chain is resumed — replays the prefix and
holds the suffix to the same check any first filing gets, and an exact retry of
the whole chain replays whole and appends nothing.
batch prints one JSON report naming, for every act in the chain, its
position, its label, the event it minted, and its outcome.
| Outcome | Meaning |
|---|---|
landed |
Appended by this run. |
replayed |
Its idempotency key matched an act already in the log; nothing was appended. |
failed |
This act was refused. |
skipped |
The run stopped before reaching this act. |
A failure adds a typed error and exits nonzero, so the report says
exactly which acts landed and which did not.
Events are commits on refs/seq/<genesis>, and the kernel owns the whole
write for each one: envelope and actor signature checks, the payload
ceiling, the admission hook, the dedup index, sequencer signing, and the
compare-and-swap that publishes the commit. Building a chain of commits
outside that path, so the ref could move once, would mean repeating those
checks where the kernel cannot enforce them.
Per-act idempotency keys carry the recovery instead. Rerunning the same file replays the prefix that already landed, without duplicating it, and continues from the first act that did not. Acts given no idempotency key are not resumable and land afresh.
For guarded reassignment, use adjacent retire-if-unclaimed and
reassign-if-unclaimed entries. The replacement names both the old request in
target and the first entry in retirement:
[
{"label":"retirement", "verb":"retire-if-unclaimed",
"target":"git:sha1:<genesis>#git:sha1:<old-request>",
"text":"retire before reassignment", "idempotency_key":"move-retirement"},
{"verb":"reassign-if-unclaimed",
"target":"git:sha1:<genesis>#git:sha1:<old-request>",
"retirement":"$retirement", "text":"Ask the next agent",
"body":{"to":"@next-agent","conditions":"the work is complete"},
"idempotency_key":"move-request"}
]The fold checks the same signed tuple as the purpose-specific command. Batch labels save callers from retyping the retirement event identifier; unrelated interleaving is allowed, while a promise or direct completion refuses.
--server forwards the same signed requests to the resident sequencer,
one at a time. That server holds the single verified frontier, and batch
semantics stay per-act exactly as they are locally.
Each act waits under the same --deadline, so batching does not shorten the
wait for any one of them. When one act's wait expires, the batch stops there and
says so — and whether you may simply run the file again is a property of the
whole prefix, not of the act that timed out. Rerunning replays what landed only
where every act up to the failure carries an idempotency_key; an act given
none lands afresh, so rerunning would append a second copy of it. The refusal
says which of those two cases you are in, and names the positions that have no
key. gs state has the rest.