beads/docs/reference
Bee ca9f14d65d feat(remember): opt-in memories.budget-chars — refuse a write that crosses the corpus budget (wy-2pox7y)
The wheelhouse-side tripwire only REPORTS the memory-corpus size, so the corpus
re-trips red every few days and nothing has ever stopped the write that crossed
the line. This is the stop.

New config key `memories.budget-chars` (integer, default 0 = OFF), wired exactly
like `prime.max-memory-chars`: recognized in cmd/bd/config.go, routed to yaml in
internal/config YamlOnlyKeys (it is read through viper, so a DB-backed write
would be accepted and then never read), validated non-negative at set time, and
documented in docs/reference/configuration.md.

With the budget ON, `bd remember` measures the corpus as the sum over every
memory of len(key)+len(content) — BYTES, the same unit `bd prime`'s
--max-memory-chars counts in — projected to AFTER the write would apply. An
overwrite replaces that key's old content in the sum rather than adding to it,
so a memory near the ceiling can still be edited.

  - over budget            -> refused, nothing written, exit 1, one line on stderr
  - over budget + --force  -> written, and the crossing is still announced
  - >= 80% and within      -> written, then warned
  - below 80%, or budget 0 -> silent; with the budget off the corpus is not even
                              read, so behavior is byte-identical to before

Every line goes to STDERR, so --json output is never corrupted; a --json refusal
additionally gets the normal machine-readable error object on stdout.

The whole decision is one pure function (rememberBudgetVerdict), which is what
lets the branches be pinned without a database.

Tests run (targeted, never ./...):
  go build ./...                                             rc 0
  go vet ./cmd/bd/ ./internal/config/                        rc 0
  go test ./cmd/bd/ -run 'Memor|Remember|Prime|Budget' -count=1   rc 0
  go test ./internal/config/ -count=1                        rc 0
  BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd/ \
      -run TestEmbeddedMemoryCorpusBudget -count=1 -v        rc 0 (6/6 subtests)
  golangci-lint run --config=.golangci.yml --build-tags=gms_pure_go \
      ./cmd/bd/... ./internal/config/...                     0 issues in touched
                                                             files (one
                                                             pre-existing gosec
                                                             G304 in
                                                             internal/config/permissions_open_nonlinux.go)

New tests: cmd/bd/memory_budget_pure_test.go (byte unit incl. multibyte,
overwrite delta, budget-off silence, config read + negative clamp, the
at-budget/one-over boundary, --force, the 80% warn band and its edges,
unclamped percentage, single-line contract);
cmd/bd/memory_embedded_test.go TestEmbeddedMemoryCorpusBudget (the same five
spec points end to end against a real embedded-Dolt store, through
`bd config set`, asserting the exact stderr lines, the nonzero exit, and that a
refused write leaves the old content intact);
internal/config/yaml_config_test.go validation + yaml-only routing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XmKxqKuXTaKivDiCoBwBV
2026-09-12 16:59:43 -07:00
..
advanced.md docs(events): document the events journal and bd events (bd-opisf) 2026-08-09 01:58:17 +00:00
antivirus.md docs: apply PR #4722 review feedback to user docs 2026-07-12 11:06:57 -07:00
configuration.md feat(remember): opt-in memories.budget-chars — refuse a write that crosses the corpus budget (wy-2pox7y) 2026-09-12 16:59:43 -07:00
events-journal.md feat(events-journal): record the mutating actor on every journal row (#5908) 2026-08-23 13:55:59 -07:00
faq.md docs(troubleshooting): document the two native-Windows integration traps (#5838) 2026-08-20 05:41:39 -07:00
git-integration.md fix: reject incompatible timeout in generated hooks (#5522) 2026-08-10 20:47:53 -07:00
index.md docs(events): document the events journal and bd events (bd-opisf) 2026-08-09 01:58:17 +00:00
json-schema.md docs: re-review and bump the three 90-day-stale freshness markers (#5394) 2026-08-07 02:35:11 -07:00
observability.md refactor(telemetry): adopt standard OTel SDK env vars with BD_OTEL_* back-compat (#3859) 2026-08-03 00:05:06 -07:00
protected-branches.md docs: apply PR #4722 review feedback to user docs 2026-07-12 11:06:57 -07:00
troubleshooting.md docs: pin the Dolt version instead of steering users to releases/latest (ga-m0dlk) (#5899) 2026-08-20 22:41:24 -07:00
worktrees.md docs: apply PR #4722 review feedback to user docs 2026-07-12 11:06:57 -07:00