Skip to content

feat: share execution machines and separate CLI model catalogs - #1285

Merged
crispinhu27 merged 15 commits into
mainfrom
feature/shared-execution-machines
Nov 24, 2026
Merged

crispinhu27 merged 15 commits into
mainfrom
feature/shared-execution-machines

Conversation

@crispinhu27

Copy link
Copy Markdown
Collaborator

What changed

  • Let execution machine owners grant access to multiple projects. Members with write access can choose the shared machine for a new conversation or set it as their own default for new conversations and SOP runs in that project.
  • Load Codex and Claude Code model catalogs and reasoning levels from each CLI's authentication mode on the selected machine. Account login uses a machine-specific catalog with built-in CLI models as the default. API Key mode uses the member's personal catalog and endpoint.

Scope

  • Platform core / API / runner
  • Shared behavior contract

Compatibility

  • Revoking access clears the affected project preferences. Existing sessions and SOP runs stay bound to their execution machine.
  • Existing model catalogs remain in personal settings. The account-login catalog starts with the CLI defaults and can be configured on the machine.
  • GORM adds the runner settings columns and project preferences table through incremental DDL.

Validation

  • npm --prefix chatbot test -- tests/hooks.test.jsx tests/execution-machines.test.jsx passed 68 tests.
  • node --test webtest/tests/mcp-sops-runners.test.mjs webtest/tests/runner-codebuddy-environment.test.mjs passed 12 tests.
  • Focused Go tests passed against disposable Docker MySQL, including project authorization, revocation, SOP routing, credential selection, and model catalog persistence after Runner re-registration.
  • python3 scripts/check-public.py passed.
  • Before rebasing, the full Chatbot and Web suites passed, and a local browser smoke test verified both authentication modes across two machines. An earlier full Go run reported Chromium and MySQL integration fixture failures, some reproduced on main.

Safety

  • Changes contain public source, documentation, and synthetic test fixtures.
  • User files and unrelated changes were preserved.

@Robert0622

Copy link
Copy Markdown
Collaborator

Reviewed 0d6d223. The project sharing and revocation tests, MySQL persistence tests, and the Codex/Claude Code account vs. API-key catalog checks passed.

[P2] Apply project eligibility to the personal default fallback. I reproduced this with an online machine set as the owner’s personal default and a writable project that the machine was not shared with. GET /api/runners/default?projectId=… returns it as the effective runnerId, but the project picker excludes it and saving a new project conversation with that ID returns HTTP 400 (无权使用此执行机器). The same fallback makes a new SOP select that machine, while a new chat falls back to Cloud. Please resolve the effective default through the same project eligibility check for both the API and SOP scheduling. The saved personal preference can still be returned separately in personalRunnerId. Default API · SOP selection

@Robert0622

Copy link
Copy Markdown
Collaborator

Re-reviewed 9c28075. The project eligibility fix works in the API and SOP selection. An ineligible personal default is retained as a preference and the project uses Cloud. The project sharing, revocation, and model catalog regressions passed.

[P2] Let owners set their eligible machines as project defaults. In a writable project, the settings page only displays “在此项目使用” for machines owned by other users. I reproduced this with two machines marked usable in the project. The peer's machine had the project-default action, while my own shared machine only had the personal-default action. The local API accepted the owned machine as the project's default and left the personal default intact. An owner with different machines for different projects therefore has no matching settings action. Gate the project action on canUseInProject so it is available to any eligible machine. Runner card actions

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

[P1] 机器绑定人失去项目写权限后,机器仍可承接该项目的新任务。 实测将共享机器设为项目默认,再由项目 Owner 将机器绑定人降为 viewer 或移出项目。两种情况下,机器列表仍返回 canUseInProject: true,默认接口仍指向原机器。预期该机器应退出新会话的候选列表和新 SOP 的默认选择。当前资格检查只校验提交人的权限和已保存的共享记录。共享资格检查 · 新 SOP 默认机器解析

[P2] Codex 账号登录模式下,跟随默认执行器的 SOP 仍使用个人 API Key 的模型和思考强度。 在同一台机器配置账号目录 qa-account-only / low 和个人默认 qa-gateway-only / high,分别以账号登录和 API Key 模式启动 SOP。两份运行快照都记录了 qa-gateway-only / high。账号登录时应采用机器账号目录或 CLI 默认值,否则可能把仅个人网关支持的模型传给本机 CLI。SOP 模型选择 · Runner 认证模式

