Repository navigation
Conversation
…che trim, and routing patch queue ## 变更摘要 - 改前: - `LiveLogCache` 维护零生产引用的 `live:sess:active` ZSET 与无上限 `_localActiveSessions` Map(L1),每次 `startRequest` 全量 `O(N)` 扫描 `_localInflight`(L2),`finishRequest` 把最大 64KB 的 `jev_state` 整份写入 Redis recent 桥接(L6),`listLiveAndRecent` 每次轮询无合并直查 Redis 且执行 `ZREMRANGEBYSCORE` 写操作(L9)。 - `PgLogWriter` 超过 `maxPending` 时对每条日志无上限直连 `pool.connect()` 触发连接池雪崩(L3/PG10),单通道把 `usage_logs`/`request_attempts`/`request_log_debug` 拆成 3 次取连接 + 3 个事务(L10/PG10),debug 体积裁剪最多 64 轮全表 `SUM+COUNT` 扫(L5/PG10),`runRetentionCleanupAsync` 遗漏 `request_attempts` 周期清理且 `routing-runtime` 在 PG 启动时主线程同步全表 `DELETE`(PG2),保留零引用 `enqueue()`/`enqueueDebug()`(L12)。 - `RequestLogStore` 对 Gemini 工具续写合并先全量 `flush()` 再走同步读改写(L4),`_windowStatsPgAsync` 使用 8 个标量 `PERCENTILE_CONT` 且跳过租户 `owner_user_id`(PG7),`'ops-window'` SWR 缓存键未包含 `mutedErrorClasses`(P2),含死分支 `isHighConcurrency`(L12),JSONL 镜像每条同步 `mkdirSync`+`appendFileSync`(L13)。 - `routing-runtime.mjs` 的 `persistRoutingPatch` 无并发串行队列且在落盘前原地修改共享 `ctx.routingConfig`(P4)。 - 改后: - `src/lib/cache/live-log-cache.mjs`:删除 `getActiveSessionKeys`/`_localActiveSessions`/`SESS_ACTIVE_ZSET`/`sessionActiveTtlSec`(保留 `getActiveSessionCounts` 与 `_localSessionConc`);`_pruneLocalInflight` 遇首条 `started >= cutoff` 立即 `break`(`O(expired)`);`formatRecentEntry` 按列表白名单剔除 `jev_state`/`advisor_usage`/`image_usage`;`listLiveAndRecent` 按 `(fetchCap, includeRecent, ageLimit)` 增加 1s single-flight 结果复用并节流 `ZREMRANGEBYSCORE`。 - `src/lib/db/pg/pg-log-writer.mjs`:移除无上限 `_directInFlight`/`_dispatchDirectWrite`,改为软上限入队 + 紧急批量 flush(并发严格 `<= concurrency`,保留 `overflowDirect` 计数兼容 `bench-20k`);新增 `mergeToolContinuationInQueue` 原地合并队列中父记录;单通道复用 1 个 `client` + 1 个事务写 `usage_logs` + `request_attempts`(保留 `SET LOCAL synchronous_commit = off` 与 attempts 排序防死锁),`request_log_debug` 包裹在 `SAVEPOINT sp_debug` 隔离失败;`runRetentionCleanupAsync` 改用单次窗口函数 `SUM(OCTET_LENGTH(record_json)) OVER (ORDER BY ts DESC, request_id DESC)` 定位截止 `ts` 后按 `ctid` 分批删,并在同把 advisory lock 内新增第 5 步 `request_attempts` `ctid` 分批清理;删除零引用 `enqueue()`/`enqueueDebug()`(保留 `USAGE_LOG_COLUMNS`/`usageLogToRow` 签名)。 - `src/lib/admin/request-log.mjs`:Gemini 续写合并优先调 `pgWriter.mergeToolContinuationInQueue` 零 DB IO,仅父记录已离队时走原 flush+DB merge 路径;`_windowStatsPgAsync` 合并为 2 个 `PERCENTILE_CONT(ARRAY[0.5, 0.9, 0.95, 0.99])` 并下推 `owner_user_id`;`'ops-window'` 缓存键纳入 `muted: this.mutedErrorClasses`;移除死分支 `isHighConcurrency`;JSONL 镜像目录只建一次且改为异步串行追加;SQLite `cleanup()` 同步清理过期 `request_attempts`。 - `src/lib/admin/routing-runtime.mjs`:PG 模式下 `initPoolRuntime` 跳过启动期同步 `attemptsRepo.cleanup()`;`persistRoutingPatch` 增加 FIFO 单飞串行队列,在隔离克隆体上预归一化并落盘成功后再原子发布 `ctx.routingConfig` 与监控配置。 - 未改 / 延后:`usage-logs-repo.mjs`、`usage-logs-view.mjs`、`panel-routes.mjs`(归其他轨道);`scripts/bench-20k/verify-closed-loop.mjs`(保留 `overflowDirect` 计数契约无需改动)。 ## 验收记录(Run) - 环境与基线:Windows + WSL2 Debian Node v24.13.0,基于 `origin/dev` `7870fa8d52c7dcc4f2af6701a45f23f6a6a37248` 在独立工作树 `X:\vm2api-wt-r3-log-rw`(分支 `fix/r3-log-rw-backpressure`)施工。 - 已跑命令与结果: - `npx biome check src/lib/cache/live-log-cache.mjs src/lib/db/pg/pg-log-writer.mjs src/lib/admin/request-log.mjs src/lib/admin/routing-runtime.mjs test/unit/live-log-cache.test.mjs test/unit/pg-log-writer.test.mjs test/unit/log-realtime-merge.test.mjs test/unit/request-log.test.mjs test/unit/routing-runtime-load.test.mjs`: PASS (9 files, 0 errors, 0 warnings) - `find src scripts -name '*.mjs' -print0 | xargs -0 -n1 node --check`: PASS (0 syntax errors) - `KIN_SCHEDULER_BIN=/mnt/x/vm2api-wt-gemini-format-parity/bin/kin-scheduler VM2API_TEST_CONCURRENCY=4 npm run test:ci`: PASS (13/13 isolated test files, exit 0) - `node --test test/unit/live-log-cache.test.mjs test/unit/pg-log-writer.test.mjs test/unit/log-realtime-merge.test.mjs test/unit/request-log.test.mjs test/unit/gemini-request-log.test.mjs test/unit/routing-runtime-load.test.mjs test/unit/settings-routing-audit.test.mjs test/unit/routing-redaction-budget.test.mjs test/unit/usage-logs-view.test.mjs test/unit/request-logs-export.test.mjs test/unit/write-behind.test.mjs test/unit/panel-redis-opt.test.mjs`: PASS (189 pass, 0 fail, 1 skip without PG_URL) - WSL 临时 Docker `postgres:18-alpine` (`127.0.0.1:55439`, 跑完已清理) `VM2API_TEST_PG_URL=... node --test test/unit/pg-log-writer.test.mjs test/unit/pg-integration.test.mjs test/unit/pg-repos-parity.test.mjs`: PASS (22/22 pass, 0 fail, 0 skip) ## 回退与手破验证(Broken by hand) - 临时关闭 `PgLogWriter._executeChannelTx` 中 `request_log_debug` 的 `useSavepoint: true` -> `PgLogWriter uses 1 client + 1 transaction per channel and isolates debug failure via SAVEPOINT` FAIL(`AssertionError: missing SAVEPOINT sp_debug / RELEASE SAVEPOINT sp_debug in single-tx sequence`)-> 恢复后 PASS。 - 临时把 `LiveLogCache._pruneLocalInflight` 的 `if (started >= cutoff) break` 退回全量扫描 -> `LiveLogCache L1/L2/L6/L9: omits sess:active, early-breaks inflight prune, strips jev_state, and single-flights/throttles reads` FAIL(`AssertionError: _pruneLocalInflight must break on first started >= cutoff instead of scanning full Map`)-> 恢复后 PASS。 - 临时绕过 `routing-runtime.mjs` 中 `persistRoutingPatch` 的 `persistQueue` 串行队列 -> `P4: persistRoutingPatch serializes concurrent patches in FIFO order and avoids mutating live routingConfig on failure` FAIL(`AssertionError: concurrent patch #2 must not interleave before patch #1 finishes`)-> 恢复后 PASS。 ## 真实使用(Real use) - 已在 WSL 本地一次性 `postgres:18-alpine` 容器上实跑 `pg-log-writer`(含真实 `UNNEST` 批量写、单事务 `SAVEPOINT`、窗口裁剪及 `request_attempts` `ctid` 清理)、`pg-integration`、`pg-repos-parity` 全通过(22/22 PASS,0 skip);未连生产机 `ph24`(沙箱禁区规则禁止)。 ## 未运行项(Not run) - 全仓 556 个单测与 E2E / Web 前端套件(本提交零改动 `web/`、Go、Rust 模块);生产机 `ph24` 线上实测(按安全红线禁止连接);`bench-20k` 20K 实压测(未改动 `verify-closed-loop.mjs` 契约,单测中 `waits for drain` 用例因 WSL 代理环境回环请求未配置 `NO_PROXY` 与本改动无关)。
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 831a05e2-760e-4a52-8da5-f2ebce56e774) |
评审结果(Codex 只读评审合并最新
|
…jsonl drain, and live-cache ## 变更摘要 - 改前: - `PgLogWriter._enqueueItem` 超过 `maxPending` 后仍无条件 `push`,PG 持续停滞时内存队列无上限增长(Major 1)。 - `runRetentionCleanupAsync` 的 debug 容量裁剪 `DEBUG_SIZE_CUTOFF_SQL` 只取 `MAX(ts)` 并按 `WHERE ts <= $1` 删除,同时间戳多条记录会被整批误删(Major 2)。 - `RequestLogStore._appendJsonl` 改异步 Promise 链后既无队列上限,也无排空接口且 `server.mjs` graceful shutdown 未等待其落盘(Major 3)。 - `LiveLogCache._pruneLocalInflight` 遇首条未过期即 `break` 假设插入序恒等于 `started_at` 序,乱序或墙钟回拨时漏清过期记录及 session 并发(Minor 1)。 - `LiveLogCache.formatRecentEntry` 移除了 `usage-logs-view.mjs` 详情仍读取的 `jev_state`(Minor 2);1s 列表缓存未在 `cache/index.mjs` 接出部署开关(Minor 3)。 - 改后: - `src/lib/db/pg/pg-log-writer.mjs`:触及 `maxPending` 时先同步派发空闲并发通道吸收突刺;通道全满且队列满时优先淘汰 `_debugQueue` 低优记录,仍满则拒绝入队并节流告警,保证任意时刻 `pending() <= maxPending` 且 `activeChannels <= concurrency`。debug 容量裁剪改用 `ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 取复合边界 `(cutoff_ts, cutoff_request_id)`,按 `ts < $1 OR (ts = $1 AND request_id <= $2)` 精确 `ctid` 分批删除。 - `src/lib/admin/request-log.mjs` & `src/server.mjs`:JSONL 镜像改为有界批量队列(默认 `jsonlMaxPending=10000`,超限计 `_jsonlDropped`)+ 单循环 `_drainJsonlQueue`,新增 `flushJsonl()` / `close()` 并在 `server.mjs` gracefulShutdown teardown(`flushWrites()` 后)等待其排空。 - `src/lib/cache/live-log-cache.mjs`、`src/lib/db/pg/config.mjs`、`src/lib/cache/index.mjs`:`_pruneLocalInflight` 增加 `_lastInflightStartedAt` / `_inflightOrderDirty` 监测,单调时保持 O(expired) 快速路径、乱序/回拨时自动退回全表清理并恢复;`formatRecentEntry` 保留非空 `jev_state`(上限 4096 字符防 64KB 膨胀,落 PG 后覆盖为完整行);`resolveCacheConfig` 新增 `VM2API_LIVE_LIST_CACHE_TTL_MS`(默认 1000,支持 0 关闭)并透传 `cache/index.mjs`。 - 在 5 个已有单测文件补齐回归用例(零新增测试文件):PG 持续停滞硬上限背压、真 PG18 同 `ts` `a/b/c` 窗口裁剪、JSONL 关机排空与慢盘队列上限、父记录离队回退 DB 续写合并、live-cache 乱序清理/jevState/跨实例开关、路由队列首项失败后次项成功及 `setRoutingConfig` 替换分支。 - 未改 / 延后:跨实例续写延迟合并与 PG 逐行回退丢弃属既有策略边界;路由写单 leader 架构由 `server.mjs` standby/draining 拦截,本次不扩展跨进程锁。 ## 验收记录(Run) - 环境与基线:Windows + WSL2 Debian Node v24.13.0,基于 `origin/fix/r3-log-rw-backpressure` (`70aa5907c`) 在独立工作树 `X:\vm2api-wt-fix-pr2458` 追加提交。 - 已跑命令与结果: - `npx biome check src/lib/db/pg/pg-log-writer.mjs src/lib/admin/request-log.mjs src/server.mjs src/lib/cache/live-log-cache.mjs src/lib/db/pg/config.mjs src/lib/cache/index.mjs test/unit/pg-log-writer.test.mjs test/unit/request-log.test.mjs test/unit/live-log-cache.test.mjs test/unit/routing-runtime-load.test.mjs test/unit/log-realtime-merge.test.mjs`: PASS (11 files, 0 errors, 0 warnings) - `find src scripts -name '*.mjs' -print0 | xargs -0 -n1 node --check`: PASS (0 syntax errors) - `KIN_SCHEDULER_BIN=/mnt/x/vm2api-wt-gemini-format-parity/bin/kin-scheduler VM2API_TEST_CONCURRENCY=4 npm run test:ci`: PASS (13/13 isolated test files, exit 0) - `node --test test/unit/live-log-cache.test.mjs test/unit/pg-log-writer.test.mjs test/unit/log-realtime-merge.test.mjs test/unit/request-log.test.mjs test/unit/gemini-request-log.test.mjs test/unit/routing-runtime-load.test.mjs test/unit/settings-routing-audit.test.mjs test/unit/routing-redaction-budget.test.mjs test/unit/usage-logs-view.test.mjs`: PASS (202 pass, 0 fail, 1 skip without PG_URL) - WSL 临时 Docker `postgres:18-alpine` (`127.0.0.1:55446`, 跑完已 `docker rm -f`) + `redis:8-alpine` (`127.0.0.1:56393`, 跑完已 `docker rm -f`) `VM2API_TEST_PG_URL=... VM2API_TEST_REDIS_URL=... node --test test/unit/pg-log-writer.test.mjs test/unit/pg-integration.test.mjs test/unit/pg-repos-parity.test.mjs test/unit/pg-redis-cache-e2e.test.mjs test/unit/sqlite-to-pg-migration.test.mjs`: PASS (31/31 pass, 0 fail, 0 skip) ## 回退与手破验证(Broken by hand) - 临时移除 `PgLogWriter._enqueueItem` 满队列拒绝 `return false` -> `PgLogWriter enforces hard maxPending bound under burst and sustained PG stall while shedding debug first` FAIL(`AssertionError [ERR_ASSERTION]: under sustained PG stall, pending (4) must stay <= maxPending (3)`)-> 恢复后 PASS。 - 临时移除 `RequestLogStore.close()` 中 `await this.flushJsonl()` -> `jsonl mirror writes legacy format asynchronously, creates directory once, drains on close, and bounds queue` FAIL(`AssertionError [ERR_ASSERTION]: store.close() must wait for pending JSONL writes before exit`)-> 恢复后 PASS。 ## 真实使用(Real use) - 已在 WSL 真实 `postgres:18-alpine` + `redis:8-alpine` 容器上实跑 `pg-log-writer`(含真实 PG18 同 `ts` `same_ts_a/b/c` `maxBytes=200` 窗口裁剪验证)、`pg-integration`、`pg-repos-parity`、`pg-redis-cache-e2e`、`sqlite-to-pg-migration` 全通过(31/31 PASS,0 skip);未连生产机 `ph24`(安全红线禁止)。 ## 未运行项(Not run) - 全仓 556 个单测与 `web/` 前端套件(本提交零改动 `web/`、Go、Rust 模块);生产机 `ph24` 线上实测(按安全红线禁止连接)。
|
已根据评审意见在
验证汇总(HEAD |
|
复验通过(head 变更摘要
验收记录(Run)
回退与手破验证(Broken by hand)
真实使用(Real use)
未运行项(Not run)
|
复核结果(head
|
…and guard requestLog.close() shutdown wiring
1. 本次改动与原因(Head $sha)已合入最新 origin/dev 并修复复核阻断项及补齐测试:
2. 已执行验证与结果px biome check src/lib/admin/routing-runtime.mjs test/unit/request-log.test.mjs — 0 fixesode --test test/unit/routing-redaction-budget.test.mjs test/unit/routing-runtime-load.test.mjs test/unit/settings-routing-audit.test.mjs test/unit/request-log.test.mjs — 105/105 PASS(0 fail)
3. 破坏性验证(Broken-by-hand)
4. 未运行项
5. 风险与回滚
|
变更摘要
LiveLogCache维护零生产引用的live:sess:activeZSET 与无上限_localActiveSessionsMap(L1),每次startRequest全量O(N)扫描_localInflight(L2),finishRequest把最大 64KB 的jev_state整份写入 Redis recent 桥接(L6),listLiveAndRecent每次轮询无合并直查 Redis 且执行ZREMRANGEBYSCORE写操作(L9)。PgLogWriter超过maxPending时对每条日志无上限直连pool.connect()触发连接池雪崩(L3/PG10),单通道把usage_logs/request_attempts/request_log_debug拆成 3 次取连接 + 3 个事务(L10/PG10),debug 体积裁剪最多 64 轮全表SUM+COUNT扫(L5/PG10),runRetentionCleanupAsync遗漏request_attempts周期清理且routing-runtime在 PG 启动时主线程同步全表DELETE(PG2),保留零引用enqueue()/enqueueDebug()(L12)。RequestLogStore对 Gemini 工具续写合并先全量flush()再走同步读改写(L4),_windowStatsPgAsync使用 8 个标量PERCENTILE_CONT且跳过租户owner_user_id(PG7),'ops-window'SWR 缓存键未包含mutedErrorClasses(P2),含死分支isHighConcurrency(L12),JSONL 镜像每条同步mkdirSync+appendFileSync(L13)。routing-runtime.mjs的persistRoutingPatch无并发串行队列且在落盘前原地修改共享ctx.routingConfig(P4)。src/lib/cache/live-log-cache.mjs:删除getActiveSessionKeys/_localActiveSessions/SESS_ACTIVE_ZSET/sessionActiveTtlSec(保留getActiveSessionCounts与_localSessionConc);_pruneLocalInflight遇首条started >= cutoff立即break(O(expired));formatRecentEntry按列表白名单剔除jev_state/advisor_usage/image_usage;listLiveAndRecent按(fetchCap, includeRecent, ageLimit)增加 1s single-flight 结果复用并节流ZREMRANGEBYSCORE。src/lib/db/pg/pg-log-writer.mjs:移除无上限_directInFlight/_dispatchDirectWrite,改为软上限入队 + 紧急批量 flush(并发严格<= concurrency,保留overflowDirect计数兼容bench-20k);新增mergeToolContinuationInQueue原地合并队列中父记录;单通道复用 1 个client+ 1 个事务写usage_logs+request_attempts(保留SET LOCAL synchronous_commit = off与 attempts 排序防死锁),request_log_debug包裹在SAVEPOINT sp_debug隔离失败;runRetentionCleanupAsync改用单次窗口函数SUM(OCTET_LENGTH(record_json)) OVER (ORDER BY ts DESC, request_id DESC)定位截止ts后按ctid分批删,并在同把 advisory lock 内新增第 5 步request_attemptsctid分批清理;删除零引用enqueue()/enqueueDebug()(保留USAGE_LOG_COLUMNS/usageLogToRow签名)。src/lib/admin/request-log.mjs:Gemini 续写合并优先调pgWriter.mergeToolContinuationInQueue零 DB IO,仅父记录已离队时走原 flush+DB merge 路径;_windowStatsPgAsync合并为 2 个PERCENTILE_CONT(ARRAY[0.5, 0.9, 0.95, 0.99])并下推owner_user_id;'ops-window'缓存键纳入muted: this.mutedErrorClasses;移除死分支isHighConcurrency;JSONL 镜像目录只建一次且改为异步串行追加;SQLitecleanup()同步清理过期request_attempts。src/lib/admin/routing-runtime.mjs:PG 模式下initPoolRuntime跳过启动期同步attemptsRepo.cleanup();persistRoutingPatch增加 FIFO 单飞串行队列,在隔离克隆体上预归一化并落盘成功后再原子发布ctx.routingConfig与监控配置。usage-logs-repo.mjs、usage-logs-view.mjs、panel-routes.mjs(归其他轨道);scripts/bench-20k/verify-closed-loop.mjs(保留overflowDirect计数契约无需改动)。验收记录(Run)
origin/dev7870fa8d52c7dcc4f2af6701a45f23f6a6a37248在独立工作树X:\vm2api-wt-r3-log-rw(分支fix/r3-log-rw-backpressure)施工。npx biome check src/lib/cache/live-log-cache.mjs src/lib/db/pg/pg-log-writer.mjs src/lib/admin/request-log.mjs src/lib/admin/routing-runtime.mjs test/unit/live-log-cache.test.mjs test/unit/pg-log-writer.test.mjs test/unit/log-realtime-merge.test.mjs test/unit/request-log.test.mjs test/unit/routing-runtime-load.test.mjs: PASS (9 files, 0 errors, 0 warnings)find src scripts -name '*.mjs' -print0 | xargs -0 -n1 node --check: PASS (0 syntax errors)KIN_SCHEDULER_BIN=/mnt/x/vm2api-wt-gemini-format-parity/bin/kin-scheduler VM2API_TEST_CONCURRENCY=4 npm run test:ci: PASS (13/13 isolated test files, exit 0)node --test test/unit/live-log-cache.test.mjs test/unit/pg-log-writer.test.mjs test/unit/log-realtime-merge.test.mjs test/unit/request-log.test.mjs test/unit/gemini-request-log.test.mjs test/unit/routing-runtime-load.test.mjs test/unit/settings-routing-audit.test.mjs test/unit/routing-redaction-budget.test.mjs test/unit/usage-logs-view.test.mjs test/unit/request-logs-export.test.mjs test/unit/write-behind.test.mjs test/unit/panel-redis-opt.test.mjs: PASS (189 pass, 0 fail, 1 skip without PG_URL)postgres:18-alpine(127.0.0.1:55439, 跑完已清理)VM2API_TEST_PG_URL=... node --test test/unit/pg-log-writer.test.mjs test/unit/pg-integration.test.mjs test/unit/pg-repos-parity.test.mjs: PASS (22/22 pass, 0 fail, 0 skip)回退与手破验证(Broken by hand)
PgLogWriter._executeChannelTx中request_log_debug的useSavepoint: true->PgLogWriter uses 1 client + 1 transaction per channel and isolates debug failure via SAVEPOINTFAIL(AssertionError: missing SAVEPOINT sp_debug / RELEASE SAVEPOINT sp_debug in single-tx sequence)-> 恢复后 PASS。LiveLogCache._pruneLocalInflight的if (started >= cutoff) break退回全量扫描 ->LiveLogCache L1/L2/L6/L9: omits sess:active, early-breaks inflight prune, strips jev_state, and single-flights/throttles readsFAIL(AssertionError: _pruneLocalInflight must break on first started >= cutoff instead of scanning full Map)-> 恢复后 PASS。routing-runtime.mjs中persistRoutingPatch的persistQueue串行队列 ->P4: persistRoutingPatch serializes concurrent patches in FIFO order and avoids mutating live routingConfig on failureFAIL(AssertionError: concurrent patch #2 must not interleave before patch #1 finishes)-> 恢复后 PASS。真实使用(Real use)
postgres:18-alpine容器上实跑pg-log-writer(含真实UNNEST批量写、单事务SAVEPOINT、窗口裁剪及request_attemptsctid清理)、pg-integration、pg-repos-parity全通过(22/22 PASS,0 skip);未连生产机ph24(沙箱禁区规则禁止)。未运行项(Not run)
web/、Go、Rust 模块);生产机ph24线上实测(按安全红线禁止连接);bench-20k20K 实压测(未改动verify-closed-loop.mjs契约,单测中waits for drain用例因 WSL 代理环境回环请求未配置NO_PROXY与本改动无关)。Note
Medium Risk
Touches hot-path log backpressure (drops possible under PG stall), routing config atomicity, and tenant-scoped stats SQL—important for ops correctness but bounded by extensive unit/PG integration tests.
Overview
This PR hardens logging, live dashboards, and routing config updates under high load and multi-tenant stats.
PgLogWriter drops unbounded overflow direct writes in favor of a strict
maxPendingcap (shed debug rows first, reject excess), batchesusage_logs+request_attempts+request_log_debugin one client/transaction with SAVEPOINT isolation for debug failures, and addsmergeToolContinuationInQueueso Gemini tool continuations can update buffered parent rows without flush/DB I/O. Retention nowctid-cleansrequest_attemptsand trims oversized debug storage via a single window cutoff instead of repeated full-table scans.RequestLogStoreprefers in-queue continuation merge, pushesowner_user_idinto PG window stats (2 arrayPERCENTILE_CONTcalls), keysops-windowSWR by muted error classes, replaces sync JSONL with a bounded async queue (flushJsonl/closeon shutdown), and adds SQLiterequest_attemptscleanup parity.LiveLogCacheremoves deadlive:sess:activetracking, whitelists/truncates recent-bridge payloads (keeps boundedjev_state), adds ~1s single-flight list read cache (VM2API_LIVE_LIST_CACHE_TTL_MS), and speeds inflight pruning when timestamps stay monotonic.persistRoutingPatchnow runs on a FIFO queue, builds a draft clone, writes disk, then atomically publishes live config and monitor hooks only after success. PG skips blockingrequest_attemptscleanup at pool init.Server shutdown calls
requestLog.close()after write-behind flush and before cache teardown.Reviewed by Cursor Bugbot for commit a9739d4. Configure here.