Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ jobs:
# blocking unrelated work.
- name: Run file watch contract tests
if: runner.os != 'macOS'
# Fail with bounded diagnostics instead of occupying a runner for the
# workflow-wide timeout if a native file-watch operation stalls.
timeout-minutes: 5
run: cargo test --locked -p bitfun-services-integrations --no-default-features --features file-watch --test file_watch_contracts

# Search tools resolve paths and symlinks directly, which also differs
Expand Down
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/architecture/agent-runtime-deployment-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ flowchart TB
| ACP/SDK Host | 使用同一个 Runtime 事件入口的 session-scoped 订阅;各自协议和进程生命周期保持独立 |
| Runtime ownership | Desktop、CLI、ACP、SDK Host 和现有 Server agent bootstrap 共用 Core owner;Embedded 取得共享锁,Shared TUI 取得独占锁,同一 workspace 上两种 deployment 互斥 |
| Session 写入 | BitFun Runtime 的持久化 Session 由 `SessionManager` 管理;同一存储位置中的同一 Session 同时只允许一个本机进程写入,list/view 等只读操作不受影响 |
| 当前 HTTP Server | 只提供 health/info/WebSocket 外壳,未装配 Agent Runtime,因此不取得 workspace ownership;`bootstrap.rs` 仅保持 agent-enabled composition 的一致边界,不由当前入口启动 |
| 当前 HTTP Server | 产品演进暂停;当前本机入口通过 App Server 装配 Embedded Agent Runtime。显式 workspace 失败即停止;隐式历史只作建议并可降级到默认 Assistant workspace。workspace 准备与后台任务均晚于 ownership,远程执行仍不可用;这些边界不表示生产 Web 能力已完整交付 |
| Shared local IPC | 未发布的本机协议已有 discovery、实例锁、严格握手、Session 控制权、有界事件流和 cleanup;唯一 consumer 是第一方交互式 TUI adapter |
| Shared TUI | `bitfun --shared` / `bitfun chat --shared` 可列出、创建、恢复 Session,删除未被控制的空闲非当前 Session,通过 `/fork` 从完整历史或选中提示词之前创建分支,重命名当前 Session,读取 transcript,通过 **View subagents** 只读查看当前根 Session 的子会话并定向取消子会话活动 Turn,切换当前 Session 的 Agent mode/model,通过 `/reload [skills|instructions]` 刷新声明式上下文,通过 `/compact` 或 `/summarize` 压缩当前 Session 上下文,在 Turn 空闲时通过 `/diff` 读取 Runtime 绑定工作区的只读差异,提交/取消 Turn,处理 Permission 和 UserInput;默认仍是 Embedded |
| Shared GUI/Headless/ACP/SDK Host/Remote | 未交付,也不会由 `--shared` 隐式启用;Replay、Observer、通用 Controller transfer 和 Session archive 同样不在当前协议中 |
Expand Down Expand Up @@ -130,7 +130,7 @@ flowchart TD
| Desktop 打开多个 workspace | 首次 attach/write 时逐个取得并持有文件锁 | 不把窗口数、Session 数等同于 Runtime 进程数 |
| 只读 list/view | 不加锁 | ownership 只管理 Runtime deployment,不扩大成读取权限 |
| 已解析且带有效 `connection_id` 的 remote workspace | 本机不加锁 | 与 Session storage 的远端判据一致;`host` 提示本身不能绕过本地锁 |
| 当前只读 HTTP Server | 不创建 Core owner | 没有 Agent Runtime 就没有 ownership 可声明 |
| 暂停演进的 HTTP Server | 创建 Core owner;显式 workspace 经 ownership-aware open,历史 metadata 在 ownership 前不触发 workspace 准备 | 显式失败终止启动;历史恢复失败告警并通过同一门禁降级默认 Assistant workspace,默认也失败时终止;该安全门槛不等于生产完整度 |

`CoreRuntimeOwnership` 只选择 deployment、产品 identity 并在进程存活期间持有锁;`services-core` 只负责 canonical key 和跨进程锁。二者都不选择 workspace、不启动 Runtime,也不替代 Session 单写、数据库事务、文件冲突控制或安全沙箱。

Expand Down
27 changes: 17 additions & 10 deletions docs/architecture/product-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ flowchart LR

### 2.4 Physical View · Level 0

Physical View 展示当前可执行单元到设备、主机和存储的映射。Desktop、CLI、ACP 和 SDK Host 使用 Embedded Runtime;交互式 TUI 可以显式连接 Shared Runtime。当前 Web Server Relay Server 都不承载 Agent Runtime。
Physical View 展示当前可执行单元到设备、主机和存储的映射。Desktop、CLI、ACP 和 SDK Host 使用 Embedded Runtime;交互式 TUI 可以显式连接 Shared Runtime。暂停演进的 Web Server 当前也通过 App Server 装配 Embedded Runtime,但实现尚不完整,不能据此声明生产 Web 能力;Relay Server 不承载 Agent Runtime。

