Commit Graph

1131 Commits

Author SHA1 Message Date
k88936 adfae5adee fix(会员计价): 零时长账期窗口按非法入参拒绝
- module-runtime/membership/upgrade.rs:账期窗口校验由 < 改为 <=,cycle_resets_at 等于 cycle_started_at 时不再退化成「剩余比例为 0」

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 14:59:26 +08:00
k88936 73b53a9dd1 fix(会员计价): ceil_div 零分母改为 debug_assert 暴露
- module-runtime/membership/upgrade.rs:ceil_div 增加 debug_assert!(denominator != 0),零分母在测试里立即失败,不再被静默算成 0 元

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 14:58:21 +08:00
k88936 14ddf09f30 Merge remote-tracking branch 'origin/master' into feat/pricing-plan
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m28s
Project CI / Backend tests (pull_request) Failing after 53s
Project CI / Native shell tests (pull_request) Failing after 1m33s
Project CI / Frontend tests (pull_request) Failing after 1m2s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 5m43s
Project CI / AI game creator shell web tests (pull_request) Failing after 45s
Project CI / Repository checks (pull_request) Failing after 1m3s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 5m24s
2026-10-03 13:36:04 +08:00
k88936 90e520fdba refactor(会员): 升级报价改为只读,不再刷新账期与钱包
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
- profile.rs:build_profile_membership_upgrade_quote_record 不再调用 refresh_profile_wallet_expiring_points,改用只读投射 project_profile_membership_cycle_at 把账期推进到当前时刻
- profile.rs:报价接口不再写库 / 发账本,不会提前消耗用户的懒刷新,同时保持与建单、结算同口径

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 13:32:54 +08:00
k88936 4eb4c6ae17 docs(会员): 补充会员账期推进与升级报价的逻辑注释
- profile.rs:advance_profile_membership_cycle_to 补充「锚点恒定、期号可推导、落库仅作单调水位、时钟回拨不重放」说明
- profile.rs:refresh_profile_membership_cycle 补充未换期(含时钟回拨)直接返回的守卫注释
- profile.rs:membership_upgrade_quote_input 注明期号即账期水位、年付补差按剩余整月折算
- profile.rs:build_profile_membership_upgrade_quote_record 与 build_profile_membership_order_snapshot 补充账期口径说明
- upgrade.rs:注明年付补差剩余整月来自单调水位、不会因重复刷新漂移

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 13:31:25 +08:00
k88936 16f92f2110 refactor(会员): 会员档位目录移除无用的 sort_order,统一按 rank 排序
- module-runtime catalog.rs:RuntimeProfileMembershipPlanRecord 与种子目录去掉 sort_order,目录单测改为按 rank 断言
- module-runtime domain.rs/commands.rs:后台改价入参与构建函数去掉 sort_order
- spacetime-module profile.rs:profile_membership_plan 表结构去掉排序列,membership_plan_records 改按 rank 升序读取
- shared-contracts runtime.rs:ProfileMembershipPlanResponse 与 AdminUpsertProfileMembershipPlanRequest 移除 sortOrder
- spacetime-client:客户端签名、mapper 与 module_bindings 同步移除 sortOrder
- api-server runtime_profile.rs:响应构建与测试夹具去掉 sortOrder
- admin-web:AdminMembershipPlanPage 移除「排序」输入,档位列表改为按 rank 排序,契约类型同步
- packages/shared:ProfileMembershipPlanRecord 去掉 sortOrder,充值弹层改为直接沿用后端的 rank 顺序
- docs:泥点三池与会员计费后端设计同步目录字段与后台能力说明

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 13:14:04 +08:00
k88936 e5de57f7f8 feat(会员): 管理接口校验调用方身份、写入侧拦倒挂目录、会员订单冻结结算快照
- profile.rs:10 个配置管理 procedure(任务/钱包/充值商品/会员档位/升级报价)补 require_editor_generation_runtime_service_identity,只允许 api-server 服务身份调用
- catalog.rs:新增 validate_runtime_profile_membership_plan_row_against_catalog,写入侧校验 rank 与月价/年价/每期泥点严格递增并拒绝倒挂
- errors.rs:新增 RuntimeProfileFieldError::InvalidMembershipPlanOrder 及中文文案
- lib.rs:导出 validate_runtime_profile_membership_plan_row_against_catalog
- catalog.rs:新增 4 个单测覆盖种子目录、单调改价、倒挂价格/泥点与重复 rank
- profile.rs:会员订单建单时冻结档位/价格/补点快照到订单行,支付结算只认快照,历史 Pending 订单回退按目录重算
- profile.rs:新增 project_profile_membership_cycle_at 只读投射账期,建单金额不再写库刷新,与预览/结算口径一致
- profile.rs:支付结算不再因档位下架拒绝已受理订单,避免付款回调卡死
- profile.rs:新增 2 个单测覆盖订单快照写入读回与无快照回退

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 12:46:50 +08:00
k88936 7acae0d308 后台契约与接口透出会员变更快照与用户会员状态
- shared-contracts 新增 AdminMembershipOrderChangePayload 与 AdminProfileMembershipPayload
- AdminProfileWalletPayload.membership_limited_points 改名 monthly_points
- AdminRechargeOrderEntryPayload 增加 membership_change 快照字段
- AdminUserDetailResponse 增加 membership 字段
- admin_recharge 映射会员订单快照与用户会员中心投影

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 11:48:24 +08:00
k88936 6d04f88f41 让充值商品默认档迁移识别旧迁移遗留的行
resolve_default_point_product_migration 同时识别停用的「首充双倍」行(赠送为 0 或等于面额)与在售的「首充加赠」行
更新迁移单测:disabled_seed 按旧迁移后的真实状态构造,并补充「首充加赠」用例

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 11:15:37 +08:00
k88936 92917f57c9 升级报价遇到目录倒挂时改为报错
quote_runtime_profile_membership_upgrade 用 checked_sub 替换 saturating_sub,价格或每期泥点倒挂时返回 InvalidQuoteInput
新增 inverted_catalog_price_and_points_are_rejected 覆盖原本会算成 0 元升级的场景

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 11:15:34 +08:00
k88936 119eb7c8b3 收紧后台会员档位与充值商品的校验和报错文案
可购买档位新增 period_points == 0 拒绝;不可购买档位固定使用目录种子的并发上限与模型权限
InvalidRechargeProductTier 拆为 InvalidRechargeProductKind 与 InvalidRechargeProductFields,报错不再误导运营

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-03 11:15:30 +08:00
k88936 06eb4e668c 修复(计费): 升级报价总期数改由周期类型推导
- 删除 RuntimeProfileMembershipUpgradeQuoteInput.cycle_count 入参,改由 target.cycle_kind.cycle_count() 推导(月付 1 / 年付 12),杜绝入参期数与周期类型不一致导致按错误期数计费
- 报价数值自检的期号上界改为相对推导出的总期数判断
- spacetime-module 构造报价入参时不再传 cycle_count
- 同步升级报价单测:年付 12 期、当前第 3 期 → 剩余完整月数 9,金额与测试夹具一并修正
- 同步设计文档 §3 入参与自检说明、§5.3 年付示例(remainingFullMonths 9 / amountCents 158334)

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 20:26:48 +08:00
k88936 bc3d8dc7da 注释(计费): 记录会员目录重建暂不缓存的原因
runtime_profile_membership_plan_catalog 加 TODO,说明每次重建只有 5 行、开销可忽略

