Skip to content

chore: remove v0.4.x release artifacts and compress CLAUDE.md - #683

Merged
anshss merged 11 commits into
mainfrom
stale-cleanup
Aug 3, 2026
Merged

anshss merged 11 commits into
mainfrom
stale-cleanup

Conversation

@anshss

@anshss anshss commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Removes stale release artifacts and compresses CLAUDE.md, which had grown to ~181 KB of always-on context.

Stale removal

  • tests/agent-{pre,post}-release-v0.4.x.md (3 files) — per-release checklists pinned to v0.4.0/v0.4.1. The repo is at 0.6.6, and no v0.5.x or v0.6.x checklist was ever authored, so the practice was tried twice in June and abandoned. These are disposable by design; the runners that consume them read agent-pre-release-v<VERSION>.md as a pattern, not a literal path, so both runners still work.
  • tests/results/ (4 timestamped run logs) — records of those same two runs, plus the .gitignore comment explaining why they were committed.
  • A dead citation in tokenjam/core/optimize/README.md to tokenjam-product-strategy.md v3, a document that exists nowhere in the repo (confirmed via git log --all).

Kept: both runners and both manual-* playbooks, which are version-independent.

CLAUDE.md compression

180.9 KB → 156.6 KB (−13%), 544 → 508 lines.

  • Purged measurements. Corpus dollar figures, similarity percentages, a skill-library byte size, a compression ratio, and a threshold value — replaced by the constant names that survive retuning. Per the repo's own standard, the test is presence rather than accuracy: an accurate number in always-on context is a future lie with a delay fuse.
  • Dropped roadmap claims — "next sprint", "not built yet", "currently empty". These read as durable facts and are the first thing to rot when the feature ships.
  • Relocated a ~52-line incident log from the core/optimize/ architecture notes into the workspace's product-state record, collapsing it here to the field contract plus a pointer. past_overspend_usd remains documented as the one canonical dollar field.
  • Compressed four rules (24, 26, 27, 28) by 17–25% each, cutting incident narrative while preserving every directive, symbol name, test name, and lettered sub-case.

Context consolidation

The cache-token aggregation rule (always include both cache_tokens and cache_write_tokens; route alternative-side pricing through calculate_cost rather than a second, lossier pricer) previously lived in the workspace-level context file, where it was the only entry describing this repo's Python internals. It now sits with the core/cost.py entry it governs, merged into that entry rather than added as a separate section.

Restructure: on-demand context instead of always-on

CLAUDE.md loads into every session in this repo. At 508 lines it was 2.5× the documented guidance of "target under 200 lines", and roughly 39.5K tokens of context before a single file was read.

Root is now 187 lines / 22 KB, down from 508 / 158 KB — with no rule lost. The detail moved to where it loads on demand:

