Skip to content

Workflow history

This page is the case file behind .clinerules. It records, for each failure that cost a session time, the rule it produced, the date, the sequence and the numbers, because a rule without its case is re-argued every session. The rules file carries the rule; this page carries the case. It is public documentation, and nothing here names an account, a size, a seat or a machine path.

The two front doors

The rule: both front doors carry the same three parts and neither is a byte-identical copy of the other, because their media differ.

The published site's home is docs/index.md, because mkdocs.yml maps Home to it, and the repository page is README.md. A reader arrives at one or the other. A change had been made to README.md, and the documentation front door was called done; the review that found it had to visit the published site to see it. The site home has a navigation tree beside it, so it points at docs/MAP.md for the routing table; the repository page has no navigation, so it carries that table itself. Duplicating what the medium already provides is the redundancy the rule is about.

A time named in its zone

The rule: a time is named in its zone, and the host's zone is measured rather than assumed.

The host is located in Tokyo and runs Etc/UTC (timedatectl, measured 2026-11-27), the operator is in Hong Kong, and the window is named in UTC: 13:30-15:30 = 21:30-23:30 HKT = 22:30-00:30 JST. A daily report keyed on a host-local 00:15 and a rolling --since=-24h mailed nine hours after the close, with the window split across two reports, and nothing in the tree said which clock it meant. That is why a timer carries OnCalendar=... UTC, a journal read carries --since=@<epoch> --until=@<epoch> --utc, and check_deploy.py's thirteenth and fourteenth rules refuse a timer without a zone and a packaged timer the bootstrap never installs.

The clock a reply names is the one measured in that same breath. Measured twice on 2026-11-30: the session read 13:29Z for "close minus two hours" by adding the local offset from memory, then dispatched the close's ledger at 14:39Z against a 15:30Z close -- a full hour early, so the run returned a mid-window snapshot and the reply had already called it a ledger. A reply that names a time, and any dispatch gated on one, runs date -u in the same command.

Screening thresholds

The rule: a screening threshold says which of four kinds it is, or it is not a threshold.

