compactlab 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. compactlab-0.2.0/.gitignore +26 -0
  2. compactlab-0.2.0/CHANGELOG.md +508 -0
  3. compactlab-0.2.0/LICENSE +21 -0
  4. compactlab-0.2.0/PKG-INFO +243 -0
  5. compactlab-0.2.0/README.md +211 -0
  6. compactlab-0.2.0/README.zh-CN.md +173 -0
  7. compactlab-0.2.0/examples/preauth.example.json +16 -0
  8. compactlab-0.2.0/pyproject.toml +95 -0
  9. compactlab-0.2.0/src/compactlab/__init__.py +3 -0
  10. compactlab-0.2.0/src/compactlab/adapters/__init__.py +2 -0
  11. compactlab-0.2.0/src/compactlab/adapters/base.py +212 -0
  12. compactlab-0.2.0/src/compactlab/adapters/cache.py +396 -0
  13. compactlab-0.2.0/src/compactlab/adapters/claude_code.py +226 -0
  14. compactlab-0.2.0/src/compactlab/adapters/codex.py +298 -0
  15. compactlab-0.2.0/src/compactlab/adapters/dsh.py +287 -0
  16. compactlab-0.2.0/src/compactlab/adapters/gemini_cli.py +259 -0
  17. compactlab-0.2.0/src/compactlab/adapters/opencode.py +375 -0
  18. compactlab-0.2.0/src/compactlab/apply/__init__.py +582 -0
  19. compactlab-0.2.0/src/compactlab/cli/__init__.py +5 -0
  20. compactlab-0.2.0/src/compactlab/cli/main.py +2436 -0
  21. compactlab-0.2.0/src/compactlab/data/config_knobs.json +158 -0
  22. compactlab-0.2.0/src/compactlab/data/harness_defaults.json +72 -0
  23. compactlab-0.2.0/src/compactlab/data/harness_formats.json +300 -0
  24. compactlab-0.2.0/src/compactlab/data/pricing.json +51 -0
  25. compactlab-0.2.0/src/compactlab/engine/__init__.py +138 -0
  26. compactlab-0.2.0/src/compactlab/engine/live.py +306 -0
  27. compactlab-0.2.0/src/compactlab/engine/settings.py +175 -0
  28. compactlab-0.2.0/src/compactlab/engine/watch.py +82 -0
  29. compactlab-0.2.0/src/compactlab/eval/__init__.py +1 -0
  30. compactlab-0.2.0/src/compactlab/eval/deep.py +390 -0
  31. compactlab-0.2.0/src/compactlab/eval/executors.py +84 -0
  32. compactlab-0.2.0/src/compactlab/eval/factcheck.py +75 -0
  33. compactlab-0.2.0/src/compactlab/lens.py +80 -0
  34. compactlab-0.2.0/src/compactlab/model/__init__.py +285 -0
  35. compactlab-0.2.0/src/compactlab/pricing/__init__.py +211 -0
  36. compactlab-0.2.0/src/compactlab/pricing/auto.py +118 -0
  37. compactlab-0.2.0/src/compactlab/pricing/ids.py +148 -0
  38. compactlab-0.2.0/src/compactlab/pricing/refresh.py +299 -0
  39. compactlab-0.2.0/src/compactlab/publish.py +125 -0
  40. compactlab-0.2.0/src/compactlab/py.typed +0 -0
  41. compactlab-0.2.0/src/compactlab/recommend/__init__.py +201 -0
  42. compactlab-0.2.0/src/compactlab/recommend/claude_code.py +172 -0
  43. compactlab-0.2.0/src/compactlab/recommend/codex.py +104 -0
  44. compactlab-0.2.0/src/compactlab/recommend/dsh.py +89 -0
  45. compactlab-0.2.0/src/compactlab/recommend/gemini_cli.py +85 -0
  46. compactlab-0.2.0/src/compactlab/recommend/opencode.py +117 -0
  47. compactlab-0.2.0/src/compactlab/recommend/units.py +63 -0
  48. compactlab-0.2.0/src/compactlab/report/__init__.py +3 -0
  49. compactlab-0.2.0/src/compactlab/report/html.py +27 -0
  50. compactlab-0.2.0/src/compactlab/report/template.html +1189 -0
  51. compactlab-0.2.0/src/compactlab/service/__init__.py +1 -0
  52. compactlab-0.2.0/src/compactlab/service/core.py +220 -0
  53. compactlab-0.2.0/src/compactlab/service/http.py +133 -0
  54. compactlab-0.2.0/src/compactlab/service/lock.py +92 -0
  55. compactlab-0.2.0/src/compactlab/service/policy.py +258 -0
  56. compactlab-0.2.0/src/compactlab/service/schedule.py +212 -0
  57. compactlab-0.2.0/src/compactlab/share.py +553 -0
  58. compactlab-0.2.0/src/compactlab/sim/__init__.py +1 -0
  59. compactlab-0.2.0/src/compactlab/sim/baseline.py +214 -0
  60. compactlab-0.2.0/src/compactlab/sim/calibrate.py +108 -0
  61. compactlab-0.2.0/src/compactlab/sim/engine.py +1130 -0
  62. compactlab-0.2.0/src/compactlab/sim/select.py +238 -0
  63. compactlab-0.2.0/src/compactlab/sim/timing.py +134 -0
  64. compactlab-0.2.0/src/compactlab/synth.py +416 -0
  65. compactlab-0.2.0/src/compactlab/term/__init__.py +0 -0
  66. compactlab-0.2.0/src/compactlab/term/style.py +134 -0
  67. compactlab-0.2.0/src/compactlab/term/top.py +531 -0
  68. compactlab-0.2.0/src/compactlab/term/views.py +598 -0
  69. compactlab-0.2.0/src/compactlab/term/widgets.py +238 -0
  70. compactlab-0.2.0/src/compactlab/verify.py +462 -0
  71. compactlab-0.2.0/tests/conftest.py +78 -0
  72. compactlab-0.2.0/tests/contract/applied.json +21 -0
  73. compactlab-0.2.0/tests/contract/consent.json +15 -0
  74. compactlab-0.2.0/tests/contract/error.json +8 -0
  75. compactlab-0.2.0/tests/contract/hello.json +112 -0
  76. compactlab-0.2.0/tests/contract/history.json +33 -0
  77. compactlab-0.2.0/tests/contract/plan.json +49 -0
  78. compactlab-0.2.0/tests/contract/pong.json +4 -0
  79. compactlab-0.2.0/tests/contract/result.json +503 -0
  80. compactlab-0.2.0/tests/contract/reverted.json +9 -0
  81. compactlab-0.2.0/tests/contract/sessions.json +93 -0
  82. compactlab-0.2.0/tests/contract/verification.json +36 -0
  83. compactlab-0.2.0/tests/golden/widgets_120.txt +19 -0
  84. compactlab-0.2.0/tests/golden/widgets_40.txt +24 -0
  85. compactlab-0.2.0/tests/golden/widgets_80.txt +19 -0
  86. compactlab-0.2.0/tests/test_adapters.py +268 -0
  87. compactlab-0.2.0/tests/test_aieval.py +120 -0
  88. compactlab-0.2.0/tests/test_apply.py +256 -0
  89. compactlab-0.2.0/tests/test_cache_and_formats.py +460 -0
  90. compactlab-0.2.0/tests/test_cache_ttl.py +66 -0
  91. compactlab-0.2.0/tests/test_cli.py +224 -0
  92. compactlab-0.2.0/tests/test_core.py +427 -0
  93. compactlab-0.2.0/tests/test_dsh.py +224 -0
  94. compactlab-0.2.0/tests/test_engine.py +527 -0
  95. compactlab-0.2.0/tests/test_engine_settings.py +163 -0
  96. compactlab-0.2.0/tests/test_impact.py +94 -0
  97. compactlab-0.2.0/tests/test_isolation.py +18 -0
  98. compactlab-0.2.0/tests/test_lean.py +230 -0
  99. compactlab-0.2.0/tests/test_lens.py +45 -0
  100. compactlab-0.2.0/tests/test_lock.py +308 -0
  101. compactlab-0.2.0/tests/test_models.py +580 -0
  102. compactlab-0.2.0/tests/test_opencode_gemini.py +339 -0
  103. compactlab-0.2.0/tests/test_profiles_pricing_executors.py +320 -0
  104. compactlab-0.2.0/tests/test_publish.py +165 -0
  105. compactlab-0.2.0/tests/test_recommend.py +184 -0
  106. compactlab-0.2.0/tests/test_report_dom.py +341 -0
  107. compactlab-0.2.0/tests/test_result_reuse.py +240 -0
  108. compactlab-0.2.0/tests/test_secrets_scan.py +19 -0
  109. compactlab-0.2.0/tests/test_service.py +500 -0
  110. compactlab-0.2.0/tests/test_share.py +287 -0
  111. compactlab-0.2.0/tests/test_term.py +188 -0
  112. compactlab-0.2.0/tests/test_time_baseline.py +157 -0
  113. compactlab-0.2.0/tests/test_verify.py +249 -0