Honest accounting — that 22 KB is the root file, not the context bill. Total content across CLAUDE.md plus the rule files fell only about 5%, from 180,866 B to 171,793 B, and to 170,127 B after the glob and compression pass below. Almost all of this PR is relocation, not deletion. The real win is deferred loading: what a session pays is root plus whichever rule files the file it touched actually matches — see the co-fire figures below.

  • .claude/rules/*.md with paths: frontmatter — one topic file per area, carrying both that area's architecture notes and the rules governing it. Each loads only when Claude touches files matching its globs.

One mechanism, not two. An earlier revision of this branch also placed nested CLAUDE.md files in ten source directories; both approaches defer loading the same way, but globs are strictly more expressive than directory boundaries (several rules govern a package and a file outside it, which a directory cannot express), and keeping all agent context in one directory makes it auditable for staleness in a single pass instead of twenty-five. The nested files are gone.

  • Root keeps the 8 rules that genuinely govern every file (1, 7, 9, 14, 20, 23, 24, 25), the package dependency boundary, build/test commands, PR conventions, and an index table mapping every relocated rule number to its file and trigger globs.

Rule numbers are cited from source comments and test files, so nothing was renumbered — deletions leave permanent gaps and every relocated rule keeps its number in its heading.

Three rules were deleted as dead weight: one forbidding hardcoded bullet characters (the CLI does this 42 times in one file, no test enforces it, zero citations), one warning against an install command for a package name that no longer appears anywhere, and one that was a verbatim duplicate of an architecture note. A fourth rule was stated twice in full; one copy is now a pointer.

.gitignore previously excluded .claude/ entirely, which would have left the rule files untracked and invisible to contributors. It now excludes .claude/* while re-including .claude/rules/.

Making the deferral actually defer

Splitting the file only pays off if the globs are disjoint enough that touching one file doesn't drag in every neighbour. They were not. core-architecture.md globbed a bare tokenjam/core/** — a superset of every optimize glob — core-config-pricing.md repeated that same bare glob alongside the two modules it needs, and optimize-architecture.md and optimize-analyzers.md carried byte-identical paths: lists, so neither could ever load without the other. Editing anything under tokenjam/core/optimize/ fired five rule files at once.

  • core-architecture.md now globs the top-level core/*.py modules it documents, plus core/export/** and core/ingest_adapters/**. It no longer matches core/optimize/, core/summarize/, core/rulewrite/ or core/fixes/, which their own files own.
  • core-config-pricing.md drops the bare core/** and keeps core/config.py, core/pricing.py, tokenjam/pricing/models.toml.
  • The identical pair is differentiated rather than merged, because the content genuinely separates: analyzer authoring plus the summarize and rulewrite lifecycles scope to core/optimize/analyzers/**, the registry/runner/cost_proposals modules and those two packages; the package walkthrough and the fix/write-budget/delivery contracts keep core/optimize/**, core/fixes/** and cli/cmd_optimize.py. Editing core/summarize/ no longer drags in the architecture file, and editing the write budget no longer drags in the authoring rules. The existing cross-references between the two files carry a reader across the boundary.

Worst-case co-fire, root included:

Editing Before After
core/optimize/analyzers/*.py 102,234 B 73,589 B
core/optimize/write_budget.py 102,234 B 58,053 B
core/summarize/*.py 102,234 B 37,887 B
core/db.py 63,220 B 52,095 B

Content compression was secondary and modest: core-architecture.md −3.5%, cli-output.md −5.0%. Both fell short of the 20–25% / 10–15% I was aiming for, and the reason is worth stating rather than hiding — these files are symbol-dense reference material where nearly every clause names a module, constant, test or flag, so past a point the only way to keep cutting bytes is to cut facts. What did land structurally: the db.py, cost.py, recommendations.py and framing.py entries interleaved what the module does with the bug that motivated its guard in single unbroken paragraphs, and each is now a description followed by a separate rule block, so the architecture is skimmable without paying for the incident. Two items the repo's own standard bans were removed while in there — a literal budget-ceiling value and a dated product-reframing cite.

Verified by extracting the set of backticked identifiers from both files before and after and diffing: no module path, function, constant, test name, CLI flag, config key, lettered sub-case or rule number was dropped.

Corrections to stale architecture claims

An audit checked ~140 factual claims in the architecture section against the code. Three were wrong, all describing user-facing behavior:

  • /optimize no longer runs analyzers on the request path. The file described ?fast=true as skipping the Trim analyzer and returning skipped_analyzers. In fact fast is accepted and ignored, skipped_analyzers is always empty, and reports are precomputed by a background daemon (boot / interval / rescan). A contributor reading the old text would have built against a request-path analyzer sweep that does not exist.
  • The UI latency rationale ("a 30-day pass is minutes") depended on that claim and fell with it.
  • The zero-install first run was described as rendering quota composition, a statusline preview, and a callout. The command's own docstrings state it carries none of those; quota composition survives only in the --json payload.

A citation to two .specs/ files that do not exist was removed; the claim it supported is still accurate.

Verification

  • import tokenjam clean; 5,070 tests still collect.
  • No rule numbers changed. These are cited from source comments and test files across the repo — one rule has 47 citation sites — so renumbering would silently mis-point every reference. Every rule number in 1–41 except the three deleted ones resolves to a rule that still exists, verified across root and all rule files.
  • An independent adversarial pass diffed the four trimmed rules for lost instructions, symbols, and sub-cases. It found one real loss (a standing prohibition in rule 26 against duplicating the persona map into this file), restored in a follow-up commit. No file paths, functions, constants, test names, or CLI flags were dropped.
  • Every rule file still starts with --- and carries a non-empty paths: key (all 18 checked mechanically). A file with frontmatter but no paths: silently becomes always-on while still looking deferred, which would quietly undo the whole PR.
  • No glob uses brace expansion or a bracket. An over-long brace pattern is used unexpanded and matches nothing, so the rule reads as scoped while never firing.
  • Rule content held up well against the code: of 41 rules, only one named something that no longer holds. The drift was concentrated in the architecture prose instead, which is the category that rots — hence the three corrections above.

anshss and others added 4 commits August 3, 2026 16:40
- Delete v0.4.0 and v0.4.1 per-release test checklists (now at 0.6.6, practice abandoned after v0.4.1)
- Remove tests/results/ directory containing 4 timestamped run logs
- Drop .gitignore comment explaining committed test logs (no longer applicable)
- Strip dead citation to tokenjam-product-strategy.md from optimize README

Co-Authored-By: Claude <[email protected]>
…p claims

CLAUDE.md is always-on context: auto-loaded into every session and trusted
without re-verification, so a measurement or a state assertion placed there is
a future lie with a delay fuse. This pass applies that standard to the file.

- Purge measurements while keeping the mechanism they motivated: the CWD-delta
  and isolated-HOME dollar figures in the ambient-environment rule, the SGR
  code count in the terminal-output rule, and the pinned assertion string in
  the test-enforcing-the-defect rule (the test file is its own source of truth).
- Drop forward-looking state assertions, which are banned regardless of
  accuracy: the policy/pricing "not built yet" and "next sprint" notes and the
  "currently empty" claim about the internal specs directory. The instructions
  they were attached to are kept.
- Collapse the core/optimize/ Key Modules bullet from a 52-line incident log to
  16 lines. The dollar-field contract keeps its canonical field, its two
  companion fields, the retired names and the one-rollup rule; the surrounding
  rules keep every do/don't and every enumerated check, with the incident
  narrative behind each cut to a clause. The evidence, the per-analyzer
  verdicts and the mixed-basis history now live in the product-state analyzer
  matrix, which is where a measurement belongs.
- Compress the reachability, persona-gating, disjoint-spans and same-events
  rules on the same principle: principle and instructions in full, story in a
  clause.

No Critical Rule was renumbered, reordered or removed — the numbers are cited
from source comments and test files across the repo, and the 1-41 sequence is
byte-identical before and after.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Restore the prohibition that `which personas have a key` is a question for
PERSONA_DISABLED_ANALYZERS' own documentation in runner.py, not for CLAUDE.md.
This clause was trimmed in an earlier compression pass and must not drift
away again—it keeps CLAUDE.md as a rule file, not a second source of truth
for a map that evolves with each analyzer's gate.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@anshss
anshss requested a review from anilmurty as a code owner August 3, 2026 12:17
@greptile-apps

greptile-apps Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR reduces always-on contributor context by moving path-specific guidance from CLAUDE.md into scoped .claude/rules files and removes obsolete v0.4.x release artifacts.

  • Reorganizes repository guidance into 18 path-scoped rule files while retaining global rules at the root.
  • Updates .gitignore so scoped rule files remain tracked.
  • Removes abandoned release checklists, historical result logs, and a dead optimize-documentation citation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
CLAUDE.md Condenses the root guidance and replaces relocated details with a scoped-rule index.
.gitignore Continues ignoring transient .claude content while explicitly tracking .claude/rules.
.claude/rules/core-architecture.md Adds path-scoped core architecture, storage, accounting, and dependency-boundary guidance.
.claude/rules/cli-output.md Adds path-scoped CLI architecture and terminal-output guidance.
.claude/rules/optimize-analyzers.md Adds path-scoped analyzer contracts and implementation guidance.
.claude/rules/optimize-cost-figures.md Adds path-scoped rules for optimization cost proposals and monetary-field handling.
tokenjam/core/optimize/README.md Removes a citation to a nonexistent strategy document.

Reviews (5): Last reviewed commit: "docs(claude): point the rules index at t..." | Re-trigger Greptile

anshss and others added 7 commits August 3, 2026 18:08
…t.py entry

The meta-repo's root CLAUDE.md carried a cross-repo section about cache token
types in aggregates, which is entirely Python-side detail (DuckDB SQL, the
optimize runner, calculate_cost) and belongs beside the cache-read vs
cache-write contract already documented on the core/cost.py bullet.

Merged rather than appended, so the two halves of the rule sit with the fields
they govern: both cache classes on both sides of every token SUM, and both on
both sides of any actual-vs-alternative price comparison, with one pricer
(calculate_cost) instead of a per-analyzer alt-price helper. Incident history
dropped; the grep hint and the mechanism are kept.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The root CLAUDE.md had grown to 508 lines / ~158K chars of always-on context,
re-sent in full on every turn of every session in this repo. Most of it governs
one directory or one file class and is dead weight for a session that never
touches that area.

Split by load semantics rather than by topic:

- Per-directory `CLAUDE.md` files (core, core/optimize, core/summarize,
  core/rulewrite, sdk, otel, api, cli, ui, mcp) carry the architecture detail.
  A nested CLAUDE.md loads only when Claude reads files in that directory.
- `.claude/rules/*.md` carry the path-scoped Critical Rules, each with `paths:`
  frontmatter so the rule loads only when a matching file is touched. Every
  rule keeps its ORIGINAL NUMBER in its heading, because source comments and
  tests cite rules by number.
- Root keeps only what governs every file: project overview, build/test
  commands, the package dependency boundary, PR/commit conventions, the eight
  genuinely global Critical Rules (1, 7, 9, 14, 20, 23, 24, 25), and an index
  naming which rule numbers live in which file behind which glob.

Imports (`@path`) were deliberately not used: they load eagerly at launch and
would have saved nothing.

Three stale claims corrected against the source while moving them:

- The `/optimize` route no longer skips anything on `?fast=true`. No analyzer
  runs on any request path; reports are precomputed by a background daemon
  (boot / interval / rescan) via `core/optimize/report_store.py` +
  `scan_cycle.py`. `fast` and `skipped_analyzers` survive for wire back-compat.
- The Lens hero-stat rationale no longer claims a 30-day `/optimize` pass takes
  minutes (it depended on the above). The hero still has its own fetch, for the
  reason that survives: it must not wait on the triage band's slowest member.
- The zero-install first-run screen renders three beats — what tj read, one
  avoidable-dollars sentence, and the onboard pointer. It carries no quota
  composition and no statusline preview; those survive only in `--json`.

Also dropped a citation to two `.specs/` files that do not exist (the claim
they supported, the negative-A/B removal of output_cap, is kept).

Three rules deleted as dead letters, their numbers permanently retired so
nothing renumbers: 6 (never hardcode a unicode bullet — unenforced and already
violated widely), 13 (never write `pip install ocw` — zero remaining
occurrences, correct install command is in the overview), 17 (verbatim
duplicate of the `otel/otlp_parsing.py` architecture note, folded into it).

`.gitignore` had `.claude/` excluded wholesale, which would have made the
relocated rules invisible to every fresh clone. Narrowed to `.claude/*` with
`!.claude/rules/` so local settings stay private while the rules ship.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A prior pass split the root CLAUDE.md into two deferred-loading mechanisms at
once: per-directory CLAUDE.md files that load when Claude reads that directory,
and .claude/rules/*.md carrying paths: globs. That is one mechanism too many.
Globs are strictly more expressive than a directory boundary, .claude/rules/
keeps all agent context in one auditable place, and scattering Claude-specific
files through the source tree is noise for everyone reading the package.

Each area now has one topic file carrying both its architecture notes and the
Critical Rules governing it, so a session touching core/optimize/ gets the
package walkthrough and the analyzer rules from the same trigger. Content moved
verbatim; every glob covers at least what the directory boundary covered.

api/ + mcp/ -> rules/api.md · cli/ -> rules/cli-output.md · ui/ ->
rules/web-ui.md · sdk/ -> rules/sdk.md · otel/ -> rules/otel.md ·
core/summarize/ + core/rulewrite/ -> rules/optimize-analyzers.md ·
core/ -> new rules/core-architecture.md + rules/core-config-pricing.md ·
core/optimize/ -> new rules/optimize-architecture.md.

The Critical Rule numbers are unchanged (1-41 less the retired 6, 13, 17), and
the root index table now covers the architecture topics too so any relocated
content is findable from root. Only cross-references that would have dangled
were rewritten.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ze lane

core-architecture.md globbed a bare tokenjam/core/**, a superset of every
optimize glob, so editing any analyzer pulled the whole core domain layer in
alongside it. Scope it to the modules it actually documents plus export/ and
ingest_adapters/, and drop the redundant bare core/** from
core-config-pricing.md, which only needs config.py, pricing.py and the
packaged pricing table.

Co-Authored-By: Claude <[email protected]>
optimize-architecture.md and optimize-analyzers.md carried byte-identical
paths: lists, so neither could ever load without the other and the split
bought nothing. Analyzer authoring plus the summarize and rulewrite
lifecycles now scope to analyzers/, the registry/runner/cost_proposals
modules and those two packages; the package walkthrough and the fix
contracts keep optimize/**, fixes/** and cmd_optimize.py. Editing
core/summarize/ or core/rulewrite/ no longer drags in the architecture file,
and editing the write budget or cost-apply machinery no longer drags in the
authoring rules.

Co-Authored-By: Claude <[email protected]>
…ative padding

In core-architecture.md the db.py, cost.py, recommendations.py and framing.py
entries interleaved what the module does with the bug that motivated its
guard, in single paragraphs a reader had to consume whole. Each is now a
description followed by a separate rule/incident block, so the architecture
is skimmable without paying for the incident.

Also removes content the repo's own standard bans from these files: a
literal budget-ceiling value and a dated product-reframing cite. No
directive, symbol, module path, constant, test name, CLI flag, config key or
rule number was dropped.

Co-Authored-By: Claude <[email protected]>
The index described core-architecture.md and core-config-pricing.md as
loading on all of tokenjam/core/**, and optimize-analyzers.md as sharing
optimize-architecture.md's globs. All three are now narrower. Rule numbers
are untouched.

Co-Authored-By: Claude <[email protected]>
@anshss
anshss merged commit e973ec4 into main Aug 3, 2026
6 checks passed
@anilmurty
anilmurty deleted the stale-cleanup branch September 18, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant