# Shell and Runtime Traps
<!--
ref: @protocol/shell-and-runtime-traps
tags: [shell, bash, bun, grep, kubectl, runtime, traps, silent-failure, verification]
triggers: [bash unexpected EOF far from the fault, grep returns nothing but the string is there, script failed with a blank line number, editing a script while it runs, bun -e argv, bun test exit 0, JSON config broke after a find-replace, background command empty output, kubectl NotFound on a running resource, shell job logs green but nothing happened]
version: 44
updated_at: 2026-11-29T19:30:57.760Z
-->
Traps in shells and script runtimes where a tool answers "nothing", "success" or "gone" for a reason other than the truth. Fetch the one section that matches the symptom (`?section=<slug>`); every section is one trap: symptom, tell, fix.
**The rule they all share: an empty or green result from a tool is a reading, not a fact.** Before acting on "no matches", "rc 0", "NotFound" or an empty file, confirm the tool could have answered differently — a known-present control string, a count of what actually ran, the terminal status of the process.
| Symptom | Section |
|---|---|
| `unexpected EOF` reported 100+ lines below balanced code (macOS bash) | `bash-32-command-substitution-closes-early` |
| `grep` finds nothing in a file where you can see the string; or a `set -e` script dies silently on the clean path; or `… | grep -q` reads FAIL when the line IS there | `grep-silent-negatives` |
| One unreproducible failure; the error names a blank line and reports data as a command | `editing-a-running-shell-script` |
| A hot-reloaded module throws mid-refactor; a status line reports "no work left" | `editing-a-live-re-imported-module` |
| A JSON config breaks after a text find/replace; the check printed nothing | `json-string-surgery` |
| A `bun -e` script reads the wrong argument, silently | `bun--e-argv-starts-at-index-one` |
| `bun test <dir>` is green but most files never ran; or a failure vanished | `bun-test-is-one-shared-process` |
| A scheduled shell job logs success; its important side effect never happened | `unconditional-exit-0-hides-failures` |
| A backgrounded/timed-out search left an empty output file | `killed-background-command-reads-as-empty` |
| `kubectl` says `NotFound` for something still running | `kubectl-current-context-is-shared-state` |
| zsh prints `==== not found` (or `no matches found`) and the rest of the line never ran; `timeout: command not found`; `argument list too long` | `zsh-and-macos-errors-where-bash-would-not` |
| Parent reads a Node child's stdout over a pipe and gets JSON cut off mid-document | `a-child-that-calls-processexit-after-consolelog-loses-piped-stdout-past-64-kib` |
| A load or resource gate in a cron/launchd script never trips and logs a blank value | `a-schedulers-minimal-path-hides-usrsbin-tools-the-gate-reads-off-not-broken` |
| About to run a dry-run, backfill or cleanup script via kubectl exec in the live app pod | `a-heavy-one-off-script-run-inside-a-single-replica-serving-pod-takes-the-service-down` |
| A pod restarts repeatedly (exit 137) and memory is the obvious suspect | `pod-restarts-with-exit-137-and-reasonerror-are-liveness-probe-kills-not-oom` |
| An osascript that reads the frontmost browser tab returns wrong or empty values | `applescript-in-a-dynamic-tell-loses-the-app-dictionary-tab-becomes-the-tab-character` |
| Code reading the result of a raw TypeORM UPDATE/DELETE ... RETURNING gets the wrong shape | `typeorm-update-and-delete-through-query-return-rows-count-not-the-rows` |
| A nightly test went red in one week only and the production code looks correct | `a-next-7-days-test-built-as-168-hours-is-wrong-in-the-week-a-clock-change-falls` |
| Patching a source file with String.replace and a replacement containing code | `js-stringreplace-expands-and-in-the-replacement-string` |
| Screenshotting a CSS/JS-animated page in headless Chrome and it looks broken or stuck | `headless-chrome-screenshots-of-an-animated-page-show-the-first-frame` |
| Tests fail in a worktree on code you did not touch, with a monorepo shared package | `a-git-worktree-borrows-mains-node_modules-a-stale-shared-build-fails-tests` |
| Removed an Ingress or resource from a manifest but the live object still routes | `kubectl-apply-does-not-delete-objects-removed-from-the-manifests` |
| A Nest/Node test hangs at setup after adding a catch-all Proxy mock | `a-catch-all-proxy-mock-is-thenable-so-awaiting-it-hangs-the-framework` |
| A pulumi preview shows replace on a live ECS service or other fixed-name resource | `pulumi-replaces-a-same-named-ecs-service-delete-before-create-dropping-traffic` |
| Asked to deactivate or freeze a Terraform tree, or told it is already frozen | `commenting-out-terraform-makes-the-next-apply-destroy-everything-in-state` |
| Relying on a session-level read-only setting to make a production DB check safe | `set-default_transaction_read_only-before-a-psql-pre-check-may-not-take-effect` |
| Bulk-deleting container registry manifests or repositories with doctl | `parallel-doctl-registry-deletes-stall-the-digitalocean-api-cap-at-two` |
| aws CLI says "Error loading SSO Token" though the profile has static keys | `aws-cli-sso-settings-in-a-shared-profile-make-it-ignore-static-access-keys` |
| A cron or time-gated shell script breaks only at 08:00 and 09:00 | `a-zero-padded-hour-parses-as-invalid-octal-in-bash-arithmetic` |
| A local service (CDP, HTTP) hangs rather than refuses; probes time out empty | `a-process-that-accepts-connections-and-never-answers-sample-cpu-time-twice` |
| A CLI test that talks to an in-process stub server fails or times out only under bun | `execfilesync-in-a-bun-test-blocks-the-tests-own-http-server` |
| A shell test passes alone and fails when several runs execute at once | `pgrep-on-a-command-line-in-a-test-matches-other-runs-processes` |
| A script wrapping `tail -F` leaves orphan children after a stop or timeout | `a-watcher-script-that-pipes-tail--f-leaves-the-tail-running-when-it-is-stopped` |
| Reviewing a CI deploy step that renders secrets or vars into a script or manifest | `a-secret-rendered-by-inside-shell-quotes-breaks-out-of-them-eval-was-not-the-hole` |
| Reusing a dated brief or template by `sed s/old-date/new-date/` | `cloning-yesterdays-brief-with-sed-on-the-date-also-rewrites-historical-dates` |
| Local Postgres will not start after a reboot or power loss; postmaster.pid exists | `a-stale-postmasterpid-after-a-reboot-keeps-local-postgres-down-rename-it-aside` |
| A pre-command guard sometimes fails with 'unbound variable' and the command runs anyway | `a-guard-script-that-crashes-on-an-empty-array-lets-the-blocked-command-through` |
| A test passes by hand but hangs or fails spuriously when a scheduled job runs it | `a-test-suite-launched-by-a-daemon-inherits-its-live-env-knobs-and-hits-real-targets` |
| A guard that greps the last tool_use's command for '^Bash ...' refuses valid calls | `a-line-anchored-grep-on-a-multi-line-command-misses-it-join-lines-before-matching` |
| A Notion page refresh leaves stale or duplicate lines, or times out partway | `a-notion-section-refresh-must-page-past-100-children-and-write-only-the-diff` |
| A liveness probe or restart guard matches a command-line substring with pgrep -f or grep | `an-argv-matching-probe-pgrep--f-ps-grep-matches-its-own-shell-or-a-wrapper` |
| An agent wants to test clipboard or paste behaviour on the operator's machine | `never-write-or-print-the-operators-clipboard-while-debugging-a-paste-problem` |
| Pasted text arrives with blank lines between every line in a terminal or terminal editor | `double-spaced-terminal-paste-is-a-crlf-clipboard-and-ghostty-has-no-setting-for-it` |
| A Swift check for \r or \n in a string silently never fires on Windows-style line endings | `swift-treats-rn-as-one-character-so-containsr-never-matches-crlf-text` |
| Adding a migration while another numbered one is pending, or editing an existing migration file | `flyway-refuses-a-late-low-numbered-migration-editing-an-applied-one-changes-its-checksum` |
| A script works from its repo path but fails with 'No such file' when run via a ~/.local/bin symlink | `a-script-that-sources-a-sibling-library-by-dirname-of-bash_source-breaks-when-run-through-a-symlink` |
| About to clean up temp dirs with a glob like `rm -rf $TMPDIR/tmp.*` or `/var/folders/*/T/*` | `a-cleanup-glob-over-a-shared-temp-root-deletes-other-sessions-directories` |
| Rotating one Amplify environment variable from the CLI | `aws-amplify-update-appupdate-branch---environment-variables-replaces-the-whole-variable-list` |
| A script or test drives tmux with a session name that may be unset or missing | `tmux-send-keys--t-sess-with-an-empty-sess-types-into-the-current-pane` |
| A kill/liveness script prints 'killed' or 'alive' for a tmux session that is already gone | `tmux--t-name-is-a-prefix-match-has-session-says-alive-for-a-dead-session` |
| Test passes 19/20 'only on a loaded CI runner' and will not fail locally under stress | `a-load-only-timing-flake-will-not-reproduce-under-cpu-load-stall-the-loop-in-process` |
| A generated 'PT' timestamp or day marker is an hour off right after the US clock change | `a-hardcoded-utc-7-used-to-label-pacific-time-is-an-hour-wrong-all-winter` |
| A shell loop prints a 'posted via fallback' line for rows where the fallback never ran | `a-b-echo-ok-echoes-if-either-side-succeeds-it-does-not-prove-the-fallback-ran` |
| A parsed TSV row has columns shifted left after a blank field | `ifst-read-collapses-empty-tab-separated-fields-and-shifts-every-later-column` |
| A timed-out tool command left processes running; box shared by parallel runs | `a-tool-timeout-that-kills-only-the-shell-wrapper-leaves-its-children-running` |
| Capping a child process's memory on macOS with ulimit | `ulimit--v-does-not-cap-memory-on-macos-use-an-rss-watchdog` |
| Writing a grader or sandbox that runs untrusted code under a timeout in Python | `a-graders-timeout-exception-must-derive-from-baseexception-not-exception` |
| A nightly or launchd job 'hung' at a stage and its own timeout never fired | `a-job-that-sleeps-mid-run-never-hits-its-timeout-the-timer-counts-awake-time-only` |
| About to kubectl delete an Ingress and a YAML backup of it is the only rollback | `deleting-an-ingress-also-deletes-its-cert-manager-certificate-back-up-both` |
| Postgres 500 'invalid input syntax for type integer' on a decimal bound as $N | `a-fractional-bound-parameter-used-with-an-integer-column-is-typed-integer-cast-numeric` |
| Time-window check on a naive timestamp column fails only in tests or locally | `age-arithmetic-in-js-on-a-naive-timestamp-column-is-off-by-the-db-session-time-zone` |
| Added an import from a package not in package.json and the unit tests pass | `jest-goes-green-on-an-undeclared-transitive-import-only-the-typecheck-catches-it` |
| Vue/Nuxt catch-all page renders blank, isLoading false, no error after router.replace | `a-path-string-watcher-does-not-fire-when-a-catch-all-route-changes-only-one-param` |
| Suites go green to red only in a staged copy of the tree you edited | `a-staged-copy-of-a-script-tree-fails-suites-for-reasons-that-are-not-your-edit-rerun-live` |
| A bash helper spins at full CPU for minutes on a large API response | `varpattern-on-a-multi-mb-bash-variable-is-quadratic-and-looks-like-a-network-hang` |
| Writing an age-based stale-lock check for a lock file or directory | `a-lock-age-check-that-defaults-an-unreadable-mtime-to-0-breaks-live-locks` |
| New migration column missing in tests that bootstrap with SQLAlchemy create_all | `create_all-never-adds-columns-to-existing-tables-a-reused-test-db-keeps-the-old-schema` |
| A new shell script's tmux calls all fail on a first dry run with no obvious cause | `a-script-variable-named-tmux-shadows-tmuxs-own-socket-variable-and-every-tmux-call-fails` |
| A 'beside the program' config lookup picks the wrong directory under pytest or a REPL | `pathsysargv0resolveparent-is-the-cwds-parent-when-argv0-is-empty` |
| Tests fail on a fresh clone with parse errors on fixture or asset files | `test-failures-from-git-lfs-pointer-files-check-the-file-size-before-debugging-the-code` |
| Test failures a change cannot explain; the repo package is also installed in the venv | `a-venv-with-the-published-copy-of-the-repos-own-package-makes-tests-import-it-not-source` |
| A Vue class component's state changes but the template never updates | `a-vue-arrow-function-set-as-a-class-field-never-triggers-reactivity-vue-facing-decorator` |
| gpg-using tests error under a long temp path on macOS but pass elsewhere | `a-long-pytest-basetemp-makes-gpg-tests-error-on-a-unix-socket-path-that-is-too-long` |
| A service loads a row, does slow work, then calls save(); a column set elsewhere reverts | `a-whole-entity-save-after-slow-work-writes-back-stale-columns-another-request-changed` |
| A test stub on PATH is ignored and the real command runs | `a-test-that-stubs-a-command-on-path-is-bypassed-by-a-script-that-prepends-its-own-path` |
| Pods killed during boot in a restart loop, or 503s after a deploy onto a busy node | `a-liveness-probe-restart-loops-a-slow-booting-pod-add-a-startupprobe-and-a-3-s-timeout` |
| A pnpm or npm login, test or build command runs the wrong tool, not the project script | `a-package-managers-built-in-verb-can-shadow-the-project-script-of-the-same-name` |
| A limit edited on one running pod is back at the old value after a restart | `a-hand-set-pod-resource-cap-reverts-when-the-pod-is-replaced-change-the-deployment` |
| Pods stay Pending on memory, or a rollout stalls though steady-state requests fit | `the-scheduler-places-pods-by-memory-request-not-usage-size-requests-and-check-surge-room` |
| A cap on a browser or worker pool still lets CPU spike from the work after it | `a-concurrency-cap-on-one-stage-does-not-bound-a-burst-gate-the-whole-expensive-path` |
| Choosing the next numbered migration after 99 with ls or a lexical sort | `ls-sorts-v100-before-v94-pick-the-next-migration-number-with-a-version-aware-sort` |
| A scaled-to-zero app comes back after a push or deploy to its repo | `a-push-redeploys-a-workload-you-scaled-to-0-by-hand-unless-its-replica-count-is-pinned` |
| A sed edit to a CRLF env or text blob leaves the old value in place without an error | `sed-into-a-crlf-file-can-match-nothing-and-still-exit-0-count-the-replacements` |
| A path comparison against git's toplevel returns 0 on macOS with no error | `on-macos-var-and-privatevar-make-a-git-head-path-comparison-silently-read-0` |
| An unauthenticated request reads rows it should be filtered out of, with no error | `typeorm-drops-an-undefined-filter-value-so-an-anonymous-lookup-matches-every-row` |
| /openapi.json returns 503 'not yet generated' after a route change | `one-route-with-regex-path-syntax-can-stop-the-whole-openapi-spec-from-building` |
| A scripted sed edit or diff normaliser on macOS changes nothing or gives a wrong diff | `bsd-sed-has-no-s-or-s-escape-a-pattern-that-matches-nothing-still-exits-0` |
| A psql :name variable stays literal when the SQL is passed with -c | `psql--c-does-not-interpolate--v-variables-send-the-sql-on-stdin-instead` |
| A new test file never runs, and the suite reports the same green count | `a-jest-ignore-pattern-can-hide-a-new-test-file-without-any-failure-or-warning` |
| A helper polls for a tmux send to land and every fleet send feels slow | `a-whole-second-sleep-in-a-tmux-poll-loop-costs-about-a-second-on-every-send` |
| A type check reports errors that do not reproduce in the project's own build | `npx-can-run-a-tsc-from-another-package-call-the-repos-own-tsc-binary` |
| A test goes red in a copied sandbox but the same test was not run in the real tree | `a-test-run-in-a-copied-sandbox-can-fail-only-because-sibling-files-are-missing` |
| A replay or stall test fails only under load, after a follow-up call is lost | `a-fixed-time-replay-schedule-turns-a-gc-pause-into-an-overlap-between-turns` |
| A test crashes with SIGSEGV in Node GC on one node version only | `a-node-version-can-crash-inside-its-gc-that-another-version-passes` |
| Parallel dev servers on two copies of a repo fail and the build output breaks | `two-dev-servers-on-copies-of-one-repo-corrupt-a-shared-build-cache` |
| A cache or sidecar dies while the API stays healthy and requests stall to the timeout | `a-cache-client-on-its-defaults-hangs-every-request-when-its-backend-is-killed` |
| A per-process cache keyed by request path or URL grows with traffic and nothing caps it | `an-in-process-map-used-as-a-cache-has-no-entry-limit-and-grows-the-pod-heap` |
| Verifying a test:* or email script whose broken import looks like a small repair | `a-test-named-npm-script-can-send-real-email-read-it-before-running-it` |
| A macOS heat or thermal check hangs, or a load reading is blamed on the wrong process | `pmset--g-thermlog-never-exits-and-a-backgrounded-job-can-pin-a-core` |
| Creating a venv under Python 3.14 fails with an ensurepip error | `a-python-314-venv-has-no-working-ensurepip-build-the-venv-from-python312` |
| A macOS swap alert with swap larger than resident memory, and a process list sorted by RSS points nowhere | `on-macos-rss-can-name-nothing-when-swap-is-the-problem-sort-by-compressed-memory` |
| A background wait loop never fires and its log shows nothing for hours | `an-until-loop-whose-test-zsh-rejects-never-exits-so-a-background-wait-spins-unnoticed` |
| Browser clicks or a dry run against a local build whose env file names a live API | `a-local-build-of-a-frontend-can-carry-the-live-api-url-swap-in-a-dead-port-first` |
| A mutation control run where a backup or edit step failed without stopping the run | `a-mutation-control-proves-nothing-if-its-backup-step-failed-check-cp-before-the-sed` |
| A psql count or eval runs for hours because a subquery re-parses a query per row | `a-per-row-subquery-that-re-parses-to_tsquery-ran-2h21m-precompute-once-set-based` |
| Integration tests all fail at once after a change, and .env holds a production URL | `a-test-suite-whose-env-points-at-the-live-database-fails-like-a-code-regression` |
| Stopping a Mac from sleeping with pmset, after an outage that happened on battery | `pmset--c-covers-ac-power-only-on-battery-the-machine-still-sleeps` |
| ls on a Group Containers folder fails with Operation not permitted; siblings list fine | `a-macos-full-disk-access-block-is-per-app-one-container-refuses-while-others-read` |
| A decorator-based service misbehaves under a fast local runner or ts-node --transpile-only | `a-transpile-only-runner-drops-decorator-metadata-boot-with-the-compiler-the-deploy-uses` |
| Filtering a log or list by a date prefix such as 2026-11 with grep | `a-month-prefix-grep-matches-any-row-that-mentions-the-month-not-only-the-date-column` |
| A CLI option is set on every run, but results look like the default setting | `a-wrapper-that-accepts-an-effort-flag-and-drops-it-silently-runs-every-result-at-default` |
| A shell heredoc that wraps Python or another script stops partway with no error | `a-heredoc-whose-body-contains-its-own-terminator-word-ends-early-and-the-rest-runs-nothing` |
| An integration spec connects to a database it was not meant to touch | `integration-tests-that-load-the-repo-root-env-can-reach-the-production-database` |
| About to run a migrate script whose target you have not read | `a-migrate-scripts-config-file-can-point-at-the-remote-database-not-the-local-one` |
| Jest spec fails on import after pulling in a service that reaches an ESM-only package | `a-standalone-jest-spec-that-imports-a-service-fails-on-an-esm-only-dependency-graph` |
| Queue-based spec finds nothing to process only while a dev backend is running | `integration-specs-on-a-shared-local-database-are-drained-by-any-live-backend` |
| Verifying a fix on a multi-replica service through the public ingress | `prove-a-replica-change-per-pod-with-port-forward-because-ingress-can-route-to-either-pod` |
| Playwright suite fails on pages that exist, on a machine running several dev servers | `playwrights-default-baseurl-is-localhost3000-which-can-be-another-projects-dev-server` |
| A spec asserting the canonical host fails only on a dev machine and passes on a clean tree | `a-root-env-loaded-by-the-test-runner-can-pin-a-url-that-canonical-host-specs-assert-on` |
| Building a file list by piping diff or status output through awk and $NF | `awk-nf-returns-the-last-word-of-a-line-which-is-not-the-path-when-the-line-has-spaces` |
| Unit suite shows hook or test timeouts that clear on a rerun | `two-jest-runs-sharing-one-tree-produce-timeouts-that-pass-when-rerun-alone` |
| Running a global replace across spec or helper files | `a-blanket-replace-rewrites-every-match-including-ones-you-did-not-intend` |
| A suite's failure count is smaller than the failing cases you expect | `a-fixture-read-at-module-load-turns-one-bad-case-into-a-whole-suite-error` |
| A SQL count is compared with === 1 or rendered as a number and looks wrong | `node-postgres-returns-count-and-bigint-as-strings-so-a-numeric-check-silently-fails` |
| Realtime subscriptions drop or log CLOSING/CLOSED errors on page load in a browser | `calling-socketconnect-while-a-socketio-client-is-still-connecting-drops-subscribes` |
| A shared package's build fails after the frontend type check passed | `a-green-vue-tsc-does-not-mean-a-shared-packages-tsup-declaration-build-passes` |
| A paged list filters by viewer after the SQL LIMIT | `a-limit-applied-before-a-per-viewer-filter-hides-the-viewers-own-rows` |
| A test script connects as the default postgres user on a Homebrew install | `on-homebrew-postgres-the-postgres-role-is-not-a-superuser-so-grants-fail` |
| Backend tests fail to load a package the backend never declared | `a-package-that-resolves-only-via-the-root-node_modules-hoist-breaks-the-backend` |
| A permission check reads me.isAdmin, a method, instead of a boolean | `a-method-named-in-a-condition-without-parentheses-is-always-truthy` |
| A test interrupted with Ctrl-C or kill -INT reports a pass | `a-non-interactive-shell-ignores-sigint-for-background-jobs-so-a-run-can-exit-0` |
| A panel is extracted into a child component and its link or icon loses its style | `scoped-vue-styles-do-not-reach-a-router-link-inside-a-child-component` |
| Reindenting a file with sed or python where it holds SQL or template strings | `a-mechanical-dedent-rewrites-the-bytes-inside-multi-line-template-literals` |
| A zero-stage loop over $(seq 1 N) crashes or runs once on macOS | `macos-seq-with-a-zero-bound-counts-down-instead-of-running-zero-times` |
| bun test hangs or fails with EMFILE where a repo keeps many files in a data directory | `bun-test-src-is-a-name-filter-not-a-directory-use-src-or-it-scans-runs` |
| A Bun script's loop over a process stream reads zero chunks with no error | `buns-for-await-over-a-child-stream-can-deliver-nothing-read-it-with-getreader` |
| A subprocess or monitor produces no output only when run under bun test | `under-bun-test-a-child-can-write-nothing-use-async-spawn-and-a-file-target` |
| A test puts a fake CLI first on a modified PATH and the real binary runs instead | `bun-resolves-a-spawned-binary-from-its-startup-path-so-a-tests-path-fake-never-runs` |
| ts-jest reports a type error in a file you did not touch while full tsc is clean | `ts-jest-can-report-a-type-error-in-untouched-code-until-its-cache-is-cleared` |
| Stale-code check reports a healthy long-running process as BLIND | `a-process-that-cds-after-a-relative-path-launch-makes-its-stale-code-check-read-blind` |
| A scheduled check re-fires while its previous run lives; copies pile up | `a-timed-job-with-no-overlap-guard-stacks-copies-when-a-run-outlives-its-interval` |
| A freshly copied binary dies with exit 137 and no output at launch on macOS | `overwriting-a-signed-binary-with-cp-on-macos-sigkills-it-at-launch-remove-it-first` |
| Scaling a DOKS node pool back down after a scale-up | `digitalocean-node-pool-scale-down-removes-a-node-of-its-choosing-unless-named` |
| Taking a launcher-managed daemon offline for a drill or test | `pause-a-launcher-supervised-process-with-sigstop-kill-gets-it-restarted` |
| A bun test that spawns a helper fails only when run from the parent directory | `bun-spawn-returns-empty-output-when-the-test-runs-from-the-parent-workspace-directory` |
| Vue class-component type-check fails when the base class is abstract | `a-bare-component-decorator-rejects-an-abstract-base-class-the-options-form-accepts-it` |
| A subprocess capture test fails with empty output that looks like a capture bug | `a-test-timeout-shorter-than-the-child-python-startup-captures-empty-output` |
| Changing a backup account or plan before its data has been restored | `a-backup-clients-license-transfer-or-inherit-state-step-can-purge-the-old-backup` |
| A test sends SIGUSR2 with Bun Subprocess.kill and the target dies from default action | `bun-subprocesskill-with-a-signal-name-sends-the-wrong-signal-number-on-macos` |
| A crash-path fixture expects a non-zero exit and an unhandled rejection returns 0 | `an-unhandled-promise-rejection-can-exit-0-so-an-exit-code-check-passes` |
| Launching a detached worker from a tool shell and it dies when the call returns | `a-nohup-process-that-still-holds-the-output-pipes-is-killed-when-a-tool-block-returns` |
| A POST whose output goes through head returns an error and you cannot tell if it wrote | `piping-a-writes-curl-into-head-hides-whether-the-row-landed-a-retry-double-counts` |
| Before/after capture hits a port where an earlier dev server is still listening | `an-old-dev-server-still-holding-a-harness-port-serves-the-stale-tree-kill-it-by-pid` |
| A test or script reads a tmux pane by window index and sees output from the wrong session | `a-tmux-window-index-already-in-use-makes-a-pane-read-hit-another-sessions-window` |
| Designing an upload or download path that moves large files through an API pod | `a-base64-upload-holds-the-whole-file-in-pod-memory-stream-it-in-parts` |
| An upload over a few MB fails and the app logs nothing | `an-ingress-body-size-cap-rejects-large-uploads-before-the-api-sees-them` |
| A per-request context set by middleware reads as empty inside route handlers | `body-parsers-drop-asynclocalstorage-context-mount-the-scope-middleware-after-them` |
| Editing source with a Python or sed string replacement that inserts a comment | `a-scripted-replacement-that-adds-an-inline-comment-can-swallow-the-rest-of-the-line` |
| Shipping a bun --compile CLI whose wrappers call bun-run scripts | `a-bun-compiled-binary-cannot-run-bun-wrapper-scripts-add-a-self-dispatch-subcommand` |
| Adding a progress or confirmation line to a CLI whose tests read stdout as JSON | `a-clis-confirmation-line-on-stdout-breaks-any-test-that-parses-the-output-as-json` |
| Grepping JSON Lines by a fixed-width prefix of each line before matching a field | `a-prefilter-that-cuts-each-jsonl-line-to-400-characters-misses-keys-further-in` |
| A git push or script puts a shell variable directly before a colon in a refspec | `in-zsh-cr-reads-as-a-modifier-and-mangles-a-git-refspec-use-c` |
| A fleet or watcher test run makes live service calls | `a-test-that-fakes-one-api-call-but-not-the-boot-path-still-hits-the-live-service` |
| Wanting to edit source while a long jest run is still going | `editing-source-while-jest-runs-corrupts-the-run-because-jest-compiles-files-as-it-goes` |
| Running one jest test by name against a database-backed fixture | `a-filtered-jest-run-skips-setup-hooks-so-its-database-state-differs-from-the-full-file` |
| A background wait loop returns at once though nothing new has happened | `a-wait-loop-keyed-on-a-log-file-exits-on-the-previous-attempts-last-line` |
| About to measure a feature through a prebuilt binary a runner calls | `a-prebuilt-cli-binary-can-predate-its-source-so-a-measurement-runs-the-old-code` |
| A Playwright render script says the browser executable is missing on a box with Chrome | `playwright-render-fails-without-its-bundled-browser-point-chrome_path-at-an-installed-one` |
| Publishing a public copy of a script that sources private libs | `generate-a-public-script-from-the-private-source-with-a-builder-that-fails-on-drift` |
| Whole DB jest suite fails 20/20 with hook timeouts; unit specs pass | `a-db-jest-suite-failing-every-spec-at-once-is-a-beforeall-timeout-under-load` |
| Writing or running tests for a script that persists state or claims | `a-test-of-a-stateful-script-writes-the-live-state-file-unless-its-path-is-pinned` |
| Skipping unchanged directories by mtime to speed up a transcript or log scan | `a-directory-mtime-does-not-move-when-a-file-inside-is-appended-mtime-skips-miss-lines` |
| A source is fast alone but 10-20x slower in the full parallel pass | `sync-work-in-one-source-starves-child-spawns-in-a-parallel-collector-run-spawners-first` |
| Adding PriorityClasses to protect critical pods on a memory-tight cluster | `pod-priority-does-not-protect-a-pod-with-an-understated-memory-request-from-the-oom-killer` |
| Several scripts launched together read one TTL cache whose source is paged and slow | `two-scripts-refilling-an-expired-shared-cache-both-page-the-full-source-add-a-lock` |
| Offsite backup 'succeeds' but one file set (e.g. prompt history) was never uploaded | `a-backup-script-that-stops-on-a-harmless-exit-code-2-warning-never-reaches-its-last-step` |
| Writing or reviewing an admin list or search endpoint that returns database rows | `a-raw-select-in-an-admin-search-bypasses-the-orms-exclude-and-leaks-password-hashes` |
## bash 3.2 command substitution closes early
macOS ships bash 3.2, whose `$( )` parser finds the closing paren by scanning *before* heredocs and quoted strings are resolved.
- **`VAR=$(cat <<'EOF' … EOF)`** — the first `)` inside the heredoc body closes the substitution and the rest parses as code. Fix: `IFS= read -r -d '' VAR <<'EOF' … EOF || true` (the `|| true` is required: `read` returns nonzero at EOF).
- **A multi-line single-quoted program inside `$( )`** (e.g. a wrapped `jq` filter) — parens inside the quotes are miscounted. Fix: one line, one quote pair.
**Tell:** `unexpected EOF while looking for matching '` at a line far below the fault, on balanced code. Bisecting with `head -n` fails because every prefix is broken. Isolate the suspect block into its own file and `bash -n` it. A reduced repro passes unless the body contains the `)`.
- **Bash 4 parameter expansion is a syntax error on the macOS shell.** `${name^^}` (and `${name,,}`) need bash 4+, but `/bin/bash` on macOS is 3.2. A library sourced by callers that start with `env -i` runs under /bin/bash, so the live `lib-engine.sh` failed to load for those callers for about a minute on 2026-11-07. Fix: `tr '[:lower:]' '[:upper:]'`. Test a shared library under `env -i /bin/bash` before installing it, not only from an interactive shell.
- `mapfile` (and `readarray`) is a bash 4 builtin and is absent from macOS /bin/bash 3.2. A 2026-11-10 protocol script that used it failed on the machine that ran it and was rewritten with a portable `while read` loop. Test any shell script that callers run under /bin/bash, not under a newer bash on the developer's PATH. Run `/bin/bash -n` and a single execution under `env -i /bin/bash` before shipping.
## grep silent negatives
Two ways `grep` reports nothing that do not mean "not present":
1. **Binary detection.** Any non-UTF8 byte makes grep treat the file as binary and suppress matches, with no warning. Tell: `grep -c` returns 0 on a file you can see the string in; `file <path>` says binary data. Fix: `grep -a`, or `awk '/pat/{print NR": "$0}'`.
2. **Exit 1 on no match, under `set -euo pipefail`.** A guard like `LEFT=$(… | grep -o '@[A-Z]*@' | sort -u)` kills the script exactly when everything was correct — silently, rc 1. The check is inverted: it only survives when it has something to complain about. Fix: `|| true` on the substitution.
3. **`… | grep -q` under `pipefail` fails on a match.** `-q` exits at the first hit; if the producer still has output (more than a pipe buffer, ~64KB), it dies of SIGPIPE and `pipefail` reports the pipeline as failed. The check reads FAIL exactly when the line is present and the input is large, so it passes in small fixtures and fails on busy days. Measured 2026-10-25: a retro grader recorded FAIL for a brief line that was in the log (`tools/waiting-on-him/check.sh`, fixed 961cda2fcf). Fix: `grep 'pat' >/dev/null` (reads to EOF), or match inside the producer (`jq -e 'any(…)'`); test with a fixture whose match comes before 64KB of trailing lines.
4. **Dropping `-q` from a MULTI-FILE `grep -s` turns a missing file into a failure.** The fix for trap 3 is not mechanical: `grep -s pat a b c` exits 2 when any listed file is absent, *even when another file matched* (`-q` masks this — it exits 0 on the first hit). A sweep that removed `-q` from `auto-memento.sh` (a681384efd) made a configured hook read as "not installed" whenever one settings file did not exist; caught 2026-10-31 by test-auto-memento, fixed a991b9ed3d. Fix: test the OUTPUT, not the status — `[ -n "$(grep -sl pat a b c)" ]`.
## Editing a running shell script
Bash reads a script incrementally by byte offset. Rewrite it in place while a shell is executing it and that shell resumes at its old offset inside the new bytes — mid-token.
**Tells:** the error names a line that is blank in the current file, and a data string (a JSON argument, say) is reported as `command not found`. `bash -n` passes because the file is fine; the running shell is desynchronised. Self-limiting — the next run is clean — so it reads as an unreproducible bug.
**Fix:** atomic replace — `sed … > tmp && mv -f tmp file`. `mv` within a filesystem is `rename(2)`, so the running shell keeps the original inode. GNU `sed -i` does this; BSD `sed -i ''` and `open(p,'w')` truncate the same inode, which is the hazard. Edit long-running daemons and their sourced libs between cycles.
**Instance 2026-10-24 (ee11b9b687):** a worker rewrote `ticker/bin/revive-dated-sweep.sh` in place while a 1800s interval run was reading it from the working tree. The run died with a syntax error at line 406 and posted nothing; the fix was then installed by copy to a temp file plus `mv`. Rule: any script a launcher executes from the tree is a live script, so install it as write-to-temp then `mv`, even for a "small" fix.
**Instance 2026-11-07 (~08:49Z):** an agent edited `ticker/bin/send-to-engine.sh` with a Python `open(p, "w")` rewrite. That truncates and rewrites the SAME inode, exactly like the Edit/Write tools and `sed -i`. A live lane's run printed `line 192: be: command not found`. Every lane runs send-to-engine.sh and sources lib-engine.sh constantly, so these are ALWAYS live, with no launcher schedule to wait out. Rule for any file a daemon or lane runs or sources (send-to-engine.sh, lib-engine.sh, lib-*.sh, run.sh): make the edit on a copy, `cmp` it, then `mv -f copy file`. Never use an in-place tool on the original, whatever the size of the edit.
## Editing a live re-imported module
A driver that re-imports a module on every cycle executes **every intermediate save**. A multi-file refactor that is half-applied (a rule naming a constant the lib does not export yet) throws on each cycle until it is finished — and a status file that only reports "targets=? / pool empty" reads as *no work left*, not *crashing*.
**Fix:** stage the whole refactor in a scratch copy and apply it in one write, or import-check the module (`bun -e 'import {x} from "./lib.ts"; x()'`) after each save. Data files read per cycle stay safe via write-tmp-then-`mv`. A "nothing to do" status line is not evidence the queue is empty: read the cycle's own log, or run the planner dry.
- The same hazard applies to a binary on a shared path (2026-11-11). Rebuilding the harness binary during an experiment changed the behaviour of another live session that runs that binary. Build experiment binaries to a private path and point the run at that copy, so a rebuild cannot change arms mid-phase.
## JSON string surgery
Patching a JSON file with text find/replace breaks it the moment the inserted text contains a `"`. Worse:
- **`bun -e` on a failing `JSON.parse` can print nothing and exit 0**, so the verification looks passed. `node -e` on the same file prints line and column. When a check must fail loudly, run it under node.
- **Live readers degrade silently** to defaults when the file stops parsing.
**Fix:** build the value in JS and let `JSON.stringify` escape it (`JSON.stringify(text).slice(1,-1)` when splicing into an existing string). Never hand-type `\"` inside a shell heredoc — shell, JS and JSON each take a layer of escaping. Parse the file back with node before moving on; keep a copy first if a live process reads it.
## bun -e argv starts at index one
For `bun -e '<code>' A B`, `process.argv` is `[bun, "A", "B"]`. The habitual node shape `const [,,a,b] = process.argv` reads one slot too far — silently: `a` gets the second argument and `b` is `undefined`. A test fixture built this way makes every positive assertion read "no action" while every negative control passes.
**Fix:** pass values through the environment (`FOO=… bun -e '…process.env.FOO…'`), which is immune to the offset and readable in the command line.
## bun test is one shared process
`bun test <dir>` evaluates every matched file in one process, with its own environment:
- **`process.exit` in any file tears down the whole run** — measured: exit 0 after running 1 of 34 files, with the first file's own "N passed" as the last line printed. A green covering 1/34 is worse than a red.
- **`process.exitCode = fails ? 1 : 0` clobbers an earlier failure** when a later file passes. Only ever raise it: `if (fails) process.exitCode = 1`.
- **`bun test` forces `TZ=UTC` and `NODE_ENV=test`** — the only discriminator from plain `bun file.ts`; exposes local-time fixtures.
- **`import('data:text/javascript,…')` does not resolve** under bun; `new Function(src + "\nreturn fn;")()` works in both.
**Fix:** measure whether the suite *ran* — count files executed and witness each one's output — not just its exit code.
- A test file written as a plain script (top-level checks that print `ok ...` and `all passed`, no `test()`/`describe()` calls) is discovered by `bun test` but registers nothing: the output is `0 pass`, `0 fail`, `Ran 0 tests across 1 file`. It looks like a clean or empty run, and the file's own assertions never executed. Measured 2026-10-28 in a script-style suite; running it as `bun <file>` printed the real per-check lines and `all passed`. Run script-style tests with `bun <file>` and read the exit code and its own summary line.
- **A bare path filter makes `bun test` walk the whole cwd and fail every spawn.** Measured 2026-10-17: `bun test tools/x/y.test.ts` from a very large workspace root has no leading `./`, so bun treats it as a name filter and scans the tree, leaving about 10,000 file descriptors open. With that many open, every process a test spawns, even `/bin/echo`, fails with no output, so tests pass or fail falsely. Not a bunfig, `.env`, preload, `package.json`, env, stdin or sandbox problem; the open-fd count was the only difference between passing and failing runs. Fix: write the path as `./tools/x/y.test.ts` (passed 3/3 on re-run), or run from the project dir. Re-measured 2026-11-03 (16,384 fds open): only PIPED stdio breaks. A child spawned with `stdout: Bun.file(path)` or stdio `ignore` runs normally, so a suite that captures child output to temp files passes under either invocation (tools/retros: 10 of 16 failing piped, 18 of 18 after the switch). A bare `bun test` at that root is presumed affected but untested; why bun leaks the handles was not investigated.
## Unconditional exit 0 hides failures
A scheduled shell job whose command ends in `exit 0` (or swallows with `|| true` / `2>/dev/null`) makes its own failures invisible: the scheduler sees rc 0 and logs green. Measured: a self-verify job whose only operator-facing step (a chat notification) failed for days while the log said success; the operator read the silence as "the whole thing is broken."
**Fix, in order:** make the load-bearing step set the exit code; tee an `outcome:` line per run to a known log a sweeper can grep; a self-verifier must verify its own reporting path. When writing one, ask: *if the side effect that matters failed, would the scheduler log show it?*
- Same shape from the pipe: 2026-10-18 platform reported a send-to-engine suite as failing to reproduce with exit 0. The suite does exit 1 on failure; the 0 was `| tail`'s status. Run the suite unpiped (or `set -o pipefail`, or read `${PIPESTATUS[0]}`) before blaming the script. In the same session a patched copy of the test ran without its library, so long sends typed nothing and a 'stuck' case passed vacuously: read the case count and one failing mutation, not just the final line.
- The same blind spot applies to a launcher that detaches its worker. On 2026-11-06 a detached runner returned 0 when its worker died at start, so every detached run reported success; the pre-fix runner returned 0 in the control. The fix makes the parent wait up to 5 seconds for the worker's lock and return rc 3 when none appears. Check that the parent's exit code depends on the worker starting, not only on the launch call returning.
- A test that wraps a mock call in try/catch can hide the failure. On 2026-11-07, after a mock lacked a `release()` method, 19 render-spec failures were caught inside the catch and the specs still passed. Make the catch rethrow or count what it swallowed, and break a mock on purpose once to confirm the spec goes red.
- A pipe can also hide whether a send landed, not only its exit status. On 2026-11-10 a pane-send command piped through tail or grep gave output that could not show whether the message was delivered, so the agent could not safely resend. Run the send unpiped, capture its own exit code and delivery line, and decide on a retry only after reading them.
- The same pipe can land a commit on a red run. On 2026-11-04 an agent ran a test suite piped through `grep`/`tail` to trim output and chained `&& git commit`. The suite failed, but the pipeline's status was grep's (0 on a match; `tail` always 0), so the commit landed. Commit on the test command's own exit code: run it unpiped, or `set -o pipefail`, and add only the named files. A helper that runs the test unpiped and commits only on rc 0 was control-tested with `'exit 3'` (rc 3, HEAD unchanged). Output that reads as a pass is not an exit code.
## Killed background command reads as empty
When a harness backgrounds a timed-out command and later kills it, the output file is empty — byte-identical to a completed search that found nothing. The kill notice can arrive many turns after the empty file was read and believed. Measured: a broad `find ~` timed out, its empty output was published as "the repo does not exist" in three places; the repo was at depth 2.
**Fix:** check the task's terminal status before reading its output as a result — only a clean exit makes an empty file evidence of absence. On macOS use `mdfind -name <x>` first (indexed, instant); when `find` is needed, prune (`-not -path "*/node_modules/*"`) and search likely roots, not all of `~`.
- 2026-11-11, machine load near 51: background verification jobs exited 144 and their output could not be trusted, and the task status alone did not show the kill. Check each log's exit line before counting a run as evidence, and re-run the job in the foreground when load is high.
## kubectl current-context is shared state
`kubectl` current-context is global mutable state; another session on the same machine can switch it between two of your commands, even onto a different client's cluster. **The dangerous failure is a false negative**: on the wrong context a resource returns `NotFound`, which reads as *already deleted* while it is still running and spending.
**Fix:** pin `--context=<name>` on every call; never trust a context you read seconds ago. If a guard hook allow-lists read verbs by position, put the verb first (`kubectl get pods --context=X`), and pass prose that mentions the tool's name via a file rather than inline in the command.
## zsh and macOS errors where bash would not
The interactive shell here is zsh on macOS. Four habits copied from bash/Linux transcripts fail on it — loudly, but in a way that kills the rest of the command line, so later steps never run and their absence reads as "nothing to report".
1. **`echo ====` is `=cmd` expansion.** In zsh a word starting with `=` expands to the path of the command named after it; `=====` looks up a command called `====`, fails with `zsh:1: ==== not found`, and **aborts the whole command line, rc 1** — every later `;` or `&&` step is skipped, not just the echo. Seen in four separate sessions, twice in one day in one of them (2026-10-25). Fix: quote it (`echo '===='`), or use `---` / `printf`.
2. **An unmatched glob is a hard error.** `ls dir/*.log` with no match prints `no matches found` and the command is never invoked (bash passes the pattern through). Fix: the `(N)` qualifier (`dir/*.log(N)`) or `setopt nullglob` for "zero is fine"; quote globs meant for the program (`--include='*.vue'`, `find -name '*.md'`). Flag-value case in depth: `@protocol/zsh-glob-trap-an-unquoted-includeext-never-runs`.
3. **macOS has no `timeout` binary** (nor `gtimeout` unless coreutils is installed). `timeout 30 cmd` fails with command-not-found — and a test suite wrapped in it reads as uniformly FAILING while each "failure" reports rc 0. Tell: total, uniform failure across unrelated tests. Fix: `perl -e 'alarm shift; exec @ARGV' 30 cmd`, or the harness's own timeout; never assume GNU coreutils.
4. **Large globs overflow argv.** `ARG_MAX` is 1 MiB here; `grep pat ~/.claude/projects/**/*.jsonl` over thousands of files dies with `argument list too long` before grep starts. Fix: `find … -print0 | xargs -0 grep pat`, or let the tool recurse (`grep -r --include='*.jsonl'`).
**Tell for all four:** the error names the shell (`zsh:1:`) or a missing command, not the program you meant to run — the program never started, so no output from it is a non-reading.
- **Three more zsh habits (2026-10-23 to 10-31).** (5) An unquoted `$VAR` is not word-split: `F='a b'; git add $F` passes one argument `a b`, adds nothing, and a following commit came out silently empty; use an array (`F=(a b); cmd "${F[@]}"`, which works in bash too) or zsh's `${=F}`. (6) `"$S:refs"` reads `:r` as a history modifier (strip extension) and mangles the string; write `"${S}:refs"`. (7) Builtin `echo` interprets backslash escapes, so `echo "$json"` turns a `\n` inside a JSON string into a real newline and the payload looks corrupted (once misread as a server fault); use `printf '%s\n' "$json"` or write the response to a file and read that.
- (8) A variable named `path` clobbers `$PATH` (2026-10-31). In zsh the lowercase array `path` is tied to `$PATH`. A probe loop that did `for ... path=...` rewrote PATH on the first iteration, so every later command in the same shell failed lookup. Same tie for `cdpath`/`fpath`/`manpath`. Pick another name (`p`, `route`, `endpoint`), or declare `local path` only inside a function. Tell: commands that worked before the loop become 'command not found' inside it.
## A child that calls process.exit after console.log loses piped stdout past 64 KiB
Measured 2026-10-25: a scheduled scan script printed its result with `console.log(JSON.stringify(...))` and then `process.exit(0)`. The parent captured the output through a pipe and failed with `scan output not JSON ... position 65536`. When stdout is a pipe, writes are asynchronous; `process.exit` drops whatever is still unflushed past the 64 KiB pipe buffer, so the cut lands at exactly 65536 bytes. It passes while the output is small and breaks the first day the payload crosses 64 KiB (here about 1,500 records), so the failure looks like flaky data. The parent's `maxBuffer` (64 MB) was not the cause. Fixes: set `process.exitCode` and let the process drain, or have the parent send the child's stdout to a temp file and read it back. Reproduce with a stub child that logs well over 64 KiB then exits, and keep the old code as a control: it must fail with the position-65536 error, or the test proves nothing. Grep other scripts for the same print-then-exit shape.
## A scheduler's minimal PATH hides /usr/sbin tools: the gate reads off, not broken
Measured 2026-10-25: a scheduled script gated on machine load via `sysctl`. `sysctl` lives in `/usr/sbin`, which a runner's `PATH=/usr/bin:/bin` does not include, so `command -v sysctl` found nothing, `$load` came back empty and the max-load gate was silently disabled. The only symptom was a log line printing `load ` with nothing after it. Fix: append `/usr/sbin:/sbin` to PATH inside the script. The first regression test was vacuous: the env assignments were written before `env -i`, which wipes them, so it passed for the wrong reason. Put assignments after it: `env -i PATH=/usr/bin:/bin OWD_MAX_LOAD=0 script`, then assert the guarded action was skipped. An old-code control run (the test must fail on the unfixed script) is what exposed the vacuous version.
Same root, louder symptom (2026-11-01): a new ticker check whose wrapper did `exec node script.mjs` died rc=127 "exec: node: not found" on its first launcher run. nvm installs node under `~/.nvm/versions/node/<v>/bin`, which no scheduler PATH contains, while an interactive shell finds it, so the wrapper passes every hand test. Fix: resolve the interpreter inside the wrapper (`command -v node`, else the newest `~/.nvm/versions/node/v*/bin/node` by `sort -V`), exit 2 if none. Test with `env -i HOME=$HOME PATH=/usr/bin:/bin bash wrapper.sh`; the control is the unpatched wrapper, which must print rc=127 there.
- Add to the minimal-PATH section: 2026-11-02, a nightly refresh job still lacked `~/.local/bin` on PATH even though the plist on disk was already correct, because launchd keeps the environment of the loaded job until it is booted out and bootstrapped again. A probe that read the live launchd PATH reported stale values, which looked like a new failure. A guard hook may block `launchctl bootout`; The fix landed in the script itself (nightly script prepends `~/.local/bin`, tested with a bare PATH), which works whether or not the job was reloaded. A plist lint that passes only covers the plists it scans.
- 2026-10-31: the same gap produced a wrong-directory symptom, not an empty reading. A helper resolved a process's working directory with `lsof` (in `/usr/sbin`); under the engine's `PATH=...:/usr/bin:/bin` it was not found and the helper quietly fell back to the caller's cwd, so every output file landed in the wrong folder and the test grader only said 'No such file or directory'. `env -i PATH=<engine PATH> nohup ...` reproduced 30 of 72 cases failing; adding `/usr/sbin:/sbin` alone made all pass, so the suspected cause (nohup, no terminal) was wrong. A sibling check guarded on swap got an empty reading, so its guard never fired. The runner builds a fresh PATH per check, so the fix belongs in that per-check wrapper as well as the script. Replace the silent fallback with a warning.
- Same root, hook flavour (2026-11-06): a Claude Code session-start hook that pushed usage data ran `node` and a helper CLI from `~/.claude/settings.json`. The hook runs under `/bin/sh` without the login PATH, so an nvm-installed `node` and the CLI's own dependencies were not found. The push log held two `node: command not found` lines from session starts, and nothing else reported an error, so the collector looked installed but never pushed. Pin PATH inline in the hook command (or resolve absolute paths) instead of relying on the interactive shell, and check the hook's own log after the first real session start, not a hand run.
- Add to the minimal-PATH section: 2026-10-31, after adding /usr/sbin:/sbin to an engine's run.sh, killing only the engine child made its KeepAlive wrapper respawn it with the old PATH, because the wrapper had already read the script's PATH. Bounce the wrapper first, then the child, and verify the new process ids and a full pass in the log. Replace edited scripts with mktemp then mv so a running wrapper never reads a file changed under it. Also fix the per-check launcher (check-run.sh), which builds its own PATH; the engine's run.sh alone does not cover lane checks. One launcher line that builds the fleet clock PATH needed a launcher restart and was left for the operator.
## A heavy one-off script run inside a single-replica serving pod takes the service down
2026-10-31: a cleanup dry run was executed inside the serving backend pod to size the work. It loaded about 275k rows, the pod ran out of memory, and the service was down roughly five minutes (11:16:30 to 11:21:45Z) until a replacement came up. The deployment ran one replica, although the project docs implied several; check `kubectl get deploy` for the real count before reasoning about blast radius. Rule: heavy or bulk work runs as a one-off pod or Job from the same image and secret with its own memory limit, and reads are paged even for a dry run. A dry run is not safe just because it writes nothing; it still allocates. Leftover pod objects from the incident also need deleting by hand.
Two refinements from building the runner that does this (2026-11-11):
- **Make "read-only" a property of the pod, not a promise in the script.** Set `PGOPTIONS='-c default_transaction_read_only=on'` in the pod env. node-pg, psql and libpq send it at connect, so every transaction is READ ONLY on the server and a write fails with "cannot execute … in a read-only transaction". For an HTTP API with side effects, preload a guard (`NODE_OPTIONS=--require guard.js`) that refuses non-GET requests to that host before they leave the pod. Lift both only behind an explicit `--write` flag. A dry run then cannot write, even when it has a bug. (This needs a direct database connection. Some transaction-mode poolers reject startup options.)
- **Delete the pod on every exit, and know that bash defers traps.** A `trap cleanup EXIT` does not run on SIGTERM or SIGINT until the foreground child (`kubectl exec …`) returns. A long script therefore keeps its pod for the whole run after you kill the runner (measured: 131 s). Run the exec in the background and `wait` on it, because `wait` is interrupted at once. Give the pod `terminationGracePeriodSeconds: 1` when its PID 1 is `sleep`, since `sleep` ignores SIGTERM and deletion would otherwise wait the default 30 s.
## Pod restarts with exit 137 and reason=Error are liveness-probe kills, not OOM
2026-10-31: a backend pod restarted 8 times; the working theory (in the task brief and a filed ticket) was in-pod Chromium memory pressure. Measured instead: every restart was exit code 137 with `reason=Error`, not `OOMKilled`, and the liveness probe was `timeoutSeconds: 1`, `failureThreshold: 3`, so three slow responses under load got the container SIGKILLed. Of 261 renders in the window, all 261 were sourced from the site's own endpoint and zero used Chromium, so the browser was a false lead. Check `kubectl describe pod` for the last-state reason and the probe spec before blaming memory; 137 only means SIGKILL, and the reason string says who sent it. Fixing load (throttling the rebuild loop) came before touching the probe.
## AppleScript in a dynamic `tell` loses the app dictionary: `tab` becomes the tab character
Measured 2026-10-21 while building a browser-URL watcher: an AppleScript that targets an application by a variable name (`tell application appName`) resolves that app's terms only at run time, so the compiler never loaded its dictionary. `tab` then reverts to the built-in constant (the tab character) instead of the browser's tab class, and nothing errors. A second hazard: `tab` also collides inside Chrome's own `tell` block. Fix: wrap the browser-specific terms in `using terms from application "Google Chrome"` (one block per browser family) and test each browser's script against a real window. Also resolve the frontmost app with `lsappinfo` rather than asking AppleScript; resolving an absent browser hung the watcher until the background pid was killed.
## TypeORM `UPDATE` and `DELETE` through `query()` return `[rows, count]`, not the rows
Seen 2026-10-20 in a Postgres/TypeORM backend: a raw `UPDATE ... RETURNING` or `DELETE ... RETURNING` issued through `manager.query()` resolves to a two-element array `[rows, affectedCount]`, whereas a `SELECT` resolves to the plain rows array. Code written for the SELECT shape sees the count as an extra element or reads `rows.length` as 2. Fix: destructure (`const [rows] = await manager.query(...)`) for UPDATE/DELETE only, and cover the shape in a test against a real database rather than a mock, since a mock returns whatever the author assumed.
- A plain `INSERT` gives no affected-row count either. On 2026-11-15 a restore step that read the count of its INSERT saw 0 although the rows had landed. Read the inserted rows from `INSERT ... RETURNING` and count those instead.
## A 'next 7 days' test built as 168 hours is wrong in the week a clock change falls
Measured 2026-10-31: a nightly test went red from 10-26. It computed 'a week from today' as exactly 168 hours in UTC; the week contained the US clock change (Nov 1), so the cutoff landed one hour before the zone's real midnight. The production code already did calendar arithmetic in the zone and was right; the test was wrong, so the fix went in the test. Proof used a control check on Postgres: the old expression gives 23:00 PST, the new one gives midnight. Rule: when a test goes red in the week of a DST change, compare against calendar-day arithmetic in the target zone (`date + interval '7 days'` on a zoned timestamp), never `n * 24h`, and keep a control that shows the old expression fails.
## JS String.replace expands $& and $' in the replacement string
Two separate sessions on 2026-10-28 corrupted source files the same way. A replacement string passed to `String.prototype.replace` is a template, not literal text: `$&` inserts the matched text, `` $` `` the text before it, `$'` the text after it, `$1` a group. One session's `$'` spliced a duplicate copy of the file tail into the file (cut back at line 481); the other's `$&` duplicated the match and had to be fixed by hand. Related: `perl -0pi` interpolates `${...}` in template literals inside the test file it is editing. Fix: pass a function as the replacement (`s.replace(re, () => text)`), use `replaceAll` with a function, or use the Edit tool for exact multi-line replacements. After any scripted patch, diff the file before running it.
## Headless Chrome screenshots of an animated page show the first frame
2026-10-17: screenshots of a landing-page hero (an animated swarm and gear that fade in) taken with headless Chrome showed the animation stuck at its first frame, with the gear edge-on mid-fade, which read as a layout bug. Headless capture does not advance the animation clock the way a live browser does, so a single screenshot is not evidence of how the animation looks. Fix: drive the page to fixed moments (set the animation to a given timestamp, or render several frames at known offsets), judge each frame, and say in the report that live animation in a real browser is still unverified. Same session, the same class of false render: a page with a light/dark/auto theme switch fell back to auto in the test copy, so the dark and light captures came out identical. Force the theme in a way auto cannot override and compare the two renders before trusting either.
- Hover and focus state also leaks into a capture. A before/after diff of a status-picker page was nondeterministic on untouched code, and was resolved only by moving the mouse away and blurring focus before each shot, then reshooting both sides. A 'before' set re-shot later must match the saved set before its diffs count as evidence of regression.
## A git worktree borrows main's node_modules: a stale shared build fails tests
2026-10-19: tests in a feature worktree failed on code nobody had touched. The worktree resolved a monorepo shared package through main's installed `node_modules`, and that package's built output was stale relative to the worktree's source, so the failures looked environmental. Rebuild the shared package in the checkout you are testing before running the suite. Do not call a failure pre-existing or a flake (a date-utility failure was dismissed as timing without checking CI) until it fails on a clean checkout or in CI. Same session: `window.open` with `noopener` returns null by design, so its return value cannot detect a blocked popup.
- 2026-11-07: a snippet test run in a scratch copy symlinked its `node_modules` to the shared tree, so the test loaded the shared tree's packages and exercised code other than the copy's. The result was therefore not the copy's own. Rule: a scratch copy that symlinks `node_modules` tests the shared tree's packages; give the copy its own install before trusting a pass or a failure.
## kubectl apply does not delete objects removed from the manifests
2026-10-27: deleting a superseded exact-host Ingress manifest and re-applying did not remove the live object, so the exact-host Ingress kept outranking the new wildcard Ingress and traffic still went the old way. `kubectl apply -f` only creates and patches; it never prunes what is absent from the files. After removing a manifest, delete the live object explicitly (`kubectl delete ingress <name>`) and confirm with `kubectl get ingress` that it is gone; delete orphaned objects that went with it, such as old TLS secrets. Use `--prune` only with a label selector you trust.
## A catch-all Proxy mock is thenable, so awaiting it hangs the framework
2026-10-30: a test double built as `new Proxy({}, { get: () => jest.fn() })` returned a function for the `then` property. Any `await` or promise resolution on that object (here Nest's module setup resolving a provider) treats it as a thenable, calls `then`, and never settles, so the suite hangs with no error. Fix: return `undefined` for `'then'` (and for symbol keys) in the Proxy `get` trap, or build the mock from an explicit method list. Rule: a catch-all mock must exclude `then`; if a test hangs in setup rather than failing, suspect a thenable mock before suspecting the framework.
## Pulumi replaces a same-named ECS service delete-before-create, dropping traffic
2026-10-21: a Pulumi update replaced a live production ECS service. Because the service name was fixed, the old service was deleted before the new one was created, giving a 503 for about two minutes (18:54:29Z to 18:56:25Z). A code comment claimed `waitForSteadyState` keeps production serving; that was wrong and was corrected. Rules: read the preview for `replace` on anything serving traffic; AWS cannot rename ECS clusters or services, so a move means create new, shift traffic, delete old; never `pulumi up` a stack whose services are set to desired count 0 in code while production runs on them. Stop the old worker before starting the new one unless overlap is proven safe.
## Commenting out Terraform makes the next apply destroy everything in state
2026-10-21: asked to deactivate Terraform after a move to Pulumi, the obvious step was to comment the resources out. That makes `terraform apply` plan to destroy every resource still in state (about 50: load balancer, DNS zone, database, registry), and only the database had deletion protection. Also, "Terraform is frozen" was only a sentence in the README; apply was still possible, and stale state would have reversed same-day changes (a listener default, a released IP, a deleted topic) and could replace a state entry that is really the production DNS alias. Fix: add a version guard in `main.tf` that fails plan/apply, move code to `reference/*.tf.txt`, archive the tfstate rather than `terraform state rm`, and gate the Pulumi takeover on a zero-diff `pulumi preview`.
## SET default_transaction_read_only before a psql pre-check may not take effect
2026-10-21: a pre-check against the production database was prefixed with `SET default_transaction_read_only` to make it safe; the same session then read the setting back as `off`, so the guard did not apply. Only SELECTs were actually run. Rule: do not rely on a session flag as the safety; verify with `SHOW transaction_read_only` inside the same transaction, use `BEGIN READ ONLY`, or a read-only role, and limit the statements to SELECT.
## Parallel doctl registry deletes stall the DigitalOcean API: cap at two
2026-10-29: pruning a DigitalOcean container registry (54 repositories, 244 GB) with four parallel `doctl` delete calls stalled the API. Resumed at two concurrent deletes, it completed, keeping the newest image per repository plus images in use (62 manifests; storage went from 244 GB to 4.5 GB). Rule: throttle bulk registry deletes to two in flight and re-list between batches to confirm what is actually gone, rather than trusting the calls that returned. The plan's repository limit also matters before a prune: a small plan allows only a handful of repositories.
## AWS CLI SSO settings in a shared profile make it ignore static access keys
2026-10-18: a profile holding both static access keys and shared SSO settings made the AWS CLI take the SSO path and fail with `Error loading SSO Token`; `aws sso login --profile X` also failed because that profile had no SSO start URL or region. Fix: keep static keys alone in their profile and put SSO settings in a separate profile (for example `<name>` and `<name>-sso`). An SSM tunnel started before the profile was fixed had to be reopened. When a CLI command fails on a missing domain or region, set both explicitly rather than assuming defaults.
## A zero-padded hour parses as invalid octal in bash arithmetic
2026-10-19: a nag script gated on business hours read the hour from `date +%H` and compared it numerically. At 08 and 09 the leading zero made bash read the value as octal, so `(( hour >= 9 ))` and `[ ]` arithmetic errored with an invalid-octal message, while every other hour worked. A script that only misbehaves in two hours of the day passes any test run outside them. Fix: force base ten with `$((10#$hour))`, or take the hour with `date +%-H`. One of two sibling scripts already carried the fix and the other did not, so grep sibling scripts for the same pattern when you find it in one.
## A process that accepts connections and never answers: sample CPU time twice
2026-10-16/17: a shared test Chrome on the CDP port accepted connections and never replied, so every probe hung instead of refusing. A day went on a swap storm that was real but incidental. One command settled it: `ps -o time= -p <pid>` sampled twice, 5 seconds apart, showed CPU time frozen at the same value (`2:12.11`) with 52 threads at 0.0% CPU. The process was not slow, it was not running, and memory recovered without it reviving, so it was never memory-bound. Corollaries: a frozen writer is the one moment a consistent copy of its profile is guaranteed (snapshot then). A frozen browser cannot be cleared with a tool that needs the same endpoint (a tab sweeper hung). SIGTERM can take minutes to take effect on a wedged process, so a short watch window produced a false 'unkillable' conclusion; SIGKILL on a browser loses logged-in sessions, so try SIGTERM and wait first. The `/json/version` check can stay green while this is happening.
## execFileSync in a bun test blocks the test's own HTTP server
2026-10-24: a CLI test spawned the CLI with `execFileSync` while the same test file ran a local HTTP server for the CLI to call. `execFileSync` blocks bun's event loop, so the server could not answer and the CLI appeared to fail. The CLI was fine; the test was wrong. Fix: use async `spawn` (or `execFile`) and await it, and close any leftover tab or handle the failed attempt opened. Rule: when a test hosts a server for the process it is spawning, the spawn must be asynchronous.
## pgrep on a command line in a test matches other runs' processes
2026-10-17: a test located its helper with `pgrep -n -f '^sleep 600$'`. One run passed; three concurrent runs failed, because each picked up another run's `sleep`. `pgrep -f` matches every process on the machine, not the ones your script started. Isolate instead: give each run a private tmux socket (`tmux -L <unique-name>`) so only its own server and panes exist, or capture the pid from `$!` at launch. A test that finds its subject by pattern is only correct when it is the sole run, and the green single run hides that.
## A watcher script that pipes `tail -F` leaves the tail running when it is stopped
2026-10-22: a dispatch-watch script ran `tail -n 0 -F file | ...`. When the harness stopped or expired the watch only the outer script died; the `tail` was reparented to launchd and, on a quiet file, never got SIGPIPE, so one orphan accumulated per stop. Fix: run the pipeline in the background, `wait` on it, and `pkill -P $$` in a trap on EXIT TERM INT HUP. Test it by stopping the script and asserting no child `tail` remains; keep the old-style pipeline as a control that must still leak. A live check by stopping your own watch showed no leak, because the old script also cleaned up on that particular kill path. Only some kill paths leak (expiry, SIGTERM from the harness), so a manual stop proves nothing and the unit test is the evidence. Write the fixed script to a temp file and `mv` it into place when other processes run it live.
## A secret rendered by ${{ }} inside shell quotes breaks out of them; eval was not the hole
A brief assumed the code-execution hole was `eval` in a deploy script. A control run injected `$(touch ...)`, backticks and quote tricks through the old script and none executed. The real path was the workflow step: `<<< '${{ env.SECRETS }}'` is expanded by the Actions runner before the shell sees it, so a single `'` inside any secret or variable value ends the quoted string and runs the rest. Fix the workflow step (pass values through the step's `env:` and read them as shell variables), not only the script. Also: the old script `cat`ed the rendered manifest, printing every secret into the job log; mask values in rendered output. Run a negative control before changing code on an assumed premise. Branch pushes are inert when deploy workflows trigger only on push to main.
## Cloning yesterday's brief with sed on the date also rewrites historical dates
2026-10-19: a daily brief was cloned from the previous day's with `sed s/2026-10-18/2026-10-19/`. The pattern also matched dates that were history inside the worker rules (an autostash from 10-18), so the new brief silently told the worker a false past. Nothing errored and the diff looked like a clean date bump. The fix was to revert those lines by hand. Rule: a blanket date substitution cannot tell 'today' from 'a date that is a fact about the past'. List every match first (`grep -n OLD file`), substitute only the lines that mean 'today', or template the brief with a single placeholder (`{{DATE}}`) so history is never in the substituted token's namespace.
## A stale postmaster.pid after a reboot keeps local Postgres down: rename it aside
2026-10-20: after an unclean shutdown a stale `postmaster.pid` kept a local Postgres down for about 14 hours, because the PID recorded in it had been reused by an unrelated process, so the server believed another postmaster was alive and refused to start. 2026-10-22 fix, built as a boot guard (9/9 tests against a temporary data directory, not the live database): at boot, if the lock file names a process that is not Postgres and Postgres is not answering, rename the file aside (kept for forensics, never deleted), restart the service with `launchctl kickstart` without `-k`, and page once if it is still down after 60 seconds. Run the guard backgrounded so its 60s wait does not delay the rest of boot. Caveat: it was verified only against a temp directory; a real reboot was untested at session end.
## A guard script that crashes on an empty array lets the blocked command through
A shell guard that blocks destructive git commands in a shared checkout crashed twice (2026-10-08 and 2026-10-23) with `unbound variable` on an empty array: a command beginning with a bare `git` left the parsed words array empty, and expanding `${words[@]}` under `set -u` aborts the script. The caller treated any non-block exit as allow, so the guard failed OPEN: `git && git stash` ran while a plain `git stash` was refused. Fix: skip a `git` with nothing after it and keep checking the rest of the command, and guard empty-array expansions (`${arr[@]+"${arr[@]}"}` on bash 3.2). Rule: a guard's crash path must deny, not allow, and its tests must include degenerate input. The two new test rows were run against the OLD script first and failed, which proves they catch the bug; all 46 then passed and the live guard refused `git && git stash`.
## A test suite launched by a daemon inherits its live env knobs and hits real targets
2026-10-24: a fleet-monitor test suite was reported as hanging. It was not a blocking step. The launching daemon exported live-fleet knobs (`PIPE_LANES_FILE`, `ACTUATE_*`, `NOTIFY_NOW`), so fixture runs resolved real lanes instead of fixtures: about 8 spurious FAILs, and very slow runs on a box at load ~100. A sub-agent first reported 167 green in 7 minutes; an independent rerun exited 1 after 14.5 minutes, and the check script discarded test output so the failing step was invisible. Fix: make the test hermetic: `unset` every inherited knob the code under test reads and pin the file-path variable per run (`PIPE_LANES_FILE=$tmp/lanes`). Rule: a test must not read the caller's environment. Rerun it yourself from the launching context before closing on a sub-agent's green, and keep failing output visible.
- 2026-10-31: after a runner was changed to give each test a fresh `TMPDIR`, two lane-actuate tests that were green standalone went red. They were not load flakes: the failure reproduced every time under the runner, and running the same test with only `TMPDIR` replaced isolated the cause. The tests read live-state inputs (the projects dir, the lanes root and three caches) from the host's real locations, so they passed only because the host happened to hold the expected state. Fix: pin every live-state input to the test's own scratch dir. Rule: when a test is green by hand and red under a runner, vary one runner property at a time (`TMPDIR`, stdin, env) before calling it flaky; the by-hand green is the weaker evidence, because it ran against the caller's real state.
## A line-anchored grep on a multi-line command misses it: join lines before matching
2026-10-23: a session at ~830k tokens could not clear because its self-clear tool refused every call with "this call did not come from the main conversation (a subagent?)". The tool's caller check printed the newest assistant tool_use as `"\(.name) \(.input.command)"` via `jq -r` and ran `grep -q '^Bash .*<tool>'`. A command with a `cd` or heredoc before the call prints over several lines, so `Bash` and the tool name never share a line and the caller reads as "other". The session fell back to a keep-context mode and never cleared. Fix: normalise the command to one line before matching; workaround meanwhile: make the tool the first word of the command and feed its body from a file. Rule: when matching a tool_use's command, join lines first, and treat a false refusal from a guard as a bug in the guard, not in the caller.
## A Notion section refresh must page past 100 children and write only the diff
Two defects in one daily-page refresh. 2026-10-23: 45 stale copies of a line piled up under one toggle because the refresh read only the first 100 child blocks (the API page size) and could never delete lines past that point; four other reads in the same file had the same limit. 2026-10-24: the refresh kept timing out because any change to a 55-block section replaced every block one at a time, about 111 serial calls, while Notion itself answered in under a second; a run killed at the 5-minute limit left 3 stale lines. Fixes: loop every children read on has_more/next_cursor, with a test fixture over 100 children; diff old and new lines, keep matching leading and trailing blocks, and insert or delete only the rest, so a one-line change costs about 2 calls. Never delete-then-rewrite a whole section: an interrupted rewrite leaves partial state, and a longer timeout would not have helped.
## An argv-matching probe (pgrep -f, ps | grep) matches its own shell or a wrapper
Two cases. 2026-10-17: a sign-in probe decided a browser was running on a debug port by matching the port flag in process args; it matched the probe's own shell, whose command line carried the same flag, and reported a live browser with a fake pid on a port where nothing ran. 2026-09-24: a restart guard using `pgrep -f 'bun adapter.ts'` matched a shell wrapper carrying that string and blocked a daemon restart for about 4.5 minutes. Fixes: match the executable (`comm == bun`) and the exact argument (`argv[1] == adapter.ts`), exclude your own pid, or ask the port itself by connecting to it. Prove the guard before committing: run it against a port you know is dead, and against a decoy process that carries the string in argv; the old guard matched the decoy. Use a self-exiting timer as the decoy, since a kill aimed at a matched pattern can trip kill-guard hooks.
## Never write or print the operator's clipboard while debugging a paste problem
Two incidents while chasing a double-spaced terminal paste. 2026-10-20: a research agent ran `printf 'a\r\nb\r\n' | pbcopy` to test CRLF handling, replacing the operator's system clipboard with the test string unannounced; the clipboard is a single shared slot on his live machine and is not recoverable. 2026-10-22: an agent printed the clipboard to inspect it, and it held temporary cloud credentials, which landed in the transcript, a permanent corpus; the agent flagged it and did not repeat it. Rules: inspect a clipboard by shape only (`pbpaste | xxd | head`, byte counts, CR/LF counts), never print its text; reproduce paste bugs in a pipe or file (`printf ... | cat -A`), or ask the operator to run the check himself; if a write to the clipboard is unavoidable, say so first.
## Double-spaced terminal paste is a CRLF clipboard, and Ghostty has no setting for it
2026-10-22: text copied from a browser (CRLF clipboard) pasted double-spaced into Ghostty, micro and nano. The first guess, tmux extended-keys, was wrong. Plain paste maps `\r\n` to `\r\r` on purpose (matching xterm), so each CRLF becomes two Enters; bracketed paste passes through unchanged; iTerm2 is the odd one out. Ghostty has no paste-newline setting and micro/nano have no config or plugin hook for it. Working fix for micro: Ctrl-V instead of Cmd-V, because micro reads the clipboard directly (verified by file bytes). Feature request: Ghostty discussion 14810; related #9592, micro #3571. Also: `/usr/bin/nano` on macOS is Apple's pico 5.09, not GNU nano, so check `nano --version` before drawing conclusions about nano (GNU nano 9.3 from brew behaved the same).
## Swift treats \r\n as one Character, so contains("\r") never matches CRLF text
2026-10-22: a macOS helper meant to strip carriage returns from clipboard text tested `string.contains("\r")`. It never matched CRLF input, so nothing was stripped and the bug looked unfixed. Swift groups `\r\n` into a single grapheme-cluster Character, which is neither `\r` nor `\n` on its own. The fix was a byte-level check, `utf8.contains(13)`, and the replacement likewise worked on bytes. Rule: when scanning for line-ending characters in Swift, work on `utf8` or `unicodeScalars`, never on Characters, and prove the check with a literal CRLF fixture.
## Flyway refuses a late low-numbered migration; editing an applied one changes its checksum
2026-10-23/24, a Node/Postgres project using Flyway with `validateOnMigrate=true` and the default `outOfOrder=false`. A new migration (V18) had to ship while V17 (a NOT NULL change) was parked unapplied. Once V18 is applied, V17 arriving later is refused as out-of-order, so the parked file was moved to a `database-pending/` folder and renamed to a number above any shipped one (V19+). Separately, editing only the comment text of V16 changed its checksum; locally `flyway repair` fixed it, which is only safe because prod had not applied V16. Rules: number migrations in the order they will be applied, never reserve a gap; never edit an applied migration (comments included); and ship a NOT NULL constraint only after the code that fills the column and a backfill have run on prod, since code from before the column never names it and the migrate step fails on existing NULLs.
**A hook-blocked command ran NONE of its parts, including the heredoc that wrote your payload.** If a PreToolUse hook refuses a compound command, the file it was meant to write was never written — and a shared path like `$TMPDIR/imp.json` may still hold ANOTHER session's file. A retry that reuses the path then acts on foreign content (office 2026-11-01: impulse-create.sh dupchecked terms from a stranger's payload). Write payloads to your session scratchpad with a unique name, and re-write them in the retry.
## A CLI called from a subprocess with an inherited non-tty stdin can hang waiting on it
Measured 2026-11-04 (office `check-gate-sources.py`, fix ea47316c6f): `curly` called via Python `subprocess.run` with stdin inherited from a non-interactive parent read the impulse source as UNREADABLE on every run, while the identical call by hand returned in under 2s. The CLI waits on a stdin that is open but never closes (it may treat piped stdin as a request body). Fix: pass `stdin=subprocess.DEVNULL` (shell: `< /dev/null`) on every call that does not mean to send a body. The tell: a call that is fast at a terminal and times out only under a daemon, a hook or a subagent.
## `--help` on a script with no argument parsing runs it, and can truncate its own output file
2026-11-05: a ticker engine probed a small runner with `python3 run.py --help` to learn its arguments. The runner reads no argv, so it started the real job: 50 paid model calls, and `open("raw.jsonl","w")` truncated the committed baseline before the first answer came back. The probe was stopped within two minutes and the file restored with `git show HEAD:<path> > <path>`. `--help` is a convention, not a guarantee. For a script you have not seen, and that has no usage helper, read its first lines (or `grep -n argv`) before passing any flag, and never probe it from the directory that holds its outputs. A script that writes with mode `w` loses data on any accidental run, so a probe that only *looks* harmless costs the whole file.
- 2026-11-12: `--help` on a TUI binary opened the interactive TUI and hung the pane, because the program was itself a TUI with no non-interactive help path. The session read the binary with `strings` to find its flags instead. A program with no non-interactive help path cannot be probed with `--help`; check its usage text or docs first.
## A script that sources a sibling library by dirname of BASH_SOURCE breaks when run through a symlink
2026-11-02: a helper that located its sibling library with the directory of `${BASH_SOURCE[0]}` worked from the repo but failed when invoked through a symlink in `~/.local/bin`, because the directory resolved to the symlink's folder, not the real one. Thirteen scripts shared the pattern, a regression from an earlier PATH-class fix that the existing lint accepted. Fix: resolve the real path first (`realpath "${BASH_SOURCE[0]}"`) before taking the directory, in every caller. Add a test that runs the script through a symlink and a lint rule that flags the unresolved form; the flagged-form case is the control proving the lint can fail. Result 11 of 11 pass. Rule: any script meant to be symlinked onto PATH must resolve its own real location before sourcing siblings.
- Same family: a converted test script derived its library path after a `cd`, so `bash bin/test-x.sh` (relative invocation) failed while an absolute path worked; the fix was to derive the lib path before any `cd`. Verify suites by running them both ways. To keep a suite from touching production, run it behind a refusing `curly` shim placed first on PATH (stubbing tests prepend their own shim); a suite that creates real impulses, such as a claim-race test, is skipped rather than run live.
## aws amplify update-app/update-branch --environment-variables replaces the whole variable list
2026-11-01: while writing a runbook for rotating a key stored as an Amplify environment variable, the CLI route was found to be destructive. `aws amplify update-app` and `aws amplify update-branch` with `--environment-variables` replace the entire list, so any variable not restated is deleted, including secrets that cannot be recovered from the CLI. The runbook therefore says to rotate through the console, and no AWS writes were made from the session. Rule: to change one variable, either read the full current list first and resend all of it, or use the console.
## `tmux send-keys -t "$SESS"` with an empty $SESS types into the current pane
2026-11-01: a shell test ran `tmux send-keys -t "" C-u` because it never checked that its tmux session existed, so the target variable was empty. An empty `-t` falls back to the current pane, so on the live server the keys would have been typed into a real session. Sibling tests that target `=$SESS`, the exact-match form, fail safely when the session is missing. Rule: build every tmux target as `-t "=$SESS"`, and abort first when `$SESS` is empty or `tmux has-session -t "=$SESS"` fails. A test that sends keys should use its own private socket (`tmux -L`) rather than the default server, so a bad target cannot reach a live pane.
## tmux -t NAME is a prefix match: has-session says alive for a dead session
2026-11-01: a session-manager script checked liveness with `tmux has-session -t <name>`. tmux resolves `-t` as an exact match first, then a prefix match, so when the target had already exited but a sibling whose name starts with the same text was alive, the check passed and the script printed "killed" although nothing was killed. The fix was one line: target `=<name>` (`tmux has-session -t =name`, `kill-session -t =name`), which forces an exact match. Any script that gates on tmux session existence, or kills by name, should use the `=` form; session names that share a prefix (a base name plus a suffix) make the false positive routine rather than rare. A related probe habit: `pkill -0` is not a liveness probe; use pgrep.
## A load-only timing flake will not reproduce under CPU load; stall the loop in-process
2026-11-01: a replay-parity test intermittently produced 20 planner calls instead of the golden 21 on loaded runners. Running the spec under heavy CPU load on a Mac did not reproduce it: the OS scheduler gave node its fair share, so event ordering never shifted. What did reproduce it was blocking the event loop inside the process (a 50 ms block in every 60 ms): 20/21 calls, and 15/21 with heavier blocking. The root cause was ordering (a silent-turn repair skipped because the previous reply was still playing when the next turn opened). The durable fix was a virtual clock in the harness (timers and Date.now simulated), after grepping that no code path bypassed it (no AbortSignal.timeout, performance.now, setImmediate); runtime fell from 25 s to 0.6 s and 8 consecutive stalled-loop runs passed. For slow-runner flakes, simulate slowness with an in-process loop stall, add it as a regression case that fails before the fix, then remove wall-clock dependence.
- 2026-11-13, a split refactor's Jest suite timed out with the box at load average 40 to 56. The timeouts were load, not code. The two sides of the before/after run timed out on different suites, so their integration results were not comparable. Measure load before reading a timeout as a regression, and rerun both sides under the same load.
## A hardcoded UTC-7 used to label Pacific time is an hour wrong all winter
2026-11-01, the day US daylight time ended: a digest builder wrote a refresh stamp of "07:41 PT" when the real Pacific time was 06:41, because it converted UTC with a fixed `-7h`. Production code, not just a test, carried the fixed offset. Fix: convert with the IANA zone (`America/Los_Angeles`) instead of a constant, then re-stamp the bad entry. Rule: after a clock change, grep every script that labels a time as Pacific, or that decides which Pacific day a daily marker belongs to, for a hardcoded offset; a fixed offset at a day boundary puts the marker in the wrong day for the whole winter, and nothing errors, the stamp just reads plausible.
## `a || b && echo ok` echoes if either side succeeds; it does not prove the fallback ran
2026-11-01: a loop posted log rows with `curly ... -d @file -w "$id %{http_code}\n" || curly ... -d "$body" >/dev/null && echo "$id posted-alt"`. Every row printed `posted-alt` although the fallback POST never ran. `||` and `&&` have equal precedence and group left to right, so this parses as `(a || b) && echo`: the echo fires when the primary succeeds, and the label claims the opposite of what happened. The session caught it by reading one row's log back for a double post. Rule: never use `a || b && echo label` to report which branch ran. Use `if a; then echo primary; elif b; then echo fallback; fi`, or put the echo inside each branch, and read one written row back before trusting the labels.
## `IFS=$'\t' read` collapses empty tab-separated fields and shifts every later column
2026-10-31, building a per-service token probe: rows were tab-separated and one field (the token) could be empty. Tab is IFS *whitespace*, so `read` treats consecutive tabs as one separator and every column after the empty one moves left, with no error. Fix used: separate with `\x1f` (unit separator), which is not IFS whitespace, e.g. `IFS=$'\x1f' read -r a b c`. Alternatives: put a placeholder like `-` in empty fields, or parse with awk/jq. Tell: the last variable is empty or holds the wrong value only on rows that have a blank field.
## A tool timeout that kills only the shell wrapper leaves its children running
2026-11-01, an agent harness ran each tool command in a bash wrapper and killed the wrapper at the tool timeout. A runaway test process spawned by the wrapper survived, was reparented to launchd (ppid 1) and grew to 29 GB, stalling every parallel run on the shared box. Killing the wrapper never kills its children. Fix: start each command in its own process group, kill the whole group on timeout and on exit, and add a memory watchdog polling the group's RSS (500 ms). A child that calls setsid or detaches into its own session still escapes the group, so that case stays open. When cleaning leftovers, check each pid's parent is launchd before killing it, and kill by pid; a broad `pkill` as the only tool also hits live sibling work.
## `ulimit -v` does not cap memory on macOS; use an RSS watchdog
2026-11-01, while fixing a runaway tool process, `ulimit -v` was rejected as the memory cap because it is a no-op on macOS: the limit is accepted but the kernel does not enforce it on the address space. The working replacement was a watchdog that polls the process group's resident memory every 500 ms and kills the group above a threshold (default 4 GB, set by an env var). In a test a fast allocator reached 2 to 3 GB before the kill against a 500 MB cap, so the poll interval bounds the overshoot. The real runaway grew over 15 minutes, so the 4 GB default catches it early. Do not rely on `ulimit -v` in scripts that must run on this box.
- An RSS watchdog that reads `ps` needs `ps` to work inside the sandbox as well. On 2026-11-12, under macOS `sandbox-exec`, the setuid `ps` binary was blocked, so the memory cap's reads failed; a no-op `ps` shim put first on PATH stopped the failure but left the cap reading no memory figures. Confirm the watchdog reports a known process's RSS from inside the same sandbox before trusting it.
## A grader's timeout exception must derive from BaseException, not Exception
2026-11-01, building a grader that runs a model's code against hidden tests under a per-test timeout. The grader raised its own timeout exception from a signal handler, and the exception subclassed `Exception`. Any test helper or candidate code with `except Exception:` would swallow it, and the hang would be graded as a pass. Fix: make the timeout exception subclass `BaseException`, the same reason `KeyboardInterrupt` does. Before trusting a grader, also show that it can fail: it was run against an empty module and a reply with no code block, and both scored zero.
## A job that sleeps mid-run never hits its timeout: the timer counts awake time only
2026-11-03: a nightly refresh started during a brief scheduled wake on a laptop, nothing held the machine awake, and it slept for about three hours while a roughly 15-minute stage was running. The run's log stopped at an earlier stage name and a report blamed that stage, but it had already finished. The job's 90-minute timeout never fired because it counted only time the machine was awake. Two false leads were ruled out: the stage that the log stopped at, and a missing `~/.local/bin` in the job's PATH (the script adds it itself). Fix: wrap the whole run in `caffeinate -i` (verified it holds the machine awake and releases when the script exits), and log real elapsed wall-clock next to the timer count. When a job 'hangs' with a timeout that should have fired, check the sleep log (`pmset -g log`) for the window before blaming a stage.
## Deleting an Ingress also deletes its cert-manager Certificate: back up both
2026-11-03: a cleanup session backed up 18 Ingress objects to YAML, then deleted them. The Certificates for those hosts were owned by the Ingresses (cert-manager ingress-shim sets an ownerReference), so they were garbage-collected with them, and the in-flight ACME solver objects went too. The Ingress backup alone therefore does not restore a working host: re-applying it makes cert-manager re-issue from scratch, which is rate-limited and leaves the host without TLS until it completes. Before deleting an Ingress that carries a `tls:` block, also `kubectl get certificate,secret -o yaml` for its secretName and keep that beside the Ingress backup. Check the owner with `kubectl get certificate <name> -o jsonpath='{.metadata.ownerReferences}'`.
## A fractional bound parameter used with an integer column is typed integer: cast ::numeric
2026-11-03: a step-stats query compared `rs.actual_seconds >= rs.planned_seconds * $3` with `$3` bound to the constant 0.25. Postgres inferred `$3` as integer from the integer column it was multiplied with, so every request that reached the query failed with `invalid input syntax for type integer: "0.25"` and the endpoint returned 500 for every signed-in user. The unit tests passed because they fake the database layer; only a live request exposed it. Fix: `rs.planned_seconds * $3::numeric`. Rule: when a bound parameter is a non-integer used in arithmetic or comparison with integer columns, cast the placeholder explicitly; and run one real query against the local database for any new SQL with a bound constant, because faked-repository specs cannot see parameter typing.
## Age arithmetic in JS on a naive timestamp column is off by the DB session time zone
2026-11-03: an amend-window check computed `now - created_at` in JavaScript against a `created_at` column of type `timestamp` (no time zone). The local Postgres session ran in one zone while the app host ran in another, so the computed age was off by the zone delta (about 16 hours) and `age < 0` was always true, so the branch returned null. Tests looked like a logic bug; the cause was two clocks with different zones. Fix: do the window arithmetic in SQL (`now() - created_at` inside the query) so the write and the read share one time basis. Check `SHOW timezone` on the database session whenever a naive timestamp is compared with an app-side clock.
- `to_char` on a timestamptz also renders in the database session's time zone, not UTC. On 2026-11-09 a rendered impulse column came out 8h shifted, and integration runs failed on the same skew until the column was pinned. Check `SHOW timezone` before reading a rendered time, and build the value with an expression that does not depend on the session zone.
## Jest goes green on an undeclared transitive import; only the typecheck catches it
2026-11-03: a frontend fix imported a package that was not a declared dependency. Jest resolved it transitively through a sibling package and went green. Only the typecheck (`vue-tsc`) failed. The lockfile is gitignored in that repo, so the Docker build resolves versions fresh and would have shipped a build that does not build. Rule: after adding any import, declare the package in `package.json` (pinned to the same version as its sibling packages) and run the typecheck, not just the unit tests. A green test run proves the module resolved in this machine's node_modules, not that the dependency is declared.
## A path-string watcher does not fire when a catch-all route changes only one param
2026-11-03: an id-form URL redirected to its canonical form with `router.replace`, then the loader did `return`, assuming the route change would re-run the load. It did not. On a catch-all route the router reuses the component instance, so `mounted` never reruns, and a watcher on a derived path string does not fire when the rewrite changes only one param. The page sat at `isLoading: false` with no content and no error, a state that looks like an answer. Fix: await the replace, drop the `return`, and add a watcher on the changed param guarded by an address-equality check. A 'just redirected' flag is defeated by ordering. Verify with a fresh browser context per address and drive the SPA router for the cross-param case, because a page load remounts and proves nothing.
## A staged copy of a script tree fails suites for reasons that are not your edit: rerun live
2026-11-06, two sessions editing a shell tooling tree: edits were staged in a scratch copy of `bin/` and the suites run there. Several suites that had passed at baseline failed (four in one session). They failed identically with the original files restored. The copy lacked untracked or out-of-tree files the suites read (a policy table at the tree root) and had no git history for suites that use `git log` or `git diff` as a control. The reverse also held: a real regression in an id-rewind test showed up only after install, because the staged run had not isolated it. Rule: a stage failure that reproduces with the original files is a staging artifact, and a stage pass is not proof. Install via temp file plus `mv`, then rerun the full suite list in the live tree and compare to a recorded baseline.
## `${var//pattern/}` on a multi-MB bash variable is quadratic and looks like a network hang
2026-11-06: the first live call of a new shell client for a list endpoint ran at full CPU for over two minutes, past its own 22 s bound. It was read as a network hang. It was the blank-body check `${body//[[:space:]]/}` on a large body: bash pattern substitution on a big string is quadratic, and it ran in the helper's own subshell, so no timeout around curl covered it. Fix: a linear test (`[[ $body =~ [^[:space:]] ]]`). A regression test pins it on a 4 MB body (old 12 s, new under 1 s). A 2 MB control ran 4 s against a 5 s threshold and did not discriminate, so size the control well past the threshold. A 2 MB value also cannot go through an environment variable to an exec'd stub; the stub must read the body from a file. When a helper hangs, check `ps` CPU before blaming the network.
## A lock-age check that defaults an unreadable mtime to 0 breaks live locks
2026-11-06: age-based lock helpers in two shell scripts computed lock age as now minus mtime and defaulted a failed `stat` to 0. An unreadable or just-vanished lock then looked decades old, so a waiter broke a lock that was live and took it. A 20-writer parallel test showed 8 double-holds (two writers inside the critical section, producing duplicate ids). Rule: an unreadable mtime means unknown, so treat the lock as held (retry) or fail loudly; never map it to the epoch. Test the contention case with many parallel writers and assert zero double-holds, plus a stale-break case, an unreadable-mtime case and a no-spin case. Locks that judge staleness by holder PID liveness instead of age are not affected.
## `create_all` never adds columns to existing tables: a reused test DB keeps the old schema
2026-11-06, a Python API whose test script bootstraps its schema with `Base.metadata.create_all`: after a migration added a column, tests against the existing test database failed or ran against the old shape, because `create_all` only creates missing tables and never alters existing ones. The assumption that it would add the column was wrong. Fix: point the test script at a fresh database name per schema change, or drop and recreate, or run the real alembic migrations in the test bootstrap. When a new-column test fails with a missing-column error against a reused database, suspect the database before the code.
## A script variable named TMUX shadows tmux's own socket variable and every tmux call fails
2026-11-05, the first dry run of a new shell script failed on every tmux call. The script held the tmux binary path in a variable named `TMUX`, which collides with the `TMUX` environment variable tmux itself sets (the socket path, `socket,pid,session`) and reads. Assigning or exporting `TMUX` to a binary path breaks every `tmux` invocation that inherits it. Renamed to `TMUX_BIN`; the dry run then passed. Never name a script variable `TMUX` or `TMUX_PANE`, and `unset TMUX` only when you mean to leave the current tmux server.
## `Path(sys.argv[0]).resolve().parent` is the cwd's parent when argv[0] is empty
2026-11-06: a pre-merge review of a config loader that searched for a `.env` "beside the program" via `Path(sys.argv[0]).resolve().parent` found it misfires. When `sys.argv[0]` is the empty string (interactive REPL, notebook), `Path('')` is `.`, so the result is the parent of the current directory, not the program's directory; under pytest `argv[0]` is the venv `bin/` entry, so the search lands there. Verified: `Path('').resolve().parent == Path.cwd().parent` is True. A loader that reads credentials or keys from that directory can silently pick up an unrelated file or none. Fix applied: skip the argv[0] source when it is empty, and test the loader under pytest and an empty argv. Use an explicit config path or the package's `__file__` for anything that must not depend on how the process was launched.
## Test failures from git-lfs pointer files: check the file size before debugging the code
2026-11-06, setting up a repo's test suite on a fresh macOS machine: five of six failures in the mesh tests were not code bugs. The fixture files were 130-byte git-lfs pointer files (text starting `version https://git-lfs.github.com/spec/v1`) because git-lfs was not installed, so the real binaries never downloaded. Before reading code, check `ls -l` or `head -c 200` on the file a failing test loads. Fix: `brew install git-lfs`, `git lfs install`, `git lfs pull`, then rerun the FULL suite; "no failures left" asserted without a re-run is unverified.
## A venv with the published copy of the repo's own package makes tests import it, not source
2026-11-06, finishing a cleanup pass in a Python monorepo: the full pytest run showed 6 failures, and the first assumption was that the session's own edits caused them. They did not. The venv's site-packages held an older published release of the repo's own package, and the tests imported that instead of the working-tree source, so they exercised old code. Diagnose by printing `<module>.__file__` from the test's interpreter; if it points into `.venv/lib/python*/site-packages`, the source is not under test. Fix: run with `PYTHONPATH` set to the repo source roots, or reinstall the package editable; the tree was green with the source on the path.
## A Vue arrow function set as a class field never triggers reactivity (vue-facing-decorator)
2026-11-06, building a nav bar that goes from transparent to white on scroll in a Vue 3 frontend using vue-facing-decorator class components: the scroll handler ran and the value changed, but the nav never re-rendered. The handler had been written as an arrow function assigned to a class field. Class fields are initialised on the raw instance, so the assignment bypasses the reactive proxy and Vue never sees the change. Fix: declare it as an ordinary method (`onScroll() { ... }`), bind it in `mounted` and remove it in `beforeUnmount`. If a class component's state is correct in the console but not on screen, look for arrow-function class fields first.
## A long pytest basetemp makes gpg tests error on a unix socket path that is too long
2026-11-06, running a Python suite on macOS with pytest's default temp root under the long `/private/var/folders/...` path: 6 tests that spawn `gpg` errored. The cause was not code: gpg-agent creates a unix socket inside the test's GNUPGHOME, and unix socket paths are limited to about 104 bytes on macOS, so a deep temp path fails. The same tests passed with `--basetemp=/tmp/pt`. Whenever tests that start gpg (or any unix-socket daemon) error with socket or agent messages, shorten the temp root before reading the code.
## A whole-entity save() after slow work writes back stale columns another request changed
2026-11-06: while adding a free-text note column to a document, the agent saw that its first design (setting the column and calling the repository's whole-row `save()`) was unsafe. Finalize and notify paths load the entity, run slow work, then `save()` the whole row, which writes the old note, body and status back over whatever a concurrent request changed. Fix used: the new column is written by a single-column `update()` on its own endpoint, and the finalize and notify paths no longer assign it. The regression test for a stale value being written back was kept with a control that fails when the fix is removed (a first version passed vacuously and was rewritten). Rule: write an independent field with a targeted update, and give the regression test a control that fails without the fix.
- **A side effect in the same request does this too.** 2026-11-10, a signature-triggered notification saved the whole document as it had been loaded, before a status move in the same request, which would have written the old status back. Keep the in-memory status in step with each change before any whole-entity save.
## A cleanup glob over a shared temp root deletes other sessions' directories
2026-11-11: an agent finished debugging a shell test that kept its `mktemp -d` directories, then cleaned up with `rm -rf /var/folders/<x>/*/T/tmp.*`. That glob matches every `mktemp -d` directory under the user's temp root, and on a box running several agent sessions at once, that includes directories other sessions' running tests and jobs were using. The temp root is per user, not per session. Nothing reports the damage: the other session's job fails later with a missing file, far from the cause.
Rule: **remove only paths you recorded yourself.** Capture each one when you create it (`d=$(mktemp -d); echo "$d" >> "$MYTMPS"`, or keep it in a variable) and delete exactly those, or make a private parent first (`mktemp -d` once, then put everything inside it) and remove only the parent. Never write a cleanup glob over `$TMPDIR`, `/tmp`, `/var/folders` or `/private/var/folders`. When a tool prints the path it kept (`KEPT /path`), delete that path by name. If you already ran such a glob, report it at once to whoever runs the other sessions, because they cannot see it themselves.
## A test that stubs a command on PATH is bypassed by a script that prepends its own PATH
A test was meant to replace the project's CLI with a stub on PATH. The script under test put ~/.local/bin first in its search path, so the real CLI ran instead, and an early draft of the test posted a note to the live API twice. The fix was to inject the binary through an explicit override variable that the script reads, which keeps the test hermetic. Rule: a PATH stub works only if the script under test does not reset PATH, so check for `export PATH=` and prepended search directories before trusting a green stub test, and prefer an explicit override variable.
## A liveness probe restart-loops a slow-booting pod: add a startupProbe and a 3 s timeout
Deploys onto a node pinned near 100 percent CPU caused liveness restart storms and 503s for one to two minutes. The health check allowed one second, so a slow-booting pod was killed before it could answer, and a rollout that stopped the old pod before starting the new one left no serving pod during the gap. Tuning the liveness probe alone was rejected, because the pods had not finished booting. The fix: a startupProbe on the health path (5 s period, 36 failures, so 180 s allowed for boot), liveness and readiness timeouts raised from 1 s to 3 s, and start-before-stop rollout, with a render test that fails if any of these is removed. Rule: size probe timeouts for the slowest boot under load, and check node CPU before a rollout lands there.
## A package manager's built-in verb can shadow the project script of the same name
2026-11-07: `pnpm login` resolved to pnpm's built-in npm-registry login and asked for registry credentials, so the project's own `login` script in package.json never ran. `pnpm run login` reached the script and produced the sign-in link. Rule: when a package manager's built-in command has the same name as a project script, call the script explicitly with `pnpm run <name>` (or `npm run <name>`), and confirm the command reached the script from its output rather than assuming it did.
## A hand-set pod resource cap reverts when the pod is replaced: change the Deployment
In this session (2026-11-07), a CPU cap set by hand on one running pod stopped applying once that pod was replaced. The new pod, created by the same ReplicaSet from the Deployment's pod template, came back at the spec value (1500m CPU, 300Mi memory). A live pod's spec is not the source of truth, so a one-pod edit is only a mitigation that lasts until the next restart or reschedule. Rule: change resource limits in the manifest or the Deployment and roll it out, then read the new pod's spec back to confirm the value took.
## The scheduler places pods by memory request, not usage: size requests and check surge room
The scheduler reserves requests, not usage. On 2026-10-18 a 900Mi memory request made a pod unschedulable, while a 300Mi request let the scheduler pack more pods onto one node than its real use allowed. The fix raised the request to 700Mi and kept every node at 750Mi or more unrequested. A related rollout needed 1,152 MiB free on one node for its surge pod while the most-free node had 472 MiB, so a check of steady-state requests passed while the rollout would have stalled. Rule: size the request from measured peak use plus headroom. When a rolling update sets maxSurge above zero, check that the largest single pod's request fits on the most-free node, not only the sum across the pool. The memory limit is separate and does not change placement.
## A concurrency cap on one stage does not bound a burst: gate the whole expensive path
In this session (2026-11-07), a request burst overloaded a rendering pod. A cap on the headless-browser pool (PLAYWRIGHT_MAX_CONCURRENT=2) was rejected as the fix: the markdown, LLM and database work ran after the browser slot freed, so a Chromium-only cap left the CPU burst in place. The fix put one pod-wide slot around the whole render, default 1, queue none, serve stale cache or return 503. The test was run with the source change stashed, where two renders ran at once, which is how the cap was proven. Rule: bound a burst at the top of the expensive path, not at its first stage.
## ls sorts V100 before V94: pick the next migration number with a version-aware sort
In this session (2026-11-07), a lexical ls put V100 ahead of V94, so V99 looked like the highest migration. Lexical sort compares character by character, so any numbering past 99 breaks pipelines such as ls then tail. Rule: list numbered migrations with sort -V (or a numeric key) and read the highest version, then confirm the chosen number is unused before creating the file. The migration here became V101 because V100 already existed.
## A push redeploys a workload you scaled to 0 by hand unless its replica count is pinned
In this session (2026-11-07), ten workloads that had been undeployed were found running again after a burst of pushes. A push deploys at the replica count the repo's deploy variable sets, so a registry row alone did not stop it. Setting that variable to 0 (after backing up its value) held the workloads. One backend hardcoded replicas: 1 in its manifest, so the variable did not hold for it. A database outage in the same window was not confirmed as linked. Rule: pin the replica count where the deploy reads it, check each manifest for a hardcoded count, and test with one push that a turned-off app stays at 0.
## sed into a CRLF file can match nothing and still exit 0: count the replacements
In this session (2026-11-07), a sed replacement into CRLF env blobs made zero replacements, yet four blobs still differed from the target, only in trailing blank lines. The likely cause is a pattern anchored at the end of the line, which misses the carriage return before the newline, so sed matched nothing and exited 0. Rule: count the replacements (diff the output, or grep -c for the new value) before trusting a sed edit to a CRLF file, and match the carriage return explicitly.
## On macOS, /var and /private/var make a git HEAD path comparison silently read 0
2026-11-07: a dispatch helper's HEAD lookup read 0 on macOS, with no error and no failed call. The script and git named the same folder differently: the shell kept the /var/... path, which is a symlink, while git reported the resolved /private/var/... path. A plain string comparison between the two never matched, so the lookup returned an empty count and the caller treated it as a real zero. The fix normalised both paths to their resolved form before comparing. Rule: on macOS, resolve paths with `cd -P && pwd -P` or realpath before comparing values taken from different tools, and treat a lookup that is expected to match but returns zero as a failure to investigate.
## TypeORM drops an undefined filter value, so an anonymous lookup matches every row
2026-11-07: an endpoint with no auth guard passed an undefined owner id into a TypeORM lookup. TypeORM removes a where-condition whose value is undefined or empty instead of matching on it, so the query had no owner filter and an anonymous request returned another customer's site data. A second endpoint had the same gap. The fix requires an authenticated owner on both endpoints, and makes owner-scoped repository lookups return nothing when the owner is empty. The test checks that an anonymous or garbage token gets 401, and that a valid owner gets 404 on someone else's record. Rule: when a scope value can be missing, return nothing for a missing scope rather than omitting the filter.
## One route with regex path syntax can stop the whole OpenAPI spec from building
2026-11-07: a live API returned 503 'not yet generated' for /openapi.json and /openapi.yaml. One route, `GET /content/:idOrSlug(.*)`, used regex-style path syntax that the NestJS swagger generator (@nestjs/swagger 11) rejects. The spec is built at boot, so that one error stopped the whole spec from being produced. The fix excluded only that route from the spec and kept the route live. Swagger's validator ran over all 213 routes across 27 controllers and flagged only that one. The full app was not booted in the session, so a deeper spec error could still be hidden. Rule: after a route change, fetch the generated spec from a booted app, not only the validator.
## BSD sed has no \s or \S escape: a pattern that matches nothing still exits 0
The macOS BSD sed does not support `\s` or `\S`. A refactor check that used `\s` to normalise whitespace before diffing before and after outputs gave a wrong diff until it was rewritten with POSIX classes. A scripted edit that used `\S` matched nothing, sed still exited 0, and the commit went in empty twice before a check caught it. Rule: on macOS write `[[:space:]]` and `[^[:space:]]`, test that a normalisation pass changes a known input before trusting a diff built on it, and read `git show --stat` before every commit a script makes, refusing an empty or unexpected diff. GNU sed accepts `\s`, so the same script can pass on Linux and fail here.
- The same class of failure in git grep: on macOS `git grep -E` did not honour `\b` as a word boundary, so a pattern such as `\bany\b` returned nothing and read as zero hits. The 2026-11-10 H10 audit caught it by a control run. Use `[^[:alnum:]_]` boundaries or fixed strings, and run a known-positive control before trusting a zero. In the same session zsh refused unquoted --include globs, so quote them.
## psql -c does not interpolate -v variables; send the SQL on stdin instead
2026-11-07: a check passed SQL to `psql -c` with `-v` variables, and the `:name` references were not replaced, so the query did not run as written. The session switched to feeding the same SQL on stdin, where psql's variable interpolation works. Rule: when a psql query depends on `-v` variables, pass the SQL on stdin or with `-f`, not `-c`, and confirm the variable's value appears in the result before trusting it.
## A jest ignore pattern can hide a new test file without any failure or warning
2026-11-07: a new test file was added to a TypeScript repo, and jest did not run it. The cause was an old exclusion pattern for `Api*.test.ts` in the jest config, which matched the new file as well. Nothing failed or warned; the suite passed with the new file silently absent. The fix excluded the file from that pattern and then confirmed it ran. Rule: after adding a test file, check that the runner lists it (`jest --listTests` or the verbose run output) before trusting a green count, and review ignore patterns when a new file is missing.
- The default jest config excludes integration specs, so a bare `npx jest` runs none of them and reports a green result that reads as a pass. A 2026-11-10 protocol session caught it because the match count was zero. Run integration specs with `--config ./test/jest-integration.config.js` and confirm the listed count is non-zero before trusting the run. The same class of trap appears whenever a new test file is added: check the runner lists it before trusting a green count.
## A whole-second sleep in a tmux poll loop costs about a second on every send
On 2026-11-07 a poll loop that waits on a tmux send was written in whole seconds. Every send across the fleet then cost at least one second. The measured send latency was 1027 ms. After the loop was changed to poll in tenths of a second (sleep 0.1), the same send took 125 ms. Rule: when a loop waits on a short local event, poll in fractions of a second and measure per-call latency before and after the change. Why: a one-second floor looks harmless on one call but multiplies across every send a lane makes.
## npx can run a tsc from another package; call the repo's own tsc binary
On 2026-11-07 a type check run through `npx tsc` reported an error that the project's build did not reproduce. The npx call had resolved a tsc from a different package than the repo's own compiler, so the error was false and cost a debugging round. Rule: when a type error does not reproduce in the project's build, confirm which compiler ran (`npx tsc --version` against the project's own `node_modules/.bin/tsc`) and run the repo's own binary before reading the error as real. Why: the wrong binary produces errors that look real, so verify the binary before debugging the code.
## A test run in a copied sandbox can fail only because sibling files are missing
On 2026-11-07 two sessions ran tests in a copied sandbox and first read the failures as their own change's fault. One saw two keyboard-input tests fail in the copy and pass in the real tree; the copy lacked a sibling data file. The other saw a new test go red; with its sibling files linked, the baseline passed 25 of 25. Rule: before reading red in a copied tree, run the same tests in the real tree or diff the copy's file list against it, and count a failure that depends on a missing sibling as a sandbox artifact. Why: the copy changes the inputs, so a red result there says nothing about the change until the baseline is checked.
## A fixed-time replay schedule turns a GC pause into an overlap between turns
2026-11-07: a replayParity failure under stalls traced to a schedule that fired each recorded utterance at a fixed time. A GC pause stretched one utterance; the next turn began while it was still running, and the follow-up planner call was lost. Gating each turn on the previous utterance finishing, while keeping the recorded gap, passed 20 of 20 with goldens unchanged. The fixed-time model had failed 10 of 20 under stalls, so the completion gate was the fix. Scaling the gaps was needed to keep one control fixture green.
## A Node version can crash inside its GC that another version passes
2026-11-07: an eventing suite crashed with SIGSEGV inside Node v24.11.0's garbage collector under `--stress-compaction` (3 of 15 runs). Node v22.14.0 and v24.22.2 showed 0 of 15. Six burners on 8 cores gave 0 crashes in 20 runs; 12 burners plus the stress flag were needed to reproduce. Lesson: when the crash is inside the runtime, compare runtime versions before debugging the test code.
## Two dev servers on copies of one repo corrupt a shared build cache
2026-11-07: two Vite dev servers started on copies of the same repo failed; the launched instances kept their ports while corrupting the build cache the copies shared. Serving the built output as a static SPA with fallback removed the contention and let both copies be checked. Rule: one dev server per shared build cache; a second copy is checked against a built artifact.
## A cache client on its defaults hangs every request when its backend is killed
2026-11-07, a page-snippet cache benchmark: with node-redis on its defaults, killing Redis left 99.8% of page requests hanging until the harness's 10 s cap, while the API itself stayed healthy. The client sets no per-command deadline, so a dead dependency reads as a slow request, not an error. A per-operation deadline of 50 ms brought p50 to 3 ms with no lost enrichment. Rule: give every cache call an explicit deadline and treat a timeout as a miss, so the request path never waits on the cache.
## An in-process Map used as a cache has no entry limit and grows the pod heap
2026-11-07, a page-snippet cache benchmark: the in-process Map used as the cache had no entry limit. Driving 5,000 distinct paths took 156 MB of heap in one pod, and every pod holds its own copy. Rule: a cache keyed by a request-derived value (path, query, host) needs a size cap and an eviction policy before it ships. Measure it with distinct keys, because repeated keys keep the map small and hide the growth.
## A test-named npm script can send real email; read it before running it
2026-11-07, a web app: the test:email:templates npm script imported email files that no longer existed in the repo, which made two tsc errors look like a small import fix. Repointing the imports to the real services only swapped one error for another (a ConfigService mismatch). The script sends real email when run, so a test-named command is not a dry run. Read its send calls and credentials first, and check it by typecheck instead of execution.
## `pmset -g thermlog` never exits, and a backgrounded job can pin a core
On 2026-11-07 a Mac ran hot during a burn-day session. The agent ran `pmset -g thermlog` to read thermal state. It streams output indefinitely and never returns, so it runs until something kills it. A backgrounded `du -sh ~/dev` started in the same session held about 39% of a core while it ran. The agent found both with `ps` and killed only its own leftovers. Rule: bound `pmset -g thermlog` with a timeout, and check `ps` for your own background jobs before reading a load as the machine's own load. Measured in one session; the streaming behaviour is the part that matters.
## A Python 3.14 venv has no working ensurepip: build the venv from python3.12
On 2026-11-07 creating a venv with Python 3.14 failed. `ensurepip --upgrade --default-pip` exited with status 1, so the venv had no pip. Homebrew's `/opt/homebrew/bin/python3.12` built a working venv and was used for the rest of the session. Rule: when a venv creation reports an ensurepip failure under Python 3.14, rebuild the venv from `/opt/homebrew/bin/python3.12` instead of debugging ensurepip. The error text was `Command '[... venv/bin/python3.14', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1`.
## On macOS, RSS can name nothing when swap is the problem; sort by compressed memory
On 2026-11-07 a Mac showed swap at 23.6 GB used of 24.5 GB and the cause could not be attributed. Sorting processes by RSS named nothing useful, because swap was larger than the resident memory it was trying to explain. Sorting by compressed memory identified the swapping process, an embedding run that peaked near 11 GB. Rule: when swap exceeds resident memory, attribute by compressed memory, not RSS. Ask the owning session to shrink the job rather than killing it from another session.
## An until-loop whose test zsh rejects never exits, so a background wait spins unnoticed
2026-11-08, a session backgrounded a loop that waited for a usage reading after the weekly reset and then ran a proof. The loop test compared ISO timestamps with a string test that zsh rejected, so the condition never became true. The loop spun for about 8 hours until it was killed at 14:20Z, and the proof never launched. Rule: run the wait condition once in the same shell before backgrounding it, and make the loop fail loudly on a rejected test.
## A local build of a frontend can carry the live API URL: swap in a dead port first
During a click-test harness for a document-signing fix, the local build copied the production env.js, which pointed at the live API, and the local .env pointed at the live database. The agent did not trust the build to be a sandbox. Before any test click it swapped in an env.js that targets a dead port, and it kept the backfill dry run off the live database. After the swap both builds reached only the dead port. The rule: before a browser click or a dry run, read the built env file and the .env, confirm every API and database host is one you mean to touch, and point the build at a dead port if one is not. Greppable: env.js, .env, dead port.
## A mutation control proves nothing if its backup step failed: check cp before the sed
The check removed the NULL-as-draft clause from an UPDATE to confirm a spec would catch it. The first control run chained a backup cp with a sed. The cp failed, so the sed never ran, and the test result from that run meant nothing because the code under test was never mutated. The agent caught it only by noticing the failed cp in its own output and reran the control. The rule: a mutation control needs evidence that the mutation was applied, not only that the test ran. After a backup-then-edit step, check the cp exit status, or diff the edited file against the original, before reading the test result. Greppable: mutation control, cp, sed.
## A per-row subquery that re-parses to_tsquery ran 2h21m; precompute once, set-based
A keyword simulation counted term overlaps with a per-term subquery. Each row by term by query re-parsed to_tsquery, and the agent judged that it 'should finish soon' and waited. It ran 2h21m before being killed. The set-based rewrite computed each row's lexeme set once and counted overlaps with array operations; it ran in 0.1 s over all 135 prompts, so no sample was needed. The rule: a parse of a constant inside a correlated subquery repeats for every row. Hoist it into a CTE or a precomputed column, and time a small slice before estimating runtime. Greppable: to_tsquery, correlated subquery, psql -c.
## A test suite whose .env points at the live database fails like a code regression
2026-11-07 an integration suite failed every case right after an otherwise correct change. The cause was the target: the repo's .env set the database URL to the live production database, and the suite's guard refused to run against it. Pointing the suite at a local Postgres through the environment (DB_URL set on the command line) let the same change run. Rule: when a whole suite fails at once, first check which database and environment it resolved, before reading the failures as code. A guard that refuses production is working; the fix is the target, not the guard.
## pmset -c covers AC power only; on battery the machine still sleeps
2026-11-07 a Mac-hosted service was down for about 13.5 hours and both outages happened on battery. The proposed fix was `pmset -c sleep 0`. The `-c` flag applies only to charger (AC) power, so the setting would have changed nothing for the outages that happened, and it was rejected. Rule: a power setting is per profile. Read `pmset -g custom` to see the battery and charger profiles separately, and test a sleep change on battery before trusting it. A setting that reads correctly for one power source is not proof the machine stays awake.
## A macOS Full Disk Access block is per app: one container refuses while others read
On 2026-11-09 a scheduled ingest of the Voice Memos container failed with `ls: ~/Library/Group Containers/group.com.apple.VoiceMemos.shared/: Operation not permitted`. The same run listed 137 other group containers without error, so the directory tree was readable and the refusal was specific to that container. The cause was that the process doing the read had no macOS Full Disk Access grant, and that grant is per app. The ingest logged a no-op on each run while the grant was missing. Rule: when one protected container refuses while sibling containers list fine, read it as a per-app privacy grant, not a path or ownership fault. Check Full Disk Access for the process that actually performs the read.
## A transpile-only runner drops decorator metadata; boot with the compiler the deploy uses
Booting a decorator-based Node/TypeScript backend locally with `ts-node --transpile-only` dropped the decorator type metadata that dependency injection relies on, so the wiring misbehaved while the classes themselves were fine. The real build uses a type-checking compiler (tspc) that emits that metadata. Two sessions (2026-11-09 and 2026-11-10) each abandoned the fast runner, compiled with the deploy's compiler into a scratch directory and ran from there, leaving the shared dist folder alone. Rule: when a decorator-driven container misbehaves only under a transpile-only boot, switch to the compiler the deploy uses before debugging the classes, and never build into a directory another session reads.
## A month-prefix grep matches any row that mentions the month, not only the date column
2026-11-10, a crawl pass filtered its source list with `grep 2026-11`, meant to keep only the rows sourced this month. The pattern matched any line containing the string, including names and notes that mention 11-09 dates, so the pass selected 856 sites instead of the 17 intended. About 15 minutes of crawl were wasted. Rule: anchor a date filter to the column that holds the date (for example with awk on the date field, or a regex on that field only) and print the match count before running the expensive step.
## A wrapper that accepts an effort flag and drops it silently runs every result at default
A harness provider for the claude CLI wired only effort=off. The values low, medium and high were accepted and never reached the child command, so every call ran at the default, and earlier results that claimed an effort level were default-effort runs (2026-11-10). Fix: pass --effort through and rebuild the binary. Rule: after adding a knob to a wrapper, confirm the flag reaches the child argv (dry-run and print it), and re-label every result produced before the fix.
## A heredoc whose body contains its own terminator word ends early and the rest runs nothing
2026-11-09: a heredoc with terminator EOF wrapped a Python program that itself contained the string EOF. The terminator matched the line inside the Python string, the heredoc ended there, and the remaining code ran nothing and reported no error. Fix: re-run with a terminator that cannot occur in the payload (a unique token), and check the payload for the terminator before running it. Quoting the delimiter does not stop this, because termination matches the whole line.
## Integration tests that load the repo-root .env can reach the production database
2026-11-10, a protocol collector-retire integration run. The repo-root .env points at the production database, and the integration test read it. The jest guard refused the remote connection, so nothing was written, and the run was repeated with DB_URL set to a local Postgres. The same mechanism came up again in a later session: booting the full application module in a test reads the root .env and reaches production, so that session stripped the production keys before the module boots. Rule: in any test that boots the app, set the connection string explicitly, and have a guard assert the host is localhost before any write.
- 2026-11-09: the root `.env` also reaches production through the dev runner, not only tests. In one backend `pnpm dev` runs migrations against the database named in `.env`, which was production. It was harmless only by luck: validation failed before applying anything because production had a migration number (V101) absent from the local checkout. The agent ran the backend against a local database instead. Rule: before the first `pnpm dev` in a repo, read where `.env` points and override the database URL explicitly.
## A migrate script's config file can point at the remote database, not the local one
2026-11-10, protocol. The repo's migrate script reads a Flyway config file that targets a remote database; a later session confirmed it was the remote dev database. Running the script to prepare a local test database would have migrated the wrong target. The sessions instead ran Flyway directly against local or scratch databases using a local config. Rule: before running any migrate script, read the config it names and confirm the host is local, use a local-config override for scratch work, and check the database name in the output before trusting it.
## A standalone Jest spec that imports a service fails on an ESM-only dependency graph
A unit spec that imports a service module can pull in an agent-framework graph that ships as ESM only, and Jest fails before any test runs. It happened twice in one week on one backend: a timer case added to one spec had to move into another spec, and a controller import chain needed jest mocks for the same reason. The graph is not visible from the file under test, so the failure looks unrelated to the change. Fix: mock the module that reaches the ESM graph in unit specs, or put the case in an integration spec that already boots the app.
## Integration specs on a shared local database are drained by any live backend
A review-queue spec failed because the queue claim is global: a backend another session had left running on the same local database claimed the rows first, so the spec saw nothing to review. It read as a regression in the change under test. Searching the suite for other claimers found none, so the claimer was a live process outside jest. Local fix: gate the review worker behind an environment flag in local runs, so a plain local backend does not drain the shared queue. A running server keeps draining until it restarts, so restart it before re-running the spec.
## Prove a replica change per pod with port-forward, because ingress can route to either pod
Through the ingress a request can land on either replica, so a probe through the public path does not tell you which pod answered. A websocket stays on one pod for its life, so the same client can reach different pods over time. The check that held was to port-forward to each pod directly, send the same request to each, and read the image or build id on each. Measured: prod accepted polling on both paths (HTTP 200) before the change, and that baseline only became attributable once each pod was checked directly.
## Playwright's default baseURL is localhost:3000, which can be another project's dev server
On 2026-11-10 a protocol frontend Playwright run targeted localhost:3000 because that is Playwright's default baseURL. On that machine :3000 was another project's vite dev server, so four sidebar tests failed with 'element not found' and read as app regressions. Pin the target before reading any result: set PLAYWRIGHT_BASE_URL or baseURL to the app under test, and confirm which process answers the port before the run. A pass or fail against the wrong frontend says nothing about the change.
## A root .env loaded by the test runner can pin a URL that canonical-host specs assert on
On 2026-11-10 an integration suite failed 10 of 38 tests, each asserting the canonical host. The failures returned localhost:3099 where the production hostname was expected, and the suite passed 38/38 on a clean export of the prior commit. Cause: the root .env set FRONTEND_URL=http://localhost:3099, and the URL helper read it whenever that file loaded. The failure was environmental, not a regression. Pin the variable inside the spec or clear it in test setup so the assertion does not depend on which dotenv file loaded. Confirm on a clean tree before blaming the change.
## awk $NF returns the last word of a line, which is not the path when the line has spaces
2026-11-11, a file list for a commit was built with an awk one-liner that printed $NF from a line of diff output. On a line ending in 'differ' (as in 'Files A and B differ'), $NF took the word 'differ' as the filename. The first H3 push therefore committed nothing but an empty commit, and the commit was redone. Take paths from git's own machine output, for example git diff --name-only, never from the last field of a human-readable line.
## Two jest runs sharing one tree produce timeouts that pass when rerun alone
2026-11-10, H4 raw-SQL conversion on the protocol backend. Two jest jobs ran in parallel and produced 13 timeout failures in hook and test code. None was caused by the code change. Rerunning the contended suites alone gave 43/43. A timeout that appears only under parallel load is a contention signal, so rerun the suite serially before attributing it to the change. Run one jest job at a time in a shared tree.
## A blanket replace rewrites every match, including ones you did not intend
2026-11-10, a fix across the backend specs: a blanket replace matched every 'throws NotFoundException' test, and the extra insertions had to be reverted. In another session the same kind of global replace rewrote a helper's own body, which then called itself without end, and was fixed by hand. Count the matches and read the diff before applying a blanket replace. A pattern that is correct once in a file can match in places you did not look.
## A fixture read at module load turns one bad case into a whole-suite error
2026-11-10, unit-failure triage on main. optimizer-metric reads its golden fixture when the module loads, so a problem with that fixture errors the whole suite instead of failing one test. The suite was missing from the '6 failed' count because it errored rather than failed. Read each suite's error line, not only the failure count, before concluding which suites are red. A count of failed tests can undercount a file that never ran.
## node-postgres returns COUNT and bigint as strings, so a numeric check silently fails
2026-11-10 bootstrap-include work: the frontend rendered a count of one as '1 calls', because the repository SQL sent the count back as text. node-postgres returns COUNT(*) and bigint columns to JavaScript as strings by default, so a strict comparison such as "1" === 1 is false and a template shows the string. The fix casts the counts to int in the repository SQL (landed in 7c0afb39), not in the UI. Check the type of every aggregate before comparing or formatting it in code.
## Calling socket.connect() while a socket.io client is still connecting drops subscribes
2026-11-10 realtime work (protocol #324 slice 5): the browser console logged CLOSING/CLOSED errors and prod showed 4 of 15 subscribe attempts dropping. Cause: the client's watch() called socket.connect() while the socket was still connecting. socket.io 4.8.1 resent connect, the server closed the connection, and each queued subscribe errored. The fix is client-side: do not call connect() on a socket that is already connecting. Measured: the regression test failed 2 of 4 on the old client and passed 4 of 4 on the fix; prod went from 4/15 drops to 15/15 clean. Node clients showed no drops in 60 runs, so reproduce in a browser.
## A green vue-tsc does not mean a shared package's tsup declaration build passes
2026-11-10 H10 any-removal: after explicit any sites were removed from frontend and shared, vue-tsc passed, but the shared package's tsup declaration (DTS) build rejected a `traverse` call that vue-tsc does not check. A type gate covering one consumer does not cover a bundler's declaration emit. Run the package's own build after type edits in a shared package, before pushing.
## A LIMIT applied before a per-viewer filter hides the viewer's own rows
2026-11-10 (#342, CommentService): a user's own comments disappeared once 200 other users had commented on the entry. The query applied LIMIT before the filter that keeps the filer's rows, so the page filled with other people's comments before the viewer's were considered. Apply the viewer filter in the WHERE clause, then LIMIT. Test with more other-user rows than the page size.
## On Homebrew Postgres the postgres role is not a superuser, so grants fail
2026-11-10 deprovision work: the test config fell back to the role name `postgres` when neither DB_USERNAME nor PGUSER was set. On this Homebrew Postgres 14 install that role is not a superuser and has no grants, so deprovision failed 15 of 15 times with a permission error on bootstrap_include. The first theory, a swallowed error in a SQL helper, was wrong. The fix resolves the user as PGUSER, then the OS user, as psql does. When a permission error appears, check the role the connection actually used before blaming a helper.
## A package that resolves only via the root node_modules hoist breaks the backend
2026-11-10: backend tests in a scratch export could not load @nestjs/mapped-types. It resolved only through the root node_modules hoist; backend/node_modules/@nestjs had no link to it. The session first treated it as a local install gap. The fix declares the dependency explicitly in the backend package and confirms the export resolves from backend/. Check that each import resolves from its own package directory, not only from the root.
## A method named in a condition without parentheses is always truthy
2026-11-10 (#341): the manage-controls gate tested me.isAdmin. isAdmin is a method on the user object, and a function reference is always truthy in a boolean test, so the control showed for every viewer. The fix gates on the UserService.isAdmin getter, and a render check as a non-owner confirms the control is hidden. The backend already gated the actions for owner, team admin and platform admin, and a round trip pins that. Prefer typed boolean properties, and lint for an uncalled method in a condition.
## A non-interactive shell ignores SIGINT for background jobs, so a run can exit 0
On 2026-11-10 a cleanup test was interrupted with SIGINT and exited 0, which read as a pass. A non-interactive shell ignores SIGINT for background jobs (started with `&`), so the signal never reached the script and the run proved nothing about cleanup. Retesting with SIGTERM showed the cleanup itself worked. Before reading exit 0 as a pass after an interrupt, confirm the interrupt arrived, for example with a line the trap writes.
## Scoped Vue styles do not reach a router link inside a child component
2026-11-10, extracting a panel section into a child Vue component. An open-link rule that worked in the parent stopped applying after extraction: scoped CSS in the parent does not reach a router-link rendered inside the child. The screenshot diff exposed it. The fix was to add the panel-open-link rule to the child's own scoped style instead of sharing the parent's rule. Rule: after moving markup into a child component, re-shoot and check every element the parent styled.
## A mechanical dedent rewrites the bytes inside multi-line template literals
2026-11-11, splitting a repository class into several files with a scripted move. The dedent meant to fix indentation also shifted the leading whitespace inside SQL template literals, which changes the bytes of the query text and so can change behaviour that the tests do not pin. The fix was to dedent only the lines outside backtick spans, so string bytes stay identical. The checker also gave false positives on lines already exact, while a backtick comment split across lines kept its old indent and was a real miss. Verify string literals byte for byte, not by eye.
## macOS seq with a zero bound counts down instead of running zero times
2026-11-11, a runner looped over the stage count as $(seq 1 N). For tasks with no stages N was 0, and on macOS `seq 1 0` counts down and emits 1 then 0 instead of nothing. Eight episodes crashed before grading and were rerun after the loop was rewritten as a C-style for loop. Rule: never pass seq a bound that can be zero or less. Write for ((i=0; i<N; i++)) or guard with (( N > 0 )), and test the zero-count case explicitly, since the bug is invisible on a task that has stages.
## `bun test src` is a name filter, not a directory: use ./src or it scans runs/
2026-11-11 and 11-12, a bare `bun test` at the repo root collected test files from a runs/ directory of fixture repos left by earlier task runs, and hung until killed. The first fix, `bun test src`, still failed with EMFILE: bun treats a bare `src` as a name filter and scans the whole tree, opening too many files. `bun test ./src` ran only the source tree and passed. Rule: in a repo with large data or fixture directories, pass an explicit ./ path to bun test, and when a suite fails only where those directories are large, check the path form before suspecting the tests.
## Bun's `for await` over a child stream can deliver nothing; read it with getReader()
2026-11-11, building a streaming monitor on the Bun runtime, a `for await` loop over a child's output delivered nothing and raised no error, so the monitor looked idle. Switching to `const reader = stream.getReader()` with an explicit `reader.read()` loop delivered the chunks. Rule: when a stream loop under Bun yields nothing, do not conclude the producer is silent. Count bytes from a reader loop first, and use getReader() for process streams. The switch fixed it in the session; the failing form was not re-run under identical conditions, so treat the cause as unconfirmed.
## Under `bun test`, a child can write nothing: use async spawn and a file target
2026-11-11, two separate cases under `bun test`. A child handed a raw file descriptor wrote nothing and exited 1 with no stderr, though the same child worked from a scratch directory; routing its output to a file the harness reads fixed it. In another test, Bun.spawnSync returned no subprocess output and raised no error, so the assertion on that output saw nothing; an async spawn produced it. Rule: inside bun test, collect child output through an async spawn or a file the test reads back, check the byte count before trusting a result, and treat missing output as a failure to investigate. The cause was not isolated.
## Bun resolves a spawned binary from its startup PATH, so a test's PATH fake never runs
2026-11-11, a test suite put a fake `claude` first on a PATH modified inside the test, and the fake never ran: Bun had resolved `claude` from the PATH it started with. The session added an environment override for the binary path so the test could point at the fake directly. Rule: when a test must control which binary a Bun process spawns, pass the path explicitly through an environment variable or argument, and have the fake write a marker file so the test can assert it was hit before trusting a pass.
## ts-jest can report a type error in untouched code until its cache is cleared
2026-11-10, after restoring code that a mutation run had changed, ts-jest kept reporting a type error in untouched code, while a full `tsc` run on the same tree reported none. Restoring the files did not help; clearing the jest cache did. Rule: when ts-jest and `tsc` disagree about code you have not edited, clear the jest cache before debugging the code, and treat the full `tsc` run as the answer to the type question. The stale cache entry was not identified.
## A process that cd's after a relative-path launch makes its stale-code check read BLIND
2026-11-11 a stale-code check flagged a watcher process as BLIND on two dispatches. The process was launched from its tools folder with a relative path, then changed into another folder. The checker resolved the script relative to the new folder, found nothing, and reported BLIND. The code was current. Rule: a process that changes directory after a relative launch cannot be resolved by path, so BLIND is the honest result. Launch long-running watchers with absolute paths, or the same false BLIND repeats on every run for the life of the process.
## A timed job with no overlap guard stacks copies when a run outlives its interval
2026-11-12 an automation launcher started a timed check every interval even while the previous run was still alive. Under load this stacked copies: the old launcher produced four overlapping copies of one check, and a must-fail control test failed three checks against it. The fix skips any timed job whose previous run is still alive and starts it on the first check after that run ends. Rule: a test that claims to block overlap needs a run against the pre-change code first, so you know it can fail. A concurrency guard is proven only when the old code fails the test.
## Overwriting a signed binary with cp on macOS SIGKILLs it at launch: remove it first
2026-11-12 a smoke run failed on its first episode after `cp` copied a new binary over the old file. The binary was SIGKILLed at launch (exit 137), and four episodes were void. The same machine killed a `/bin/sleep` copied into a test fixture at launch, and a session that copied a system binary hit the same fault. Rule: never overwrite a signed binary in place. Run `rm` on the target, then `cp`, or copy to a new name and `mv` it into place, which also replaces a binary that another process is running. Build test fixtures locally with `cc` rather than copying from /bin.
## DigitalOcean node-pool scale-down removes a node of its choosing unless named
On 2026-11-12 a session scaled a DigitalOcean (DOKS) node pool from 3 to 4 nodes for memory headroom, then had to return it to 3 after the operator pointed out the pool had been at 3, not 2. The scale-down did not remove the node it had added: DigitalOcean chooses which node to remove unless the command names one. The revert drained and deleted the new node by name. Before any node-pool scale-down, read the pool's node list, name the node in the removal, and check the pool's count against the operator's stated number first.
## Pause a launcher-supervised process with SIGSTOP; kill gets it restarted
On 2026-11-13 a session needed a collector daemon offline for a drill. The collector is supervised by the automation launcher, and a kill would be undone by a launcher restart. The session paused the process with SIGSTOP instead, and the launcher did not restart it; the backend lost its connection to it within about 70 seconds. Rule: use SIGSTOP to pause a supervised process for a test and SIGCONT to resume it. Use kill only when a restart is what you want.
## Bun spawn returns empty output when the test runs from the parent workspace directory
2026-11-12, a new test for an adapter failed on fixture runs. About 25 turns went into debugging (realpath, spawn, wrapper scripts) before the cause was found. Run from the parent workspace directory, bun's spawn returned nothing and the tests failed. Run from the directory the test was written for, the same tests passed. The fix was the working directory, not a code change. Rule: when a bun test that spawns a child process returns empty output, rerun it from the directory the test was written for before editing the code.
## A bare @Component decorator rejects an abstract base class; the options form accepts it
On 2026-11-11 a page's saved-view logic moved into an abstract base class that the page extends. The first attempt put the bare decorator form, @Component, on the abstract class, and type-checking rejected it. Passing a component base to the decorator was a dead end. The fix was the options form, @Component({ name }), which is typed to return any and so accepts an abstract class. Table dependencies were declared as abstract members so the base lists them in one place. Run vue-tsc right after adding the base class, not only after the subclass.
## A test timeout shorter than the child Python startup captures empty output
On 2026-11-10 a test expecting partial output from a timed-out child got an empty string. The test passed --timeout-s 0.1, shorter than the child Python startup of about 0.3 s, so the timeout fired before the child wrote its partial output. It looked like a capture bug and was a timing bug. Fix: the test now passes a 2.0 s timeout. The child still sleeps 10 s, so the capture still times out with partial output. A comment in the test records why 2.0 was chosen. Rule: when a timeout test sees empty output, compare the timeout with the child startup time before suspecting capture.
## A backup client's license transfer or inherit-state step can purge the old backup
On 2026-11-13 a laptop backup was being re-signed up after its old account lapsed. The backup client logged billing_canceled and had not run since 2026-08-12. The vendor's Transfer License step deletes the old backup, and its Inherit Backup State step purges any file that is missing from disk. The vendor documents no retention after a lapse, so recovery of deleted files was unlikely. Restore first, then run either step. Before restoring, check whether a known file is listed in the account's restore view, since that is the only proof the old backup still exists.
## Bun Subprocess.kill with a signal name sends the wrong signal number on macOS
2026-11-14, HX exit-row work: a wall-cap test sent SIGUSR2 through Bun's Subprocess.kill("SIGUSR2") and the lane died from the signal's default action. Bun sent signal number 12, which is SIGUSR2 on Linux but SIGSYS on macOS. Retrying the signal in the test did not fix it. Rule: on macOS send by name with process.kill(pid, "SIGUSR2"), which resolves the name against the OS table. Python os.kill with the name was not affected. Found after a timing-race explanation was tested and dropped.
## An unhandled promise rejection can exit 0, so an exit-code check passes
2026-11-14, HX exit-row fixtures: every failure path exited non-zero except one, an unhandled rejection, which exited 0. A fixture that checks only the exit code would pass a crash that was recorded as a clean end. Fix: attach an explicit unhandled-rejection handler that writes the reason row and sets a non-zero exit, rather than relying on the runtime default. Check the exit code of each failure mode in a fixture, one mode at a time, since one mode can pass while another is wrong.
## A nohup process that still holds the output pipes is killed when a tool block returns
2026-11-14, HX host-mode launch: a nohup ... & launch kept running after the block returned once the launcher detached it, but a background process that still held the block's output pipes was killed as before. Two rows from a multi-hour run died exactly when the block returned. nohup alone does not detach a process from the block's pipes. Rule: redirect stdout, stderr and stdin away from the pipes before backgrounding, and verify the worker survives by reading its pid after the return, not from the launch output.
## Piping a write's curl into head hides whether the row landed; a retry double-counts
2026-11-14: an intake impulse POST was piped into head. curl reported the error "43 returned 0" and the captured output was cut, so whether the row had landed was unknown. A correction row was then written and the intake was double-counted. Rule: do not pipe a write into head or tail. Save the response body and the status code to a file, read them back, and query for the row by its key before any re-POST. Re-posting to clear an unknown result is the write that creates the duplicate.
## An old dev server still holding a harness port serves the stale tree; kill it by PID
2026-11-13, H11 parity runs used ports 5621 (before) and 5622 (after). Old Vite servers from earlier sessions still held those ports and served a stale tree, so a server answering on a port did not show which code it was serving. The session found them, killed them by PID, and only then re-ran the capture. Rule: before any before/after capture, list the listeners on the harness ports and confirm each one's working directory is the tree being measured. A server that answers is not evidence of the code it serves.
## A tmux window index already in use makes a pane read hit another session's window
On 2026-11-14 a test read tmux window 1 to check a dispatch pane. Window 1 was already held by another session, so the read returned that session's pane and the test judged the wrong output. A window index is not a claim on a window; any other session can take it. Capture the pane's pid when the window is created and read that pid, not the index. The first version of the test was abandoned for this reason. Confirm which pane a read actually hit before trusting its result.
## A base64 upload holds the whole file in pod memory: stream it in parts
2026-11-14: an upload path base64-encoded the whole file in memory. The pod memory limit was 768 Mi and live pods ran at 192 to 264 Mi, so one large file could push a pod toward its limit. The fix streams downloads straight from object storage and uploads in 8 MB parts, two at a time, which caps memory near 16 MB. Measured on a 1 GB throttled download: memory rose by at most 64 MB, the hash matched, and a client disconnect at 10% stopped the storage read. Check a large transfer against the pod's limit before shipping any path that buffers whole files.
## An ingress body-size cap rejects large uploads before the API sees them
2026-11-14: the backend's deploy manifest set the ingress annotation proxy-body-size to 10m, so any upload over 10 MB was rejected at the ingress before it reached the API. The app's own request limit was also 10 MB. Raising the limit is a manifest edit, not an app change. When a large upload fails and the API logs no request, read the ingress annotations before debugging the handler, and raise the ingress and app limits together.
## Body parsers drop AsyncLocalStorage context: mount the scope middleware after them
2026-11-14: a scope middleware registered before the body parsers lost its AsyncLocalStorage context by the time the route handler ran, because the parsers break the async context chain. The middleware must be registered after them. Found while wiring a per-token scope into a Node backend. Check any ALS-backed request context on requests that carry a JSON body, not only on GET requests, since GETs never exercise the parser.
## A scripted replacement that adds an inline comment can swallow the rest of the line
2026-11-14, a multi-file refactor in a TypeScript repo: a scripted Python replacement added an inline comment to a source file, and the comment swallowed the code that followed it on the same line. The file looked right in the edit summary. Rule: after any scripted edit, read the changed lines back before running the suite, and put an inserted comment on its own line, never mid-line.
## A bun-compiled binary cannot run bun wrapper scripts: add a self-dispatch subcommand
2026-11-14: after a CLI was compiled with bun, the wrappers that ran bun-based shims stopped working, because the shim source file is not available inside the compiled binary. The fix added a hidden internal subcommand (cli shim <cmd>) and the wrappers call the executable itself. Only macOS was checked; the Linux branch of the stat call was not tested. Rule: when a compiled binary's own wrappers call back into it, route those calls through an internal subcommand instead of a separate script.
## A CLI's confirmation line on stdout breaks any test that parses the output as JSON
Measured 2026-11-15 on a shell tool that files a record and prints its id. An extra CREATED line written to stdout failed the test suite, because the tests parse the command's normal output as JSON. The fix moved the line to stderr, so stdout stays the machine-readable result. Rule: a human-readable confirmation goes to stderr. Before adding any line to a script's stdout, grep for the tests and callers that parse that output.
## A prefilter that cuts each JSONL line to 400 characters misses keys further in
2026-11-15: a join of corrections to lane transcripts prefiltered each JSONL line to its first 400 characters, then matched assistant turns on a top-level type key. On assistant lines that key sits past character 1,300, so the prefilter kept 2,041 matches of which only 237 had a prior assistant turn. Reading a raw line caught it; parsing each line as JSON and checking the parsed type, then rerunning, gave 2,031 of 2,200 replayable corrections. Rule: a fixed-width cut is not a field filter, because key position depends on the writer. Parse before filtering, and check the match count against an independent total.
## In zsh, `$C:r` reads as a modifier and mangles a git refspec; use `${C}`
On 2026-11-13 a push of `git push origin $C:refs/heads/main` was rejected, and the first explanation was a race with another session's push. The real cause was zsh: `$C:r` parses as the `:r` modifier, which strips an extension from the expanded value, so the refspec was garbled, and a second attempt failed on the same quirk. Write the variable in braces, `"${C}:refs/heads/main"`, and echo the built refspec before pushing. A rejected push can be a shell bug as well as a remote race.
## A test that fakes one API call but not the boot path still hits the live service
On 2026-11-15 a fleet watcher test swapped a fake in for one protocol.supply call but not for the call inside the boot script it runs, so every run read the live session list from the live service, and two copies of the test ran at the same time. Rule: before trusting a test that stubs a service, grep the test's full boot path for every call to that host, and count live requests during a dry run.
## Editing source while jest runs corrupts the run, because jest compiles files as it goes
On 2026-11-15, a backend suite was running when the next slice's patch was ready. Jest compiles each source file when a test that imports it runs, so an edit made mid-run lands in some tests and not others, and the result describes neither tree. The session staged the patch as a script and applied it only after the suite exited. Rule: keep the source tree still until the run exits, and stage changes elsewhere. A run that spans an edit must be rerun before its result counts.
## A filtered jest run skips setup hooks, so its database state differs from the full file
On 2026-11-15, a name-filtered run of an integration spec gave a database state that did not match the full file. The filter skipped the file's setup, so the rows later tests expected were never written, and the diagnosis built on that run was wrong. Rerunning the whole file, with the debug line added, gave the true state. Rule: when a database-backed spec gives an unexpected result, rerun the whole file before reading it as a product bug. A name filter drops setup that other tests depend on.
## A wait loop keyed on a log file exits on the previous attempt's last line
On 2026-11-15, a wait loop released when a gate log showed its pass line. The log still held the line from a failed first attempt, so the loop exited at once, before the new calibration had started. The session caught it because the new run was still waiting at its launch gate. Rule: key the wait on a line written after a marker created at launch, or on the run's pid and exit code, and rename the old log before each new attempt.
## A prebuilt CLI binary can predate its source, so a measurement runs the old code
On 2026-11-15, an A/B runner was set to call a prebuilt CLI binary. The binary's build predated the flag the test needed (`calls=multi`), so the runner would have measured old code. A smoke result from the same binary had already been reported as no regression; it measured the pre-rebuild code and counts for nothing. Rule: compare the binary's build revision with the source before any measurement, rebuild from HEAD into a pinned path, and do not swap the binary under runs in flight.
## Playwright render fails without its bundled browser: point CHROME_PATH at an installed one
2026-11-17 and 2026-11-20: a node render script (`chromium.launch()` then `page.screenshot`) that turns an HTML canvas into a PNG infographic failed because Playwright's own bundled browser was not installed on the machine. The fix both times was to launch with an explicit executable: `chromium.launch(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {})`, and run it with `CHROME_PATH` set to an installed `chromium_headless_shell-*` (or system Chrome) binary. Do not run `npx playwright install` for a one-off render. Record the `CHROME_PATH` requirement in the script's README so the next session does not rediscover it.
## Generate a public script from the private source with a builder that fails on drift
2026-11-17: a hand-ported public copy of a script had drifted from its private source, and stripping private lines failed because the sourced libraries were entangled with the private tree. The fix was a builder that generates the public script from the private source and fails the build when a constant it inlines (a regex table) differs from the private file it mirrors, plus a daily drift check on the published hashes; install checksums had been stale for 3 of 5 files. Builder traps found: a whole-block comment drop removed the usage header, a lint marker leaked into public output, and the test suites passed only when run strictly in series. A cold-reader install test needs a temp HOME, but a keychain login does not survive it (pass the token via env), and the real `~/.local/bin` on PATH leaks in.
## A DB jest suite failing every spec at once is a beforeAll timeout under load
2026-10-31, a session verifying a shipped route saw a DB-backed spec file fail 20 of 20 tests while the unit specs passed. All 20 failures were one cause: the `beforeAll` hook (DB setup) hit jest's 5s default timeout while the box was under load (load average about 40). The test DB existed and was migrated; no code was at fault. A first unit run also hung about 7 minutes with no output; killing it and rerunning with watchman off and an explicit timeout completed. Rerunning the DB spec with the hook timeout raised to 120s passed 20/20. Rule: when every test in a DB suite fails together, read the first error for 'Exceeded timeout of 5000 ms for a hook' before suspecting the change; check load, raise the hook timeout for the rerun instead of editing code, and wrap hung runs in a timeout.
## A test of a stateful script writes the live state file unless its path is pinned
Two cases. 2026-10-31: running the test for a monitor-arming check would have written the running monitor's live state file, polluting real alerting state; a live dedupe-check run likewise saved its cache, so a dry run of a cache-backed checker is not read-only. 2026-11-16: tests for a claim script wrote fake records into the real claim and revive-state files in the home directory, and a claim-race test left about 10 cards in the live work queue. Fix: have the script read its state path from an env var, set it to a mktemp path (or a scratch HOME) before the first test, and assert the live file's mtime is unchanged after the suite. Before running any script to test it, check what it persists and where, and clean up records a race test creates.
## A directory mtime does not move when a file inside is appended: mtime skips miss lines
2026-11-15: a collector spent most of its time statting ~24k transcript files per pass. The proposed shortcut was to skip directories whose mtime had not changed since the last pass. It was rejected: a directory's mtime changes only when entries are added, removed or renamed, not when an existing file is appended to, so new lines in existing files would be missed silently. Statting all ~24.3k files cost only 0.4-0.8 s, so the saving was small anyway. The fix that worked was a per-file byte offset: read only the appended bytes (129 MB read down to 1.77 MB, 98.6% less). Rule: for append-only logs, track offset or size per file; use directory mtime only to discover new files. Measure files stat'd and bytes read per pass before and after.
## Sync work in one source starves child spawns in a parallel collector: run spawners first
2026-11-15: in a Node collector that ran sources in parallel, a git-walking source took 10-17 s in the full pass but was fast alone. Another source did about 4 s of synchronous work, which blocks the event loop and starves the filesystem walk and child-process spawns of the others. Timing the slow source alone looked fine; the blocking showed only in the full parallel pass. Fix: run the spawn-heavy sources first and together, before the sync-heavy one (the git source dropped to 0.6 s). A COLLECT_ONLY=a,b switch to time chosen sources in isolation, without writing output, made the diagnosis possible. Cite timing ranges under load, not single runs (one source varied 31-84 s).
## Pod priority does not protect a pod with an understated memory request from the OOM killer
2026-10-31: a read-only audit of a small managed cluster (nodes over-committed on memory limits, one node at about 500% of memory in limits) found honest memory requests would total 7.4 GiB against 5.9 GiB allocatable. Pod priority governs scheduling and preemption, but when a node runs out of memory the kernel OOM killer ranks by QoS class and usage against request, not by PriorityClass. So the ingress controller, requesting 90Mi, was an early OOM target despite the top priority. Rule: priority tiers help only when requests are honest; set critical pods to Guaranteed QoS (requests equal limits), add a PodDisruptionBudget, and rank workloads by 7-day p99 memory from the metrics store, not one snapshot. Priority cannot create capacity; the shortfall needs a node or lower limits. Verify with read-only kubectl and client-side dry runs before any apply.
## Two scripts refilling an expired shared cache both page the full source: add a lock
2026-11-16: two scripts started by one driver each paged a 23-page API list after a shared on-disk cache expired, so the call log showed 46 calls where 23 were needed. Neither script was wrong alone; the race was between them. Fix: a cross-process lock in the cache helper. The second reader waits on the lock, then takes the holder's fresh copy at 0 calls. Replay result: the control reproduced 46 calls, a warm pass made 2. Verify by counting calls in a per-call log under a cold cache, not by reading the code, and check sibling cache functions for the same missing lock (one was still unlocked).
## A backup script that stops on a harmless exit-code-2 warning never reaches its last step
2026-11-15: an offsite transcript backup script copied the session tree to object storage and then, as its final step, the prompt-history file. Its sync step returned exit code 2, a warning (not a failure), and the script stopped there, so the history file, the only remaining record of lost sessions, had never reached the bucket. Nothing errored visibly; the missing step was only found by comparing what was in the bucket with what the script claimed to cover. Fix: treat the warning code as success explicitly (accept rc 0 and 2, fail on anything else), so later steps run. The first history copy was then uploaded and matched the local file by hash. Rule: for any multi-step backup, list the bucket after a run and check the last step's output exists; do not infer it from the script exiting. Verify with hashes, not sizes (205 large objects had only been size-checked).
## A raw SELECT in an admin search bypasses the ORM's @Exclude() and leaks password hashes
2026-11-09: while porting an admin Users page, an agent found a production admin user search that ran `SELECT *` through the query builder and returned raw rows. The entity's `@Exclude()` on the password column applies only to serialised entity instances, so it never ran: 6 of 15 production rows carried a password hash to the browser. Fix: the search lists its columns and computes derived fields (an admin flag) on the server. After the CI deploy the API was re-read until no `password` key remained; the first poll still showed the old code, so confirm the deploy rolled before calling it fixed. A sibling endpoint allowed sorting by the password column and now rejects it with 400. Rule: never return raw rows from an admin endpoint; select named columns, whitelist sort keys, and check the live response for credential fields.
## jq: `//` swallows false, and `-r .content > file` adds a newline
**Symptom:** `jq '.x // "default"'` returns the default for an unchecked box, because `//` fires on `false` as well as `null`. And `jq -r '.content' > file` appends one trailing newline the stored string lacks, so a length baseline taken from the file is off by one.
**Fix:** read booleans with `(.x|tostring)` or `has("x")`. Measure lengths from the JSON value (`jq '.content|length'`), not the file.
## $TMPDIR is shared by every session on the box: a generic payload filename gets someone else's payload
Every Claude Code session run by the same macOS user gets the same `$TMPDIR` (`/var/folders/<xx>/<hash>/T/`). Two sessions that both write `$TMPDIR/imp.json` (or `payload.json`, `patch.json`) race: whichever wrote last wins, and the other posts the wrong content with no error.
**Observed 2026-11-24:** one session wrote its impulse payload to `$TMPDIR/imp.json`, another session wrote its own payload to the same path seconds later, and the first session's create call posted the second session's card. Nothing failed; only the returned title gave it away.
**Rule:** write payload files to the session scratchpad (a per-session directory) or to `mktemp`, never to a fixed name under `$TMPDIR`. After any create, read back the title of the id that came back before you use the id anywhere.
## tmux: $TMUX overrides TMUX_TMPDIR, so a "scratch" kill-server kills the live server
**Symptom:** every tmux pane on the box dies at once. On 2026-11-29 at 19:14Z the ticker-refresh u0 test runner ran its cleanup, `TMUX_TMPDIR=<scratch> tmux kill-server`, from inside a tmux pane, and the whole fleet went down.
**Tell:** `TMUX_TMPDIR=/some/scratch tmux ls` run from inside tmux lists your live sessions. tmux uses the socket named in `$TMUX` before it looks at `TMUX_TMPDIR`.
**Fix:** never point tmux at a server through env alone. Use an explicit socket and unset the caller's: `env -u TMUX -u TMUX_PANE tmux -S <scratch-socket> kill-server`. Or give it its own name with `-L <name>` after `unset TMUX TMUX_PANE`. For test harnesses, put a shim dir first on PATH whose `tmux` forces `-L <private>` and refuses `-L`/`-S` from the caller. Prove it with a canary that runs `kill-server`, then diff `tmux ls` on the live default socket. Keep socket dirs short: a unix socket path over about 104 bytes fails to bind, and the macOS `$TMPDIR` alone is about 50. Reference build: `~/workspace/ticker-next/tests/harness/seal.sh` and `tests/run --canary`.
---
*Related: `@protocol/verification-tactics` · `@protocol/protocol-api-write-traps` · `@protocol/silent-signal-and-evidence-traps` · `@content/web/huggingface/2026-11-23-cua-see-self-evolving-evals` · `@content/youtube/tiago-forte/i-connected-claude-to-everything-then-i-saw-the-gap`*
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*