Skip to content

Logs expire on a schedule you can set - #79

Merged
fylorn merged 1 commit into
mainfrom
feat/log-retention
Sep 21, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/log-retention

Conversation

@fylorn

@fylorn fylorn commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Recorder::gc has been written and tested for a while and nothing ever called it, so the request log only ever grew. There was no setting for it either.

Two clocks

A request or response body is tens of KB, and a busy day makes hundreds of MB of them. A row — time, model, usage, amount — is a few hundred bytes, and a quarter of those is tens of MB. One clock for both means either throwing away "what did last month cost" early, or letting the disk pay for bodies.

default
body_days 7
row_days 90
body_max_bytes 2 GB

The size cap is for the weeks that are not typical. What days of retention costs depends on usage, and usage has weeks that run ten times normal; without a ceiling that week fills the disk and the first anyone hears of it is the disk being full. Oldest whole days go first — half a day of records is harder to explain than none ("why is this morning's request empty?"), which is what the blob store already did.

When it runs

Once at startup, then hourly. Only at startup and a machine that stays on never gets to it; only on a timer and a machine shut overnight never does either. Each pass re-reads the config, so changing a limit takes effect on the next pass instead of needing a restart.

What the UI gets

RetentionView carries body_bytes_now alongside the three settings. "2 GB" is a number nobody can judge as tight or loose without seeing what is currently in use.

Tests

That the two clocks are independent (a body past its day count goes while its row stays, and the row goes only when its own count passes); that the size cap bites even when nothing is old enough; that defaults stay out of the config file but a choice does not, and that an unwritten field stays at its default rather than becoming 0 — 0 would tell gc to delete everything; and that a typo in the section is rejected rather than silently ignored, which is the lesson already recorded on Limits.

🤖 Generated with Claude Code

`Recorder::gc` has been written and tested for a while and nothing
ever called it, so the request log only ever grew. There was no
setting either.

Two clocks, because the two things cost three orders of magnitude
apart. A request or response body is tens of KB and a busy day makes
hundreds of MB of them; a row — time, model, usage, amount — is a few
hundred bytes, and a quarter of those is tens of MB. One clock for
both means either throwing away "what did last month cost" early or
letting the disk pay for bodies. Defaults: bodies 7 days, rows 90.

The size cap is for the weeks that are not typical. What days of
retention costs depends on usage, and usage has weeks that run ten
times normal; without a ceiling that week fills the disk and the first
anyone hears of it is the disk being full. Default 2 GB of bodies,
oldest whole days going first.

It runs once at startup and then hourly. Only at startup and a machine
that stays on never gets to it; only on a timer and a machine shut
overnight never does either. Each pass re-reads the config, so changing
a limit takes effect on the next pass rather than needing a restart.

`RetentionView` carries what bodies currently occupy alongside the
settings: "2 GB" is a number nobody can judge without knowing what is
in use.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 63f24af into main Sep 21, 2026
1 check passed
@fylorn
fylorn deleted the feat/log-retention branch September 21, 2026 12:33
This was referenced Sep 21, 2026
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