Self-repair Phase 5: failure cluster store with PVC backing#374
Merged
rockfordlhotka merged 5 commits intomainfrom May 9, 2026
Merged
Self-repair Phase 5: failure cluster store with PVC backing#374rockfordlhotka merged 5 commits intomainfrom
rockfordlhotka merged 5 commits intomainfrom
Conversation
In-process ConcurrentDictionary keyed by (server, tool, errorClass) backed by an append-only JSONL log plus a periodic JSON snapshot under /data/agent/telemetry. McpRecoveryExecutor records every post-recovery failure (chain-exhausted, Stage A retry-fail, Stage B retry-fail, Stage B fill-fail, and no-provider/no-StageB) with the originating session id; auto-recovered calls do not record. GetEscalatableAsync surfaces clusters satisfying Count >= 3 && SessionIds.Count >= 2 && LastSeen within 24h, ready for Phase 4 (#348) ticket creation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both early-exit branches in McpRecoveryExecutor previously returned without recording — non-schema errors (auth/network/server-side) and "X is required but X is in args" cases were invisible to the failure store. Now both record under errorClass=unknown so DreamService can spot recurring patterns the recovery layer can't classify. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Other hosted services may dispose their CancellationTokenSources during shutdown; passing the host's stopping token to SemaphoreSlim.WaitAsync after that point throws ObjectDisposedException. Shutdown flush is critical work and shouldn't be cancellable anyway — the timer callback already uses CancellationToken.None. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #349
Summary
ConcurrentDictionary<ClusterKey, FailureCluster>keyed by(server, tool, errorClass)for hot reads/writes.failure-clusters.jsonlplus a periodic snapshot atfailure-clusters.snapshot.json, both under/data/agent/telemetry. On startup, snapshot is loaded then JSONL events withat >= snapshotWrittenAtare replayed; on flush, the snapshot is written atomically and the JSONL is truncated.McpRecoveryExecutorrecords every post-recovery failure (chain-exhausted, Stage A retry-fail, Stage B retry-fail, Stage B fill-fail, and the no-provider/no-StageB short-circuit) with the originating session id fromToolInvokeRequest.SessionId. Auto-recovered calls do NOT record — those remain inRecoveryDiagnosticsmetrics only.GetEscalatableAsyncfilters toCount >= 3 && SessionIds.Count >= 2 && (now - LastSeen) < 24hso Phase 4 (Self-repair Phase 4: closed-loop repair tickets in DreamService #348) can iterate ready-to-ticket clusters without re-implementing the threshold.FailureClusterOptions.Test plan
FailureClusterTests—ClusterKeylowercases server/tool, rejects blanks, equality is canonical.FailureErrorClassifierTests— extracts field names from each Phase-1 pattern, falls back tounknown.FileFailureClusterStoreTests(12 cases) — escalation thresholds (count, session count, recency window), bounds enforcement, snapshot+JSONL persistence round-trip, JSONL truncation, corrupt-line recovery, ordering byLastSeendesc.McpRecoveryExecutorFailureClusterTests(9 cases) — auto-recovered does NOT record; each exhausted-recovery branch DOES record with the righterrorClassand forwardedsessionId; nullIFailureClusterStorekeeps Phase-1 contract; throwing store does not break recovery.Acceptance criteria (from #349)
GetEscalatable_ThreeFailuresAcrossTwoSessions_InWindow_ReturnsClusterPersistence_SnapshotAndJsonl_RestoreClusterStateFlush_TruncatesJsonlAutoRecovered_StageA_DoesNotRecordOut of scope
source=canary— Phase 6.🤖 Generated with Claude Code