Skip to content

Guard no-op subject.deleted webhook, add search_mode, cover purge_events (#282, #281, #279)#283

Merged
smaramwbc merged 1 commit into
mainfrom
fix/webhook-guard-search-mode-purge-tests
Jul 8, 2026
Merged

Guard no-op subject.deleted webhook, add search_mode, cover purge_events (#282, #281, #279)#283
smaramwbc merged 1 commit into
mainfrom
fix/webhook-guard-search-mode-purge-tests

Conversation

@smaramwbc

Copy link
Copy Markdown
Owner

Addresses three of the open jy7lsna issues (the other two, #278 and #280, are already fixed on main and were closed).

#282subject.deleted webhook 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 a subject.deleted event with episodes_deleted: 0, memories_deleted: 0 — a spurious deletion signal to consumers (cache invalidation, audit, compliance). Now gated on ep_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/search had two silent-fallback paths (semantic requested without q; embedding provider missing or erroring). Callers couldn't tell their "semantic" query actually ran plain text. Added an additive search_mode field to SearchMemoriesResponse:

  • semantic — embedding/hybrid search ran
  • text — plain text (semantic not requested, or requested without q)
  • text_fallback — semantic requested with q but couldn't run (no provider / provider error), text ran instead

Backward compatible (existing clients ignore the field). Endpoint docstring added.

#279purge_events had zero test coverage (tests)

webhooks.purge_events is a destructive operator helper. Added unit tests locking in its two safety guards (no-filter → ValueError; non-terminal status → ValueError) and its status / event_type / tenant_id filter 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

- #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.
@smaramwbc
smaramwbc merged commit 59bceae into main Jul 8, 2026
5 checks passed
@smaramwbc
smaramwbc deleted the fix/webhook-guard-search-mode-purge-tests branch July 8, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant