Skip to content

fix(chat): allow owners to use unshared execution machines - #1452

Merged
crispinhu27 merged 1 commit into
mainfrom
feature/chat-owned-execution-machines
Nov 26, 2026
Merged

crispinhu27 merged 1 commit into
mainfrom
feature/chat-owned-execution-machines

Conversation

@crispinhu27

Copy link
Copy Markdown
Collaborator

What changed

Project sharing in #1285 made a project grant a prerequisite for a machine owner's own chat turns. Project members with write access can now select their own compatible execution machine, use it as their personal default when project settings allow, and resume conversations already bound to it. Other members use the machine through the project grant.

The picker, draft and turn validation, and Runner dispatch use the conversation permission. Project LOOP routing and scheduled execution check project grants. The deployment guide and changelog describe the new behavior.

Scope

  • Platform core / API / runner
  • Shared behavior contract

Compatibility

The Runner list adds canUseInConversation. The change uses existing machine bindings, chat records, database schema, and Runner version requirements.

Validation

  • npm --prefix chatbot test passed all 535 tests. npm --prefix chatbot run build passed.
  • node --test webtest/tests/mcp-sops-runners.test.mjs webtest/tests/sync-schedule.test.mjs passed all 26 tests.
  • Focused go test runs passed in internal/httpapi, internal/engine, and internal/repo, including conversation binding and steering, issue dispatch, automatic assignment, share revocation, and MySQL admission across targets.
  • A local end-to-end run using e2e/local.sh, Docker MySQL, and a real Runner verified an unshared owner's chat draft, platform assignment, issue dispatch to the shared Runner with artifact retrieval, and queue promotion to the platform after the share was revoked.
  • go vet ./internal/httpapi ./internal/engine ./internal/repo and python3 scripts/check-public.py passed.

The broader Go test run reached its timeout. The broader MySQL run reached its timeout and reported failures in TestEvolutionQueueMySQLConcurrentAdmission and TestMySQLReadsObserveExternalChangesWithoutReload. Both failures also reproduced with the base branch code on an AutoMigrate test database.

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.

@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.

PR #1452 — fix(chat): allow owners to use unshared execution machines

head: 952aab8 | base: main (0a026c1) | 审查时间: 2026-11-26 18:00

总结

通过。可以 Approve。

代码审查结论

PR 修复了 #1285 引入的回归:项目写权限成员把自己的机器绑定到项目后,自己再发对话时反而被拦,只因为 CanUseRunner 要求机器必须已共享给项目。

核心改动(internal/repo/runner_sharing.go,internal/httpapi/assistant_execution.go 等):

  • 新增 CanUseConversationRunner:机器所有者在拥有项目写权限时,无论机器是否共享,都可在对话中使用自己的机器。公式 shared || (owned && (projectID == "" || writable)) 覆盖了个人对话(无 projectID)和项目对话(有写权限)两种场景。
  • canUseBoundRunner / canUseBoundExecutionTarget 新增 requireShare bool 参数:定时任务(Scheduled)和 SOP helper 仍走原有的 CanUseRunner(要求共享),普通对话走新逻辑,权限边界清晰。
  • resolveRunnerDefaults 切换到 CanUseConversationRunner,对话默认机器解析和访问检查保持一致。
  • 前端 useExecutionMachines.js 过滤条件从 canUseInProject 改为 canUseInConversation,新字段由后端同步返回,不影响其他页面(LOOP 调度等)仍使用 canUseInProject。

主要覆盖场景:

  • internal/httpapi 新增 TestOwnerCanUseConversationRunner / TestOwnerRequiredShareForScheduled 等测试,明确区分对话和定时来源的访问策略。

无安全风险:

  • 只放宽了机器所有者自己对自己机器的访问,没有把任意成员到任意机器的权限放开。
  • 定时任务/SOP helper 仍要求机器已共享给项目(requireShare=true),不受影响。
  • ownerless(平台拥有)机器的逻辑未变。

验证结果

  • go vet ./internal/httpapi ./internal/engine ./internal/repo:通过
  • go test ./internal/repo(Runner/Sharing 相关):ok (0.999s)
  • go test ./internal/httpapi(Runner/Steer/Execution 相关):ok (48.2s)
  • go test ./internal/engine(Runner/AutoAssign 相关):ok (187.6s)
  • CI 15/15 全绿(first-run pass, e2e×5 pass, curl-install pass, secrets pass, tcmcp pass, validate×2 pass, e2e-required pass, e2e-browser pass, GITHUB_SCAN pass);browser 和 core 仍 pending(与本 PR 无关,main 同状态)
  • 与最新 main (0a026c1 feat(runners): configure privileged Docker sandboxes in settings) 无冲突

本地部署实测(私有测试库,非 Tencent/LoopForge 本身)

平台:PR build 952aab8,MariaDB 全新库,端口 18152,native 沙箱,CodeBuddy deepseek-v4.1-flash。
Runner:PR build agentflow-runner 0.13.1,owned by user B(项目 member)。

场景 结果 HTTP 状态
机器所有者(user B,项目 member)在项目对话中选择自己未共享的机器 ✅ 正常发起(202) 202
非所有者(user A,项目 admin)选择 user B 未共享的机器 ✅ 被拒(400「无权使用此执行机器」) 400
user B 把机器共享给项目后,user A 再用 ✅ 正常发起(202) 202
user B 取消共享后,user B 自己再用 ✅ 仍可正常发起(202) 202
user B 在个人对话(无项目)中用自己的机器 ✅ 正常发起(202) 202

5/5 场景全部通过。

非阻塞

  • 定时任务和 SOP helper 场景未在本轮实测(需要完整 Runner 执行链路,沙箱无 Docker),但对应代码路径有单测覆盖且逻辑保持原 CanUseRunner,无回归风险。

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