Task 50 — Distributed reflection
Phase: 4
Initiative: 20
Status: done
Owner: —
Slug: distributed-reflection
Goal
Отчёты рефлексии включают производительность peer-агентов, routing-решения, паттерны сбоев и предлагают улучшения: новые skills, routing-правила, peer-связи. Формируют proposals, а не unreviewed prod-изменения.
Acceptance criteria
PeerMetricandFailurePatternmodelsReflectionProposalandReflectionProposalStore— structured proposal persistenceDistributedReflection.CollectPeerMetrics()— health scores, latency, circuit stateDistributedReflection.CollectFailurePatterns()— failure patterns from audit/CB stateDistributedReflection.CollectRoutingPatterns()— intent → peer resolution patternsDistributedReflection.GenerateProposalsAsync()— circuit-open → NewSkill proposals, low-health → TrustUpdate proposalsDistributedReflection.GenerateLLMProposalsAsync()— LLM-assisted proposal generation (configurable)DistributedReflection.GetPendingProposals(),Approve(),Reject()— human-in-the-loopReflectionProposalConfiginMeshConfig- DI registration in
MeshServiceExtensions - Unit tests (ProposalStore CRUD, proposal generation, status transitions)
dotnet build+dotnet testpass
Sub-tasks
PeerMetric,FailurePattern,RoutingPatternmodelsReflectionProposal,ReflectionProposalStore— structured proposals with JSON persistenceReflectionProposalConfiginMeshConfig(AppConfig.cs)DistributedReflection— injectRouterHealthTracker,MeshAuditServiceDistributedReflection.CollectPeerMetrics()— peer health, latency, circuit stateDistributedReflection.CollectFailurePatterns()— failure patterns from CB + auditDistributedReflection.CollectRoutingPatterns()— intent → peer resolution patternsDistributedReflection.GenerateProposalsAsync()— circuit-open → NewSkill, low-health → TrustUpdateDistributedReflection.GenerateLLMProposalsAsync()— LLM-assisted proposalsDistributedReflection.GetPendingProposals(),Approve(),Reject()— human-in-the-loop API- DI registration in
MeshServiceCollectionExtensions - Unit tests for
ReflectionProposalStore(CRUD, status transitions) - Unit tests for
DistributedReflection(metric collection, proposal generation) dotnet build src/agent/Hercules.csproj— 0 errorsdotnet test --filter "FullyQualifiedName~DistributedReflection"— all pass
Dependencies
- блокирует / опирается на: task_017 — safe-self-improvement
- блокирует / опирается на: task_041 — inter-agent-audit
Validation
dotnet build src/agent/Hercules.csproj → 0 errors
dotnet test --filter "FullyQualifiedName~DistributedReflection" → 14/14 pass
dotnet test --filter "FullyQualifiedName~ReflectionProposalStore" → 12/12 pass
dotnet test tests/Hercules.Agent.Tests/ → 1338/1348 pass
(10 pre-existing failures in OtelServiceTests,
NumericValidatorTests, BudgetGuardTests,
WasmToolTests, HerculesBusTests — unrelated)
Implementation notes
Bug fix: CollectFailurePatterns() returned empty when auditService was null — circuit breaker check was nested inside the audit null-guard. Fixed by moving CB check outside the guard so it always runs regardless of audit availability.
Risks / Rollback
Перегрузка шумными proposals; rate-limit + ранжирование + человек-в-контуре.
Links
- Backlog: ../backlog.md
- Roadmap (EN): ../../ROADMAP-EN.md
- Roadmap (RU): ../../ROADMAP-RU.md