Skip to content

feat(sharing): implement require_approval with a pending-approval queue#22

Merged
yhyyz merged 1 commit into
ourmem:mainfrom
doctatortot:feat/share-approval-queue
May 21, 2026
Merged

feat(sharing): implement require_approval with a pending-approval queue#22
yhyyz merged 1 commit into
ourmem:mainfrom
doctatortot:feat/share-approval-queue

Conversation

@doctatortot
Copy link
Copy Markdown
Contributor

Problem

AutoShareRule.require_approval exists 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.)

  • A require_approval rule match now enqueues a PendingShare instead of dropping the memory.
  • New per-tenant endpoints:
    • 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 a Share 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, mirroring the existing import_tasks pattern (schema + init + record/list/get/delete). The materialise step is factored into apply_pending_share(...) so it stays unit-testable without AppState.

Tests

test_pending_share_approval_flow: a require_approval rule 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).

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>
@yhyyz yhyyz merged commit d84cc8d into ourmem:main May 21, 2026
1 check passed
@yhyyz
Copy link
Copy Markdown
Contributor

yhyyz commented May 21, 2026

Merged — great to finally have require_approval do something real. The pollable queue design is solid. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants