fix(p2p): replicate content deletion - #69
Merged
Merged
Conversation
Signed-off-by: trvon <git@trevon.dev>
There was a problem hiding this comment.
🟡 Changes recommended
The new integration test installs a ServiceManager observer that captures stack references but isn’t reliably cleared on failure paths, risking use-after-scope and teardown hangs.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR closes a P2P deletion-integrity gap by ensuring production document deletion replicates both the document/<hash> tombstone and the independently retrievable content-blob/<hash> tombstone, with durable/atomic staging and serialized publication/draining to remain crash- and restart-safe.
Changes:
- Add atomic/bounded batch staging for erase intents (
stageErases) so multi-key deletions reserve outbox capacity before any local mutation. - Update daemon deletion flow to stage/publish both blob+document tombstones (or document-only when
--keep-refsis used), with idempotent behavior based on committed tombstone state and serialization against background draining. - Add/extend unit + integration tests and register an integration gate covering deletion integrity.
File summaries
| File | Description |
|---|---|
| tests/unit/memory_sync/memory_sync_catch2_test.cpp | Adds a unit test asserting atomic, bounded capacity reservation for batched erase staging. |
| tests/unit/daemon/daemon_metrics_status_test.cpp | Extends delete handler test to expect both content-blob and document tombstones and updates stub content existence behavior. |
| tests/integration/daemon/meson.build | Registers a new integration test gate for production deletion integrity. |
| tests/integration/daemon/memory_sync_service_integration_test.cpp | Adds an end-to-end integration test exercising real IPC delete flow, serialization, idempotency, --keep-refs, and interrupted deletion recovery. |
| src/daemon/components/ServiceManager.cpp | Implements two-key staging (blob then document), serialized publish/drain, and idempotent publication based on committed tombstones. |
| src/daemon/components/dispatcher/request_dispatcher_documents.cpp | Threads keepRefs through pre-delete staging and post-delete publication hooks. |
| include/yams/memory_sync/memory_sync.h | Introduces EraseStageRequest and MemorySyncLoop::stageErases, plus preserves committed tombstone winners during outbox cleanup. |
| include/yams/memory_sync/memory_sync_service.h | Exposes stageErases and hasCommittedTombstone through the service wrapper. |
| include/yams/daemon/components/ServiceManager.h | Updates delete staging/publication APIs to include retainContent and adds a test observer hook + serialization mutex. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+512
to
+516
| serviceManager->testingSetMemorySyncDeleteOutboxObserver([&](std::string_view stage) { | ||
| if (stage == "delete_publish_locked" && !publisherSignalled.exchange(true)) { | ||
| publisherLockedPromise.set_value(); | ||
| releasePublisher.wait(); | ||
| } else if (stage == "delete_drain_waiting" && !drainerSignalled.exchange(true)) { |
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.
Stack
fix/p2p-correctness-pr→experimental)fix/p2p-correctness-prand must be reviewed/landed as part of that stack.Summary
Closes the deletion-integrity P1 disclosed on #68: a production document deletion previously published only
document/<hash>, leavingcontent-blob/<hash>remotely retrievable by hash.This layer now:
--keep-refsas an explicit document-only deletion mode;AI disclosure
This change was developed with extensive AI assistance, including test design, implementation, and adversarial review. It has not yet received full human maintainer review.
No merge, deployment, production restart, remote corpus mutation, SourceHut push, force update, or promotion to
mainis part of this PR.