merge: perf/db
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
commit
671874a2c4
22 files changed
+1006
-88
No files matched your search
@@ -527,6 +527,7 @@ export const StorageCleanupTarget = z.enum([
|
||||
"agent_event",
|
||||
"audit",
|
||||
"capability_stats",
|
||||
"pipeline",
|
||||
"identity_pool",
|
||||
"analyze",
|
||||
"images",
|
||||
@@ -555,6 +556,16 @@ export const StorageBudgetUsage = z.object({
|
||||
});
|
||||
export type StorageBudgetUsage = z.infer<typeof StorageBudgetUsage>;
|
||||
|
||||
/** 一条语句的累计统计(pg_stat_statements,参数已归一化为 $n) */
|
||||
export const StatementStat = z.object({
|
||||
query: z.string(),
|
||||
calls: NonNegInt,
|
||||
totalMs: z.number().nonnegative(),
|
||||
meanMs: z.number().nonnegative(),
|
||||
rows: NonNegInt,
|
||||
});
|
||||
export type StatementStat = z.infer<typeof StatementStat>;
|
||||
|
||||
export const SystemStorage = z.object({
|
||||
/** 各项最差档(unknown 不参与) */
|
||||
level: HealthLevel,
|
||||
@@ -577,6 +588,17 @@ export const SystemStorage = z.object({
|
||||
lastAnalyzeAt: Timestamp.nullable(),
|
||||
}),
|
||||
),
|
||||
/**
|
||||
* 语句统计(pg_stat_statements):enabled=false 时 note 说明原因(没装扩展 / postgres 没预加载);
|
||||
* slowest 按平均耗时(调用 ≥ 10 次),frequent 按调用次数,各前 5;since 为统计起点(上次重置)
|
||||
*/
|
||||
statements: z.object({
|
||||
enabled: z.boolean(),
|
||||
note: z.string().nullable(),
|
||||
since: Timestamp.nullable(),
|
||||
slowest: z.array(StatementStat),
|
||||
frequent: z.array(StatementStat),
|
||||
}),
|
||||
}),
|
||||
/** PG kv_cache 各 region(条数含未清理的过期行) */
|
||||
kvCache: z.array(z.object({ region: z.string(), entries: NonNegInt, expired: NonNegInt, bytes: NonNegInt })),
|
||||
|
||||
@@ -559,6 +559,17 @@ export const StorageRetentionDays = z.object({
|
||||
capabilityStats: Days,
|
||||
/** 待识别池 unmatched 条目无新证据多少天后归档 */
|
||||
identityPoolArchive: Days,
|
||||
// ── 2026-10-06 数据库清理(docs/runbook/storage.md「保留规则」);旧库缺这些字段时按缺省补 ──
|
||||
/** 已结束的引擎 run(步骤级联)、运行元数据 / 事实 / 信号;仍被保留中的业务任务引用的跟随任务 */
|
||||
engineRun: Days,
|
||||
/** 已投递的 outbox 事件(只删无幂等键或一次性 / 带时间槽的幂等键) */
|
||||
outboxEvent: Days,
|
||||
/** 识别尝试记录;每条资源至少保留最近 3 次 */
|
||||
resolutionAttempt: Days,
|
||||
/** 已识别(资源已绑定作品)的待识别池条目;忽略、归档的不删 */
|
||||
identityResolved: Days,
|
||||
/** 站点列表快照;每个站点最近一次成功的保留 */
|
||||
siteSnapshot: Days,
|
||||
});
|
||||
export type StorageRetentionDays = z.infer<typeof StorageRetentionDays>;
|
||||
|
||||
@@ -612,6 +623,11 @@ export const DEFAULT_STORAGE_SETTINGS: StorageSettings = {
|
||||
audit: 180,
|
||||
capabilityStats: 90,
|
||||
identityPoolArchive: 30,
|
||||
engineRun: 14,
|
||||
outboxEvent: 30,
|
||||
resolutionAttempt: 30,
|
||||
identityResolved: 60,
|
||||
siteSnapshot: 30,
|
||||
},
|
||||
cacheTtl: {
|
||||
tmdbSearchDays: 7,
|
||||
|
||||
Reference in new issue
Block a user