jacked tests run --on <label> -- <gate command> runs a gate on a
machine that the user chooses and reaches with ssh (a LAN host, a host on a
Tailscale network, a rented server), and records it in the local history. The gate runs the
commit that was sent. A lost connection never gives a verdict. The laptop does no test work.
Spec:
2026-11-25-test-diet-design.html: the
section "A gate on a different machine", the acceptance item "Gate machine", the table "The
owner's answers (2026-11-26)" (the rows "The gate machine" and "A gate on a different machine when
the connection drops"), and the table "Changes during the build". The owner asked for two lanes: a
runner lane for CI, whose provider is open, and run --on, a gate "on a machine of
your own choosing across like ssh via tailscale or something like that" for each user of
jacked.
The second review found nine open defects in the first design. Most of them were in the parts that made it a job runner: a queue, a lock for one full gate at a time, detach and attach, cancel, a run that two sessions share, and pending runs. This design has none of those parts. Two decisions remove them, and the two have different sources:
These rules follow from the two decisions:
cmd > log 2>&1; rc=$?.The review report is .superpowers/sdd/gateplan-review3.md: 1 CRITICAL, 13 MEDIUM,
8 LOW. Each row gives the finding, the change, and the section that holds it.
| Finding | Change | Section |
|---|---|---|
| L1 CRITICAL: a half-open connection | A heartbeat byte each 15 s on standard
input; 60 s of silence takes the stop path of the end of input. The stop path writes nothing
to the session streams. A CI test stops the beats with the pipe open and an unread gate
output. The live proofs stop the local ssh with kill -STOP. |
Decisions "The life of a gate"; Task 2; Task 5 |
| L2: the reap race | The exit of the leader is found with no reap
(os.waitid with WNOWAIT on Linux, select.kqueue on
macOS). Then the group stop, then the reap. One lock and a reaped flag. The
leftovers of a normal exit are stopped too. | Decisions "The life of a gate" |
| L3: the RAM floor | machines add and machines set take
--priority and --min-free-mb. The driver reads free memory each 5 s.
A source for each OS; no floor on macOS. | Decisions "Machine list", "Priority and the free-memory floor" |
| L4: Windows stop, lock, delete order | A job object of the driver, with a leader process so that nothing of the gate starts outside the job. The delete order keeps the marker until the content is gone. | Decisions "The life of a gate", "Live runs and
gc" |
| L5: the driver dies | POSIX: the lock descriptor goes to the setup and the gate
(pass_fds). Windows: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. A
kill -9 test. | Decisions "Live runs and gc"; Task 2 |
L6: have and retention | have gives the tips of
refs/jacked/keep/*. A new keep ref replaces each keep ref that it contains.
gc prunes the worktree registrations and, on request, old keep refs. No git call
of the driver starts an automatic gc. | Decisions "Sending the commit", "The gate clone
and the worktree", "Live runs and gc" |
L7: seen --on and the setup | The setup text and the sorted
--env names are in inputs_sha. seen --on takes
--setup and --env. --input with --on is
refused. | Decisions "The record"; Task 3 |
L8: clean_after | Defined with git status; the changed
paths come back as a stream and print as in a local run. | Decisions "The result" |
| L9: the RUN grammar | RUN is the record's run ID, with the pattern string of
history.RUN_ID_RE, ASCII digits only. A test compares the two strings. |
Global constraints |
| L10: exit 75 and the probe line | "no verdict, exit 75" with the reason, apart from "the gate returned 75". The load and the free memory print before the gate. | Decisions "The record" |
| S1: destination in messages | -E and LogLevel=ERROR
on ssh; the standard error of scp goes to the same log. The driver
prints paths relative to its root and the class name of an unexpected error. The scope of the
rule is stated. | Global constraints; Decisions "Transport" |
| S2: host keys and connection sharing | StrictHostKeyChecking=yes,
ControlMaster=no, ControlPath=none,
PermitLocalCommand=no on ssh and scp. |
Decisions "Transport" |
| S3: argv to a remote shell | The gate runs as argv with no shell on each OS.
Only --setup uses a shell. A test sends an argument with a space,
&, %PATH% and $HOME. | Decisions "The gate command"; Task 2 |
| S4: a different host under a label | The probe of each run and the result must give the stored machine identity. A mismatch gives exit 75 and no record. | Decisions "The machine identity" |
| S5: the list grammar | An alias grammar with no @, :
or /; a python grammar that refuses . and -c; the label
local is refused. | Decisions "Machine list" |
| S6: the install temp name | The temp name and the 12-hex hash are in the grammar. | Global constraints; Decisions "Driver install" |
| S7: bounds and terminal escapes | A 1 MiB limit on the result line; each stream to disk, with its SHA-256 and a free-space check; the gate output goes through a filter that keeps colors and removes other escape sequences. | Decisions "Reading the result" |
| T1: the Python floor | The floor is jacked's own requires-python
(3.11). The archive refuses an older interpreter with one line. The driver tests run under
uv run --python 3.11, and the refusal runs under a real 3.10. | Global constraints; Tasks 1 and 2 |
T2: monkeypatch and a child | Each test list says which tests import the package and pass fakes as arguments, and which run the built archive as a child. The driver has no test-only environment variable. | Tasks 1 and 2 |
T3: a test that starts a real ssh | An autouse tripwire in
tests/conftest.py, built first. | Task 1 |
| T4: proofs of the owner's machines | A table of each proof that only those machines can give, and each write to each machine, marked "needs the owner's go-ahead". | Proofs that only the owner's machines can give; Task 5 |
| G1: the owner's answer | Settled by the owner on 2026-11-26: "Stop on drop, no reattach". The plan cites the spec row. The lock for one gate at a time stays dropped, as my call. | Why this design is smaller |
| G2: size and arguments | The driver is a zipapp built from a small package; the
local side is five modules; run_on takes one options object. | File structure; Task 3 |
| G3: cadence and the leak sweep | Targeted tests per task with the
grep -rl hits, the scanner, help-copy and pin tests; one full suite at the end
through jacked tests run --kind full; /dcr beside it; a local sweep
for machine names before the first push; hosted CI before the live proofs, so the Windows code
first runs on a hosted runner, not on the owner's machine. | Tasks 3 to 5 |
| R1: reuse and small items | A copy of the remove rule with a Windows test; the
processor time of the gate only; a setup_seconds field; two machine identities
accepted and stated; no shell layer for the gate. | Decisions "The machine identity", "The result", "The record" |
sequenceDiagram
participant L as Local: remote_run.py
participant D as Gate machine: gate_driver-HASH.pyz
L->>D: probe
D-->>L: driver hash, Python, git, OS, disk, load, free memory, machine identity
L->>D: have REPO
D-->>L: the tips of refs/jacked/keep/*
L->>D: gate REPO SHA RUN (stdin: JSON header, git bundle, then one heartbeat byte each 15 s)
D->>D: lock the run folder, fetch the bundle, add a worktree, run the setup and the gate
D-->>L: gate output on standard error, live
D->>D: stop the group or the job, read the reports, remove the run folder
D-->>L: result JSON line, then the streams (reports, changed paths) on standard output
L->>L: check each value and each stream, read the reports, write the record with the label
local remote_run.py -> driver: probe -> hash, Python, git, OS, disk, load, free memory, machine identity local -> driver: have REPO -> the tips of refs/jacked/keep/* local -> driver: gate REPO SHA RUN (stdin: header, bundle, then a heartbeat byte each 15 s) driver: lock the run folder, fetch the bundle, add a worktree, run setup and gate; output on stderr live driver: stop the group or the job, read the reports, remove the run folder driver -> local: result JSON line, then the streams on stdout local: check each value and stream, read the reports with the recorder's reader, write the record
The global constraints of the recorder plan apply. These are added.
jacked/testdiet/gate_driver/. Each import in it is a module of the standard library
or a relative import of the package (from . import grammar). So the same files run
as jacked.testdiet.gate_driver in the tests and as the top-level package
gate_driver in the archive. It needs Python 3.11 or later, its standard library,
and git.FLOOR = (3, 11) is the lower bound of requires-python in
pyproject.toml, and a test compares the two. Hosted CI runs Python 3.11 on Linux,
macOS and Windows, so each driver test also proves the floor on the three systems. The driver
never uses a call that is newer than the floor without a version branch (for example
shutil.rmtree(onexc=...) is 3.12; the copy of the remove rule keeps the
onerror branch for 3.11).jacked/testdiet/driver_build.py builds a zipapp,
gate_driver-<HASH12>.pyz, in memory from the package files. Each entry has a
sorted place, the date 1980-01-01 00:00:00, the mode 0644 and no compression
(ZIP_STORED). There is no __pycache__. So one jacked build always
gives the same bytes and the same hash. zipapp.create_archive is not used, because
it keeps the file times. HASH12 is the first 12 hex characters of the SHA-256 of the archive.
The archive's __main__.py is a copy of gate_driver/archive_main.py. It
holds only the floor check and the call of gate_driver.cli.main, in a syntax that
each Python 3 can parse. So an older interpreter gets the one refusal line, not a
SyntaxError.re.fullmatch on both sides:
history.RUN_ID_RE,
(\d{8})T\d{12}Z-[0-9a-f]{8}. The driver compiles it with re.ASCII, so
\d is only 0 to 9. A test asserts that the two pattern strings are equal, and that
the driver refuses a RUN with a digit that is not ASCII. RUN is the record's run ID:
run --on makes it with history.new_run_id() before the gate, and the
run folder, the temporary ref and the record use it. (A local run makes its ID after the gate;
a remote run makes it first, because the ID crosses SSH.)[0-9a-f]{40}([0-9a-f]{24})?. REPO: [0-9a-f]{16}. HASH12:
[0-9a-f]{12}.gate_driver-[0-9a-f]{12}\. + RUN +
\.part.probe, have, gate, gc,
install. The driver also has the verb leader (Windows only). Only the
driver starts it, on its own machine; the local side never sends it.gc) goes in a
JSON line on standard input.os.kill. The decision "The life of a gate"
gives the mechanisms.gc delete a run
folder only when the rule of the decision "Live runs and gc" holds. The rule reads
only the folder's own name and content.ssh go to a private log
(-E), and a message gives the exit code and the local path of that log. The driver
prints paths relative to its root (runs/<RUN>/...). It captures the standard
error of git and prints one line with the exit code of git. Its main() catches an
unexpected exception and prints its class name only; the traceback goes to
root/driver.log. The gate's own output is the output of the user's own command: it
passes through the output filter and can hold remote paths (pytest prints
rootdir:).ssh or
scp. An autouse tripwire in tests/conftest.py enforces it
(Task 1). The tests use LocalTransport: the built archive as a child process, with
a temporary home and a pipe pair. The live proof covers the real SSH paths (Task 5).gc can remove it. Tests in Tasks 2 and 3; live proof in Task 5..., a have answer of --all, an ssh value that
starts with - or holds @, a header with a JUnit glob or a folder of
../x, an argument with & or %PATH%. Expected: refused
on both sides, or passed as typed with no shell. Tests in Tasks 1, 2 and 3.gc. Expected: gc never removes the folder of a live gate. Tests in
Task 2.kill -9). Expected: gc keeps the folder until the last process of the
gate is gone. Test in Task 2.--on
refuses it, because only a commit can be sent. Test in Task 3.JACKED_GUARDRAILS.md sets 500 lines for each module and 4 arguments for each function. So the
driver is a package and the local side is five modules. The click commands are in
jacked/testdiet/, not in jacked/cli.py, because cli.py is
at its size limit (the spec table "Changes during the build", row "Where the commands
live").
| File | Responsibility |
|---|---|
The driver package jacked/testdiet/gate_driver/ (runs on a gate machine; standard library only) | |
archive_main.py | The source of the archive's __main__.py: the floor check, then cli.main. |
cli.py | main(argv): the verbs, the exit codes, the catch-all. |
grammar.py | The patterns, check(kind, value), the header checks, FLOOR. |
root.py | The root checks, the machine identity, the driver log, install. |
probe.py | probe; the free memory, the load and the free disk for each OS. |
files.py | The run lock, the marker, the copy of the remove rule, the PATH-only program search. |
gitsteps.py | The gate clone, the fetch, the worktree, the keep refs, have, the status after the gate. |
gate.py | The verb gate: the header, the bundle, the run folder, the setup, the gate, the result, the delete order. |
watch.py | The input thread, the heartbeat, the memory watch, the one lock of the stop decision. |
posix_proc.py | The new session, pass_fds, the priority argv, the exit with no reap, the group stop. |
windows_proc.py | The job object and the leader (ctypes), the priority class, the processor time of the job, the absolute path of cmd.exe. |
collect.py | The verb gc. |
The local side (jacked/testdiet/) | |
driver_build.py | The archive build, its hash, the install over scp. |
gate_machines.py | The machine list: its grammar, load, add, set, remove. Not machines.py: machine.py already holds the identity of the local machine, and two names one letter apart are a trap. |
transport.py | The Transport protocol, SshTransport (the ssh and scp lines, the private log), the heartbeat writer. |
remote_run.py | RemoteRun and run_on: the probe check, the have check, the bundle, the header, the record. |
remote_result.py | The result reader with its bounds, the streams, the output filter. |
gate_commands.py | The click group jacked tests machines, added to the recorder group. |
commands.py, model.py, views.py | The options --on, --setup, --env of run and seen; the field setup_seconds and the inputs_sha doc line; the setup share in profile. |
jacked/data/rules/jacked-reference.md, README.md | How to add a gate machine, the SSH alias, the setup command, a background run, the limits. |
| Tests | |
tests/conftest.py, tests/unit/test_ssh_tripwire.py | The tripwire and its test. |
tests/unit/gate_local_transport.py | LocalTransport: the built archive as a child with a temporary home. It is test code, so it is not in the package. |
tests/unit/test_testdiet_gate_driver.py | In-process tests of the driver package, with fakes passed as arguments. |
tests/unit/test_testdiet_gate_protocol.py | Child-process tests of the built archive: the protocol, the process control, the locks, gc. |
tests/unit/test_testdiet_gate_machines.py, test_testdiet_remote_run.py | The local side, with LocalTransport. |
| Subject | Decision | Reason |
|---|---|---|
| Machine list | jacked_home()/.claude/jacked-gate-machines.json,
written only by the machines commands through atomic_write_bytes with
mode 0600: {"version": 1, "machines": {"<label>": {"ssh": "<alias>",
"python": "python3", "workers": N, "priority": "low" | "normal", "min_free_mb": N | null,
"os": "linux" | "darwin" | "win32", "machine_id": "<32 hex>"}}}. The default
priority is low; there is no default floor. The grammar, checked at each load and
each write: a label matches LABEL_RE and is not local (the label of
local records); ssh matches [A-Za-z0-9][A-Za-z0-9._-]* (a Host alias
of the SSH configuration or a MagicDNS name, with no @, : or
/); python matches [A-Za-z0-9_][A-Za-z0-9._/\\:-]* (so
., .. and -c are refused); workers and
min_free_mb are integers of 1 or more. A load refuses a file that group or others
can read (POSIX). machines add LABEL --ssh ALIAS [--python NAME] [--workers N] [--priority
low|normal] [--min-free-mb N] installs the driver, probes, and stores the identity and
the OS. machines set LABEL takes the same options (--min-free-mb none
removes the floor), with the same checks and the same atomic write. A floor on a machine whose
OS is darwin is refused with one line. | The grammar makes "the list holds no
address and no user" true by itself, not by a documentation line. jacked keeps its state in
.claude/ under its home. |
| Transport | Each step is ssh -a -x -T -E <log> -o LogLevel=ERROR -o
BatchMode=yes -o StrictHostKeyChecking=yes -o ControlMaster=no -o ControlPath=none -o
ClearAllForwardings=yes -o PermitLocalCommand=no -o ServerAliveInterval=15 -o
ServerAliveCountMax=4 -- <alias> <python>
.jacked-gate/drivers/gate_driver-<HASH12>.pyz <verb> <values of the
grammar>. The upload is scp -q with the same -o options and
--, to <alias>:<TEMP>. scp has no
-E, so the local side writes its standard error to the same log.
<log> is jacked_home()/.claude/jacked-gate-logs/<label>.ssh.log
(folder 0700, file 0600, appended). ssh, scp and git
come from jacked.findbin.find_bin. Options that a user configuration can set and
that break the protocol (StdinNull, SessionType none,
ForkAfterAuthentication, RemoteCommand) are not pinned, because an
OpenSSH older than 8.7 refuses some of their names. Each one gives a protocol error and exit
75, never a verdict. machines add tells the user to connect one time by hand to
accept the host key. A host key failure gives exit 75 and the log path. Tried on a Windows host
on 2026-11-26: 1 MB of binary standard input arrived with the same SHA-256 (standard output is
a live proof of Task 5). | A value of the grammar needs no quoting in a POSIX shell,
cmd.exe or PowerShell. The gate machine never gets the local SSH agent. What
crosses is the full history that the commit reaches and the --env values, so the
host key must be known (the first value of an option wins, and the command line comes first).
No run becomes a channel of a master connection that a different ssh opened, with
keepalive settings of its own. PermitLocalCommand=no stops a
LocalCommand of the user configuration from writing into the result stream. The
local ssh finds a dead link in about one minute; the gate machine finds it with the
heartbeat. |
| Driver install | scp sends the archive to TEMP in the remote home.
<python> <TEMP> install checks that the first 12 hex characters of the
SHA-256 of its own file are the hash in its name. It makes or checks the root, then moves itself
with os.replace to
.jacked-gate/drivers/gate_driver-<HASH12>.pyz. probe answers
with the hash of the driver that runs. When Python cannot open the driver file (Python's own
exit code 2), run --on installs the driver and probes one more time. Old drivers
stay; gc lists them, and removes each one other than the running one only when its
options ask for it and no run folder is live. | Two jacked builds must not replace each other's driver in the middle of a run. A driver file is about 100 KB, so to keep old ones costs nothing that matters. |
| Driver exit codes | 0: done. 64: a refused value. 65: a protocol error (the
header, the bundle, a byte after the bundle that is not the heartbeat byte). 66: Python is older
than the floor; one line names the two versions. 75: stopped, no verdict. Never 2, which is
Python's own code for a file that it cannot open. The exit code of the gate travels in the
result line, never as the exit code of the driver or of ssh. Each other exit code
of ssh or of the driver (for example 127, when the remote shell finds no Python)
gives exit 75 and one line with the code, the label and the log path. | The local
side must tell "no driver" from "a refused value", and the exit 255 of ssh from a
gate code. |
| Root on the gate machine | ~/.jacked-gate, resolved by the driver
with Path.home() (HOME on POSIX, USERPROFILE on Windows). No path crosses SSH. The
root, drivers, repos and runs have mode 0700 on POSIX.
The driver refuses a root that is a link, that the user does not own, or that group or others
can write. root/driver.log (mode 0600) holds the traceback of an unexpected error
and the messages of a stop that it cannot print. It never holds the header or an env
value. | A Windows shell does not expand ~. A test sets the home of a child,
so the driver needs no test-only variable. |
| The machine identity | The driver keeps 32 random hex characters in
root/machine-id. probe and the result of gate give it.
machines add stores it in the list. Each run --on probes before the
bundle, and the probe and the result must give the stored identity. A mismatch gives exit 75,
no record, and one line that names the label and the command that accepts a planned change:
jacked tests machines probe LABEL --accept (or remove and
add). seen --on LABEL uses the stored value and opens no connection.
No command prints the identity: machines list and machines probe
print "stored" or "matches". A gate machine that also runs jacked has two identities, the one
of its gate root and the one of its recorder. My call: accept that and say it in the reference.
A record of --on and a local record never prove each other's tree, because their
labels and their inputs_sha always differ. | The recorder never compares
two machines. A reused alias, a VM that was made again, or an edited SSH configuration must not
put the times of a second host under the label of the first. seen must not wait
on a network. |
| What is sent | Only a commit. --on refuses a tree with changes that
are not committed. --on refuses --input, in run and in
seen, because those files are not on the gate machine. The record holds the tree
of that commit. | A bundle carries commits, not a working tree. |
| Sending the commit | have REPO gives the tips of
refs/jacked/keep/* of the gate clone, one SHA on each line, and nothing else. The
local side checks each element: the SHA grammar first; then one git cat-file
--batch-check with the elements on standard input keeps each element whose type is
commit in the local repository. An element that fails a check is dropped with one
printed line. A kept tip need not be an ancestor of the sent commit: the remote holds each
commit that a tip reaches, so a tip of a different branch still removes the shared history from
the bundle. When git merge-base --is-ancestor --end-of-options <sent>
<tip> holds for a kept tip, the gate clone already holds the sent commit: the
header gives bundle_size 0 and no bundle follows (git refuses to make an empty
bundle). Else the local side makes a temporary ref refs/jacked/gate/<RUN>,
makes a bundle with git bundle create <file> --stdin (the ref, and each kept
tip as ^<sha>, on standard input), and deletes the ref. | A bundle
needs a ref name. A have answer of --all fails the grammar, which
comes first: git rev-list --stdin accepts pseudo-options from standard input since
Git 2.42. An ancestor rule would drop the only tip after each branch change or rebase, because
the driver deletes the keep refs that a newer one contains, and each such run would send the
full history. A false tip costs nothing: the fetch fails on a missing prerequisite, and the run
gives exit 75. Checked on 2026-11-26 with git 2.54 in a scratch repository: a
^<tip> of a sibling branch gives a bundle whose prerequisite is the merge
base. |
| The header | The first line of standard input of gate is one JSON
object: command (the argv list), setup (a string, or null),
env (key to value), junit (globs relative to the worktree folder),
folder (the gate folder relative to the top of the work tree, "." at the top),
workers, priority, min_free_mb (or null),
bundle_size (bytes; 0 when the gate clone already holds the commit),
silence_seconds. Then the bundle bytes. Then one
heartbeat byte, ., each 15 seconds, until the result ends. The driver refuses a
line longer than 1 MiB; a glob or a folder that is absolute, that holds a ..
part or a backslash; an env key that does not match [A-Za-z_][A-Za-z0-9_]* or
that starts with JACKED_GATE; a silence_seconds that is not an
integer from 5 to 60 (run --on always sends 60). The driver never writes the
header to a file. | A value on standard input needs no quoting and is not visible in a process list. The folder is a part of the run identity (the spec table "Changes during the build", row "The folder of the gate"). A child-process test of the heartbeat sends 5, so the driver needs no test-only variable, and no client can make the limit longer than 60. |
| The gate clone and the worktree | repos/<REPO>.git, bare, with
core.autocrlf=false, core.fsmonitor=false,
core.logAllRefUpdates=false and core.hooksPath at the null device.
Each git call of the driver has -c gc.auto=0 -c maintenance.auto=false and the
environment GIT_TERMINAL_PROMPT=0. The bundle goes into
refs/jacked/gate/<RUN>. The worktree is runs/<RUN>/tree,
made with git worktree add --detach. The driver checks that its HEAD
is the sent SHA. With bundle_size 0, there is no gate ref: the driver first checks
git cat-file -e <SHA>^{commit} (a protocol error when it fails), and adds the
worktree from the SHA. Then git update-ref refs/jacked/keep/<SHA> <SHA>
makes the keep ref (one ref for each sent commit), git update-ref -d deletes
refs/jacked/gate/<RUN>, and the driver deletes each keep ref that
git for-each-ref --merged=<SHA> refs/jacked/keep/ lists, other than the new
one (the list holds the new one too). The gate runs in
runs/<RUN>/tree/<folder>. | Nothing of a repository runs on a fetch or a worktree add. No git process of the driver outlives it as a detached automatic gc. The keep refs are a cache: a deleted one costs one larger bundle, and no data. A keep ref that a newer one contains adds nothing. |
| The gate command | The gate runs as argv with no shell, on POSIX and on Windows,
as run_gate does. Each {junit} in each element becomes the absolute
path of runs/<RUN>/reports/junit.xml (the rule of
reports.placeholder). On Windows, a bare program name is found with a search of
PATH only, with PATHEXT and never in the current folder: a copy of the rule of
jacked.findbin.find_on_path, as process._program uses it. Only
--setup, a string by nature, uses a shell: /bin/sh -c <text> on
POSIX, and on Windows the string form of Popen with <cmd> /d /s /c
"<text>", where <cmd> is the absolute path from
GetSystemDirectoryW, the rule of jacked.winproc.system_program. The
driver finds git one time, with the same PATH-only search, before it changes to a
worktree. The setup and the gate run in the gate folder, with the null device as standard
input, and with JACKED_GATE=1 and JACKED_GATE_WORKERS. No local
variable goes to the gate machine unless --env KEY names it; no value is printed
or recorded. $JACKED_GATE_WORKERS is not expanded in argv; a script of the
repository reads it. A setup that fails gives no gate, and the result says
setup-failed with the exit code of the setup. | The same typed argv means the
same thing on the two machines, as command_sha says. No argv quoting is complete
for cmd.exe (it expands %VAR% inside quotes), so the gate never goes
through it. A new worktree has none of the files that git ignores; the setup provides them. The
driver cannot import jacked.findbin or jacked.winproc, and the
scanners of jacked/ parse its files too. |
| Priority and the free-memory floor | Priority low: on POSIX, the
argv starts with nice -n 10; on Linux, when ionice is on PATH, with
ionice -c 2 -n 7 nice -n 10 (the best-effort class at its lowest level). On
Windows, the leader starts with BELOW_NORMAL_PRIORITY_CLASS, and each child
inherits it. The floor: the driver reads the free memory before the setup, and each 5 seconds
during the setup and the gate. The source for each OS: Linux, MemAvailable of
/proc/meminfo; Windows, GlobalMemoryStatusEx().ullAvailPhys with
ctypes. macOS: my call: no floor. machines add and set refuse a floor
for a macOS machine with one line, and the probe prints "free memory: not available". Below
the floor at the start, there is no gate. Below it during the run, the driver takes the stop
path of "The life of a gate". In both cases it prints one line with the two numbers, and the
result says memory-floor. | The owner's answer of 2026-11-26: their Windows
machine is a gate machine "at low priority", and it also runs other work. nice
and BELOW_NORMAL lower only the processor priority, so the floor is the only
memory protection, and a gate can take memory after its start. On Linux, MemFree
is near 0 on a busy machine because of the page cache; MemAvailable is the right
value. macOS has no value in the standard library and no single documented "available memory"
value of the same kind; a guessed value would stop gates at random. The idle class of
ionice can starve a gate on a busy disk. A floor that the user sets is not an
arbitrary cap. |
| The life of a gate | Three threads. The input thread reads standard input after
the bundle, one byte at a time; each beat sets the time of the last beat. The watch thread wakes
each second. The main thread starts the setup, waits for it, then starts the gate and waits for
it. The setup and the gate each start as a leader of their own, and each gets the same stop
path. These are the stop conditions: the end of input; a byte that is not the beat;
silence_seconds with no beat; free memory below the floor; and the exit of the
leader by itself (then the stop path stops the leftovers).
POSIX. The leader starts with start_new_session=True, so the
group ID is the PID of the leader. The main thread finds the exit of the leader with no reap:
on Linux, os.waitid(os.P_PID, pid, os.WEXITED | os.WNOWAIT); on macOS,
select.kqueue with KQ_FILTER_PROC and KQ_NOTE_EXIT
(CPython 3.11 and 3.12 for macOS have no os.waitid, checked on 2026-11-26). The
zombie keeps its PID, so the group ID stays reserved. The stop: SIGTERM to the group; a wait of
at most 10 seconds, which ends early when the group has no live member other than the leader
(Linux: the group field and the state of /proc/<pid>/stat; macOS:
/bin/ps -A -o pid= -o pgid= -o stat=); SIGKILL to the group; then the reap with
Popen.wait(), which gives the exit status that the zombie holds. One lock guards
the flag reaped. The watch thread signals only under that lock, and only while
reaped is False. The main thread sets reaped under that lock before it
reaps. A member that calls setsid() leaves the group, and the driver cannot stop
it; the reference says so.
Windows. The driver makes a job object ( CreateJobObjectW,
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, no breakaway flag; a nested job needs Windows 8
or later). For the setup, and then for the gate, it starts <python>
<archive> leader with a pipe as its standard input, assigns that leader to the
job, and only then writes one JSON line to it: the argv (or the setup text), the folder and
the environment. The leader starts the command, with the null device as its standard input,
waits for it, and exits with its code. Popen gives no handle to resume a process that it
started suspended, so the leader is the way that nothing of the gate starts outside the
job. The stop is TerminateJobObject, with no grace time: the driver has no signal
for a console process without os.kill. After the leader exits by itself,
TerminateJobObject also stops the leftovers. A job handle is not a PID, so it
cannot reach a process of other work.
The silence path writes nothing to standard output or standard error. On a half-open channel, each write blocks, as the gate does. So the stop decision, the stop and the delete never wait on a write, and their messages go to root/driver.log. The
watch thread also runs while the result is written: when silence_seconds pass with
no beat in that phase, it ends the driver with os._exit(75). Nothing is left on
the disk at that point.
The reads before the gate have the same limit. The input thread starts with the first read: a stall of 60 seconds (or of silence_seconds when the header
is read) in the header or the bundle ends the run as a protocol error. So a link that dies
during the upload does not hold the run folder and its lock either.
The time line after the last beat: at most silence_seconds
(60), plus 1 second for the check, plus 10 seconds of grace (POSIX). So no process of the gate
is left after 71 seconds. At the end of input the stop starts at once. | A laptop lid or
a network change gives no end of input. During the silence, the gate fills the SSH channel
window and blocks on its own output, so it would hold the folder, the worktree, a test database
copy and its memory for about two hours. A killpg after the reap can reach an
unrelated group that got the same ID. A gate that exits by itself can leave a database server,
an xdist worker or a background job in its group. On Windows, the job of the SSH session stops
the session processes only when the session ends, and it allows breakaway. |
Live runs and gc | gate makes
runs/<RUN>, then takes an exclusive lock on
runs/<RUN>/active.lock, then writes the marker run.json
({"run": "<RUN>"}), and only then writes anything else.
POSIX: fcntl.flock. The descriptor goes to the setup and the
gate with pass_fds. A flock belongs to the open file description, so the lock is
free only when the last process of the gate is gone, also when the driver dies. Before the
delete, the driver closes its descriptor, opens a new one, and takes the lock with no wait.
When it cannot, a process of the gate still lives: the folder stays for gc, and
one line in the driver log says so. A process that closes its inherited descriptors (Python's
subprocess does that by default) does not hold the lock, but the leader that
started it does, as long as it lives. A process that also leaves the group (a daemon) escapes
the lock and the stop. The gate is over at that point, so no verdict changes, and
gc can delete the folder under that process. The reference says so.
Windows: msvcrt.locking on byte 0. The handle is not
inherited. The job gives the same guarantee: the death of the driver closes the job handle, and
KILL_ON_JOB_CLOSE stops the gate. Windows does not delete an open file, so the
driver releases and closes the lock before it deletes active.lock.
The delete order, on each OS: (1) git worktree remove
--force of the tree, then the remove rule for what stays (a copy of the rule of
cleanup.remove_tree_quietly: a read-only file gets write permission and the delete
tries again); (2) each other entry, other than the marker and active.lock; (3)
release the lock, close it, delete active.lock; (4) the marker; (5) the empty
folder, with rmdir, never rmtree. A delete that stops part way keeps
the marker, so gc can finish it.
The rule of gc: it removes a run folder only when its name is
a RUN; it is inside root/runs after the path is resolved; it is not a link; it
holds a marker that names its own RUN; and either it can take the lock with no wait, or
active.lock is missing and the marker is the only entry. gc also runs
git worktree prune for each clone. Its options come in one JSON line on standard
input: keep_ref_days (or null) deletes each keep ref whose commit has a committer
date older than that number of days, then runs git gc --prune=now;
old_drivers (true or false). It prints each folder, keep ref and driver that it
removes and each that it keeps. | The system releases a lock when a process ends, for
each reason. A PID can be used again. The OOM killer near the floor kills the driver, not the
gate, and gc must then not delete a worktree under a live gate. The age of a keep
ref is the committer date of its commit, my call: it needs no state of its own, and a wrong
delete costs one larger bundle. |
| The result | The order: the gate ends; the stop path stops the leftovers; the
reap; the status of the worktree; the reports are read into memory; the run folder is removed
by the delete order; then the result is written. The result is one JSON line on standard
output: schema (1), exit_code, wall_seconds (the gate
only), setup_seconds (or null), child_cpu_seconds (or null),
load_start, load_end (or null), free_mb_start (or null),
commit, clean_after, report_root,
machine_id, streams (a list of {"kind": "junit" |
"changed", "size": N, "sha256": "<64 hex>"}). Then the bytes of each stream, in
order. A stop that can still write gives {"schema": 1, "stopped": "setup-failed" |
"memory-floor" | "protocol", ...} with its numbers. clean_after is True when
git status --porcelain=v1 -z --untracked-files=all --ignore-submodules=none in
the worktree prints nothing (ignored files are not in it). The status compares with the sent
commit, so a change by the setup counts. The changed stream holds the paths of
that status, relative to the repository, separated by NUL. child_cpu_seconds is
the processor time of the gate only: on POSIX, the difference of
RUSAGE_CHILDREN before and after the gate (the setup and git are outside it); on
Windows, the difference of the user and kernel time of the job
(JobObjectBasicAccountingInformation) before and after the gate. The gate's own output goes to standard
error, live. | One session, no second fetch step, no window in which a finished run waits
for a client. The run folder is gone before the write, so a write that never ends leaves
nothing on the disk. A setup that rewrites a tracked lockfile (npm install and
package-lock.json, uv sync and uv.lock) makes each remote
run "tree changed"; the reference says so. The paths go as a stream, so the result line holds
only small values and its limit is real. |
| Reading the result | The local side reads the result line with a limit of 1 MiB;
a longer line is refused, logged and gives exit 75. Each value is checked for its type: an exit
code is an integer from 0 to 255 and not a boolean, a size is a non-negative integer, a SHA-256
is 64 hex characters, the commit is the sent SHA, the machine identity is the stored one,
report_root is an absolute path of at most 4096 characters with no NUL. The local
side uses report_root only to make the paths of the report relative; it never
prints or records it. Each
stream goes to a file of a new private folder (mode 0700), under a name that the local side
makes (junit-<n>.xml, changed), with its SHA-256 computed while
it is written. A size larger than the free space of the disk of that folder
(shutil.disk_usage) is refused with one line that gives the two numbers; that is a
real limit, and the refusal is logged. A wrong value, a wrong SHA-256, a short read, or an
ssh exit of 255 gives exit 75 and no record. Then
read_junit(..., root=<top>, report_root=<report_root>) reads the
reports, the changed paths print as in a local run (one emit line each), and the
folder is removed.
The output filter, my call: the local side copies the gate output from the standard error of ssh to its own standard error through a filter. The filter
decodes UTF-8 with an incremental decoder (errors="replace"). It keeps text,
newline, carriage return, tab and SGR color sequences (ESC [ digits and
;, then m). It removes each other control character (C0, DEL, C1) and
each other escape sequence (OSC, which holds the clipboard write OSC 52; DCS; any other CSI). A
sequence that two reads split is handled. The lines of the driver pass through the same
filter. | A wrong type is not a verdict. A wrong or hostile machine must not fill the memory or the disk of the laptop, or write to its clipboard. A local gate's output passes raw, because the local machine is the user's own. The SHA-256 of each stream also proves that Windows OpenSSH did not change a byte. |
| The record | Source run; the RUN as id; the label as
machine; the stored machine_id; the tree of the sent commit;
tree_changed = not clean_after; folder =
tree.work_folder(cwd) of the local folder; schema =
model.SCHEMA; command_sha = tree.command_sha(argv,
folder=folder); inputs_sha = the SHA-256 of the canonical JSON
{"env_keys": [sorted names], "setup": <text or null>} (sorted keys, the
separators , and :, UTF-8), never a value of an env key; the remote
load, processor time and setup_seconds. setup_seconds is a new
optional field of RunMeta, so schema stays 1 (an added optional field
does not change what proves a tree). profile prints the setup share,
setup_seconds / (setup_seconds + wall_seconds), only when the record holds it, as
the spec row "Setup share" says. The doc line of inputs_sha in
model.py says what it holds for --on. seen --on LABEL [--setup
CMD] [--env KEY]... -- CMD... computes the same identity and calls
record.seen with the stored machine identity, so each rule of seen
applies, with the rows of the spec table "Changes during the build" (the folder of the gate,
the record version, the newest run decides). The output of run --on:
before the gate, one line with the load and the free memory of the probe; after it, the closing
line recorded <run id>, verdict <verdict> of a local run. When no
verdict came back, the line is "no verdict, exit 75" with the reason. When the gate itself
returned 75, the line is "the gate returned 75", so the two can be told apart. run
--on returns the gate's exit code, or 75 when no verdict came back. A signal to the
local command (Ctrl-C, SIGTERM, SIGHUP) closes the standard input of ssh, so the
driver stops the gate at once; the local command then gives exit 75 and writes no record.
--strict works as in a local run. | The same
rules as a local record. Two runs with different setups get different identities, so
seen --on never says "passed" for a setup that never passed. |
install, probe, haveFiles. Modify tests/conftest.py and the pytest
markers of pyproject.toml. Create
tests/unit/test_ssh_tripwire.py; in jacked/testdiet/gate_driver/:
__init__.py, archive_main.py, cli.py,
grammar.py, root.py, probe.py, files.py, and
the have part of gitsteps.py; jacked/testdiet/driver_build.py;
tests/unit/gate_local_transport.py, tests/unit/test_testdiet_gate_driver.py,
tests/unit/test_testdiet_gate_protocol.py.
# python gate_driver-HASH12.pyz VERB [values]
# exit codes: 0 done, 64 refused value, 65 protocol error, 66 Python below the floor, 75 no verdict
FLOOR = (3, 11) # gate_driver/grammar.py
def check(kind: str, value: str) -> str # raises ValueError; kinds: run, sha, repo, hash12, temp, verb
def floor_line(version: tuple[int, int]) -> str | None # the one refusal line, or None
def main(argv: list[str]) -> int # gate_driver/cli.py
def root(home: Path | None = None) -> Path # gate_driver/root.py: ~/.jacked-gate, checked
def free_memory_mb(meminfo_text: str) -> int # gate_driver/probe.py: the MemAvailable parse (Linux)
def build_driver() -> tuple[bytes, str] # jacked/testdiet/driver_build.py: the archive bytes and HASH12
tests/conftest.py,
an autouse fixture wraps subprocess.Popen (so also subprocess.run,
call and check_output) and fails the test when the program, after
os.path.basename and the removal of .exe, is ssh or
scp. The opt-out is the marker real_ssh, which no test of this plan
uses; register it in the markers list of pyproject.toml. It is its own
fixture, so the marker real_process of the tripwire
_no_real_service_processes does not open it; its shape follows that tripwire. HOME
isolation is not enough: OpenSSH on POSIX finds ~/.ssh from the password entry, not
from $HOME. Checked on 2026-11-26: no module of jacked/ and no test
starts ssh or scp (jacked/cli.py names them only in a
table of command descriptions), so the tripwire breaks no current test. Write test_ssh_tripwire.py, run it (FAIL), add the fixture, run
it (PASS).uv run --python 3.11 python -m pytest tests/unit/test_testdiet_gate_driver.py
tests/unit/test_testdiet_gate_protocol.py. Then prove the refusal: build the archive
with uv run python -c "import sys; from jacked.testdiet.driver_build import build_driver;
sys.stdout.buffer.write(build_driver()[0])" > "$TMPDIR/gd.pyz", then run
uv run --no-project --python 3.10 python "$TMPDIR/gd.pyz" probe. Expected: one
line that names 3.11 and 3.10, and exit 66.feat(testdiet): the gate driver checks
each value and its own root, and ships as one archive.In-process tests (they import jacked.testdiet.gate_driver, and they
pass each fake as an argument):
def test_the_tripwire_fails_a_test_that_starts_ssh_or_scp(): ... # test_ssh_tripwire.py
@pytest.mark.parametrize("kind,value", BAD_VALUES) # "..", "a;b", "--all", a trailing newline, upper case hex, a non-ASCII digit in a RUN
def test_each_value_outside_its_grammar_is_refused(kind, value): ...
def test_the_run_pattern_is_the_pattern_of_the_history_with_ascii_digits(): ...
def test_each_import_of_the_driver_package_is_the_standard_library_or_relative(): ... # ast walk, sys.stdlib_module_names
def test_the_floor_is_the_requires_python_of_jacked(): ... # tomllib reads pyproject.toml
def test_the_floor_line_names_the_two_versions(): ... # floor_line((3, 10))
def test_archive_main_parses_with_an_old_feature_version(): ... # ast.parse(feature_version=(3, 7))
def test_two_builds_give_the_same_bytes_and_hash(): ...
def test_the_archive_holds_the_package_files_and_main_only(): ... # no __pycache__, sorted, 1980 dates
def test_a_root_that_is_a_link_or_that_others_can_write_is_refused(tmp_path): ... # POSIX
def test_the_machine_id_is_made_one_time(tmp_path): ...
def test_free_memory_reads_memavailable_not_memfree(): ...
def test_the_path_search_agrees_with_find_on_path_and_skips_the_current_folder(tmp_path): ... # Windows leg
def test_the_remove_rule_removes_a_read_only_file(tmp_path): ... # Windows leg: a read-only git object
def test_an_unexpected_error_prints_its_class_name_only(tmp_path, capsys): ...
Child-process tests (they run the built archive with
sys.executable through LocalTransport, with HOME and USERPROFILE at a
temporary folder):
def test_an_unknown_verb_exits_64(tmp_path): ...
def test_install_refuses_a_file_whose_hash_is_not_its_name(tmp_path): ...
def test_install_moves_the_driver_into_the_root(tmp_path): ...
def test_probe_gives_the_hash_python_git_os_disk_load_memory_and_machine_id(tmp_path): ...
def test_probe_prints_no_absolute_path(tmp_path): ...
def test_have_gives_only_the_keep_refs_of_the_gate_clone(tmp_path): ...
gate, the process control, gcFiles. Create in jacked/testdiet/gate_driver/:
gate.py, watch.py, posix_proc.py,
windows_proc.py, collect.py; extend gitsteps.py and the two
driver test files.
uv run --python 3.11. Expected: PASS. The macOS and
Windows parts get their first run on the macOS and Windows legs of hosted CI (5.3), before any
live proof.feat(testdiet): a gate lives as long as
its connection.In-process tests (fakes for the clock, the memory source, the process table,
killpg and the reap, passed as arguments):
def test_the_stop_signals_the_group_only_before_the_leader_is_reaped(): ... # the order of the fake calls; the lock and reaped
def test_the_group_wait_ends_early_when_no_member_lives(): ...
def test_the_watch_stops_after_the_silence_limit(): ...
def test_a_byte_other_than_the_beat_stops_the_gate(): ...
def test_the_watch_stops_below_the_free_memory_floor_during_the_gate(): ...
def test_the_silence_path_writes_nothing_to_the_session_streams(): ...
def test_the_delete_order_keeps_the_marker_until_the_content_is_gone(tmp_path): ... # a remover that fails at step 1
@pytest.mark.parametrize("header", BAD_HEADERS) # an absolute or ../ glob or folder, a bad env key, a JACKED_GATE key, 2 MiB, silence 4 or 61
def test_a_header_outside_its_rules_is_refused(header): ...
Child-process tests (the built archive):
def test_gate_runs_the_sent_commit_in_its_folder_and_returns_its_exit_code(tmp_path): ...
def test_gate_puts_a_report_path_for_the_placeholder_and_returns_the_stream(tmp_path): ...
def test_gate_streams_the_gate_output_on_standard_error(tmp_path): ...
def test_an_argument_with_a_space_and_shell_characters_arrives_as_typed(tmp_path): ... # S3: a space, &, %PATH%, $HOME; Linux and Windows legs
def test_a_bundle_shorter_than_its_size_gives_no_gate(tmp_path): ...
def test_a_failed_setup_gives_no_gate_and_a_setup_failed_result(tmp_path): ...
def test_the_end_of_input_stops_the_gate_and_its_children(tmp_path): ... # focus 1; a sleeper that holds a file open; Windows: then the file can be deleted
def test_a_silent_open_input_stops_a_gate_that_blocks_on_its_output(tmp_path): ... # L1: silence 5, the beats stop, the pipe stays open, nobody reads stderr
def test_a_result_that_nobody_reads_ends_the_driver_after_the_silence_limit(tmp_path): ...
def test_the_leftovers_of_a_normal_exit_are_stopped(tmp_path): ... # a gate that starts a sleeper and exits 0
def test_a_gate_child_cannot_leave_the_job(tmp_path): ... # Windows: CREATE_BREAKAWAY_FROM_JOB
def test_a_driver_killed_with_sigkill_leaves_a_folder_that_gc_keeps_until_the_gate_ends(tmp_path): ... # POSIX; focus 5
def test_a_killed_driver_stops_its_gate_through_the_job(tmp_path): ... # Windows; focus 5
def test_a_gate_that_writes_into_its_worktree_reports_clean_after_false_and_the_path(tmp_path): ...
def test_a_setup_that_changes_a_tracked_file_reports_clean_after_false(tmp_path): ...
def test_each_stream_has_its_size_and_sha256(tmp_path): ...
def test_the_run_folder_is_removed_before_the_result(tmp_path): ...
def test_gc_removes_a_folder_whose_lock_is_free_and_keeps_a_live_one(tmp_path): ... # focus 4
def test_gc_never_removes_a_folder_without_the_marker_or_a_link(tmp_path): ...
def test_gc_finishes_a_partial_delete(tmp_path): ... # only the marker is left
def test_gc_prunes_the_worktree_registrations(tmp_path): ...
def test_a_new_keep_ref_replaces_each_keep_ref_that_it_contains(tmp_path): ...
def test_no_git_call_of_the_driver_starts_an_automatic_gc(tmp_path): ...
def test_no_local_variable_reaches_the_gate_unless_named(tmp_path): ...
def test_a_low_priority_gate_and_its_child_run_at_low_priority(tmp_path): ... # POSIX: os.getpriority; Windows: GetPriorityClass
def test_a_gate_below_the_free_memory_floor_does_not_start(tmp_path): ... # a floor larger than the machine's memory, in the header
def test_the_child_cpu_time_counts_the_gate_and_not_the_setup(tmp_path): ...
run --on, seen --onFiles. Create gate_machines.py, transport.py,
remote_run.py, remote_result.py, gate_commands.py; extend
driver_build.py with the install; modify commands.py,
model.py, views.py (all in jacked/testdiet/); create
tests/unit/test_testdiet_gate_machines.py,
tests/unit/test_testdiet_remote_run.py. Where a recorder name that this task needs is
private (today run._write_record, which prints the closing line, and
record._LOCAL, the local label), make it public in the same commit. No module imports
a private name of another module.
class Transport(Protocol):
def call(self, verb: str, values: Sequence[str]) -> Popen: ... # standard input, output and error as pipes
def upload(self, data: bytes, temp_name: str) -> int: ...
class SshTransport: ... # argv(verb, values) builds the ssh line of the decisions; upload() runs scp
@dataclass(frozen=True)
class RemoteRun:
label: str
argv: tuple[str, ...]
cwd: Path
setup: str | None = None
env_keys: tuple[str, ...] = ()
junit: tuple[str, ...] = ()
kind: str | None = None
record_label: str | None = None # --label
runner: str | None = None
strict: bool = False
transport: Transport | None = None # None: the SshTransport of the machine list
def run_on(options: RemoteRun) -> int
def inputs_identity(setup: str | None, env_keys: Sequence[str]) -> str
def load_machines(home: Path | None = None) -> dict[str, GateMachine]
# jacked tests run --on LABEL [--setup CMD] [--env KEY]... [--junit GLOB]... [--kind ..] [--label ..] [--runner ..] [--strict] -- CMD...
# jacked tests seen --on LABEL [--setup CMD] [--env KEY]... -- CMD... (opens no connection)
# jacked tests machines add LABEL --ssh ALIAS [--python NAME] [--workers N] [--priority low|normal] [--min-free-mb N]
# jacked tests machines set LABEL [--ssh ALIAS] [--python NAME] [--workers N] [--priority low|normal] [--min-free-mb N|none]
# jacked tests machines list | probe LABEL [--accept] | gc LABEL [--keep-ref-days N] [--old-drivers] | remove LABEL
LocalTransport. Run them. Expected: FAIL.grep -rl testdiet tests/ (each test file that imports or reads a module of
jacked/testdiet, changed or new; this includes
tests/unit/test_cli_tests_group.py, tests/unit/test_testdiet_run.py
and tests/unit/test_tests_reference.py); tests/unit/test_ssh_tripwire.py;
the scanner tests; and the doctests of jacked/testdiet. Expected: PASS.feat(testdiet): jacked tests run --on records a gate of a different machine.def test_run_on_returns_the_gate_exit_code_and_records_the_label_identity_folder_and_schema(repo, tmp_path): ...
def test_the_record_id_is_the_run_of_the_command_line(repo, tmp_path): ...
def test_run_on_refuses_a_tree_with_changes_that_are_not_committed(repo): ... # focus 6
def test_run_on_and_seen_on_refuse_input(repo): ... # L7
def test_a_lost_connection_returns_75_and_records_nothing(repo, tmp_path): ... # focus 1
def test_a_silent_link_returns_75_and_records_nothing(repo, tmp_path): ... # the transport stops the beats
def test_a_result_with_a_wrong_type_returns_75_and_records_nothing(repo, tmp_path): ... # focus 3
def test_a_result_line_over_the_limit_is_refused_and_logged(repo, tmp_path, caplog): ...
def test_a_stream_with_a_wrong_sha256_returns_75(repo, tmp_path): ...
def test_a_stream_larger_than_the_free_space_is_refused_with_the_two_numbers(tmp_path): ... # in-process: free space as an argument
def test_a_result_for_a_different_commit_returns_75(repo, tmp_path): ...
def test_a_different_machine_under_the_label_returns_75_and_names_the_accept_command(repo, tmp_path, capsys): ... # S4: a second root
def test_probe_accept_stores_the_new_identity(repo, tmp_path): ...
def test_a_junit_file_with_a_doctype_from_the_gate_machine_gives_no_test_data(repo, tmp_path): ...
def test_a_have_answer_that_is_not_a_commit_here_is_dropped_and_printed(repo, tmp_path, capsys): ... # focus 2
def test_a_tip_of_a_different_branch_still_makes_a_small_bundle(repo, tmp_path): ...
def test_a_commit_that_the_gate_clone_holds_sends_no_bundle(repo, tmp_path): ... # bundle_size 0
def test_the_alias_the_remote_root_and_the_identity_are_never_printed_or_recorded(repo, tmp_path, capsys): ...
def test_machines_list_and_probe_print_no_machine_identity(tmp_path, capsys): ... # S1
@pytest.mark.parametrize("entry", BAD_ENTRIES) # ssh "-x", "u@h", "h:22", "a/b", "a b"; python ".", "-c"; label "local"
def test_load_machines_refuses_an_entry_outside_the_grammar(tmp_path, entry): ...
def test_load_machines_refuses_a_file_that_others_can_read(tmp_path): ... # POSIX
def test_machines_add_stores_the_priority_the_floor_the_os_and_the_identity(tmp_path): ...
def test_machines_set_changes_priority_and_floor_with_an_atomic_write(tmp_path): ...
def test_a_floor_on_a_macos_machine_is_refused(tmp_path): ...
def test_seen_on_uses_the_stored_identity_and_opens_no_connection(repo, tmp_path): ... # a transport that fails the test when it is called
def test_seen_on_with_a_different_setup_says_not_seen(repo, tmp_path): ... # L7
def test_a_record_of_a_gate_machine_is_never_compared_with_a_local_one(repo, tmp_path): ...
def test_profile_prints_the_setup_share_of_an_on_record(repo, tmp_path): ...
def test_the_output_filter_keeps_colors_and_removes_osc_52_split_over_two_reads(): ...
def test_no_verdict_and_a_gate_code_of_75_print_different_lines(repo, tmp_path, capsys): ... # L10
def test_run_on_prints_the_load_and_free_memory_before_the_gate(repo, tmp_path, capsys): ...
def test_the_changed_paths_print_as_in_a_local_run(repo, tmp_path, capsys): ...
def test_the_ssh_and_scp_lines_have_the_fixed_options_and_no_value_outside_the_grammar(): ... # argv only; -E, LogLevel=ERROR, StrictHostKeyChecking=yes, ControlMaster=no, ControlPath=none, PermitLocalCommand=no, -- before the alias
jacked-reference.md and README.md,
in ASD-STE100 and with no em-dash: how to add a gate machine (an SSH alias or a MagicDNS name;
connect one time by hand to accept the host key); that the gate machine holds the full history
of the repository; the setup command and --env; the worker count, the priority and
the floor (Linux and Windows; macOS has no floor); a background run in the form cmd >
log 2>&1; rc=$?; what "no verdict, exit 75" means, and how it differs from "the
gate returned 75"; the time line of a stop (71 s at most after the last heartbeat);
gc; and the limits: a setup that rewrites a tracked lockfile makes each remote run
"tree changed", $JACKED_GATE_WORKERS is not expanded in argv, a process that calls
setsid() is not stopped, a Windows gate gets no grace time, and a gate machine that
also runs jacked has two identities.grep -rl 'jacked-reference.md\|README.md' tests/unit), and
tests/unit/test_no_em_dash_in_user_text.py. Expected: PASS.docs: a gate on a machine of your choice.Only the main session runs this task. Before the first write to a machine, it names each write of the section "Proofs that only the owner's machines can give" for that machine and gets the owner's go-ahead for that machine. A go-ahead for one machine does not carry to the other.
The order puts hosted CI before the live proofs. So the Windows-only code (the job, the
leader, the msvcrt lock) first runs on the Windows leg of hosted CI, and only then on
the owner's Windows machine. It is still one full gate and one CI run.
jacked tests run --kind full -- uv run python -m pytest -n auto --junitxml={junit} > log
2>&1; rc=$?. Quote the summary line of the log. /dcr runs beside this
gate as a read-only review, not after it. A review fix that changes code costs one more targeted
run and one more full gate.git log -p <merge base>..HEAD) for each
ssh value of the local machine list, each Tailscale name and each remote user name.
Expected: zero hits. The sweep runs locally, prints only counts, and writes nothing to the
repository. This repository is public, so a hit stops the push./pr: push, open the pull request, and let
hosted CI run on the three systems. Quote the "N passed" line of each leg. A red leg gets a fix
with its targeted tests, and only the failing CI step runs again.seen --on exit 0 and 1; gc; and the full suite of this branch through
run --on.low with a floor that the owner sets, after the go-ahead for it. Each proof of the
table for this machine, and the same checks as 5.4.Hosted CI (Linux, macOS and Windows, with no SSH server) proves the grammar, the header, the
bundle, the result reader, the streams, gc, the locks, the POSIX process groups, the
heartbeat time limit through LocalTransport, and the Windows job. It cannot prove
the items below. Each one needs a real SSH session to a real second machine.
| Proof | How | Machine |
|---|---|---|
| The heartbeat stops a gate on a silent link with no end of input (L1) | Start
run --on in the background and keep its PID ($!). Find the local
ssh with pgrep -P <that PID> -x ssh. Send it
kill -STOP. Wait 75 seconds. Read the process list of the gate machine: no
process of that gate. Then stop that ssh by its PID, and see exit 75 and no
record. | both |
| The end of input stops a gate (focus 1) | Stop the local command by its PID during a gate. Read the process list of the gate machine: no process of that gate. | both |
| The bytes of standard output arrive unchanged | A gate whose report is 1 MiB of binary data that holds each byte value. The stream SHA-256 check gives no "differs" line. (Only standard input was tried on 2026-11-26.) | the Windows machine |
-E catches the errors of ssh (S1) | A wrong alias, and a key that the server refuses. The output shows only the label, the exit code and the log path. | both |
StrictHostKeyChecking=yes with the real configuration (S2) | Run
the ssh line by hand with one more option, -o
UserKnownHostsFile=<an empty temporary file>. Expected: "Host key verification
failed" in the log, and no connection. This changes no file of the owner's SSH
configuration. | both |
| The job of the SSH server and the job of the driver on a real session (L4) | The
two stop proofs above, on Windows, and a gate child that tries
CREATE_BREAKAWAY_FROM_JOB. | the Windows machine |
| The priority on a real gate (L3) | During a gate, read the priority of a gate
process: ps -o ni= on POSIX, the priority class on Windows. | both |
| The floor at the start and during a gate (L3) | A floor above the free memory: no gate, one line with the two numbers. Then a floor about 1 GB below the free memory, and a gate that takes memory in steps of 100 MB: the stop comes before the floor. | the Windows machine |
| The shell that parses the remote command line | Read
HKLM\SOFTWARE\OpenSSH, value DefaultShell (cmd.exe when it is
missing, or PowerShell), and run probe through it. | the Windows machine |
The writes to each machine. Each one needs the owner's go-ahead for that machine before it runs.
~/.jacked-gate/drivers/; (W2) the root ~/.jacked-gate with
machine-id and driver.log; (W3) the gate clone
repos/<REPO>.git, which holds the full history of the repository, and its
keep refs; (W4) a run folder for each gate (a worktree, the reports), and the processes of each
gate; (W5) the deletes of gc inside the root; (W6) the test gates of the stop
proofs, which start a sleeper process.The reads (the process list, the priority of a process, the free memory, the
DefaultShell value) change nothing, but they also use a connection to the machine, so
the main session asks for them in the same go-ahead.
This lane is infrastructure, not jacked code. The owner asked on 2026-11-26 for self-hosted GitHub Actions runners for their private repositories, in the pattern that they operate today: one fresh, walled-off container for each job, a single-use runner registration, a time limit. The provider is open. The owner answered the prices of a rented box with "hm maybe managed runners? those others seem very expensive for what we use them for jesus or just use my [machine] i dont want to pay that much" ([machine] is the owner's own Windows machine; the spec table "The owner's answers (2026-11-26)", row "The gate machine"). So the choices are managed runners or the owner's Windows machine; a rented box is not chosen. The owner picks, and approves the account and the cost.
When a machine of this lane is also a POSIX gate machine of Task 5.4, the gate over SSH uses a second user, so a gate and a CI job never share files.
The setup is a separate runbook that the main session writes after the owner picks, and walks before it hands it over. It holds: the operating system and Docker; a supervisor that starts the runner containers; one runner registration for each private repository that uses it; and a test of the copy of a large test database on the file system of the machine before any real job. Each step that writes to the machine is named before it runs, and needs the owner's go-ahead.
Generated with the jacked HTML artifact template. Edit freely.