实测

  • 核对了 HEAD 和指定的 base...head 差异。Compose 源码构建成功,容器标签与镜像内提交号一致,健康接口返回 200,原 MySQL 容器保持健康。
  • 浏览器和 API 验证了真实 Runner 绑定、多项目共享、绑定人设置项目默认、成员选择共享机器,以及未共享项目回退云端。Viewer 设置默认返回 403。显式撤销一个项目的共享后,该项目默认清除,旧草稿再次保存返回 400,另一项目的默认仍有效。
  • 共享 Runner 成功执行脚本 SOP。并发上限初始为 10,1001 和 0 可保存,负数返回 400。将绑定人降为 viewer 或移出项目后,均复现机器仍可选且仍为有效默认。
  • 浏览器确认 Codex 对话按认证模式显示账号目录或个人目录,清空账号目录后显示内置模型。对比两种模式的新 SOP 快照,复现账号登录模式选错模型和强度。
  • 定向 Go 测试 22 项通过,其中 MySQL 集成测试 2 项。Chatbot 测试 106 项和 Web 测试 12 项通过。
  • 部署上的 Runner E2E 有 4 项通过,覆盖产物传递、失败后保留产物、必填产物校验和会话鉴权。仓库子 SOP 因用例未配置远端而跳过。管理路由用例使用普通账号,在管理员专用接口收到 403,未完成该用例。
  • 使用提供的测试资源查询 Git 测试仓库远端 HEAD 成功。DeepSeek 模型目录请求返回 2 项,CodeBuddy IOA 目录探测列出 36 项。

@Robert0622

Copy link
Copy Markdown
Collaborator

[P2] Check chat compatibility before assigning a shared project default

On 49dd598, I connected a real online Runner 0.9.2 from the LoopForge 0.3.4 image, shared it with a project, and selected 在此项目使用 as a writable member. The default request returned HTTP 200. The workbench automatically selected that machine, but the first send failed before model dispatch. The session request returned HTTP 400 with 执行机器需升级至 0.10.1 才能执行对话, and the unusable default remained selected.

The project-default action accepts Runner 0.8.0 and later, while chat requires 0.10.1. Please apply the chat capability check to the chat picker and its effective default. If older Runners remain eligible for SOPs, keep that preference usable for SOP routing and fall back to another compatible machine or Cloud for chat.

Project default action · Chat admission

Workbench rejects the already selected Runner 0.9.2

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

[P1] 机器绑定人失去项目写权限后,这台机器仍对其他成员可用,也仍是有效的项目默认。 CanUseRunner 只检查「机器是否共享给该项目」和「当前请求者是否有该项目写权限」,没有检查机器的绑定人(runner.OwnerUserID)现在是否还有该项目写权限。复现:bob 把 bobhost 共享给 p1,alice 设 bobhost 为 p1 默认;alice 通过 PUT /api/projects 把 bob 移出 p1 成员;之后 GET /api/runners?projectId=p1 仍返回 bobhost 的 canUseInProject: true,GET /api/runners/default?projectId=p1 仍返回 bobhost,PUT /api/runners/default 仍返回 200。此时 bob 自己已经没有 p1 的写权限,其他人却还能把代码派发到他的机器。这条是上一轮在 0d6d223/9c28075 之后于 49dd598 提的 P1,本轮仍未修复。runner_sharing.go

[P1] 机器撤销共享(或成员被降为 viewer)后,已经锁定执行机器的会话仍然发往原机器。 assistant.go 里锁定分支直接用 old.Execution() 作为目标,不重新调用 CanUseRunner;assistant_process.go 派发前只检查机器是否在线。复现:bob 在 p1 建会话 asbob1,执行目标锁定为 alice 的 laptop 并成功跑过一轮;alice 用 PUT /api/runners/laptop/shared-projects {"projectIds":["p2"]} 撤销 p1 共享;bob 在同一会话再发一轮,POST /api/assistant/generations 仍返回 202,日志显示请求已经走到 requestWorkspace(只是本机没有 daemon 才失败)。把 bob 降为 viewer 结果相同。影响是机器所有者撤销共享后,其他人既有的对话仍能继续在他的机器上执行代码。main 上会话只能用自己的机器,这是本 PR 新引入的。assistant.go · assistant_process.go

