Skip to content
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/_rpm-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
;;
cosh-ng)
dnf install -y rust cargo openssl-devel pkgconfig
rustc --version | awk '{ split($2, v, "."); if (v[1] != 1 || v[2] < 88) exit 1 }'
;;
agent-sec-core)
dnf_install clang llvm openssl-devel libseccomp-devel bubblewrap python3-pip systemd-rpm-macros
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.88.0

- uses: Swatinem/rust-cache@v2
with:
Expand Down Expand Up @@ -1195,7 +1195,7 @@ jobs:
with:
python-version: '3.11'

- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.88.0
with:
components: 'rustfmt, clippy'

Expand Down Expand Up @@ -1239,7 +1239,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.88.0

- uses: Swatinem/rust-cache@v2
with:
Expand Down
63 changes: 60 additions & 3 deletions docs/developer-guide/en/cosh-ng/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

[中文版](../../zh/cosh-ng/architecture.md)

cosh-ng separates the interactive terminal, Agent runtime, and deterministic OS
API so each boundary can be tested and integrated independently.
cosh-ng separates the interactive terminal, Agent runtime, deterministic OS
API, and an emerging Gateway control plane so each boundary can be tested and
integrated independently. The Gateway material described below is a partial
candidate-worktree foundation, not an upstream production service.

## System view
## Upstream system view

```text
bash/zsh <--- cosh-shell
Expand All @@ -27,6 +29,46 @@ owns a long-lived cosh-core child at runtime. The stdin/stdout protocol between
them must remain backward-aware because either side can fail or restart
independently.

The pinned upstream baseline for the Gateway plan is
`fa0c8369d300d90a6470965dc564e20b09487eb7`. It contains the five crates and
runtime path above, but no `cosh-gateway` or `cosh-gateway-contracts` crate.

## Candidate Gateway foundation

The shared candidate worktree based on that baseline adds two library crates:

```text
cosh-gateway-contracts --> TaskAggregate --> SQLite Task/event/receipt/Outbox transaction
|
+---------------> Capability Broker slice (in-memory, targeted tests)

cosh-gateway ----------> RuntimeSupervisor --> private COSH JSONL v1 codec
`-------> official ACP wire-v1 codec/bridge
+ bounded session driver
+ fixed installed-adapter profiles

future CoshCoreBridge --> contracts public mapping + supervisor + codec

Gateway daemon/API, CoshCoreBridge, installed ACP entrypoint,
complete ACP domain/governance mapping, Shell attachment, and Web presentation
are not implemented.
```

The Task reducer and SQLite store are local control-plane foundations. The
Runtime supervisor owns a directly launched child process group, bounded
stdout/stderr, escalation/reap, and one process terminal observation. Its
cosh-core codec speaks the existing **private COSH control protocol v1**; it is
not ACP and is not yet mapped to public Runtime events.

No executable Gateway entry point or authenticated Unix/network API exists.
The current Shell path is unchanged: `cosh-shell` still owns its native PTY and
compatibility cosh-core process. The candidate pins official ACP Rust SDK 2.0.0,
raises the component baseline to Rust 1.88, and adds a supervised stable-v1
stdio slice plus built-in profiles for installed `codex-acp` and
`claude-agent-acp`. There is no package-runner or network bootstrap path. The
library still lacks an installed entrypoint, a session driver with independent
cancel, a production permission proxy, and real-adapter conformance evidence.

## Crate responsibilities

| Crate | Binary | Owns | Must not own |
Expand All @@ -36,6 +78,8 @@ independently.
| `cosh-cli` | `cosh-cli` | Clap commands, JSON envelope, exit status | Distro-specific branching outside platform adapters |
| `cosh-core` | `cosh-core` | Providers, tool loop, hooks, Skills, MCP, extensions, registry, sessions, and compaction | Terminal ownership or foreground PTY interaction |
| `cosh-shell` | `cosh-shell` | PTY host, input routing, cards, approvals, evidence, UI, core process lifecycle | Provider implementation or direct OS API abstraction |
| `cosh-gateway-contracts` (candidate) | — | Side-effect-free Task, Runtime, Capability, identity, header, and error contracts with bounded leaf strings/digests | Storage, process ownership, transport, provider, OS execution, or aggregate admission limits not yet implemented |
| `cosh-gateway` (candidate) | — | Partial Task reducer/SQLite store, Runtime supervision/private core codec, ACP v1 codec/bridge and fixed installed-adapter profiles, and Capability integration slice | Shell PTY, installed Gateway/ACP entrypoints, provider/ACP wire types as domain contracts, OS effects outside the Broker, or ungoverned ACP callbacks |

