Skip to content

[upstream-port][backend] 模型广场关闭时 root 仍可访问定价接口 + 任务结算日志补 is_task #887

Closed
TokenNotIncluded/lmm-api-source
#2

Description

@LIghtJUNction

开发主线交接(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)

  • 34b19421 fix(pricing): allow root access when the model square is disabled (#7761)
  • b22a43b6 fix: 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

本批其余上游提交(已核对,不需要单独移植)

  • ba0e478e relaykit 中 tool_calls 与 assistant 文本并存:fork 的 to_oai_chat_req.go:313 已经是 if len(mediaMessages) > 0,已包含。可以考虑只移植上游的回归测试(request_registry_test.go +80 行)。
  • 3f926c3e perf_metrics ClassifyRelayOutcome: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。

Activity

  1. added
    botOpened by the maintenance bot
    upstream-portQuantumNous/new-api upstream commit port candidate
    on Oct 12, 2026
  2. LIghtJUNction commented on Oct 30, 2026

    @LIghtJUNction
    CollaboratorAuthor

    巡检(2026-10-31 04:32 Asia/Taipei)

    已在 TokenNotIncluded/lmm-api-source@22cda9e9 启动后端 CloudAgent 移植本 issue(定价模块关闭时 root 可读 + 任务结算日志 is_task):

  3. LIghtJUNction commented on Oct 30, 2026

    @LIghtJUNction
    CollaboratorAuthor

    小时巡检核对(2026-10-31 05:36 Asia/Taipei):

    • CloudAgent bc-45d5c27a-d140-52d7-adc3-53a44f7db475 已结束;source PR #2 已 squash 合并为 e6013777(pricing_http root 在模块关闭时放行 + task_log 强制 is_task)。
    • recipkg tip 经 owner #970 钉 pin generated/lmm-api-source → e6013777(tip 9fa33bb)。
    • 本 issue 已于 2026-10-30T20:57Z 以 completed 关闭;本小时无额外动作。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    botOpened by the maintenance botupstream-portQuantumNous/new-api upstream commit port candidate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions