Repository navigation
feat(#44): store self-metrics — row bytes, rows/day, capture lag p50/p95, dead weight - #99
Merged
Merged
Conversation
abogartz
force-pushed
the
feat/hits-log
branch
from
October 25, 2026 19:45
54e7718 to
e8dc708
Compare
abogartz
force-pushed
the
feat/status-self-metrics
branch
from
October 25, 2026 19:46
f454d4e to
0c5786e
Compare
…d weight A store that cannot describe itself cannot be maintained. memory_status and the /memory panel now answer four questions nobody could answer before: - what a row costs: total store bytes and per-row average, measured over the rendered row (the number that matters is what retrieval has to carry). - how fast it grows: rows/day over the trailing 30d, per ACTIVE day, so a store idle for three weeks does not report "0.1 rows/day" as if it were a trend. - how stale a capture is: capture_lag evidence (lag from the newest transcript message to the moment the capture model was asked) rendered as p50/p95. A capture with no observed message time contributes no lag rather than an invented 0 ms — that would make every session look instant. - how much of the store never gets used (the #42 ledger's dead-weight number, carried into the same STORE section as the count and share). Everything here is reported, never acted on. Retirement, decay and consolidation remain explicit decisions. Test: test/metrics.test.ts (percentile nearest-rank; rowsPerDay active-day math and window edges; capture_lag window filter; lagSince timestamp tolerance — "yesterday" must not become 0 ms), test/metrics-tool.test.ts (the shipped memory_status tool renders bytes, rows/day, lag and dead weight together). ticket: #44
abogartz
force-pushed
the
feat/status-self-metrics
branch
from
October 25, 2026 20:00
0c5786e to
6d1858b
Compare
|
🎉 This PR is included in version 0.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #44
Part of #84. Depends on: the stack merges in order — #96 → #97 → #98 → this PR → #45. Base is
feat/hits-logbecause the dead-weight number this PR renders is produced by #42's ledger.What this does
Makes the store able to describe itself.
memory_statusand the/memorypanel now carry, next to the row counts that were already there:stat()says about a filecapture_lagevidence line: newest transcript message → the instant the capture model was askedNothing here acts. Retirement, decay and consolidation stay explicit decisions; a metric that quietly deleted rows would be the worst possible thing in this PR.
The lag semantics
lagSince()takes the newest timestamp it can find in a session context (time.updated,createdAt,created,timestamp; numbers or ISO strings). A capture with no parseable message time records no lag at all rather thanlag=0: inventing zero would pull p50 toward "instant" and hide exactly the staleness the ticket asks about. The percentile is nearest-rank over the trailing 30 days, and lines outside the window are ignored.Tests
test/metrics.test.ts— percentile is nearest-rank and returns no answer for empty input;rowsPerDaycounts active days (3 rows over 2 days = 1.5), ignores rows outside the window, and says "no evidence" rather than 0 for an idle store;captureLagfilters by window and by event;lagSincetolerates missing/garbage timestamps —"yesterday"must not become0 ms.test/metrics-tool.test.ts— the shippedmemory_statustool renders all four numbers together against a real store: bytes and per-row average present,rows/day (30d)present,capture lag p50 4.2 s / p95 4.2 sfrom one evidence row,never retrieved 2 (100%)before anything has been recalled.tscclean; Biome clean at error level.Review focus
rowsPerDayandcaptureLagboth use ISO string comparison against a 30-day cutoff, androwsPerDaygroups byts.slice(0, 10)(UTC day). Correct for us, but a store with clock-skewed rows across the boundary is doing string math — worth a look.never retrievedis a claim about the ledger's lifetime, not the store's. A row created before the ledger started, or before the last rotation, can look dead when it is merely old. The report shows the number without that qualifier (thesincebound exists inreadLedger()); if you want the qualifier surfaced, say so and I'll add it rather than soften the number.memory_statusnow sums rendered bytes over active rows and reads up to 30 evidence files per call. Fine at current store sizes; it is an O(store) read on a tool call.