按作者意见标记 wont fix,暂不改 LazyLock / &'static 缓存

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 20:06:07 +08:00
k88936 047e6d72e4 重构(计费): 会员档位 rank 解析改为可失败返回
runtime_profile_membership_plan_rank 返回 Option<u8>,目录缺行时返回 None

去掉 unwrap_or(0),不再把目录缺失伪装成 Normal 而误报 NotUpgrade

plan_rank_follows_catalog_order 测试断言同步改为 Some(..)

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 20:05:51 +08:00
k88936 83dbd0cc77 修复(计费): 升级报价拒绝越界数值入参
- 新增 RuntimeProfileMembershipUpgradeRejection::InvalidQuoteInput 及 wire token

- 报价前校验期号范围与账期窗口,避免 saturating_sub 静默夹取

- 新增 invalid_numeric_input_is_rejected 回归测试

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:57:04 +08:00
k88936 f09701f6d4 重构(计费): module-runtime 去掉通配 re-export 改为策展导出
- lib.rs 移除 pub use civil_calendar::*,公历基元只保留 civil_calendar:: 命名空间

- lib.rs 移除 pub use membership::*,改为只重导出对外的会员契约符号

- 未改动 spacetime-module / spacetime-client / api-server,现有引用保持可用

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:56:54 +08:00
k88936 8e1471d7af 测试(计费): 固化会员目录价格与泥点随 rank 递增的不变量
在 catalog 文档写明升级补差依赖的单调性不变量,并新增回归测试断言 rank 越高月价、年价、每期泥点严格递增

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:23:36 +08:00
k88936 58a79a2e4e 修复(计费): 北京本地时间换算校验当日时刻范围
beijing_local_micros 增加 time_of_day_micros 越界即返回 0 的校验,避免越界时刻被解释成另一天

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:22:36 +08:00
k88936 5ab6f161d0 文档(计费): 修正北京本地时间换算的返回值说明
beijing_local_micros 文档由「本地日期不存在返回原值」改为「返回 0」,与实际实现一致

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:13:31 +08:00
k88936 f810064657 文档(计费): 澄清档位排序以目录 rank 为准
RuntimeProfileMembershipPlan 文档改为说明排序由目录 rank 决定、枚举不实现 Ord,避免误以为变体顺序是排序契约

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:13:10 +08:00
k88936 8b8213f0c8 修复(计费): 公历反算避免 i64 溢出
civil_from_days 用 saturating_add 计算日序号偏移,消除 date_key 接近 i64::MAX 时的加法溢出

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:12:34 +08:00
k88936 603ecb0887 修复(计费): 星期换算避免 i64 溢出
weekday_from_date_key 先按 7 取模再加偏移,消除 date_key 接近 i64::MAX 时的中间加法溢出

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:11:59 +08:00
k88936 abc92d230b chore(契约): 三池余额 DTO 交给 ts-rs 生成,同步 SpacetimeDB 绑定
- 给 ProfileMudPointBalanceResponse 加 ts-bindings 特性下的 ts_rs::TS 导出,u64 标 ts(type = "number") 避免前端分叉成 bigint
- 新增 packages/shared/src/contracts/generated/ProfileMudPointBalanceResponse.ts,runtime.ts 改为 re-export 不再手写第二份字段
- 新增 packages/shared/src/utils/mudPoints.ts:派生展示用合计与北京时间月度刷新文案
- 同步 spacetime-client 生成绑定:升级报价改名为 snapshot,与 module 侧改动对齐

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 19:00:08 +08:00
k88936 c772600d59 feat(会员): 新增补差升级报价接口、后台档位读写与订单权益快照
新增 POST /api/profile/membership/upgrade-quote:只读报价,下单时后端用同一纯函数重算

