Let operation validators force the tag scope on every tag-scoped operation
Summary
OperationValidatorExtension can force a tag scope on only two operations today:
- retain —
validate_retaincan rewritecontents(tags, strategy); - recall —
validate_recallcan returntags/tags_match/tag_groups, which the recall then uses.
Every other operation that reads or creates tag-scoped data gets an accept-or-reject hook with no tags in its context, so an extension cannot pin a caller to their scope. A caller who should only see user:dan + kind:rule can omit tags (or pass someone else's) on any of the operations below and read outside their scope.
Related: #5030 (source text), #5031 (entity filter).
What's missing
1. Reads with a tag filter — the extension must be able to replace it
| operation | hook today | gap |
|---|---|---|
| reflect | validate_reflect(ReflectContext) |
context has no tags; return value ignored. A reflect with no tags reaches the whole bank. |
memories/list, documents, mental-models (list), observations/scopes, tags, graph |
validate_bank_read(BankReadContext) |
accept/reject only |
entities, entities/graph |
validate_bank_read |
accept/reject only (and no tag param yet, #5031) |
| knowledge-base tree / search / export | validate_bank_read |
accept/reject only (and no tag param yet) |
Proposal: ReflectContext and BankReadContext carry the request's tags / tags_match / tag_groups; ValidationResult.accept_with(tags=..., tag_groups=...) is honoured by every one of these reads, the same way recall does it. Reflect must pass the forced filter to every tool in its loop (recall, mental-model search, expand).
2. Reads by id — the extension must see the item's tags
GET one memory, one document, a document's chunks, one mental model, one knowledge page, one entity, observation history. There's no filter to inject; the extension needs the target's tags in the context to allow or deny. (MentalModelGetContext carries only mental_model_id today.)
3. Creating/updating mental models and knowledge pages — the extension must see and force the tags
A mental model's tags decide which memories it is built from. A caller scoped to user:dan can create a mental model tagged user:kate, wait for the refresh, then read a summary of Kate's memories. Create/update today goes through validate_bank_write / validate_mental_model_refresh, neither of which carries the requested tags, so the extension can't even see this to reject it.
Proposal: carry tags / trigger.tags_match / trigger.tag_groups in the create/update/refresh contexts and let the extension rewrite or reject them, mirroring retain's contents enrichment.
Done when
An extension that forces tags=["user:dan","kind:rule"], tags_match="any_strict" on every operation leaves no endpoint through which that caller can read a memory, observation, chunk, document, mental model, knowledge page or entity outside that scope. A system test drives the Dan/Kate scenario from #5030 through each endpoint with a test validator.
Source: vectorize-io/hindsight