# 071 - Token and Velocity Diet ## User Story As the operator, I want the skills, their hooks and the hub to cost fewer tokens and less time per call, so that every agent works cheaper and faster and I can re-measure it on demand. ## Decisions (operator-confirmed 2026-11-27; do not re-litigate) 1. **Source**: the skeptic audit of 2026-11-27 (master db3dee0); every fix here answers one of its rows and is proven by the same measurement before and after. 2. **All four bundles** (operator), in this order: output diet, hook speed, hub speed, context diet. 3. **Commit chain slimmed, names kept** (operator): kvb-code-clean, kvb-check-legal, kvb-check-score, kvb-check-break-risk, kvb-git-diff, kvb-check-confidence and kvb-code-scope-guard keep their names and triggers; each keeps its steps, details move to reference files read on demand, and repeated rules move to one shared file. Rejected: one merged pre-commit skill (every agent's commit flow would change at once). 4. **Bench in kvb-check-efficiency** (operator): `scripts/overhead.py` measures hook latency, script output bytes and hub poll cost; kvb-skill-silence, kvb-code-tune and kvb-optimize run it. Rejected: a new skill name (kvb-optimize already orchestrates both levers). 5. **Behaviour stays**: every guard keeps refusing what it refused; only output size, process count and parse work shrink. ## Approach ```mermaid flowchart TD subgraph P["๐Ÿงญ 0 ยท Preparation"] P1["๐Ÿ“‹ Audit picks"] --> P2{"โœ… Operator approves?"} P2 -- "โœ๏ธ corrections" --> P1 end P2 -- "๐Ÿค– yes" --> A1 subgraph A["โœ‚๏ธ A ยท Output diet"] A1["๐Ÿ“ป Radio summary, receipts, clips"] --> A2["๐Ÿงช Make test quiet, TSV listings"] A2 --> A3{"๐Ÿ“ Bytes before vs after?"} A3 -- "๐Ÿ”ด not smaller: fix" --> A1 end A3 -- "๐ŸŸข smaller" --> B1 subgraph B["โšก B ยท Hook speed"] B1["๐Ÿƒ Fast path, lazy imports"] --> B2{"โฑ๏ธ ms before vs after, guards still refuse?"} B2 -- "๐Ÿ”ด no: fix" --> B1 end B2 -- "๐ŸŸข yes" --> C1 subgraph C["๐Ÿ–ฅ๏ธ C ยท Hub speed"] C1["๐Ÿ—‚๏ธ Names index, state cache, register archive"] --> C2{"โฑ๏ธ Poll cost before vs after?"} C2 -- "๐Ÿ”ด no: fix" --> C1 end C2 -- "๐ŸŸข yes" --> E1 subgraph E["๐Ÿ“š D ยท Context diet"] E1["โœ‚๏ธ Slim commit chain, shared rules, ignore files"] --> E2["๐Ÿ“ Bench overhead.py"] E2 --> E3{"๐Ÿงช Tests and lints green?"} E3 -- "๐Ÿ”ด no: fix" --> E1 end E3 -- "๐ŸŸข yes" --> D1["๐Ÿ Review, commit with operator OK, hand-over"] ``` ## Acceptance Criteria ### Output diet - [ ] `radio.py show --all --since 7d` prints the summary form by default and no `read by` receipt rows; `--full` restores every row. - [ ] One injected hook block holds at most 5 rows of at most 200 characters per channel, then one `+N more` line. - [ ] `make test` prints no per-test line on success and every failure in full. - [ ] `rasci.py show` ends with one `gaps: (show --gaps)` line instead of every gap; `--gaps` lists them one per line. The table format stays, because the gaps line was larger than the 30 rows it followed. ### Hook speed - [ ] `hooks.py pre-bash` on a `git status` event takes at least 40 % less median wall time than before (`overhead.py`), and every refusal case of `tests/test_hooks.py` still refuses. - [ ] Prompt reminders whose schedule row is off exit without starting a Python process. ### Hub speed - [ ] `names.json` drops the repeats of a name flip-flop: a fixture with 30k flip-flop entries shrinks below 60 entries, and the match cards' `born_of`, the renames, aliases, holders and current names stay identical (`test_hub_names`). Keeping only the newest entry per session and source was rejected: it erases the rename history. - [ ] A state build reuses the speech phrasing of unchanged radio rows; on a copy of the live council it takes at most 60 % of its time before. Reusing the whole build while file mtimes hold was rejected: the council files change every few seconds and the build depends on the clock. - [ ] `rasci.py` moves tasks `done` or `stopped` for more than 7 days to `rasci-archive.json`; `get`, `show --all`, `artifacts` and `tools` still list them, and a command naming one brings it back. ### Context diet - [ ] The seven commit-chain SKILL.md files total at most 1,200 words, with names and descriptions' triggers unchanged. - [ ] No skill description exceeds 25 words; `test_lock` budgets pass. - [ ] `.ignore` and `.rgignore` exclude `.worktrees/`, `.state/`, `.agents/`, `.claude/` and `.continue/`. - [ ] `test_queue_hung` patches its hang window to at most 0.2 s. ### Bench - [ ] `kvb-check-efficiency/scripts/overhead.py` prints one line per case (median ms, output bytes) for the hook, radio and register cases; kvb-skill-silence, kvb-code-tune and kvb-optimize name it. ### Tests - Unit: - [ ] The changed scripts' existing test modules plus new cases for the summary default, the injection cap, the names compaction and the archive. - Integration: - [ ] `tests/test_hooks.py` dispatch cases unchanged in outcome. - E2E: - [ ] The hub match and state pages render the same cards after the names compaction (existing `tests/e2e` match spec).