## Interactive data flow

Expand Down Expand Up @@ -108,5 +152,18 @@ after structural changes.
- Tool auto-approval fails closed. Raw command substring matching is not a
security boundary.

## Gateway and ACP delivery boundary

The candidate libraries do not form a durable production Gateway. They still
lack the Gateway API/daemon, Task coordinator and lease/recovery loop, complete
Capability enforcement, integrated CoshCore Bridge, installed ACP Runtime
entrypoint, production permission UI/evidence, real-adapter evidence,
Shell attachment, and Web/channel presentation. The
[ACP v1 Phase 0-2 planning set](../../../../src/cosh-ng/docs/design/acp-v1-phase-0-2/README.md)
separates the pinned upstream baseline from candidate implementation evidence
and defines the remaining module boundaries, Warp comparison, delivery
sequence, and acceptance gates. Overall Phase 0-2 status remains **NOT
ACCEPTED**.

Continue with [Developing cosh-ng](getting-started.md), [IPC protocols](ipc-protocol.md),
and [Testing](testing.md).
51 changes: 49 additions & 2 deletions docs/developer-guide/zh/cosh-ng/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

[English](../../en/cosh-ng/architecture.md)

cosh-ng 将交互式终端、Agent 运行时和确定性的操作系统 API 分开。每个边界都能独立测试,也可以由其他程序单独集成。
cosh-ng 将交互式终端、Agent 运行时、确定性的操作系统 API 和逐步形成的 Gateway control plane
分开。每个边界都能独立测试,也可以由其他程序单独集成。下文 Gateway 内容是候选工作树中的局部基础,
不是上游 production service。

## 系统视图
## 上游系统视图

```text
bash/zsh <--- cosh-shell
Expand All @@ -22,6 +24,40 @@ caller ---> cosh-cli ---> cosh-platform ---> cosh-types

安装后的 `cosh` 启动器通常执行 `cosh-shell raw cosh-core`。`cosh-shell` 编译时不依赖工作空间中的其他 crate,运行时则维护一个长时间存活的 cosh-core 子进程。两端都可能独立失败或重启,因此 stdin/stdout 协议需要保持向后兼容。

Gateway 规划固定的上游基线是 `fa0c8369d300d90a6470965dc564e20b09487eb7`。该基线包含上图五个
crate 与 runtime path,但没有 `cosh-gateway` 或 `cosh-gateway-contracts` crate。

## 候选 Gateway 基础

基于该基线的共享候选工作树增加两个 library crate:

```text
cosh-gateway-contracts --> TaskAggregate --> SQLite Task/event/receipt/Outbox transaction
|
+---------------> Capability Broker slice(in-memory,targeted test)

cosh-gateway ----------> RuntimeSupervisor --> private COSH JSONL v1 codec
`-------> official ACP wire-v1 codec/Bridge
+ 固定 installed-adapter profile

未来 CoshCoreBridge --> contract public mapping + supervisor + codec

Gateway daemon/API、CoshCoreBridge、已安装 ACP entrypoint、完整 ACP
domain/governance mapping、Shell Attachment 与 Web presentation 均未实现。
```

Task reducer 与 SQLite store 是 local control-plane 基础。Runtime supervisor 独占一个 direct child
process group、bounded stdout/stderr、escalation/reap 与一次 process terminal observation。它的
cosh-core codec 使用现有 **private COSH control protocol v1**,不是 ACP,也尚未映射为 public
Runtime event。

当前不存在 executable Gateway entry point 或 authenticated Unix/network API。Shell path 没有改变,
`cosh-shell` 仍拥有 native PTY 与 compatibility cosh-core process。候选树准确固定官方 ACP Rust SDK
2.0.0,把组件 baseline 提升到 Rust 1.88,并增加 supervised stable-v1 stdio slice 以及已安装
`codex-acp`/`claude-agent-acp` 的内置 profile。这里没有 package runner 或 network bootstrap
路径。Library 已有支持独立 cancel 的有界 Session Driver,仍缺已安装 entrypoint、production
Permission UI/evidence 与 real-adapter conformance 证据。

## Crate 职责

| Crate | 二进制 | 拥有 | 不应拥有 |
Expand All @@ -31,6 +67,8 @@ caller ---> cosh-cli ---> cosh-platform ---> cosh-types
| `cosh-cli` | `cosh-cli` | Clap 命令、JSON 响应、退出状态 | 平台适配器之外的发行版分支 |
| `cosh-core` | `cosh-core` | 模型服务、工具循环、Hooks、Skills、MCP、Extensions、注册表、会话和压缩 | 终端控制或前台 PTY 交互 |
| `cosh-shell` | `cosh-shell` | PTY 宿主、输入路由、卡片、审批、终端证据、界面、core 进程生命周期 | 模型服务实现或直接抽象操作系统 API |
| `cosh-gateway-contracts`(候选) | 无 | 无副作用的 Task、Runtime、Capability、identity、header 与 error contract,leaf string/digest 有界 | Storage、process ownership、transport、provider、OS execution 或尚未实现的 aggregate admission limit |
| `cosh-gateway`(候选) | 无 | 局部 Task reducer/SQLite store、Runtime supervision/private core codec、ACP v1 codec/Bridge 与固定 installed-adapter profile、Capability integration slice | Shell PTY、已安装 Gateway/ACP entrypoint、把 provider/ACP wire type 当作 domain contract、绕过 Broker 的 OS effect 或未治理的 ACP callback |

## 交互数据流

Expand Down Expand Up @@ -85,4 +123,13 @@ Clap command
- Linux 包路由可使用 `ID_LIKE` 中第一个可识别家族,但 typed 和 JSON 输出仍保留发行版的真实 `ID`。
- 工具自动审批在无法判断时拒绝执行。直接匹配原始命令子串不能充当安全边界。

## Gateway 与 ACP 交付边界

候选 library 尚未组成持久 production Gateway,仍缺 Gateway API/daemon、Task coordinator 与
lease/recovery loop、完整 Capability enforcement、集成 CoshCore Bridge、已安装 ACP Runtime
entrypoint/Session Driver、production Permission Proxy、real-adapter 证据、Shell Attachment 与
Web/channel presentation。[ACP v1 Phase 0-2 规划集](../../../../src/cosh-ng/docs/design/acp-v1-phase-0-2/README_zh.md)
区分固定的上游基线与候选实现证据,并定义剩余模块边界、Warp 对比、交付顺序与验收 Gate。
Phase 0-2 总体状态仍为 **NOT ACCEPTED**。

继续阅读[开发 cosh-ng](getting-started.md)、[IPC 协议](ipc-protocol.md)和[测试](testing.md)。
6 changes: 4 additions & 2 deletions src/cosh-ng/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ crates/cosh-shell/scripts/check-layout.sh

该脚本必须保持通过;新增或迁移代码不能增加新的 violation group。脚本中的 registered debt 只表示迁移债务被 inventory 追踪,不代表最终验收已完成。

Prerequisites: Linux (or macOS for limited functionality), Rust 1.74+. pkg/svc commands need root/sudo. Checkpoint commands need a running ws-ckpt daemon.
Prerequisites: Linux (or macOS for limited functionality), Rust 1.88+. pkg/svc commands need root/sudo. Checkpoint commands need a running ws-ckpt daemon.

## Architecture

5-crate workspace. Dependency direction: `cosh-cli` / `cosh-core` → `cosh-platform` → `cosh-types`; `cosh-shell` is standalone (no internal crate deps).
7-crate workspace. Dependency direction: `cosh-cli` / `cosh-core` → `cosh-platform` → `cosh-types`; `cosh-shell` is standalone (no internal crate deps). `cosh-gateway` depends only on the side-effect-free `cosh-gateway-contracts` leaf among internal crates.

