Pulse/docs/release-control
rcourtman 9f43a22fb1 Bound patrol-main session at 200 messages to stop unbounded disk growth
The patrol-main chat session was reused across every scheduled
Patrol run with no upper bound. After a month of runs the file
had grown to 16 MB / 3,593 messages, and every AddMessage
rewrote the whole file to disk — so the I/O cost per Patrol
run was scaling with total session age, not with the run's own
output. Across all chat sessions on this dev instance, the
ai_sessions directory hit 676 MB / 1,629 files.

The stateless-Patrol-input fix (commit 43760fb0d) stopped
loading the session back into the agentic loop, but Patrol
still wrote each run's messages to the session for the Pulse
Assistant sidebar's forensic view. That write path is what
this commit bounds.

ExecutePatrolStream now calls SessionStore.TrimMessages(200)
after each run, keeping roughly the last two runs' worth of
messages — enough for the sidebar to show recent activity, far
short of unbounded growth. The next Patrol run on a bloated
session will drop the historical 3,000+ messages down to 200
on its first write, so existing storage debt clears on its
own without a separate migration.

User-driven chat sessions are unaffected: TrimMessages with
keepMostRecent <= 0 is a no-op, and callers that want full
history retention simply don't call it. Only Patrol's
forensic session is capped.

The canonical Patrol forensic log is the PatrolRunRecord
history surfaced at /api/ai/patrol/runs — that's the durable
record with structured fields. The chat-session-shaped file
is a sidebar convenience, not the source of truth.

Three tests guard the boundary:
  - TrimMessages keeps the most recent N (50 messages
    trimmed to 10 → messages 40-49 remain)
  - TrimMessages is a no-op below threshold (5 messages,
    cap 200 → 5 messages remain)
  - TrimMessages with non-positive keep is a no-op (3
    messages, cap 0 or -5 → 3 messages remain)

ai-runtime contract updated.
2026-05-10 23:19:08 +01:00
..
internal Clear v6 prerelease-to-GA promotion gate 2026-04-20 16:33:03 +01:00
v6 Bound patrol-main session at 200 messages to stop unbounded disk growth 2026-05-10 23:19:08 +01:00
control_plane.json Capture Pulse Intelligence product direction 2026-05-06 15:56:45 +01:00
control_plane.schema.json Map legacy stable releases in control plane 2026-04-11 13:23:07 +01:00