Files
khosra/scripts/budgets.env
T
Claude Opus 5andbdeshi 7796b0d919 make context a budget the harness enforces
Adopts ideas/token-conservation.md, parked 2026-07-28, plus the disciplines
the human added: read the compressed form first, discover by mechanism,
shrink output at the source, never pay twice for the same bytes.

docs/context-economy.md owns all of it and leads with a floor, because
every cheap failure mode is also a token saving — skipping the owning doc,
guessing a signature, reporting from a diff, thinning a test — and each has
already cost this repo a defect. Frugality is for presentation and
discovery, never for the artifact or the evidence.

Mechanical, not remembered:

- scripts/surface.sh generates docs/surface.md — every top-level
  declaration with its line, 261 lines standing for 3757 of source. The
  pre-commit hook regenerates and stages it, so it cannot be stale, and
  verify.sh compares independently for a clone that never set
  core.hooksPath. The hook refuses a commit with unstaged .go changes,
  since what it generated describes the working tree, not the commit.
- verify.sh --quiet: 48 lines of gate output become 1. The hook uses it.
- CLAUDE_LOC_MAX=150, the only budget billed per turn rather than per read.

Both new gates were watched failing before being kept: a doctored
surface.md, and CLAUDE_LOC_MAX temporarily set to 5.

state.md's inventory loses its LOC column. It had already drifted on six
files (content.go 381→450, render.go 447→454, web.go 206→217, check
216→223, watch 129→137, chrome 105→110) which is what a number written in
two places does; the generated file owns sizes now, the table owns purpose.
The subagent question is recorded there as the one open decision, with the
case for and against written out in the idea file.
2026-08-01 02:16:11 +06:00

30 lines
2.2 KiB
Bash

# Growth budgets. `_MAX` fails verify.sh; `_WARN` prints and moves on.
# Raising a _MAX needs an ADR stating old and new values. Growth requires a signature.
#
# Only whole-system budgets fail. A hard per-file limit is the one gate whose cheapest fix makes the
# code worse — sharding a coherent file into a `_helpers.go` turns it green while creating the package
# CLAUDE.md rule 3.6 bans. Total mass cannot be gamed by moving code between files; file length can.
CORE_LOC_MAX=2800 # cmd/ + internal/{content,render,web} + repo root, non-test .go (ADR-0041)
EXT_LOC_MAX=2000 # internal/ext/ — composition, grows after the core freezes
FILE_LOC_WARN=500 # any single .go file — advisory
FUNC_LOC_WARN=60 # any single function — advisory
DEPS_MAX=6 # total modules in go.mod, direct plus indirect
CLAUDE_LOC_MAX=150 # CLAUDE.md only — the one file billed on every turn (ADR-0053)
# Two ceilings because "the core stops growing after Arc 2" (architecture.md invariant 9) is only an
# invariant if something measures it: post-freeze CORE holds and only EXT rises.
# Costed, not round, and re-costed once (ADR-0041): the first figure covered spine, bundles, queries,
# render, routing and templates (~1200-1800 → 2000) but never budgeted what cmd/ would hold. Adding `check`
# ~250, `new` ~100, `-dev` ~100, change detection ~100 and the page cache ~200 to a core already at 1870
# gives ~2620 → CORE 2800. A second raise is evidence something belongs in internal/ext/, not evidence the
# number is still too small.
# Feeds, sitemap, OpenGraph, shortcodes, image sizing, galleries, paging, indieweb ~900-1200 → EXT
# 2000, deliberately loose since that is where growth belongs. Reaching CORE asks what to delete;
# reaching EXT asks whether a template would have done it — only .go lines count here.
#
# CLAUDE_LOC_MAX is a different kind of budget: every other ceiling here bills once, when someone reads
# the code, while CLAUDE.md is re-sent on every turn of every session. 150 leaves ~20 lines of headroom
# over the current file. Reaching it means moving detail to the doc that owns the topic, never deleting
# a rule to fit — `docs/README.md`'s compression contract governs which of the two you are doing.