- **cosh-types**: Pure types, zero side effects. Defines `CoshResponse<T>` envelope, `CoshError` (with error codes, recoverable flag, hint), and ws-ckpt IPC protocol types.
- **cosh-platform**: Platform abstraction layer. Distro detection from `/etc/os-release`, package manager routing (dnf/apt/zypper/brew), systemd service adapter, ws-ckpt daemon Unix socket IPC client.
- **cosh-cli**: CLI entry point (binary: `cosh-cli`). 4 command domains: `pkg`, `svc`, `checkpoint`, `audit`. All output is JSON via `CoshResponse<T>`. Uses clap derive for argument parsing.
- **cosh-core**: Unified agent core (binary: `cosh-core`). Headless JSONL backend + LLM provider integration (OpenAI-compat, SysOM/Aliyun). Includes hooks, tools, skills, extensions, and config management. Interactive TUI mode is declared but not yet implemented.
- **cosh-shell**: AI-augmented interactive shell (binary: `cosh-shell`). PTY wrapper over bash/zsh with OSC marker-based command boundary detection, streaming AI analysis (Claude/Qwen adapters), inline card rendering (ratatui), tool approval control protocol.
- **cosh-gateway-contracts**: Side-effect-free Gateway Task, Runtime, Capability, identity, and error contracts. It must not own storage, processes, transports, providers, or OS execution.
- **cosh-gateway**: Gateway control-plane library foundations: Task reduction and storage, Runtime supervision, private core transport, ACP v1 codec/bridge, bounded session driver, fixed installed-adapter profiles, and Capability admission. It does not currently provide a daemon, installed ACP entrypoint, production permission UI/evidence, or real-adapter conformance evidence.

### cosh-shell Code Organization

Expand Down
8 changes: 5 additions & 3 deletions src/cosh-ng/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| Requirement | Version |
|-------------|---------|
| Rust toolchain | stable (managed by `rust-toolchain.toml`) |
| Minimum Rust version | 1.74 |
| Minimum Rust version | 1.88 |
| Components | rustfmt + clippy |
| Supported platforms | Linux (full); macOS (limited functionality) |

Expand All @@ -19,7 +19,7 @@ rustup show # Confirm toolchain is ready
## Build

```bash
# Full build (all 5 crates)
# Full build (all workspace crates)
cargo build --workspace

# Release build
Expand Down Expand Up @@ -72,7 +72,9 @@ cosh-ng/
├── cosh-platform/ # Platform abstraction (distro detection, backend routing)
├── cosh-cli/ # CLI entry
├── cosh-core/ # Agent core
└── cosh-shell/ # Interactive terminal
├── cosh-shell/ # Interactive terminal
├── cosh-gateway-contracts/ # Side-effect-free Gateway contracts
└── cosh-gateway/ # Gateway control-plane library foundations
```

## Dependency Management
Expand Down
8 changes: 5 additions & 3 deletions src/cosh-ng/CONTRIBUTING_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| 要求 | 版本 |
|------|------|
| Rust toolchain | stable(`rust-toolchain.toml` 管理) |
| Rust 最低版本 | 1.74 |
| Rust 最低版本 | 1.88 |
| 组件 | rustfmt + clippy |
| 支持平台 | Linux(完整功能);macOS(功能受限) |

Expand All @@ -19,7 +19,7 @@ rustup show # 确认工具链已就绪
## 构建

```bash
# 完整构建(所有 5 个 crate)
# 完整构建(所有 workspace crate)
cargo build --workspace

# 发布构建
Expand Down Expand Up @@ -69,7 +69,9 @@ cosh-ng/
├── cosh-platform/ # 平台抽象(发行版检测、后端路由)
├── cosh-cli/ # CLI 入口
├── cosh-core/ # Agent 核心
└── cosh-shell/ # 交互终端
├── cosh-shell/ # 交互终端
├── cosh-gateway-contracts/ # 无副作用的 Gateway contract
└── cosh-gateway/ # Gateway control plane library 基础
```

## 依赖管理
Expand Down
Loading
Loading