Parallel-agent ergonomics
Multiple agents, one machine/repo: ports, mutexes, branch discipline, change notes, gate output for agentsRun several AI agents on one machine against one repository — each in its own worktree, a separate working directory on a shared checkout — and they start colliding over the machine’s finite resources. Two dev servers grab the same port; three full test runs fire at once and thrash the disk and caches; a git stash in one worktree pops in another; two agents open divergent branches for the same task. The cruel part is that these collisions don’t look like collisions to an agent that doesn’t know another worktree exists — they look like application bugs (“address already in use”, a test that times out only sometimes, a lockfile that changed on its own), so the agent misdiagnoses them and burns a session chasing a ghost. The collisions continue past the machine: when every pull request adds its line to the top of the changelog and bumps the version, each merge puts every other open pull request in conflict, and each conflict costs a resolution and another full CI run. And the agents collide with their own budgets: a clean test run prints hundreds of lines an agent pays to read and learns nothing from, while the filter that would quiet it (| tail) swallows the run’s exit status, so a red run comes out green. And an agent left running unattended is either running or killed: a person who wants it to hold a push for a minute, pause while they look, or stop at a safe point has no way to say so, so they kill it mid-step or let it carry on. This module treats “N agents in parallel” as a designed-for condition and engineers the collisions away up front.
Parallel agents sharing one machine are a supported mode, so the shared
resources are partitioned deterministically rather than contended: each
worktree gets a deterministic port derived from its identity; heavy
build/test runs pass through a cross-worktree lock that admits runs by
the machine’s load (atomic, with a CI bypass, since a CI runner is
already isolated): a run starts while the machine has room for one more,
the first always does, and a holder that needs the machine to itself waits
for every run to finish and holds back new ones; branches are
reused before created; the shared-state footguns (git stash across
worktrees, a root install with the wrong package manager, global git config)
are banned with a stated rationale; each worktree’s data lives in a
namespace derived from its identity, created with an owner and an
expiry and reaped by that owner; worktree teardown nudges
reflection so a session’s lessons reach the learning loop; no pull
request edits a file every pull request edits: a change’s changelog entry
and version bump are a change note of its own, which a release step
writes into the changelog after the merge; a gate speaks to an
agent in a condensed voice on green and in full on red, keeping its own
exit status, with one named verdict line per part; and an agent left
running unattended can be reached through a control channel of its
worktree, whose binding directives are a closed set enforced by code
that fails closed, while free-text notes only advise; a repository
working in parallel measures where its merges conflict, and removes
each conflict hotspot at its cause or records why it
keeps it.
Everything below is one tool-independent statement made mechanical; the per-ecosystem wiring lives in mappings.md.
M12 Lite — minimum useful
the branch reuse-before-create rule and the footgun bans are written down (a convention agents can follow), and a port-allocation convention exists (even if only “each worktree picks a port from this range”); and a change records its changelog entry and version bump as a change note of its own, not as an edit to the changelog or the version; and the gate commands name a quiet invocation for agents (a reporter flag or a script), with the rule that no filter in a pipe stands between a gate and its exit status.
- The branch reuse-before-create rule and the shared-state footgun bans (no git stash across worktrees, no root install with the wrong package manager) are written down where agents will read them.
branch-reuse-and-footgun-bans-writtenWhat the audit looks for (2)- an instruction/doc states: reuse an existing branch before creating one
- a footgun list bans stash-across-worktrees and wrong-manager root installs, each with a reason
- A per-worktree port-allocation convention exists, so two worktrees do not default to the same port.
port-allocation-convention-existsWhat the audit looks for (1)- a documented convention assigns each worktree a port (a range to pick from, or a derivation)
- A change records its changelog entry (and any version bump) in a file of its own, not as an edit to a file every change edits, so merging one change does not put the others in conflict.
change-records-one-file-per-changeWhat the audit looks for (3)- a doc tells contributors to add a per-change note file (changes/, .changeset/, changelog.d/, newsfragments/ or similar) instead of editing the changelog
- expected-absent: the repository keeps no changelog or version that changes with each pull request
- Jig's changelog skill meets it where `.config/jig.yaml` sets `changelog.file` and a contributor doc points at its notes folder; `/jig:changelog setup` is the remedy where a changelog is edited by every pull request
- The gate commands name a quiet invocation for agents (a reporter flag or a script), with the rule that no filter in a pipe stands between a gate and its exit status.
gate-quiet-invocation-namedWhat the audit looks for (2)- the instruction file or the gate documentation names, for each gate command, the quiet form agents run (a reporter flag such as `--reporter=dot`, or a script such as `test:quiet`)
- a written rule says a gate's output is never filtered through a pipe (`| tail`, `| grep`) that would replace its exit status
M12 Standard — production teams
deterministic per-worktree port allocation is scripted (mechanical, not eyeballed); the cross-worktree heavy-run lock is scripted with a CI bypass, one run at a time or admitted by the machine’s load; and worktree create/remove hooks are wired so the port slot is allocated on create and reflection is nudged on remove; where worktrees share a database, each worktree’s namespace is derived from its identity and created with an owner and an expiry, and a report-first reaper drops the stale ones; a release step assembles the change notes after the merge, one run at a time, while a check fails a malformed note or a direct edit to what that step writes; the quiet form is scripted: a summary on green, the full output on red, the gate’s own exit status, one verdict line per part; and where agents run unattended, each takes a control channel whose directives are enforced by code and fail closed; where work runs in parallel, dated merge-conflict reports name their window and coverage, and every hotspot has a remedy or a recorded decision to keep it.
- A repository whose tools leave machine-local resources declares their kinds and ownership boundaries, so a sweep reports its lifecycle proof before collecting and keeps unregistered or unverified resources.
resource-kinds-declaredWhat the audit looks for (5)- the repository declares the resource kinds its tools mint, their roots or prefixes where needed, and the owner records each predicate requires
- the repository's instructions or configuration name the collector that sweeps those kinds, one that reports before removing, records receipts and keeps an unknown lifecycle or an unregistered resource
- with Jig: .config/jig.yaml sets gc.kinds to the shipped kinds it mints, with gc.worktree_roots and gc.scratch_prefixes where those kinds need them (the machine's installation and its confirmed bounds live outside the repository and are not scored)
- with Jig: process-opener worktrees have a derived runs root and Git-directory owner records; collection requires ended launch records and dead captured processes under shared admission, without a repository-declared root
- expected-absent only where the repository's tooling leaves no machine-local resources between runs
- Per-worktree port allocation is scripted and deterministic — the same worktree identity always maps to the same in-range port.
port-allocation-scriptedWhat the audit looks for (2)- a script maps a worktree id to a stable port within a configured range
- the dev flow / a create hook calls it rather than hardcoding a port
- Heavy build/test runs pass through a scripted cross-worktree lock that bounds them on one machine (one at a time, or as many as the machine's load admits) and bypasses under CI.
heavy-run-mutex-scripted-with-ci-bypassWhat the audit looks for (2)- a lock wrapper (atomic mkdir-style) guards heavy commands across worktrees, as a single mutex or as slots admitted by load
- it runs the command immediately when a CI signal is set (CI / an explicit bypass)
- Worktree create/remove hooks are wired — create allocates and surfaces the port slot, remove nudges reflection.
worktree-hooks-wiredWhat the audit looks for (4)- a create hook allocates/prints the worktree's port slot
- a remove hook prints a reflection nudge (non-blocking)
- in Herdr: executable `.config/worktree-hooks/create` and `remove` count as wired only when the repository also tracks how both are reached: creation through a setup script or documented install step that installs Jig's Herdr plugin (tools/herdr/plugin), or through commands or launcher configuration that open worktrees with tools/herdr's `open`, which runs the create hook itself where no plugin is installed; and removal through commands or launcher configuration that remove worktrees with tools/herdr's `remove`; the hook files alone are configured, not wired, since an installed plugin and a habit of opening or removing through the tool are not facts the repository shows
- in T3 Code: creation counts as wired when a tracked `t3.json` has a script with `runOnWorktreeCreate: true` whose command runs `.config/worktree-hooks/create`, and the repository documents importing that script into the project's actions (Settings → Projects → Actions), since T3 Code runs a `t3.json` script only once it is imported; removal counts as wired only when the repository also tracks how the remove hook is reached, through commands or launcher configuration that run `.config/worktree-hooks/remove` inside the worktree before removing it, with the project's automatic worktree cleanup documented as off, because T3 Code has no pre-remove point and its cleanup policies remove worktrees without the hook; a `t3.json` without the documented import step or without that removal path scores the criterion configured, not wired
- Where worktrees share a database server, each worktree's data namespace is derived from its identity by a script, created with an owner and an expiry, and reaped by its owner through a command that reports before it drops and refuses the production namespace (expected-absent for a repository with no database or no parallel worktrees).
worktree-namespaces-keyed-and-reapedWhat the audit looks for (3)- the migration or dev command derives the namespace (a schema, a database, a key prefix) from the branch or worktree name; the same identity always maps to the same name
- production is the namespace with no prefix and needs an explicit flag to be targeted; the derivation never yields it
- creation writes the owner and an expiry (a schema comment, a registry row); a reap command lists each namespace with its reason (expired, orphaned, unlabelled) and drops only after the report, only the owner's, never an unlabelled one
- A release step assembles the per-change notes into the changelog and sets the version after the merge, one run at a time, and a check fails a change whose note it cannot read or that edits what the step writes.
change-records-assembled-after-mergeWhat the audit looks for (3)- a CI job or release tool on the integration branch writes the notes into the changelog and moves the version (Changesets, towncrier, scriv, changie, or a script)
- a pull-request check fails a malformed note, or a direct edit to the changelog's release sections or the version
- Jig's changelog skill meets both where `.config/jig.yaml` sets `changelog.file` and a workflow runs its action (`plugin/skills/changelog` with `command: check` on pull requests and `command: release` on the integration branch, as its workflow template does); without such a workflow the release step is not wired, and `/jig:changelog setup` is the remedy
- An agent left running unattended can be reached without killing it, through a control channel whose directives (at least stopping, pausing or holding its push) are a closed set enforced by code and fail closed, while free-text notes only advise (expected-absent where no agent runs unattended).
unattended-agent-control-channelWhat the audit looks for (4)- a channel per worktree (files in its gitignored scratch, or a runner feature) accepts directives from a live session while the agent runs
- each directive is checked by code at a named checkpoint (before a push, between rounds), not left to the agent to obey
- an unreadable channel or directive is treated as a hold or a stop, never as clear
- Jig's drive-pr skill in use (its drive mailbox) meets this for review loops only where its push-hold recheck (push-hold-recheck.ts) runs as the last pre-push hook command in the installed hooks; without it a hold sent during the pre-push hooks is not honoured, and the channel is not yet mechanical
- Each gate command an agent runs has a quiet form that prints a summary on success and the full output on failure, and exits with the gate's own status rather than a filter's.
gate-output-quiet-on-greenWhat the audit looks for (3)- a package script or wrapper (test:quiet, lint:quiet, a quiet-run wrapper) condenses a passing run and prints a failing run in full
- the wrapper takes the exit status from the command itself, not from a pipe through a filter (no `| tail` or `| grep` between the gate and its status)
- the instruction file or the gate set names the quiet form as what agents run
- A gate run with several parts ends each part with one named verdict line, and its reader treats a part without one as not run, never as passed.
verdict-line-per-partWhat the audit looks for (3)- the gate runner (a script, a task runner, a wrapper around each part) prints one line per part naming it and its outcome
- a rule where agents read it says that a missing verdict line means the part did not run
- expected-absent when the gate set is one command with one outcome
- A repository working in parallel measures where its merges conflict, and each conflict hotspot is removed at its cause or kept by a recorded decision with a reason and a condition for revisiting it.
merge-conflict-hotspots-measuredWhat the audit looks for (6)- dated reports rank conflicted paths with causes and state the time window, recurrence threshold and coverage limits
- each reported hotspot links to a change that removes its cause, work to make that change, or a recorded keep decision with its reason and revisit condition
- a hotspot entered into the reflection store as a finding (reflect's hotspots operation) counts as that work once escalated to a tracker issue or approved, and as a keep decision only when its dismissal's reason says the cause is kept on purpose and names a condition for revisiting it; a dismissal as not actionable or already fixed, or an open finding, records neither
- reports after a remedy compare like windows to check whether its cause stopped recurring
- the audit's own replay supplies current conflict evidence but does not establish that the repository already measures or acts on hotspots
- expected-absent only where neither people nor agents work in parallel; an empty history or a clone with no live events does not establish this
M12 Strict — regulated / compliance posture
the port allocator and the resource lock each ship a self-test that runs in CI, so a broken utility fails loudly; the teardown hook’s reflection nudge is wired to the M8 loop; and the footgun bans are enforced where mechanizable (e.g. a hook or lint that rejects the wrong package manager at the repo root); and the quiet wrapper ships a self-test proving a failing run keeps its status and prints in full, and the agent runtime applies it automatically where it has a hook for that, under the fail-towards-showing-more rule.
- The port allocator and the resource lock each ship a self-test that runs in CI, so a broken utility fails loudly instead of silently misallocating.
utilities-self-tested-in-ciWhat the audit looks for (2)- each utility has a paired self-test exercising a known pass and a known fail
- CI runs both self-tests
- The worktree teardown hook's reflection nudge is wired to the learning loop, so a session's lessons have a durable destination.
teardown-nudges-reflection-wiredWhat the audit looks for (3)- the remove hook points at the reflection step / learning-loop inbox (ties to M8)
- the nudge fires on teardown without blocking it
- with Jig's reflect skill: the remove hook parks the worktree's unsent reflection findings (`journal.ts park`) and refuses the removal only when parking fails
- The footgun bans are enforced where mechanizable — e.g. a hook or lint rejects a root install with a package manager the repo did not declare.
footgun-bans-enforced-where-mechanizableWhat the audit looks for (2)- a hook/lint derives the declared package manager and rejects the others at the root
- the remaining bans that cannot be mechanized are still documented
- The quiet wrapper ships a self-test, run in CI, proving that a failing run keeps its status and prints in full, and the agent runtime applies the quiet form by itself where it has a hook for that.
quiet-wrapper-self-testedWhat the audit looks for (3)- a self-test of the wrapper runs a failing command through it and asserts the command's own exit status and its full output
- CI runs that self-test
- where the agent runtime has a command-rewriting hook, a tracked hook applies the quiet form, and a command it cannot classify runs unchanged with its full output
Adoption steps
-
Copy
templates/WORKTREE-ERGONOMICS.mdinto your docs tree and trim the footgun table and port ranges to your stack. -
Vendor
reference/port-allocator/, and usereference/resource-lock/from a pinned Jig checkout that keepsplugin/shared/at its relative path (the lock imports it); wrap your heavy gate commands withwith-resource-lock.tslocally (CI is handled by the bypass). -
Wire the create/remove hooks from
templates/worktree-hooks.mdat your worktree manager’s hook points (see mappings.md). -
Import
templates/branch-discipline.mdinto your agent instruction file so the reuse rule and bans travel with every agent. -
Add the two self-tests to CI so the utilities can’t rot silently.
-
Where worktrees share a database, derive each worktree’s namespace with
reference/worktree-namespace/in the migration or dev command, write the owner and expiry when it is created, and give each owner the reaper’s decision as a command that reports before it drops (commands per database in mappings.md). -
Where the repository keeps a changelog or a version that every pull request touches, move it to change notes: pick the tool for your ecosystem from M16’s mappings or use the plugin’s
changelogskill (/jig:changelog setupwalks through it), run the release step on the integration branch after each merge, and the branch check on every pull request. Convert open pull requests’ changelog edits into notes once. -
Give each gate command a quiet form: a reporter flag from mappings.md or
reference/quiet-run/around it, named in the package scripts the instruction file lists; where the agent runtime has a command-rewriting hook, wire the wrapper there. -
Where an agent runs unattended, give it a control channel: use
drive-pr’s drive mailbox for review loops (with its push-hold recheck as the last pre-push hook command), or build the same closed set of directives into your own loop, each checked by code at a named checkpoint and failing closed (mappings.md). -
Where work runs in parallel, run the history report for a named window (mappings.md), retain its coverage statement, and record a remedy or a keep decision for every hotspot. Rerun it over comparable windows after a remedy lands.
Core piecesThe whole copyable model — all its rules in one place, ready to drop into a docs tree — is templates/WORKTREE-ERGONOMICS.md. The branch-discipline block is written to be imported into…Open
-
Deterministic per-worktree ports — each worktree derives its port from its own branch or directory name, so the same worktree always gets the same port and two worktrees almost never clash, with no registry and no lock. The portable allocator is
reference/port-allocator/(allocate-port.ts+ self-test); the collision caveat and range-sizing guidance are in its README. -
A cross-worktree heavy-run lock, admitted by load — full build/test passes run only as many at once as the machine can carry, instead of thrashing it or idling it behind one run. The lock has slots, each an atomic process-id lock at a shared path (a symlink, or a hard link on Windows) with a wait timeout and dead-holder reclaim. A waiter takes a free first slot at once; any other slot only while the predicted load (the one-minute load average plus the cost of each run started in the last minute, which the average does not show yet) leaves room for one more run under a share of the cores, and the available memory stays above a floor. The first run is always admitted, so the queue always moves, and a check that cannot read the host admits, so a broken reading falls back to a ceiling on slots rather than stalling every run. A ceiling of one slot is a plain one-at-a-time mutex. A holder that needs the machine to itself (a collection of stale resources, say) takes every slot in a fixed order and holds back new runs while it waits. A waiting run says what it waits on (every slot held, the load, the memory, an exclusive holder) and who holds the slots, and announces itself beside the lock while it waits, so another mechanism (a scheduler deciding whether to start one more agent) can count the runs that hold a slot and the runs waiting for one:
reference/resource-lock/(with-resource-lock.ts- self-tests). It bypasses under CI because a CI runner
is an already-isolated machine — waiting there would be pure latency. This
is the same
with-resource-lockmechanism the M1 gates & enforcement ladder module points to for putting heavy pre-push gates behind the lock; M12 owns the script, M1 consumes it. It can also be skipped locally — not just bypassed in CI — when a change-area catalog’s validation plan clears it on both axes: it selects no heavy profile including its fail-closed defaults (an unmatched file, or a seeded area missingvalidation.profile, both select the deepest — never vacuously a shallow one), and the plan’s sandbox requirement is clear: the remote-machine requirement a repository’s own composer computes from the seeds’impliedByclosure, where it has one (see mappings.md). Profile depth alone is not enough to skip: it’s seed-only by design, so a shallow seed set can still reach, purely through the closure, a dependent that needs the machine — only agreement on both axes means nothing heavy enough to need the lock ran.
- self-tests). It bypasses under CI because a CI runner
is an already-isolated machine — waiting there would be pure latency. This
is the same
-
Branch reuse before create — before creating a branch, look for an existing one (local or remote) and reuse it; only create when none exists, so two agents on the same task converge on one branch instead of forking two. The rule and its snippet are
templates/branch-discipline.md. -
Footgun bans with rationale — conveniences that are safe in a single checkout but dangerous across shared worktrees are banned with the reason attached (a rule with a rationale survives; a bare “don’t” gets worked around): no
git stashto move work between worktrees (the stash stack is shared repo-wide), no root install with the wrong package manager (it rewrites the shared lockfile), no mid-session global git config. The table lives intemplates/WORKTREE-ERGONOMICS.mdand the importable checklist inbranch-discipline.md. -
Teardown nudges reflection — the worktree-remove hook prints a prompt to run the reflection step while the session is freshest, so lessons flow into the M8 learning loop instead of evaporating. The prompt is a nudge, never a blocker; what the hook does refuse is losing findings already captured in the worktree (with Jig’s
reflectskill it parks them for the next reflection). Skeletons for both create and remove hooks aretemplates/worktree-hooks.md. -
Change notes instead of a shared changelog edit — each pull request adds its changelog entry as a file of its own (a change note), saying which release it needs; it never edits the changelog’s open sections or the version. After the merge, a release step on the integration branch, one run at a time, writes the notes into the changelog, moves the version to the largest bump asked for, and deletes the notes; a branch check fails a note the step could not read and a direct edit to what the step writes. Pull requests then touch disjoint files, and no two claim the same version. What goes in a changelog, how the version is chosen and how a release is tagged and pushed is release practice, M16’s; this piece is only that no two pull requests edit the same lines for it. The plugin’s
changelogskill is the runnable form of both; the tools that do the same per ecosystem are in M16’s mappings. -
Per-worktree data namespaces — several worktrees share one database server, so each derives its own namespace (a schema, a database, a key prefix) from its identity, the way it derives its port: the same worktree always gets the same name, and no two share one. The namespace is created with its owner and an expiry, and a report-first reaper, run by that owner, drops what has expired or whose worktree is gone, never the production namespace and never a namespace created without those keys (the missing key is the finding). The drop decides each name again under a lock the create also takes, since a worktree can come back on the same branch, and so to the same name, after the report.
reference/worktree-namespace/derives the name and decides the plan; the per-database create and drop commands are in mappings.md. This is M10’s symmetric teardown applied on the developer’s machine. -
Agent-facing gate output — a gate command an agent runs is read by the agent, line by line, so its output is shaped for that reader. On success its quiet mode prints a summary (a verdict line and the last few lines); on failure it prints the full output; and it keeps the gate’s own exit status, which a filter in a pipe (
| tail,| grep) would replace with its own, turning a red run green. A run with several parts prints one named verdict line per part, and its reader treats a missing verdict line as “did not run”, never as passed, so a part that was skipped or a wrapper that died cannot pass by silence. The quiet form is a script of the repository’s own (test:quiet,lint:quiet), so every agent runtime and every person runs the same one. A runtime that can rewrite a command before it runs (an agent hook) applies it automatically, under a safety model that fails towards showing more: it rewrites only a plain invocation of a known runner; leaves anything with shell punctuation, a pipe, a redirect, a background run or an inspection flag (--help, a dry run, a coverage report, a watch mode) untouched; bounds what it captures; and fails a mistyped test path instead of reporting that no tests ran. The portable wrapper isreference/quiet-run/(quiet-run.ts+ self-test); the runners’ own flags and the hook shape per runtime are in mappings.md. -
A control channel into an unattended agent — an agent left running on its own (a review loop driving a pull request to convergence for an hour, say) has only two states seen from outside: running, or killed. A person, or the session that started it, who notices a problem needs something in between: do not push yet, pause, stop at the next safe point, here is context you may want. The channel is scoped to the agent’s worktree: a sender can leave a message on it while the agent runs, and the agent records what it has read, so a sender can tell a message seen from one lost. Its messages come in two kinds, and the split is the point:
- Directives bind. They are a closed set (hold the push, pause, stop, and resume one of those), each enforced by code at named checkpoints, so the agent need not cooperate for one to take effect: a held push is refused immediately before it happens; a pause or a stop takes effect between rounds, never in the middle of one. A directive the agent cannot read counts as in force. A check made before an irreversible action must never read “no hold” from a file it could not parse.
- Notes advise. They are free text the agent may read and is never obliged to act on. The power to bind is reserved for the closed set, so no note can change which directives are in force. That does not make a note’s text safe: an agent that reads it has untrusted text in its context, and treats it as such.
Adding a directive therefore means adding the code that enforces it at a stated checkpoint, never a sentence the agent is asked to obey. The channel belongs to one worktree, not to the machine: it is a conversation with this worktree’s agent, so it is kept with that worktree (in its scratch, or in the runner that started the agent; memory tiers). Jig’s
drive-prskill ships it as the drive mailbox; its layout and the equivalents per agent runner are in mappings.md. -
Measure merge conflicts at their cause — replay the merges in a named time window and rank the paths that conflicted, with their causes. A conflict hotspot is a path that meets the configured recurrence threshold (at least 3 merges by default). For each hotspot, remove the cause or record a decision to keep it, with a reason and a condition for revisiting it. Compare windows of the same length and scope before and after the remedy to see whether the cause stops. The
resolve-conflictshistory report is the runnable form. It distinguishes files whose layout creates conflicts (shared counts, version lines or additions at the same place) from two changes to the same thing. Its replay sees reachable merge commits; the skill separately keeps a live record of rebases, cherry-picks and reverts resolved in this clone. Keep its coverage limits with the findings: silence from the live record is not proof of a conflict-free branch. Feed recurring causes into the existing M8 learning loop rather than creating a second issue queue: thereflectskill’shotspotsoperation enters each measured hotspot into the reflection store as a finding whose class is its cause, so a cause that recurs across files escalates to one tracker issue.
The whole copyable model — all its rules in one place, ready to drop into a docs
tree — is templates/WORKTREE-ERGONOMICS.md.
The branch-discipline block is written to be imported into an agent instruction
file (the M0 instruction-architecture module
governs how those files layer), so every agent inherits the rules.
Resource lifecycleA machine-local resource is collected only when its lifecycle proves every holder gone. Age is an additional guard, and unregistered resources or an unreadable proof are findings to…Open
A machine-local resource is collected only when its lifecycle proves every holder gone. Age is an additional guard, and unregistered resources or an unreadable proof are findings to keep. A collector reports before collection, checks the proof again at removal, and writes a receipt for report-only runs as well as collections. Its creator and collector coordinate at the final check; a tool’s refusing removal protects only the conditions it checks.
Jig’s resource collector supplies the runner,
receipts, confirmed repository bounds, scheduler installation and adapters
for drive-pr state and scratch scopes. Registered test scopes can be collected
when persistent fixture records prove every holder gone. Unknown child trees,
incomplete registrations and other scratch remain retained. Worktree reports evaluate lifecycle evidence. A worktree a
workspace runtime manages is collected through that
runtime, whose registry of the agents working in it stands in for the session
opener’s shared lock (the runtime binding).
Any other worktree’s collection waits for the operated reaper migration and that lock. A worktree’s
ignored content is the one part git cannot give back, so it is set aside only
where its writer marked it disposable (a cache directory tag,
Jig’s .context/scratch/), and any
other ignored path keeps the worktree until it is preserved
(the collector’s rule). The machine policy
can tighten a repository declaration and cannot widen it.
In your toolsThe same rule, wired into a specific CI provider, hook manager or tracker. Shows only your stack.Open
The module invariant — deterministic per-worktree ports, a
cross-worktree heavy-run lock admitted by load, with a CI bypass, branch reuse-before-create,
change records of their own assembled after the merge, banned shared-state
footguns, gate output shaped for an agent, and a control channel into an
unattended agent, and measuring merge-conflict hotspots — is tool-independent. This file maps its mechanisms
onto concrete worktree managers / agent runners, package managers, and
CI providers. Replace <placeholders> with your values.
The utilities, and where they plug in
The module ships portable scripts for the mechanisms below; the rest is
convention. Run the resource-lock script from a pinned Jig checkout, keeping
plugin/shared/ at its relative path for the shared lock and process cleanup
registry. Point one variable at the module in that checkout and build
paths from it, exactly as the other modules do. The change-note commands
ship inside the plugin; run them from its installed cache with the consumer
repository as the working directory.
| Utility | Runs where | Signal it reads |
|---|---|---|
reference/port-allocator/allocate-port.ts | worktree-create hook and/or the dev script | worktree id (arg or WORKTREE_ID), range via PORT_BASE/PORT_SPAN |
reference/resource-lock/with-resource-lock.ts | around heavy local gate commands (build, test, e2e) | lock via LOCK_NAME/--lock; slots and admission via LOCK_SLOTS, LOCK_STATIC_SLOTS, LOCK_TARGET_UTIL, LOCK_RUN_COST, LOCK_MIN_MEM_GB; the machine to itself via --exclusive; bypass via CI/RESOURCE_LOCK_BYPASS |
changelog/scripts/release.ts | on the integration branch after every merge, one run at a time | the repository’s changelog: configuration (notes directory, changelog, version files) |
changelog/scripts/check.ts | in the branch gates | the base’s changelog: configuration, plus --base |
reference/quiet-run/quiet-run.ts | around each gate command an agent runs (a test:quiet script, or a runtime hook) | --name per part, --tail for the lines a green run shows |
reference/worktree-namespace/namespace-for-worktree.ts | the migration or dev command, and the create hook | the worktree’s branch (arg or WORKTREE_ID), --prefix, --max-length |
reference/worktree-namespace/find-stale-namespaces.ts | the owner’s reap command, before any drop | the inventory via --inventory, git worktree list --porcelain via --live, --owner, --production (required) |
Worktree managers / agent runners — where the hooks wire
The create hook allocates and prints the port slot; the remove hook nudges reflection and parks the worktree’s unsent reflection findings. Both act on the worktree they run in, so each runs inside its worktree. Only the wiring point differs per tool.
| Manager | Create-hook point | Remove-hook point | Notes |
|---|---|---|---|
plain git worktree | a wrapper script/alias around git worktree add | a wrapper around git worktree remove that changes into the worktree being removed, runs the remove hook there, and removes the worktree only when it succeeds | git itself has no add/remove hook event; the wrapper is the seam |
| Herdr | Jig’s Herdr plugin (tools/herdr/plugin) answers worktree.created by running .config/worktree-hooks/create inside the worktree the event names (data.worktree.path in HERDR_PLUGIN_EVENT_JSON); tools/herdr/workspace.ts open waits for it before starting an agent, and runs it itself where the plugin is not installed | tools/herdr/workspace.ts remove resolves the worktree, runs .config/worktree-hooks/remove inside it and parks its reflection findings on the machine that holds it, and removes it through herdr worktree remove only when both succeed | Herdr runs a plugin’s commands in the plugin’s own directory, so a create hook that read its working directory would give every worktree the same identity and port slot; worktree.removed fires after the checkout is gone, so it can only notify, never park |
| Orca | the Orca workspace tool’s open (the launcher’s orca provider) runs .config/worktree-hooks/create inside the new worktree once its branch is named, before the agent starts, and marks the run in the worktree’s git directory so it runs once; a worktree created in the Orca app runs Orca’s own setup hook instead (Settings → Repository, or scripts.setup in the repository’s orca.yaml), which can name the same file | tools/orca/workspace.ts remove runs .config/worktree-hooks/remove inside the worktree, parks its reflection findings when the clone is on this machine, and removes it through orca worktree rm only when both succeed; Orca’s own delete runs an orca.yaml archive hook only when asked (--run-hooks) and has no other pre-remove point | Orca names a new branch after the worktree under its own prefix, so the tool renames it before the hook runs; Orca reads the branch from git and follows |
| Worktrunk | a blocking pre-start hook in the repository’s .config/wt.toml (pre-start = ".config/worktree-hooks/create"); Worktrunk runs it inside the new worktree, before any post-start hook runs | a blocking pre-remove hook (pre-remove = ".config/worktree-hooks/remove") runs inside the worktree being removed, before it is deleted; its failure aborts the removal, so unsent reflection findings are parked or the worktree stays, provided the hook ran | Worktrunk asks before it first runs a repository’s project hooks, and again when one changes; declining skips every project command for the operation and the removal continues, so the hook must be approved before the first removal and after each change to it, because a refusal is not a removal veto and deletes the git directory holding unsent findings; post-remove runs in the primary worktree after the checkout is gone, so it can only notify, never park |
| T3 Code — watched | a script in the repository’s t3.json with "runOnWorktreeCreate": true and "command": ".config/worktree-hooks/create"; T3 Code runs it inside the new worktree (with T3CODE_PROJECT_ROOT and T3CODE_WORKTREE_PATH set), which a thread has only when it runs in a worktree (the New worktree mode in the app, or t3 thread start --worktree), once the script is imported into the project’s actions (Settings → Projects → Actions), and "async": false holds the agent until the hook exits | none: T3 Code offers no point before a worktree is removed, so a wrapper runs .config/worktree-hooks/remove inside the worktree, parks its unsent reflection findings, and removes it only when both succeed (the repository writes that wrapper, as for plain git worktree); set the project’s automatic worktree cleanup to Off, since a cleanup policy removes worktrees without the hook | T3 Code runs a t3.json script only once someone imports it on each T3 Code server that opens the project, so the file is the shared declaration and the import a step each server takes; a runOnSettle script runs each time a thread is settled (moved to the finished shelf, by a person or automatically), not before a removal, and cannot veto one; worktrees isolate files, not ports or databases: the create hook’s port slot covers ports, and a per-worktree data namespace covers databases; Jig ships no T3 Code provider, and its revisit conditions are assessed below |
| Rex — watched | no worktree concept: a wrapper would create the worktree, run its create hook inside it, then open a Rex session in it | a wrapper would run the remove hook inside the worktree, park its unsent reflection findings, and remove it only when both succeed | Jig ships no Rex provider; its program status and provider revisit conditions are assessed below |
| another workspace runtime (such as Conductor) | the runtime’s post-create / workspace-setup hook | the runtime’s pre-remove / teardown hook | the runtime already brackets a session — the natural home for both |
direnv / per-directory env | .envrc calls allocate-port.ts on entry and exports PORT | none (no teardown event) | derived ports mean no cleanup is needed |
| tmux / shell session per worktree | shell rc sources a per-worktree env file | a shell EXIT trap prints the reflection nudge | lightweight; good when there is no formal manager |
Because ports are derived, the create hook is convenience, not correctness:
any dev script can call allocate-port.ts directly and get the identical port
without a hook having fired.
Rex: conditions for reconsidering a provider
Assessment dated 2026-11-11: Rex is a candidate workspace runtime, with no supported Jig integration. Its command line offers machine-readable output, stable identifiers, waiting, capture, input and events; its server API describes its own methods. These are useful seams for running an agent in a worktree a wrapper owns.
Reconsider a provider when each prerequisite can be checked:
- A stable release is available; Rex is currently in beta.
- A Linux or iOS client is in testing. The installation guide currently limits client testing to macOS; Linux availability is server-only.
- A published licence or an open-source core establishes the terms for use.
- Authentication goes beyond trusting how a caller reaches the server. The remote-access guide currently relies on Tailscale identity or a private connection such as an SSH socket forward while fuller authentication is planned.
The first integration would be a workspace provider for the launcher. The dispatcher’s session runtime would follow only once Jig supplies the subscription-account binding itself: Rex’s operating-system accounts do not provide the subscription-account roster and session binding the dispatcher needs (ADR-0011).
Also revisit reading program status as the
agent’s reported state when a supported runtime exposes it: in sessions
and in steer’s check that the agent still waits before sending an answer.
Rex exposes status records through the terminal block’s program_status
method (Lua API),
reachable through block.method in its server API.
T3 Code: conditions for reconsidering a provider
Assessment dated 2026-11-18: T3 Code (MIT licence,
pingdotgg/t3code) is a candidate workspace runtime,
with no supported Jig integration beyond the worktree hooks above. It is a
server that runs Claude Code, Codex, Cursor, OpenCode and other agents in
threads, with web, desktop and phone clients. What it offers
Jig’s tooling today:
- A seam for a workspace provider: a thread can open in
a worktree of its own, and the repository’s
t3.jsonscript runs the create hook there. Isolation is optional:t3 thread startruns in the project folder unless it is given--worktree <base-branch>, so a launcher would pass that flag, or parallel agents share one checkout and no create hook runs. - MCP thread tools for agents it did not start
(
t3_thread_launch,t3_thread_wait,t3_thread_read,t3_thread_list), and the same tools on the host ast3 thread start,send,showandlist(outside agents). - A provider instance per subscription account: each Claude instance names
its own
CLAUDE_CONFIG_DIR(Claude provider). - A headless server,
t3 serve, ort3 upas a background service (remote access).
Reconsider a provider when each prerequisite can be checked:
- A stable release is available; T3 Code is at 0.1.x, with nightly prereleases.
- It offers a hook before a worktree is removed, so the remove hook can park reflection findings without a wrapper and cleanup policies cannot bypass it.
- Usage per subscription account is readable by a program. Its Usage → Limits
view shows per-account quotas, refill windows and the provider’s reset
times, which the dispatcher’s wall needs, but its
documentation names no command or API that returns them, only the
application’s own views and the
/usage-limitscomposer command. - Jig’s plugin skills and hooks are confirmed to load in its threads, under each provider instance’s configuration directory.
The first integration would be a workspace provider for the launcher. The dispatcher’s session runtime would follow once its account usage is readable and the dispatcher’s subscription-account binding (ADR-0011) can map onto its provider instances.
Package managers — the wrong-root-install footgun
The footgun ban “no root install with the wrong package manager” is concrete per ecosystem: each manager owns a lockfile that a foreign install rewrites, breaking every sibling worktree that shares it. Detect the declared manager (derive from the lockfile present) and reject the others.
| Ecosystem | Declared by (lockfile) | The wrong-root-install that bites | Mechanizable check |
|---|---|---|---|
| Node | pnpm-lock.yaml / package-lock.json / yarn.lock / bun.lockb | running a different manager’s install at the root rewrites/duplicates the lockfile | a hook asserting the lockfile matches the declared manager before install |
| Python | poetry.lock / uv.lock / Pipfile.lock | a bare pip install into the shared env instead of the project’s | pre-commit / setup check that the project manager is used |
| Rust | Cargo.lock | hand-editing or a divergent cargo update at the root | review + lockfile-drift gate |
| Go | go.sum | go get bumping shared module state mid-session | go mod verify in a gate |
The general rule: derive the package manager from the repo (don’t declare it) and treat any other manager’s root install as the banned action.
Reading the host’s load, per platform
The lock admits a run beyond the first only while the machine has room for one more. What the reading rests on differs by platform:
| Platform | Load | Available memory | Effect |
|---|---|---|---|
| Linux | the one-minute load average | MemAvailable from /proc/meminfo | load and memory both decide |
| macOS | the one-minute load average | none: the system reports only its free pages, which count reclaimable caches as used | load and the slot ceiling decide |
| Windows | none (the platform keeps no load average) | the free memory the system reports | memory and the slot ceiling decide |
Set LOCK_RUN_COST to the parallelism of the command the lock guards (a test
runner’s worker count, a build’s job count), so a run just started counts at
what it will add. A lock that guards a resource only one user may have at a
time (a fixed port, a shared database), rather than the machine’s capacity,
keeps LOCK_SLOTS=1: a plain mutex.
CI providers — why (and how) the lock bypasses
A CI runner already gives each job its own isolated machine, so the
cross-worktree lock has nothing to bound there and the wait would be pure
added latency. with-resource-lock.ts therefore runs the command unlocked when
it sees a CI signal. Most providers set CI=true automatically, so the bypass is
usually zero-config; the column below is the signal to rely on (or set
RESOURCE_LOCK_BYPASS=1 explicitly).
| Provider | Auto-set signal | Note |
|---|---|---|
| GitHub Actions | CI=true | also GITHUB_ACTIONS=true; the default CI is enough |
| GitLab CI | CI=true | also GITLAB_CI=true |
| Buildkite | CI=true | one agent per job — already isolated |
| Jenkins | CI not guaranteed | set RESOURCE_LOCK_BYPASS=1 (or CI=1) in the job env |
Locally, leave heavy commands wrapped:
LOCK_RUN_COST=4 bun with-resource-lock.ts --lock test -- pnpm test # admitted by the machine's loadIn CI, run them unwrapped or wrapped — either way the bypass makes them run immediately:
# GitHub Actions — CI=true is already set, so even a wrapped command runs at once
- run: pnpm testThe lock is the same mechanism M1 points to for heavy pre-push gates; a repo that adopts both wraps its heavy gate once and gets the cross-worktree bound locally and the isolation-based bypass in CI for free.
Per-worktree data namespaces
The name comes from
reference/worktree-namespace/; the create
writes the owner and the expiry beside it; the reaper reads them back into
the decision script’s inventory and drops what it lists, after the report.
The drop decides each name again under a per-name lock the create also
holds, from a fresh census, because a worktree can come back on the same
branch between the report and the drop
(the reference’s drop step).
The same shape on every database: only the commands differ.
| Database | Create, with owner and expiry | Inventory for the reaper | Drop |
|---|---|---|---|
| PostgreSQL | CREATE SCHEMA "$NS"; COMMENT ON SCHEMA "$NS" IS '{"owner":"$USER","expires_at":"<ISO 8601>"}'; the migration runner sets search_path to the namespace, and production (the public schema, no prefix) needs an explicit opt-in flag | SELECT jsonb_agg(jsonb_build_object('name', n.nspname) || coalesce(obj_description(n.oid, 'pg_namespace')::jsonb, '{}'::jsonb)) FROM pg_namespace n | DROP SCHEMA "$NS" CASCADE |
| MySQL / MariaDB | CREATE DATABASE $NS; owner and expiry in a worktree_namespaces table, since a database carries no comment | SELECT name, owner, expires_at FROM worktree_namespaces joined with SHOW DATABASES | DROP DATABASE $NS |
| MongoDB | a database per worktree, owner and expiry as a document in a namespaces collection of an admin database | that collection, joined with listDatabases | db.dropDatabase() on the namespace |
| A branching database host (Neon, PlanetScale) | a branch per worktree, named by the script, with the host’s expiry or a tag for owner and expiry | the host’s branch list | the host’s delete-branch call |
| SQLite | a file per worktree under a gitignored directory, owner and expiry in a sidecar .json | the directory listing | delete the file and its sidecar |
| Redis / Valkey | a key prefix per worktree rather than a database; owner and expiry in a hash under the prefix | SCAN by the prefix, reading the hash | UNLINK the keys under the prefix |
A production target is refused in the migration runner (the empty prefix
needs an explicit flag), in the reaper (--production <name> is never a
candidate), and wherever the drop runs, so no single mistake reaches it.
Control channels
The invariant: an unattended agent is reached through a closed set of directives that code enforces and that fail closed, plus notes that only advise. The mechanisms an agent runner already has cover part of that; the table says which part.
| Mechanism | Binding directives | Advisory notes | Fails closed | Note |
|---|---|---|---|---|
drive-pr’s drive mailbox | hold-push, pause, stop, each with its resume | yes, read by choice with mailbox.ts check | yes: an unreadable inbox or directive holds the push and stops the loop | the reference; two append-only files under the worktree’s .context/drive-mailbox/ |
A process signal (SIGKILL) | termination only, immediately rather than at a safe point | no | not applicable | the hard kill the channel exists to avoid needing |
A runner’s message to a running subagent (Claude Code’s SendMessage) | none: the message enters the agent’s context, and the agent decides | yes | no | suits a subagent in the same session; give it nothing it must obey |
Typing into the agent’s terminal (tmux send-keys) | none | yes, but as if the person typed it | no | free text with the force of a person’s instruction, which is what keeping notes advisory prevents |
A runner’s own messaging covers the notes; the directives need code at the agent’s checkpoints, whichever runner starts it.
The reference’s layout: two append-only files in the worktree’s scratch
directory (.context/drive-mailbox/), an inbox any sender appends to and an
outbox only the agent writes, recording what it has read and answered. Each
append takes a lock, so concurrent senders never interleave a line. A hold
sent while the push’s own pre-push hooks run lands after the push’s first
check; running push-hold-recheck.ts as the last pre-push hook command
closes that window
(drive-pr README § Push hold).
Change notes — per ecosystem
The invariant: no pull request edits a file every pull request edits. Each
change adds a note of its own, and one run at a time on the integration branch
writes the notes into the changelog and moves the version. The tools that do
it (the plugin’s changelog skill,
Changesets, towncrier, scriv, changie), the ones that generate the changelog
from commits instead, and how the release reaches a protected branch are in
M16’s mappings, with the rest of the
release practice.
One neighbouring approach removes the conflicts without notes, and is not
enough: a union merge driver (CHANGELOG.md merge=union in
.gitattributes) lets git keep both sides of a local merge, but places lines
without knowing the changelog’s sections, does nothing for the version, and
GitHub’s mergeability check does not use it: the pull request still shows as
conflicting.
Agent-facing gate output
The invariant: a gate speaks to an agent in a condensed voice on green and
in full on red, keeps its own exit status, and prints one verdict line per
part. Two seams carry it: the runner’s own flags, and a wrapper the
repository or the agent runtime applies. The wrapper is
reference/quiet-run/; the flags below condense
less than it does, but cost nothing to adopt.
Runner flags
| Runner | Quieter on green | On red | Trap |
|---|---|---|---|
go test (no -v) | one ok / FAIL line per package: the verdict-per-part shape, built in | a failing package prints its output in full | -v turns every test into a line again |
| pytest | -q (or -qq), --tb=short | failures keep their traceback | an argument that matches nothing must fail the run, not report that no tests ran: the wrapper’s shell sets its no-match option (failglob) for that reason |
| vitest | --reporter=dot | failures print in full under every reporter | --silent drops the tests’ own console output, which is often the diagnostic |
| Jest | --reporters=summary | the same | --silent, the same |
bun test | no condensing flag: wrap it | — | — |
cargo test | -q | failures print in full | — |
| Biome | --reporter=summary | the summary lists each failing rule | — |
| ESLint | — | — | --quiet hides warnings, not success noise: with a ratchet counting warnings (M1) it hides what the ratchet counts |
tsc | prints nothing on success already | errors only | — |
| Turborepo | --output-logs=errors-only: a task’s log only when it fails | the failing tasks’ logs | without --continue, the first failure stops the rest, and their missing verdicts mean did not run; with it, every part runs and gets its line |
The pipe trap
bun test | tail -n 30 exits with tail’s status, so the suite’s failure is
gone before anything reads it. set -o pipefail keeps the failing status
in bash and zsh, but it is off by default and a hook’s shell is not always
the agent’s; the wrapper captures the status from the command itself and
needs no shell option.
Agent-runtime hooks
A runtime that can rewrite a command before it runs applies the wrapper automatically; where it cannot, the quiet package script named in the instruction file is the seam, and the agent runs it by convention.
| Runtime | Seam | Contract |
|---|---|---|
| Claude Code | a PreToolUse hook on the Bash tool | reads the tool call as JSON on standard input (tool_input.command), replies with hookSpecificOutput.updatedInput.command holding the rewritten command; it must not reply with a permission decision, since a rewrite is not a review of the command, and the rewritten call goes through the normal permission flow |
| any runtime | the quiet script (test:quiet, lint:quiet) the instruction file names | the agent runs it by convention; no rewrite |
The hook’s safety model fails towards showing more, never towards hiding a failure:
- it rewrites only a command that, trimmed, is a plain invocation of a known runner (an allowlist of exact prefixes, each followed by a space or the end), and the check for shell punctuation runs before the prefix match, so a rewrite can never start a second command;
- anything with a pipe, a redirect, a subshell, a quote, a newline or a
background run passes through untouched, and so does an inspection flag
(
--help, a dry run, a collection-only run, a coverage or durations report, a watch or debugger mode): those outputs are the payload, and a tail of them would be wrong, not merely short; - the rewritten command captures the exit status from the runner itself and bounds what it captures;
- a cancellation prints what was captured before re-raising the signal, so a run killed by the tool’s own timeout leaves its diagnostics behind;
- the shell the wrapper hands the command to fails an argument that matches
nothing (
failglob), so a mistyped test path cannot pass as “no tests ran”.
Measuring merge conflicts
The invariant: a repository working in parallel measures where its merges conflict, and each hotspot is removed at its cause or kept by a recorded decision. This works across ecosystems because the evidence is in git.
Run the plugin command from its installed cache, with the repository as the
working directory (<skill-dir> is the installed resolve-conflicts skill):
bun <skill-dir>/scripts/history.ts --days 30 --json > <scratch>/merge-conflicts.json| Source | What it observes | Limit to retain with the report |
|---|---|---|
git replay (history.ts) | reachable merge commits, their conflicted paths and region causes; the Conflicts resolved: commit section adds decisions and reasons | requires git 2.43 or later (2.45 in a partial clone); never fetches; shallow boundaries can hide merges; squashed branches and rebase stops may leave no replayable merge |
clone-local live record (resolve-conflicts) | resolutions of merges, rebases, cherry-picks and reverts, including time and whether drive-pr started them | events live in git’s common directory and cover this clone only; no event does not mean no conflict |
| the repository’s M11 event pipeline | the same conflict events sent through its own emitter | coverage depends on where that emitter runs; see M11 |
The replay does not read the live record. The replay JSON schema is
merge-conflicts/v1. Keep the window, scope, skipped
merges and cause-accuracy statement with the path rankings. The threshold
is resolve_conflicts.hotspot_min_merges (default 3). Choose a remedy from
the reported cause: derive counts, move release versions after the merge,
or keep entries in separate files; an overlapping change still needs a
decision about the work itself. Record the hotspot’s cause, remedy or keep
decision, reason and revisit condition in the repository’s learning loop.
With Jig’s reflection on, bun <skill-dir>/../reflect/scripts/reflect.ts hotspots <scratch>/merge-conflicts.json
notes each hotspot as a reflection finding whose class is its cause; the
reflection’s escalation and review then record the remedy, or a keep
decision: a dismissal whose reason says the cause is kept on purpose and
names the condition for revisiting it.
Compare like windows after the change rather than treating an empty or
partial report as proof that the cause is gone.
Machine resource collection schedules
The invariant is a daily report and a weekly collection, with explicit
executable paths and environment. The installed plugin copy owns the command;
a worktree checkout cannot host a job that may remove that checkout.
jig install gc previews the repository bounds and installs on
confirmation (--yes); the first install, before the plugin’s jig command
is on PATH, runs from the installed copy as
bun --no-env-file --config=<plugin>/gc/bunfig.toml <plugin>/jig.ts install.
See the command for its configuration, proof
requirements and rollout limits.
| Platform scheduler | Installed file or entry | Cadence | See the last run | Remove |
|---|---|---|---|---|
| macOS launchd | ~/Library/LaunchAgents/dev.jig.gc.plist | StartCalendarInterval.Hour, from machine gc.hour | jig status gc; launchctl print gui/<uid>/dev.jig.gc; collection receipts | jig uninstall gc --machine --yes |
| Linux systemd user timer | ~/.config/systemd/user/jig-gc.service and jig-gc.timer | OnCalendar, from machine gc.hour | jig status gc; systemctl --user status jig-gc.timer; journalctl --user -u jig-gc.service; receipts | jig uninstall gc --machine --yes |
| cron fallback | Current user’s crontab, marked # jig-gc | Daily hour field from machine gc.hour | jig status gc; collection receipts; scheduler’s own mail or logs | jig uninstall gc --machine --yes |
The command chooses collection on machine gc.collect_day or under
gc.min_free_bytes pressure; other daily runs report. Removing one repository
keeps the job while another repository or machine-level kind remains.
Worktree collection through a workspace runtime: Orca is the runtime
supported so far. It applies on a machine whose gc.orca.command names Orca;
the runtime’s agent registry stands in for the opener’s lock, an agent that has
not finished or an unreadable registry keeps the worktree, and the removal goes
through Orca. See the Orca binding.
What the module provides
| Piece | What it is |
|---|---|
templates/WORKTREE-ERGONOMICS.md | The copyable model: every rule, with the footgun table |
templates/branch-discipline.md | The branch reuse-before-create rule and the footgun bans, written to be imported into an agent instruction file |
templates/worktree-hooks.md | Create-hook (allocate and print the port slot) and remove-hook (nudge reflection) skeletons |
reference/port-allocator/ | The deterministic per-worktree port allocator |
reference/resource-lock/ | The cross-worktree heavy-run lock, admitted by load, with its CI bypass (shared with M1) |
changelog skill | The change note’s procedure, the branch check that holds pull requests to it, and the release step that writes the notes in after the merge (M16’s runnable form too) |
reference/worktree-namespace/ | The per-worktree data namespace: the name derived from a worktree’s identity, and the reaper’s decision (which of one owner’s namespaces are expired or orphaned, which were created unlabelled, with production refused) |
reference/quiet-run/ | The quiet-run wrapper: a verdict line and the tail on green, everything on red, the command’s own exit status; with its self-test |
drive-pr’s drive mailbox | The control channel into an unattended review loop: notes, and the hold-push, pause and stop directives with their checkpoints |
resolve-conflicts history report | A read-only replay: paths, causes, hotspots and coverage |
mappings.md | Worktree managers and agent runners, package managers, CI providers, change notes and the union merge driver, per-database namespace commands, test-runner quiet flags and the command-rewriting hook per agent runtime, control channels |
| maturity criteria | The criteria the audit skill scores |
Each reference utility is a Bun script with a self-test. The port allocator
stands alone; the resource lock imports the shared helpers under the Jig
repository’s plugin/shared/, and the namespace scripts import helpers from
its lib/, so run them from a pinned Jig checkout or vendor those directories
at the same place relative to them
(their README).
Left out by design
- Local values. Port ranges, lock names, hook-manager wiring, the notes directory and the version files are each repository’s own; the scripts take them as arguments or ship with neutral defaults.
- The release itself. Which changes get an entry, how the version is chosen, how a release is tagged and who may push it are M16’s.
- Repositories without parallel agents. The worktree practices (branches and footguns, ports, the heavy-run mutex, worktree hooks and namespaces, the teardown nudge) are expected-absent for a repository that never runs parallel agents on one machine: with a single checkout there is nothing to partition, so scoring them “absent” is correct, not a gap. The gate-output practices (the quiet form, its self-test, one verdict line per part) apply to any repository where an agent runs the gates, single checkout or not. The change-note criteria are expected-absent where no changelog or version changes with each pull request, and the control-channel criterion where no agent runs unattended. Merge-conflict measurement applies wherever people or agents work in parallel, including across machines; it is expected-absent only where work never runs in parallel.
- A control channel the agent must obey in free text. Notes stay advisory by design; see core piece 9.
Future
- Probe-for-free port fallback (walk to the next open port on a detected clash), described in the port-allocator README; it is not shipped, to keep the allocator stateless and dependency-free.
- A runnable workspace lifecycle, and cross-worktree locks as shared tooling, are later work in the roadmap.
- Resource collection rollout. The runner and first adapters are in the plugin. Moving in the operated worktree reaper and its opener’s lock, validating the installed weekly sweep, and then adding container, branch and registered-process kinds remain in roadmap item 24, following the design’s build order.
- A copyable command-rewriting hook that applies the quiet wrapper in an agent runtime: the contract and the safety model are in mappings.md, and each repository writes its own until a second runtime shows what two such hooks share.
- Jig’s own gate runner in the quiet form.
scripts/gates.tsruns each step with its full output and prints one line at the end, so Jig’s record scores piece 8 absent; wrapping its steps inreference/quiet-run/, one verdict line per step, is open work.