# Harness token cost — cut standing per-session context waste

outcome: the fixed token cost every session pays (diagnostics spam, startup context blocks, index reads, dispatch briefs, ft rewrites) drops measurably, with every claimed saving computed against the honest baseline (what the harness already truncates/caches for free — the ft-audit correction).
status: ACTIVE
source request: owner 2026-08-15 — ranked six-item briefing on harness-side token sinks; #2 (CLAUDE.md compression) explicitly WITHDRAWN by owner ("skip 2 i dont want to mangle my CLAUDE.md" — recommendations-only instead, plain English, owner reviews).

## Items and lanes

1. Diagnostics spam scoping — INVESTIGATED, owner tradeoff pending: source is Claude Code's built-in LSP feature (typescript-lsp/rust-analyzer-lsp plugins); v2.1.233 offers ONLY per-language on/off — no per-file scoping, no severity floor. Fires in interactive sessions (proven live: another lane's deliberately-broken probe file's errors arrived in the orchestrator session), not in dispatched subagents. Lever: disable the LSP plugins (loses own-edit error catching; typecheck gates still catch at land time) or accept the noise. Owner decision — recorded, not taken. Originally: ACTIVE (sonnet lane): new-diagnostics blocks inject other lanes'/worktrees' TypeScript noise into unrelated sessions repeatedly; scope injection to files the session itself edited, or suppress known-noise classes. Largest unclaimed save observed today.
2. WITHDRAWN by owner. Plain-English recommendations delivered in chat for owner review only; no agent edits CLAUDE.md files.
3. Plan INDEX archive — DONE this landing: 25 DONE/SUPERSEDED rows moved to docs/plans/INDEX-archive.md (greppable, never bulk-loaded); hot INDEX 86→51 rows; INDEX header updated.
4. SessionStart context capping — implementation done, submit pending (sonnet lane, worktree `wt/token-cost-lanes-hooks`): every SessionStart hook wired in `~/.claude/settings.json` measured on a real transcript, then capped. `compact-context-restore.mjs` (source=compact): 17935→2249 bytes additionalContext (2-line narrative summary, unchanged 4096B-capped task block persists inline; full narrative moves to `~/.local/state/overdeck/session-context/compact-context-restore/<session>.md`). `auto-handoff.mjs --announce`: 1504→491 bytes, 12→6 lines (full `renderReport()` persisted to `.../auto-handoff-announce/<slug>-<session>.md`; shared `renderReport` export kept intact for its own test coverage, a new `renderAnnounceSummary` added instead of shrinking it). `agent-session-ledger.mjs`: was unbounded O(N) (2 lines/dead-session, no cap, no persisted file) — now previews top 5 + persists full list to `.../agent-session-ledger/<time>-<pid>.md` (keyed per-run, not a shared `latest.md`, so two racing SessionStarts never overwrite each other's already-emitted pointer); synthetic 20-session case measured at 1152B/14 lines. `dead-advisor-remind.mjs` (595B/8 lines) and `live-transcript-journal.mjs`/`context-mode-cache-heal.mjs`/3 non-Node SessionStart hooks (0 bytes each) needed no change — regression-tested instead. The owner's "12KB block observed today" was not traced to one specific file with certainty; `compact-context-restore.mjs`'s pre-change narrative (`3 × HEAD_PROMPT_CHARS = 12000`, observed 17935B live) is the closest measured match. New gated test `modules/workstation/claude/tests/sessionstart-context-cap.test.sh` (8/8 pass, registered in `tools/ci/constants.mjs`); `hooks/test-compact-context-restore.sh` (86/86) and `tests/session-durability.test.mjs` (41/41, node --test) updated so their existing content assertions read stdout+persisted-file while new assertions pin stdout alone under the byte ceiling; gated `tests/agent-session-ledger.test.sh` (87/87) unaffected. `tools/ci/inventory.mjs --check` is red pre-existing (34 unrelated drifted files, none touched by this item) — not regenerated, out of scope. Next: submit via ship.sh from the worktree.
5. Shared dispatch preamble — DONE this landing: modules/workstation/claude/briefs/lane-preamble.md; orchestrator briefs reference it via the main-checkout path instead of restating the recurring rules per dispatch.
6. ft rewrite narrowing — DONE (landed 8e926172d, deployed, installed-hook verified): git status / grep-family / heredoc+multiline pass through raw; big-output rewrites kept; suite extended. Originally: ACTIVE (sonnet lane): per today's measured audit (86% of claimed savings double-counted vs harness truncation; git-status count corruption; heredoc text mangling; gitignore-blind grep), narrow the rewrite layer to genuinely huge outputs only.

## Constraints

- Honest baseline rule binds every item: savings measured against what the harness already truncates/caches, never against unlimited raw output.
- Owner's CLAUDE.md files are never edited by agents under this plan.

## Receipt

2026-08-15: items 3+5 landed with this commit; lanes for 1, 4, 6 dispatched (sonnet). Next: lane reports → verify → land → measure per-session context delta.
