Skip to main content

Module record

Module record 

Source
Expand description

The record: AgentMux’s own size over weeks, kept on this computer (docs/specs/SPEC_LONG_RUNNING_ZERO_DEGRADATION_2026_11_16.md §6, task #47820 phase 1).

A leak that takes weeks to show can only be found from a record kept that long, and Tower’s memory ledger (tower::memory_ledger) forgets after an hour and a restart. Every five minutes the sample Tower already takes for the ledger is also written here as one JSON line in a file for its day, with the machine’s totals, AgentMux’s parts and its largest rows. Raw days are kept for KEEP_DAYS, oldest first out, and the whole record has a size budget (MAX_BYTES). Each finished hour is also folded into one rollup line (min, median, p95 and max of each figure) in a file for its month, kept for a year (ROLLUP_KEEP_DAYS) within its own budget (ROLLUP_MAX_BYTES): slow growth over months is read from those.

Nothing leaves the computer, and a line holds numbers and stable keys only (core, agent:<block>, np:claude.exe, renderer:window:<hash>): no text, titles or paths. A renderer’s own key is made of its window’s or page’s name, so a line keeps its kind and a hash of it instead.

Structs§

AgentMuxLine
AgentMux’s own processes at the time of a sample.
Inventory
What the record holds on disk.
MachineLine
The machine’s totals at the time of a sample.
PageLine
What one window’s page held when it last reported (record.page, every five minutes): numbers and the window’s own label (main, window-3), never a title or a path.
PageRoll
One window’s page over an hour: JS heap (MB), elements and mounted rows.
PartLine
One of AgentMux’s four parts, or one of its largest rows.
Record
Where the lines go, and when.
Rollup
One finished hour of lines folded into one.
Sample
One line of a day’s file.
Stat
min, median, p95 and max of a figure over an hour.

Constants§

EVERY_MS
The gap between lines.
KEEP_DAYS
Raw days kept.
MAX_BYTES
The record’s own budget: past it, the oldest days go first (never today’s).
ROLLUP_KEEP_DAYS
Hourly rollups kept: a year, and a month’s file goes whole.
ROLLUP_MAX_BYTES
The rollups’ own budget (a year is about 10 MB), so the record as a whole stays under 40 MB.

Functions§

compact
A snapshot as one line. disk is the record’s drive; up_s how long srv has run.
day_of
2026-11-16 for a time in ms since the epoch (UTC).
default_dir
Where this AgentMux keeps its record: the record folder of its channel, which an upgrade keeps.
events_to_remove
The events files to delete: a month that ended more than keep_days before today.
files_to_remove
The day files to delete, given what is on disk as (file name, bytes): those older than KEEP_DAYS before today, then the oldest of what is left while the total is over max_bytes. Today’s file is never listed.
inventory
The files of dir, counted and sized.
note_page
A window’s page reported: kept until it reports again, and written into the next line of the record. A label is cut to what an id holds; a window that reports more than [MAX_PAGES] windows’ worth is ignored.
pages_at
The pages that reported in the last [PAGE_FRESH_MS], by label.
read_events
The events of the months that overlap from_ms to to_ms taken in that window, newest limit in time order, and how many the window holds. Each is the line as written: t, kind and numbers.
read_raw
The last limit lines taken from from_ms to to_ms, in time order, and how many lines the window holds in all.
read_rollups
The last limit hourly rollups of the hours that start from from_ms to to_ms, in time order, and how many the window holds in all.
rollup
The hour starting at hour as one line, from its lines (in time order). None for no lines.
rollups_to_remove
The rollup files to delete: a month that ended more than keep_days before today, then the oldest of what is left while the total is over max_bytes. The month of today is never listed.