Skip to content

[EPIC-INT-01A] 阶段 1:网关协议拓宽与 Runtime 桥接 (Backend Only) #360

@pionxe

Description

@pionxe

🎯 目标 (Goal)

让 Gateway 正式接收并分发 Runtime 相关 JSON-RPC 方法,neocode gateway 启动时注入真实 RuntimePort 实例,为后续客户端接入铺平道路。

🔍 涉及范围 (Scope)

  • 修改网关 JSON-RPC 方法归一化、Frame 分发注册、ACL 白名单、网关启动装配。
  • 新增 Runtime → Gateway 的桥接适配器。
  • 注意:本阶段不涉及 TUI 迁移,不改变默认 neocode 启动 TUI 的主链路。

📁 待修改文件 (Proposed Files)

  • internal/gateway/protocol/jsonrpc.go
  • internal/gateway/bootstrap.go
  • internal/gateway/security.go
  • internal/gateway/contracts.go
  • internal/cli/gateway_commands.go
  • internal/cli/runtime_port_bridge.go (新增)
  • 以及对应的 _test.go 测试文件

✅ 实现清单 (To-Do List)

  • 扩展 JSON-RPC 方法常量与归一化分支,覆盖:gateway.run, gateway.cancel, gateway.compact, gateway.listSessions, gateway.loadSession, gateway.resolvePermission
  • bootstrap.go 中注册上述 action 的 handler(允许返回结构化业务错误,但绝不能返回 method not found)。
  • 扩展 Strict ACL 白名单与测试,确保新方法按 Source 规则放行。
  • 新增 RuntimePort 桥接适配器,把现有 runtime 实例包装给 gateway 使用。
  • 改造 neocode gateway 命令:通过装配拿到 runtime 实例并传入 Serve(ctx, runtimePort)
  • 架构红线检查:保持网关“协议路由中枢”定位,绝对不在网关层写业务逻辑。

🎉 验收标准 (Acceptance Criteria)

  • neocode gateway 启动时 runtimePort 成功注入非空实例(可通过日志断言)。
  • 发送上述新增方法的 JSON-RPC 请求,不再返回 method not found
  • 未知方法依然被网关严格拒绝。
  • 全量测试 go test ./... 与并发测试 -race 均通过。

🔗 依赖关系 (Dependencies)

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