refactor: one durable pending-action store — the MCP park migrates up, the bespoke mechanism retires (ADR-0047 §5.4 follow-up) - #511
Merged
Conversation
…, the bespoke mechanism retires guardrailsvc.PendingActionStore is the generic pending-action model brought up to the MCP write park's own guarantees (restart survival, retention-window sweep, at-most-once apply-on-approve, an opaque Payload for restart-safe re-dispatch). RequestGuardedAction now parks through it; mcpsvc's gated-write lifecycle (gateWrite/ResolveMCPWrite/ CancelMCPWrite/PendingMCPWrites/ResolvedMCPWrites/check_write_status) migrates onto the same store, and MCPWriteRecord plus its bespoke settings-key persistence are deleted. A settings file carrying the old mcp-pending-writes key upgrades automatically (MigrateLegacyPendingWrites, wired in main.go ahead of GuardrailService's own construction) so a user's parked write survives the upgrade. Every existing MCP-write/guardrail Go test and e2e spec passes unmodified against the new seam. 🤖 Generated with Claude Code Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012im1JxQQV2ahnXzZDdVmZq
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.
Summary
ADR-0047 §5.4's homed follow-up:
guardrailsvc.PendingActionStoreisthe generic pending-action model brought up to
MCPWriteRecord's ownguarantees (restart survival, retention-window sweep, at-most-once
apply-on-approve, an opaque
Payloadfor restart-safe re-dispatch).guardrailsvc.RequestGuardedActionnow parks through the sharedstore instead of an in-memory-only map.
mcpsvc's gated-write lifecycle (gateWrite/ResolveMCPWrite/CancelMCPWrite/PendingMCPWrites/ResolvedMCPWrites/check_write_status) migrates onto the same store.MCPWriteRecord, its bespoke settings key,loadWrites, andpersistWritesLockedare deleted.mcp-pending-writeskey upgradesautomatically (
mcpsvc.MigrateLegacyPendingWrites, wired inmain.goahead ofguardrailsvc.NewGuardrailService's ownconstruction, so the shared store never loads a stale
pre-migration view) — a user's parked write survives the upgrade.
(
mcpsvc's ownmcpWriteExpiryvar), not a single global, so twodifferent consumers of the store can each state their own window.
Test plan
(including the two persist-failure tests, which turned out not
to need migration — the constructor-time default store is real
and backed by the same settings.Store already passed in).
guardrailsvctests pin the same persist-failure propertydirectly against the shared store (kept alongside, not instead
of, the still-passing mcpsvc-level ones).
tests for
PendingActionStoreitself,-raceclean.the record lists, resolves, and re-dispatches correctly, and the
old key clears.
depguard-new, comment-hygiene, file-loc-limit,
go test ./... -race(one pre-existing, already-quarantined, unrelatedclipboard flake — confirmed also present on unmodified
origin/main on this machine).
guardrail.spec.ts,guardrail-authoring.spec.ts,guardrail-review.spec.ts,mcp-write-approval.spec.ts,mcp-write-cancel.spec.ts,mcp-write-staleness.spec.ts,atlas-mcp-write-approval.spec.ts,approval-prompt.spec.ts(20/20).🤖 Generated with Claude Code
https://claude.ai/code/session_012im1JxQQV2ahnXzZDdVmZq