agentleFS
gglucassgglucass/headroom-desktop/CLAUDE.md

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.

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
  1. Distinctive:

    After any code change, run the relevant tests/checks before declaring the task done.

    line 9
  2. Distinctive:

    If a test cannot be run in this environment, say so explicitly rather than skipping silently.

    line 12
  3. Very specific:

    Every entry in src-tauri/python/*.lock carries --hash lines, so pip runs in hash-checking mode.

    line 30
  4. Distinctive:

    Never kill a pid resolved from a port without verifying its identity (argv/process name) first.

    line 54
  5. Distinctive:

    No em dashes, smart quotes, or decorative Unicode.

    line 58
  6. Very specific:

    Never hardcode colors in component CSS.

    line 61
  7. Very specific:

    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 …

    line 62
  8. Distinctive:

    When adding or modifying a component, visually verify both light and dark mode before declaring done.

    line 64
  9. Very specific:

    Run npm run check:colors (or ./scripts/check-colors.sh) on any CSS you touch.

    line 65

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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, plus cargo check --manifest-path src-tauri/Cargo.toml if the change crosses module boundaries.
  • Frontend changes: npx tsc --noEmit and 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 upstream savings_tracker.py, prometheus_metrics.py, and server.py between the old and new pins, and check every consumed field against stats_contract_pins_every_consumed_path in state.rs. Upstream has silently redefined persisted savings fields before (0.36.0 widened compression_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 declares HEADROOM_ROLLOUT_CHANNEL=beta (tool_manager.rs), so any new feature with default_enabled_in at or below beta auto-enables for every user on the bump; any feature the app requests whose available_in moved above beta silently turns off (this is how 0.37.0 disabled the output shaper on stable).
  • Diff ProxyConfig (proxy/models.py) and cli/proxy.py defaults 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 /stats diff 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 full ContentRouter.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 behind HEADROOM_NET_COST_POLICY=1, not set, zero netcost:skip markers 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 split models.rs reads), 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_blocks now has a client-side tool_result pass that keeps deferred-but-present refs, so no rc.5 regression). sitecustomize_drops_vendors_the_wheel_ships fails 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.py is byte-identical to 0.38.0), cache-integrity observer (HEADROOM_CACHE_INTEGRITY, probe scripts/verify-cache-integrity.py --sitecustomize), responses shared budget (HEADROOM_RESPONSES_SHARED_BUDGET, probe scripts/verify-responses-budget.py --sitecustomize; the native #3693 deadline is per ContentRouter.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, probe scripts/verify-quarantine-spare-capacity.py; _run_compression_in_executor is byte-identical to 0.38.0),, learn rule coercion (HEADROOM_LEARN_RULE_COERCE; list-valued rule content crashed headroom learn, RUST-K5, upstream PR #2471; the desktop puts the sitecustomize on the learn subprocess PYTHONPATH for it; self-neutralizes on analyzer._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 in discover_projects/scan_project/traffic _project_for_pattern, mirrored by state::main_worktree_root for the desktop list; probe scripts/verify-learn-worktree-merge.py; self-neutralizes on plugins.claude._main_worktree_root; upstream PR #3854), CCR repair order (HEADROOM_CCR_REPAIR_ORDER; helpers.strip_unsupported_ccr_retrieve_blocks neutralizes 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 Code Read of code back unchanged (Bash cat -n/nl -ba and Codex reads are already read_protected under the coding profile's HEADROOM_PROTECT_READS, so only Read reaches it), _apply_strategy_to_content records its WORD count as compressed_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 as lossy_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_server seeds HEADROOM_LOSSLESS_THEN_LOSSY=1 for the coding profile, which made the first cut inert for every user while its bare-router test passed, so kompress_waste_behaves_against_the_installed_wheel seeds seed_proxy_env_defaults() first; latency only, the unit mismatch itself is a compression change to check with savings: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 with HEADROOM_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 in content_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 a savings:did check after the stable ships; only sound on top of token read window, which keeps recent Reads out of the router; probe scripts/verify-kompress-fallback-units.py runs #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's text(r) prints the whole exec result, so a detected read reaches content_router._read_output_should_be_protected as 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-line nl -ba models.rs was replaced by one CCR marker and re-read twice with line filters; the vendor judges the envelope's output string(s) instead, the verdict text(r.output) gets; this LOWERS single-request tok_saved on those reads by design (31-item Codex A/B: 3 code reads change, 28,244 -> 15,943 tokens saved), so check it with savings:did after 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_body and _from_responses_body seed 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, probe scripts/verify-proxied-guarded-upstream.py; self-neutralizes on upstream_pinning.proxied_guarded_upstreams_allowed, see the pinning bullet below, upstream PR #3804), and token read window (HEADROOM_TOKEN_READ_WINDOW; the desktop runs HEADROOM_MODE=token, which sets protect_recent_reads_fraction=0.3, but proxy_pipeline_kwargs passes the coding persona's protect_recent=0 as read_protection_window, so ContentRouter.apply narrowed the window to 0 and a Claude Code Read, Skill or read_file result had no protection at any position (a newest-message Read of analyzer.py went out as flattened Kompress output, 9,448 -> 5,694 tokens; cache mode keeps it excluded_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 with savings:did after the stable ships; prerequisite for upstream #3881, whose measured gains were newest-message Reads; probe scripts/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 before install_upstream_pinning (direct, CONNECT and SOCKS dials; httpcore 1.0.9 proxy pools drop socket_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; probe scripts/verify-upstream-tcp-keepalive.py; self-neutralizes when the wheel ships headroom.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 memoizes ImageCompressor._ocr_extract and OnnxTechniqueRouter.analyze_image per 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 wraps run_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 of sitecustomize._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 with savings:did after the stable ships; upstream PR #3941), and image worker reap (HEADROOM_IMAGE_WORKER_REAP; image_isolation._reset_image_pool drops the pool after a timeout, crash or error with shutdown(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_response derives a streamed Anthropic turn's uncached input as the local tokenizer count minus cache read/write instead of taking usage.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's HEADROOM_MALLOC_TRIM=1 is now redundant but harmless.
  • 0.39.0 added connect-time upstream pinning (proxy/upstream_pinning.py): a caller-supplied x-headroom-base-url upstream (Grok and OpenCode routes, proxy_intercept.rs) is REFUSED with UnpinnableUpstreamError when the backend has HTTP(S)_PROXY/ALL_PROXY set, because the proxy resolves the target itself. Operator-configured upstreams (Anthropic, OpenAI) are unaffected. HEADROOM_ALLOWED_BASE_URLS cannot 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 sets HEADROOM_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_wheel test 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 running HEADROOM_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. Diff prefix_tracker.py resolve_tracker (lineage, cache integrity), server.py _run_compression_in_executor (quarantine), handlers/openai.py Responses executors (shared budget, and run its probe with --disabled), grep the Anthropic handlers for a tool-reference hint, and check learn/analyzer.py _parse_llm_response for non-string handling (learn coercion), and run helpers.strip_unsupported_ccr_retrieve_blocks on a parallel retrieve pair to see whether tool_results still lead (CCR repair order), and check _read_output_should_be_protected for exec-envelope unwrapping (Codex whole read), and key two openers that share a 600-char first block (holdout key), and check whether ContentRouter.apply still lets a zero read_protection_window narrow token mode's read window (token read window), and check whether the wheel ships headroom/proxy/tcp_keepalive.py (upstream TCP keepalive), and check whether _ocr_extract or analyze_image gained a per-image cache and compress a deadline (image memo, #3941), and check whether _reset_image_pool stops the dropped pool's workers (image worker reap), and check whether _finalize_stream_response still derives Anthropic uncached input from optimized_tokens (stream uncached input), and check whether _apply_strategy_to_content still 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 /stats key sets against the old wheel (a 0.38.0 boot removed nothing and added savings.by_layer.output_shaping at zero traffic with method: "inactive", which parse_output_reduction now treats as no claim).
  • #3460 (conversation clusters in the output-savings ledger) shipped in 0.38.0 and needs NO ledger purge: the merged accumulator keeps conversation-qualified observations in separate qn/qsum/qsumsq fields, so legacy rows never enter the measured mean and both arms restart together on the bump. output_savings.rs mirrors 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 the holdout_key vendor (requalify_output_savings_arms_once drops qn/qsum/qsumsq/clusters from 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. /stats cost.compression_savings_usd (what the desktop's daily buckets delta) is still list-priced via merge_cost_stats; only savings.breakdown.compression_savings_usd, cost.cache_aware_savings_usd and the persisted lifetime.compression_savings_usd (read only as the pre-rollup fallback in parse_savings_breakdown) moved to the cache-aware basis. savings_basis and compression_savings_list_usd sit beside them. The savings-basis canary is token-based and untouched.
  • 0.38.0 moved proxy_output_shaper to available_in=STABLE (still not default-enabled, so HEADROOM_OUTPUT_SHAPER=1 is what turns it on); nothing else moved in the FEATURES registry, and HEADROOM_ROLLOUT_CHANNEL=beta stays for read_maturation. HEADROOM_BEACON=off still 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>.log and stops writing proxy.log; an upgraded machine keeps the stale 0.37.0 proxy.log forever. Anything scanning that log (the Kompress status markers in newest_wheel_proxy_log) must pick the newest proxy*.log, never the fixed name. Read protection for shell reads is HEADROOM_PROTECT_READS, switched on by the coding profile the desktop runs, not by an env the desktop sets; #3621 extends it to Codex exec custom_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/*.lock carries --hash lines, so pip runs in hash-checking mode. After ANY pin change run python3 scripts/hash-python-locks.py; bundled_locks_carry_a_hash_for_every_requirement fails 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_sha strips --hash options, so rehashing alone never makes installs re-sync; any pin added, removed or moved still does.
  • vendor-wheels-v1 assets 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-v2 plus a VENDOR_WHEELS_INDEX_URL bump, and the CI --find-links URLs in test.yml) or a new version, then rerun hash-python-locks.py. build-vendor-wheels.yml defaults to vendor-wheels-v1 and uploads with --clobber: never dispatch it with that default.
  • CI's pip-audit (advisories job) audits hash-python-locks.py --export output per target platform, so Intel-Mac-only pins are covered. Accepted advisories are --ignore-vuln entries 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/forwarded AND tok_saved/tok_before, on requests in the size band the change affects.
  • A ratio is not a measurement. cache_read/forwarded falling can mean the cache broke or the conversations grew. Check the ABSOLUTE per-request figure before blaming either. A flat cache_read per request against a growing denominator is workload; a cache_read that 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:did in 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/latest keeps the previous stable, and only new downloads reach it via HEADROOM_DOWNLOAD_TAG=vX.Y.Z on the headroom-web Railway web service. Promote with gh release edit vX.Y.Z --prerelease=false --latest and clear the variable. New installs have no pre-period, so they cannot enter savings: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.json notes and 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 plain fs::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 ~/.zprofile and ~/.claude.json links with regular files, silently). CI's scripts/check-direct-writes.py fails any other fs::write/fs::rename/File::create in 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 :root in src/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 :root block 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.