@@ -0,0 +1,26 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ .pytest_cache/
5
+ dist/
6
+ *.egg-info/
7
+ out/
8
+ .DS_Store
9
+ .coverage
10
+ htmlcov/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+ # never commit real history or outputs derived from it
14
+ compactlab-result.json
15
+ compactlab-report.html
16
+ compactlab-demo/
17
+ *.jsonl
18
+ !tests/fixtures/**/*.jsonl
19
+ .compactlab/
20
+ settings.json
21
+ config.toml
22
+
23
+ # private promotion / launch material lives outside the repo (~/compactlab-private)
24
+ docs/LAUNCH.md
25
+ launch/
26
+ *.private.md
@@ -0,0 +1,508 @@
1
+ # Changelog
2
+
3
+ All notable changes are documented here. Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
4
+ versioning: [SemVer](https://semver.org/).
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Changed
9
+ - **On PyPI.** `uv tool install compactlab`, `pipx install compactlab` and `uvx compactlab demo` work; releases
10
+ upload with trusted publishing (the `Publish` workflow). The menu bar app installs with the signed and notarized
11
+ Homebrew cask: `brew install --cask LemonCANDY42/tap/compactlab-app`.
12
+ - **Docs and presentation.** The READMEs are a short front page (pitch, the one real-log result, install,
13
+ quickstart, ways to use it, harnesses, privacy, limitations), the same in English and Chinese, with a language
14
+ switch, release and platform badges, and screenshots of the menu bar app. The reference detail they held moved to
15
+ `docs/GUIDE.md`; `docs/README.md` indexes every doc. `app/scripts/screenshots.sh` renders the app screenshots from
16
+ synthetic data. `docs/ARCHITECTURE.md` and `docs/ROADMAP.md` caught up with the adapters, the app and the
17
+ Homebrew install; CONTRIBUTING uses `uv`, covers the app and the docs rules; the issue and PR templates ask for
18
+ the app, harness and OS.
19
+
20
+ ## [0.2.0] - 2026-11-26
21
+
22
+ ### Added
23
+ - **A read-only macOS menu bar app** in `app/` (Phase 1 of `docs/MENUBAR_APP.zh-CN.md`): how close each active
24
+ Claude Code and Codex session is to auto-compaction and whether its cache is still warm, the last calibration's
25
+ threshold per model and role (Codex's one key, Claude Code's idle compaction), a daily background calibration
26
+ on the service's schedule and backoff (put off on low power), the HTML report, open at login. A thin client of
27
+ `compactlab engine`: one resident `engine watch` driven by FSEvents, one-shot `result`, `calibrate` and `report`
28
+ processes; it parses no logs, writes no settings and uses no network. macOS 14+, built with SwiftPM
29
+ (`app/scripts/package_app.sh`); the `App` workflow tests it, smoke-tests the packaged app and, given a Developer
30
+ ID certificate and a notary key as secrets, signs and notarizes it.
31
+ - **The menu bar app reviews, applies and undoes changes** (Phases 2 and 3 of the design): a review window per
32
+ suggested change (old → new, $ and minutes per day, the data behind it, the exact edit) with Apply, one change or
33
+ all; the last change in the panel (in effect, undone, or changed by someone else) with its verification and Undo;
34
+ notifications, each once and each kind optional (a suggestion two calibrations agree on, an auto-apply with Undo,
35
+ a setting edited behind compactlab, a verification result, repeated calibration failures) and a dot on the icon;
36
+ optional auto-apply for Claude Code under the existing rules. In English and Simplified Chinese
37
+ (`app/scripts/check_strings.py` checks every string), with an icon, a disk image (`make_dmg.sh`, notarized in CI),
38
+ a Homebrew cask template, and a release upload. `swift test` also runs it against the real engine.
39
+ - **`compactlab engine plan`, `apply`, `revert`, `history`, `verify` and `consent`** for the app
40
+ (docs/ENGINE_API.md): `plan` prints each change with its per-day impact and its own hash; `apply` writes only the
41
+ reviewed plan (`--expect-plan`, `--only harness:model`) under the state dir's lock and records the write as
42
+ auto-apply does; `history` reports what every written key holds now (drift); `hello` reports the stored consent.
43
+ A consent may name every model (`--models '*'`, the `engine consent` default). Contract stays version 1.
44
+
45
+ ## [0.1.0] - 2026-11-25
46
+
47
+ First release. Install with `brew install LemonCANDY42/tap/compactlab` or from GitHub with `uv tool install`.
48
+
49
+ ### Changed
50
+ - **`lens.json` and the service's `result.json` keep the latest run of every harness.** A run replaces the harnesses
51
+ it scanned (every one unless `--harness` limits it, including one with no logs in the window) and keeps the
52
+ others' groups, sessions, Codex single-key decision, idle-compaction verdict and model notes from the file, so
53
+ `simulate --harness dsh` no longer leaves a lens with dsh alone. A harness whose logs could not be read keeps its
54
+ entries. Kept groups keep their picks, and re-selection (`--profile`) and the threshold cap use the options of
55
+ the run each harness comes from (another run's cap may not even fit their grid); the top-level fields (`options`,
56
+ `mode`, `calibration`, ...) are the latest run's. Both files and `engine result` gain `harnesses`: per harness, the
57
+ mode, newest turn and calibration its groups come from (and, in `result.json`, its options). Writes are atomic and serialized by a lock
58
+ file beside each file. `simulate --out` and `demo` still write their own run alone. The lens mod reads Claude Code
59
+ groups only (OpenCode can run the same models) and that harness's calibration age.
60
+
61
+ ### Fixed
62
+ - **The scan cache kept the text of a turn still in progress.** When a log ended with a user message, a tool call or
63
+ its output that no turn had yet, the row's resume state stored them verbatim (Claude Code and Codex). It now keeps
64
+ only what the analysis uses: whether the message corrects the agent, the tool's name and a hash of its key, and the
65
+ output's token count. Resuming gives the same session as a full parse. The cache version is now 6: the first scan
66
+ deletes version 5's files, which could hold such text.
67
+
68
+ ### Added
69
+ - **One calibration or config write at a time, across processes.** `recalibrate`, `engine calibrate`, the runs of
70
+ `serve`, `apply --write`, `retune` and `revert` take `<state-dir>/service/lock` (`flock`, without waiting), so the
71
+ menu bar app, the CLI and a launchd/systemd schedule can start jobs whenever they like. Whoever gets the lock runs;
72
+ the others do nothing and say which job holds it (pid, start time): `engine calibrate` prints the `busy` error (no
73
+ longer reserved), the CLI exits 75 (`EX_TEMPFAIL`), and a scheduled run of `serve` is logged and retried a minute
74
+ later without counting as a failure. The operating system drops the lock when its holder exits or crashes, so there
75
+ is no stale lock. The calibrator re-reads its state under the lock: a calibration another process just made counts
76
+ as the scheduled one, and failures elsewhere back off here too. A dry-run `apply` does not take the lock.
77
+ - **`apply --expect-plan <hash>`.** Every plan prints a hash (`plan <hash>`, `plan_hash` with `--json`) over each
78
+ change's harness, file, key, current value and new value, without timestamps. With `--expect-plan`, `apply` makes
79
+ the plan again under the lock and refuses to write (exit 2, no backup or manifest) unless it is the reviewed one.
80
+ With `--json`, refusals are now JSON on stdout too: `{"error": {"code": "plan_changed" | "busy" | "refused",
81
+ "message": ...}}`, next to the new plan for `plan_changed`.
82
+ - **`compactlab engine`, the JSON interface for the menu bar app** ([docs/ENGINE_API.md](docs/ENGINE_API.md)).
83
+ `hello`, `sessions`, `watch`, `result` and `calibrate` print versioned JSON (`engine_api: 1`) on stdout, errors
84
+ included; examples of every message in `tests/contract/` are checked against the real output. `watch` is a resident
85
+ JSON Lines process driven by `refresh` / `snapshot` / `ping` / `quit` on stdin that lists the active sessions:
86
+ context of the latest request, model, threshold in force and where it comes from, window, and when the prompt
87
+ cache goes cold. It reads only the end of recently written logs with the analysis's own parsers, reading further
88
+ back when Claude Code has appended copies of earlier messages (on 85 real files, including a 109 MB log ending in
89
+ 20 MB of copies, every value matched a full parse), and finds files incrementally; on a 3,200-file history it peaks
90
+ at 32 MB and uses about 1.5% of a core while sessions are being written.
91
+ - Codex subagents whose session names their parent only in `source.subagent.thread_spawn` now get that parent.
92
+ - **OpenCode adapter** (1.x storage). Reads `~/.local/share/opencode/opencode.db` (`$XDG_DATA_HOME`,
93
+ `--opencode-root`) read-only with SQLite's normal locking, so a running OpenCode is never blocked or written to.
94
+ One turn per `step-finish` part, reasoning counted as output, subagents from `session.parent_id`, compactions from
95
+ the `compaction` part and its `summary: true` reply (whose own call is not a turn). Checked on a real 1.19.5
96
+ database: no unknown events, and the parsed token sums equal OpenCode's own per-session totals. The default rule
97
+ is window − min(max output, 32,000); `recommend` prints a per-model `provider.<id>.models.<model>.limit` (OpenCode
98
+ 1.x has no threshold key, and `compaction.reserved` only applies to models whose limit sets `input`) and gives the
99
+ 2.x `compaction.buffer` share in a note. `doctor` counts sessions in the 2.x storage, which is not read yet.
100
+ OpenCode's provider ID is the session's platform for pricing (`anthropic/…` is Anthropic's own API, not
101
+ OpenRouter).
102
+ - **Gemini CLI adapter, experimental** (built from the 0.46/0.70 source; no real log checked yet). Reads
103
+ `~/.gemini/tmp/<project>/chats/*.jsonl` and subagent chats (`$GEMINI_CLI_HOME`, `--gemini-root`), and the older
104
+ single `session-*.json` files. Messages re-written by id are merged, tool-result messages are not prompts, and a
105
+ `<state_snapshot>` summary marks a compression. Default: half the model's token limit (about 524K); `recommend`
106
+ prints `model.compressionThreshold`.
107
+ - **Ratio knobs**: `recommend/units.py` turns a token threshold into a fraction of the window or a share kept free,
108
+ rounding so the trigger never lands above the pick and noting when the window makes a step coarse or when one
109
+ global fraction lands elsewhere for another model. dsh's `thresholdRatio` uses it.
110
+ - `simulate` reads the configured threshold for OpenCode (`--opencode-config`) and Gemini CLI (`--gemini-settings`);
111
+ `verify --applied-at` accepts OpenCode (`--model provider/model`) and Gemini CLI changes. `apply` does not write
112
+ either harness's config yet.
113
+ - **Codex gets one decision for its one limit.** `model_auto_compact_token_limit` covers every model, but `recommend`
114
+ printed the pick of the model with the most turns (175k from `gpt-6.1-sol` history), which would also apply to the
115
+ GPT-6.2 models now in use and leave them worse off. The value is now chosen across the Codex models in use, each
116
+ scored at the lower of the value and its own clamp, with the usual tolerance rules; every Codex group, `recommend`,
117
+ `apply` and auto-apply follow that one decision. A model that a newer version of its family took over is left out
118
+ and listed (`gpt-6.1-sol` → `gpt-6.2-sol`).
119
+ - **Keep the current setting when it is within the tolerance.** A profile's pick that would not beat your current
120
+ setting's score by more than the 2% selection tolerance is now **keep current** instead of a change: the pick is
121
+ the largest threshold within 2% of the best, so it could even score slightly worse than a setting already nearer
122
+ the best. `recommend`, `apply` and auto-apply leave such a setting alone, the idle-compaction verdict counts it as
123
+ in force, and the terminal views, report and `share` say why.
124
+ - **Prices, windows and defaults that change over time.** Auto refresh also runs weekly for known models, and every
125
+ price or window a refresh moves is logged (`pricing-changes.json`; recent ones for your models appear in `simulate`
126
+ and `pricing auto status`). A refresh older than the bundled snapshot no longer overrides the bundle's newer rows.
127
+ Each group keeps the price it was replayed with, so loading a saved result after a change says what moved. The
128
+ window is the most common among a group's latest sessions (Codex can change a model's window; a clean switch is
129
+ reported), a Claude Code context beyond the assumed window means the window grew, and threshold compactions landing
130
+ more than 10% from the assumed default are flagged (the harness changed its default, or a setting compactlab cannot
131
+ read is in force). A model no public file lists stops triggering refreshes after 5 tries.
132
+ - **New models and other platforms are priced from the right row.** Model IDs are reduced to the vendor's ID and the
133
+ platform they point at (Bedrock, Vertex, OpenRouter, Azure; Codex sessions record `model_provider`), and a lookup
134
+ says how it matched: the platform's own row, the vendor's list price, a borrowed row from the closest model of the
135
+ same family, or the fallback. Before, `claude-fable-5-2` picked up Fable 5's prices by substring (cache reads 5×
136
+ too high) and every GPT-6 model in Codex got the $3/$15 fallback. `pricing refresh` now keeps every vendor's own
137
+ models (not resellers' re-spelled copies) and each platform's prices under `<platform>:<id>`; `pricing show` gains
138
+ `--platform` and a match column. The bundled snapshot adds Fable 5.2 and the GPT-6 family. Codex parser version 6
139
+ re-reads Codex logs once.
140
+ - **`compactlab pricing auto on|off|status`: opt-in refresh for new models.** When on, `serve` and scheduled runs
141
+ download models.dev (LiteLLM if that fails) when the logs show a model with no price row of its own, at most once a
142
+ day or once an hour for a model the last attempt did not cover. Off by default; `simulate` and the other commands
143
+ stay offline and say which models need it.
144
+ - **`simulate` lists models priced from someone else's row, and Claude Code models with no window of their own** while
145
+ others have one and whose sessions reach it, with the closest configured model's value as a stand-in when the new
146
+ model has under 3 active days of data.
147
+ - **Third-party models in Claude Code** (DeepSeek, Kimi, GLM behind `ANTHROPIC_BASE_URL`) are replayed with the 200K
148
+ window Claude Code assumes for an ID it does not recognize, or `CLAUDE_CODE_MAX_CONTEXT_TOKENS` from settings.json's
149
+ `env` block or the environment. A Claude model missing from the default rules compacts at about 967K when its window
150
+ is 1M. `recommend`, `apply` and auto-apply key `modelSettings` by the canonical Claude name, which also covers
151
+ Bedrock, Vertex and dated IDs (a preauthorization or consent listing either spelling matches), and the current
152
+ setting is read the same way; a `[1m]` variant keeps its own key (`claude-opus-4-6[1m]`), read and written apart
153
+ from the base model's. A Claude Code context
154
+ beyond 200K for an unrecognized ID widens the window to what the logs show (the env var is probably set in a shell
155
+ compactlab does not see).
156
+ - **Claude Code's idle compaction is modelled and gets its own advice.** `idleCompaction` (on by default) summarizes a
157
+ long conversation left idle on the one-hour cache while the cache is still warm, about 55 minutes in, and applies
158
+ the summary on return. The adapter tells these compactions apart (an `auto` boundary an hour or more after the last
159
+ turn that took under 5 s, or `precomputed: true`); they no longer count as the threshold, as compaction wait or as
160
+ the "history" threshold. The replay charges the summary (a cached read and its output), returns you to the smaller
161
+ context, adds the re-discovery after it, and charges summaries for sessions never resumed at the observed rate.
162
+ Whether a gap fires depends on the app and machine, not the context size (124 of 335 eligible gaps in the
163
+ maintainer's logs), so each gap keeps its logged outcome and the rest fire at the group's rate. Groups on the
164
+ one-hour cache are replayed with the setting flipped too; `simulate` prints a keep-on / turn-off verdict over all of
165
+ them (it is one global setting) and `recommend` adds an `idleCompaction` snippet when flipping wins by more than 2%,
166
+ even when no window changes. Main sessions only; the flipped sweep is saved in the result, so re-selecting a saved
167
+ result (`--profile`, `--value-of-time`) updates the verdict too. `CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS` is read from
168
+ settings.json's `env` block or the environment; `verify` uses the same setting.
169
+ - **`verify` counts the compaction requests the logs leave out.** Each compaction's summary request (a cached read of
170
+ the context and the summary output) is not a logged turn; observed cost now adds an estimate, as the replay does.
171
+ Threshold, idle and hand-typed compactions are counted apart, the "setting in effect" check uses threshold
172
+ compactions only, and a role that never reached the threshold gets `untouched` instead of "saved less than
173
+ predicted".
174
+
175
+ ### Fixed
176
+ - `demo` scanned the real OpenCode, Gemini CLI and dsh logs too (only Claude Code and Codex were pointed at the
177
+ synthetic data), so a demo report could show your own models. It now reads only the synthetic logs.
178
+ - Service logging set up twice in one process logged every line twice and kept writing to the first stderr.
179
+ - **Codex: most tool calls were missed.** Current Codex runs commands as `custom_tool_call` (`exec`), which the
180
+ adapter ignored (24,107 calls in 30 days of the maintainer's logs); tool outputs as lists of content blocks are now
181
+ counted by their text, not their JSON (an image's base64 no longer counts as context). Codex writes a response's
182
+ `token_count` after that response's tool has run, so turn latency now runs from the input before the response's
183
+ first output item to its last one (it had been the tool's run time, or zero; an aborted response no longer stretches
184
+ the next turn), and a tool output that arrives before its turn is recorded on that turn instead of the previous
185
+ one. Parser version 5 re-reads Codex logs.
186
+ - **Re-discovery time could explode.** It divided the re-discovered tokens by the median of all tool results; for a
187
+ Codex group whose logged results were ~4 tokens that gave 134 hours of re-discovery in a 39-hour history (+4,826
188
+ min/day). The step is now in the same units as the tokens: the mean re-discovery result with an observed penalty,
189
+ the prior's 2,000 tokens with the prior.
190
+ - **"No action needed" now means the default threshold is never reached.** Idle compactions and the hand-typed
191
+ `/compact` the replay keeps no longer count; `verify`'s predicted threshold compactions leave them out too.
192
+ - **"Change" for a negligible gain.** A profile now keeps the default unless it beats it by more than the 2% selection
193
+ tolerance (by the selection rule the default is as good a choice); the reason says "net gain under 2%".
194
+
195
+ ### Changed
196
+ - **Scan cache is SQLite, one row per log** (`~/.compactlab/cache/scan-v4.sqlite3`), so a background recalibration
197
+ no longer loads and rewrites one big JSON file. A scan reads and writes only the rows of the files it scans, one
198
+ row per transaction (two runs can share the cache; a write that cannot get the lock in 10 s is skipped), streams
199
+ each log line by line, and rebuilds an unchanged file from its session without reading the resume-only state. Same
200
+ rules as before: size, mtime_ns, SHA-1 of the first 4 KiB, resume offset, parser version, a torn last line is
201
+ never consumed, 0600 files in a 0700 directory. New: rows of deleted logs are pruned after each scan in one
202
+ transaction and zeroed in the files (`secure_delete`, then a checkpoint; a prune that cannot delete, or cannot
203
+ erase yet because another run is reading, says so); a corrupt database is rebuilt, and a row of the wrong shape is
204
+ parsed again instead of failing the calibration; the first scan deletes older cache versions (`scan-v1.json` to
205
+ `scan-v3.json`) and never a newer one's; `cache clear` deletes every version; `cache info` shows rows, rows of
206
+ deleted logs, saved results and older or newer versions; `doctor` reports the cache actually in use (it looked for
207
+ `scan-v1.json`). For adapter authors: a parser's `finish()` must now depend only on its session, and an adapter
208
+ that overrides `load()` overrides `fingerprint()` too (see docs/ADDING_A_HARNESS.md).
209
+ - **A calibration with nothing new reuses the last result.** A lite run with the cache keys its result by every log
210
+ it would read (path, parser version, size, mtime_ns, first 4 KiB; OpenCode: the database files and the sessions in
211
+ the window) and by every other input (effective prices, options and the harness settings they read, configured
212
+ thresholds, compactlab's own files, local time rules). When both keys match it returns the saved result without
213
+ decoding a session; the output is byte for byte a full run's, the calibrator still stamps a fresh time and runs
214
+ auto-apply. Zero newly parsed files is not enough on its own (another command may have refreshed the scan cache),
215
+ so the key is the files themselves, taken before the scan. `--no-cache` and deep mode never reuse.
216
+ Measured end to end (`recalibrate`, through publishing result.json and lens.json) on one machine's 30 days of logs
217
+ (3,237 files found, 2,820 in the window; APFS clone, scratch HOME, `/usr/bin/time -l`, CPU time and macOS peak
218
+ memory footprint; the machine was also building Swift, load 8-95, so wall time is given only where load was low):
219
+
220
+ | run | before (JSON cache) | SQLite rows | + result reuse |
221
+ | --- | --- | --- | --- |
222
+ | cold (empty cache) | 115 s CPU, 2.10 GB | 85 s, 0.82 GB | 85 s, 0.78 GB |
223
+ | warm (nothing changed) | 20-23 s, 1.17-1.52 GB (15 s wall) | 19-23 s, 0.75-0.84 GB | 0.5-1.3 s, 56 MB (0.9-3.2 s wall) |
224
+ | incremental (5 logs, 12.8 MB appended) | 31-56 s, 1.17-1.51 GB | 13-23 s, 0.75-0.84 GB | 17-25 s, 0.78-0.84 GB |
225
+
226
+ `engine calibrate` with nothing changed: 0.4-0.8 s wall at load 14, 59 MB. Building the key costs a full run
227
+ 0.6-1.9 s. A run with appended logs still analyses every session, so its peak stays at ~0.8 GB: the sessions
228
+ themselves (mostly the text of user messages), which the next entry removes.
229
+ - **The scan cache and the lite analysis keep no transcript text** (cache version 5; the first run deletes version
230
+ 4's file, which held it). The lite analysis reads text in three places only: whether a user message corrects the
231
+ agent, which tool calls repeat and how long a compaction summary is. Sessions are now kept lean, on disk and in
232
+ memory: a correction flag, tool keys reduced to the tool name and a 96-bit hash (no path or command), summary
233
+ lengths, and no prompts, output snippets or summaries. Only a log's still-unanswered last message waits in the
234
+ cache until its reply. Results are byte for byte the same; deep mode, which reads text, parses the logs itself.
235
+ The correction check runs the regex only on short windows around the words any match must contain: the same
236
+ answer on all 33,288 prompts of the test history, 5x faster. For adapter authors: a resumed parser must not read
237
+ the text of turns or compactions it made before (use `Compaction.set_summary` / `summary_len`).
238
+ Measured end to end (`recalibrate` through publishing result.json and lens.json; same APFS clone of 30 days of
239
+ logs: 3,243 files, 182,160 turns; scratch HOME; `/usr/bin/time -l`; interleaved runs; load 20-32 from Swift builds
240
+ elsewhere, so CPU time):
241
+
242
+ | run | before (result reuse, text in cache) | lean |
243
+ | --- | --- | --- |
244
+ | incremental (5 logs, 12.9 MB appended) | 22.9-25.5 s CPU, 0.80-0.85 GB | 19.0-21.6 s, **189-218 MB** |
245
+ | `engine calibrate`, incremental | 14.8 s, 0.82 GB | 14.7 s, 201 MB |
246
+ | 5 logs rewritten | 23.3-25.8 s, 0.75-0.84 GB | 18.8-20.1 s, 193-209 MB |
247
+ | warm (nothing changed) | 1.35-1.63 s, 56-57 MB | 1.13-1.37 s, 56-59 MB |
248
+ | cold (empty cache) | 168 s (104-148 s in earlier pairs), 0.78-0.88 GB | 132 s, 0.29 GB |
249
+
250
+ Cold CPU is within the load noise: the cold scan step alone, three alternating pairs on the same 600 files, was
251
+ 18.5-23.4 s before and 21.1-23.9 s lean (mean +5%). The lean sessions of that history hold 109 MB instead of 475
252
+ MB, and the cache file is 99 MB instead of 314 MB. result.json and lens.json are identical to before.
253
+ - **Clearer terminal and report wording** (from a review while making the promo video):
254
+ - one verdict line first in `demo` / `simulate` (terminal and plain output) and `top`:
255
+ `→ Opus 5.5 main: set 625k ▼ −22% cost ▲ +3.0 min/day wall-clock`;
256
+ - the action "set" is now "change" (zh 建议改): it reads as advice, not as already applied;
257
+ - time is labelled "wall-clock" (zh 总耗时) everywhere, the net change (added compaction wait minus faster
258
+ turns), so it no longer shares a word with the "time" profile; cost is 成本 in Chinese, not the profile name;
259
+ - keep-default reasons in plain words: `not worth it at $250/h: saves $3.7/day but adds 1.1 min/day of
260
+ wall-clock (= $4.6)`;
261
+ - `top` drops the "◴ – · next –" and "service down" placeholders until something has calibrated or a service
262
+ was set up ("service not running" then), draws the default `┊`, current `╎` and profile `┃` marks differently,
263
+ labels the selected threshold on the axis, keys the `░` saved hatch, and shows "keep default" instead of a
264
+ hatched bar for models that keep it;
265
+ - panel subtitles and `top` show the prompt-cache TTL the replay used for Claude Code (`cache 1 h`).
266
+
267
+ ### Fixed
268
+ - **History copied into a resumed or forked Claude Code log is no longer counted twice.** The new log repeats the
269
+ parent's messages with their original timestamps; the same API call was priced and counted once per copy (in one
270
+ period a third of the turns and a third of the compactions). The earliest session keeps them; later copies drop
271
+ them and report `skipped_inherited`.
272
+ - **The replay keeps your hand-typed `/compact`.** It used to drop every recorded compaction, so the "default"
273
+ baseline assumed you never compact by hand and the estimated saving was credited to the threshold. Now a manual
274
+ `/compact` is replayed at the same place while the replayed context is still at least 70% of the size it was typed
275
+ at (`MANUAL_KEEP`). On a session with 31 manual and 6 automatic compactions the default baseline went from $1,276 to
276
+ $932 against $915 actually logged, and the balanced pick's saving from −31% to −6.5%. The report's single-session
277
+ chart does the same.
278
+ - **Claude Code re-writes old compaction records later in a log.** One long session showed 64 compactions, 37 real.
279
+ They are now read once (by record id), and the re-written summary line is skipped with them.
280
+ - **Hand-typed `/compact` no longer counts as the threshold.** Claude Code logs whether a compaction was `auto` or
281
+ `manual`; compactlab ignored it, so `verify`, `share --verify` and the "historical" replay counted manual ones in
282
+ the observed compactions and the median size at compaction. A user who types `/compact` often saw "already in
283
+ effect" for a threshold that never was (real logs: 2.9 → 0.5 auto compactions per 1k turns before the change).
284
+ The adapter now records `trigger`; unknown (Codex, dsh) still counts as auto; `observed_manual_compactions` is
285
+ reported separately. The scan cache version is 3, so the first run after upgrading re-reads the logs.
286
+ - **Replay model and presentation fixes** (from an independent review of the simulator, selection and report):
287
+ - sessions are grouped by harness, model and role, so one model name under two harnesses is two groups; a session
288
+ that switched models is still replayed with every turn priced at the model that served it (and its logged cost
289
+ likewise);
290
+ - `--max-threshold` below the grid start is an error (`InfeasibleCap`) instead of recommending the last grid point
291
+ above the cap (`50k` used to select `350k`);
292
+ - re-selecting a profile (`--profile`, `--value-of-time`, the service) keeps deep mode's measured recall
293
+ guardrail: the lowered pick and the `deep_recall_below_floor` flag no longer revert to the lite choice;
294
+ - a time model on the prior also uses the prior's re-discovery step; one 600-second sample no longer moves it;
295
+ - re-discovery calibration only uses compactions with a full 20-turn window before and after and no other
296
+ compaction inside (a boundary at turn 10 sliced backwards: constant-repeat work gave rho 0.377, now 0);
297
+ - the report's per-session replay runs on every turn and thins the drawn line afterwards (it stepped through 160
298
+ growth bins and counted 160 compactions against the engine's 266); the session picker lists the group's own
299
+ harness only;
300
+ - the terminal `c` copy and the report's Copy button use the harness's recommender, so a DeepSeek Harness
301
+ threshold copies a `modelPolicies` entry instead of Claude's `modelSettings` JSON.
302
+ - **Config-writing and service safety fixes** (from an independent review of `apply` and `serve`):
303
+ - a running service re-reads and validates the consent file before every auto-apply, so `consent clear` or a
304
+ passed `expires` stops writes without a restart (the reason shows under `last_apply`);
305
+ - backups under `~/.compactlab/backups` are created 0700 / 0600 instead of the process umask;
306
+ - `consent set` stores the settings file as an absolute path, and a stored relative path is refused;
307
+ - Codex `config.toml` edits are string-aware (quoted keys, signed values, `key = ...` lines inside multi-line
308
+ strings) and parsed before writing; invalid TOML or a non-integer value is refused;
309
+ - `max_change_pct` compares with the value in force, including an inherited top-level `autoCompactWindow`, and
310
+ `0` is a real limit;
311
+ - auto-apply picks only grid points within `--max-step`, so rounding can no longer exceed it (960k → 850k);
312
+ - an error in the auto-apply phase (e.g. a malformed settings file) backs off and shows in status instead of
313
+ killing the scheduler thread.
314
+ - **Input parsing, pricing, deep-mode and lens-mod fixes** (from an independent review):
315
+ - a recognized Claude Code or Codex record with a non-numeric, negative or non-finite token count (e.g.
316
+ `"input_tokens":"oops"`) is skipped and counted in `parse_errors` instead of aborting the whole scan;
317
+ - refreshed or overridden prices re-scale the carried 1-hour cache-write and long-context tiers to the new base
318
+ prices, so a refreshed Opus input no longer keeps the old 1-hour write price;
319
+ - `pricing refresh` drops rows with negative, NaN/infinite or non-numeric rates or invalid windows (and fails
320
+ if none are left), and replaces the cached file atomically, so a bad fetch cannot clobber good prices;
321
+ - deep mode: `--budget` now also stops the run as soon as the measured spend after a call exceeds the cap (it
322
+ used to check only the estimate before a call), and the Claude Code executor passes `max_tokens` as
323
+ `CLAUDE_CODE_MAX_OUTPUT_TOKENS`. Codex has no per-call output limit, so there one call can still overshoot;
324
+ - deep mode probes no longer put the expected file path in the question (an empty summary scored 100%): every
325
+ probe asks the same open question, answered once and scored against each file;
326
+ - the Claude Code lens mod re-reads the lens file after every turn, so a recalibration shows up in a running
327
+ session even for the same model.
328
+ - **Cache TTL and write price from the logs.** The replay assumed a 5-minute prompt cache priced at the 5-minute
329
+ write tier, but Claude Code on a subscription caches the main session for 1 hour, billed at 2× the input price.
330
+ The Claude Code parser now keeps each request's 1-hour share (`usage.cache_creation.ephemeral_1h_input_tokens`,
331
+ `Turn.cache_write_1h`); a group whose written tokens are mostly 1-hour is replayed with a 1-hour TTL and the
332
+ 1-hour write price (new `cache_write_1h` price rows for Claude models). Groups record `cache_ttl` and
333
+ `cache_ttl_source`, shown in the CLI notes and the report; the actual cost prices each write at its tier.
334
+ `--cache-ttl` still overrides. On the maintainer's history the balanced pick moved from 550k (−33%) to 625k
335
+ (−22%) for Opus 5.5 and from 575k (−24%) to 650k (−15%) for Sonnet 5.5. Parser version 4 re-parses cached files.
336
+
337
+ ### Added
338
+ - **`verify` for a change made by hand.** `compactlab verify --applied-at WHEN --model M --new 625k [--old N]`
339
+ builds the manifest from what you give (Codex: no `--model`), since `apply` was not used. The output notes that the
340
+ time and old value are yours, and a new `already` verdict says when the sessions before that time already compacted
341
+ near the new threshold (the settings file's modification time is not when a setting took effect).
342
+ - **`share --verify` and schema `compactlab.share/2`.** A record can carry a per-group `verification` block with
343
+ what `verify` found (predicted vs logged cost and compactions per 1k turns, interval, whether the setting was in
344
+ effect, sample sizes). The checker accepts `/1` and `/2`; `aggregate_shares.py` adds the median prediction error.
345
+ - **`compactlab verify`: check a change against the logs.** Splits sessions at the last `apply` (manifest time; `--id`
346
+ for another) and compares, per model and role, logged cost and compactions per 1k turns before vs after, with an
347
+ 80% bootstrap interval over sessions, against a replay of the before sessions at the old and new threshold (no data
348
+ from after) and a replay of the after sessions (shows a changed workload). Reports whether compactions land near
349
+ the new threshold (a setting overridden elsewhere shows as "far"), says "too early" below 3 sessions / 2 active days
350
+ per side, and drops sessions that span the change. Cost only; wall-clock is not verified.
351
+ - **`compactlab share`: an anonymous, opt-in record of the estimated savings.** Writes `compactlab-share.json`
352
+ with, per harness / model / role, the thresholds compared and the estimated change per day (each profile vs the
353
+ harness default and vs your current setting, and your current setting vs the default), plus trust markers
354
+ (history length, time-model source, replay cost over logged cost). Figures are rounded; no session ids, paths,
355
+ timestamps, curves or text; unknown model names become `other`; demo data is refused. `share --check FILE`
356
+ validates a record against an allow-list schema (`compactlab.share/1`). New "Share my estimated savings" issue
357
+ form, a workflow that validates and labels submitted records, and `scripts/aggregate_shares.py` for medians per
358
+ group. Nothing is sent by the tool. See `docs/SHARING.md`.
359
+ - **DeepSeek Harness (`dsh`) adapter, experimental.** Reads `$DSH_HOME/sessions` (default `~/.dsh/sessions`): the
360
+ newest `session[.vN].jsonl[.zstd]` per session, zstd via the standard library on Python 3.14+ or the `zstd`
361
+ command (a torn last frame is dropped), disjoint usage counts, `compaction/*` events (failed ones dropped),
362
+ subagents and seeded forks. Default rule: the lower of 80% of the window and window − 256k output reserve − 65,536
363
+ (727,040 on a 1,048,576 window). `recommend --harness dsh` prints a compaction-basic `modelPolicies` entry
364
+ (`thresholdRatio`, `headroomTokens: 0`, explicit `maxTokens`); `apply` does not write dsh config. DeepSeek
365
+ V4 Flash / Pro pricing rows (off-peak list price). `--dsh-root`; `doctor` reports the zstd decoder. The scan cache
366
+ re-parses changed compressed files instead of resuming them (`Adapter.resumable`, `Adapter.read_records`).
367
+ - docs/ROADMAP.md.
368
+
369
+ ### Changed
370
+ - Install instructions use the GitHub source (`uv tool install git+https://github.com/LemonCANDY42/compactlab`,
371
+ `pipx install git+…`, or `uvx --from git+… compactlab demo`); compactlab is not on PyPI. A test keeps
372
+ PyPI-style install commands out of the docs. The terminal SVGs show the command they ran.
373
+ - **Terminal views.** A stdlib-only renderer (`compactlab.term`: truecolor / 256 / 16 colours, NO_COLOR,
374
+ `--plain`, `--color`, `--unit`, CJK-aware widths 30..200) gives `demo`, `simulate`, `recommend`, `doctor` and `serve`
375
+ a fastfetch-style header and per-model panels (threshold gauge, was/now bars, cost sparkline, profile chips,
376
+ recommendations with keep-default reasons). Piped output keeps the full plain tables.
377
+ - **`compactlab top`.** A live curses view (tree, braille cost/time chart, meters; keys for profile, unit, filter,
378
+ copy, recalibrate, help; mouse; one static frame off a TTY). `serve` writes an endpoint file for it.
379
+ - `docs/assets/demo.svg` and the new `docs/assets/top.svg` are rendered from the real CLI output.
380
+ - `compactlab serve` is quiet: one in-place progress line only on a terminal (cut to its width at a space, so it
381
+ never wraps into extra rows), nothing otherwise; the log says `recalibrating (reason)` and `recalibrated in Ns:
382
+ N files, M cached, K parsed, X groups; next calibration: <time>`, and the next calibration at start.
383
+ - **One percent base.** Overview cards, the chart's Total rows and the sidebar badges all divide the summed change by
384
+ the summed default of the models marked "set" (they disagreed: −21% vs −24% for the same −$185.3/day).
385
+ - **Before / after on the Overview.** Per model, a grey "was" bar (default) with the "now" bar (profile) overlaid,
386
+ the saving hatched green and additions amber, for cost and wall-clock per day; a total row from summed amounts;
387
+ `absolute | each row = 100%` and sort toggles; screen-reader sentences. The model page shows a compact pair.
388
+ A dumbbell style (was ring → now dot, green or amber line) shares everything; default from nine rows up.
389
+ - **Percent first.** Changes lead with their percent of the harness default (cost vs the default's window cost,
390
+ time vs its total wall-clock: the engine's `d_cost_pct` / `d_time_pct`) with the per-day amount secondary, in the
391
+ report (header toggle `% | $`, remembered) and the lens mod (`▼−61% (−$204.8/day)`). lens.json gains `cost_pct` /
392
+ `time_pct`. Totals divide summed amounts by summed defaults; zero references fall back to amounts.
393
+ - **Signed deltas everywhere.** Every change against the default or current setting shows arrow and sign
394
+ (`▼ −$429.3/day`, `▲ +5.8 min`) in the report and the lens mod; absolute figures show neither. Chart tooltip rows
395
+ name their basis (window total vs per-day delta), in English and Chinese.
396
+ - **Report review fixes.** Overview totals count only groups whose action is "set" (keep-default rows greyed, also in
397
+ sidebar badges); one answer line with a Copy button in the sticky bar replaces the money and time KPIs; ▼ saves /
398
+ ▲ adds instead of minus signs, with a key on the chart; chart labels de-overlapped (halos, side away from the
399
+ curve, panel titles at the left, at least four ticks); current setting shown or "no current setting found";
400
+ sessions filtered to the group; per-role no-change reasons; labelled thresholds, session counts and note glyphs;
401
+ phone captions restored; darker-mode contrast; charts refit with a ResizeObserver.
402
+ - **Report layout.** Opens on the model with the largest per-day impact (never one that needs no change). Each
403
+ model page leads with one chart: $/day and min/day vs the default over the threshold axis, session peaks behind,
404
+ the recall-floor zone hatched, marks for default, current and the three profiles, and a draggable cursor with the
405
+ slider under it; then profile cards, KPIs and the table. Sidebar is a tree (harness > family > model, role chips,
406
+ impact badges, search, remembered folds, a collapsed "No change needed" bucket, drawer on phones) with an
407
+ Overview page (per-model bars and a roll-up of recommended settings). Models that never compact get a short
408
+ state and a peak chart instead of $0 cards. Warning triangles only for real guardrail flags. See
409
+ docs/REPORT_UI.md.
410
+ - **Profiles replace tiers.** Three profiles, always computed side by side: `cost` ($10/h of agent time),
411
+ `balanced` (default, $250/h) and `time` ($600/h). `--profile` on simulate / report / recommend / apply / retune
412
+ picks the one to lead with or write; `--value-of-time` overrides its price of time and re-selects from a saved
413
+ result without replaying. `standard` / `headroom`, `--tier`, `--headroom`, `--headroom-cap` and `--view` are gone
414
+ (`--max-threshold` replaces `--headroom-cap`). Result schema 4.
415
+ - Why: with $10/h the old `headroom` pick on real data compacted several times more often than the default and
416
+ added many hours of compaction wait per month.
417
+ - Guardrails: `balanced` never below 40% of the effective max window, `time` never below 50%; both keep added
418
+ compaction wait under 30 min/day vs the default (`--wait-cap`); `cost` warns instead. Recall floor kept.
419
+ - Low-confidence latency fits (fewer than 20 timed compactions, thin turn bins) no longer drive the choice: the
420
+ group uses the pooled harness fit or a pessimistic prior, and says which.
421
+ - "keep default" also when a profile does not beat the default on its own score.
422
+ - Comparisons now include minutes/day, added compaction wait/day and compactions/day, against default and current.
423
+ - Report: profile switch, three profiles side by side with flags, copy panel per profile. CLI/report state that
424
+ costs are list-price estimates and recall is a lite-mode proxy.
425
+ - Report UI: the threshold slider can be dragged continuously (the control bar is built once and updated in place
426
+ instead of being re-rendered on every input event); sticky control bar; slider marks for the three profiles,
427
+ the default and the current setting (click to snap); hover/tap tooltips on the charts (click selects); focus and
428
+ scroll kept across re-renders; copy button feedback and a file:// fallback; 44px touch targets on narrow or
429
+ touch screens; reduced-motion and focus-ring support; no horizontal scroll at 375 / 768 / 1440 px. Regression
430
+ tests run the report in headless Chrome (skipped when Chrome is absent).
431
+ - Report redesign: warm off-white / near-black themes from CSS tokens (system preference plus a manual
432
+ Auto/Light/Dark toggle), one clay accent, hairline borders, a system serif for titles and tabular mono numbers,
433
+ a group sidebar that becomes a top bar on phones, a header with date range, data source and mode, KPI cards,
434
+ calmer charts with direct labels instead of legends, and plain-language callouts for thin data, short histories,
435
+ borrowed time models and guardrail flags (red only when a guardrail is broken). States it is an independent
436
+ open-source tool. Still one offline file; slider, sticky bar, tooltips and a11y behaviour unchanged.
437
+ - Report shows less text: inline SVG icons (coin / scale / clock for the profiles, refresh, shield, calendar),
438
+ delta chips with ▲▼, gauges for recall and for the threshold as a share of the max window, ⓘ and ⚠ icon buttons
439
+ with tooltips (also their accessible names) instead of paragraphs and banners, one language at a time
440
+ (browser language by default), and a one-line footer disclaimer. Tests check every icon is named or hidden.
441
+ - docs/assets adds report-dark.png, report-mobile.png and report-mobile-dark.png.
442
+ - Headless Chrome in tests and `scripts/make_assets.py` runs with `--use-mock-keychain` so it never asks for the
443
+ macOS keychain.
444
+ - Synthetic demo latencies are closer to real logs (compaction ≈ 90 s + 0.4 s per 1k tokens).
445
+
446
+ ### Fixed
447
+ - compactlab-lens: the band wrapped mid-token in narrow terminals (`┃525` / `k`). Rows are now packed to the band's
448
+ real width (`bodyColumns`), counting wide glyphs as two columns, and break only between whole pieces. The compact
449
+ form starts below 60 columns and the two-row form below about 40. The unfolded card follows the same rules, and
450
+ tests cover 30–120 columns in both languages.
451
+
452
+ ### Added
453
+ - **Service mode.** `compactlab serve` is a stdlib-only service that binds loopback only (other binds are refused
454
+ without `--unsafe-bind`) and checks the Host header. It serves the live report, `/api/result`,
455
+ `/api/profile/<name>` and `/api/health`, plus a token-guarded `POST /api/recalibrate`. It recalibrates in lite mode
456
+ every `--every` (s/m/h/d/w or off): incremental scan, single-flight, backoff after failures, lower priority, a
457
+ rotating log, no network.
458
+ - `compactlab recalibrate` (one run).
459
+ - `compactlab schedule print|install|status|uninstall` for launchd and systemd user units. It writes only into the
460
+ user's unit folder, never loads them, and never overwrites a foreign file.
461
+ - `compactlab consent set|show|clear` and `--auto-apply` / `--dry-run`. Auto-apply has minimum history, a low-confidence
462
+ skip, a dead-band and minimum benefit, a 100k max step, a 7-day cooldown, guardrail checks per step and manual-edit
463
+ detection (`notify`, never overwrite). It reuses apply's backup and manifest, adds a change journal, and `revert`
464
+ understands it.
465
+ - The report shows calibration age and next run, a recalibrate button when served, and a drift marker. The lens mod
466
+ shows calibration age (amber when stale). See docs/SERVICE.md.
467
+ - Larger default picks: `balanced` now prices time at $250/h with a 40% minimum window, `time` at $600/h with 50%
468
+ (were $100/h with 25% and $400/h with 35%). The report shows a guardrail that merely moved the pick as an info
469
+ icon instead of a warning; warnings are reserved for flags that need attention.
470
+ - **compactlab-lens**, a Claude Code mod in `mods/compactlab-lens` (with `.claude-plugin/marketplace.json` at the
471
+ repository root). It shows one row above the prompt, expandable, and a pane on desktop: this session's context as a
472
+ dot bar with ticks at the default and the profile threshold, a context-per-turn sparkline (an SVG on desktop),
473
+ $/day and min/day chips vs default and current, compactions so far, a ⚠ when the window in force differs, a
474
+ profile switch that only changes the display, and a button that copies `/autocompact <n>`. It is read only: one
475
+ local file and the engine's own figures, with no network, no model calls and no settings writes. It is an
476
+ independent project, not affiliated with Anthropic. See docs/MOD.md.
477
+ - `simulate --lens-out` (default `~/.compactlab/lens.json`): the small per-model summary the mod reads.
478
+ - **Per-day impact** for every profile of every group, vs the harness default and vs the current setting: USD,
479
+ minutes (compaction wait and turn-speed gain separately) and compactions, per calendar day, per active day and
480
+ per month. In the report (new section, basis switch), in `recommend` (table after the snippets, `impact` in
481
+ `--json`) and in the result (`comparison.<profile>.vs_default.impact`). Groups record `active_days` and `span`.
482
+ - Time dimension: turn-latency and compaction-latency fits from log timestamps, wall-clock per threshold
483
+ (saved by smaller contexts vs added by compactions and re-discovery).
484
+ - Baselines: every profile compared with the harness default (`data/harness_defaults.json`, with sources) and with the
485
+ current configured value; "no action needed" / "keep default"; `apply` skips those.
486
+ - `compactlab recommend`: ready-to-paste settings per harness, scope (global / project / agent), profile and format
487
+ (json / toml / yaml / env / shell), with merge one-liners, evidence and revert hints; `--copy`, `--check`;
488
+ per-adapter recommenders; config facts with sources and verified-on dates in `data/config_knobs.json`;
489
+ "Copy settings" panel in the report.
490
+ - Bilingual output by default: CLI summary and HTML report in Chinese and English (`--lang`, report switch).
491
+
492
+ ### Changed
493
+ - Renamed the opt-in mode `hyper` to `deep`.
494
+
495
+ ### Added (the first working version)
496
+ - Claude Code and Codex adapters with resumable parsers, unknown-event counting and fork/inherited-prefix handling.
497
+ - Incremental on-disk scan cache keyed by size, mtime, head hash and byte offset.
498
+ - Replay simulator: cache read/write/output costs, long-context tiers, cache TTL/idle effects, summary size,
499
+ post-compaction base context, re-discovery penalty calibrated from observed compactions.
500
+ - Two result tiers per model and role: `standard` (optimum) and `headroom` (default).
501
+ - Two modes: `lite` (offline, default) and opt-in `deep` (re-summarize at candidate thresholds, probes, LLM judge,
502
+ estimate + `--yes` + hard `--budget`; Claude Code / Codex executors).
503
+ - Self-contained HTML report: gears, Pareto frontier, cost curves, token distribution, history-vs-replay overlay,
504
+ lite-vs-deep comparison, sessions table.
505
+ - `apply` / `retune` / `revert` with pre-authorization files, backups, manifests and key-level revert for
506
+ Claude Code `modelSettings.<model>.autoCompactWindow` and Codex `model_auto_compact_token_limit`.
507
+ - `doctor`, `pricing show|refresh` (models.dev / LiteLLM), `cache info|clear`, `demo`, `--json` output.
508
+ - Bundled pricing snapshot with source and date; harness format facts with verification status.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 compactlab contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.