Gas City inside the Herdr desktop app: a herdr-app mod that shows a city's rigs, agents and work and acts on them through gc's API.
Status: scaffold, gc client, discovery, sync engine, agents panel, work
board, session and work actions, commands, keys, "needs you" toasts and open
terminal. The mod finds the gc API, lists the cities, and
shows the copy's city: its connection state, its rigs, agents and sessions
with live status, pending prompts and active beads, a detail pane for one
session, and the work board (ready, in progress, recently closed) with a
detail pane for one bead. It acts on sessions, agents and rigs through gc's
API (start, wake, suspend, stop the turn, close, kill, pin, send input,
answer a prompt, suspend and resume agents and rigs) and on work (create a
bead and optionally sling it, sling, close and reopen a bead), and shows
every action's outcome. Every action can also be driven by a command
(herdr-app do gascity.<command>), and a toast tells you when a session
needs you, opening a "needs you" window on the session. Open terminal shows
a session's terminal in a herdr tab running gc session attach, after
waking the session through gc's API. install.sh installs a release (see
Install), and a tag publishes one. An integration test runs the built mod
against a real scratch gc city, with an HC_SCOPE process audit.
With the Herdr app installed and gc running on this
computer (started outside Herdr; gascity/RECIPE.md says why):
curl -fsSL https://github.com/gastownhall/herdr-gascity/releases/latest/download/install.sh | shA release's install.sh carries its version and the sha256 of its
gascity-mod-<version>.tar.gz; it downloads that tarball, refuses any other
bytes. It refuses a tarball holding anything but plain files and folders
inside its own tree (links, devices, absolute paths, ..), unpacks it
without the archive's owners, and runs herdr-app check on it before it
replaces anything. An earlier install is moved to
<app home>/mod-backups/gascity-<time>/ (outside mods/, where herdr
would load it as a second mod), and moved back if the new build cannot be
put in place. The whole script runs from main "$@" on its last line, so
a download cut short runs nothing. With Herdr open it shows the Gas City
tab already open in a local space (reused only if the mod in it answers:
herdr's listing does not say which mod a tab holds), or opens one in a
space on this computer (space.new
first when there is none, or when herdr answers "no space yet"; retried
while herdr has not yet noticed the new folder), shows it,
and sends gascity.set-gc-bin:<gc> until the new copy answers (15 s), so a
Herdr started from the desktop runs the gc on your PATH. Every failed step
prints herdr's message and exits non-zero. Options: --gc-bin <gc or absolute path to gc>, --from <tarball> (checked against
<tarball>.sha256 when that file is next to it). The recipe, the preview
and keys.json stay out of mods/, as in herdr's own install flow; add
"ctrl-alt-g": "mod.open:gascity" to your keys.json yourself if you want
it. compat.json names the herdr-app and gc versions a release supports.
| Path | What |
|---|---|
src/ |
TypeScript source of the mod. main.ts is the View; copy.ts wires one copy to discovery and the shared sync registry; host.ts is the only module that touches herdr-app's host APIs; host.schemas.ts decodes the host data the mod reads; probe.ts writes the probe file; view/ draws from a model and does no I/O. |
src/discovery/ |
Finding gc and the copy's city: resolve.ts (endpoint resolution), supervisorConfig.ts (strict supervisor.toml reader), gcStatus.ts, settings.ts (machine-wide settings), city.ts (the per-copy city state machine), controller.ts (runs them). |
src/vm/ |
Pure view-models: header.ts (connection chip, endpoint source, cities, banners, diagnostics), agents.ts (the rig/agent/session join), board.ts (the work board and bead detail), status.ts (the status chip), detail.ts, region.ts (data age and errors), layout.ts (how the regions fit the width), diagnostics.ts, probe.ts (the probe document), errorText.ts, sanitize.ts. |
src/gc/ |
The gc API client: client.ts (written against herdr's constrained fetch), ops.ts (one function per used operation), errors.ts (the GcError union and gc's problem+json mapping), decode.ts (decode policy), zod.ts (the only zod import; turns on jitless), and *.gen.ts generated from the pin. |
src/commands.ts, src/keys.ts |
The command grammar (strict; see below) and the key map of a focused copy. |
src/notify/ |
"Needs you" toasts: needsYou.ts (one toast per new pending prompt, per app), focus.ts (the shared gascity.focus target), window.ts (the overlay window copy). |
src/actions/ |
The person's actions: session.ts, agent.ts, rig.ts, work.ts (one gc API call each), activity.ts (what an action is and the states it goes through), outcome.ts (the ledger that sends them and follows their outcomes). |
src/terminal/ |
Open terminal: binding.ts (the TerminalBinding seam and transport gating), argv.ts (the env -u HC_* attach argv and its shape check), attach.ts (wake through gc, then open or show the attach tab, confirmed in herdr's terminal list). |
src/hostGuards.ts |
The argument checks of host.ts's wrappers: the URL the platform opener gets, and the only path the mod writes. |
src/sync/ |
The sync engine: one shared store per gc city per app, its poll loop, the event watcher, the fetch budget, backoff, visibility and staleness (see below). |
api/ |
openapi.pinned.json: gc's OpenAPI spec pruned to the used surface; PIN: the gascity commit and the sha256 of the full upstream file; used-surface.json: the operations and model fields the mod uses. |
types/ |
The subset of herdr-app's herdr and gpui-kit/gpui-base host modules the source uses. |
compat/host-aliases.ts |
Maps the global names in types/ onto the declarations herdr-app generates, for the types-drift check. |
gascity/ |
The mod folder as herdr-app loads it: the built, committed, readable main.js, mod.json (with the "needs you" window's overlay spec), and keys.json, an optional key-map fragment. |
gascity/RECIPE.md, gascity/preview.png |
herdr's recipe for the mod (what it shows, what it runs and reads, and why gc must not be started from a herdr terminal) and its screenshot, for herdr.dev/mods. |
install.sh |
The installer (see Install). The repository's copy is unstamped and needs --from; a release attaches the stamped one. |
compat.json |
The herdr-app and gc versions this build supports; a test keeps its gc minimum equal to api/PIN and RECIPE.md in step. |
scripts/package.ts |
bun run package [--out dist]: the reproducible release tarball (gascity/, LICENSE, compat.json), its .sha256, and the stamped install.sh. |
.github/workflows/release.yml |
On a v<version> tag: bun run ci, shellcheck, package (twice, compared), and a GitHub release with the three files. Dispatched, or pushed with a packaging change, it is a dry run that uploads them as an artifact. |
build.ts |
esbuild bundle of src/ into gascity/main.js. Deterministic; the header names the version and a sha256 digest of the build inputs. |
scripts/authority.ts |
The authority lint (see below). |
scripts/bundle-fresh.ts |
Fails when the committed gascity/main.js differs from a clean rebuild. |
scripts/used-surface-diff.ts, scripts/types-drift.ts |
The drift checks (see below). |
test/harness.ts |
Loads the built bundle under bun with fake herdr/gpui-kit modules and a Proxy element recorder, after herdr-app's own mod tests. |
test/unit/ |
Unit and render tests. |
test/contract/ |
Responses recorded from a scratch city at the pinned gc (record.ts), validated with ajv against the pin and decoded by the client. |
test/install/ |
install.sh against a stub herdr-app and curl (test/install/stub/) that record every call and answer from scripted replies. |
test/engine/ |
Engine parity: the client bundled like the mod, run in QuickJS (quickjs-ng, wasm) with Function/eval trapped, compared with bun. |
test/integration/ |
The integration test against a real scratch gc city (see below): scenario.integration.ts, the live herdr stand-in herdr.ts (constrained fetch, allowlisted exec, recorded run), terminals.ts (tabs in PTYs under herdr's shell wrapper), proxy.ts, checks.ts. |
canary/pack/ |
The canary pack: one deterministic, LLM-free agent (assets/canary-agent.sh) for the integration test and the nightly canary. |
canary/city.ts, canary/city.toml.in |
An isolated scratch city (own HOME, GC_HOME, XDG dirs, tmux socket, port; teardown stops only what it started). |
canary/scope-audit.ts, canary/proc.ts |
The HC_SCOPE process audit over /proc; as a CLI (bun canary/scope-audit.ts --city <path> session attach <id>) it audits the herdr terminal running that attach. |
canary/bootstrap-linux.sh, canary/mirror.sh, canary/lib.sh, canary/result.sh |
The released herdr-app headless on a GPU-less Linux runner (Xvfb or Weston, lavapipe), installed by herdr's published install.sh from a sha256-checked per-release mirror; each stage's outcome in out/stages.jsonl. |
canary/mod-linux.sh |
The packaged mod in that app against a scratch city run by gc built at api/PIN: package, herdr-app check, install.sh --from, the probe connected, the shot. Run by the smoke and the preview workflows. |
canary/canary-linux.sh |
The nightly canary's stages S5-S13: every step driven through herdr-app do gascity.<command> against the canary city, plus one real key. |
canary/targets.ts |
The agent-UI target list's parser and the check that this canary is the job the list designates, every step mapped to a stage it runs; bun canary/targets.ts --file <list.toml> prints only this canary's entry (the list is private). |
canary/gc-authority.ts |
The canary's authority audit: every gc change traces to a write the mod's probe shows, every write is accounted for, every program the mod ran is allowlisted, and the mod agrees with gc. |
canary/report.sh |
The canary's report job: one result per planned run, every field checked before it reaches the summary or an issue, and one canary-failure issue on the default branch for a product failure. |
- gc is the only authority. Every change to a gc session, agent, rig or
bead is a gc API call. The mod never runs
hc,tmuxorbd, and never names a herdr command that ends, re-homes, pins or types into a terminal (terminal.kill,keep,park,pin,right_click,paste,paste_image, and hc'ssend/keys/label). - One door to the host. Only
src/host.tsimportsherdr, and only asimport * as herdr. The namespace is used only asherdr.<export>.herdr.runis called directly with a string-literal first argument from an allowlist:tab.selectandmod.open. A toast'sactionis a second way to run an app command (herdr runs it when the toast is clicked), soherdr.notifyis called directly with an object literal whoseaction, if any, is an object literal naming a string-literal command from its own allowlist:mod.open. The calls whose arguments must be checked are listed in the lint'sALLOWLISTby their exact text (each must occur exactly once), so each can only be its wrapper's own call insrc/host.ts, and each wrapper refuses a bad argument before herdr sees it: discovery's<gcBin> supervisor status --json(fixed arguments; agcBinthat does not namegcis refused);tab.newinopenAttachTab(onlyenv -u HC_SCOPE -u HC_TERMINAL_ID -u HC_TERMINAL_SOCKET <gc> --city <absolute path> session attach <gc session id> [--no-start]); andxdg-open/openinopenUrl(only an http(s) URL on this computer: a file would be opened by its default handler, and macOS runs a.commandfile).writeTextFilewrites only the probe directory (<app home>/data/gascity-probe/): a file undermods/would be code no lint saw. The mod imports nothing butgpui-kit,gpui-base,herdr, zod and its own modules. It does not use the host'sprocess(whoserunspawns programs). - No code compiled at run time. There is no
eval, noFunctionidentifier, noReflect.construct, and no dynamic import. Every read of.constructor(the way toFunction,AsyncFunctionand their kin without naming them) is refused, whether called, aliased (const F = f.constructor), passed on (Reflect.apply(f.constructor, …),.call,.bind), destructured (const { constructor: F } = f) or read by key (Reflect.get(f, "constructor")); only.constructor.name,.constructor.prototypeand===/!==comparisons are allowed. Known limit: the lint reads syntax, so a key computed at run time gets past it (const k = "constructor"; f[k](…),globalThis["Func" + "tion"], scanning property descriptors,Reflect.getwith a variable key). These are left to review and to the runtime check: the engine-parity probe runs the client, the sync engine and the action paths in QuickJS withFunction,evaland every function prototype'sconstructorreplaced by traps, and fails if any trap is hit. zod is imported only throughsrc/gc/zod.ts, which must callz.config({ jitless: true }). - The bundle is the source.
gascity/main.jsis unminified and must equalbun run buildbyte for byte, so a person or agent installing the mod can read what runs. Its header has a digest of the git-tracked build inputs, sogit adda new source file before building.
scripts/authority.ts checks the first three rules over src/**/*.ts and
gascity/**/*.js with the TypeScript parser, so comments never count. String
literals are also scanned for hc/tmux/bd anywhere in a shell command
(except a literal that is only compared, an operand of ===, !==, == or
!= or a case label: that is data read from gc, such as its transport
value tmux, not a command; every other use is still scanned) and for the
denied terminal commands. A hit is allowed only inside exact text
listed in the lint's ALLOWLIST, and only when that text occurs exactly once
in the file, so an entry pins one place: an identical call added elsewhere
fails. An allowlist entry that matches nothing fails. The bundle's entries are
discovery's gc supervisor status call, open terminal's tab.new and zod's
plain-object check, which reads o.constructor only to compare it and read
its prototype (openUrl has no caller yet, so the bundle has no opener).
- Pinned spec.
api/openapi.pinned.jsonis gc'sinternal/api/openapi.jsonat the commit inapi/PIN, pruned to the operations inapi/used-surface.jsonand the components they reach. - Generated types and schemas.
bun run gen:gcwritessrc/gc/*.gen.tsfor the listed model fields only. A field or model that drifts from the pin fails generation; a test keeps the committed files fresh. - Decode policy. Extra fields are ignored; a missing required field or a
wrong type is a
decodeerror with the operation, JSON path and issues; an unknown enum value decodes to{kind: "unrecognized", raw}; gc's["array","null"]decodesnull(and, when optional, absent) to[], except fields listed underkeepAbsentsuch aswake_reasons, where absent means "not asked for"; list elements decode one by one, so a bad element is reported asunreadableinstead of failing the list. - herdr's fetch. Whole body, no response headers, a fixed 30 s timeout and
an 8 MiB cap. Rejections become
unreachable,timeoutortoo-large. An answer from any origin other than the configured loopback one (herdr follows redirects) is refused. A mutation whose transport fails, whose 2xx answer does not decode, or that was redirected isoutcome-unknown, never a plain error a person could simply retry. Nothing is retried; mutations carryX-GC-Request: herdr-gascity/<version>, andIdempotency-Keyonly where gc declares it. Loopback API URLs only. - Re-pinning.
git -C <gascity> show <commit>:internal/api/openapi.json > openapi-upstream.json,bun run pin:gc --spec openapi-upstream.json --commit <sha> --committed <iso date>,bun run gen:gc, then re-record the fixtures against a throwaway city started from that gc build (bun run record:gc --throwaway-city …; see the header oftest/contract/record.ts).
Each copy of the mod finds gc's API on this machine. Candidates, first that
answers GET /health within 5 s of the request being sent wins (time spent
waiting in the fetch budget's queue does not count; a probe still queued
after 40 s is dropped, and a probe the mod cancelled is tried once more
before the candidate counts as unreachable):
- the
apiUrlsetting; - the URL gc reports in
gc supervisor status --json(api_url), when gc prints one; [supervisor]bind/portin~/.gc/supervisor.toml(0.0.0.0and::dial loopback, as gc does). The reader is strict: anything in those keys it cannot read for sure is shown with its line, and resolution stops there;http://127.0.0.1:8372.
Only loopback URLs (127.0.0.1, localhost, [::1], with a port) are used;
any other is refused, not probed. The header names the URL, gc's version and
where the URL came from; every candidate and its outcome is listed in the
header while none answered, and in the diagnostics drawer once one did.
A gc home other than ~/.gc needs the apiUrl setting (a mod cannot read
environment variables).
Settings are machine-wide, in herdr's shared store under gascity.settings:
apiUrl and gcBin (gc, or the absolute path to it). A copy opened with
props: {city: "<name>"} shows only that city. A copy opened without props
shows its last choice (kept in that copy's localStorage), else the only
running city, else asks. City states: discovering, no endpoint, cities failed,
choose a city, unknown city, running, stopped; a running city also shows
read-only and "gc too old" notices from gc's answers, including a change gc
refused for the whole city (no write grant, a read-only server), until a
change it accepts or a fresh discovery. A city-list poll that cannot reach gc
moves every state but running to "cities failed" (gc not reachable at …),
so a supervisor stopped with gc supervisor stop (which first takes the city
off the list) never reads as an unregistered city; a running city's store
says it is reconnecting instead.
With no endpoint, the copy rediscovers from its own 250 ms timer: 5 s after the failure, then 10, 20, 40 and every 60 s ("retry now" does it at once). A discovery that makes no progress for 90 s (herdr resumed it in another copy that then closed, so its requests never settle) is started again. Closing a copy cancels its discovery: its queued requests are dropped and nothing it had started runs gc or sends a request afterwards.
Two scheduled workflows watch the two things the mod is built against. Each fails its run when something the mod uses changed, and says exactly what in the job summary; they need no secrets and only read.
- gc drift (
.github/workflows/gc-drift.yml, nightly, or dispatched with any gascity branch, tag or commit): fetches gc'sinternal/api/openapi.jsonand compares it with the pin, restricted to the used surface (scripts/used-surface-diff.ts). A used operation, parameter or field that is gone, moved, newly required, or that gc may now omit or send with another type fails, as does a request gc would now refuse (a tighter length or range bound, a new pattern, format or const, fewer enum values) or a query parameter serialized differently (style/explode); additions the decoders absorb (a new enum value, a renamed model with the same fields) are listed as compatible. Locally:scripts/fetch-gc-spec.sh main /tmp/gc.jsonthenbun run scripts/used-surface-diff.ts --upstream /tmp/gc.json --upstream-commit <sha>. - herdr-app types drift (
.github/workflows/types-drift.yml): hourly it reads herdr-app'slatest.jsonand checks a release it has not checked yet, and fails at once while the current release's last check failed (so the status stays red); daily it checks the current release regardless. It installs the release the way the canary does (the per-release mirror), runsherdr-app typesheadless, and type-checkssrc/against the generated declarations withcompat/host-aliases.tsin place of the subsets intypes/. The summary shows the type errors and a diff of the host declarationssrc/uses against the last checked release. When a new file intypes/declares host modules or globals, list it inHOST_SUBSETSinscripts/types-drift.ts(a test refuses unclassified files) and map any global type it declares incompat/host-aliases.ts. It dispatches the nightly canary once per new release: a per-version marker in the Actions cache, restored before the check and saved as soon as it dispatches, keeps a release whose check keeps failing (an install that never succeeds) from dispatching it every hour.
GitHub disables scheduled workflows in a public repository after 60 days without activity in it; a commit, or re-enabling the workflow in the Actions tab, starts them again.
herdr's fetch blocks a background-pool thread for the whole request, and
herdr's own work runs on that pool. So the engine never long-polls, and
copies share their gc traffic.
herdr also gives every async host operation (fetch, cx.sleep, timers)
to the copy whose code is running when it starts. Its completion runs in that
copy's scope, and when that copy closes the operation is cancelled: its
promise never settles. The engine is built around that rule:
-
One store per city per app, driven by every copy's own timer.
src/sync/registry.tskeeps one store per (gc API URL, city) in module scope, which every copy of the mod shares. Extra copies of the same city cause no extra requests. Each subscribed copy callstick()every 250 ms from a timer it creates in its own init. A tick starts the store's next step only when one is due, so every step starts in a live copy's own turn. The engine itself owns no timer and never sleeps. -
Closing a copy starts nothing.
unsubscribe()only abandons a step that copy started: its queued requests are dropped from the fetch budget (never sent), its late answers are ignored, and the next tick of any other copy starts a fresh step. Releasing the last store on an endpoint leaves the budget's degraded mode without starting anything. A step that makes no progress for 140 s is abandoned the same way and recorded. -
The city list (
cities.ts): oneGET /v0/citiespoll per gc API per app, every 10 s while no copy shows a running city and every 60 s once one does, and at the next tick after acity.*event. It is driven by the copies' ticks like a city store. -
Change signal = a short event poll.
GET …/events?limit=50withoutindexreturns at once. herdr's fetch hides response headers, so the cursor comes from the body: the newestseqthe page shows. gc readstotalafter the page, sototalmay name an event the next poll will bring. A hole between the cursor and the oldest new event, or an unreadable entry that may be new, is a gap; atotalbelow the cursor means gc's log was replaced. Both refetch every domain. If the first read is refused (a city not running yet, a read grant), it is retried at the 60 s sweep, not in a loop. -
Invalidation map (
invalidate.ts). Each event type marks the domains it can change: session events → sessions and agents; pending events → pending; bead events that can move a bead on the board → both bounded board columns, plus a fetch of each closed bead (at most 10 per step) for the closed list; city events → rigs and agents. Refetches are debounced 300 ms and coalesced per domain. -
Cadence (
scheduler.ts), as on screen / hidden:Poll On screen Hidden events 2 s 10 s sessions + pending 5 s 30 s detail transcript 2 s paused sweep (everything) 60 s 60 s The event poll keeps running while hidden, so app-wide listeners (toasts) still hear about prompts.
visibility.tsdecides whether a gascity view may be on screen. It applies per app, because a copy cannot tell which pane is itself. -
Fetch budget (
budget.ts). At most 2 gascity requests are in flight per app, across all copies, cities and endpoints. While an endpoint is backing off, at most 1 request to it is in flight. Queued requests start in this order: mutation > events > snapshot > peek > sweep. A slot older than herdr's 30 s fetch timeout plus 5 s belongs to a fetch herdr cancelled with the copy that started it: it is reclaimed, and its caller gets acancellederror, not a gc timeout. A cancelled read does not back off and is not held: it is simply still due. A cancelled mutation is outcome-unknown. Time spent queued never counts as a timeout. Discovery's/healthand/v0/citiesprobes go through the same budget; a probe's 5 s race starts when it leaves the queue, and a probe that lost it stays counted in flight until herdr's fetch settles. Each copy's tick also reclaims, so a queued request starts in a live copy's turn even with no city subscribed. -
Backoff (
backoff.ts,endpoint.ts). A transport failure, a 5xx, or an answer from off the loopback origin (a followed redirect) on a read backs the endpoint off: 1 s doubling to 60 s, with jitter. Until it recovers, only one probe goes out per retry time; a probe that never ends expires after 40 s. The first success resets it and refetches everything. Other read errors (4xx, decode) are shown and held until the next sweep or "retry now". Mutations are never retried; a mutation whose outcome is unknown is neither retried nor counted as gc answering. -
Errors and staleness are state. Each domain keeps its last good data, the error that followed it, and whether a refetch is wanted or held.
domainFreshnesssays how old the data is and whether it is stale and why. Every failure, including a listener or log hook that throws and a step that crashes or stalls, goes to a bounded diagnostics ring in the snapshot and to the registry'sonErrorhook. -
Time is injected. The clock is a parameter, and the tests run the engine under a fake of herdr's ownership rule (
test/unit/sync/fakes.ts). The engine-parity probe also runs a scripted sync scenario in QuickJS.
Each copy subscribes, from its own 250 ms timer, to the shared city list of its gc API and, once a running city is chosen, to that city's store. It renders from their snapshots only and never fetches while drawing. On close it unsubscribes and starts nothing; the other copies keep updating.
- Rows. Rigs in gc's order (with gc's agent and running counts), then
rigs that only an agent names, then the city's own agents. A session joins
the agent its
agent_namenames, else itstemplate; one that matches no agent is listed under "Other sessions", never dropped. Pool agents show their limits. The session list followsnext_cursorin pages of 500 up to 2 000 rows, and says "showing N of M" beyond that. - Status chip (
vm/status.ts), most specific first: a pending interaction (needs you, with its kind) > a lifecycle state other than active (suspended, asleep, …, with gc's reason) >program_status(state, kind, progress, app) > the transcript's activity, marked "(transcript)" > unknown. An absentprogram_statusis unknown, never idle. An agent row shows its most urgent session, or its own state without one. A value this version does not know is shown raw and listed in the diagnostics. - Active bead. Its title comes from the board's data, else from the bead fetched by id (at most 10 per step, again on an event about it, after an event gap, when gc comes back and on "retry now", but not at every sweep, whose cost would grow with the city); it is never guessed.
- Detail pane. Clicking a session opens it: gc's facts, its conversation, the wake reasons (fetched when it opens and on "retry now", because gc probes the runtime for each session), a keep-awake line, and the pending prompt with gc's own options. The raw terminal stays in the attach tab (Open terminal).
- Conversation (
sync/transcript.ts). Read from gc's per-session transcript, every 2 s while the pane is open and on screen, paused while hidden, at peek priority under the fetch budget. A session with a log (formatconversation) is read once from its last compaction segment (tail=1) and then followed withafter=<last turn id>, so each poll carries only new turns, each shown under its role and time; gc's 409transcript-cursor-invalidatedstarts again from the tail. A session without one (formattext) is a capture of its terminal, read whole each time. At most 200 turns are kept; older ones are said to be hidden. A log with no compaction (Codex writes none) is read whole from the tail; past herdr's 8 MiB cap the pane falls back to gc's bounded peek of the terminal (its last 40 lines), says so, and reads only that until it is reopened. A read started for an earlier pane of the session is dropped when it lands on a reopened one. The session's SSE stream is not used: herdr'sfetchreads a whole body under a 30 s total timeout, and that stream never ends. - Keep awake (
sync/keepAwake.ts). While a session's pane is open in any copy, the mod pins it in gc so it is not put to sleep, and unpins it when the last pane of it closes. It only ever unpins a pin it made: it pins only a session the pane's wake-reasons read shows as listed, active, running, without a lifecycle reason and without thepinreason, and says why it did not otherwise. A person's own Pin or Unpin of the session takes it over. The pins it made are kept in herdr's shared valuegascity.pins(written before the pin is sent), so a pin left by a crash, or by a copy that closed with its pane open, is released at the next start; a pane that opens while its session is still recorded (an unpin that did not land, say while gc was unreachable) holds that pin as its own. A pane that opens while the session's release is in flight (a gc restart, or switching city and back, with the pane open) waits for it to land and then decides on a wake-reasons read asked after it; a copy places its open pane before a new store's first tick, so a store restart keeps the recorded pin instead of releasing it. Agascity.pinsvalue that is not a list is never overwritten: it is reported, and the pane does not pin. A failed wake-reasons read is decided again on the pane's refresh. Its pins and unpins are actions of their own kinds in the activity log ("Keep awake", "Release keep-awake"), so retrying one is not a person's Pin, and refetch nothing; a pin that failed or was not sent is forgotten without an unpin. gc's pin is one ownerless flag that the session itself does not report, so a pin a person makes outside this mod between the pane's read and its pin is taken for the mod's and is released when the pane closes. - Errors and staleness. Each region says how old its data is; on a
failure it keeps the last data, greyed, with the error above it. The header
says connected, connecting, reconnecting in N s (with the cause), city
stopped, gc too old, read-only, or herdr-app too old. gc's partial lists
show
partial_errors; an entry that cannot be read is an "unreadable" row. The diagnostics drawer lists the last 100 failures with their time and source. - Plain text only. Every string gc supplies (names, statuses, titles,
errors, problem details, prompts, output) is shown with escape sequences,
control characters, bidirectional marks, Unicode tag characters and
out-of-band line separators removed (
vm/sanitize.ts), never as markdown or links. Lines written to herdr's log are cleaned the same way. - Probe. While the shared value
gascity.probeistrue, the copy's tick writes<app home>/data/gascity-probe/probe.json(gascity-herdr-probe/4;probe:on/probe:offset it; /4 added the toasts in the exec/run log and thewindow,noticeandcommandsfields, and later the header'sbanners): connection, banners, discovery, city, visibility, sessions with their status, the board (each column's cards, the closes seen in events with their seq andclose_reason, the seed, the filter and the columns' errors), the selected bead, the session detail, actions with their state and request id, the exec/run log (with each toast and the command its action runs), whether the copy holds the keyboard and is the "needs you" window, the notice line, the app's commands with the copy and result, the refresh count, errors and the budget high-water mark. It serializes the same view-models the panel draws. Writes are herdr's compare-and-swap, at most one in flight, on change or every 5 s. One copy owns the file (the first to write it, until it closes), so several copies do not take turns rewriting it. A document over herdr's 1 MiB file limit is cut down by a fixed rule (the session output, pending prompt and bead description go first, then every list is halved until it fits) and says what it left out intruncated; the diagnostics record it. When the probe is turned off the file is emptied (herdr gives mods no way to delete a file), compare-and-swap like any write.
The work board sits beside the agents panel when the pane is at least 1500 px wide, else under it (its columns stack too below 720 px), and reads the same shared store; it adds no polling of its own.
- Ready and In progress are gc's
/work/readylists (open, andstatus=in_progress), at most 50 each, in gc's own order (priority, then creation). gc's work list has no total, so a full column says "50+". Each card shows the id, priority, title, state in words ("in progress", "blocked" when gc says so), type, assignee, labels. - Recently closed lists the closes the store saw in
bead.closedevents, newest close first (the event's seq: gc has no close time), with gc'sclose_reason. Below an "earlier (by creation time)" divider follows the one-time seed (status=closed&sort=newest&limit=20). gc's bead events carry the whole bead, so the list follows them: a close lists its bead (fetched by id only when the event's bead cannot be read, and listed only if gc says it is closed), and a laterbead.updatedorbead.deletedabout a listed or seeded bead drops it unless it is still closed, whether or not the reopened bead shows on a Ready page. After a gap in the events every listed bead is fetched again. A bead is listed once, at its latest close; one back in Ready or In progress is never listed as closed. At most 20 in all; when closes came faster than they could be fetched the list says it may be incomplete. - Infrastructure beads (
session,message,molecule,gate;INFRASTRUCTURE_BEAD_TYPESinsrc/gc/ops.ts) are hidden. gc filters the columns (exclude_type); the store keeps infrastructure closes out of the closed list (no fetch, no slot) and counts them; the chip says what is hidden and how many. - Bead detail. Clicking a card opens its facts at once; the store then fetches the bead by id for its description (the columns carry none), and again on an event about it. Two copies showing the same bead fetch it once.
- Errors and staleness work as in the agents panel: each column says how old its data is (event-driven columns are confirmed by each good event poll), keeps stale cards greyed with the error above them, and lists entries gc sent that cannot be read; every bead string is plain text.
Every action is one gc API call; the mod never runs hc, tmux or bd
and never ends or types into a terminal itself.
- Where. The detail pane: Wake, Suspend, Stop turn, Pin, Unpin, Close…,
Kill… (with Force kill), a send box (Send, Interrupt and send when gc says
the session supports it, Send as message), and one answer button per option
gc lists for a pending prompt (gc's own words, sent back exactly as gc
listed them). Each answer button carries the prompt's request id and the
option it was drawn with; if gc's prompt has changed by the click, nothing
is sent and the panel asks to review it. Each agent row: New session… (an optional alias) and Suspend
agent… / Resume agent (rig-scoped agents use gc's own route). Each rig gc
lists: Suspend rig… / Resume rig. The work board: + New bead (title,
description, priority, labels, and optionally an agent to sling it to);
on the open bead, Sling… (one button per agent gc lists) and Close… (with
a reason), or Reopen for a closed bead. Actions marked
…ask first: close, kill, agent suspend, rig suspend, sling and bead close say what gc will do and send nothing until confirmed. Sling's question says that gc cannot deduplicate a sling, so a retry after an unknown outcome may route the bead twice, and asks again on every retry. - A new bead slung to an agent is two gc calls, each its own entry in the activity log: the create, then, once gc has created the bead, the sling of that bead. A create that fails, is unknown or is not sent slings nothing (its entry says the sling was not sent and why); a retry of the create that is done slings once. A sling that fails or is unknown after a successful create shows as such, and its retry resends only the sling: the bead is never created again.
- What is refetched. After each action (and before a retry of an unknown one) the mod refetches what it changes: a new bead → Ready; a sling → Ready, In progress and sessions; a bead close or reopen → Ready and In progress (the recently-closed list follows gc's bead events); an open bead's detail is fetched again after an action on it.
- Headers. Every mutation carries
X-GC-Request.Idempotency-Key(a fresh UUID per action) goes only on the operations gc declares it on: session create, submit, messages, respond, wake, suspend, stop, close and kill, and bead create. gc declares none on pin/unpin, agent/rig actions, sling, and bead close/reopen. - Outcomes. Each action shows in the activity log as pending, then done,
failed, outcome unknown or not sent, with gc's answer or reason and its request id.
A 202 (session create, submit, messages) is followed through gc's request
outcome endpoint (
after_seq= the 202'sevent_cursor) at 0.5 s, 1 s, 2 s, then every 2 s; with no outcome after 120 s it is unknown. Submit and message outcomes say whether gc delivered or queued the input; a created session is named. - Never retried automatically. A mutation whose connection was lost,
whose 2xx answer could not be read, that was redirected, that gc answered
with a server error (any 5xx but 501, e.g. 503
write_unconfirmed, which may have landed) or with 409idempotency-in-flight(the same key is still running) is outcome unknown, not failed: the mod refetches what it changes and offers Retry only once a refetch that started after the outcome became unknown has arrived, so the person sees the current state first. A retry after an unknown outcome reuses the action's Idempotency-Key. gc keeps keys in memory for 30 minutes and forgets them on restart, so the button promises deduplication only within that; where gc declares no key the button says the action may happen twice. Only a definite refusal (a 4xx, or 501) is failed, and its retry uses a new key, unless an earlier attempt of the same action ended unknown: from then on every retry keeps that key (a later refusal or an unsent retry does not prove the earlier attempt failed), and the log says so. A destructive action asks again on retry. An action already under way is not sent twice. - herdr ownership. An action is sent in the turn of the copy whose button was clicked, and its outcome is polled from that copy's own timer. The activity log is the city's, shared by every copy. If that copy closes first: a request still queued in the fetch budget is dropped and shown as not sent; one in flight is outcome unknown at once (its late answer is ignored, nothing is resent); an accepted request's outcome is a read gc serves by request id, so a surviving copy's timer takes over polling it. Every step has a deadline, so an action never hangs as pending: a request still queued 70 s after it was asked for is dropped and shown as not sent, so it can never go out after being reported.
The detail pane's Open terminal (the t key, the attach command) shows the
session's terminal in a herdr tab running gc session attach. herdr-core
gives every program a terminal runs an HC_SCOPE sweep token and kills
every process carrying it when the terminal's holder dies, and gc session attach on a session that is not running starts its runtime in the CLI
process. So gc must never start a runtime inside the tab:
- Wake first, through gc. The mod reads the session from gc. A session
gc reports draining or closing (even if still running) is refused: an
attach could start it again. One gc is still starting (
creating,start-pending) is not woken, only waited for until it has settled. If it is not running the mod asks gc to wake it (POST …/wake, with the action's Idempotency-Key), so the controller starts it from its own environment, then reads it at 0.5 s, 1 s, then every 2 s until gc saysrunning(and the session has settled). A poll only decides: the tab is opened by the next tick of the copy that asked, after the action's deadline and ownership checks, never in whatever turn a late answer arrives in. A refused wake, or a session still not running 60 s after the wake, opens no tab; the log says why (gc's reason, or its last state). - The argv drops herdr-core's variables. The tab runs
env -u HC_SCOPE -u HC_TERMINAL_ID -u HC_TERMINAL_SOCKET <gc> --city <path> session attach <id>, so nothing the attach leaves running carries the token if the session fell asleep in between. The city path is gc's (its city list), the id gc's (its session list),<gc>thegcBinsetting. With gc 1.6.0 or newer (by/health's version; the first release after--no-startlanded) the argv ends with--no-start, so the attach starts nothing; adevor older gc gets no flag, and the wake through the API is the guard. The gate reads the version of the gc that serves the API (the supervisor's/health), while the flag goes to thegcBinprogram in the tab; these can differ. If the program is older than the supervisor, it rejects the unknown flag and the attach exits (shown as attach exited: it fails closed, starting nothing); if it is newer, the flag is only left out. - A local space. The tab opens in the active space if it is on this
computer, else in the first space that is; never in a remote machine's
space (the attach would run on that host). With no local space, no tab:
the log says to open one (
space.new). - Dedupe while the attach runs. A terminal in a local space whose
program is still our attach of that session gets its tab selected instead.
When the attach exits, herdr's wrapper leaves the person's shell in the
terminal (same argv,
program.shelltrue): that one is not reused, a new tab is opened. - Confirmed through herdr's terminal list (
runreturns nothing): a new terminal running the attach must appear within 5 s (else not seen) and still be running it 10 s after the tab opened (else attach exited: gc's reason is in the tab, which stays open as a shell). Otherwise it is opened. Each outcome is one entry in the activity log; the entry is pending (with what it waits for) until then. - Transport gating. Sessions on transports without a terminal (
acp,subprocess) show why instead of the button; any other value, or none, is allowed and gc answers in the tab. - The seam.
src/terminal/binding.tsdecides how a session's terminal is shown. Today the only binding is the attach tab; the session's own native terminal in an overlay window (once gc reports a session's runtime binding, or a runtime pack labels its terminals) goes there first.
Commands. herdr-app do gascity.<command> and keys.json bindings
"<key>": "gascity.<command>" deliver a command to every Gas City copy on
screen: the tab, the "needs you" window, a split pane, pinned copies
(herdr refuses a command when no copy is shown). A command is a verb and its
arguments separated by :; each argument is percent-encoded
(encodeURIComponent), so text may hold :, % and =, e.g.
submit:scratch:sc-20:close%20fe-1%3A%20done.
- Once per app, in the right city. Every command that changes gc state
names its city first, and only a copy showing that city acts on it; any
other copy logs it as
skippedin the app's command log (no notice line, so copies showing another city stay quiet). Copies share the mod's module, so the first copy of that city to get a delivery claims it and the others log aduplicate: the same text within 2 s is one delivery. An optional last raw argumentnonce=<id>(letters, digits,.,_,-; at most 64) makes a delivery distinct from an earlier one with the same text, keeps it claimed for 10 minutes, and becomes the Idempotency-Key where gc declares one. A copy that refuses a delivery gives its claim up. Commands that only change what a copy shows (focus,city,session,bead,cancel,back,refresh,probe) andset-gc-bin(which stores the same value whichever copy runs it) run in each copy that gets them. - Retrying a scripted command. Sending the same nonce again within 10
minutes is the same delivery: the command book logs it as a
duplicateand nothing reaches gc (unless the first delivery was refused, which gives its claim up). So a script that retries after a failed or unknown outcome needs a new nonce, and that is a new action with a new Idempotency-Key: gc cannot deduplicate it against the first attempt, so if the first one landed the retry may apply twice. Check the state first (the probe'sactionsand gc's own API) before retrying. Reusing the same nonce after the 10 minutes is sent again with the same Idempotency-Key, which gc deduplicates only within its own 30-minute memory and not across a gc restart; and where gc declares no key (pin, agent and rig actions, sling, bead close and reopen) nothing is deduplicated. The panel's own Retry button keeps the key after an unknown outcome. - Same path as the buttons. Each command calls the same copy method its button calls, so it sends the same gc request and leaves the same entry in the activity log (the tests compare them pairwise).
- Explicit ids. Commands name what they act on by gc's id (a session also by its exact alias or session name, refused when more than one session has it), never by "the current selection". An agent, rig or city must be one gc lists; a bead must be on the board or known to gc.
- Confirmation. A command whose button asks first (close, kill, force
kill, agent and rig suspend, sling, bead close, and a new bead slung to an
agent) takes an explicit trailing
confirm. Without it, the command opens the same question or form its button opens (filled in) and sends nothing (a person can still answer it;cancelcloses it); with it, the command also answers the question as clicking its button would.confirmis told apart by position only, so text arguments never turn into a confirmation. - Strict. An unknown verb, a wrong number of arguments, an empty id, a
bad percent escape or a
confirmwhere none fits is refused; so is a command the copy cannot carry out (an unknown or ambiguous id, a list not loaded yet, an action already under way,cityon a pinned copy). A refusal changes nothing and is shown, cleaned, in the panel's notice line. A command that throws is refused with the error and kept in the diagnostics; the copy keeps taking commands. - The log is the app's. The probe's
commandslists the last 20 commands any copy got, with the copy (panel,panel <city>for a pinned copy,window) and the result:done,asked,refused,skippedorduplicate, and why.
| Command | What it does (the button it stands for) |
|---|---|
focus[:<city>:<session>] |
bare: take the keyboard; with a city and a session: select the city and open the session's detail |
city:<city> |
select a city (as the header's city list does; refused by a pinned copy) |
session:<session> |
open a session's detail (as clicking its row does) |
bead:<bead> |
open a bead's detail (as clicking its card does) |
refresh |
refetch everything now (Retry now; the r key) |
probe:<on-or-off> |
turn the probe file on or off (shared for every copy) |
cancel |
close the open question or form without acting (Cancel) |
back |
close the open session's detail (as Esc does when no question or form is open) |
set-gc-bin:<gc-bin> |
store the gc program every copy runs: gc, or the absolute path to a program named gc (the installer sends it) |
session-new:<city>:<agent>[:<alias>] |
start a session of an agent, with an optional alias (New session…, then Start session) |
wake:<city>:<session> |
wake a session (Wake) |
suspend:<city>:<session> |
suspend a session (Suspend) |
stop:<city>:<session> |
stop a session's current turn (Stop turn) |
pin:<city>:<session> |
pin a session awake (Pin) |
unpin:<city>:<session> |
clear a session's pin (Unpin) |
close:<city>:<session>[:confirm] |
close a session (Close…, then Close) |
kill:<city>:<session>[:confirm] |
kill a session's runtime (Kill…, then Kill) |
kill-force:<city>:<session>[:confirm] |
force-kill a session's runtime (Kill…, then Force kill) |
submit:<city>:<session>:<text> |
send input to a session (Send) |
interrupt:<city>:<session>:<text> |
interrupt the turn and send input (Interrupt and send) |
message:<city>:<session>:<text> |
send a queued message to a session (Send as message) |
answer:<city>:<session>:<request>:<option> |
answer a session's pending prompt with one of gc's options (its answer button); the session's detail must show that prompt |
attach:<city>:<session> |
open a session's terminal in a herdr tab, waking it through gc first (Open terminal; the t key) |
agent-suspend:<city>:<agent>[:confirm] |
suspend an agent (Suspend agent…, then Suspend agent) |
agent-resume:<city>:<agent> |
resume an agent (Resume agent) |
rig-suspend:<city>:<rig>[:confirm] |
suspend a rig (Suspend rig…, then Suspend rig) |
rig-resume:<city>:<rig> |
resume a rig (Resume rig) |
bead-new:<city>:<title>[:<agent>[:confirm]] |
create a bead (+ New bead, then Create); with an agent it is also slung there, which needs confirm (else the form opens filled in) |
sling:<city>:<bead>:<agent>[:confirm] |
sling a bead to an agent (Sling…, then the agent) |
bead-close:<city>:<bead>:<reason>[:confirm] |
close a bead with a reason, which may be empty (Close…, then Close bead) |
bead-reopen:<city>:<bead> |
reopen a closed bead (Reopen) |
Keys. mod.json is focusable: pane.go onto a Gas City pane hands it
the keyboard and sends the bare focus command, and the copy focuses its
root. Then j/down and k/up open the next or previous session (as
clicking its row), r is Retry now, t is Open terminal for the open
session, and escape closes the open question
or form, else the session's detail. Keys act only while the root itself
holds the keyboard: typing in a text box (the send box, a form) is the box's
alone. The send box sends to the session whose detail drew it, never to
whatever is selected at the time. The probe's keyboard says whether the
copy holds the keyboard. gascity/keys.json is an optional fragment for
herdr's keys.json, {"global": {"ctrl-alt-g": "mod.open:gascity"}}: an app
command, so it works while every Gas City copy is hidden.
"Needs you" toasts. When a city's pending list (gc's /pending, in the
shared store) gains a prompt, the mod posts a toast, " needs you",
naming its kind, session and city. The store is shared, so several copies of
a city post each toast once. Every (session, request id) pair posted is
remembered, so a refetch, a resync after missed events or a reconnect after
an outage posts nothing again; what was already pending when the city was
opened is the baseline, shown by the header's "N need you" rather than
toasted. A session gets at most one toast per 30 s: a newer prompt inside
that window waits and is toasted once it has passed, if gc still lists it.
A burst posts at most 3 toasts and one "N more sessions need you" summary.
A toast herdr refuses is recorded in the city's diagnostics and tried again
after its session's window.
Clicking a toast must bring Gas City on screen, and a command cannot reach a
hidden copy. So before posting, the mod writes the session to the shared
value gascity.focus ({city, session, seq, at}, seq growing), and the
toast's action is the app command mod.open {name: "gascity"}, which opens
the "needs you" window: a copy herdr opens from mod.json's overlay
spec. That copy applies the newest target written in the last 10 minutes on
its next tick (selects the city, then opens the session: its pending prompt
with gc's options, the send box, its actions), and lists the city's other
sessions that need you, a "Show Gas City tab" button per tab holding a Gas
City pane (tab.select) and Close. While it is open it keeps the shared
flag gascity.window ({open: true, at}) fresh every 5 s and clears it on
close; a flag older than 15 s is stale (a window that died with herdr) and
ignored. While any of the window's text boxes holds a draft, a newer
target does not replace the session being answered: the window offers it
("Session B in city C needs you too", Show) and switches when Show is
clicked or the boxes are empty. A send box draft belongs to the session it
was typed for: Send and Enter refuse it for any other session, so a switch
never carries text to another session. mod.open toggles, so while the window is open toasts carry no
action; the open window follows each newer target by itself. Commands reach
the window like any shown copy. Known limit: the authority lint checks a
toast action's name, not its args.
test/integration/scenario.integration.ts runs the built gascity/main.js
against a real scratch gc city, on Linux, with no GPU and no herdr-app. It
is its own workflow (.github/workflows/integration.yml), not part of
bun run ci: it needs gc, tmux, curl and bash, and takes a few minutes.
GC_BIN=/abs/path/to/gc bun run test:integration-
The gc under test is built from the gastownhall/gascity commit in
api/PIN: the API the mod's types, decoders and contract fixtures come from. That commit'sgc session attachhas no--no-startand reports versiondev, so the mod sends no flag and its wake through the API is the only guard, which is the case the audit is for. The nightly canary covers the latest gc release. -
The city.
canary/city.tsmakes everything under one temporary directory: its own HOME, GC_HOME, XDG directories,TMPDIRandTMUX_TMPDIR, a free loopback port, the file bead store, and the city's own tmux socket (tmux -L <city>-<run id>), never the default tmux server. TMUX, HC_* and GC_* variables of the caller are dropped.gc supervisor runis the test's own child, never under a herdr terminal. Every process it starts carriesHERDR_GASCITY_RUN=<run id>; teardown stops the supervisor, kills the city's tmux server by its socket, then signals only processes carrying that marker, and the last test checks none is left. If the harness itself was killed before its teardown, this stops what a run left behind (the run id is in the run directory'slogs/report.json):grep -lz '^HERDR_GASCITY_RUN=<run id>$' /proc/[0-9]*/environ 2>/dev/null | cut -d/ -f3 | xargs -r kill
-
The agent.
canary/pack/has one agent whose sessions runcanary-agent.sh: it printsCANARY READY <alias>, and on the lineclose <bead> [<nonce>](typed by gc's submit) closes the bead through gc's API with the reasoncanary <nonce>and printsCANARY DONE. -
herdr, in bun.
test/integration/herdr.tsloads the bundle as herdr does (shared module code, two copies of the city's view) with a realfetchconstrained like herdr's (options{method, headers, body}, the same refused headers, 30 s timeout, 8 MiB cap, no response headers, every request metered),execallowlisted to<gc> supervisor status --json, andrunrecorded:tab.newstarts the argv in a PTY under herdr's wrapper ($SHELL -ic '"$@"; exec "$0" -i' $SHELL <argv>) with a freshHC_SCOPEtoken, andterminals()reports it with herdr's record shape (the program named from the PTY's foreground process). Commands go only to copies on screen, asherdr-app do gascity.<command>does. -
The scenario. Discovery (the API URL gc reports in
gc supervisor status --json) and one shared store for both copies; a session started through the mod, running within 90 s; a bead created through the mod andsubmit close <bead>sent to the session, the bead in the closed ring within 60 s; changes shown within 3 s of gc's event (the median of six samples within 3 s, none over 4 s: the on-screen poll cadence allows about 2.8 s at worst); then the session suspended through gc and Open terminal: the mod must wake it through gc's API and see it running beforetab.new. -
The
HC_SCOPEaudit. With the attach tab's token known, no process outside that terminal's process tree may carry it (/proc/*/environ): not the city's tmux server, the agent's pane, the supervisor. It runs for the woken session; then the terminal's tree is killed and gc must still report the session running. Then the race path: the recorded attach argv run right after the session was suspended again, once with the city's tmux server running and once with it killed. At the pinned gc (past gastownhall/gascity#9011) the attach asks the controller to wake the session and waits for it; the test checks its output says so and that it never went into gc's own start path, while the audit samples/procevery 100 ms the whole time. -
The checks are shown to bite. The audit flags a daemon started from a terminal without the
env -uprefix (and passes with it), and a copy of the bundle patched to skip the wake fails the wake-before-attach check. -
Negative cases. A city gc does not have (the banner names it); a sling gc never answers (a proxy holds it: herdr's 30 s timeout, an unknown outcome, the board refreshed before a retry is offered, never retried); the supervisor dying mid-run (the reconnecting banner, at most one request in flight while it is down, then back); a city that requires signed write grants and a read-only bind (
::ffff:127.0.0.1: gc serves it read-only while it still listens on loopback only) — reads work; a change fails with gc's reason. Across all of it, never more than 2 requests in flight. -
Artifacts.
logs/under the run's directory:report.json(timings, audits, checks), the probe files, every request and host call, each terminal's output, the supervisor's log.
.github/workflows/smoke.yml loads the mod in the current stable herdr-app
before it ships: on every push and pull request that touches src/,
gascity/, the installer, the packaging or the scripts it runs. It takes
about six minutes:
- the released app and its core, installed by herdr's own
install.shand run headless on Xvfb with software Vulkan (canary/bootstrap-linux.sh); - the mod packaged as a release packages it (
bun run package), thenherdr-app checkon it with no display; - gc built from the commit in
api/PIN, running a scratch city with two sessions and a few beads (canary/mod-linux.sh city); install.sh --fromthe package, with the app open: the installer must open the Gas City tab, show it, and storegcBin;gascity.probe:on, and the mod's probe must show it connected to the city with its sessions listed, then the whole board;herdr-app shot(not blank) andherdr-app statuswith no errors.
The shot, the probe, the app's log and every stage's outcome
(spike-result.json, stages.jsonl) are the run's artifact. A second job
packages the same mod with a syntax error appended to main.js and passes
only when the smoke fails at the check stage. The workflow is read-only,
gets no secret, saves no cache (it only restores the release mirror, whose
tarballs are checked against the release manifests on every run) and cannot
be dispatched.
canary/mod-linux.sh city puts its city in GC_HOME (default ~/.gc) on
gc's default port, where a person's own gc lives, so it refuses to run
unless GITHUB_ACTIONS=true or HERDR_CANARY_THROWAWAY_HOME equals $HOME
(your word that HOME is a throwaway directory), and refuses a GC_HOME
that already exists or a supervisor already answering on the port. It
records the supervisor gc init started ($CANARY_ROOT/supervisor.json:
home and pid), and teardown stops that supervisor only, and only while it
is still the one running there. Never run it, or herdr-app, on a machine
whose gc or Herdr you use.
.github/workflows/canary.yml runs the whole integration in the released
app every night: on a fresh ubuntu-24.04 VM, the current stable herdr-app
(from herdr's install.sh, as the smoke installs it), the mod installed by
install.sh --from this commit's package, and gc built at api/PIN running
the canary city (canary/pack/, its tmux sessions on a socket of the run's
own). Every step goes through herdr-app do gascity.<command> with the mod's
tab selected, and the mod's probe and gc must agree on each:
| Stage | What must happen |
|---|---|
| discover | the mod connects and shows the canary city running, with no errors |
| session | session-new starts a session gc runs and the mod lists |
| output | the session's CANARY READY line and the run's nonce in the detail |
| attach | attach opens a herdr terminal on gc session attach; gc shows it attached |
| scope-audit | nothing under that terminal leaks HC_SCOPE past the scrub |
| keyboard | a real XTEST key reaches the mod (r refreshes) |
| bead-input | bead-new creates a bead on the board; submit sends the agent its close line |
| bead-closed | the agent's close, with the run's reason, in the mod's closed list and detail |
| authority | canary/gc-authority.ts over gc's supervisor.request events and the probe: every gc change (to the city, under it, or creating one) is a write the probe shows, the detail pane's keep-awake pin and its release included; the only other one allowed is the agent's one close of the run's bead after the submit; a probe that was truncated or whose exec log or action ring is full fails the audit |
Each stage records its class (infra, product, gc, integration, ui). Every
call that could hang has a deadline of its own (polls, herdr-app do, curl,
gc init, the installers, the X focus), and each product step's timeout is at
least a minute longer than the sum of its stage's deadlines (a test checks
it); a step killed at its timeout, an apt hang included, is classed infra.
canary/result.sh writes canary-result.json: the first failing stage, its
class and reason (stage-failed, step-timeout, not-reached), and
whether it is a product failure. canary/report.sh reads exactly one
result per planned run, checks every field against what result.sh writes
(a result it cannot read is reported by field name and fails the step), and
on the default branch files one issue labelled canary-failure for a product
failure, or comments on the open one the Actions bot filed; infra failures
only show in the summary, and on any other branch nothing is filed. Weekly the workflow runs a
soak of five sequential runs and reports the product-stage flake rate
(target under 2%). types-drift.yml dispatches it when a new herdr-app
release appears, and it can be dispatched by hand (reason, runs). The
canary job is read-only and gets no secret; only the report job, which runs
no downloaded code, may write issues.
Each job holds only what it needs: the workflow grants nothing by default.
The mirror job checks out this repo alone, fills the release mirror
(manifests and tarballs, each sha256-checked, nothing run) and is the only
job that saves a cache. The canary job, which builds and runs gc, has no
permissions and no token, and only restores that cache. The report job checks
out this repo for report.sh, reads artifacts and writes issues.
The lane today is main (the mod at the commit, gc at api/PIN). A
latest-release lane (both published installers, released gc) follows the
first mod release and a gc release with the APIs the mod uses.
Needs bun (version in .bun-version).
bun install --frozen-lockfile
bun run build # rebuild gascity/main.js; commit it with the source change
bun test # unit + render tests (no GPU, no display, no herdr-app)
bun run typecheck # src/ against the QuickJS host types; tools against bun's
bun run lint:authority # or: bun run scripts/authority.ts <file-or-dir>
bun run check:bundle # or: bun run scripts/bundle-fresh.ts --bundle <path>
bun run ci # all of the above, as CI runs them
GC_BIN=/abs/gc bun run test:integration # the integration test (see above)
bun run gen:gc # regenerate src/gc/*.gen.ts from api/
bun run notices # regenerate gascity/THIRD_PARTY_NOTICES.md
bun run package # dist/: the release tarball, its .sha256 and the stamped install.sh (GNU tar)- Bump
versioninpackage.jsonandsrc/version.ts,bun run build, and updatecompat.json(and RECIPE.md's "Needs") to what this release was tested with; merge that. - Push the tag
v<version>on that commit. The release workflow checks the tag names the version, runs CI, packages, and publishes the release withgascity-mod-<version>.tar.gz, its.sha256and the stampedinstall.sh. A version with a-suffix is a prerelease. - The repository topic
herdr-modlists the mod at herdr.dev/mods (herdr readsgascity/RECIPE.mdandgascity/preview.png); it is set once, by hand.
MIT, see LICENSE. Bundled third-party licenses: gascity/THIRD_PARTY_NOTICES.md.