Task 49 — Human-in-the-loop эскалация
Phase: 4
Initiative: 24
Status: done
Owner: —
Slug: human-escalation
Goal
Mesh эскалирует неоднозначные, low-confidence, policy-sensitive, разрушительные или budget-exceeding операции с кратким action plan и контекстом для подтверждения человеком. Гейты выполнения обеспечиваются кодом, а не только промптами.
Acceptance criteria
EscalationConfigadded toMeshConfigIEscalationService+EscalationServiceimplementationEscalationContext+EscalationResultmodels with escalation type, severity, action plan- Escalation triggers in
IntentRouter(trust admission denial → escalate) - Escalation triggers in
AgentCore(low-confidence responses, guardrail failures, verification blocks) - Escalation priority levels: Low / Medium / High / Critical
- Batch-approve API endpoint (
POST /api/escalations/batch-approve) - Escalation status API endpoints (list, get, approve, deny)
EscalationPanel.astrocomponent in hercules-web with batch approve- DI registration in
MeshServiceExtensions - Unit tests for
EscalationService dotnet build+dotnet testpass
Sub-tasks
- Add
EscalationConfigtoAppConfig.cs(nested inMeshConfig) - Create
EscalationContext.csandEscalationResult.csmodels inMesh/Escalation/ - Create
IEscalationService.csandEscalationService.cs - Add
escalationstable toSqliteSessionStoreschema + persistence methods - Wire
EscalationServiceinMeshServiceExtensionsDI - Add
IEscalationServicefield + escalation call inIntentRouter(trust denial → escalate) - Add escalation triggers in
AgentCore(guardrail failures, low-confidence, verification blocks) - Create
EscalationController.cswith list/get/approve/deny + batch-approve endpoints - Wire
EscalationControllerinHercules.WebApi/Program.cs - Create
EscalationPanel.astroin hercules-web with batch approve UI - Add
EscalationPanelto mesh page (memmesh.astro) - Write unit tests for
EscalationService(6 tests) dotnet build src/agent/Hercules.csproj— 0 errorsdotnet test --filter "FullyQualifiedName~Escalation"— 6/6 pass
Validation
dotnet build src/agent/Hercules.csproj → 0 errors (19 pre-existing warnings)
dotnet test --filter "FullyQualifiedName~Escalation" → 6/6 pass
dotnet test tests/Hercules.Agent.Tests/ → 1314/1322 pass
(8 pre-existing failures:
OtelServiceTests ×5, NumericValidatorTests ×2,
BudgetGuardTests ×1)
Implementation notes
EscalationConfignested inMeshConfig.Escalation(default: disabled for backward-compatibility)EscalationServicemirrorsApprovalServicepattern: in-memoryConcurrentDictionarycache + SQLite persistence- Escalation types: LowConfidence, BudgetExceeded, PolicyDenial, AmbiguousIntent, DestructiveOperation, DelegationTrustLow, HighCostOperation
- Three escalation triggers: (1) guardrail hard-cap pre-check, (2) verification pipeline blocks, (3) low-confidence LLM responses
- Trust admission denials in
IntentRouterescalate delegation attempts to mesh operators - Critical escalations log at Warning level (future: pager integration)
Scope / Likely files
src/agent/Mesh/Escalation/, src/hercules-web/src/components/EscalationPanel.astro
Dependencies
- блокирует / опирается на: task_010 — approval-gates
- блокирует / опирается на: task_040 — trust-admission
Risks / Rollback
Operator fatigue; агрегация эскалаций + приоритезация + удобный batch-approve.
Links
- Backlog: ../backlog.md
- Roadmap (EN): ../../ROADMAP-EN.md
- Roadmap (RU): ../../ROADMAP-RU.md