feat(sharing): implement require_approval with a pending-approval queue#22
Merged
Merged
Conversation
The require_approval field on auto-share rules existed but had no effect:
matching memories were silently skipped, with no queue and no way to approve
them.
Implement it. A require_approval rule match now enqueues a PendingShare instead
of silently dropping the memory. New per-tenant endpoints:
- GET /v1/shares/pending list shares awaiting approval (in spaces
the caller can write to)
- POST /v1/shares/pending/{id}/approve materialise the share (copies source
content + vector), record event, dequeue
- POST /v1/shares/pending/{id}/reject drop the pending entry
All gated by verify_space_write_access on the target space.
Persistence: a pending_shares table in SpaceStore (mirrors the import_tasks
pattern). The materialise step is factored into apply_pending_share(...) so it
stays unit-testable without AppState.
Notifications are intentionally out of scope -- the queue is pollable.
Tests: test_pending_share_approval_flow (require_approval enqueues rather than
sharing; approve materialises the copy with its vector and drains the queue).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Merged — great to finally have |
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.
Problem
AutoShareRule.require_approvalexists but has no effect: a matching memory is silently skipped (continue), with no queue and no way to approve it. The field lies.Approach
Implement it as a pollable approval queue. (Notifications are intentionally out of scope — separate subsystem; the queue is pollable.)
require_approvalrule match now enqueues aPendingShareinstead of dropping the memory.GET /v1/shares/pending— list shares awaiting approval, scoped to spaces the caller can write to.POST /v1/shares/pending/{id}/approve— materialise the share (copies source content + vector), record aShareevent, dequeue.POST /v1/shares/pending/{id}/reject— drop the pending entry.verify_space_write_accesson the target space.Persistence
A
pending_sharestable inSpaceStore, mirroring the existingimport_taskspattern (schema + init + record/list/get/delete). The materialise step is factored intoapply_pending_share(...)so it stays unit-testable withoutAppState.Tests
test_pending_share_approval_flow: arequire_approvalrule enqueues rather than sharing; approve materialises the copy with its vector and drains the queue. Full suite green (389 passed); fmt + clippy clean (no new warnings).