[P2] Codex 账号登录模式下,SOP 仍会使用发言人的个人 API Key 模型和思考强度。 sop_executors.go 在用户有个人 Key 时直接返回 preferred.Model/Effort,没有判断执行机器是否处于本机账号登录模式。上一轮在 49dd598 提过,本轮未修复(这一条为读代码确认,未实跑 SOP 执行)。sop_executors.go

实测

  • 本轮增量 49dd598 只改前端 web/app/runners.js 与两个 webtest:本人机器的「在此项目使用」按钮、PUT 后保留 canUseInProject、当前默认机的禁用状态。逐行看过,这部分没有发现缺陷。
  • 共享项目 PUT /api/runners/:id/shared-projects:alice 把自己的 laptop 共享给 p1/p2、desktop 共享给 p1 → 200;bob 共享给非成员项目 → 403;bob 改 alice 的机器 → 403;机器重新注册后共享列表保留。
  • 项目默认 PUT /api/runners/default?projectId=:Owner 与 member 设可用机器 → 200;viewer、外部用户 → 403;未共享的项目 → 403;不带 projectId 设别人的机器为个人默认 → 403;撤销共享后 user_project_runner_prefs 中对应默认已删除。
  • 复测上轮两条:0d6d223 的 P2(个人默认回退未做项目资格判断)已修复——alice 个人默认 laptop,在 p3 查询返回 runnerId="";9c28075 的 P2(本人机器缺少「在此项目使用」)已修复——以 alice 打开 p1,laptop 和 desktop 都出现该按钮,点击后显示「此项目默认 · desktop」,接口 projectRunnerId 一致。
  • go test 定向(repo/httpapi/domain 的 Runner/Sharing/SOPExecutor/ProjectDefault/Effort 用例)通过;MySQL runner 共享集成测试 3 项通过;webtest mcp-sops-runners、runner-codebuddy-environment 共 12 项通过。engine 的 2 个 SharedWorkspace 用例因容器没有 bwrap 失败,与本 PR 无关。
  • 未测:没有 runner daemon,会话与 SOP 在共享机器上真正执行、产物传递、两种登录模式下的模型快照对比都未实跑;没有 Docker 与 bwrap。

截图(p1 下的机器列表与默认机)

  • alice 视角:alice p1
  • 设默认后:alice p1 default

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

复测 ed78884e(fix: revalidate runner shares and SOP auth defaults)。

已修复

  • CanUseRunner / RunnersForUser / SetProjectDefaultRunner 现在通过 runnerSharedByWritableOwner 同时检查机器绑定人当前是否仍有该项目写权限。实测:bob 把 bobhost 共享给 p1,alice 设 bobhost 为 p1 默认(200,projectRunnerId 正确);alice 把 bob 移出 p1 后,GET /api/runners?projectId=p1 返回空列表,GET /api/runners/default?projectId=p1 的 projectRunnerId 变为空,PUT /api/runners/default?projectId=p1 返回 403,SetProjectDefaultRunner 400→403 一致。上一轮 49dd598 的 P1 已修复。
  • Codex/Claude Code 账号登录模式:sopExecutorAccess.defaultsFor / runnerLoginDefaults 走登录模型目录,不再套用个人默认的 model/effort。这条为读代码确认(新增 sop_executors_test.go 154 行覆盖)。

仍未修复(P1)

  • 已锁定执行机器的会话仍不重新校验共享。internal/httpapi/assistant.go:172-178 的锁定分支直接用 old.Execution(),assistant_process.go:157-160 派发前只检查机器是否在线,仓库里只有 assistant_execution.go:42、runners.go:437 调用 CanUseRunner。复现路径不变:bob 在 p1 建会话锁定到 alice 的 laptop 并跑过一轮 → alice 撤销 p1 共享 → bob 在同一会话再发一轮,POST /api/assistant/generations 仍返回 202 并走到 requestWorkspace(本机无 daemon 才中止)。建议在锁定分支和派发前各调一次 CanUseRunner,失败时返回明确的「机器已不可用」而不是继续派发。

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

复测 23825c0(这次范围是 98fafaf..23825c0:合并 main 的 b0f8680,加上 23825c0 fix: honor runner project grants for scheduled chat)。上一轮的 P1 和本轮第一个 P2 都已修复,但升级后的老会话问题还在,暂不 approve。

