Skip to content

审查 + 修复:v2 模块协议重构高置信 BLOCKER(main@34e658b)#3

Merged
Tanya7z merged 7 commits into
mainfrom
cursor/v2-review-f73b
Jul 21, 2026
Merged

审查 + 修复:v2 模块协议重构高置信 BLOCKER(main@34e658b)#3
Tanya7z merged 7 commits into
mainfrom
cursor/v2-review-f73b

Conversation

@Tanya7z

@Tanya7z Tanya7z commented Jul 21, 2026

Copy link
Copy Markdown
Member

这是什么

对另一个 agent 推到 mainv2 模块协议重构(34e658b)的审查,并直接修复了其中高置信度、可端到端验证的 BLOCKER。含一份完整审查报告 docs/reviews/v2-module-protocol-review.md + 6 个源码修复提交(仅改 db-server/srccatalog.json,未碰模块业务逻辑)。

已修复(附运行时验证)

用「模拟真实模块 · 按 module-auth 派生 token」端到端验证:

编号 问题 修复文件
P-M1 v2 路由请求体恒空(读 req._body 从未赋值) index.ts
B2 GET /configs/all 被 v2 鉴权遮蔽 401(SAPI 启动必用) index.ts
回归 模块启停后 enabled 不翻转(读启动缓存 lock) index.ts
B3 /db/tx 从 body 取 moduleId → 越权 + 事务恒拒 db-routes.ts
B4 整体 db:write:* 断言恒失败 → 所有事务被拒 tx-runner.ts
schema finalize() 从未调用 → 表永不落地;softDelete 建表 SQL 语法错误 schema-registry.ts
B7 land-gui 未登记 catalog → 永不装载 catalog.json

验证结果

GET /api/sfmc/configs/all                          -> 200 (返回配置)
define-table lands (feature-land, 带 token)         -> 200 created
tx insert + query (feature-land)                   -> 200 (写入并查回)
get by id                                          -> 200
tx 伪造 body.moduleId=feature-afk(持 land token)   -> 以 feature-land 身份执行(忽略 body)
feature-afk 写 lands(无权限)                        -> 403 permission_denied
无 token                                           -> 401
tools/smoke-modules.js                             -> 全部通过
node tools/check-ootb.js                           -> 5/6(剩 sim-new-user 为既有 shim 缺失,与 v2 无关)
npm run build --workspaces                         -> 全部通过

仍未修复(需提交方更大改动,已在报告详述)

  • B1 SDK 客户端从不带 token(host-bootstrap 未注入身份)→ 真实模块调用仍会 401。
  • B5 tx() 录制-回放拿不到服务端生成的 id/结果 → 步骤间依赖失效。
  • B6 service provider 无注册通路,land 的 12 个 provides 全是空操作。

这三项属于 SAPI 侧/协议级改动,须结合 Bedrock 运行时验证,不在本安全外科修复范围内。另有多个 MAJOR/MINOR(update/delete 按 rowid 定位、软删未过滤读、借贷方向反、land-gui 直查 land 私有表、afk afterWorldLoad 时机、clean-break 残留等)与规则偏离,清单见 docs/reviews/v2-module-protocol-review.md

Open in Web Open in Cursor 

cursoragent and others added 7 commits July 21, 2026 14:54
审查 main@34e658b 的 v2 平台层/SDK/land·land-gui·afk 迁移。含构建+启动+冒烟+接口运行时验证。结论:存在多个 BLOCKER(鉴权闭环未打通、configs/all 回归 401、db:write:* 权限自相矛盾、tx 结果不可回传、service provider 未实现、land-gui 未登记 catalog),当前尚不符合要求。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
1) v2 路由此前读 req._body(从未赋值)→ 所有 db/config/service 请求体恒空;改为复用已预读缓存的 body(req)。
2) GET /api/sfmc/configs/all 是 SAPI 启动一次性拉配置的旧端点,被 v2 模块鉴权命名空间遮蔽成 401,导致插件端起不来;显式豁免。
3) setModuleEnabled 另读新 lock 副本写盘,但 buildModuleList 读的是启动缓存的 lockFile → 启停后 enabled 不翻转;改为回写共享缓存。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
此前 /db/tx 从请求体取 moduleId:既可持 A 的 token 冒用 B 的权限越权,也导致客户端只发 {steps} 时 moduleId 缺失、事务恒被拒。改为强制 moduleId=auth.id。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
run() 开头无条件断言 db:write:*,但该通配无法通过 permission-gate 校验(模块声明它会启动失败),导致所有事务(含只读)恒被拒。删除该断言;读写权限由每个 step 的 requireTableRead/Write 按具体表精确 gate。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
1) finalize() 从未被调用 → 模块表永不落地、insert/query 全部 no such table;改为 define 即幂等建表(碰撞检测已按内存表完成)。
2) buildColumnClause 把 _deleted_at/_version 追加进每个列子句且无逗号分隔 → softDelete 表建表 SQL 语法错误;抽出 buildColumnList 在表级追加一次。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
land-gui 已迁 v2 但未登记 catalog → 永不装载、requires 顺序不被约束。补上条目(requires feature-land)。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
@cursor cursor Bot changed the title 代码审查:v2 模块协议重构(main@34e658b) 审查 + 修复:v2 模块协议重构高置信 BLOCKER(main@34e658b) Jul 21, 2026
@Tanya7z
Tanya7z marked this pull request as ready for review July 21, 2026 17:02
@cursor

cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@Tanya7z
Tanya7z merged commit 5e6fe15 into main Jul 21, 2026
1 check failed
@Tanya7z
Tanya7z deleted the cursor/v2-review-f73b branch July 21, 2026 17:02
Tanya7z added a commit that referenced this pull request Jul 21, 2026
Reflects today's 6-session work:
- 6 v2 modules now online (added afk, chat-sounds, spawn-protect,
  feature-area consolidation merging fly+peace+creative+survival+clean)
- v2 protocol runtime fixes (PR #3): body parsing, /configs/all
  auth exemption, tx moduleId spoofing, db:write:* assertion, schema
  finalize/softDelete SQL, land-gui catalog registration,
  enabled-flip regression
- tools/smoke-modules.js now passes 100%
- 15 v1 modules remaining (was 21, minus the 5 consolidated into
  feature-area and the 1 already at chat-sounds)
- Permission regex bug fixed (2-segment service:<name>)
- URL normalization finalized; author fields restored to Shiroha7z

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants