Repository navigation
[upstream-port][backend] 模型广场关闭时 root 仍可访问定价接口 + 任务结算日志补 is_task #887
Copy link
Copy link
Closed
TokenNotIncluded/lmm-api-source
#2Labels
botOpened by the maintenance botOpened by the maintenance botupstream-portQuantumNous/new-api upstream commit port candidateQuantumNous/new-api upstream commit port candidate
Description
开发主线交接(2026-10-12)
开发默认主线现为 wip/rust-core-go-extensions;旧单体 main 与 traditional 冻结于 3948a0a1ee1cefdd016a7aa45a11851545bb4b85。分支交接不是发布、部署或验收通过。原问题、源码基线、测试与未完成项保留;旧单体路径仅作历史证据,后续先在微服务源码重新确认并按职责移植,不回灌旧数据库/权限/资金实现。
主线/S11 跟踪:#895。Extore 商品同步:#894,未验收,禁止部署,尤其禁止合并/推送 Extore main。
上游提交(QuantumNous/new-api,2026-10-12,42e694eb..ba0e478e)
34b19421fix(pricing): allow root access when the model square is disabled (#7761)b22a43b6fix: mark task settlement logs with is_task for tiered billing display (#7446)
改了什么,对 LMM 的意义
- 34b19421:管理员在「顶栏模块」里关掉
pricing(模型广场)后,HeaderNavModuleAuth("pricing")对所有人直接 403,root 也拿不到/api/pricing,后台依赖定价数据的管理页面就不能用了。上游的改法是:模块关闭且请求带Authorization时改走RootAuth(),只放行 root,公开广场仍然关闭。fork 的apps/api-go/middleware/header_nav.go的HeaderNavModuleAuth和上游修复前一样(约 105–115 行),router/api-router.go:185-186的GET /api/pricing、POST /api/pricing/runtime都会受影响。fork 前端http-client.ts会带Authorization: Bearer <access token>,所以这个条件能触发。 - b22a43b6:异步任务的差额结算和退款日志(
taskBillingOther)没带is_task,只有首次扣费日志(task_billing.go:40)带了。上游前端靠is_task选择任务档位的渲染分支,缺了它会把差额/退款日志当成普通 relay 的动态计费显示。fork 的apps/api-go/service/task_billing.go:122的taskBillingOther同样缺这个字段(fork 用的是map[string]interface{},加一行other["is_task"] = true就行)。fork 前端usage-logs/types.ts已经声明了is_task,目前还没有地方读它,这一条主要是让日志数据一致,也方便以后移植前端。
fork 中的位置
apps/api-go/middleware/header_nav.go(+ 上游测试middleware/header_nav_test.go,74 行,可以移植)apps/api-go/service/task_billing.go(taskBillingOther),测试放在apps/api-go/service/task_billing_test.go
本批其余上游提交(已核对,不需要单独移植)
ba0e478erelaykit 中 tool_calls 与 assistant 文本并存:fork 的to_oai_chat_req.go:313已经是if len(mediaMessages) > 0,已包含。可以考虑只移植上游的回归测试(request_registry_test.go+80 行)。3f926c3eperf_metricsClassifyRelayOutcome:fork 没有pkg/perf_metrics/outcome.go,之前审查时已经跳过上游的 outcome 分类设计(a5b40663,fork 用自己的 metrics/StreamStatus),不适用。- 前端提交 3827fd83 / bbf60b49 另开 issue 跟踪(要用 Opus)。
冲突与风险
- 34b19421 会让关闭广场后的
/api/pricing*对 root 继续可用,需要确认 fork 的authHelper在Authorization无效时会返回 401,不会走到TryUserAuth;另外要注意 HumanGrant / AI 会话 token(feat(auth): add HumanGrant scoped AI sessions (default enabled, admin toggle) #865)走 RootAuth 时的权限范围不能被放大。 - b22a43b6 只是在日志 other 字段里加一个键,不改扣费金额。
测试
cd apps/api-go && go test ./middleware/... ./service/... && go vet ./...- 新增:模块关闭时匿名请求 403、普通用户 403、root 200(参考上游 header_nav_test.go);
taskBillingOther返回结果里有is_task=true CGO_ENABLED=0 go build ./...
工作量
小:约 1–2 小时。纯后端,可以和 #816/#817 一起做,也可以单独开一个后端移植 PR。
由 bot 每小时巡检生成(fork main c289dbda,upstream head ba0e478e)。只开了 issue,没写代码,没开 PR。
Metadata
Metadata
Assignees
Labels
botOpened by the maintenance botOpened by the maintenance botupstream-portQuantumNous/new-api upstream commit port candidateQuantumNous/new-api upstream commit port candidate
Activity
LIghtJUNction commentedon Oct 30, 2026
巡检(2026-10-31 04:32 Asia/Taipei)
已在
TokenNotIncluded/lmm-api-source@22cda9e9启动后端 CloudAgent 移植本 issue(定价模块关闭时 root 可读 + 任务结算日志is_task):LIghtJUNction commentedon Oct 30, 2026
小时巡检核对(2026-10-31 05:36 Asia/Taipei):
bc-45d5c27a-d140-52d7-adc3-53a44f7db475已结束;source PR #2 已 squash 合并为e6013777(pricing_httproot 在模块关闭时放行 +task_log强制is_task)。generated/lmm-api-source→e6013777(tip9fa33bb)。