已修复

  • [P1] 撤销共享后,已锁定的会话还能继续派发。TestLockedConversationRejectsTurnsAfterRunnerAccessChanges、TestConversationDispatchRechecksRunnerShareBeforeStarting、TestSteerKeepsRunningTurnWhenRunnerShareIsRevoked、TestConversationRunnerDefaultSkipsMachinesThatOnlySupportSOPs 在 head 通过。把修复代码换回 f8b1de5 后,这 4 个用例全部失败。
  • [P2] 定时任务用保存人的个人默认机器时,每次运行都被拒绝。现在 scheduleLoginRunner 要求机器已经共享给任务所在的项目:保存时,未共享的个人机器直接返回 400;模型目录按 projectId 判断是否可以用本机登录;撤销共享后,固定会话改用云端新会话。TestScheduleJobUsesSaversDefaultRunnerLogin 现在通过。webtest sync-schedule.test.mjs 20/20 通过。

仍未修复(P2):升级后,现有项目会话如果锁定在用户自己未共享的机器上,会变成 403
复现方法和上一轮一样:机器 own-laptop 归 owner 所有、没有共享给任何项目,项目 workbench 下有一个锁定在这台机器上的会话,owner 本人调用 POST /api/assistant/chat:

  • main:200
  • f8b1de5:200
  • head 23825c0:仍然是 403 当前无法使用会话绑定的执行机器,请新建对话或联系机器绑定人恢复共享

在 main 上,用户可以在项目会话里直接用自己的机器(newExecutionTarget 只校验 OwnerUserID == userID)。所以升级后,这类老会话会全部不可用,必须先把机器共享给项目。docs/deployment.md:194 仍然写着 “Existing SOPs and conversations keep their bound workspaces”,和现在的行为相反。
建议从下面选一种:

  • 升级时为已锁定会话的 (机器, 项目) 自动补上共享。
  • 在升级说明和这段文档里写明:项目内继续使用个人机器,需要先共享给项目。

定时任务这次已经改成「必须先共享」,会话这边也需要给出一致的迁移方式或说明。

实测

  • 原生部署 head(Go 1.26.11,MySQL 8.4.7,按 PR 的 chatbot 重新构建前端),健康检查 200。
  • 合并提交 b0f8680 的冲突在 internal/domain/project.go 和 internal/httpapi/project_write_access.go。处理方式是保留 #1264 的角色常量,并把 HasWritableMember 改用 ProjectRoleViewer,没有残留冲突标记。
  • ./internal/httpapi、./internal/repo、./internal/engine 中 Assistant、Runner、Schedule、Project 相关用例的失败集合,和 main(c42e224)完全一致(workspace checkpoint 和 MCP 类用例,原因是本机缺 bwrap)。./internal/repo 全部通过。

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

复测 95d5999(范围 23825c0..95d5999:合并 main 的 596ced8,加上 95d5999 docs: explain how to resume project chats after upgrading)。上一轮剩下的 P2 已经按建议的第二种方式处理(在升级说明里写明需要先共享),我按文档在真实升级场景里走了一遍,没有发现新问题,通过。

上一轮 P2 的处理

  • CHANGELOG 新增「Upgrade action for personal execution machines」条目,docs/deployment.md 新增 “Upgrading existing project conversations” 一节,原来那句和实际行为相反的 “Existing SOPs and conversations keep their bound workspaces” 已经改掉。
  • 新增 TestOwnerResumesLegacyProjectConversationAfterSharingRunner:先断言未共享时返回 403,共享后返回 200,且会话的执行目标没有变、消息数为 4。本机通过。

升级实测(main → 本 PR,同一个库)

  1. 用 main(177d881)在全新库上部署,普通用户 alice(非平台管理员)建项目 workbench,用 main 构建的 Runner 接入自己的机器 alice-laptop(0.12.1,没有共享给任何项目,装了 CodeBuddy CLI)。在项目里新建会话,锁定到这台机器,用 CodeBuddy + deepseek-v4.1-flash 跑一轮,返回 PRE-UPGRADE-OK。
  2. 停掉 main,在同一个库上启动本 PR 的平台,Runner 换成本 PR 构建的版本重新连上。在同一个会话里带完整历史再发一条:返回 403 当前无法使用会话绑定的执行机器,请新建对话或联系机器绑定人恢复共享。这和文档描述一致。
  3. 按文档操作:用 Chromium 打开「执行机器」页,点 alice-laptop 卡片上的「共享项目」,弹窗标题是「共享 alice-laptop」,选项里有 Workbench,勾选后保存,按钮变成「共享项目(1)」(截图 1、2)。
  4. 回到原会话再发一次:返回 202,这一轮在原来那台机器上跑完,回复 POST-UPGRADE-OK。会话的 executionTarget 仍是 {pool: runner, runnerId: alice-laptop},历史是完整的 4 条消息。
  5. 取消共享后再发,又变回 403;重新共享后恢复正常。

合并提交 596ced8

  • 冲突在 internal/httpapi/assistant_process.go 的 Runner 派发分支。处理方式是保留本 PR 重新校验共享的分支,并把 #1295 的项目凭据版本检查(SupportsProjectCredentials)放进这个分支,位置在 SupportsConversationCLI 之后、SupportsCLISettings 之前,没有丢失检查,也没有残留冲突标记。

测试

  • go vet ./... 通过;chatbot 493/493 通过。
  • ./internal/domain、./internal/gitwork、./internal/repo 全部通过。./internal/httpapi、./internal/runtime、./internal/runner、./internal/engine 的失败用例是 main(177d881)的子集,没有新增失败,都是本机缺 bwrap、Docker、Chromium 沙箱导致的。

非阻塞建议(P3)

  • 机器绑定人本人遇到这个 403 时,提示里的「联系机器绑定人恢复共享」指的其实就是自己。可以考虑在提示里直接写「到 设置 → 执行机器 → 共享项目 把这台机器共享给本项目」,或者链接到升级说明。

截图 1:执行机器页的「共享 alice-laptop」弹窗,勾选 Workbench
1285-01

截图 2:保存后,卡片显示「共享项目(1)」
1285-02

@crispinhu27
crispinhu27 merged commit c3dd1b4 into main Nov 24, 2026
16 checks passed
@crispinhu27
crispinhu27 deleted the feature/shared-execution-machines branch November 24, 2026 16:38
Robert0622 pushed a commit that referenced this pull request Nov 24, 2026
…hine

Project SOPs run on the user's project default machine (#1285), but
/api/executor-models only checked the personal default, so a user whose
only machine login was on the project default saw no usable CLI in the
role wizard. ExecutorCredentials now resolves the machine with
ResolveRunnerDefaults(user, project), and the role and SOP editors pass
the current project and cache the catalog per user and project.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Robert0622 added a commit that referenced this pull request Nov 25, 2026
* fix: only offer configured executors in model pickers

* fix: show when no executors are available

* fix: count shared and runner-login executors as configured

The executor model catalog marked a CLI configured only when the caller
saved a personal key, so users on the platform's shared CodeBuddy Key or
with account login on their default runner saw no executors in the role
wizard and SOP preview, although SOP runs accept them. Reuse the SOP run
credential check for `configured` and report the personal key separately
as `personal`.

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

* fix(executors): resolve picker credentials on the project default machine

Project SOPs run on the user's project default machine (#1285), but
/api/executor-models only checked the personal default, so a user whose
only machine login was on the project default saw no usable CLI in the
role wizard. ExecutorCredentials now resolves the machine with
ResolveRunnerDefaults(user, project), and the role and SOP editors pass
the current project and cache the catalog per user and project.

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

* fix(executors): offer cloud pool logins in the executor pickers

A project SOP whose responsible user has no default machine runs on a
cloud pool runner with that runner's account login, but the pickers
only looked at the default machine and showed no executor at all.
Resolve credentials the same way selectSOPExecutionTarget does and
count a CLI when any online pool runner logs it in.

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

* test(httpapi): build the cloud-pool picker test without path/filepath

#1223 replaces every filepath.Join(t.TempDir(), "workspaces") in
catalog_test.go with sandboxRoot(t) and drops the path/filepath import.
The new TestExecutorModelsConfiguredFollowsTheCloudPool still used
filepath, so merging both PRs (in either order, no textual conflict)
broke the internal/httpapi test build. The test only reads the
executor catalog, so a plain t.TempDir() is enough and compiles on
both bases.

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