Skip to content

docs(claude-md): trim derivable content from always-loaded memory - #30

Merged
mlevkov merged 1 commit into
mainfrom
tech-debt/session-03
Aug 1, 2026
Merged

docs(claude-md): trim derivable content from always-loaded memory#30
mlevkov merged 1 commit into
mainfrom
tech-debt/session-03

Conversation

@mlevkov

@mlevkov mlevkov commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

CLAUDE.md is loaded in full into every session's context, and roughly 75% of it
restated facts that a session can recover from the repo itself — the directory tree,
the dependency list, env-var tables, CI workflow descriptions. This trims it from
824 to 233 lines (~7.7k → ~2.3k estimated tokens per session) while keeping every
non-derivable contract, gotcha, and design rationale.

Documentation-only: no source files are touched.

Type of Change

  • Documentation update

Changes Made

Removed as derivable from the repo:

  • Directory tree and architecture diagram — verbatim ls/find output
  • API endpoint list — src/routes.rs
  • Six env-var tables — every variable and default is defined in src/config.rs
  • Observability stack section — all ports are in docker-compose.yaml
  • Quick-start and test commands — standard cargo invocations, and the hardcoded
    test counts (183/30/18) had already drifted
  • Message format and event types — src/models/event.rs
  • Error-type/status-code list — src/error.rs
  • Dependency list — Cargo.toml
  • CI/CD section — .github/workflows/
  • License — LICENSE
  • The "no unwrap()/expect()" rule — Cargo.toml [lints.clippy] sets
    unwrap_used = "deny" and expect_used = "deny", and CI runs clippy -D warnings,
    so the build enforces it whether or not the doc says so

Compressed to prose, so the contract survives without the copied code:

  • RateLimitError / build_router() startup-failure behavior
  • The enum-variant (never string-match) rule for connection-error detection
  • Shutdown ordering and the Notify-not-polling rationale, with a pointer to
    docs/structured-concurrency.md
  • Middleware invariants: auth meters failures only, fallible RateLimitLayer::new(),
    exact-path bypass
  • RATE_LIMIT_BURST replace-not-add semantics, moved out of the deleted table

Kept verbatim (not recoverable from code — these encode why, not what): Iggy SDK
integration rationale, the TRUSTED_PROXIES security contract, request-timeout contracts,
0-indexed partitions, fuzz-test commands, the log-level convention, middleware order,
and deployment security.

Testing

Documentation-only change; no source files touched, so no tests were added and none were
run locally. Verified instead:

  • Heading hierarchy has no orphaned subsections after the cuts — survivors were promoted a
    level where their parent heading was removed (### Iggy SDK Integration##,
    #### Log Levels###)
  • Code fences balanced (12, even)
  • Every file the trimmed doc now points at exists: src/config.rs, .env.example,
    docs/structured-concurrency.md, docs/README.md
  • Only CLAUDE.md is modified

CI runs the full fmt/clippy/test matrix on this branch regardless.

Checklist

Code Quality

  • Code follows project style guidelines (cargo fmt) — n/a, no source changes
  • No new Clippy warnings — n/a, no source changes
  • Public APIs have documentation comments — n/a, no API changes
  • Error handling is appropriate — n/a, no source changes

Testing

  • Tests cover the happy path / error cases — n/a, no behavior changes
  • All existing tests pass — unaffected; no code paths modified

Documentation

  • CLAUDE.md updated
  • README updated — n/a, no user-facing changes
  • Remaining content explains "why" not "what" — that is the organizing principle of
    the trim

Security

  • No secrets or credentials committed
  • Input validation — n/a, no source changes
  • No new security vulnerabilities introduced — the TRUSTED_PROXIES contract and
    deployment-security guidance were deliberately preserved in full

Related Issues

None.

Additional Notes

On the PR size check: pr.yml warns above 500 changed lines; this is 655
(32 insertions, 623 deletions). It is a pure documentation deletion, so the raw line
count overstates the review surface — the 32 inserted lines are the only new prose.

Reverting any single block: git show <this-commit>^:CLAUDE.md has the original file.

Not included here (proposed but deliberately deferred): moving the Deployment Security
section to a lazily-loaded skill, which would save a further ~370 estimated tokens per
session. It stays inline in this PR.

CLAUDE.md loads in full on every session; roughly 75% of it restated facts a
session can recover from the repo in a few tool calls.

Removed as derivable: directory tree, architecture diagram, API endpoint list,
six env-var tables (defaults live in src/config.rs), the observability stack
section (ports are in docker-compose.yaml), quick-start and test commands
(standard cargo invocations, and the hardcoded test counts had drifted),
message format and event types (src/models/event.rs), the error-type/status
list (src/error.rs), the dependency list (Cargo.toml), CI/CD
(.github/workflows/), and License. The no-unwrap/no-expect rule went too:
Cargo.toml [lints.clippy] already denies it mechanically.

Compressed rather than dropped, so the contracts survive: RateLimitError
startup-failure behavior, the enum-variant (not string-match) rule for
connection errors, shutdown ordering and the Notify-not-polling rationale, and
the middleware invariants (auth meters failures only, fallible
RateLimitLayer::new, exact-path bypass). RATE_LIMIT_BURST's replace-not-add
semantics moved from the cut table into prose.

Kept verbatim: Iggy SDK integration rationale, TRUSTED_PROXIES contract,
request-timeout contracts, 0-indexed partitions, fuzz commands, log levels,
middleware order, deployment security.

824 -> 233 lines (~7.7k -> ~2.3k est. tokens per session).
@mlevkov
mlevkov merged commit e12a513 into main Aug 1, 2026
22 checks passed
mlevkov added a commit that referenced this pull request Aug 1, 2026
…orward

TD-2026-07-09 flips to resolved with a Resolution section covering all six
commits: the state enum and what it deleted, the three leaks and the distinct
mechanism that closes each, the sync lock as a prerequisite rather than a
preference, the observability split, and the surface narrowing.

It also corrects its own deferral note. "The enum refactor is shape-only with
no behavioral delta" held for the enum and for the sync conversion it turned
out to require, but not for the permit -- releasing on drop is a real behavior
change and the only one this TD carried. Left uncorrected, that sentence would
sit directly above a resolution disproving it.

TD-2026-07-08 gains two silences the plan review found that its Problem section
did not name: a rejected header is indistinguishable from an absent one, so the
echo alone cannot close its item 2; and a non-UTF-8 header value is dropped
with no log at all, because the malformed-value warn sits inside the to_str
success branch. Recorded on the TD rather than only in the review artifacts,
since the registry index is what a future session actually reaches. Its
deferral to session 04 is noted with the reason -- the two records were
mis-sequenced, not oversized.

Registry row synced by hand; this repo has no index generator.

README's test count moves 183 -> 191, verified by running the suite rather than
by arithmetic. CLAUDE.md needs no equivalent edit: PR #30 removed the section
that carried counts.
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