Documentation
¶
Overview ¶
Package notifystore decorates the shared prompt store so every successful write fires the prompts/list_changed notifier and every scope-widening write clears the attachment guard. Wrapping the one shared instance — the single store the manage_prompt tool, the admin/portal REST handlers, and the knowledge add_prompt path all write through — makes both properties of the write itself, so no write path can change the prompt set without a connected client learning about it, and none can widen a prompt's scope past its attached materials.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
Wrap returns base wrapped so every successful create/update/delete fires notify, preserving base's capability interfaces. A plain notifyingStore embeds prompt.Store and adds the write hooks; when base also implements the search extension (the production postgres store does, some test stores do not), the returned value additionally implements prompt.Searcher / knowledge.PromptSearcher by delegating Search to base, so the up-casts at promptlayer/tool.go, portal/prompt_handler.go, and searchfed still succeed. (knowledge.PromptSearcher is Search + GetByID; GetByID comes from the embedded prompt.Store, so implementing Search is sufficient for both.)
Invariant: the ONLY extension methods any caller up-casts the prompt store to beyond prompt.Store are Search (prompt.Searcher) and the versioning methods (prompt.VersionStore, asserted by prompt.ApplyEdit and the composition root). If a future extension interface is introduced, it must be forwarded here too, or the wrapper will silently drop it. Capabilities that need no write hook (prompt.CollectionStore) are instead exposed through the prompt.CollectionProvider accessor on notifyingStore, which every wrapper shape inherits, so they add no combinations here.
Types ¶
type Guard ¶
Guard reports whether a prompt about to be written would leave one of its attached resources unreachable for the audience the write gives it (#1013). It is applied here, on the shared store, for the same reason list_changed is: every path that writes a prompt crosses it, so making the check a property of the write means no writer — the manage_prompt tool, the portal editor, an admin promotion approval — can widen a prompt's scope past its materials, and none of them needs its own copy of the rule.
It governs scope, not readership. Sharing a personal prompt person-to-person writes to the share store, not the prompt, so it does not pass through here; a recipient of a prompt carrying the author's private template receives it with that material reported as undelivered, which the serve-time check guarantees. A nil guard skips the check.