Skip to content

Roadmap: harden the existing execution model before expanding scope #71

Description

@jamiesun

Roadmap: harden the existing execution model before expanding scope

背景

sshx 当前已经具备较完整的 Agent 远程执行能力,包括:

  • 单主机 / 多主机远程执行
  • 稳定的 JSON / JSONL 执行契约
  • dry-run
  • 结构化 audit
  • host / credential 管理
  • SFTP / transfer
  • guarded apply
  • guarded sql
  • host inspection / plugin
  • stdio MCP
  • human-only interactive login
  • source address binding
  • release signing / SBOM / provenance

当前阶段不应继续横向增加大量新功能。

接下来的重点应该是:

提高执行确定性、安全性、可验证性、稳定性和长期维护能力。

目标是让 sshx 从“功能完整的 Agent SSH CLI”进一步收敛为:

A predictable, auditable and safe remote execution primitive for agents.


核心原则

新增能力应优先满足以下条件之一:

  1. 减少 Agent 判断次数
  2. 减少执行结果的不确定性
  3. 提高执行前后的可验证性
  4. 提高错误分类和恢复能力
  5. 提高审计证据质量
  6. 提高跨平台一致性
  7. 降低长期维护成本

避免仅仅因为某个远端工具存在,就增加新的 sshx verb。


P0 — Execution Plan Integrity

目前 --dry-run 可以展示执行计划,但计划与实际执行之间还缺少明确的完整性绑定。

目标:

resolve
  ↓
plan
  ↓
review / agent decision
  ↓
execute exactly that plan
  ↓
audit

增加稳定的 execution plan fingerprint。

例如:

{
  "schema": "sshx.plan.v1",
  "target": "db-01",
  "action": "apply",
  "risk": "mutation",
  "plan_hash": "sha256:..."
}

执行时允许:

sshx apply ... --expect-plan=sha256:...

如果执行环境或影响执行语义的输入发生变化,应拒绝执行。

Tasks

  • 定义 sshx.plan.v1
  • 明确哪些字段参与 plan hash
  • 排除时间戳、随机 ID 等非确定字段
  • --dry-run --json 输出 plan_hash
  • 支持 --expect-plan=<hash>
  • plan mismatch 返回稳定 error_kind
  • audit 记录 plan_hash
  • MCP 暴露相同语义
  • 增加 deterministic serialization 测试
  • 增加 TOCTOU / changed-input 测试

Acceptance

相同输入产生相同 plan hash。

任何会改变实际执行目标、权限或副作用的关键输入发生变化后,旧 plan hash 不得继续执行。


P0 — Unified Risk Model

目前不同执行路径已经存在安全限制,但风险语义还可以进一步统一。

建议引入统一风险等级:

read
mutation
privileged
destructive

风险不是单纯根据命令字符串判断,而应该来自:

action
+ target
+ privilege
+ operation type
+ known side effects

例如:

Operation Risk
uname -a read
download file read
upload new file mutation
apply mutation
sudo read privileged
sudo mutation privileged
destructive SQL destructive
disk / filesystem destructive command destructive

Tasks

  • 定义统一 risk enum
  • run 使用统一风险分类
  • apply 使用统一风险分类
  • sql 使用统一风险分类
  • sftp / transfer 使用统一风险分类
  • dry-run 输出 risk
  • JSON result 输出 risk
  • audit 输出 risk
  • MCP 保持一致
  • --force / bypass 与 risk 模型统一
  • 补充风险分类测试矩阵

Acceptance

Agent 不需要根据不同 verb 单独推断风险。

所有产生副作用的执行入口使用相同风险语义。


P0 — Preconditions & Postconditions

对于 mutation,sshx 应尽可能提供执行前后的事实,而不是只报告命令成功。

例如 apply:

before_sha256
expected_sha256
after_sha256
backup_path
changed

对于其他操作也可以提供适当的 precondition / postcondition。

目标:

Execution success != desired effect confirmed.

Tasks

  • 抽象通用 precondition result
  • 抽象通用 postcondition result
  • apply 完善 before / after fingerprint
  • SQL mutation 返回明确 affected-state evidence
  • SFTP mutation 返回目标文件 metadata
  • execution result 中增加 changed
  • 区分 executed 与 verified
  • audit 保留 verification metadata
  • verification failure 使用独立 error_kind

P1 — Execution Fingerprint

除了 plan hash,实际执行结果也应产生 fingerprint。

例如:

{
  "plan_hash": "sha256:...",
  "execution_id": "...",
  "execution_fingerprint": "sha256:...",
  "started_at": "...",
  "finished_at": "...",
  "verified": true
}

用于关联:

plan
execution
result
audit

Tasks

  • 定义 execution identity
  • CLI / MCP / audit 使用同一个 execution ID
  • multi-host execution 为 parent / target 分配稳定关联 ID
  • audit query 可按 execution ID 查询
  • export 保留关联关系

P1 — Cancellation & Deadline Semantics

多主机 fan-out 已经存在,下一步重点应放在失败和取消语义。

Tasks

  • 明确 per-host timeout
  • 明确 global timeout
  • context cancellation 全链路传播
  • SSH connect 可取消
  • command execution 可取消
  • SFTP 操作可取消
  • multi-host fan-out cancellation
  • MCP cancellation 映射
  • cancellation 返回稳定 error_kind
  • audit 区分 timeout / cancelled / failed

