Task 35 — Формат inter-agent сообщений
Phase: 3
Status: done
Owner: —
Slug: delegation-envelope
Goal
Версионированный JSON delegation envelope: requestId, traceId, idempotencyKey, sender, recipient, intent, typed payload, replyTo, deadline, auth context, requested response schema.
Acceptance criteria
Sub-tasks
src/agent/Mesh/Schema/— создать папку для типов схемsrc/agent/Mesh/Schema/ResponseSchema.cs—ResponseSchemarecord: schema type, example schema, content typesrc/agent/Mesh/Schema/AuthContext.cs—AuthContextrecord: token, claims, delegation depth- Обновить
IntentEnvelope:- добавить
IdempotencyKey: string? - добавить
Recipient: string? - добавить
Auth: AuthContext? - добавить
ResponseSchema: ResponseSchema? - добавить
Version: string= “1.0”
- добавить
- Обновить
IntentTransport.SendToAsync— передавать auth context в headers - Unit tests:
IntentEnvelopeTests.cs— serialization roundtrip, null handling dotnet build— 0 errors (warnings pre-existing)dotnet test— Phase tests pass (223/223)
Scope / Likely files
src/agent/Mesh/Envelope/, src/agent/Mesh/Schema/
Dependencies
- блокирует / опирается на: task_007 — typed-contracts
Risks / Rollback
Эволюция схемы; явные semver + миграции.
Implementation notes
2026-08-13
Добавлено:
src/agent/Mesh/Schema/ — новая папка для типов схем:
ResponseSchema.cs— тип для запрошенной схемы ответа: schema_type (json/text/xml/binary), json_schema, content_type, versionAuthContext.cs— auth context для delegation: auth_type, token, claims, delegation_depth, root_request_id
src/agent/Mesh/IntentEnvelope.cs — расширенный delegation envelope:
- Добавлены новые поля:
IdempotencyKey,Recipient,Auth(AuthContext),ResponseSchema,Version,Deadline - Изменено:
TimeoutMs→Deadline(DateTimeOffset вместо int) - Добавлен factory method
IntentEnvelope.Create<T>()для typed payload - Добавлен backward-compatible constructor (obsolete) для existing code
- Добавлены методы
IsExpired,GetDeadlineOrDefault() - Добавлен
IntentResponse.SchemaMismatch()factory method
src/agent/Mesh/IntentTransport.cs — обновлен SendToAsync:
- Forward auth context в HTTP headers (Authorization, X-Delegation-Depth, X-Root-Request-Id)
- Forward idempotency key в X-Idempotency-Key header
- Timeout вычисляется из Deadline
tests/Phase3Tests/IntentEnvelopeTests.cs — добавлены тесты:
- Envelope_With_AllNewFields_SerializesCorrectly
- Envelope_Create_WithTypedPayload_SerializesCorrectly
- Envelope_Deadline_Expires_Correctly
- Envelope_GetDeadlineOrDefault_ReturnsDeadline
- IntentResponse_SchemaMismatch_Has_SchemaMismatch_Status
Validation:
dotnet build— 0 errors, warnings pre-existing (OpenTelemetry, async test patterns)dotnet test Phase— 223/223 passed
Links
- Backlog: ../backlog.md
- Roadmap (EN): ../../ROADMAP-EN.md
- Roadmap (RU): ../../ROADMAP-RU.md