fix: 修复回流 main 时残留的冲突标记(billing.lua / billing_test.go 取 release/v2.0.x 干净版本)

This commit is contained in:
root
2026-10-20 22:05:19 +08:00
parent a073423867
commit 3ef918a87a
2 changed files with 5 additions and 10 deletions

View File

@ -72,8 +72,6 @@ local DEFAULT_PRICES = {
}
plugin.prices = DEFAULT_PRICES
<<<<<<< HEAD
=======
-- ===== 规则 → 价格表编译(全部在插件内) ==============================
--
-- billing 没有任何内核逻辑(issue #1 的方向):规则文件、编译、计价、账目、
@ -479,7 +477,6 @@ plugin.http = {
-- 测试/运维直调导出(/api/plugins/billing/call/...);不是内核接口。
plugin.exports = { "rules_get", "rules_put", "rules_add", "rules_delete" }
>>>>>>> 7941b41 (refactor(billing)!: 计费全部沉入插件,内核零 billing 代码;规则由插件自持)
-- Default prompt-cache discount. 0.1 = a cache read costs a tenth of a fresh
-- token, which is what DeepSeek/Qwen/Kimi and most others charge. It can be
-- overridden per price entry (prices.models.<m>.cache_discount) or globally by
@ -597,7 +594,11 @@ local function priceFor(payload)
-- look the same: an unpriced model silently costing 0 is the most dangerous
-- failure mode a cost plugin has, because the bill still adds up and just
-- quietly under-reports. It is counted separately and surfaced in the UI.
out = {
-- ★ local 是必须的:此前写的是全局 `out = {`,而 priceFor 每个请求都会调用,
-- 于是这个表挂在 VM 级全局变量上跨请求残留/泄漏(GitCode issue #1 顺带发现)。
-- 功能上因为每次整体重建而侥幸正确,但它是共享可变状态,任何提前 return 或
-- 后续分支忘了重建都会让上一单的价格漏到下一单 —— 计费错误不会报错。
local out = {
prompt = d.prompt or 0, completion = d.completion or 0,
per_request = 0, cache_discount = d.cache_discount, peak = d.peak,
-- nil = bill reasoning at the completion rate, which is what every
@ -644,8 +645,6 @@ local function priceFor(payload)
if kp.cache_discount ~= nil then out.cache_discount = kp.cache_discount end
if kp.peak ~= nil then out.peak = kp.peak end
end
<<<<<<< HEAD
=======
-- profile 级 default 策略(编译期写入 prices.default_mode)在这里落地:
-- `free` = 运营声明"没有单独规则的源一律免费" ⇒ 计为已定价(不进 unpriced 统计);
@ -656,7 +655,6 @@ local function priceFor(payload)
out.priced = true
end
end
>>>>>>> 7941b41 (refactor(billing)!: 计费全部沉入插件,内核零 billing 代码;规则由插件自持)
return out
end