Pulse/internal
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
..
actionplanner Fail closed dry-run action execution 2026-05-05 09:22:04 +01:00
agentexec Align Patrol prober with agent command policy 2026-05-01 20:28:11 +01:00
agenttls Add fingerprint-pinned TLS mode for unified agent 2026-04-22 01:36:46 +01:00
agentupdate Harden unified agent runtime and installer 2026-04-23 23:04:18 +01:00
ai Bound patrol-main session at 200 messages to stop unbounded disk growth 2026-05-10 23:19:08 +01:00
alerts Skip agent-sourced alerts in node-presence cleanup 2026-05-10 23:12:31 +01:00
api Record user-chat token usage to the cost ledger 2026-05-10 23:15:53 +01:00
bootstrap
cloudcp Remove monitored-system volume caps 2026-05-05 12:59:59 +01:00
config Keep direct DeepSeek Patrol models selectable 2026-05-08 11:57:04 +01:00
crypto Harden secure local key file handling 2026-04-22 05:13:01 +01:00
deploy Remove monitored-system volume caps 2026-05-05 12:59:59 +01:00
discovery
dockeragent Allow insecure dev HTTP agent runtime URLs 2026-04-23 13:48:54 +01:00
hostagent Fix PVE version detection on agent hosts 2026-05-08 15:30:08 +01:00
hosted Canonicalize legacy hosted signup principals 2026-05-04 22:52:00 +01:00
hostmetrics
kubernetesagent Allow insecure dev HTTP agent runtime URLs 2026-04-23 13:48:54 +01:00
license Remove monitored-system volume caps 2026-05-05 12:59:59 +01:00
logging Stabilize backend race tests for v6 RC publish 2026-04-11 22:46:34 +01:00
metrics
mock Drive agent host profiles from platform manifest 2026-05-07 23:42:15 +01:00
mockmode Gate release mock fixtures behind demo entitlement 2026-04-10 12:33:57 +01:00
mockmodel Sharpen mock summary isolation and role shaping 2026-04-01 12:21:36 +01:00
mockruntime Gate release mock fixtures behind demo entitlement 2026-04-10 12:33:57 +01:00
models Fix platform identity source contracts 2026-05-08 14:54:08 +01:00
monitoring Mark failed PBS poll as failure and lock down with regression tests 2026-05-08 19:53:03 +01:00
notifications Fix notification queue race test 2026-05-01 22:26:01 +01:00
platformsupport Show platform versions in system badges 2026-05-08 15:07:09 +01:00
recovery fix(recovery): preserve canonical pbs guest continuity 2026-03-29 11:38:35 +01:00
relay Fix RC3 backend release blockers 2026-05-01 21:36:28 +01:00
remoteconfig Allow insecure dev HTTP agent runtime URLs 2026-04-23 13:48:54 +01:00
repoctl Retire product upgrade metrics runtime 2026-04-30 12:24:22 +01:00
securityutil Allow insecure dev HTTP agent runtime URLs 2026-04-23 13:48:54 +01:00
sensors
servicediscovery Fix silent fingerprint loss for LXC and VMs 2026-05-10 20:31:46 +01:00
ssh/knownhosts
storagehealth Fix Unraid storage health explanations 2026-05-08 12:18:09 +01:00
system
telemetry Canonicalize usage-data telemetry reporting 2026-04-14 11:05:10 +01:00
testutil Stabilize rc1 mock mode and metrics history 2026-04-11 16:47:37 +01:00
truenas Curate demo-facing mock data across platform views 2026-03-31 18:05:55 +01:00
unifiedresources Merge duplicate map keys in TestActionExecutionContractStaysAPIOwned 2026-05-09 15:08:51 +01:00
updates Verify SSHSIG on in-app update artifacts 2026-05-09 23:14:07 +01:00
updatesignature Fix v6 demo release signing key deployment 2026-05-05 21:40:14 +01:00
utils Canonicalize ago duration formatting 2026-03-19 03:07:56 +00:00
vmware Curate demo-facing mock data across platform views 2026-03-31 18:05:55 +01:00
websocket Fix RC3 backend release blockers 2026-05-01 21:36:28 +01:00