Skip to content

Capability Interactions

ghbvf edited this page Jun 17, 2026 · 1 revision

能力交互

GoCell 的核心交互是:声明模型先行,跨 Cell 只经 Contract,运行时通过 Assembly/Corebundle 装配,外部资源通过 Adapter 和 CellModule 注入。

总体装配链路

Assembly
  -> Runtime bootstrap/composition
    -> CellModule
      -> CoreCell
        -> Slice
          -> Contract
      -> Adapter

含义:

  • Cell 是垂直能力单元,负责生命周期、健康、ready、slice inventory。
  • Slice 是 Cell 内单职责单元,slice.yaml 是 slice 元数据事实源。
  • Contract 是跨 Cell 边界,声明 owner/kind/lifecycle/endpoint/topic,不应靠直接 Go import 跨 Cell 调用。
  • Assembly 是物理部署单元,负责注册并驱动 Cell 生命周期。
  • CellModule 是 Composition Root 子层,负责把 CoreCell 与 runtime/adapters 绑定。
  • Corebundle 是当前平台能力的生产装配入口。

交互模式

模式 能力序列 一致性等级 当前成熟度
HTTP 同步请求响应 HTTP middleware -> Authn -> Authz/PDP -> Cell handler -> persistence -> metrics/logging L0/L1 4.2/5
事务性事件发布 Service -> TxRunner -> outbox.Writer -> relay -> publisher L2 4.6/5
异步事件消费 Subscriber -> Idempotency Claimer -> Handler -> Ack/Requeue/Reject/DLQ L3 4.1/5
配置广播 configcore publish -> event.config.* -> accesscore/config subscriber -> audit append L2/L3 3.8/5
审计旁路 任意业务事件 -> auditcore subscriber -> hash chain ledger L2 4.0/5
Bootstrap/Shutdown Load config -> build deps -> init assembly -> start router/eventrouter/workers -> readiness -> drain/LIFO teardown 横切 4.4/5
Saga/Workflow Saga definition -> journal -> coordinator -> step run/compensate -> projection/checkpoint L3 2.8/5
设备长延迟闭环 Server enqueue -> device poll -> command report -> ack/timeout/reconcile/cert renewal L4 3.0/5

平台 Cell 交互

accesscore -> auditcore

accesscore 发布 session/user/role 事件,auditcore 订阅并写入 hash chain。代表 Journey 是 J-auditlogintrail。

configcore -> accesscore/auditcore

configcore 发布 config upsert/delete/version/rollback 事件。accesscore.configreceive 订阅配置变更更新本地状态,auditcore 订阅配置事件做审计。

syscore -> 管理面

syscore 通过 HTTP contract 暴露 cell health 查询能力,补上平台运行状态读取面。

运行交互

cmd/corebundle 是运行装配中心:

  1. 从环境变量解析 topology、JWT、metrics、listeners、TLS、Redis/RabbitMQ/Postgres 等依赖。
  2. demo topology 使用 in-process bus;Postgres topology 倾向 fail-closed,例如缺少 AMQP URL 不继续伪装真实运行。
  3. cellmodules 把 corecells 与 adapters 绑定。
  4. runtime bootstrap 接管 readiness、health、HTTP/gRPC、eventrouter、workers、shutdown。

治理交互

治理不是单一机制,而是多层组合:

层 机制
元数据 JSON Schema + governance REF/TOPO/VERIFY/FMT/ADV 等规则
依赖方向 .golangci.yml depguard + archtest typed scan
代码生成 generated verify、codegen drift tests、sealed construction
CI make verify bucket fanout、PR cheap subset、nightly full archtest
运行 corebundle integration、fail-closed env validation、health/readiness

当前交互风险

  1. corecells/go.mod 直接依赖 adapters/postgres,与“corecells 不依赖 adapters”的架构约束冲突。
  2. 全量 archtest 主要在 nightly,PR-time 仍有延迟发现风险。
  3. 多条 Journey 仍含 manual/experimental 项,当前更多证明“元数据不撒谎”,不是完整业务 E2E。
  4. ContractMeta 与 ContractSpec 双定义仍可能造成治理/运行时语义漂移。
  5. runtime/shared deps 和 corebundle env 装配是复杂度中心,需要持续保持字段冻结、sealed construction 和测试覆盖。

Clone this wiki locally