admin
|
16cf68d132
|
feat(stats): 运行期统计落盘/恢复 + 审计口径收口 (1.0.18)
起因:发版后管理台「用量」与「趋势」从 0 重新长起来。根因是统计类键
(ust:/ums:/utt:/utms:/ud:/udu:/uds:/uda:/uex:/uh:)只活在共享内存,
进程退出即消失;而上游/账号/域名/用户都有 data/*.json 所以不丢。
统计落盘(新 stats_persist.rs):
- 快照 data/llm-stats.json(与 users.json 同级),原子写 <path>.tmp.<pid> + rename
- 两个落盘点互补:worker 退出钩子 exit_process(发版/docker stop,零丢失)
+ 记账后按间隔节流落盘(默认 60s,覆盖 SIGKILL/OOM/断电)
- 启动 init_process 恢复,put-if-absent → 多 worker 幂等、不覆盖新数据
- 白名单 10 个统计前缀;刻意排除配置类/ukb:/内核态(各有数据文件或重启清零更安全)
- 恢复结果发布 shm spr:last(不再放进程内静态量,否则接口落到哪个 worker 报哪个数)
- 接口 GET /api/admin/stats/persist + POST /api/admin/stats/dump
- 指令 ipass_stats_persist <秒>(0=只留退出钩子);生产 conf 刻意不写
fix(audit): excerpt 双重编码
- json_quote_bytes(手工转义+两侧引号)塞进 json!() 被二次转义,落盘成
"excerpt":"\"{\\\"model\\\"…",解码后多一层引号,消费方全解析不到
- 改为 excerpt_text():只 from_utf8_lossy,转义交给 serde
docs: 新增 docs/llm/STATS_PERSISTENCE.md(含 runbook)、docs/llm/AUDIT_LOG.md
(两者此前被代码注释与 Dockerfile 引用但文件并不存在)
tests:
- 新增【15】统计落盘/重启恢复 13 条(间隔压 1s → 快照产出与白名单 →
nginx -s quit → 恢复键数 == 快照键数、用量不变、再打一笔 +1、趋势仍在)
- 【13】「不再生成 body 副本」改断言本轮增量 = 0(对历史残留免疫);
选择器改 body_bytes>400 且取最后一条匹配(目录里有首版的双重编码行)
- run.sh 复位改用 mv(rename 不算删除)——本机 safe-delete 钩子在累计删除
超 50 个文件后会静默拦掉后续删除,rm -rf 与 python rmtree 同样被拦
- 回归 298 全绿(网关 102 + LLM 196)
|
2026-09-14 19:32:17 +08:00 |
|
admin
|
479024c61e
|
feat(api): /api/v1/me 聚合能力目录 (upstreams + apix) (1.0.16)
- plugin-apix: 新增 apix::enabled(),仅列 enabled=true 的代理
- ipass-core: CoreExt::decorate_me 签名加 &User 和 &port,让装饰零额外
shm 查询就能做权限收敛(upstreams 按 allowed_models 过滤)
- gateway::GatewayExt: decorate_me 多塞 upstreams(白名单过滤)和 apix
(仅 enabled)两个字段;port 从请求 Host 头取(适配 88 / 443 反代)
老 3 个端点 /api/v1/{upstreams,apix,domains} 保留不破坏。同事拿 key 一个
me 拿全能力目录,不再需要分别调三个端点。
回归 281 全绿(网关 102 + LLM 179)
|
2026-09-14 17:14:00 +08:00 |
|
admin
|
db99ce1521
|
docs: 文档与注释系统性对齐插件化现状 + 清理前身实现引用
- readme §16 补 1.0.10-1.0.13 四条变更记录;§12.6 tag 表补 1.0.9-1.0.13
- readme §5 架构图更新为插件化结构(PLUGINS 注册表/四开关/四表)
- readme §11 补 api-proxies.json 数据模型小节;§8 管理台表格补 API 代理行
- readme/CLAUDE.md 测试断言数对齐 262(102+160);三个 JSON 改四个
- CLAUDE.md LLM 落点表改 crates/plugin-llm 路径;发版补 git push 前置教训
- 清理全部前身实现引用(readme 三处、CLAUDE.md 性能章节、util.rs 注释)
- PLUGIN_ARCHITECTURE.md 增补 1.0.13 sso 合流记录
|
2026-09-13 18:27:28 +08:00 |
|
admin
|
85ea0a1531
|
refactor(plugin): P4 拆 plugin-apix —— API 代理迁入独立插件,过渡期路由清空
- plugin-apix 新 crate:apix/handlers/api/config/models/store
- ApiProxy/ApiProxyStore、api-proxies.json 读写、ax: 键空间与 APIX_* 常量自内核迁入
- ApiProxyHandler 与 $apix_* 六变量注册归 ApixPlugin;用量记账仍走 plugin_llm::stats(同一片键空间、单一写入口)
- gateway 路由表只剩 trend 组合端点(需 users+upstreams+apix 三方名册)
- 行为等价:262 项回归全绿(gateway 102 + llm 160)
|
2026-09-13 12:16:47 +08:00 |
|
admin
|
0d8e1c94d1
|
refactor(plugin): P3 拆 plugin-llm —— LLM 路由/配额/计量/审计/趋势迁入独立插件
- plugin-llm 新 crate:llm/upstreams/usage_filter/llm_audit/stats/handlers/api/config/models/store
- 下行契约(downstream_key/identity/check_quota/fail)与记账原语(usage::bump/read/bump_day)已下沉 ipass-core
- usage_filter 改走 loc::enabled(Switch::Llm) + core::plugin::ctx_index(解除对 gateway 私有 ModuleConfig 的依赖)
- gateway 收缩为壳:LlmHandler/LlmHealthHandler/AuditHandler 随 LlmPlugin 装配;
/api/admin/trend 留 gateway(需 users+upstreams+apix 三方名册,组合根职责)
- 行为等价:262 项回归全绿(gateway 102 + llm 160)
|
2026-09-13 12:08:34 +08:00 |
|
admin
|
74aeefee58
|
refactor(plugin): P0-P2 插件化落地 —— workspace 化 + ipass-core + plugin-domain
- P0: rust/ 改 workspace(ipass-core 内核 + gateway 唯一 cdylib),
[profile.release] 上移根、依赖收敛 workspace.dependencies;
users::delete 的 stats::forget 依赖改为 on_delete 钩子注册表
- P1: 契约层 core/plugin.rs(Plugin trait)+ core/loc.rs(Switch 并集 +
set_switch_fn,未实现变体保守 false);gateway PLUGINS 分发循环,
不认领统一 404(插件绝不自行 404)
- P2: 身份端点下沉 core/api.rs(CorePlugin + CoreExt 扩展注册表,
gateway 作装配根回填域名数/用量/连带回收/白名单校验);
plugin-domain crate(domains + DomainEntry + sub: 前缀 + ResolveHandler
+ $proxy_backend_addr + 域名类端点含 purge)
- 行为等价:conf/nginx.conf、Dockerfile、tests 零改动,262 回归全绿
- 方案文档 docs/plugin/PLUGINIZATION_PLAN.md
|
2026-09-13 11:43:22 +08:00 |
|