feat(P4-004): summarization pipeline — LLM + cron scheduling

Add SummarizationService that reads hot agent logs (>24h), groups by
session, calls a cheap LLM (gpt-4o-mini default, configurable via
SUMMARIZATION_MODEL) to extract key insights, stores them with
embeddings in the insights table, and transitions processed logs to
warm tier. Add CronService with node-cron for scheduled execution
(summarization every 6h, tier management daily at 3am). Tier
management promotes warm→cold (30d) and purges cold logs (90d).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 08:52:52 -05:00
parent 666d2bc36d
commit 1d4916fe97
6 changed files with 247 additions and 2 deletions

17
pnpm-lock.yaml generated
View File

@@ -113,6 +113,9 @@ importers:
fastify:
specifier: ^5.0.0
version: 5.8.2
node-cron:
specifier: ^4.2.1
version: 4.2.1
reflect-metadata:
specifier: ^0.2.0
version: 0.2.2
@@ -129,6 +132,9 @@ importers:
'@types/node':
specifier: ^22.0.0
version: 22.19.15
'@types/node-cron':
specifier: ^3.0.11
version: 3.0.11
'@types/uuid':
specifier: ^10.0.0
version: 10.0.0
@@ -2747,6 +2753,9 @@ packages:
'@types/mysql@2.15.27':
resolution: {integrity: sha512-YfWiV16IY0OeBfBCk8+hXKmdTKrKlwKN1MNKAPBu5JYxLwBEZl7QzeEpGnlZb3VMGJrrGmB84gXiH+ofs/TezA==}
'@types/node-cron@3.0.11':
resolution: {integrity: sha512-0ikrnug3/IyneSHqCBeslAhlK2aBfYek1fGo4bP4QnZPmiqSGRK+Oy7ZMisLWkesffJvQ1cqAcBnJC+8+nxIAg==}
'@types/node@22.19.15':
resolution: {integrity: sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg==}
@@ -4174,6 +4183,10 @@ packages:
sass:
optional: true
node-cron@4.2.1:
resolution: {integrity: sha512-lgimEHPE/QDgFlywTd8yTR61ptugX3Qer29efeyWw2rv259HtGBNn1vZVmp8lB9uo9wC0t/AT4iGqXxia+CJFg==}
engines: {node: '>=6.0.0'}
node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
@@ -7548,6 +7561,8 @@ snapshots:
dependencies:
'@types/node': 22.19.15
'@types/node-cron@3.0.11': {}
'@types/node@22.19.15':
dependencies:
undici-types: 6.21.0
@@ -9001,6 +9016,8 @@ snapshots:
- '@babel/core'
- babel-plugin-macros
node-cron@4.2.1: {}
node-domexception@1.0.0: {}
node-fetch@3.3.2: