Guard no-op subject.deleted webhook, add search_mode, cover purge_events (#282, #281, #279)#283
Merged
Conversation
- #282: DELETE /v1/subjects fires the subject.deleted webhook only when something was actually deleted (ep_count + mem_count > 0). Deleting a missing subject (or the same subject twice) is a no-op and no longer emits a spurious deletion event; the 200 response with honest zero counts is unchanged. - #281: GET /v1/memories/search reports which path actually ran via a new additive `search_mode` field ("semantic" | "text" | "text_fallback"), so callers can distinguish a real semantic search from a silent text fallback (semantic requested without q, no embedding provider, or a provider error). Endpoint docstring added. - #279: add unit tests for the destructive webhooks.purge_events helper — its no-filter and terminal-status guards and its status/event_type/tenant_id filter scoping. New tests pass; ruff clean.
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.
Addresses three of the open jy7lsna issues (the other two, #278 and #280, are already fixed on
mainand were closed).#282 —
subject.deletedwebhook fires even when nothing was deleted (bug)DELETE /v1/subjects/{id}fired the webhook unconditionally. Deleting a missing subject (or the same one twice) enqueued asubject.deletedevent withepisodes_deleted: 0, memories_deleted: 0— a spurious deletion signal to consumers (cache invalidation, audit, compliance). Now gated onep_count + mem_count > 0. The HTTP response is unchanged (still 200 with honest zero counts — the delete stays idempotent).#281 — search response doesn't say which mode ran (feature)
GET /v1/memories/searchhad two silent-fallback paths (semantic requested withoutq; embedding provider missing or erroring). Callers couldn't tell their "semantic" query actually ran plain text. Added an additivesearch_modefield toSearchMemoriesResponse:semantic— embedding/hybrid search rantext— plain text (semantic not requested, or requested withoutq)text_fallback— semantic requested withqbut couldn't run (no provider / provider error), text ran insteadBackward compatible (existing clients ignore the field). Endpoint docstring added.
#279 —
purge_eventshad zero test coverage (tests)webhooks.purge_eventsis a destructive operator helper. Added unit tests locking in its two safety guards (no-filter →ValueError; non-terminal status →ValueError) and itsstatus/event_type/tenant_idfilter scoping, so a refactor that drops a guard turns CI red.Verified locally: 30 new/related tests pass, ruff clean. No existing test relied on the old behavior.
Closes #282
Closes #281
Closes #279