Skip to the content.

Task 87 — Misc hardening: DelegationBoundary TTL, ResilientTransport trim, CORS, backup passphrase, SLO real metrics

Phase: 5 Initiative: 46 Status: done Owner: — Slug: misc-hardening

Goal

Набор medium-severity fixes не вошедших в отдельные tasks:

  1. DelegationBoundaryService TTL (M): _chainContexts (Mesh/Budget/DelegationBoundaryService.cs:20) — ConcurrentDictionary без eviction; растёт безгранично per root request ID.
  2. ResilientTransport peer semaphore trim (M): _peerSemaphores (ResilientTransport.cs:26) — per-peer semaphores никогда не удаляются даже после peer gone.
  3. CORS default (M): WebApi/Program.cs:463-465 — AllowAnyOrigin() по default.
  4. Backup passphrase default (M): BackupConfig.Passphrase = "" — backups unencrypted by default.
  5. SLO real metrics (M): SloService.cs:296 — response-time P95 simulated, not measured. :371 — recovery time estimated, not measured.
  6. AuditService filters (M): AuditService.cs:243-250 — QueryAsync ignores actor/action/sessionId/toolName/result/from/to filters.
  7. NetworkMonitor fallback (M): NetworkMonitor.cs:99-107 — ResolveUrl returns null если NetworkPollUrl empty → always offline.
  8. FleetPolicy not enforced (M): FleetPolicy.MaxConcurrentTasksPerAgent/MaxFanOutWidth declarative only.
  9. BackupService.MaxSizeMb unused (M): BackupConfig.MaxSizeMb=500 declared but never checked.
  10. EscalationService fire-and-forget (M): IntentRouter.cs:125 — _ = _escalationService.EscalateAsync(...) — exceptions swallowed.
  11. SharedMemorySync silent catch (M): SharedMemorySync.cs:356-360 — catch { /* Skip peer on error */ } — no logging.

Acceptance criteria

Sub-tasks

Scope / Likely files

src/agent/Mesh/Budget/DelegationBoundaryService.cs, src/agent/Mesh/Resilience/ResilientTransport.cs, src/agent/Hercules.WebApi/Program.cs, src/agent/Backup/BackupService.cs, src/agent/Backup/Models.cs, src/agent/Slo/SloService.cs, src/agent/Audit/AuditService.cs, src/agent/Offline/NetworkMonitor.cs, src/agent/Mesh/Router/FanOutOrchestrator.cs, src/agent/Mesh/IntentRouter.cs, src/agent/Mesh/SharedMemorySync.cs, src/agent/appsettings.json

Implementation notes

Round 1 (this tick) — completed

Hardening-фиксы из перечисленных 12 sub-tasks, реализованные в этом тике (6 из 12):

Round 1 (this tick) — tests

tests/Hercules.Agent.Tests/Phase5Tests/MiscHardeningTests.cs — 9 unit-тестов:

Validation

Remaining work (4 of 12 sub-tasks)

These will be tackled in subsequent ticks.

Round 3 (this tick) — completed

Final four sub-tasks completed; task_087 is now fully done (12/12).

ResilientTransport peer-semaphore trim (sub-task #2):

SLO P95 real measurement (sub-task #6):

SLO recovery-time real measurement (sub-task #7):

FleetPolicy enforcement in FanOutOrchestrator (sub-task #10):

Round 3 (this tick) — tests

Total new tests for Round 3: 31. All pass.

Round 3 (this tick) — validation

Dependencies

Round 2 (this tick) — completed

Audit filter implementation (sub-task #33):

Round 2 (this tick) — tests

tests/Hercules.Agent.Tests/Phase5Tests/AuditServiceFilterTests.cs — 11 unit-tests against a real SqliteSessionStore:

Round 2 (this tick) — validation

Dependencies

Risks / Rollback

Individual fixes independent; rollback per-fix via git revert. CORS tightening может сломать existing web UI deployments — document migration.