Skip to content

feat(im): 把聊天发起人记入需求操作日志,并在平台管理里配置外部访问地址 - #1300

Merged
newexploreor merged 6 commits into
mainfrom
feat/issue-operation-im-actor
Nov 25, 2026
Merged

newexploreor merged 6 commits into
mainfrom
feat/issue-operation-im-actor

Conversation

@newexploreor

@newexploreor newexploreor commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

本 PR 含两部分,针对的是企业 IM 渠道上两个互相挡路的问题:聊天建的需求查不到是谁发起的,以及没配对外访问地址时 Bot 连绑定链接都生成不了(后者会直接挡住前者的验收)。

  • 第一部分:把聊天发起人记入需求操作日志(commit ec1e4aa、f51a4f5)
  • 第二部分:平台管理里配置外部访问地址,并让授权类报错说清下一步(commit 32b6b70)

两部分只在 internal/botinteraction/inbound.go 和 internal/httpapi/bot_drafts.go 有文件重叠,改的是不同位置,无语义冲突。


第一部分:把聊天发起人记入需求操作日志

问题

从企业微信、飞书、钉钉的 Bot 创建需求或触发 SOP,执行用的是发送者绑定的平台账号,但需求的操作日志里只有这个账号:

  • 聊天里建的需求和平台页面建的需求,在操作日志里长得一模一样;
  • 到底是哪个 IM 成员要求做的,事后查不出来——发送者只存在 bot_chat_origins 里,那张表的职责是把运行事件路由回原会话,SenderID 标的是 json:"-",没有任何接口或页面读它。

改动

1. 操作日志记录 IM 身份

domain.IssueOperation 新增三个字段:

字段 含义
ActorChannel 渠道(wecom / feishu / dingtalk)
ActorSender 该渠道内的发送者 ID(企业微信是企业内部 userid)
ActorSenderName 发起时点该发送者的显示名快照(渠道报了才有)

Actor 语义不变,仍是「实际用谁的权限执行的平台账号」。平台页面上的操作三个字段都为空。

2. 身份通过请求上下文传递

新增 botChatActor(internal/httpapi/bot_chat_actor.go),挂在内部平台调用的 request context 上,和 requestUserContextKey 并列——mcpserver.LocalInvoker 会把 ctx 透传进内部请求,所以 handler 侧读得到。

没有复用 BotChatOrigin:那个结构负责通知路由、缺 channel、且要求会话行存在;这里只做归属标注,在聊天轮次的每条写入路径上都设。

注入点覆盖三条写入路径:

路径 文件
本轮内直接写入(auto 模式) bot_interactions.go generateBotReply
网页确认页 / 聊天卡片确认草稿 bot_drafts.go executeBotDraft
聊天澄清保存后顺带启动 SOP bot_clarify.go botClarifySave

create / update / dispatch 都走 recordIssueOperation 这一个函数,所以三个动作一次覆盖。

3. 发送者显示名

只有钉钉的回调自带 senderNick,映射到 InboundEvent.SenderName 并随互动记录持久化;之后缓存到绑定上,因为同一发送者后续的动作不再带名字(卡片点击、网页确认、澄清后启动 SOP)。解绑时和其余身份信息一起清掉;空名字不会覆盖已存的名字。

企业微信和飞书的机器人回调只给发送者 ID,凭据也是机器人维度的,所以不为它们编造名字:这类发送者继续由绑定的平台账号来指名(账号本身带中文名,日志里已经显示)。新增的列就是以后接通讯录查询时的落点,不用再改一次 schema。

顺带两处可读性改进:节点审批 / 重试 / 回答的运行决策备注里,发送者 ID 后面补上已知姓名;飞书、钉钉的通知接收人选择器在知道姓名时显示姓名而不是打码 ID。

4. 前端

需求详情的操作日志:聊天发起的条目显示 钉钉 张三(staff-1)(平台账号 xxx),企业微信显示 企业微信 wangxx(平台账号 roberttwang(王某)),平台操作显示不变。

迁移

只新增列,由 repo.Open() 的 gorm AutoMigrate 补齐,无需数据迁移脚本。

测试

新增 internal/httpapi/bot_issue_attribution_test.go(7 例)和 internal/botinteraction/sender_name_test.go(2 例):

  • 企业微信网页确认草稿创建需求 → 记到 wecom / new-wecom-user,Actor 仍是绑定账号
  • 企业微信自动写入模式创建需求 → 同上
  • 钉钉自动写入 → 额外记到 ActorSenderName="张三"
  • 平台页面创建需求 → 三个字段为空(防回归)
  • 姓名缓存:首次上报写入绑定、后续无名动作仍能解析、空上报不清空、解绑后清空
  • 企业微信不产生姓名(如实为空)
  • 渠道映射:钉钉 senderNick 到事件和互动记录;企业微信事件确实不带姓名
  • 上下文载体:空 sender 不产生半填充记录、channel 缺省归一到 wecom、标签回退规则

每个关键断言都做了反向验证(临时打断链路确认用例会红),不是空跑。

go test ./internal/httpapi ./internal/domain ./internal/repo ./internal/botinteraction ./internal/notification ./web 通过。internal/httpapi 里有若干 workspace / 沙箱用例在本环境失败(缺 bwrap、web/native-chat 是 gitignore 的构建产物),已用 git stash 在干净 main 上复跑确认与本次改动无关。gofmt、go vet 干净。


第二部分:平台管理里配置外部访问地址

问题

平台的对外访问地址只能在启动时从 AGENTFLOW_PUBLIC_URL 读一次。部署时没设的话,没有任何补救办法:

  • 企业微信 / 飞书 / 钉钉的 Bot 回复「平台外部访问地址尚未配置,请联系管理员」,账号绑定链接和写操作确认链接都生成不了;
  • 通知里的运行详情链接退化成「请在平台运行记录中查看」。

要修只能改 .env 再重启。

改动

1. 平台管理 → 外部访问地址

新增分区,管理员填一次存库。页面设置优先于环境变量,这样页面永远能纠正部署时的错配或漏配;同时页面标注当前生效来源,并显示被盖掉的环境变量值,避免「我改了 env 怎么没生效」。

2. 为此需要一个 resolver

Service.PublicURL 原本是启动时读一次 env 的字符串,还被再拷一份进 botIdentityHandlers,所以运行时改不动。

  • 新增 Service.PublicAddress():先查库里保存的值,再回落到环境变量;
  • 所有拼链接的地方改走它(notification/service.go、push.go、httpapi/notifications.go、httpapi/bot_drafts.go);
  • botIdentityHandlers.publicURL 从 string 改成 func() string。

单行主键查询,调用方都是 IM 事件级频率,所以不加缓存,省掉缓存失效的复杂度。

3. 「自动识别」怎么做的

页面上的「填入当前访问地址」取的是管理员浏览器自己的 location.origin,不读也不信任服务端收到的 Host 头。