P1 — Fan-out Failure Policy

增加少量、明确的 fan-out 控制能力:

--fail-fast
--max-failures=N

不要演化成 workflow engine。

Tasks

  • --fail-fast
  • --max-failures
  • stopped / skipped target 进入结构化结果
  • 保证 JSONL completion semantics
  • audit 记录停止原因
  • MCP progress 与最终结果一致

P1 — Error Taxonomy Review

系统能力已经增长较多,需要重新审视 error_kind。

目标:

Agent 可以根据 error kind 明确决定:

retry
fix config
request credential
request approval
abort
inspect target

Tasks

  • 审计当前所有 error paths
  • 清理依赖字符串匹配的错误
  • 避免相同错误出现多个分类
  • 明确 retryable / non-retryable
  • 考虑增加 retryable 字段
  • 为主要 error kind 建 contract tests
  • 文档提供 Agent decision table

P1 — Audit Evidence Quality

当前 audit 已支持 query / export。

下一阶段重点不是增加日志数量,而是提升证据质量。

建议保证能够回答:

Who/what initiated it?
Which host?
Which resolved address?
Which credential role?
Which plan?
Which risk?
Was a bypass used?
What was executed?
Was state changed?
Was the result verified?
What failed?

Tasks

  • audit schema review
  • 增加 plan hash
  • 增加 execution ID
  • 增加 risk
  • 增加 changed / verified
  • 增加 cancellation state
  • 检查所有 secret redaction paths
  • audit export contract test
  • corrupt / partial JSONL 容错测试

P1 — Test Coverage & Reliability

目前继续扩功能的收益已经低于补测试的收益。

优先覆盖:

execution contract
safety
credentials
audit
cross-platform
failure paths

Tasks

  • 提升核心 package coverage
  • 为 frozen JSON schema 增加 golden tests
  • 增加 CLI compiled-binary E2E
  • 增加 SSH authentication failure matrix
  • 增加 host-key failure matrix
  • 增加 timeout / cancellation tests
  • 增加 partial network failure tests
  • 增加 corrupted settings tests
  • 增加 corrupted vault tests
  • 增加 audit write failure tests
  • 增加 interrupted apply tests
  • 增加 multi-host partial failure tests

不追求单纯的 coverage 数字。

优先保证关键执行路径和 failure path 被覆盖。


P2 — Internal Architecture Cleanup

随着功能增长,应继续降低 package 间耦合。

重点关注:

resolve
plan
policy
execute
verify
audit

这些阶段是否存在隐式交叉。

Tasks

  • review internal/app responsibilities
  • 减少 CLI parsing 与 execution logic 耦合
  • 抽离通用 execution lifecycle
  • 统一 run / sql / apply 的结果模型
  • 避免不同 verb 独立实现 audit semantics
  • 避免不同 verb 独立实现 timeout semantics
  • 避免不同 verb 独立实现 risk semantics
  • review public/internal package boundaries

原则:

不为“架构漂亮”重构,只重构已经产生重复语义或行为漂移的部分。


P2 — Cross-platform Parity

继续明确 Linux / macOS / Windows 的能力矩阵。

Tasks

  • 列出 feature parity matrix
  • 明确 unsupported 是设计限制还是待实现
  • Windows permission semantics tests
  • Windows path semantics tests
  • Windows keyring tests
  • plugin / skill symlink behavior review
  • 不支持的能力必须 fail explicitly

禁止 silent degradation。


Non-goals

本阶段明确不做:

  • daemon
  • resident remote agent
  • HTTP/SSE MCP server
  • Web UI
  • scheduler
  • cron
  • workflow / playbook
  • desired-state reconciliation
  • connection pool
  • persistent task queue
  • fleet heartbeat
  • SOCKS proxy
  • generic tunnel manager
  • Kubernetes management platform
  • Docker management platform
  • Redis / Kafka / MongoDB 等“一工具一个 verb”的横向扩张

如果某项能力不能明显减少 Agent 判断成本或提高执行可信度,默认不进入 sshx core。


Suggested release sequence

v0.14

Execution integrity:

  • plan hash
  • --expect-plan
  • unified risk model
  • preconditions / postconditions

v0.15

Execution lifecycle:

  • execution fingerprint
  • cancellation
  • timeout semantics
  • fan-out failure policy

v0.16

Audit & contract hardening:

  • error taxonomy
  • audit evidence
  • frozen schema tests
  • MCP parity

v0.17

Reliability:

  • failure-path E2E
  • cross-platform parity
  • internal lifecycle cleanup
  • security review

之后再评估进入 v1.0。


Definition of Done

这一阶段完成后,sshx 应满足:

  • Agent 可以在执行前获得稳定、可哈希的 plan
  • Agent 可以确保实际执行与已审阅 plan 一致
  • 所有核心操作共享统一 risk semantics
  • mutation 可以明确报告是否发生状态变化
  • 关键 mutation 可以验证执行后状态
  • timeout / cancellation 行为一致
  • multi-host partial failure 可机器判断
  • error taxonomy 足以指导 Agent 下一步动作
  • audit 可以完整串联 plan → execution → result
  • frozen contract 有稳定测试保护
  • 关键 failure paths 有 E2E 覆盖
  • 不引入 daemon / workflow / control-plane complexity

最终目标不是让 sshx 支持更多事情。

最终目标是让 Agent 更放心地执行已经支持的事情。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions