fawney19
fce7e959e5
Add multi-database data layer
...
Introduce aether-data-schema and driver-specific schema generation for Postgres, MySQL, and SQLite.
Split data backends, lifecycle, repositories, and gateway runtime integration across database drivers.
Verified with cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace.
2026-05-05 18:27:36 +08:00
fawney19
0c9b5ddd77
Fix usage terminal state regression
2026-04-28 10:31:16 +08:00
fawney19
f30b1f3f6b
fix(usage): 流式终端 usage 以更完整值为准,Codex CLI 显式选择 response 解析器
...
- 新增 StandardizedUsage::signal_score/is_more_complete_than/choose_more_complete,流式合并与终端落库均按信号完整度择优
- OpenAI Chat/CLI 解析器支持仅 usage 的终结 chunk 与 response.completed usage
- Codex provider 注入 provider_stream_event_api_format=openai:cli,解析器选择改由 report_context 显式决定
- usage_mapper 扩展嵌套 response/message/item 兼容 Claude message_start/message_delta 及 Gemini stream chunks
- usage SQL upsert 在终态(completed/failed/cancelled)时按 GREATEST 写入 token/费用镜像列
2026-04-25 00:57:01 +08:00
fawney19
e265475c17
fix(usage): 修正 input_tokens 统计与显示
...
- SQL 查询不再用 settlement snapshot 的 billing_input_tokens 覆盖原始 input_tokens
- usage_mapper 针对 OpenAI 格式在 input_tokens 缺失时从 total_tokens - output_tokens 推导
- 前端轮询合并优先采用最新 record 的 input_tokens / effective_input_tokens
2026-04-24 20:59:12 +08:00
fawney19
657fcd595c
refactor(rust): 拆分 usage sql 仓储为模块并外置 SQL 文件
...
- 将 usage/sql.rs 拆分为 sql/mod.rs 与 sql/tests.rs
- 将内联 SQL 抽离到 sql/queries/ 目录下的独立 .sql 文件
- 前端用量记录表格移除缓存创建 token 展示,保留 cache read 列
2026-04-24 20:22:24 +08:00
fawney19
f695238e8a
feat(billing): 引入 billing v3 settlement snapshot 及 usage_billing_facts 视图
...
- 新增迁移 20260424000000:为 usage_settlement_snapshots 添加 settlement_snapshot、
billing_dimensions、billing_input/output/cache tokens、billing_total_cost_usd 等列,
并创建 usage_billing_facts 视图(从 settlement snapshot 覆盖原始 usage token/cost 字段)
- event_enrichment:构建结构化 settlement_snapshot(含 pricing_snapshot、billing_plan_snapshot、
resolved_dimensions、cost_breakdown 等),写入 request_metadata
- pricing:新增 pricing_source() 方法区分 provider_override / global_default / unpriced
- sql.rs:settlement snapshot 写入新列;用量汇总查询改用 usage_billing_facts 视图
- maintenance/runtime:所有统计查询的 FROM usage 替换为 FROM usage_billing_facts
- admin observability:在 settlement 响应中暴露 settlement_snapshot / billing_dimensions,
并从 metadata 中剥离对应字段
- request_metadata:允许 settlement_snapshot / billing_dimensions 字段传播
- stream execution:在首个数据帧到达时记录 TTFB,补全流式请求的 streaming 事件
2026-04-24 17:52:33 +08:00
fawney19
342d4a268c
feat(stream-bridge): 支持上游 sync 响应转 SSE 流式输出,记录 client/upstream 流模式差异
...
- 新增 sync_to_stream 桥接模块,将非 SSE 上游响应转换为 SSE 格式回传给流式客户端
- stream_pump 检测非 SSE 响应头后缓冲整包并通过桥接逻辑重写为 SSE 帧
- proxy handler 同步支持 sync→stream 聚合与转换(覆盖 openai/claude/gemini 四种格式)
- sync_products 补全 openai:cli 的完整流式事件聚合(text delta、reasoning、tool call 等)
- usage runtime 写入 client_requested_stream / upstream_is_stream 到 request_metadata
- SQL 查询层将两个布尔字段从 request_metadata jsonb 中提取并回传给前端
- 前端 status.ts 新增 resolveUsageStreamLabelSegments,优先读取 client_requested_stream
- RequestDetailDrawer 在流式转换场景下显示"客户端→上游"两段 Badge
2026-04-23 21:53:50 +08:00
fawney19
cf6228f525
feat(stats,rules): api_key 用量统计(total_tokens 字段 + 回填)与 body rules 新增 append/insert/regex_replace/name_style 操作
...
- 新增迁移 20260422120000_add_api_key_usage_stats.sql,为 api_keys 表添加 total_tokens 列
- 新增回填 20260422120000_backfill_api_key_usage_stats.sql,按历史 usage 重建 api_key 维度汇总
- 在 UsageWriteRepository trait 中添加 rebuild_api_key_usage_stats,补齐 SQL/内存实现及上层调用链
- 内存实现中新增 apply_usage_stats_delta,支持增量更新 api_key 统计快照
- dev.sh:改进临时日志目录管理,并在网关异常退出时输出错误提示
- frontend EndpointFormDialog:将 append 操作从 insert 分支拆分,提供独立 path/value 输入 UI
- rules.rs:扩展 body rules 支持,新增 append/insert/regex_replace/name_style 操作及 WildcardSlice 路径段
2026-04-22 20:16:57 +08:00
fawney19
a5e6bd3b62
feat(stats): 新增聚合读路径与回填机制并重构 dashboard/usage 读取链路
...
- 新增 stats_user_summary 及 user_daily_provider/api_format/cost_savings 等聚合表
- 扩展 stats_daily/hourly 有效 token 与响应时间等字段,maintenance runtime 同步写入
- 新增 backfill 模块与 --apply-backfills 命令补齐历史聚合数据
- 重写 dashboard_filters、usage_heatmap、user_rollups 查询改走聚合表
- 同步更新 baseline_v2.sql 与 migration 集,README/dev.sh 补充回填用法
2026-04-22 17:29:39 +08:00
fawney19
d719a1329c
fix(usage): cache-affinity 间隔查询将 interval_minutes 强制转为 DOUBLE PRECISION
2026-04-19 16:32:29 +08:00
fawney19
c302dfe42d
fix(usage): 完善 cache-affinity 时间线的用户名回退与模型空值兜底
...
- 当 auth 用户查询失败时回退到历史 username,避免时间线丢失用户信息
- SQL 投影对 usage.model 使用 COALESCE 兜底空值
- IntervalTimelineCard 在刷新间隔为 0 时跳过定时刷新
- Usage 页面关闭时间线卡片的自动轮询
2026-04-19 16:07:01 +08:00
fawney19
e82c9c5104
fix(usage): 容错缺列投影以支持旧版和部分升级场景
...
map_usage_row 中对 http_audit/routing/settlement 等新增投影列改用
row_try_get_optional,将 ColumnNotFound 视同 NULL,避免仅选取核心字段
的读取路径在列缺失时整行失败。同时补充 UPSERT 和 LIST 前缀的占位列
断言。
2026-04-19 01:48:16 +08:00
AAEE86
6666992d01
feat(admin): 将用户管理的用量统计改为全量累计口径 ( #314 )
...
- 新增按用户 ID 批量汇总 usage 的后端查询
- 在 /api/admin/users 中返回 request_count 和 total_tokens
- 移除用户管理页面额外的 usage 聚合请求
- 为管理端用户列表补充累计统计回归测试
2026-04-19 01:26:22 +08:00
AAEE86
bafb63a665
持久化 provider key 使用统计并移除 usage 汇总覆盖 ( #313 )
...
* 持久化 provider key 使用统计并移除 usage 汇总覆盖
- 在 usage upsert 时按请求前后差值同步 provider_api_keys 统计
- 增加基于保留 usage 记录的 provider key 统计重建能力
- 号池管理列表直接读取 provider_api_keys 统计字段
* fix: harden provider key usage stats sync
---------
Co-authored-by: fawney19 <elky0401@gmail.com >
2026-04-19 01:02:09 +08:00
fawney19
3363592751
Refactor usage body capture and stream terminal reporting
2026-04-18 17:48:21 +08:00
RWDai
ff4e853fd3
Fix/usage transfer filter ( #307 )
...
* fix(usage): 恢复 usage 列表中的 fallback 路由信号
* fix(admin): 支持 usage 记录展示和筛选 fallback 转移
* fix(usage): 在用户 usage 记录中暴露 fallback 标记
* fix(usage): 共享 usage 页面支持 fallback 筛选
* fix(usage): 对齐 fallback 筛选相关前端类型
* fix(usage): propagate has_fallback through active polling
---------
Co-authored-by: fawney19 <elky0401@gmail.com >
2026-04-17 13:38:23 +08:00
fawney19
1e0bc61526
feat(gateway/data): 新增 usage 关键词搜索、缓存命中摘要、结算成本摘要及 dashboard 聚合查询能力
...
- 新增 UsageAuditKeywordSearchQuery,支持多关键词、用户名、API Key 交叉过滤
- 新增 UsageCacheHitSummaryQuery/StoredUsageCacheHitSummary,统计请求缓存命中率
- 新增 UsageSettledCostSummaryQuery/StoredUsageSettledCostSummary,汇总结算成本
- 新增 UsageDashboardSummaryQuery、UsageBreakdownSummaryQuery 等 dashboard 聚合类型
- SQL 层实现对应查询方法,含 list_by_ids、list_usage_audits_by_keyword_search、count_usage_audits_by_keyword_search
- 将上述能力通过 GatewayDataState / AdminAppState 暴露给 handler 层
- user_me_usage 及 dashboard_filters 切换为新查询接口,移除旧的内存过滤逻辑
- 同步更新 memory 层及测试
2026-04-17 01:00:38 +08:00
fawney19
65cd9dc3e5
fix(admin): 修复 usage 观测全表扫描并下推聚合查询
...
- 收紧 admin usage/stats 默认时间范围和 active 轮询查询
- 将 summary/records/aggregation/time-series/leaderboard 下推到 SQL 侧
- 统一前端时间参数并补齐 admin usage/stats 回归测试
2026-04-16 17:46:19 +08:00
fawney19
d805a28c9a
feat: 请求候选追踪添加 proxy 元数据, 修复 usage 状态回退, 优化前端轮询
...
- 在各 planner decision payload 中注入 proxy trace 信息 (node_id, node_name, url, source)
- request_candidate 报告上下文支持 proxy 字段, extra_data 合并逻辑改为 merge 而非覆盖
- SQL/内存仓库防止 usage status 从 streaming 回退到 pending
- 前端移除活跃请求完成时的全表刷新, active discovery 尊重 globalAutoRefresh 开关
2026-04-16 11:57:42 +08:00
fawney19
43e7ad112f
perf(usage): user-me usage 查询避免全量加载,默认限制 7 天范围
...
- UsageAuditListQuery 新增 limit 字段,支持在 SQL 层 LIMIT
- user-me usage 端点无时间范围时默认查最近 7 天
- active usage 端点无 ids 过滤时限制查最近 1 小时
- InMemory 实现同步支持 limit truncate
2026-04-15 16:25:57 +08:00
fawney19
4087e096f2
fix(usage): 为 InMemory 仓库补充 status 过滤逻辑
2026-04-15 09:53:52 +08:00
fawney19
8827c46c33
perf(usage): 将 status 过滤下推到 SQL 查询层
...
为 UsageAuditListQuery 新增 statuses 字段,支持在数据库端按状态
筛选用量记录。admin usage summary 路由不再全量拉取后内存过滤,
改为直接查询 pending/streaming 状态的记录。
2026-04-15 09:30:42 +08:00
fawney19
98ad1172b0
perf(usage): heatmap 改为数据库端按天聚合查询
...
将 admin 和 user heatmap 从逐条加载 usage audit 记录后在应用层聚合,
改为通过 SQL GROUP BY DATE 在数据库端直接按天汇总, 大幅减少数据传输量。
新增 UsageDailyHeatmapQuery / StoredUsageDailySummary 类型,
在 trait、SQL、内存实现中均补齐 summarize_usage_daily_heatmap 方法。
同时优化 docker-compose: postgres 增加空闲事务超时与 keepalive 参数,
gateway 增加健康检查配置。
2026-04-15 02:11:32 +08:00
fawney19
53acfbabf6
refactor(gateway): 重构 ai pipeline 规划链路
2026-04-14 01:27:04 +08:00
fawney19
4fd2b4a014
fix(gateway): 修复 balance 刷新去重键冲突、usage 状态回退与测试竞态
...
- balance_cache: 引入实例级 refresh key 防止多实例共享进程级 HashSet 冲突
- InMemoryUsageRepo: 阻止 pending/streaming 状态覆盖已终结(completed/failed/cancelled)记录
- usage 同步测试: 等待条件从 is_some() 改为检查 status=="completed" 避免竞态
- wallet 测试: 增加轮询等待 wallet 扣款完成
- 整理 import 语句与 tests 模块位置
2026-04-13 16:48:05 +08:00
AAEE86
b2d85d70ca
refactor(runtime): 优化管理端摘要查询与维护聚合链路
...
- 为 provider catalog key 和 video task 列表增加 summary/page 查询与排序能力,减少列表场景读取重字段
- 将多处 SQL 结果读取改为流式收集,降低 `fetch_all` 的内存占用
- 把日/小时统计、钱包日用量等维护任务改为数据库侧 `CTE + upsert` 聚合
- 修复视频任务轮询更新时从本地 snapshot 回填稀疏字段,避免 `prompt` 和请求体信息丢失
2026-04-13 15:44:58 +08:00
fawney19
6aa16ec792
feat(data): 废弃 usage 表 HTTP/结算列,迁移至 settlement_snapshots 与 http_audits
...
- 新增迁移 20260413030000:标记 billing_status、finalized_at、request_headers 等列为 DEPRECATED
- 更新 baseline_v2.sql 同步废弃注释,BASELINE_V2_CUTOFF_VERSION 升至 20260413030000
- usage/sql.rs:inline body 阈值归零,强制所有 body 走 blob 存储;upsert 时清空 legacy header/output_price 列
- 查询层优先读 usage_settlement_snapshots 的 billing_status、finalized_at、output_price_per_1m
- runtime.rs:stale usage 处理同步写入 usage_settlement_snapshots;SELECT FOR UPDATE 改为 FOR UPDATE OF usage
- 前端:PerformanceAnalysis 页面重构为实时面板,新增 prometheus 工具函数与 monitoring API
2026-04-13 14:53:46 +08:00
fawney19
5bb08e6aa4
feat(gateway): 重构 usage 数据层、迁移系统与系统导入
...
数据库迁移:
- 引入 baseline v2 bootstrap,空库首次启动自动初始化
- 服务启动不再自动执行迁移,需显式 `--migrate` 运行
- 新增 pending migration 检测,schema 落后时拒绝启动
Usage 数据层:
- usage body 存储外部化为独立 blob 表
- 新增 HTTP audit 表拆分存储请求/响应头与 body ref
- 后台清理任务支持 legacy body ref 元数据迁移
- usage runtime 写入迁移到专用 tokio runtime(独立线程池, 8MB 栈)
系统导入/导出:
- 支持用户、API Keys、钱包数据的完整导入
- 兼容 legacy 与 v1.3+ 两种导出格式
其他改进:
- executor outcome 增加 runtime miss 诊断上下文
- 主 tokio runtime 栈大小调整为 8MB
- 前端 provider 管理支持 base URL 配置
- dev.sh 支持 --migrate 参数
2026-04-13 14:01:22 +08:00
fawney19
848f99d3e5
merge(pr287): absorb remaining rust branch changes
...
Absorb the remaining changes from PR #287 into aether-rust-pioneer after resolving conflicts locally and preserving the admin fixes already landed in this branch.
Closes #287
Co-authored-by: AAEE86 <ppk0227@hotmail.com >
2026-04-11 03:10:16 +08:00
fawney19
a54ac76688
fix(admin): restore pool key usage aggregates
2026-04-11 02:54:54 +08:00
AAEE86
174f11604a
fix(data): 统一 usage 内存仓储时间戳单位并通过格式检查
...
- 将 usage 内存仓储的秒级过滤条件转换为毫秒后再比较
- 汇总 provider api key 最近使用时间时将毫秒转换为秒
- upsert 在缺少 created_at 时默认写入毫秒时间戳
- 补充时间戳单位回归测试
- 调整 registry.rs 格式以通过 cargo fmt --all --check
2026-04-10 22:23:26 +08:00
fawney19
3f057628b7
fix: 修正用量失败状态判断与 Codex 会话头
2026-04-10 21:33:34 +08:00
AAEE86
b1f6fff0a5
fix(gateway): 修复 local finalize 与 usage 聚合相关测试失败
...
- 修正内存 usage 仓库的时间单位处理,恢复 stats/monitoring/dashboard/wallet/pool 聚合结果
- 允许 openai:compact 走 CLI 响应转换与本地 finalize cross-format 路径
- 更新 cross-format 测试夹具,显式启用 enable_format_conversion
- 调整 failover 测试优先级,消除候选平局导致的顺序不稳定
- 补齐 ai_pipeline 架构断言所需导入并清理残留 runtime 空目录
2026-04-10 18:27:02 +08:00
fawney19
010ab127e2
feat: 扩展 cache creation token 细分统计与 effective_input_tokens 计费逻辑
...
- 新增 cache_creation_ephemeral_5m/1h_input_tokens 字段,区分不同 TTL 的缓存写入 token
- 引入 effective_input_tokens(扣除 cache read 后的有效输入 token),暴露给 usage 接口
- billing 规则生成器支持 5m/1h ephemeral cache 独立定价与分级计费
- usage_mapper 增加 Claude/Anthropic 格式映射,修复 OpenAI responses 格式字段兼容性
- 迁移逻辑增强:支持 checksum 容错、applied/pending 数量日志、逐步执行信息输出
- executor 抽离 LocalExecutionRequestOutcome 类型,统一 sync/stream 路径返回语义
- provider-transport auth 层新增 complete passthrough headers 构建逻辑
- 前端 usage 类型全面补充 effective_input_tokens、cache_creation_tokens、total_input_context 字段
2026-04-10 17:44:55 +08:00
AAEE86
82c3c33610
fix(build): 修复网关构建失败并收口候选选择与 finalize 回归
...
- 补齐 DecisionTraceCandidate 新增字段,修复审计测试构造
- 修正 usage 内存仓库的 created_at_unix_ms 字段引用与秒/毫秒换算
- 将 build_minimal_candidate_selection 重构为输入对象,消除 clippy 参数过多问题
- 修复 admin global model created_at 旧字段残留引用
- 修复 openai:cli 与 openai:compact 同家族 finalize 在 needs_conversion=true 时的成功回落逻辑
- 清理 aether-gateway 中的 derive/default 与 needless borrow 等 clippy 问题
2026-04-10 17:23:40 +08:00
AAEE86
677b8f5acb
Merge remote-tracking branch 'upstream/aether-rust-pioneer' into rust
2026-04-10 15:08:32 +08:00
fawney19
5014e2f5fd
refactor: 抽离 AI pipeline 与调度共享能力逻辑
2026-04-10 01:46:14 +08:00
AAEE86
0b3f619280
fix: 号池列表统计与最后使用时间显示
...
- 为 usage 仓储新增按 provider_api_key_id 汇总请求数、Token、费用和最后使用时间的能力
- 在 /api/admin/pool/{provider_id}/keys 中优先使用 usage 汇总结果覆盖 request_count、total_tokens、total_cost_usd、last_used_at
- 补充数据层与网关侧回归测试,避免号池管理页统计全为 0 且最后使用为空
2026-04-09 15:10:21 +08:00
fawney19
5d96d6673b
refactor: 大规模模块拆分与代码精简,新增 ai-pipeline/data-contracts 独立 crate
...
- 新增 aether-ai-pipeline 和 aether-data-contracts crate,将 pipeline 逻辑与数据契约从 gateway 中解耦
- 重构 admin handlers:拆分单体模块为 auth/billing/endpoint/features/model/observability/provider/system 等独立子模块
- 合并 chat/cli 重复代码路径:精简 conversion、finalize、planner 中的 sync/chat/cli 分支
- 重构 scheduler/executor/data 层,引入 facade 模式降低模块间耦合
- 移除冗余的 intent 模块,将 plan_fallback/policy/stream_path/sync_path 迁移至 executor
- 前端适配:调整 admin API 调用和 provider 模型测试对话框
2026-04-07 02:50:19 +08:00
fawney19
8f26e1a31f
refactor: 移除独立 hub/proxy/executor/gateway crate,统一为 gateway tunnel 架构
...
- 删除 aether-hub、aether-proxy 独立项目及其 Dockerfile/配置
- 删除 crates/aether-executor 和 crates/aether-gateway 全部模块
- 新增 apps/ 目录作为应用入口
- 将 hub 概念重构为 gateway tunnel transport
- 将 executor 重构为 execution runtime
- 新增 tunnel.rs 合约定义和 testkit tunnel/execution_runtime 模块
- 更新 Python 服务层和测试适配新架构命名
2026-04-03 14:59:58 +08:00
fawney19
ddf18fed9a
feat: 扩展 Rust gateway 全功能模块,新增 billing/crypto/wallet crate 及完整数据层
...
- 新增 aether-billing、aether-crypto、aether-wallet 独立 crate
- aether-data 扩展 repository 层:announcements、auth_modules、billing、
candidate_selection、gemini_file_mappings、global_models、management_tokens、
oauth_providers、proxy_nodes、quota、users、wallet 等模块
- aether-gateway 新增 api/auth/billing/control/middleware/scheduler/usage/
video_tasks/hooks/maintenance/model_fetch/provider_transport 等功能模块
- 重构 executor decision 和 gateway state 为模块目录结构
- 新增 gateway router、frontdoor 路由层及对应测试
- Python 侧 API 路由重构,新增 compat/support 模块
- 前端 Logo 组件更新及 Provider 管理页面调整
2026-03-31 19:19:04 +08:00
fawney19
b5a0070023
feat: 引入 aether-runtime/cache/data/http/testkit 基础 crate,完善并发门控与审计系统
...
新增 crate:
- aether-runtime: 服务运行时基础设施(并发门控、分布式并发、指标、队列、优雅关闭、tracing)
- aether-cache: 通用 TTL 缓存与命名空间抽象
- aether-data: 数据访问层(PostgreSQL/Redis 后端、repository 模式)
- aether-http: HTTP 客户端封装(重试、配置)
- aether-testkit: 集成测试工具集(gateway/executor/hub/proxy fixture、等待、负载测试)
gateway 扩展:
- 引入 audit 模块(shadow 执行审计、决策链路追踪、请求审计 bundle)
- 引入 cache 模块(AuthContext 缓存、direct-plan bypass 缓存)
- 引入 data 模块(auth/candidates/config/usage/video_tasks 数据访问)
- 集成 ConcurrencyGate/DistributedConcurrencyGate 请求门控
- 新增本地 auth 拒绝、过载响应构建器
- 补充 control/auth_cache/video/concurrency 集成测试
aether-proxy 扩展:
- AppState 集成 stream_gate / distributed_stream_gate 并发门控
- 新增 ProxyAdmissionError 及准入拒绝流程
- stream_handler 补充门控饱和/不可用场景测试
- 配置与注册客户端逻辑完善
aether-hub 扩展:
- main.rs 引入运行时初始化、指标端点、健康检查
- local_relay 重构为 lib.rs 暴露公共接口
2026-03-24 15:12:56 +08:00