```mermaid
flowchart LR
subgraph LocalHost["Local Host"]
direction TB
subgraph EmbeddedNodes["Embedded"]
direction LR
DesktopApp["Desktop App"] ~~~ CLIApp["CLI App"] ~~~ ACPApp["ACP"] ~~~ SDKHost["SDK Host"]
DesktopApp["Desktop App"] ~~~ CLIApp["CLI App"] ~~~ ACPApp["ACP"] ~~~ SDKHost["SDK Host"] ~~~ PausedWebServer["Paused Web Server"]
end
SharedRuntime["Shared Runtime"]
WorkspaceData["Workspace Data"]
Expand All @@ -325,8 +325,6 @@ flowchart LR
MobileClient["Mobile Client"]
end

WebServer["Web Server"]

subgraph RelayHost["Relay Node"]
direction TB
RelayServer["Relay Server"]
Expand All @@ -337,7 +335,7 @@ flowchart LR
AIProviders["AI Providers"]
RemoteHosts["Remote Hosts"]

WebClient -->|WebSocket| WebServer
WebClient -->|WebSocket| PausedWebServer
MobileClient -->|HTTPS| RelayServer
DesktopApp <-->|WebSocket| RelayServer
CLIApp <-->|WebSocket| RelayServer
Expand All @@ -353,7 +351,7 @@ flowchart LR
DesktopApp -->|SSH| RemoteHosts

classDef unit fill:#ffffff,stroke:#737373,stroke-width:1.3px,color:#171717;
class DesktopApp,CLIApp,ACPApp,SDKHost,SharedRuntime,WorkspaceData,ToolProcesses,WebClient,MobileClient,WebServer,RelayServer,RelayDB,AssetStore,AIProviders,RemoteHosts unit;
class DesktopApp,CLIApp,ACPApp,SDKHost,PausedWebServer,SharedRuntime,WorkspaceData,ToolProcesses,WebClient,MobileClient,RelayServer,RelayDB,AssetStore,AIProviders,RemoteHosts unit;
style LocalHost fill:#ffffff,stroke:#737373;
style EmbeddedNodes fill:#ffffff,stroke:#a3a3a3;
style UserDevice fill:#ffffff,stroke:#a3a3a3;
Expand All @@ -369,7 +367,7 @@ flowchart LR
| Shared Runtime | 私有本机 IPC;当前只有交互式 TUI consumer |
| ACP | Embedded Agent Runtime、ACP 协议生命周期 |
| SDK Host | 私有跨进程 adapter;公开 SDK 产品尚未交付 |
| Web Server | Health、Info、WebSocket 外壳;不包含 Agent Runtime |
| Paused Web Server | 当前提供 Health、Info、WebSocket 与 App Server,并装配 Embedded Agent Runtime;产品演进暂停,现有实现不代表生产完整度 |
| Relay Server | WebSocket/HTTP bridge、账户与同步;不包含 Agent Runtime |

### 2.5 Scenarios (+1) · Level 0
Expand Down Expand Up @@ -727,15 +725,23 @@ flowchart TB
CLI["CLI / TUI"] --> CliClosure["Core owner feature closure"]
ACP["ACP"] --> Parts["Runtime Parts"]
SDKHost["SDK Host"] --> Parts
ServerBootstrap["Server agent bootstrap · dormant"] --> Full
ServerBootstrap["Paused Web Server current host"] --> ServerClosure["agent-runtime + ssh-remote"]

Full --> Coordinator["ConversationCoordinator"]
CliClosure --> Coordinator
Parts --> Coordinator
ServerClosure --> Coordinator
Ownership["CoreRuntimeOwnership"] -. "first-party composition injects once" .-> Coordinator
```

当前公开 HTTP Server 不调用 agent bootstrap,因此不创建 Runtime 或 workspace ownership;图中的 Server 节点只记录已有 agent-enabled composition 边界,不能据此宣称 Server Agent API 已交付。
暂停演进的 HTTP Server 当前会调用 agent bootstrap 并装配 Embedded Runtime。启动边界如下:

- 显式 `--workspace` 必须是已存在且可规范化(canonicalize)的绝对本机路径。它是权威操作员输入;参数校验、打开或 ownership 失败均终止启动,不允许静默切换目录。
- 无显式参数时只加载历史 metadata,不在 ownership 前准备 workspace。本机历史打开失败会告警,并通过同一门禁降级到默认 Assistant workspace;默认目录的首次创建也位于可回滚 ownership claim 内,默认 workspace 失败时才终止启动。
- 当前 Host 没有 SSH manager,因此不尝试恢复 Remote 历史。新默认目录不存在时会原位使用并正确分类旧 Assistant 默认目录;目录迁移仍由正常产品启动流程持有。
- Server 选择 `ssh-remote` 并注入 `RemoteExecPort`,但没有装配全局 remote-workspace/SSH manager,远程执行仍返回不可用。