这点是刻意的:这个地址会被拼进带一次性 token 的绑定链接,并引导用户去那里登录平台。来源可伪造就等于一条钓鱼链路。所以没有做「运行时从请求头自动学习」。

校验规则照搬 scripts/install-address.py:86-95 已有的那套,保证安装器和页面接受完全相同的值:拒绝 userinfo / query / fragment / 路径、拒绝 0.0.0.0 和链路本地地址。回环地址保存但附警告而不是拒绝——它是本机联调会用的,但发到手机上点不开。

另外校验会把 scheme 和 host 规范化成小写(HTTPS://X → https://x),因为这个值要被拼进链接。这是写测试时发现的。

4. 顺带:让授权类报错说清下一步

这几条是实际踩坑时把人引向错误方向的提示:

  • 企业微信 850002(no authorization)原先掉进兜底文案「请检查机器人授权或稍后重试」,而且没被计入 awaiting_authorization,所以 Bot 在管理页显示成笼统的 error,「重试一下」看起来很合理——但这个码重试一万次也一样。现在明确说是机器人的「消息」能力授权没给、该由谁去哪里授权、以及重试不解决问题。
  • 新增 851009(授权待管理员审批)和 853006(企业主体未开通该能力)的专门文案。
  • awaiting_authorization 的判定收敛成一个 awaitingAuthorization() 谓词,健康状态和发送失败两条路径共用。853006 故意不算在内——没有任何授权能解决它,算进去会让人一直等一个等不到的审批。
  • 飞书 / 钉钉的企业待确认提示原先是「请稍后重发消息」,但在管理员确认企业之前重发永远不会成功。现在直接写明要去「项目 → 机器人」第②步点「确认企业」。

迁移

只新增一张表,由 repo.Open() 的 gorm AutoMigrate 补齐,不需要迁移脚本。

测试

新增 4 个测试文件:

文件 覆盖
internal/domain/platform_settings_test.go 校验规则逐条(含 IPv6 带端口、大写 scheme 规范化)、回环警告而非拒绝、UsablePublicURL、长度上限
internal/httpapi/platform_public_url_test.go 非管理员 GET/PUT/DELETE 全 403;页面值覆盖 env 且回显被盖掉的 env;清除后回落 env;空值等同清除;10 种非法形状全部 400 且不落库;回环保存带 warning;保存后 PublicAddress() 和绑定链接立刻生效(resolver 的真正验收点)
internal/repo/platform_settings_test.go upsert 只有一行、空库读零值、修剪空白、清除后回落
internal/notification/wecom_authorization_test.go 四个授权码的文案和 awaitingAuthorization();853006 不算待授权;未知码保持兜底

反向验证做了两处,确认测试在测链路不是空跑:

  • 打断 PublicAddress() 的查库分支 → TestSavedPublicURLAppliesWithoutRestart 报 address after saving = "";
  • 摘掉 handler 的管理员校验 → TestPublicURLRequiresPlatformAdmin 报 GET as a plain member = 200。

回归对比:go test ./internal/httpapi 在改动前后的失败用例名完全一致(12 个,均为本环境缺 bwrap、以及 web/native-chat 是 gitignore 的构建产物所致),用 git stash 在干净 main 上复跑确认。./internal/domain、./internal/repo、./internal/notification、./internal/botinteraction 全绿。gofmt、go vet 干净。


合并后的整体验证

go test ./internal/httpapi 在本分支与干净 main 的失败用例名逐字一致(12 个,均为本环境缺 bwrap、以及 web/native-chat 是 gitignore 的构建产物所致),用 git stash 复跑确认。

两部分各自的测试在合并后同时通过,共 17 例:

--- PASS: TestIssueOperationNamesWeComSenderOnConfirmedDraft
--- PASS: TestIssueOperationNamesWeComSenderOnAutoWrite
--- PASS: TestIssueOperationNamesDingTalkSender
--- PASS: TestIssueOperationHasNoChatIdentityOnPlatformWrite
--- PASS: TestBotChatActorContext
--- PASS: TestBotSenderNameIsCachedOnTheBinding
--- PASS: TestWeComSenderHasNoReportedName
--- PASS: TestPublicURLRequiresPlatformAdmin
--- PASS: TestPublicURLPageSettingOverridesEnvironment
--- PASS: TestPublicURLEmptyValueClears
--- PASS: TestPublicURLRejectsUnusableAddresses
--- PASS: TestPublicURLWarnsAboutLoopback
--- PASS: TestSavedPublicURLAppliesWithoutRestart
--- PASS: TestDingTalkEventMapping
--- PASS: TestDingTalkEventCarriesSenderName
--- PASS: TestWeComEventReportsNoSenderName
--- PASS: TestWeComAuthorizationFailuresAreActionable

./internal/domain、./internal/repo、./internal/notification、./internal/botinteraction、./web 全绿;gofmt、go vet 干净。两部分都只新增列或新增表,由 AutoMigrate 补齐,不需要迁移脚本。

roberttwang added 3 commits November 24, 2026 09:41
…operations

Creating a requirement or triggering its SOP from a WeCom, Feishu or
DingTalk Bot ran as the platform account the sender is bound to, but the
requirement's audit trail only named that account: the operation log of a
requirement created from chat was indistinguishable from one created on the
platform, and the IM member who asked for it could not be recovered (the
sender was only kept in bot_chat_origins, which is notification routing and
is never exposed).

Carry the IM sender of a chat turn in the request context of the internal
platform calls the turn makes (botChatActor, next to the request user) and
record it on IssueOperation as ActorChannel/ActorSender. Actor keeps its
meaning: the platform account whose permissions were used. Both new fields
stay empty for operations taken on the platform itself.

The actor is injected on every write path of a chat turn: writes made
within the turn, drafts confirmed on the platform page or on a chat card,
and the SOP started right after a chat clarification is saved. create,
update and dispatch all go through recordIssueOperation, so all three are
covered. Operations are stored in the issue JSON payload, so no migration
is needed.

The requirement drawer now shows "企业微信 <userid>(平台账号 <account>)"
for chat-initiated entries and is unchanged for platform ones.
…ly its ID

The audit entry added by the previous commit identified a chat-initiated
operation by raw sender ID, which reads as an opaque string in the
requirement drawer and in the member picker.

Capture the display name the channel reports for a sender and keep it next
to the identity. DingTalk is the only channel that sends one (senderNick),
so it is mapped onto InboundEvent and persisted with the interaction; the
name is then cached on the binding, because the later actions of the same
sender carry none - card clicks, confirmations on the platform page, and the
SOP started right after a chat clarification is saved. A revoked binding
drops the cached name with the rest of the identity, and an empty report
never clears a stored one.

WeCom and Feishu bot callbacks carry the sender ID alone and their
credentials are bot-scoped, so no name is invented for them: those senders
keep being named by the platform account they are bound to, which the entry
already shows. The new column is the place a contact-directory lookup would
fill later without touching the schema again.

IssueOperation gains ActorSenderName as a snapshot of the name at the time
of the action. Node approvals, retries and answers now put the name next to
the sender ID in the run's decision note, and the Feishu/DingTalk
notification-target picker shows it instead of a masked ID.

New columns only, filled by AutoMigrate; no data migration.
The platform's external address was only readable from
AGENTFLOW_PUBLIC_URL at startup, so a deployment that did not set it had
no way to recover: chat Bots answered "平台外部访问地址尚未配置,请联系
管理员" and could build neither an account binding link nor a write
confirmation link, and notifications lost their run detail link. Fixing it
meant editing .env and restarting.

Add 平台管理 → 外部访问地址, where a platform administrator saves the
address once. A saved value wins over the environment, so the page can
always correct a wrong or missing deployment configuration; the page names
the effective source and shows the shadowed environment value, so a
configured AGENTFLOW_PUBLIC_URL is never silently mistaken for the one in
use.

Reading it on use required a resolver. Service.PublicURL was a string read
from the environment once and copied again into botIdentityHandlers, so
nothing could change it at runtime. Service.PublicAddress now resolves the
stored value first and the environment second, and every link builder goes
through it; botIdentityHandlers takes a func instead of a string. The row is
a single primary-key lookup and the callers run at chat-event rate, so there
is no cache to invalidate.

The suggested value comes from the administrator's own browser
(location.origin), never from a Host header the platform received: this
address is pasted into binding links that carry a one-time token, so a
forgeable source would be a phishing vector. Accepted shapes mirror
scripts/install-address.py so the installer and the page agree; a loopback
address is saved with a warning rather than refused, because it is what a
local trial uses but cannot work in a link sent to a phone.

Also make the authorization failures say what to do about them, which is
what sent people looking at the wrong layer:

- WeCom 850002 ("no authorization") fell through to the generic "请检查机器
  人授权或稍后重试" and was not counted as awaiting authorization, so the
  configuration showed a plain error and retrying looked reasonable. It now
  names the capability grant, where to grant it, and that retrying will not
  help; 851009 (pending approval) and 853006 (tenant capability blocked) get
  their own text, and awaiting_authorization is decided by one predicate
  shared by the health and delivery paths. 853006 stays a plain error because
  no authorization resolves it.
- The Feishu/DingTalk enterprise-confirmation notice now names the step that
  unblocks it instead of asking the sender to retry, which cannot succeed
  until an administrator confirms the enterprise.

New table only, filled by AutoMigrate; no data migration.
@newexploreor newexploreor changed the title feat(im): 把聊天发起人记入需求操作日志(企业微信 / 飞书 / 钉钉) feat(im): 把聊天发起人记入需求操作日志,并在平台管理里配置外部访问地址 Nov 24, 2026
@crispinhu27

Copy link
Copy Markdown
Collaborator

审查了 32b6b709,建议修复下列问题后合并。

  1. [P1] 原生 MCP 写入漏记 IM 发起人。 原生工具请求从会话恢复了 botStartOrigin,遗漏了 botChatActor。实测 issues_dispatch 返回 201,操作日志里的 ActorChannel 和 ActorSender 仍为空。请在网关恢复审计上下文,并在原生工具测试中断言落库结果。代码
  2. [P1] 新标签页使 platform-required 失败。 第五个标签加入后,现有测试仍预期从「Git 主机信任」按右方向键直接回到「成员账号」。请补上「外部访问地址」可见性和从新标签回绕的断言。同一用例在基线通过,在 PR 上失败。代码 · CI 日志
  3. [P2] 「保存并启动」记录了错误的 IM 成员。 群聊中 A 发起澄清、B 通过文字或卡片启动 SOP 时,日志把 A 的 IM 身份和 B 的平台账号写在同一条记录。请用实际发送命令或点击卡片的成员填充调度审计上下文。代码
  4. [P2] 升级前的钉钉绑定无法写入首次上报的姓名。 Docker MySQL 8.0 上,升级后新增的 sender_name 对旧行是 NULL,sender_name <> ? 会跳过这些行。请让更新条件显式覆盖 sender_name IS NULL,以便网页确认日志和接收人选择器能读到姓名。代码
  5. [P2] 无效端口可以覆盖有效的外部访问地址。 保存带 65536 端口的地址返回 200,随后的绑定、确认和通知链接无法在浏览器打开。请校验显式端口范围,并在校验失败时保留当前地址。代码
  6. [P2] 企业微信待授权通知在审批通过后仍需手动重试。 模拟 851009 后完成审批并成功检查会话,旧投递仍停在 awaiting_authorization。请明确指引用户到发送记录重试,或在授权恢复时将待授权投递重新入队。代码

PR 自带的相关 Go 定向测试通过。上述行为已用隔离快照复现。

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review:feat(im) 聊天发起人记入需求操作日志 + 平台管理「外部访问地址」

结论:不通过(有 2 个 P1:主路径的 IM 发起人没有记上;PR 让 CI 里一个现有前端测试失败)

审阅的 head:32b6b70951b58ce6bae59d674dfe00e248467c88(base main be35aff)

「外部访问地址」这部分本身做得不错。只有平台管理员能读写(GET/PUT/DELETE 都校验了),CSRF 的 Origin 校验有效,scheme、userinfo、path、query 和 0.0.0.0、链路本地地址都会拒绝,回环地址给出提示,「填入当前访问地址」取的是 location.origin 而不是 Host 头。保存后立即生效,不用重启。需要改的问题主要在归因链路和授权恢复上,见下文。


P1

P1-1 原生 MCP 工具调用的写操作没有带上 botChatActor,自动写入模式下操作日志里没有 IM 发起人

  • 现象:Bot 回合中,模型通过原生 MCP 网关(/internal/agent-tools/<token>/mcp,CLI 类引擎就走这条)调用 agentflow__issues_save / issues_dispatch 等写工具时,记下的操作只有 actor,actorChannel 和 actorSender 都是空的。PR 自带的 TestIssueOperationNamesWeComSenderOnAutoWrite 测的是 commitFinal 里的 drafts 路径,没有覆盖这条主路径。
  • 复现步骤:写一个单测(思路同 TestIssueOperationNamesWeComSenderOnAutoWrite),在 h.generate 里对 h.api 发起 tools/call agentflow__issues_save {"body":{"projectId":"p","title":"..."}},然后看最新的 create 操作:
    op: actor="other-user" actorUserId=43 channel="" sender=""
    REPRODUCED: native MCP write recorded no IM sender
    
  • 位置:internal/httpapi/agent_tool_mcp.go:423-427。这里只从 session.ctx 复制了 botStartOriginFrom,没有复制 botChatActorFrom。确认模式(drafts)的写入不走这里,所以不受影响;只读模式本来就不写。
  • 建议:在同一处补上
    if actor, ok := botChatActorFrom(session.ctx); ok {
        ctx = withBotChatActor(ctx, actor.Channel, actor.SenderID, actor.SenderName)
    }
    再加一个走 MCP 网关的回归测试(issues_save 和 issues_dispatch 各测一次)。

P1-2 新增第 5 个 tab 后,webtest/tests/platform-admin.test.mjs 失败(CI core 作业,platform-required 会是红的)

  • 现象:platform admin page separates accounts, admins, shared keys and Git host trust 断言 arrow keys wrap around,即在「Git 主机信任」上按 ArrowRight 应回到「成员账号」。现在会先到「外部访问地址」,所以断言失败。
  • 复现步骤:cd webtest && npm ci && node --test tests/platform-admin.test.mjs
    • PR head:# pass 5 / # fail 1,失败在 platform-admin.test.mjs:75,actual [] / expected ['accounts']
    • main:# pass 6 / # fail 0
  • 位置:webtest/tests/platform-admin.test.mjs:57,71-77;tab 定义在 web/app/workbench.js:1665。
  • 说明:键盘导航的实现是通用的,没有问题。真实浏览器里实测,从「Git 主机信任」按 → 到「外部访问地址」,再按 → 回到「成员账号」,按 ← 回到「外部访问地址」,aria-selected、tabIndex 和焦点都对。过时的只是这个测试。
  • 建议:更新测试,在 shown() 里加入 publicUrl,补一次 ArrowRight 到 publicUrl,再断言回到 accounts。最好再加一条外部访问地址 tab 的 jsdom 用例(mock /api/platform/public-url)。

P2

P2-1 群聊里「保存并启动」把 SOP 启动归到发起澄清的人,而不是实际操作的人

  • 现象:成员 A 在群里发起澄清,需求负责人 B 发「保存并启动」(或点卡片)。dispatch 用的是 B 的平台账号,IM 发起人却记成 A。
  • 复现步骤:单测里用 newClarifyChatFixture(feishu),让 ou_member 发「澄清 #7」,把会话置为 concluded,再让 ou_owner 发「保存并启动」:
    dispatch op: actor="bot-owner" actorUserId=42 channel="feishu" sender="ou_member"
    
  • 位置:internal/httpapi/bot_clarify.go:883,withBotChatActor(..., sess.StarterSender, ...)。文本命令路径上,generateBotReply 已经在 bot_interactions.go:99 放进了正确的发送者 B,这一行又把它覆盖成了 A。
  • 建议:归因用当前这条消息或卡片点击的发送者,把 item.SenderID 传进 botClarifySave。BotChatOrigin 继续用 starter 来路由通知,这两件事要分开。

P2-2 升级前已有的绑定行 sender_name 是 NULL,sender_name <> ? 永远不成立,显示名不会被缓存

  • 现象:AutoMigrate 给 bot_user_bindings 加的 sender_name varchar(191) 可为空、默认 NULL,存量绑定都是 NULL。NoteBotSenderName 的 WHERE ... AND sender_name <> ? 遇到 NULL 结果是 UNKNOWN,行不会更新。所以升级前就绑定的钉钉用户,之后的卡片点击、网页确认、「保存并启动」都拿不到名字;通知目标列表里也只显示掩码 ID。
  • 复现步骤(真实 MySQL 8.4):
    1. 用 main 的二进制初始化空库 lf_upg,插入一条 user_id=1 的绑定。
    2. 换 PR 的二进制启动,AutoMigrate 后 SHOW COLUMNS 得到 sender_name varchar(191) YES NULL,该行 sender_name IS NULL = 1。
    3. 执行与 NoteBotSenderName 相同的 UPDATE ... WHERE id=? AND user_id > 0 AND sender_name <> '张三',得到 ROW_COUNT() = 0,值仍是 NULL。
  • 位置:internal/repo/bot_identities.go:68;字段定义在 internal/domain/bot_identity.go(SenderName ... gorm:"size:191")。
  • 建议:条件改成 (sender_name IS NULL OR sender_name <> ?),或给列加 not null;default:''。注意 AutoMigrate 不会回填已有的 NULL 行,所以改 SQL 条件更稳。再加一个预置 NULL 行的测试。

P2-3 新增的 850002、851009 进入 awaiting_authorization 后不会自动重新排队,851009 的文案却写着「审批通过后自动恢复」

  • 现象:awaitingAuthorization() 新纳入了 850002 和 851009,这两类投递失败后状态变成 awaiting_authorization。但 ClaimNotification 只领取 pending(以及租约过期的 sending)。仓库里把 awaiting_authorization 改回 pending 的只有手动「重试」(repo/notifications.go:513)。Bot 健康检查恢复成 ready 时,也不会重新排队这些投递。管理员审批通过后,这些通知会一直卡着,和文案说的不一致。另外,main 上 850002 会以 pending 退避重试最多 5 次,现在改成直接挂起。
  • 复现步骤:代码确认,未实测真实企业微信。notification/service.go:356-358 把状态设为 awaiting_authorization;repo/notifications.go:476 只 claim pending;全仓 grep awaiting_authorization,除手动重试外没有任何恢复路径。
  • 位置:internal/notification/provider.go:45-46(文案),:60(分类);internal/notification/service.go:356-358;internal/repo/notifications.go:476。
  • 建议:二选一。
    • 在 Bot 验证或健康检查回到 ready 时(service.go:105-113),把该 Bot 的 awaiting_authorization 投递重新排为 pending,这样文案才成立。
    • 或者把文案改成「审批通过后请在投递记录里点重试」。

P3

P3-1 外部访问地址没有校验端口范围:65536、99999999、0 和末尾空冒号都能保存(另一位 reviewer 定为 P2,我复核后建议定 P3)

  • 现象:PUT /api/platform/public-url 提交 https://lf.example.com:65536、:99999999、:0、https://lf.example.com: 都返回 200,并且立即成为生效地址,此后绑定链接和确认链接都会是坏的。页面上的 <input type="url"> 会被 Chromium 拦下(checkValidity()=false),所以只有直接调 API 才会触发,而且只有平台管理员能调,因此建议 P3。注释说规则「mirror scripts/install-address.py」,但安装脚本里的 parsed.port 对 >65535 会抛 ValueError,两边并不一致。
  • 复现步骤:curl -X PUT .../api/platform/public-url -d '{"value":"https://lf.example.com:65536"}' 返回 200 {"source":"settings","stored":"https://lf.example.com:65536",...}。
  • 位置:internal/domain/platform_settings.go:67。net.SplitHostPort 只拆分,不检查范围;Go 的 url.Parse 也只检查端口是数字。
  • 建议:端口非空时用 strconv.Atoi 校验 1..65535,空端口(末尾冒号)也拒绝,并补对应的表驱动用例。

UI 会拦下 65536(input type=url)
API 保存 65536 后成为生效地址

P3-2 钉钉 senderNick 按字节截断到 191,可能把 UTF-8 字符切断,导致消息入库被 MySQL 拒绝

  • 现象:truncate() 是 s[:n] 字节切片。昵称超过 191 字节时(例如 64 个汉字是 192 字节,或者较长的 emoji 昵称),结果是非法 UTF-8。MySQL strict 模式会报 ERROR 1366 Incorrect string value,accept 把存储错误返回给适配器重投,于是这条消息会一直失败。触发概率低,但后果是这条消息永远处理不了。
  • 复现步骤:单测里 dingtalkEvent(..., senderNick=strings.Repeat("张",64)) 得到 len=191 valid=false;在真实 MySQL 上插入同样被切断的字节,报 ERROR 1366 (HY000): Incorrect string value: '\xE4' for column 'sender_name'。
  • 位置:internal/botinteraction/channel_dingtalk.go:485,internal/botinteraction/inbound.go:65-70;internal/repo/bot_identities.go:66 的 len(name) > 191 也是按字节算的。
  • 建议:按 rune 截断(项目里已有 truncateRunes),或截断后用 strings.ToValidUTF8 修正;191 的判断也改成按 rune 计数。

P3-3 创建需求时客户端提交的 operations 会原样保留,可以伪造 IM 发起人(main 上已有,本 PR 让影响变大)

  • 现象:PUT /api/issues 新建需求时,body 里的 operations(现在包括 actorChannel、actorSender、actorSenderName)会原样保存,服务端只在后面追加一条真实的 create。有项目写权限的成员因此可以在操作日志里伪造「钉钉 老板(boss)(平台账号 ceo)」这样的记录。main 上已经可以伪造 actor,本 PR 让 IM 归因字段也能伪造。编辑时 mergeIssueEdit(issues.go:416)会用服务端副本覆盖,没有这个问题。
  • 复现步骤:PUT /api/issues {"projectId":"welcome","title":"forge-test","operations":[{"actor":"ceo","actorChannel":"dingtalk","actorSender":"boss","actorSenderName":"老板","action":"create","detail":"forged"}]},返回里保留了伪造的那一条,详情抽屉里按真实 IM 记录展示(见截图)。在 main lane 上同样的请求也会保留伪造的 actor。
  • 位置:internal/httpapi/issues.go:348-349(!found 分支直接在客户端的 v.Operations 上追加)。
  • 建议:新建时先 v.Operations = nil,再 recordIssueOperation。

伪造的 IM 归因在操作日志里显示为真实记录

P3-4 小问题(nit)

  • botChatActor.Label()(internal/httpapi/bot_chat_actor.go:65)没有任何调用方,是死代码,建议删除或用起来。
  • DELETE /api/platform/public-url 会写入 updatedAt,但清空了 updatedBy,看不出是谁清除的(platform_public_url.go:88,传入的 actor 是 "")。清除之前也没有二次确认。
  • 环境变量为空时清除,toast 仍提示「已清除,改回使用环境变量」,实际状态是「未配置」(web/app/platform-public-url.js 的 clear.onclick)。

复核另一位 reviewer(crispinhu27)的结论

结论 复核结果 依据
[P1] 原生 MCP 写操作缺少 botChatActor 确认 agent_tool_mcp.go:423-427;单测复现 channel="" sender=""(我用的是 issues_save,dispatch 走同一个 ctx)
[P1] e2e 里「Git 主机信任」ArrowRight 回到「成员账号」的断言 确认(具体是 webtest/tests/platform-admin.test.mjs:75,属于 platform workflow 的 core 作业,不是 e2e/ 目录) PR 5/6,main 6/6
[P2] 「保存并启动」在群聊里记错 IM 成员 确认 bot_clarify.go:883;单测复现 actorUserId=42 sender="ou_member"
[P2] 升级前的钉钉绑定 sender_name 为 NULL,<> ? 跳过 确认 真实 MySQL 升级复现,ROW_COUNT()=0
[P2] 端口 65536 被接受(200) 确认,但建议定 P3(UI 的 type=url 会拦截,只有管理员直接调 API 才会触发) curl 返回 200;platform_settings.go:67
[P2] 企业微信 awaiting_authorization 审批后不会重新排队 确认(代码层面;未实测真实企业微信) repo/notifications.go:476、service.go:356-358、provider.go:45

验证

  • 代码阅读:git diff main...pr-1300,39 个文件,+1352/-71。
  • go vet(domain、repo、notification、botinteraction、httpapi、web):通过。
  • go test -count=1:
    • internal/domain、internal/repo、internal/notification、internal/botinteraction、web 全部 ok。
    • internal/httpapi 有 14 个失败(浏览器、沙箱、SSH 类用例,如 TestMainBotBrowserStartsAndDrivesRunBrowser、TestSSHRepositoryCheckoutAndDelivery)。在 main 上跑同一组用例,失败集合完全相同,属于本容器环境问题,与本 PR 无关。PR 新增的 TestIssueOperation*、TestBotSenderName*、TestPlatformPublicURL* 等全部通过。
  • webtest:node --test tests/platform-admin.test.mjs,PR 5 通过 1 失败,main 6 通过(即 P1-2)。
  • 复现单测(审阅用的临时文件,已从 worktree 移除):MCP 归因缺失、保存并启动归因错误、钉钉昵称 UTF-8 截断,三项都复现。
  • 真实部署(PR lane,http://127.0.0.1:18100,MySQL 8.4,AGENTFLOW_PUBLIC_URL=http://127.0.0.1:18100):
    • AutoMigrate 建好了 platform_settings(id, payload json, updated_at),bot_user_bindings 和 bot_interactions 也加上了 sender_name。
    • 用 main 的 schema 升级到 PR,复现了 P2-2。
    • 管理员 GET:source=env,带回环地址提示。
    • 保存 https://LoopForge.Example.com/ 后规范化为 https://loopforge.example.com,source=settings,页面提示环境变量已被覆盖,并显示最后修改人。
    • 无效输入返回 400:ftp://、javascript://、http://0.0.0.0、/path、u:p@、?x=1、169.254.169.254。
    • 回环地址 http://localhost:18100、http://[::1]:80:200,带 warning,toast 也会提示。
    • :65536、:99999999、:0、末尾冒号:200(P3-1)。
    • 普通成员 member1 的 GET、PUT、DELETE 都返回 403;未登录 401;没有 Origin 或跨源的 PUT 都是 403;POST 405。
    • 保存后 POST /api/notification-preview 里的链接立即变成 https://lf-review.example.com/#/runs/example,无需重启。main lane 上同样的请求仍是环境变量地址,而且 main 上没有这个接口(404)。
    • 平台管理 tab 的键盘导航在真实浏览器里正常(P1-2 的说明)。
  • 未实测:真实的企业微信、飞书、钉钉收发,包括绑定链接送达、850002/851009/853006 的真实返回和审批后的恢复,以及钉钉回调里的 senderNick。

截图

外部访问地址:来自环境变量 + 回环提示
保存有效地址(规范化、覆盖环境变量、最后修改人)
保存回环地址:接受并提示
非法 scheme 被拒绝
tab 键盘导航(第 5 个 tab)
普通成员看不到平台管理内容

Robert0622
Robert0622 previously approved these changes Nov 24, 2026

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review:feat(im) 聊天发起人记入需求操作日志 + 平台管理「外部访问地址」(复审)

结论:✅ 通过(Approve)

审阅的 head:576324a3bec237188b5f02f9a0ad0be4557447fa(新提交 fix(im): address audit and public URL review feedback;上一轮审的是 32b6b709)

上一轮我和 crispinhu27 提的 2 个 P1、4 个 P2 都修好了,P3 也基本都处理了。我逐条看了代码,在真实 MySQL 8.4 上部署跑了一遍,没有发现新的阻塞问题。

上一轮问题逐条复核

问题 状态 依据
P1 原生 MCP 写入没带 botChatActor ✅ 已修 agent_tool_mcp.go:427-429 从 session.ctx 恢复 actor。TestAutoModeStartsRecordTheChat 现在通过真实的 /internal/agent-tools/<token>/mcp 网关调用 issues_save 和 issues_dispatch,并断言 ActorChannel=wecom、ActorSender=new-wecom-user。反向验证:删掉这 3 行后,用例失败,报 create audit attribution = {... ActorChannel: ActorSender: ...}
P1 platform-admin.test.mjs 因第 5 个 tab 失败 ✅ 已修 node --test tests/platform-admin.test.mjs:9/9 通过(新增了外部访问地址 tab 的用例)
P2 群聊「保存并启动」记成了发起澄清的人 ✅ 已修 botClarifySave 不再用 StarterSender 覆盖 actor。文本命令沿用 generateBotReply 放进去的当前发送者,卡片路径在 botClarifyCardAction 里用 item.SenderID 设置。TestChatClarificationStartAttributesTheSavingMember 通过。反向验证:去掉卡片路径那一行后,用例失败,报 dispatch attribution = {... ActorChannel: ActorSender: ...}
P2 升级前绑定行的 sender_name 是 NULL,名字写不进去 ✅ 已修 条件改成了 (sender_name IS NULL OR sender_name <> ?)。真实 MySQL 8.4.7 升级实测:先用 main 二进制建库并插入一条旧绑定,再让 PR 的 repo.Open() 做 AutoMigrate,得到 sender_name IS NULL = 1。之后调 NoteBotSenderName("张三"),读回 "张三" ✅
P2 awaiting_authorization 审批后不会自动恢复,和文案不一致 ✅ 已修(选了「改文案」方案) 851009 去掉了「审批通过后自动恢复」。所有待授权类错误码的文案都补上了「到『机器人 → 记录 → 发送记录』点击『重试』」。我核对过前端,这条路径确实存在:bots.js 有「发送记录」tab,awaiting_authorization 状态会显示「重试」按钮
P3 端口范围没有校验 ✅ 已修 详见下面的实测
P3 钉钉昵称按字节截断,会切坏 UTF-8 ✅ 已修 入站按 rune 截断到 BotSenderNameMaxRunes=191,NoteBotSenderName 也改成按 rune 计数。真实 MySQL 实测:192 个汉字被忽略,191 个汉字正常写入,没有出现 1366 错误
P3 新建需求时能伪造客户端传入的 operations ✅ 已修 新建时先 v.Operations = nil。实测带伪造 actorChannel=dingtalk / actorSender=boss 的 PUT /api/issues,返回里只有服务端记录的那一条 create(actor=admin(admin))
P3 nit:Label() 是死代码;DELETE 不记录操作人;toast 文案不准;清除前没有确认 ✅ 已修 Label() 已删除。DELETE 后 updatedBy=admin。清除前会弹 afConfirm。toast 区分了两种情况:有环境变量时提示「改回使用环境变量」,没有时提示「外部访问地址未配置」

部署实测

环境:PR 二进制,MySQL 8.4.7,AGENTFLOW_PUBLIC_URL=http://127.0.0.1:18100;另起一个不设环境变量的实例用来对比。

  • 端口校验(API)::65536、:99999999、:0、https://host:、http://[::1]: 都返回 400,提示「端口必须为 1 到 65535」。:443、:8443、http://[2001:db8::1]:8090 返回 200。HTTPS://LF-Review.Example.com:8443/ 被规范化成 https://lf-review.example.com:8443。
  • 校验失败时保留原值:先保存 https://lf-review.example.com,再 PUT :65536,返回 400,GET 拿到的仍是原地址。
  • 页面(Chromium):输入 :0 能通过浏览器的 URL 校验,提交后 toast 显示「端口必须为 1 到 65535」,当前地址不变。空值被 required 拦下(checkValidity()=false)。点「清除」会弹出「清除外部访问地址」确认框,确认后:
    • 有环境变量的实例 toast 为「已清除,改回使用环境变量」;
    • 没有环境变量的实例 toast 为「已清除,外部访问地址未配置」。
  • 生效链路:保存后 POST /api/notification-preview 生成的链接立即变成 https://lf-review.example.com/#/runs/example,清除后回到 http://127.0.0.1:18100/#/runs/example,不用重启。
  • 权限:普通成员对 /api/platform/public-url 的 GET、PUT、DELETE 都返回 403。

测试

  • go vet(domain、repo、notification、botinteraction、httpapi、web):通过。
  • go test -count=1:internal/domain、repo、notification、botinteraction、web 全部 ok。
  • internal/httpapi 有 21 个失败,都是浏览器、沙箱、SSH、workspace 类用例,本容器缺少运行条件。其中 14 个在同一个 base(be35aff8)的 main 上失败得一模一样。另外 7 个(TestConversationRootsFollowConversationDir、TestResolveCodeBuddyManagedInventory、TestDevServerPreviewServesWorkspaceFiles 等)我在 PR 和 main 上分别单独重跑,都能通过,说明是全量并发跑时环境不稳定导致的,和本 PR 无关。
  • CI 全绿。和最新的 main(177d881)试合并没有冲突,go build ./... 和 go vet 都通过。

非阻塞的小建议(nit)

  • strconv.ParseUint 接受前导零,https://host:0443 会原样保存成 :0443。浏览器能打开,只是不够规整,可以考虑用规范化后的端口重建。
  • 850002 原来的文案里有「重试不会解决这个问题」,现在换成了「权限恢复后到发送记录里重试」。意思没错,但授权恢复之前重试仍然会失败,可以在文案里再强调一下「先授权、后重试」的顺序。

未实测:真实的企业微信、飞书、钉钉收发(包括钉钉回调里的 senderNick,以及 850002/851009 的真实返回)。这部分由单测覆盖。

Resolve conflicts between the platform settings introduced here and the
new Git HTTP host trust (aibot credentials) landed on main:

- internal/httpapi/server.go: both the platformSettingsHandlers and the
  gitHTTPHostTrustHandlers wiring and routes, added next to each other;
- internal/repo/models.go: platformSettingsRow joins the AutoMigrate list
  alongside main's PlatformGitHTTPHost;
- web/app/workbench.js: the Git host trust tab keeps main's HTTP host
  panel and this branch's 外部访问地址 tab.

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审 e4b24a25(合并 main):合并本身没问题,但 CI 的 e2e 路由覆盖率卡在 84.8%,暂不 Approve

上次 Approve 的是 576324a3。这次新增的只有合并 main 的提交 e4b24a25(main 在 2ad5659b)。我按冲突解决情况、CI 和部署实测重新看了一遍。

阻塞:CI browser / platform-required 失败,e2e 路由覆盖率 84.8%,低于 85%

  • 现象:browser 作业 失败在 Require registered routes to be hit at least 85%:
    e2e route coverage: 347/409 = 84.8%
    ...
      DELETE /api/platform/public-url
      PUT /api/platform/public-url
    FAIL: route coverage 84.8% is below 85%
    
    platform-required 因此也是红的。
  • 原因:本 PR 新增 3 条路由(GET/PUT/DELETE /api/platform/public-url),e2e 只走到了 GET。main(2ad5659b)的 platform 作业是 346/406 = 85.2%,PR 加上这 3 条、只覆盖 1 条,就变成 347/409 = 84.8%。576324a3 时 CI 是绿的,因为那时 main 上还没有 #1279 新增的 git-http-hosts 路由(其中 POST/DELETE 也没被 e2e 覆盖),余量还够。合并 main 之后,余量就不够了。
  • 建议:在 e2e/api/50-platform.test.mjs 里补一条 public-url 用例,覆盖 PUT 和 DELETE,并在 track 里恢复原值,避免污染共享 e2e 环境。补上后是 349/409 = 85.3%。下面这段我在本机部署上跑过,✔ 1 pass:
    test('platform: public URL can be overridden, validated and reset by admins only', async () => {
      const path = '/api/platform/public-url';
      const before = await get(path);
      track('platform public URL', async () => {
        if (before.stored) await put(path, { value: before.stored }, { expect: 200 });
        else await del(path, { expect: 200 });
      });
      await put(path, { value: 'ftp://lf.example.com' }, { expect: 400 });
      const saved = await put(path, { value: 'https://LF-E2E.Example.com/' }, { expect: 200 });
      assert.equal(saved.value, 'https://lf-e2e.example.com');
      assert.equal(saved.source, 'settings');
      if (cfg.tokenB) {
        await get(path, asB({ expect: 403 }));
        await put(path, { value: 'https://b.example.com' }, asB({ expect: 403 }));
        await del(path, asB({ expect: 403 }));
      }
      const reset = await del(path, { expect: 200 });
      assert.equal(reset.stored, '');
      assert.notEqual(reset.source, 'settings');
    });

合并冲突的解决是对的

git show --remerge-diff e4b24a25 显示 3 处冲突,两边的改动都保留了下来:

  • internal/httpapi/server.go:platformSetting 和 main 的 httpHostTrust 两个 handler 都在,/api/platform/public-url 的 3 条路由和 /api/platform/git-http-hosts 的 4 条路由也都在。
  • internal/repo/models.go:AutoMigrate 列表同时包含 platformSettingsRow{} 和 PlatformGitHTTPHost{}。
  • web/app/workbench.js:「Git 主机信任」tab 同时显示 SSH、HTTPS 和 HTTP 三块内容,「外部访问地址」tab 照旧;loadPlatformPublicURL 和 loadPlatformHTTPHosts 都会被调用。

部署实测(PR head e4b24a25,本机原生部署,MySQL 8.4.7 空库,AGENTFLOW_PUBLIC_URL=http://127.0.0.1:18100)

  • 建表:platform_settings 和 platform_git_http_hosts 都建好了;bot_user_bindings.sender_name、bot_interactions.sender_name 也都加上了。
  • 外部访问地址(管理员):
    • GET 返回 source=env,并带回环地址提示。
    • PUT https://LoopForge.Example.com/ 后规范化为 https://loopforge.example.com,source=settings,带 updatedBy。
    • ftp:// 返回 400;:65536 返回 400(端口必须为 1 到 65535,上一轮的 P3 已修)。
    • http://localhost:18100 返回 200 并带 warning。
    • DELETE 后回到 source=env。
  • 权限:普通成员 GET/PUT/DELETE 都是 403,未登录 401,跨源 PUT 403。
  • main 带进来的 HTTP 主机信任:
    • POST git.internal.example:8080 返回 201。
    • 普通成员 GET /api/git-http-hosts 能看到 http://git.internal.example:8080。
    • 普通成员 POST 返回 403。
    • 不带 If-Match 的 DELETE 返回 428,带上 revision 后返回 204。
    • HTTPS 主机列表正常。
  • 页面(Chromium,真实登录):
    • tab 依次是 成员账号 / 平台管理员 / 共享 CodeBuddy Key / Git 主机信任 / 外部访问地址。
    • 「Git 主机信任」里 SSH、HTTPS、HTTP 三块都在,并且能看到刚加的 HTTP 主机;这个 tab 里没有混进外部访问地址的内容。
    • 「外部访问地址」从页面保存成功,并提示「环境变量 … 已被这里的设置覆盖」。
    • 键盘导航:在 Git 主机信任上按 → 到外部访问地址,再按 → 回到成员账号,按 ← 又回到外部访问地址。
    • 页面没有 JS 报错。820 宽深色布局也看过。
  • 单测:
    • go vet 通过。
    • domain、notification、botinteraction、web 全部通过。
    • webtest/tests/platform-admin.test.mjs 9/9 通过。
    • repo(真实 MySQL)和 httpapi 的失败与 main 在同一环境下的结果对比见下。
  • 未实测:真实企业微信、飞书、钉钉的收发。这部分合并没有改动,上一轮已经审过。

repo / httpapi 的失败与本 PR 无关:同一容器、同一 MySQL 跑 main 2ad5659b,失败的是同样 24 个用例(TestMySQLGitSSHCredentialLifecycle、TestMySQLReadsObserveExternalChangesWithoutReload,以及浏览器/沙箱/SSH 类用例)。PR 和 main 的失败集合完全一致。本 PR 新增的 TestIssueOperation*、TestBotSenderName*、TestPlatformPublicURL* 等全部通过。

截图和完整记录在评审方的资料库里。按要求不往本仓库上传图片,也不开截图分支。

@crispinhu27

Copy link
Copy Markdown
Collaborator

复审 dacb9565。上一轮六条问题均已修复,platform-required 已通过,E2E 路由覆盖率为 85.3%(349/409)。建议合并前修复下面的外部地址校验问题。CI

  1. [P2] 带网卡标识的 IPv6 链路本地地址仍能覆盖有效配置。 本地实测保存 http://[fe80::1%25en0]:8090 返回 200,落库值变成 http://[fe80::1%en0]:8090,覆盖了有效的环境变量地址。随后链接生成器拒绝这个值,Bot 无法生成绑定和确认链接。请在保存前拒绝带 zone 的 IPv6 地址,并断言校验失败时原地址继续生效。代码
  2. [P3] 钉钉绑定完成后漏存回调已上报的姓名。 /bind 确认成功后提前返回,跳过正常对话里的姓名缓存。绑定回调带有 senderNick,接收人列表仍显示平台账号和掩码 ID。请在成功完成绑定时缓存已上报的姓名,覆盖绑定后立即读取接收人列表的用例。代码
  3. [P3] MySQL 下仅修改昵称的大小写或重音时,缓存保留旧值。 Docker MySQL 8.0 默认使用 utf8mb4_0900_ai_ci。上报 Zoë 或 zoe 后,sender_name <> ? 仍保留 Zoe,接收人列表和网页确认日志会继续读到旧值。请按原始文本精确比较,并保留对旧行 NULL 的兼容。代码

本地复跑了 PR 和合并快照 398f6d76 的相关 Go 用例,平台管理前端用例 9/9 通过。MySQL 升级实测确认旧绑定可以首次写入姓名。

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review(增量):#1300 dacb9565

结论:LGTM,Approve。 上一轮(e4b24a25)唯一的阻塞是 CI 红:e2e 路由覆盖率 84.8%,低于 85%,原因是 PUT/DELETE /api/platform/public-url 没有被 e2e 测到。这次的新提交补上了这两个接口的 e2e 测试,CI 现在 16/16 全绿。

  • Reviewed head:dacb9565fc5f2440f0032c2b87e0802cc317b5a6(上次评审 e4b24a25)。新提交只有 dacb9565 test(e2e): cover public URL settings lifecycle,改了 1 个文件 e2e/api/50-platform.test.mjs(+29)。
  • 和当前 main 848793b3 合并没有冲突(git merge-tree 干净)。

代码审阅

新用例 platform: saves and clears the external access address 覆盖了保存、拒绝非法端口和清除三个环节:

  • 保存时带末尾 /,断言返回的 value/stored 已去掉斜杠,source=settings,envValue 不变,updatedBy 有值;
  • 端口 65536 返回 400,而且之后 GET 结果和保存后完全一样(失败请求没有改动数据);
  • 清除后 source 按部署环境回到 env 或 none,stored 为空,再 GET 结果一致;
  • t.after 会恢复到测试前的设置,不会污染共享环境。

部署实测(本机,PR 构建 + MySQL 8.4.10 空库)

场景 结果
node --test api/50-platform.test.mjs 全文件 13 通过 / 0 失败 / 1 跳过(跳过的那条需要真实模型,和本 PR 无关)
新用例单独跑 ✅
测试前先设置 https://pre-existing.example.com,再跑新用例 ✅ 跑完后恢复成原来的地址,t.after 的恢复逻辑有效
普通成员 PUT /api/platform/public-url 403
CI(browser / platform-required / core / e2e 等) 16/16 通过

@newexploreor
newexploreor merged commit 1cbaa4a into main Nov 25, 2026
16 checks passed
@newexploreor
newexploreor deleted the feat/issue-operation-im-actor branch November 25, 2026 07:31
Robert0622 pushed a commit that referenced this pull request Nov 25, 2026
#1300 added a clarification test that expects the bot reply "已启动 SOP" and a comment that says "a SOP started". This branch already renders "已启动 LOOP", so the test failed after merging main.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Robert0622 added a commit that referenced this pull request Nov 26, 2026
* feat: rename SOP to LOOP across LoopForge

* Apply LOOP terminology to copy merged from main and fix CHANGELOG anchor

Rename the user-visible SOP copy that main added for the enterprise IM
channels, observability dashboard and docs, following the same rules as
the rest of this branch (routes, JSON fields and identifiers unchanged).

Keep accepting the old wording where it can still arrive: notification
cards skip both LOOP and SOP header lines, chat drafts recognise both
(LOOP:…) and (SOP:…) notes, and the clarification command accepts
"保存并启动 LOOP" as well as "保存并启动 SOP".

Point the CHANGELOG link at #updating-existing-public-loops.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Renumber the LOOP terminology migration to 043 and re-apply the rename to main's new copy

main added 042_project_credentials.sql and 042_skill_bodies_to_files.sql,
so the terminology migration becomes 043_loop_terminology.sql; the
installer, its test and the deployment guide follow.

Rename the user-visible SOP copy from #1264, #1294, #1295, #1296 and
#1298 (project roles, join requests, project credentials, workspace
preview messages) with the same rules as the rest of the branch.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Restore the legacy (SOP:…) draft note check clobbered by the rename sweep

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(chatbot): recognize proposal receipts saved before the LOOP rename

Conversations saved before the rename still hold the SOP wording of the
declined and timed-out proposal receipts. The chat matched only the new
LOOP text, so these internal resume turns showed up as user messages.
Accept both wordings.

Rooms also parse LOOP「…」 authors with the correct length and keep
recognizing legacy SOP「…」 authors.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Apply LOOP terminology to the chat attribution copy merged from main

#1300 added a clarification test that expects the bot reply "已启动 SOP" and a comment that says "a SOP started". This branch already renders "已启动 LOOP", so the test failed after merging main.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Resume paused children marked before the LOOP rename

The child-resume marker merged from #1327 now reads "等待继续子 LOOP". A parent paused on a build that stored "等待继续子 SOP" still resumes its child after admission.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* test: cover run evaluation before approval

* test: exercise five previously uncovered platform routes

* fix: translate LOOP evaluation and runner allocation messages

* fix(engine): name LOOP in the remaining auto-assign errors

The default-executor fallback label and the no-compatible-sandbox
error still said SOP after the main merge.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix: name LOOP in errors merged from main

Four user-visible errors that arrived with main (#1342 work branch naming,
#1343/#1348 runner auto-assign, #1301 child artifacts) still said SOP.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(migrations): preserve customized LOOP template copy

* test(install): copy migration 043 into the live install fixture

install-schema-extensions.sh now replays migrations/043_loop_terminology.sql,
but test-install-live.sh only copied 001/033/038/042 into its trimmed
fixture, so every live install identity stopped at the first install with
'cat: migrations/043_loop_terminology.sql: No such file or directory'.

Copy 043 as well, and add a test-install.py check that every migration the
installer replays is in the live fixture's copy list, so CI catches the
next one.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Name LOOP in comments and test copy merged from main

The merge of main kept the product copy for requirements without a LOOP,
but comments, test fixtures and failure messages around #1411's sopMode
still said SOP. Use the LOOP terminology there too; protocol values such as
sopMode none/sop and Go identifiers keep their names.

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: roberttwang <roberttwang@tencent.com>
Co-authored-by: roberttwang <u_dc6754cd1ee5@users.noreply.local>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <codex@users.noreply.github.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.

3 participants