新增后台 /admin/api/profile/membership-plans 的读取与按档位改价改权益接口

订单与管理端契约补上会员权益变更快照(变更前后档位、周期、补点、有效期与价格拆分)

报价结果统一走「模块侧快照 + application 记录侧投影」两段式,与既有 DTO 约定一致

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 17:36:26 +08:00
k88936 703a24b682 重构(计费): 余额接口并列暴露三池并去掉会员 tier 字段
- 余额响应改为每日免费 / 月度 / 永久三池并列,不再暴露总额与会员限时泥点
- 会员响应与充值中心以 plan 取代 tier,充值中心改为输出会员目录
- 微信虚拟支付按目录档位校验会员商品,不再依赖会员商品配置行
- 同步 shared-contracts 测试夹具到新的三池与 plan 口径

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 16:59:49 +08:00
k88936 e98564e13c 重构(会员): 会员目录与自然月账期落到数据库与领域层
- 领域层新增会员档位枚举、自然月账期、目录快照与补差报价入参,删除旧 tier 相关函数
- profile_membership 表以 plan 与自然月期数取代 tier 与固定 30 天周期
- profile_recharge_order 末位追加会员权益变更快照,供人工复核退款
- profile_membership_plan 目录表成为价格与权益的唯一真相源,新增后台读写接口
- 充点商品收敛为六档且取消首充赠送,旧播种行按新规则迁移
- 充值中心改为输出会员目录,不再输出会员商品行与权益矩阵
- 重新生成 SpacetimeDB 绑定并同步客户端映射与 facade

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 16:59:34 +08:00
kdletters 3a0d92b622 Anthropic 直通只用 x-api-key 出示 Router 凭据
Project CI / AI game creator shell Rust crates (push) Successful in 1m55s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m20s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m36s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m24s
Project CI / Frontend tests (push) Successful in 3m27s
Project CI / Repository checks (push) Successful in 3m43s
Project CI / Backend tests (push) Successful in 5m15s
Project CI / AI game creator shell web tests (push) Successful in 1m47s
Project CI / Native shell tests (push) Successful in 7m34s
- llm:原生 Anthropic 直通不再同时带 Authorization: Bearer,只发 Anthropic 规范的 x-api-key
- 实测:Router 对同一次 /v1/messages 请求,只带 x-api-key 时 200(4.7s 返回真实回复),同时带 Bearer 时 79 秒后被断开
2026-10-02 16:14:56 +08:00
k88936 03073564b1 重构(会员): 会员表列改为 plan 与自然月账期,订单落权益变更快照
profile_membership 删除 tier / cycle_period_days 与四个会员商品权益列,末位追加 plan、cycle_index、cycle_count、cycle_kind

profile_recharge_product_config 删除 tier 与四个会员权益列,只保留充点商品;会员商品不再落该表

profile_recharge_order 末位追加会员变更快照列(变更类型、前后档位、前后周期、补点数、前后到期日 / 刷新日、价格快照)

会员周期刷新改为按北京时间自然月从原始锚点重算,到期清月度余额、永久泥点不受影响

会员购买与升级改走目录表实时价格:有效期内同周期升档按补差报价,补点向下取整、金额向上到分

会员账本幂等锚改为订单维度(membership-period-grant / membership-upgrade-grant 加订单 ID)

充点商品迁移规则改为六档无首充赠送,旧首充赠送行与停用的 ¥128 / ¥328 行一并归一

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 15:54:28 +08:00
kdletters 3e9bc76c2c Anthropic 路由改回原生优先、桥接兜底
Project CI / AI game creator shell Rust crates (push) Successful in 1m46s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m31s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m38s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m33s
Project CI / Frontend tests (push) Successful in 2m41s
Project CI / Backend tests (push) Successful in 4m17s
Project CI / Repository checks (push) Successful in 2m51s
Project CI / AI game creator shell web tests (push) Successful in 1m52s
Project CI / Native shell tests (push) Successful in 5m49s
- llm:/api/llm/anthropic/* 先按 Anthropic 原样直通 Router 的 /v1/messages(20 秒首包上限),拿到 2xx 就直接透传
- llm:直通返回非 2xx、连接失败或首包超时才回退到 Anthropic→Chat 协议桥接,并记录 model/status 便于定位
- 测试:两条 Anthropic 路由用例改为「原生先被拒 + 桥接命中」的两段式 mock
2026-10-02 15:49:01 +08:00
k88936 01c7cc8b66 重构(会员): 档位身份改为 plan 枚举,价格以目录表为真相源
- 领域层清理:删除 RuntimeProfileMembershipTier 及旧的 tier 别名体系
- 会员目录行改名 RuntimeProfileMembershipPlanRecord,快照新增 enabled 字段
- 补差升级报价入参改为「目录表解析出的当前/目标套餐快照」
- 新增会员商品 product_id 编解码(档位 + 周期,严格解析拒绝未知 token)
- 报价与允许操作矩阵改为读取快照 rank / enabled,不再走编译期常量

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 15:38:52 +08:00
kdletters 580c74759a Anthropic 桥接对上游一律流式,并补非流式聚合
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m19s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m4s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m30s
Project CI / AI game creator shell Rust crates (push) Successful in 1m17s
Project CI / Frontend tests (push) Successful in 3m14s
Project CI / Repository checks (push) Successful in 3m49s
Project CI / Backend tests (push) Successful in 5m45s
Project CI / AI game creator shell web tests (push) Successful in 1m51s
Project CI / Native shell tests (push) Successful in 6m47s
- anthropic_bridge:向 Router 一律请求 stream=true,兼容只接受流式 chat 的上游
- anthropic_bridge:新增 SSE 聚合,客户端要非流式时在网关侧拼回 OpenAI 形状再转 Anthropic message
- llm:非流式分支按上游返回形状选择直读 JSON 或聚合 SSE
- 测试:新增聚合单测(文本 + tool_calls + usage → Anthropic tool_use 还原)
2026-10-02 15:29:42 +08:00
kdletters 21a8886c4c AGC Anthropic 网关改为桥接 Router 的 Chat Completions
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m28s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 1m56s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m23s
Project CI / AI game creator shell Rust crates (push) Successful in 1m34s
Project CI / Frontend tests (push) Successful in 3m11s
Project CI / Repository checks (push) Successful in 3m43s
Project CI / Backend tests (push) Has been cancelled
Project CI / AI game creator shell web tests (push) Has been cancelled
Project CI / Native shell tests (push) Has been cancelled
- llm/anthropic_bridge:新增 Anthropic Messages → OpenAI Chat Completions 请求转换(system、messages、tool_use、tool_result、图片、工具名安全化与还原)
- llm/anthropic_bridge:新增 OpenAI SSE → Anthropic SSE 流式翻译(message_start、content_block_start/delta/stop、message_delta、message_stop,tool_calls 还原成 tool_use)
- llm:/api/llm/anthropic/v1/messages 不再打现网不可用的 Router /v1/messages,改走转换后的 /v1/chat/completions;非流式响应同样翻译回 Anthropic message
- llm:删除只服务旧直通的 Anthropic 流式结算辅助,结算点改为翻译器产出 message_stop 或流结束
- 测试:新增请求转换、工具名还原、流式翻译单测;Anthropic 路由测试改为断言 Chat Completions 上游与 Anthropic 形状回包
2026-10-02 15:09:52 +08:00
k88936 71c778ccee feat(会员): 会员档位目录随充值商品配置播种
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m23s
Project CI / Backend tests (pull_request) Failing after 28s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m56s
Project CI / Frontend tests (pull_request) Successful in 2m59s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m0s
Project CI / Native shell tests (pull_request) Successful in 7m6s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 11m24s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 13m27s
- 新增 ensure_default_profile_membership_plan,表为空时按会员目录种子整表播种。
- 播种入口挂在 ensure_default_profile_recharge_product_config,表非空时保留后台改价。
- 设计文档 §10 改为「已确认输入 + 实施状态」,记录三项拍板结论。
- 设计文档补充实施约束:module-runtime 与 spacetime-module 相互依赖,领域层清退必须与 schema 变更同批提交。
- 设计文档列出待落地清单(会员遗留清退、三池 DTO、报价接口、充点 6 档、前端同步)。
2026-10-02 15:02:15 +08:00
k88936 1790ddff6a Revert "重构:清退会员遗留档位与商品权益字段"
This reverts commit 103f3b548a.
2026-10-02 15:00:04 +08:00
k88936 103f3b548a 重构:清退会员遗留档位与商品权益字段
- 删除 RuntimeProfileMembershipTier 枚举与会员权益快照/记录。
- 会员快照与记录的 tier 改为 plan 枚举,新增 cycle_index / cycle_count / cycle_kind。
- 充点商品快照/记录与配置快照/记录移除 tier 及四个 membership_* 字段。
- 充值中心快照/记录改用 membership_plans,取代 membership_products 与 benefits。
- 充点商品重播种为六档并取消首充赠送,删除会员商品构造与档位查表 helper。
- 后台充值商品 upsert 只接受泥点商品,会员商品改由会员计划目录维护。
2026-10-02 14:55:31 +08:00
k88936 61d4db4610 feat(会员): 新增会员计划目录表 profile_membership_plan
- spacetime-module:新增 profile_membership_plan 表,主键为档位枚举 RuntimeProfileMembershipPlan,一行一档承载月价 / 年价 / 每期额度 / 模型权限 / 并发上限
- migration.rs:表目录登记 profile_membership_plan
- spacetime-client:重新生成绑定,新增目录表与档位 / 模型权限枚举
- docs:后端数据契约新增 profile_membership_plan 说明,并把表定义源码路径修正为 runtime/active/profile.rs

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:49:43 +08:00
k88936 f6fbd2a392 chore(会员): 删除未被引用的旧表定义副本
- spacetime-module:删除 src/runtime/profile.rs,它未被 src/runtime.rs 挂载(真正生效的是 runtime/active/profile.rs)
- 避免设计文档与实现指向失效文件,也避免后续删列改动误落两份

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:36:16 +08:00
k88936 26e1ea9e27 feat(泥点): 账本来源追加会员升级补点
- module-runtime:RuntimeProfileWalletLedgerSourceType 末尾追加 MembershipUpgradeGrant,保持枚举只追加
- shared-contracts:新增 PROFILE_WALLET_LEDGER_SOURCE_TYPE_MEMBERSHIP_UPGRADE_GRANT 常量
- api-server:后台枚举索引映射与来源格式化支持新来源,并补单测断言
- spacetime-client:手写 mapper 与生成绑定同步新增变体
- packages/shared 与主站前端:钱包流水来源标签新增「会员升级补点」

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:33:16 +08:00
k88936 ba22d178d3 重构:会员领域模块归并到 membership 目录
- 把 membership_catalog/cycle/limits/upgrade 四个文件移入 src/membership/ 并去掉公共前缀
- 新增 membership/mod.rs 统一声明子模块并按依赖顺序导出
- lib.rs 改为 pub mod membership,删除旧的四个模块声明
- membership/upgrade.rs 内部引用改为同级模块路径
- 无行为变化,cargo test -p module-runtime 全通过

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:21:01 +08:00
k88936 2b77fa08c3 领域层:新增会员补差升级报价纯函数
- 新增 membership_upgrade.rs:quote_runtime_profile_membership_upgrade 与 RuntimeProfileMembershipUpgradeQuoteInput / RuntimeProfileMembershipUpgradeQuote
- 月付按「新月价 − 当前月价」「新每期额度 − 当前每期额度」;年付按 (新年价 − 当前年价)/12×(后续完整月数 + 本期剩余比例)
- check_runtime_profile_membership_upgrade_allowed 实现允许操作矩阵:非会员 / 周期变更 / 同档降档 / 目标不可购买一律拒绝
- membership_cycle_remaining_ratio_ppm 计算本期剩余比例(ppm,向下取整)
- 金额向上取到分、补点向下取整;有效期 / 刷新日 / 期数保持不变
- 单测复现 spec 示例:Plus 月→Pro 月 ¥200 / 2500 点 / 余额 3115;Plus 年→Pro 年 ¥1083.34 / 1250 点 / 余额 1865
- 设计文档同步报价函数签名与「后续完整月数 = cycle_count − cycle_index」口径

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:11:54 +08:00
k88936 33a4c8dbc3 领域层:新增会员计划目录种子与档位解析
- membership_catalog.rs:runtime_profile_membership_plan_catalog 一行一档(Starter ¥39/400/¥390、Plus ¥99/1150/¥990、Pro ¥299/3650/¥2990、Max ¥699/8650/¥6990、Normal 全 0 且不可购买)
- 新增 RuntimeProfileMembershipPlanCatalogRow 与 RuntimeProfileMembershipPlanSnapshot
- resolve_runtime_profile_membership_plan_snapshot 按所选周期取月价 / 年价;rank 与可购买判定只来自目录
- 单测覆盖档位覆盖与排序、价格与点数、年价独立存储、Normal 语义、周期取价
- 设计文档同步登记目录纯函数入口

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:10:10 +08:00
k88936 969ee329d7 领域层:新增会员自然月账期与并发上限纯函数
- membership_cycle.rs:北京时间锚点解析、自然月推进与月末夹取(1/31 → 2/28 → 3/31,从原始锚点重算)、期窗口、到期日、本期剩余微秒
- membership_limits.rs:并发上限哨兵 MEMBERSHIP_UNLIMITED_CONCURRENCY = 128 与 is_unlimited_concurrency
- lib.rs 注册并导出两个模块
- 单测覆盖闰年、跨年、窗口连续性、零索引归一、哨兵判定
- 设计文档同步:membership_cycle_window 去掉无用的 cycle_kind 形参并列出账期推进基元

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:09:04 +08:00
k88936 741b179ca5 重构:抽出公历日期基元为独立模块 civil_calendar
- 新增 server-rs/crates/module-runtime/src/civil_calendar.rs:days_in_month / is_leap_year / days_from_civil / civil_from_days / weekday_from_date_key
- application.rs 删除上述重复实现,改为引用新模块,行为不变
- 新模块自带单元测试:闰年规则、日序号往返、已知日期星期
- 后续会员自然月账期、分析维表等纯日期逻辑统一复用该模块

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:08:04 +08:00
k88936 b827c93d39 领域层:新增会员档位、周期、模型权限与变更类型枚举
- 新增 RuntimeProfileMembershipPlan { Normal, Starter, Plus, Pro, Max } 作为档位权威身份,取代旧 RuntimeProfileMembershipTier
- 新增 RuntimeProfileMembershipCycleKind:月付 1 期、年付 12 期(每期仍为一个自然月)
- 新增 RuntimeProfileMembershipModelAccess { Basic, Full } 与 RuntimeProfileMembershipChangeKind { Purchase, Upgrade }
- 四个枚举各带 as_str 与 parse,未知对外 token 返回 None,由调用方显式拒绝
- 新增集成测试 tests/membership_plan_enum.rs:token 往返、Normal 不可购买、期数映射、未知 token 拒绝

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-02 14:06:20 +08:00
lhk229 aad5a0bcef 修复公开模型目录测试遗漏协议字段
Project CI / AI game creator shell Rust crates (push) Successful in 1m43s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m34s
Project CI / Backend tests (push) Successful in 5m23s
Project CI / Native shell tests (push) Successful in 6m24s
Project CI / Frontend tests (push) Successful in 2m21s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 10m57s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 11m21s
Project CI / AI game creator shell web tests (push) Successful in 1m54s
Project CI / Repository checks (push) Successful in 2m23s
补齐公开模型目录完整 JSON 断言中的 protocol 字段。
同步后端契约文档中的回归验证说明。
验证模型目录定向测试、编码检查、文档索引和 Rust 格式检查通过。
2026-10-02 13:29:08 +08:00
kdletters 6bf57c1e51 AGC 把执行器与线协议拆成正交维度
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m1s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 1m37s
Project CI / AI game creator shell Rust crates (push) Successful in 1m25s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m6s
Project CI / Frontend tests (push) Successful in 2m52s
Project CI / Backend tests (push) Failing after 4m14s
Project CI / Repository checks (push) Successful in 3m42s
Project CI / AI game creator shell web tests (push) Successful in 2m5s
Project CI / Native shell tests (push) Successful in 8m2s
AgcAgentMode 回退为仅 codex/cc,只表示执行器;新增 AgcModelProtocol 表示线协议
协议取值 openai_responses/openai_chat/anthropic,与执行器组合封闭并在校验时失败关闭
存量目录缺 protocol 时按执行器推导;历史误写的 agentMode=anthropic 读取时归一为 cc
后台 AGC 模型页拆成 Agent 模式与协议两列,新增协议下拉与对应测试
公开目录 /api/llm/models 与后台 DTO 同时下发解析后的 protocol
客户端持久化 selectedModelProtocol,选模型时按执行器推导兜底协议并校验组合
Codex wire_api 按协议在 responses/chat 间切换,不再硬编码 responses
同步 appSurface 与模型选择测试断言,补 protocol 字段
同步模型别名文档与后端架构文档的正交维度说明
2026-10-02 12:08:26 +08:00
kdletters fee0dc1fa4 合并 origin/master:网站游戏评分与评价 2026-10-01 19:41:30 +08:00
kdletters d1f789cc10 AGC 支持 Anthropic 独立网关路由与后台协议选项
新增平台 Anthropic 网关路由 /api/llm/anthropic/{*path},复用账号 Router 凭据边界
OpenAI 侧规范路径改为 /api/llm/v1/responses 与 /api/llm/v1/chat/completions,旧路径保留兼容
baseUrl 不再携带路由与版本段,统一由协议自己拼 v1/<op>
cc 执行器改走平台网关,ANTHROPIC_AUTH_TOKEN 复用平台会话,不再直连 Router
后台模型目录 agentMode 增加 anthropic,管理页与客户端契约同步
补齐三条路由埋点与静态段白名单,新增三条回归测试
同步后端架构文档、模型别名文档与排障记忆
2026-10-01 19:41:08 +08:00
lhk229 b60aea4e71 实现网站游戏评分与评价 (#561)
Project CI / AI game creator shell Rust crates (push) Successful in 1m43s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m7s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m55s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 3m23s
Project CI / Frontend tests (push) Successful in 3m3s
Project CI / Repository checks (push) Successful in 3m42s
Project CI / AI game creator shell web tests (push) Successful in 2m3s
Project CI / Backend tests (push) Successful in 6m19s
Project CI / Native shell tests (push) Successful in 8m7s
公开游戏详情页新增评分与评价:登录用户可提交并修改自己对每款游戏的唯一一条 1–10 分评价,评论可空且最多 4000 个 Unicode 码点;游客可分页浏览评价并查看平均分与评分人数。

- 新增私有评价表及共享 DTO/API,事务内校验游戏公开可见性、保证唯一性,并计算分页与全量评分统计;下架或封禁后关闭读写,重新公开及更新版本保留评价。
- 详情页支持编辑预填、取消、提交期间冻结输入、失败保留草稿,以及保存、翻页和账号/游戏切换时的旧响应隔离;复用现有认证与公共组件。
- 同步主规范、里程碑、实施计划、生成绑定、表目录和验收脚本。不扩展 AGC、外部 API、评论审核或评分缓存。

验证:
- 本轮审查复跑前端定向测试 40 项、评价领域测试 2 项,均通过。
- 网站 typecheck、Rust/TypeScript DTO 对齐、SpacetimeDB schema、文档索引、编码与 diff 检查通过。
- 实施文档另记录本地隔离数据库/API 49 项及桌面/移动视口浏览器 smoke 通过;本轮审查未重跑这些运行时验收,也未运行完整测试套件。

发布说明:新增 SpacetimeDB 表,部署时需同步 module 与 API。尚未部署 dev/production,待用户验收。

Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/561
Co-authored-by: Linghong <ink29535@proton.me>
Co-committed-by: Linghong <ink29535@proton.me>
2026-10-01 19:19:58 +08:00
kdletters dbc3355e3a 账单不再计入实际变动为 0 的泥点流水
- spacetime-module:每日免费 / 会员周期换期改为先算「换期后余额 + 实际变动」(新增 resolve_expiring_points_wallet_transition),实际变动为 0 时只更新余额状态、不再写 profile_wallet_ledger
- spacetime-module:通用结算入口 apply_profile_wallet_signed_delta 在 amount_delta 为 0 时直接返回当前余额,不再落一条 0 变动流水
- spacetime-module:账单列表 list_profile_wallet_ledger_entries 在按余额结算链排序之后、截断 50 条上限之前剔除 amount_delta 为 0 的存量行,历史 0 流水立即从账单消失且不占用列表上限
- spacetime-module:新增 3 条定向单测覆盖换期实际变动与账单 0 变动过滤(去 0 后不改变其余条目顺序)
- 文档:后端数据契约 profile_wallet_ledger 补「实际变动为 0 不进账单」口径并修正源码路径为 runtime/active/profile.rs;decision-log 追加 2026-10-01 条目说明根因是旧判据看入参而不是实际余额变动
2026-10-01 13:23:29 +08:00