The four kinds are physical (a venue's tick, lot size or fee), analytic (a closed-form statistic with its citation), an exogenous risk boundary the owner declares before the run (alpha, the survival leverage L_max, the trial count N, the capital base Cap), and a power requirement -- the sample a test needs to distinguish the effect it looks for, which follows from the standard error and the declared alpha and is the only honest form of a fill floor. A number that fits none of the four is an opinion wearing a decimal point: refuse it, and refuse it whichever of us proposed it -- "it looked right" is not a source.

Two limits travel with the page (docs/METHODOLOGY_SCREENING.md, arithmetic in tools/study/significance.py). The funnel's hurdle is sqrt(1/(T-1)) times the expected maximum of N trials, and N is the participation ratio of the trials' correlation matrix (N_eff = N^2 / sum c_ij^2), not a count anyone picks: measured 2026-11-29 over 53 series it is 8, the live window reads DSR 0.456 and fails, and 12:30-14:30 reads 0.961 and passes. A marginal test taken at weight zero admits a negative-Sharpe candidate, which is why the verdict needs max(0, rho * SR_P) and a finite position. The live window's -1.30 skew is one day (2026-11-26, 104 contracts carried into the close while every hour inside it made money), so "this window is worse" is not what the distribution says.

A column is read from its writer

The rule: a column's meaning is read from its writer, not from the number's size.

sweep_summary.py prints fills= and the value is fills_median -- a per-day median, not a month's total -- so a 28-day row can read "28 fills" and hold some 780 of them. Reading that column as a total turned NES's 22-of-28-positive month into "one fill a day" on 2026-11-30, and the same session read pos= (also a median) as a peak and argued about a cap the run never approached. The check is one line: grep -n 'median\|sum(' <the tool that printed the line>.

The data audit

The rule: data/ is input, never output, and it is audited rather than remembered.

Seven Zone.Identifier sidecars from a browser download sat beside the archives until 2026-11-27. python3 tools/fetch/data_inventory.py classifies every file (symbol, kind, day, size) and reports what a run would discover the hard way -- a partial download, a day with only one of the two files, the same day in two layouts, an unreadable gzip, days past the retention -- and it never deletes without --prune=<rule>, which names the rule and prints every path. An orphan is evidence and an old day is an archival decision, so neither is ever pruned by a script; anything the audit cannot classify is listed for exactly that reason.

Extend before you create

The rule: extend before you create, and the commit says which file was extended or why none could be.

The tree carries 55 GB of generated material against 6.7 MB of source (data/ 42 GB in 1,145 files, out/ 13 GB in 3,528) with 110 files under tools/. The failure this exists for is measurable: fixing one mislabelled counter (post_only) meant editing seven pages, because one fact was written in seven places.

Editing documents and tables

The rule: a document edit is anchored on a line inside the section, never on the section's first line; a table row is anchored on the row after it; and a heading is included in the replacement verbatim.

Measured twice on 2026-11-25, both times while inserting a new section in front of an existing one: the anchor was the old section's opening sentence, the heading went with it, and the damage was only visible on reading the file back. Earlier in one session, three edits replaced a row's opening text and left two rows merged (the docs/TOOLS.md table twice, and a studies section whose first sentence went with the heading).

Measured again three times on 2026-11-30, every one of them while inserting a row into a change log (docs/ROADMAP.md twice, CHANGELOG.md once -- where the heading went): an insert's old text is the first line of the row or section below it, and quoting only that line's opening is what merges them. And five more times the same day, including three headings that a paragraph replacement ate (docs/ROADMAP.md twice -- the L2 card and the parameter card -- and CHANGELOG.md once): a replacement whose old text is a heading deletes it, so the new text must end with that heading verbatim. The region is read back, with awk -F'|' 'NF!=5' on the table as the one-second check that every row still has its columns.

Registered runs and drivers

The rule: a run's exit status, its driver and its command string are part of the measurement.

Measured 2026-11-28: a column added to a sweep row and not to the tool's COLUMNS made every day raise, the tool exited 1 on its first day, and the driver still echoed exit=0 -- it printed $? without propagating it, so four arms "succeeded" with a CSV holding one header line each. The tell is an artifact that is present but empty: a CSV with a header and no rows, a log with a start and no end. The same session, the same class: submitted and cancels went into the row dict and not into the CSV's COLUMNS, and DictWriter raises on an unknown key at the first day, inside a driver that hid it.

Measured 2026-11-28: the NES cell was launched at 07:22 and tools/sweep/up_ten_contract_cell.sh gained --debounce=<ms> four minutes later; bash re-reads a script as it executes, so the shifted lines landed mid-file and the run's tail died with line 92: $1: unbound variable -- at a line that holds a comment in the file being read, which is the tell. The CSV it had already written was fine, so the run looked broken and was not. And a chain of runs is stopped at its loop, not at its child: killing one arm's python inside a for ms in ... let the loop start the next arm beside the re-launched job, so two sweeps shared one cuts directory -- the tool's own refusal names the pid that holds the lock, and that message is how the stray was found.

Measured 2026-11-28: the cell script expanded BASE="…--advance-debounce-ms=$DEBOUNCE…" beside DEBOUNCE=${DEBOUNCE:-40000} and parsed --debounce=<ms> forty lines later, so the debounce ladder ran one arm four times -- the four CSVs agreed to the digit, and that is what caught it. A lever that changes nothing on a moving book is a bug until a one-day two-value smoke shows the flag moving a number (40000 ms fills 51 times, 250 ms 168).

Measured 2026-11-27: a cell described by reference -- "the frozen ten-contract cell with --settle-residual" -- spent a session finding that the two flags which make it the recorded cell are --extra-layers=1 and --settle-slippage-ticks=1; the previous driver lived in /tmp, one wipe from gone.

Gate tiers and their costs

The rule: match the check to what changed, and treat the full gate as a commit-time cost rather than a per-edit one.

Measured on 2026-11-16 with nothing else running, and these are the numbers the header of verify_l2.sh carries: tier 0 is 3 s, code 26 s, full 26 s, asan 6 s of tests plus 4 s of replay once the sanitizer tree exists (632 s when it does not), and fast 70 s to 1 min 50 s across two runs -- a spread wide enough that the rule is the range, not a number. Re-measured on 2026-11-25, after the burst section gained two full-day probe runs, fast read 2 min 16 s, 1 min 43 s and 1 min 33 s. A pinned whole-day tool run costs about 15 s of gate by the tool's own standalone time, so pinning one is a decision about every later commit rather than a free check. The document half is almost all two pages -- part 3 of the performance history at 65 s and part 4 at 44 s -- so the whole set costs ~107 s here while a named page costs seconds. Running fast after every edit "to be safe" is the anti-pattern: two minutes to learn nothing about the line just written, and a log long enough to bury the failure that matters.

Tier 0 exists because a red unit test once passed a gate that only compared replay output. The tiers also refuse a stale build (2026-11-26, twice in one session): verify_l2.sh compares the newest artifact in the build directory against src/ and tests/ and stops with the file names and run: bash .run.sh build, because a gate that judges a binary older than its sources reports a behaviour change that is really a missing build -- which is exactly how a red tier0 was read as a test defect while it was a test that had never been compiled.

Measured 2026-11-27, six tasks in one session: fast ran twice on two of them, and both extra runs were predictable -- a change under src/ moved the size table (32,776 to 32,840) and a new tool-owned flag was missing from the prose lint's allowlist.

Sizing, units and clocks

The rule: a flag that names its unit is read twice, a per-tick figure is converted before it is quoted, a duration is added in the clock's unit, and /tmp has a size.

Measured 2026-11-25: a five-point grid labelled "0 to 80 ms" was five runs at 0 to 80 us, so every conclusion drawn from it was about zero latency and the table looked clean because there was no delay in it. tools/sweep/okx_maker_baseline.py now warns below one millisecond.

On 2026-11-25 the profile page, the changelog and two tool docstrings said "one tick is half a basis point" for a day, because a tick looks small. 0.0001 on a 0.19 instrument is 5.2 bps, not half of one, and the difference is the whole answer to "can a fee be paid". The venue's own tickSz beside the spread in ticks is the cheap cross-check: okx_spread_screen.py reports both, and the two agreed on 5.2 to 5.4 while the prose disagreed with them both.

Measured 2026-11-28 UTC, four defects of one class, each invisible because every fixture was microseconds or a hand-set number. The risk bucket divided a millisecond timestamp by a constant 1e6 (148 tokens in a two-hour window instead of 144,000, which read as "the strategy wants 23 orders a second" when it wanted 1.59). MatchingEngine added --order-latency-us=<us> raw, so the cell's "10 ms" arm was ten seconds and its "100 ms" arm a hundred. The volatility halt divided the same way. And clock_units_per_second returned milliseconds for a microsecond epoch (ts >= 1e11 is true of 1.7e15 too), so every duration on the Deribit sources came out a thousand times short.

Measured 2026-11-26: a fourteen-symbol, seven-day sweep costs about 1.5 GB of cut a symbol and filled the 7.7 GB tmpfs, and the two symbols that ran last died with exit 120 and a completely empty log -- the interpreter could not flush its own traceback either. That pair is the tell for a full /tmp rather than a traceback.

Polling and detached runs

The rule: a heavy run is detached, registered and closed by the tool that consumes its output; polling is a file read of a new artifact; and a lost completion is read back rather than retyped.

Measured 2026-11-28, when the host restarted and /tmp/tq went with it, taking five jobs' logs: a reboot ends every detached run without a word. The state to avoid is the one the rule was written from -- three fetches and two sweeps running, each with a log, none of them with a named consumer.

Read with the file tools, write with a redirection, and never wait in the foreground: the shell on this host loses a command's completion often enough that a grep costs a second call to read its redirected output -- dozens of times in one session -- while read_files and search_codebase are never lost. Two sleep 150 calls cost five minutes of wall clock in a session that a single edit would have covered.

Measured 2026-11-23: a live session started from the tool's terminal with tools/gate/detach.sh ran to completion in the background while the tool's shell executed nothing for twenty minutes -- the command printed its log path and returned, and the tool never saw it end, so every later command was dropped. The session's own numbers were unaffected; only the loop was lost.

Measured 2026-11-17: a build that finished in 16 s was reported "still running" for the tool's 300 s budget, and a bare git log was still in less hours later, holding pts/10.

Measured 2026-11-28: 28 file days of OKX trades moved 7.44 GB in about 70 minutes and 21 depth days moved 210 MB in about 12, both through bash tools/gate/detach.sh <name> <seconds> -- … with one flushed line per day (flush=True), so progress was a file read rather than a guess. Two lessons were paid for in that session: the first 28-day fetch printed nothing until it finished, and a 21-day depth fetch was started while the owner was waiting for an answer.

Measured 2026-11-25 on this host, deliberately: seq 1 1000 | sed ... -- about 10 KB of short lines -- lost its completion and the tool opened a new terminal, while a single 4000-character line, sleep 3; echo and sleep 12; echo all reported normally. The attribution this used to carry -- a sleep holding the pty -- was tested and is wrong: the sleeps are fine and the cat after them is the leak. That session lost 25 completions and the tool created a terminal per loss (its log reaches terminal 25, and ps showed fourteen idle bash processes, each at a prompt with no child), which is exactly what made it read as a wedged shell: the shell had finished and nothing was holding it. The loss is not limited to big outputs -- two six-line ones went the same way in the same hour. And an editor-written docs2.req was taken while it was still empty, the daemon's set -- ran with no arguments, and a bare status executed instead of the gate, with no docs2.out to read.

Queue discipline and artifacts

The rule: a queue row carries the four cells, one heavy job runs at a time, and an artifact's path comes from the tool's naming rule.

Measured 2026-11-28: the two windows before the ledger existed were read by pasting [EXECUTION] and [STRATEGY_METRICS] out of the host's journal, and the number that decided them (submitted_orders=343) was absent, so a session's diagnosis ran on an arithmetic figure of 155,000 that the journal contradicted by a factor of 450.

Measured 2026-11-29: twenty-two of twenty-six re-records were registered with --artifact=.../f1_control.csv while up_ten_contract_cell.sh writes <arm>.csv, so every row read absent beside an exit of 0 -- the runs were fine and the registry was wrong, which is the worse way round because it reads as "the queue produced nothing". The tell to watch for is an artifact column of all absent against all-zero exits.

Measured 2026-11-28 UTC on this host -- 8 cores, 15 GB, 6.0 GB free on the 7.7 GB tmpfs -- so the binding resource is the tmpfs and not the CPU. The queue is serial by construction (two sweeps in one cuts directory is the collision the sweep tool refuses by pid), it runs at nice 10 so a foreground fast is not starved, and a job whose --needs-gb=<n> exceeds what /tmp holds is marked blocked instead of dying at exit 120 with an empty log. A foreground gate may run beside it, and a tier0 red that names only venue_order_session_test (#23) while a job is running is the known load-sensitive flake: re-run tier0 alone instead of debugging it.

The terminal loses a completion

The rule: a command whose completion was not observed is read back from the artifacts, and a terminal that dropped every later command is left alone rather than typed into.

Measured twice on 2026-11-23 -- once after a live session was typed into the shell, once right after a commit and a log read -- the tool never saw the last command end, kept waiting for the pty, and every command typed afterwards refused to execute: bash .run.sh sh ... printed nothing, and a bare date > /tmp/x wrote no file. The tell is a file the command should have written and did not, so it is checked for with a read rather than a retype; there is nothing to kill and nothing to retry.

Measured three times on 2026-11-23 (the two above, and one more after a status that had succeeded): the shell integration stops reporting a command's end, the tool waits for the pty, and every later command is dropped while the work itself runs on. Ruled out by measurement rather than by guess: the pager (the runner exports GIT_PAGER=cat), descriptor inheritance (run.sh and detach.sh both setsid with </dev/null), and a stray child (ps showed none in the two cases that were checked). What is left is the completion detector, which the tree cannot fix. Verified the same day: a status request written by an editor rather than a shell executed and left its log. After an editor restart the daemon is gone (measured 2026-11-25: bash .run.sh daemon printed "started" rather than "refused"), so that one command is the only thing a restart costs.

Measured 2026-11-17: the first command of a session (git log --oneline -5) opened less, the tool waited its full 300 s budget, and the pager was still alive when ps was read hours later.

The failure the one-bash terminal replaced was a zsh session restored from before the change: oh-my-zsh's prompt forks subshells and its [Y/n] prompt took the first keystroke, so pgrep ran as grep.

The one-verb runner

The rule: everything goes through the ignored root runner, one verb at a time, and no pager ever.

On 2026-11-15 a collision between two gates in one tree -- two gates write the same /tmp slices and the same out/lat recordings -- produced a recorder: replaying the recording did not reproduce the run MISMATCH in one log and a plain code OK in the other, which reads exactly like a real regression.

A page included in another page

The rule: a page that is also included in another page cannot carry a relative link.

Measured 2026-11-28 UTC, one gate run lost to a link that was correct in the file it was written in: docs/L2_FLAGS.md is inlined into docs/using/01-getting-started.md, so a link written for docs/ is resolved from using/ there and mkdocs build --strict fails naming the including file.

The handoff copy and the commit

The rule: a commit's path list is derived from git status, and a sync is a copy that was checked rather than a command that ran.

The hook rule exists because of how the previous arrangement failed: it called a script outside the repository whose default repo was the pre-rename checkout directory, so every commit for ten days wrote ERROR: <that directory> is not a git repository into a log nobody opened and the Drive copy stayed at 7035823.

Three commits in one session -- a99aed0, a9b2734, 07ccb07 -- named their files by hand, missed one each time, and left a commit that did not build while the gate that approved it was green on the working tree: the includes had moved in the tree and not in the commit.

The hook syncs and pushes as a child of the shell that committed, so the next command typed into that shell kills it between the manifest and the copy -- observed twice, and what it leaves is an empty diff.patch for the change under review.

Measured 2026-11-28 UTC: .handoff.md had grown to 2,989 lines of per-session blocks, five of them marked "read this first", and every number in them was already in the tracked documents -- so the history was removed and the file is 45 lines of state.

The publication boundary audit

The rule: a secret, a machine path or a private file that is tracked is a defect, not a preference.

Measured 2026-11-26, when the audit before the boundary table found thirteen machine paths and fifty-one seat references in tracked files.

The deploy's four questions

The rule: a deploy answers identity, ordering, failure echo and content, and a deploy that fails twice for the same reason stops.

Seven deploys failed for seven reasons, and the audit that followed (2026-11-27) found that all seven fit one frame, written here so the eighth is caught in the tree rather than on the host.

  • Identity -- the account that writes a file is not the account that reads it. 0640 root:toyquant written by a bootstrap is right; the same file written by hand as root:root 0640 is a relay whose EnvironmentFile= fails, and the engine's - prefix turns that into silence. The only check that proves it is runuser -u toyquant -- test -r <file>, which deploy/preflight.sh and deploy/check_health.sh both run.
  • Ordering -- After= sequences a start and does not prevent one: a unit whose dependency failed still starts, so the engine Requires= the relay. A check that reads ss immediately after systemctl restart is a race, so both scripts wait for the address with a bound and name the port that never opened; waiting for one socket when the engine dials two is the same defect one layer down.
  • Failure echo -- a check that cannot say which port, unit, variable or file failed costs the round trip it was written to save. Every message names the thing; check_health.sh attaches the failed units' last sixty journal lines and notify.py mails the same summary, because nobody watches a journal.
  • Content -- the unit on the host is only as complete as the bundle: every program, unit and template a unit names has to be in deploy.yml's package step, or the host runs a unit for a file it never received.

Measured across seven failed deploys in one night: every re-dispatch of the same line cost a round trip and taught nothing the first log did not already say, because a red deploy is a fact about the tree or the host and not about the dispatch. The first failure is read (its log names the file, the port, the unit or the variable), the second is a reproduction with one variable moved, and a third dispatch of the same commit is refused -- today by the reader saying what would have to differ before it goes out again, and on the host by the reverted_release marker deploy/rollback.sh writes and the next deploy reads. The rule is also what makes an automatic rollback safe: a revert that is immediately re-deployed is a loop with extra steps.

Measured 2026-11-26: the first deploy to a real host crash-looped 35 times and the health check reported "activating". -march=native is a benchmark's flag -- an artifact built on one host and run on another is one instruction away from status=4/ILL -- so the deploy preset sets TOYQUANT_PORTABLE_BINARY=ON, and the health check reads NRestarts and ExecMainStatus, because systemd's Failed with result lines are not severity err and journalctl -p err will not show them.

Measured 2026-11-28: the light release path's "install the key" step was copied from the full deploy job without its ssh-keyscan line, so the first config-only dispatch died at Host key verification failed inside the rsync -- a red deploy whose cause was one missing line in a copy.

Guards, units and systemd

The rule: a guard counts what should be running, shell logic lives in a tracked script, and a check that reads a running process runs after the thing that starts it.

Measured 2026-11-29, preparing the second live seat: check_health.sh failed on "one host may run one" and the live unit's own comment argued the same thing -- both were true of one instrument and false of two, so the first deploy carrying a second seat would have gone red at 13:30 with "two processes run toy_quant". The pattern is the constant: -ne 1, "one host may run one", a socket list written with the first seat's two ports. What replaced them counts: the number of engines that should be running is 1 + active seat instances, the relay count the same, and the addresses come from the unit's own environment through a tracked script rather than from a line that names seat 1.

Measured 2026-11-27: a regex's \. in a unit's Exec line reached bash as a bare dot and every start logged Ignoring unknown escape sequences, while the $1 and $) of a function in the same line depend on two parsers agreeing about quoting. So a wait, a probe or any other shell logic belongs in a tracked script beside the unit (deploy/wait_for_ports.sh), which bash -n and a local run can check; the unit line takes a path and its arguments.

Measured 2026-11-30: an action branch inlined into .github/workflows/ops.yml's one remote script made every dispatch answer 422 ... Exceeded max expression length 21000 -- stop and flatten included, so nothing on the host could be reached -- and the step measured 23,031 characters before the branch and 24,255 after it. An action's body belongs in a tracked script shipped beside the others (deploy/record_window.sh, deploy/order_summary.py), named by check_deploy.py's ops-actions rule.

Measured 2026-11-27, twice: deploy/preflight.sh asks whether the relay's two sockets are open, and the workflow ran it before restarting the relay -- on a host the operator had stopped (ops stop) there was nothing listening, so the job failed at the first check and no deploy could bring the host back up: preflight: FAIL nothing listens on 127.0.0.1:8765. The order is now: restart the relay with the unpacked code, wait for its ports, run the preflight against that relay, restart the engine, then the health check. And a reload is not proof of a load: daemon-reload can miss a unit file written a moment before it (enable accepted the name while restart answered Unit toyquant-relay.service not found), so deploy/bootstrap_server.sh asks LoadState for every unit it installed, retries the reload, and names the one that did not load.

A report over a window that never opened

The rule: an empty journal is a SKIP, not a failure, and the schedule is what says a seat is expected -- a unit the manager does not load and a seat with no window timer are named and skipped, never mailed as an ALERT.

Measured 2026-12-03 15:35 UTC: one timer, one window, three mails. The host's seats file still named a seat whose unit had been removed in the migration to the templated layout, and a seat that carried no start timer at all, so the report wrapper ran a mail for each. Their journals were empty, every clause the verdict reads came back missing, and the verdict therefore read FAIL -- with a blank net and a blank residual, because there was no session to read them from: [ALERT] ... n/a U | residual:n/a | FAIL, one of them under the same label as the day's real PASS mail. The row the report wrote for the removed seat is the tell: sessions=0 with every other cell blank and verdict=FAIL still queued for a mail. The tree's own daily_report.py already returns before compose on a sessions=0 row (skipped (no session); row written, no mail), but the host's deployed copy predated that guard -- and its release file was absent, so the mail's build slot read commit n/a rather than naming the revision it ran. Two changes landed: the guard stays the first line (an empty journal must return before compose), and report_seats.sh now asks LoadState for seat 1's unit and for the seat's window-start timer before it reports, so a seats file that names a unit the manager does not load is skipped instead of mailed. The deploy that carries the guard is the fix -- the guard alone had been in the tree since 2026-12-03 and had never reached the host.

A release path that starts what the host runs

The rule: the release path starts the units the host actually runs, and a guard counts what should be running rather than asserting one topology.

Measured 2026-12-04 16:43 UTC: a deploy on a host migrated to the templated layout (one unit per seat) failed at the preflight, not at the build. The activation tried the plain units, which the manager does not load, then waited on the seat's ports without ever asking any unit to open them; the preflight's sixth check read nothing listens on 127.0.0.1:8765 -- the port the host opens for its window -- so the release was rolled back and latched. The rebuild itself was healthy: the binary, the config and the engine start were green; the red was a start nobody issued. The activation now reads the seats file, keeps the seats that carry a window-start timer, starts each one's relay and waits for the ports that seat's env names. A release path written for one topology has to be re-read when the host moves to another, and the tell is a rollback whose only failing check is a port no unit was asked to open.