headroom-desktop
CLAUDE.md589 starsChanged 59 days agoMITView on GitHub
This file holds only what the model cannot derive: project invariants, environment quirks, and concrete commands. Generic coding-style coaching (write simply, read before editing, state the bug and stop) was removed on 2026-08-03 — modern models do it unprompted and the harness enforces the rest. Do not re-add it.
- Installs packages
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 9
After any code change, run the relevant tests/checks before declaring the task done.
- Distinctive: line 12
If a test cannot be run in this environment, say so explicitly rather than skipping silently.
- Very specific: line 30
Every entry in src-tauri/python/*.lock carries --hash lines, so pip runs in hash-checking mode.
- Distinctive: line 54
Never kill a pid resolved from a port without verifying its identity (argv/process name) first.
- Distinctive: line 58
No em dashes, smart quotes, or decorative Unicode.
- Very specific: line 61
Never hardcode colors in component CSS.
- Very specific: line 62
If a needed color does not exist as a token, add it to both the :root block and the @media (prefers-color-scheme: dark) override — do not …
- Distinctive: line 64
When adding or modifying a component, visually verify both light and dark mode before declaring done.
- Very specific: line 65
Run npm run check:colors (or ./scripts/check-colors.sh) on any CSS you touch.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md - headroom-desktop
This file holds only what the model cannot derive: project invariants, environment quirks, and concrete commands. Generic coding-style coaching (write simply, read before editing, state the bug and stop) was removed on 2026-08-03 — modern models do it unprompted and the harness enforces the rest. Do not re-add it.
Testing Rules
- After any code change, run the relevant tests/checks before declaring the task done. Do not ask the user to verify.
- Rust changes:
cargo test --manifest-path src-tauri/Cargo.toml --lib <filter>for the affected module, pluscargo check --manifest-path src-tauri/Cargo.tomlif the change crosses module boundaries. - Frontend changes:
npx tsc --noEmitand any relevant Vitest suite. For visual changes, see Styling Rules. - If a test cannot be run in this environment, say so explicitly rather than skipping silently.
Wheel Bump Rules
- Before changing
HEADROOM_PINNED_VERSION: diff upstreamsavings_tracker.py,prometheus_metrics.py, andserver.pybetween the old and new pins, and check every consumed field againststats_contract_pins_every_consumed_pathin state.rs. Upstream has silently redefined persisted savings fields before (0.36.0 widenedcompression_savings_usd); the savings-rate canary in state.rs is the runtime tripwire, this diff is the compile-time one. - Re-pick every platform's wheel URL/sha256 when bumping (see the pin comment in tool_manager.rs).
- Diff
rollout.py's FEATURES registry between the old and new pins. The app declaresHEADROOM_ROLLOUT_CHANNEL=beta(tool_manager.rs), so any new feature withdefault_enabled_inat or below beta auto-enables for every user on the bump; any feature the app requests whoseavailable_inmoved above beta silently turns off (this is how 0.37.0 disabled the output shaper on stable). - Diff
ProxyConfig(proxy/models.py) andcli/proxy.pydefaults between the pins, and grep the handler diffs for new early 4xx/429 returns. A "fix" that starts ENFORCING a config value nobody felt before is a default-behaviour change the FEATURES diff, the vendor checks and the/statsdiff all miss: 0.39.0's #3350 began consuming a 100k TPM bucket that caps at its own rate, so every request over 100k input tokens got a permanent 429 ("Token rate limited. Retry after Ns") and every long 1M-context session bricked on rc7/rc8. The desktop now passes--no-rate-limit(rc9); upstream fix is PR #3806. - Diff
headroom/transforms/between the pins. This is the compression ENGINE and nothing else in these rules covers it; the 0.35.0 -> 0.37.0 bump changed it by +421 lines and shipped unexamined. Diff it, but do NOT assume a diff means a behaviour change. Bisected 2026-09-02 with a fixed workload replayed on both wheels installed from PyPI (uv venv+uv pip install headroom-ai==<v>, about 3s per version):ContentRouter.compress()AND the fullContentRouter.apply()path returned BYTE-IDENTICAL output on 0.35.0 and 0.37.0 (tok_before 62,384 -> tok_after 57,068, identical transforms list, on both). The engine is EXONERATED. The real production drop (fable-5 500k+: 4.64% / 25,631 tokens per request down to 0.45% / 2,463 at matched model and size) is therefore caused by the INPUT reaching the compressor, not the compressor. Six hypotheses are refuted and must not be restated as fact: the prefix-replay guard (identical on full-replay and floor builds), workload/model mix (matched), the TTL-aware net-cost gate (flag-gated behindHEADROOM_NET_COST_POLICY=1, not set, zeronetcost:skipmarkers across 925 requests), protection rate (0.35 vs 0.32 per request), router acceptance thresholds (min_ratio_*identical), and content granularity (today's messages are BIGGER, 3,053 vs 1,982 tok/msg, which should compress better). What the router logs do show: more messages compressed per request (4.0 -> 5.1) each yielding far less, at an unchanged frozen fraction (86.8% -> 85.2%). Investigate session shape next, not the wheel. - The pin is
0.39.0(2026-09-26). That wheel shipped seven vendors the 0.38.0 sitecustomize carried, each deleted, not re-pinned: request-log body window (RequestLogger.MESSAGE_WINDOW), Kompress request deadline #3693 (shares_request_deadline), feed?include_messages=0#3672 (the native feed also carries the per-request uncached/cache_write splitmodels.rsreads), rollup cache-read cost #3734 (_empty_cache_delta), streaming metering headers #3769, Codex exec JS-literal reads #3737, and the client-side tool-search repair (strip_unsupported_tool_search_blocksnow has a client-sidetool_resultpass that keeps deferred-but-present refs, so no rc.5 regression).sitecustomize_drops_vendors_the_wheel_shipsfails if any of these, or the nine 0.38.0 dropped (#3380 prefix floor, #3414, #3480, #3482, #3483, #3484, #3685, #3613, #3106), comes back. Re-pinning one would double-apply the fix: the feed vendor, for one, has no self-neutralization check and would re-register the route. - Eighteen vendors are still owed upstream and are exact-pin gated to
0.39.0: transient-system lineage (HEADROOM_TRANSIENT_SYSTEM_LINEAGE;prefix_tracker.pyis byte-identical to 0.38.0), cache-integrity observer (HEADROOM_CACHE_INTEGRITY, probescripts/verify-cache-integrity.py --sitecustomize), responses shared budget (HEADROOM_RESPONSES_SHARED_BUDGET, probescripts/verify-responses-budget.py --sitecustomize; the native #3693 deadline is perContentRouter.apply, and with the vendor off the Responses unit fan-out still times out with a continuing worker), tool-ref 400 hint (HEADROOM_TOOL_REF_HINT; the wheel still appends no user hint), quarantine spare capacity (HEADROOM_QUARANTINE_SPARE_CAPACITY, probescripts/verify-quarantine-spare-capacity.py;_run_compression_in_executoris byte-identical to 0.38.0),, learn rule coercion (HEADROOM_LEARN_RULE_COERCE; list-valued rulecontentcrashedheadroom learn, RUST-K5, upstream PR #2471; the desktop puts the sitecustomize on the learn subprocess PYTHONPATH for it; self-neutralizes onanalyzer._as_str), learn worktree merge (HEADROOM_LEARN_WORKTREE_MERGE; each linked git worktree, e.g. a Conductor workspace, was its own learn project and Project learnings row, so learnings never reached the repo; merges worktrees into the main checkout indiscover_projects/scan_project/traffic_project_for_pattern, mirrored bystate::main_worktree_rootfor the desktop list; probescripts/verify-learn-worktree-merge.py; self-neutralizes onplugins.claude._main_worktree_root; upstream PR #3854), CCR repair order (HEADROOM_CCR_REPAIR_ORDER;helpers.strip_unsupported_ccr_retrieve_blocksneutralizes a headroom_retrieve pair in place, so a retrieve made in parallel with another tool left[text, tool_result]and Anthropic 400'd "tool_use ids were found without tool_result blocks" on the first request of a long session after every backend restart; the vendor moves tool_results back to the front of each message the repair rewrote; identical on upstream main; self-neutralizes when the wheel's own repair keeps tool_results first), Kompress waste (HEADROOM_KOMPRESS_WASTE; code_aware hands a line-numbered Claude CodeReadof code back unchanged (Bashcat -n/nl -baand Codex reads are alreadyread_protectedunder the coding profile'sHEADROOM_PROTECT_READS, so onlyReadreaches it),_apply_strategy_to_contentrecords its WORD count ascompressed_tokens, and the no-savings Kompress fallback is kept only if its cl100k payload beats that word count, which code at 2.1-2.4 tokens/word never does, so rc8 spent 19.8s of inference per such Read for 0 tokens saved, logged aslossy_unrecoverable_skipped; the vendor skips that one call when the must-keep words plus a 0.30 keep floor (HEADROOM_KOMPRESS_WASTE_KEEP_FLOOR, lowest observed 0.43; re-measure on a Kompress model bump) already reach the word count, returning the wheel's own passthrough value, so forwarded bytes are identical; it gates only the :3968 fallback (W < _estimate_tokens(content)), never the lossless-then-lossy call at :3719, and must NOT gate on_lossless_then_lossy:run_serverseedsHEADROOM_LOSSLESS_THEN_LOSSY=1for the coding profile, which made the first cut inert for every user while its bare-router test passed, sokompress_waste_behaves_against_the_installed_wheelseedsseed_proxy_env_defaults()first; latency only, the unit mismatch itself is a compression change to check withsavings:did; self-neutralizes when either half of the mismatch changes; not fixed on upstream main 8ff46dc9; stands down whenever kompress fallback units binds, which keeps the calls it skips, so it only runs withHEADROOM_KOMPRESS_FALLBACK_UNITS=0), kompress fallback units (HEADROOM_KOMPRESS_FALLBACK_UNITS; upstream #3881's three hunks applied verbatim to_apply_strategy_to_content's source and exec'd incontent_router's globals: code_aware's result counted with_estimate_tokens, both Kompress attempts judged with it, the inline lossless-then-lossy attempt recorded in the chain so a losing one is not re-run; a code_aware no-op on line-numbered code can now be Kompress-compressed with a retrieval marker instead of forwarded verbatim, so it RAISES savings and needs asavings:didcheck after the stable ships; only sound on top of token read window, which keeps recent Reads out of the router; probescripts/verify-kompress-fallback-units.pyruns #3881's own three tests; self-neutralizes when any hunk's old text is gone), Codex whole read (HEADROOM_CODEX_WHOLE_READ; Codex code mode'stext(r)prints the whole exec result, so a detected read reachescontent_router._read_output_should_be_protectedas the JSON envelope{chunk_id,wall_time_seconds,...,output}, whose detector verdict flips per file between SOURCE_CODE and releasable JSON_ARRAY; rc8's 400-linenl -ba models.rswas replaced by one CCR marker and re-read twice with line filters; the vendor judges the envelope'soutputstring(s) instead, the verdicttext(r.output)gets; this LOWERS single-requesttok_savedon those reads by design (31-item Codex A/B: 3 code reads change, 28,244 -> 15,943 tokens saved), so check it withsavings:didafter the stable ships; self-neutralizes when the wheel protects an enveloped code read; not fixed on upstream main 8ff46dc9), holdout key (HEADROOM_HOLDOUT_KEY;output_savings_policy.conversation_key_from_bodyand_from_responses_bodyseed the output holdout on the first 512 chars of the opener's FIRST text block, which for Claude Code is the global CLAUDE.md system-reminder and for Codex the AGENTS.md block, so every conversation of a client hashed to one key and one arm: on 2026-09-30 one machine's 24.7k opus continuations were 3 "conversations" with 0 control and the measured A/B covered 296 pings; the vendor seeds on every text block in full, a single short block keeps its old key; changes which conversations are shaped, so check it after the stable ships (cache_read per request, since a re-keyed live conversation flips its shaper tail once on the update); self-neutralizes when the wheel separates openers behind a shared prologue; upstream PR #3209), and and proxied guarded upstreams (HEADROOM_ALLOW_PROXIED_GUARDED_UPSTREAMS, which the desktop sets at launch, probescripts/verify-proxied-guarded-upstream.py; self-neutralizes onupstream_pinning.proxied_guarded_upstreams_allowed, see the pinning bullet below, upstream PR #3804), and token read window (HEADROOM_TOKEN_READ_WINDOW; the desktop runsHEADROOM_MODE=token, which setsprotect_recent_reads_fraction=0.3, butproxy_pipeline_kwargspasses the coding persona'sprotect_recent=0asread_protection_window, soContentRouter.applynarrowed the window to 0 and a Claude CodeRead,Skillorread_fileresult had no protection at any position (a newest-messageReadof analyzer.py went out as flattened Kompress output, 9,448 -> 5,694 tokens; cache mode keeps itexcluded_tool); the vendor drops a zero window so token mode's own max(4, 30%) window applies and older excluded-tool output still compresses; LOWERS compression on recent Read/Skill/Grep/Glob/Edit/Write output, so check it withsavings:didafter the stable ships; prerequisite for upstream #3881, whose measured gains were newest-message Reads; probescripts/verify-token-read-window.py; self-neutralizes when the router stops letting a zero window narrow protection; not fixed on upstream main), and upstream TCP keepalive (HEADROOM_UPSTREAM_TCP_KEEPALIVE_SECONDS, idle seconds, default 30, 0 disables; the buffered-CCR path (~30% of Claude Code turns) waits 600s per attempt, three attempts, while heartbeating Claude Code every 0.25s, so a link that dies without a reset (train tunnel, Wi-Fi handover) became a 10-30 minute spinner ending in Claude Code's "check your network or proxy" where a direct connection fails over in ~3 min; the vendor wraps each upstream pool's network backend beforeinstall_upstream_pinning(direct, CONNECT and SOCKS dials; httpcore 1.0.9 proxy pools dropsocket_options) and rebinds that name in the already-imported server.py; measured in a Linux container with iptables DROP: ReadError after 92s vs ReadTimeout at the full read timeout without it; transport only, no compression or cache effect; probescripts/verify-upstream-tcp-keepalive.py; self-neutralizes when the wheel shipsheadroom.proxy.tcp_keepalive; upstream PR #3907), and image memo (HEADROOM_IMAGE_MEMO; every turn resends the conversation, so the image-isolation worker re-ran RapidOCR on every screenshot in history and SigLIP on the first one each turn, one screenshot OCR'd 114 times in two hours on 2026-10-02; the vendor memoizesImageCompressor._ocr_extractandOnnxTechniqueRouter.analyze_imageper process on the image bytes' sha256, so the technique and forwarded bytes are unchanged; the memo dies with its worker and a cold transcode of ~11 screenshots outran the 30s isolation timeout, so each turn's fresh worker started over and the history never compressed (32 timeouts that day): the vendor also wrapsrun_image_compression_isolated(rebinding the name in both already-imported handlers) to hand the worker a deadline at 2/3 of the timeout as a picklable partial ofsitecustomize._hd_im_worker, past which the OCR memo only answers what it has, so an unreached image takes the no-text fallback that turn and the next continues; this RAISES compression on turns that used to time out, so check it withsavings:didafter the stable ships; upstream PR #3941), and image worker reap (HEADROOM_IMAGE_WORKER_REAP;image_isolation._reset_image_pooldrops the pool after a timeout, crash or error withshutdown(wait=False), which never stops the worker, so it ran the abandoned image to the end while the next request cold-loaded the ONNX models in a fresh one; on 2026-10-02 one proxy held four such workers at ~1 core each; the vendor kills the dropped pool's workers, so a request racing a reset can forward its original image, the wheel's own fail-open; CPU only; upstream PR #3940, which resets per pool), and stream uncached input (HEADROOM_STREAM_UNCACHED_INPUT;StreamingMixin._finalize_stream_responsederives a streamed Anthropic turn's uncached input as the local tokenizer count minus cache read/write instead of takingusage.input_tokens, so the estimate's error lands in the new-input denominator: on 2026-10-02 three long screenshot-heavy sessions ran ~10% over the provider's count, 20.1M uncached logged vs 3.3M real, and the day showed 14.8% for a real 24.7%, while under-counting turns clamp real uncached to 0; the vendor takes the provider's count when message_start reported one; accounting only, tokens saved and list-priced dollars unchanged, the rate moves both ways; self-neutralizes when the derivation's text is gone; upstream PR #3946). Attribute-gated guards (#2942 context limit, response-cache poisoning, #3170 dollar unfold, #2668 chained reads, #3379 replay guard, #3166 cc-switch reset) bind on 0.39.0 unchanged; the replay guard stays inert. 0.39.0 defaults periodic malloc trim on for linux as well as darwin, so the desktop'sHEADROOM_MALLOC_TRIM=1is now redundant but harmless. - 0.39.0 added connect-time upstream pinning (
proxy/upstream_pinning.py): a caller-suppliedx-headroom-base-urlupstream (Grok and OpenCode routes,proxy_intercept.rs) is REFUSED withUnpinnableUpstreamErrorwhen the backend hasHTTP(S)_PROXY/ALL_PROXYset, because the proxy resolves the target itself. Operator-configured upstreams (Anthropic, OpenAI) are unaffected.HEADROOM_ALLOWED_BASE_URLScannot fix it: it flips the guard to allow-only mode, which would break OpenCode's arbitrary gateways. httpx takes proxies from the macOS/Windows system settings too, so no env var is needed to hit this. The desktop setsHEADROOM_ALLOW_PROXIED_GUARDED_UPSTREAMS=1, vendored on 0.39.0: a proxy route forwards on the guard's name verdict (the 0.38.0 behaviour), direct routes stay pinned. Upstream PR #3804. - On every bump: (0) CI's test-macos-wheel job ("Vendored patches against the pinned wheel") builds a runtime from the lock plus the NEW pin and fails on any
skipping:, so a vendor that stops binding fails the bump PR; it proves binding, not the fleet-level effect, and does not replace (1)-(3). (1) re-run every*_against_the_installed_wheeltest against the NEW wheel before the runtime is upgraded, by installing it into a scratch venv (uv venv v && uv pip install -p v/bin/python "headroom-ai[proxy,code,spreadsheet]==<v>" truststore), symlinking it to<dir>/headroom/runtime/venv, and runningHEADROOM_DATA_DIR=<dir> cargo test --lib against_the_installed_wheel; every one of those tests self-skips when its vendor does not bind, so a green run on the OLD runtime proves nothing. (2) Check each owed vendor against the new wheel's SOURCE, not only its test: a vendor without a self-neutralization check still binds and passes when the wheel already ships the fix. Diffprefix_tracker.pyresolve_tracker(lineage, cache integrity),server.py_run_compression_in_executor(quarantine),handlers/openai.pyResponses executors (shared budget, and run its probe with--disabled), grep the Anthropic handlers for a tool-reference hint, and checklearn/analyzer.py_parse_llm_responsefor non-string handling (learn coercion), and runhelpers.strip_unsupported_ccr_retrieve_blockson a parallel retrieve pair to see whether tool_results still lead (CCR repair order), and check_read_output_should_be_protectedfor exec-envelope unwrapping (Codex whole read), and key two openers that share a 600-char first block (holdout key), and check whetherContentRouter.applystill lets a zeroread_protection_windownarrow token mode's read window (token read window), and check whether the wheel shipsheadroom/proxy/tcp_keepalive.py(upstream TCP keepalive), and check whether_ocr_extractoranalyze_imagegained a per-image cache andcompressadeadline(image memo, #3941), and check whether_reset_image_poolstops the dropped pool's workers (image worker reap), and check whether_finalize_stream_responsestill derives Anthropic uncached input fromoptimized_tokens(stream uncached input), and check whether_apply_strategy_to_contentstill counts code_aware in words (kompress fallback units; drop it AND kompress waste once #3881 ships); drop each vendor the wheel carries, re-pin the rest. (3) Boot the new wheel in the scratch venv with the shipped sitecustomize on PYTHONPATH and diff/statskey sets against the old wheel (a 0.38.0 boot removed nothing and addedsavings.by_layer.output_shapingat zero traffic withmethod: "inactive", whichparse_output_reductionnow treats as no claim). - #3460 (conversation
clustersin the output-savings ledger) shipped in 0.38.0 and needs NO ledger purge: the merged accumulator keeps conversation-qualified observations in separateqn/qsum/qsumsqfields, so legacy rows never enter the measured mean and both arms restart together on the bump.output_savings.rsmirrors that gate (MEASURED_MIN_CLUSTERS); without the mirror the Rust estimator would promote on legacy data the wheel itself refuses to score. The desktop requalifies once more for theholdout_keyvendor (requalify_output_savings_arms_oncedropsqn/qsum/qsumsq/clustersfrom both arms, backup~/.headroom/.holdout-key-requalified.bak), because rows qualified under the collapsed key are whole clients in one arm. The holdout is a flat 3% (OUTPUT_HOLDOUT); the 10% boost it replaced was compensating for that key. - #3699 (cache-aware counterfactual, savings schema v6) shipped in 0.38.0.
/statscost.compression_savings_usd(what the desktop's daily buckets delta) is still list-priced viamerge_cost_stats; onlysavings.breakdown.compression_savings_usd,cost.cache_aware_savings_usdand the persistedlifetime.compression_savings_usd(read only as the pre-rollup fallback inparse_savings_breakdown) moved to the cache-aware basis.savings_basisandcompression_savings_list_usdsit beside them. The savings-basis canary is token-based and untouched. - 0.38.0 moved
proxy_output_shapertoavailable_in=STABLE(still not default-enabled, soHEADROOM_OUTPUT_SHAPER=1is what turns it on); nothing else moved in the FEATURES registry, andHEADROOM_ROLLOUT_CHANNEL=betastays for read_maturation.HEADROOM_BEACON=offstill silences the v2 beacon (#3253 widened the payload, not the gate). Locks: anyio topped up to 4.14.2 (#3662 CVEs); the litellm floor moved to 1.96.2 for Python 3.14 wheels only and the pins stay at 1.90.1/1.88.1 (see the lock lineage note). - 0.38.0 (#3204) writes the wheel runtime log as
~/.headroom/logs/proxy-<port>.logand stops writingproxy.log; an upgraded machine keeps the stale 0.37.0proxy.logforever. Anything scanning that log (the Kompress status markers innewest_wheel_proxy_log) must pick the newestproxy*.log, never the fixed name. Read protection for shell reads isHEADROOM_PROTECT_READS, switched on by thecodingprofile the desktop runs, not by an env the desktop sets; #3621 extends it to Codexexeccustom_tool_call reads, so expect Codex tool-output compression to drop a little on this bump while re-reads drop with it.
Runtime Lock Rules
- Every entry in
src-tauri/python/*.lockcarries--hashlines, so pip runs in hash-checking mode. After ANY pin change runpython3 scripts/hash-python-locks.py;bundled_locks_carry_a_hash_for_every_requirementfails on an unhashed entry. - Each lock must pin its FULL dependency closure for every platform it serves (the app installs the lock WITH resolution, not
--no-deps), because hash-checking mode refuses any unpinned dependency: a missing transitive pin is a hard bootstrap failure, not a silent fetch of the newest version. The CI "lock resolves to wheels only" dry-runs (run without--no-deps) prove this per platform. requirements_lock_shastrips--hashoptions, so rehashing alone never makes installs re-sync; any pin added, removed or moved still does.vendor-wheels-v1assets are FROZEN for every name and version a lock pins. pip gets them through--find-links(VENDOR_WHEELS_INDEX_URL) with no sha256 fragment, and hash-checking mode keeps an unhashed candidate, so an added better-tagged wheel (say an hnswlib-0.8.0 arm64 build beside the universal2 one) or a same-name re-upload gets picked, fails--hash, and breaks every install, upgrade and repair on that platform, including builds already shipped, which read the release live. A new or rebuilt wheel goes to a new tag (vendor-wheels-v2plus aVENDOR_WHEELS_INDEX_URLbump, and the CI--find-linksURLs in test.yml) or a new version, then rerunhash-python-locks.py.build-vendor-wheels.ymldefaults tovendor-wheels-v1and uploads with--clobber: never dispatch it with that default.- CI's
pip-audit(advisories job) auditshash-python-locks.py --exportoutput per target platform, so Intel-Mac-only pins are covered. Accepted advisories are--ignore-vulnentries with their reason in test.yml; drop each with the pin that carries it.
Compression / Cache Change Rules
The 0.9.4 prefix-replay regression cost every upgraded user ~17pp of their input savings rate for ~18 hours across 89 installs. The first two rules below would have caught it before release; the third catches the next one after it ships.
- Verify both sides of a trade. Any change that buys one metric with another (the prefix-replay guard buys provider cache hits by spending compression) is only verified when BOTH are measured. The 0.9.4 sign-off measured cache reads and busts and never looked at
tok_saved, so it reported "better on every metric" while compression had collapsed. Minimum evidence:cache_read/forwardedANDtok_saved/tok_before, on requests in the size band the change affects. - A ratio is not a measurement.
cache_read/forwardedfalling can mean the cache broke or the conversations grew. Check the ABSOLUTE per-request figure before blaming either. A flatcache_readper request against a growing denominator is workload; acache_readthat stops scaling with conversation size is a bug (that plateau was the 0.9.4 fingerprint). - Measure on the fleet, after the stable ships. There is no pre-promotion soak (removed 2026-09-30): rc builds reach only Garm's machine, so a staging soak is n=1 and proves nothing.
bin/rails savings:didin headroom-web is the fleet check, run whenever a change needs evidence:DAY=<a FULL stable day> VERSION_PREFIX=<version>, the day after that day (a release-day run is at most ~22% of the ~24h bucket and dilutes a real effect ~4x). The rollback is the change's kill switch, so name it in the PR body or release notes. - Do NOT add a client-side savings-rate canary that compares a machine against its own history. It has no control group, so a user switching models or growing conversations trips it; that was tried and produced 12 false events across 9 hosts (Sentry RUST-89/8C). The fleet DiD has a control arm, which is the entire reason it works.
- Do NOT reimplement upstream #3380 against the pinned wheel. The 0.9.4-rc.4 failure was a splice reimplementation (replay to the confirmed floor, then stitch on this turn's fresh output) that shipped every turn's beyond-floor pipeline drift and lost 22% of fleet cache coverage (1.20 -> 0.94 reads/sent, n=17, p=0.007). The sanctioned form is the sitecustomize prefix-floor VENDOR (0.9.6): the PR's overlay_cached_prefix + finalize_turn exec'd verbatim, exact-pin gated to wheel 0.37.0, pre-clamp floor bridged via prepare_turn's tracker_frozen, full-replay fallback for floorless callers, kill switch HEADROOM_PR3380_VENDOR=0, functionally tested against the installed wheel. Anything in between - partial hunks, rewritten logic, a floor derived at the overlay call site - is banned. The vendor was dropped in 0.9.20-rc.1 because the 0.38.0 wheel ships #3380 natively; if a future wheel loses it, vendor it the same way again.
Release Cadence / Update Loudness
- Stable releases batch weekly; out-of-band stable releases are for regressions and security only (user feedback 2026-09-03: daily update prompts read as churn). Daily rc's on the beta channel are fine.
- A stable can be built without being offered to anyone: put
[publish: download-only]in the release commit (or dispatch release-macos.yml with publish=download-only). The release stays a prerelease,releases/latestkeeps the previous stable, and only new downloads reach it viaHEADROOM_DOWNLOAD_TAG=vX.Y.Zon the headroom-web Railwaywebservice. Promote withgh release edit vX.Y.Z --prerelease=false --latestand clear the variable. New installs have no pre-period, so they cannot entersavings:did; a compression change in a download-only build is measured only after promotion. - Updates are quiet by default: no dialog/notification, and on macOS they silently download+install with only a passive "Restart to update" affordance. A ready update then applies itself after 30 awake minutes with no client traffic and every window hidden (
spawn_idle_update_applier): macOS/Linux restart into the staged build, Windows runs the installer then (once per process). That relaunch stays in the tray like a login launch (storage::take_quiet_relaunch); without it the new build raised and focused its window on a machine whose owner may be typing elsewhere. Without the applier, on 2026-10-02 59% of macOS and 75% of Windows installs were a week or more behind, because a menu-bar app rarely restarts. To make a release loud (old interrupting flow, for must-take updates), put<!-- headroom:loud -->anywhere in.github/release-notes/<VERSION>.md- the marker flows through latest.jsonnotesand is stripped from the displayed notes.
Persistence Rules
Most stability bugs in this codebase's history were violations of one of these five. Follow them for any new code; treat violations found in existing code as bugs.
- Anything persisted uses
client_adapters::atomic_write(tmp+rename), never plainfs::write. Crash mid-write must not truncate state, and a rewrite must keep the file's mode and write THROUGH a symlink (a hand-rolled rename replaced dotfiles-managed~/.zprofileand~/.claude.jsonlinks with regular files, silently). CI'sscripts/check-direct-writes.pyfails any otherfs::write/fs::rename/File::createin non-test code unless it carries// direct-write: <reason>; only Headroom's own files qualify. - Anything versioned/deserialized carries
#[serde(default)](container-level where possible). One added required field must not wipe a user's history. On parse/schema failure: back the file up and log, never silently overwrite; salvage format-agnostic fields where possible. - Anything appended (logs, JSONL) has a size cap or rotation from day one.
- Never kill a pid resolved from a port without verifying its identity (argv/process name) first.
- Day/hour bucket keys must state their timezone. User-facing "days" are local (
local_day_key); if a source is UTC-bucketed (backend rollups), key it by its UTC date and say so - never relabel one as the other.
Formatting
- No em dashes, smart quotes, or decorative Unicode. Plain hyphens and straight quotes, so output stays copy-paste safe. Accented letters and CJK are fine when the content needs them.
Styling Rules
- Never hardcode colors in component CSS. Use the semantic tokens defined in
:rootinsrc/styles.css(--surface-*,--text-*,--border-*,--fill-*,--accent*,--warning*,--danger*,--chip-*). - If a needed color does not exist as a token, add it to both the
:rootblock and the@media (prefers-color-scheme: dark)override — do not inline a hex/rgba in a component rule. - Exceptions: pure
#fff/#000, brand gradients, and launcher/splash-only one-offs that are intentionally theme-invariant. Comment the exception inline. - When adding or modifying a component, visually verify both light and dark mode before declaring done. If dark mode cannot be tested, say so explicitly.
- Run
npm run check:colors(or./scripts/check-colors.sh) on any CSS you touch. It flags raw hex/rgba in component rules. Migrate any new offenders to tokens before committing. Existing offenders are the Stage 4 migration backlog — don't add to them.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