这些是当前实现缺口,不表示产品已弃用,也不表示生产 Server、Remote Connect 或 Desktop 完整能力已经交付。恢复 Web Server 演进时必须通过 App Server 和现有 owner 补齐这些边界,不能恢复平行的 WebSocket command path。

当前 Peer 运行连接:

Expand All @@ -756,7 +762,8 @@ flowchart LR
| Desktop | 使用 `product-full`;显示外部来源、审批、冲突、诊断和 Host 能力 | 可执行能力在事实所在 Host 运行;Safe Mode 只阻止新调用,不改来源、不取消正在运行的调用 |
| CLI / TUI | 使用显式 Core owner feature closure(`agent-runtime`、`canvas-runtime`、`external-sources`、`plugin-runtime`、`ssh-remote`);提供 `/extensions`、统一 `/hooks`(旧 `/hooks_external` 为别名)、`/tools` 和 `/agents`;Claude Code/Codex 命令 Hook 可经显式审阅复制为原生层 | 保持现有 CLI capability plan,但不自动继承 Desktop 后续加入 `product-full` 的能力;生态解析仍在适配器,不启动第二套 Agent Runtime;OpenCode Hook 仍只静态发现;远程能力未接入时不回退本机 |
| ACP | 使用 `DeliveryProfile::Acp`、Runtime Parts,以及 `agent-runtime`/`canvas-runtime`/`external-sources`/`ssh-remote` Core owner feature | load 成功后才发布活动状态;close 排空后再卸载;完整历史、Canvas 工具物化、兼容指令来源和配置仍由 Core/ACP 管理 |
| Peer / Server | Server 提供 control/catalog;Peer Host 执行真实工作区操作;当前 HTTP Server 不装配 Agent Runtime | 控制端不替远端发现或执行;旧 Host 明确降级,SSH Remote 未接入时返回不支持;只读 Server 不声明 Runtime ownership |
| Peer | Peer Host 执行真实工作区操作 | 控制端不替远端发现或执行;SSH Remote 未接入时返回不支持 |
| Paused HTTP Server | 当前装配 Embedded Runtime 和 App Server;Core feature closure 为 `agent-runtime,ssh-remote` | 产品演进暂停;显式本机 workspace 失败即终止,历史 metadata 不在 ownership 前准备;本机历史恢复失败或 Remote 历史不可执行时降级默认 Assistant workspace;SSH manager 未装配,不能声明远程执行能力或产品完整度 |
| Web / Mobile Web | 依赖现有后端入口 | 不持有插件执行单元,也不能据空 profile 宣称独立能力 |
| HarmonyOS 手机 Remote | phone-only ArkTS 远程入口 | 不等于 HarmonyOS PC 本地 Runtime、CLI/TUI 或 GUI |

Expand Down
43 changes: 19 additions & 24 deletions docs/performance/01-compile-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> 最近核实:2026-08-04
>
> 快照基线:`gcwing/main@061024fb2` 加权限规划 owner 迁移
> 快照基线:`gcwing/main@7f9bcf3a8`
>
> 稳定规则:[Rust 构建与依赖边界](../architecture/rust-build-dependency-boundaries.md)

Expand All @@ -13,10 +13,10 @@

| 结论 | 说明 |
|---|---|
| 本轮收益是测试隔离,不是产品构建瘦身 | 权限纯策略测试从 Core 约 449 节点的闭包迁到 Agent Runtime 约 78 节点的闭包;产品依赖图不变 |
| App Server / Server 已退出 `product-full` | normal/build 闭包分别从 545 降到 421、从 565 降到 497;这是产品入口构建图收敛,不据此宣称固定耗时收益 |
| 不再用 `product-full` 解决 focused test | Core 权限编排测试当前最小闭包是 `agent-runtime,canvas-runtime`;纯策略直接在 Agent Runtime 验证 |
| 不新增 CI 或测试入口 | 继续使用现有 test target 和 CI job;治理 PR 不复制同一闭包的验证 |
| 下一优先级是 App Server / Server | 先核实真实生产调用链,再收敛其 Core `product-full` 边界;收益不足则停止 |
| Server 保留 SSH 接口边界 | App Server 只选 `agent-runtime`;Server 为 bootstrap 注入的 `RemoteExecPort` 额外选择 `ssh-remote`。当前验证 host 未装配 SSH manager,不能据此宣称远程执行可用 |
| 依赖多版本不能按数量批量清理 | 只处理仓库能控制、行为等价且能缩小真实构建图的版本路径 |

权限 owner 的长期边界和功能不变量见
Expand Down Expand Up @@ -55,17 +55,20 @@
| Core `agent-runtime` check | 约 391 个节点 | 窄 owner feature 可独立编译 |
| Core 权限编排测试 | `agent-runtime,canvas-runtime`,约 449 个节点 | 保留真实 scope、Hook、请求生命周期和 Tool 执行 |
| Core `product-full` test | 约 516 个节点 | 仅用于确实需要完整产品装配的兼容路径 |
| App Server normal/build | 545 → 421 个节点 | 精确选择 `agent-runtime`,减少 124 个节点(约 22.8%) |
| Paused Web Server normal/build | 565 → 497 个节点 | 默认入口选择 `agent-runtime,ssh-remote`,减少 68 个节点(约 12.0%);非默认 source-check 为 544 个节点,不进入默认模块图 |
| Agent Runtime integration target | 5 个显式 target | 已完成收敛;平台和进程边界继续独立 |

节点数来自同一 Windows 环境下的 `cargo tree --locked` 相对统计,不是实际耗时,也不是跨平台阈值。
权限纯策略路径理论上少进入约 371 个节点;产品构建闭包没有变化。
权限纯策略路径理论上少进入约 371 个节点。App Server / Server 数字包含入口自身,使用同一
Windows 环境和 normal/build edge 口径;没有混入全 workspace 的 feature union。

### 3.2 依赖与 feature

| 状态 | 范围 | 处理结论 |
|---|---|---|
| 已稳定 | 根 `Cargo.lock`、Reqwest Rustls 单栈、Desktop 直接 `image 0.25`、workspace Tokio 最小基线 | 不重复治理 |
| 下一步核实 | App Server / Server 的 Core `product-full` | 按生产 construction path 收敛,不先写 feature 清单 |
| 已完成 | App Server / Server 的 Core `product-full` | App Server 固定 `agent-runtime`;Server 固定 `agent-runtime,ssh-remote`;边界检查防止回退 |
| 可独立治理 | Installer 的 Reqwest 0.12、独立 lockfile、疑似无消费者的 `tokio/full` | 保持 Installer 独立 workspace,不顺手合并 |
| 等待上游 | `screenshots 0.8.10 -> image 0.24.9` | 只有受维护且行为等价的上游替代出现后再处理 |
| 明确保留 | `portable-pty 0.8/0.9` | 非 OHOS 与 OHOS 的平台兼容选择,不为去重破坏 |
Expand Down Expand Up @@ -100,25 +103,17 @@

## 5. 后续顺序

### R1:收敛 App Server / Server 的 `product-full` 边界

这是下一 PR 的推荐范围,也是唯一需要优先设计的核心入口改造。

先回答:

- App Server 与 Server 的真实 construction、command 和 schema 路径分别消费哪些 Core owner?
- Server 对未实现能力应保持什么 typed unsupported 行为?
- 哪些能力由 Server 直接消费,哪些只是经 App Server 间接带入?

实现边界:

- 只替换一个端到端 capability slice 的依赖路径,不一次迁移全部 Core 调用;
- 优先显式选择已有 owner feature,或消费现有 Runtime SDK/service port;
- 不复制 Session、Tool、Permission、Hook、Event 状态,不建立第二 Runtime;
- 未迁移能力保留现有兼容路径或明确 unsupported,禁止静默本机回退。

验收必须覆盖 Server WebSocket/App Server round-trip、权限、取消、事件与恢复语义,并对比 App Server、
Server 的 normal/build/test closure。若构建图收益不足或行为等价无法证明,则不删除兼容边界。
### R1:App Server / Server `product-full` 边界(已完成)

- 真实入口是 Server bootstrap 构造一套 Embedded Agent Runtime,再由 `/ws` 直接 serve App Server;
- App Server 的当前 schema 只消费 Runtime 以及 git/config/i18n 路径,因此固定为 `agent-runtime`;
- Server 的 bootstrap 还注入 `RemoteExecPort`,因此显式保留 `ssh-remote`;当前未装配 SSH manager,
远程执行仍明确不可用;
- 未注册的 dispatch/external-source 旧模块及其第二套 SSH 状态退出默认编译图;非默认 source-check
feature 只保护暂停源码的编译与既有单测。external-source 请求继续返回 typed `host_capability_unavailable`,
没有静默本机回退;
- 默认解析闭包没有新增激活依赖;4 个 optional dependency 只服务于 source-check。没有新增 test target
或 CI job,也没有复制 Runtime owner。

### 后续队列

Expand Down
Loading