Skip to content

fix(stream): rate-limit live-stream rotations to prevent disk thrash - #16

Merged
ChronodeAi merged 2 commits into
mainfrom
fix/live-stream-rotation-cooldown
Aug 25, 2026
Merged

fix(stream): rate-limit live-stream rotations to prevent disk thrash#16
ChronodeAi merged 2 commits into
mainfrom
fix/live-stream-rotation-cooldown

Conversation

@ChronodeAi

Copy link
Copy Markdown
Owner

Second follow-up to #14, found while verifying #15 on the live deployment.

Problem

The engine keeps the full viewer stream in memory and re-materializes it into the fresh file on its first save after a rotation. With the in-memory mirror still over the cap (130 MB history vs 32 MB cap), EVERY subsequent publish rotated again — rename + full ~130 MB rewrite per observation. Verified empirically on the deployed daemon: two observations produced two consecutive generations.

Fix

Rotations are rate-limited to one per 10-minute window (ROTATION_COOLDOWN_MS, injectable nowMs for tests). Disk stays bounded without the storm; the write path remains never-blocked and best-effort.

Also, both deployment-proven:

  • docs/upstream-sync.md: deploy builds use npm ci --legacy-peer-deps (plain npm ci fails on upstream lock drift transitive to @anthropic-ai/claude-agent-sdk).
  • CHANGELOG chronode.5 entry notes the cooldown behavior.

Battery

  • npx vitest run: 1967 passed / 1 skipped (+2 cooldown tests); same 3 known base artifacts.
  • tsc sorted identical to baseline set.
  • Canonical R13 dummy-secrets + RUN_HF_SMOKE=1: R-13 passed (receipt .r13-receipts/1787697755266-0-c80c6888).
  • skills:check green; evidence inventory refreshed.

Post-deploy verification showed the engine keeps the full stream in
memory and re-materializes it into the fresh file on the first save
after a rotation; with the in-memory mirror still over the cap, every
subsequent publish re-rotated ~130MB (rename + full rewrite per
observation). Rotations are now rate-limited to one per 10-minute
window so disk stays bounded without the storm. Also records two
deployment-proven corrections: npm ci needs --legacy-peer-deps on this
lockfile (upstream transitive drift), and the CHANGELOG gains the
cooldown note.
@ChronodeAi
ChronodeAi merged commit 30ebf2f into main Aug 25, 2026
15 of 16 checks passed
@ChronodeAi
ChronodeAi deleted the fix/live-stream-rotation-cooldown branch August 25, 2026 22:49
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