# Changelog
All notable changes to `cmdc_gateway` are documented in this file.
## [0.3.0] - 2026-05-16
**Minor release** — A2A Protocol Task endpoints + Gateway-level Guardrails
+ alignment with cmdc 0.3.0 core. No breaking changes against v0.2.x.
### Added — A2A Protocol Task Endpoints (Phase 11C / ADP Ch.15)
Implement A2A (Agent-to-Agent) JSON-RPC 2.0 Task protocol, making CMDC
Gateway a first-class A2A-compliant Agent runtime callable from any
ADK / LangGraph / CrewAI / external Agent that speaks A2A.
- `POST /v1/a2a/tasks/send` — synchronous JSON-RPC Task invocation;
idempotent on `taskId`; returns final Task result map; goes through
Auth → RateLimit → Guardrails Plug chain
- `POST /v1/a2a/tasks/sendSubscribe` — SSE streaming variant emitting
`TaskStatusUpdateEvent` / `TaskArtifactUpdateEvent` with heartbeats
- `CMDCGateway.A2A` — new module: JSON-RPC handler + Task lifecycle
(handle_send / start_subscribe); maps A2A Task semantics onto existing
Session API
- `CMDCGateway.SSEHandler.stream_a2a/3` — A2A-flavored SSE stream that
translates CMDC events to A2A Task lifecycle event schema
### Added — Gateway Guardrails (Phase 11C / ADP Ch.18)
- `CMDCGateway.Plugs.Guardrails` — HTTP-layer input/output filter:
denylist keywords, max prompt size, sensitive content rejection;
mounted in the Router Plug chain after Auth + RateLimit, before
dispatch; pluggable via application config
### Added — A2A Client SDK Examples
Three runnable client samples proving external A2A agents can call this
gateway end-to-end (discover → send → subscribe):
- `examples/a2a/curl_examples.sh` — raw HTTP / SSE walkthrough
- `examples/a2a/elixir_send.exs` — Mix-runnable Elixir Req client
- `examples/a2a/node_send.mjs` — Node.js fetch-based client
- `examples/a2a/README.md` — quickstart with environment setup
### Added — Performance Baselines
- `benchmark/event_translator.exs` — Benchee suite for
`CMDC.Event.t()` → A2A `TaskStatusUpdateEvent` translation throughput
- `:benchee ~> 1.3` added as `:dev / :test` dependency
### Changed — Dependency Upgrade
- `{:cmdc, "~> 0.3"}` — pick up all 13 RFC items from cmdc 0.3.0 core
(most notably: `:tool_execution_metrics` event, `:after_turn` Plugin
hook, batch `attach_tools/2`, error-tuple public API #B21)
### Quality
- `mix credo --strict` — **0 issues** (clean)
- All A2A endpoints covered by `test/cmdc_gateway/a2a_test.exs`
- Existing 107 tests + new A2A coverage all green
## [0.2.0] - 2026-04-24
### Added — A2A Inter-Agent Communication(ADP Ch15)
- `CMDCGateway.AgentCard` — 生成 A2A 兼容的 Agent Card JSON(capabilities + endpoints)
- `GET /.well-known/agent.json` — 免认证暴露 Agent Card,供其他 A2A Agent 发现
### Added — Guardrails & Safety Control Plane(ADP Ch18 + CMDC v0.2 RFC)
- `POST /v1/sessions/:id/switch_model` — 运行时切模型(RFC C8,async 202)
- `POST /v1/sessions/:id/attach_tool` — 运行时加载工具(RFC C9)
- `DELETE /v1/sessions/:id/tools/:name` — 运行时卸载工具(RFC C9)
- `POST /v1/sessions/:id/steer` — 中段注入指令(Phase 10A)
- `POST /v1/sessions/:id/abort` — 结构化 abort,支持 reason/kill_tools(RFC B6,async 202)
- `GET /v1/sessions/:id/status` — 扩展 session status(pending + queue_sizes,RFC C11)
- `POST /v1/sessions` 新增 userData + promptMode 透传(RFC A1 / Phase 10B)
### Fixed — Meter 自动订阅修复(P0)
- `Meter.init/1` 启动时 `EventBus.subscribe_all/0` 全局订阅
- 自动 `record_token_usage/2` on `{:agent_end, _, %CMDC.TokenUsage{}}` 事件
(支持 cached/reasoning/cost_usd 细粒度字段)
- 移除对 `{:prompt_received}` 的订阅,避免与 Router 手动 `record_prompt/1` 重复计数
### Changed — EventTranslator 白名单扩容
- 新增 7 种事件翻译:`model_switched`、`tool_attached`、`tool_detached`、
`tool_call_unknown`、`memory_flushed`、`plugin_event`、`steering`
### Changed — 依赖与质量
- `{:cmdc, "~> 0.2"}` 依赖升级
- 新增 `excoveralls` 开发依赖
- Router 的 `CMDC.steer/2` 返回值修正(移除永不匹配的 `:ok` 子句)
- `switch_model`/`abort` 改为 202 Accepted + `async: true`(cast 语义)
- 代码质量 lift:`mix credo --strict` 零 issue(修 `with/else` 单子句 + `try/rescue` 显式 +
cyclomatic complexity + alias 字母序)
### Stats
- 107 个单元 + 集成测试,全部通过(其中 13 个 v0.2 新端点测试)
- `mix compile --warnings-as-errors` 通过
- `mix credo --strict` 0 issue
## [0.1.0] - 2026-04-08
### Added
- `CMDCGateway.Router` — Plug/Cowboy HTTP 路由,13 个 REST 端点
- `CMDCGateway.SessionStore` — ETS Session 注册表,含 tenant_id/api_key 多租户字段
- `CMDCGateway.RateLimiter` — per-api-key 令牌桶限流
- `CMDCGateway.Plugs.Auth` — API Key 认证中间件(X-API-Key / Bearer Token)
- `CMDCGateway.Plugs.RateLimitPlug` — 限流 Plug,返回标准 429 + Retry-After
- `CMDCGateway.Meter` — per-api-key 用量计量(prompt 次数 + token 统计)
- `CMDCGateway.EventTranslator` — 内部 CMDC 事件 → 对外 JSON schema(15 种事件)
- `CMDCGateway.SSEHandler` — Server-Sent Events 流式推送 + 30 秒心跳
- `CMDCGateway.WSHandler` — Cowboy WebSocket 双向通信(事件推送 + 控制消息)
- `CMDCGateway.CallbackTool` — HTTP 回调工具动态注册与代理执行
- `GET /healthz` 健康检查端点(无需认证)
- 84 个单元测试 + 集成测试,全部通过