Skip to content

fix(backend): make memory & conversation deletion work again on desktop and mobile - #14691

Open
undivisible wants to merge 5 commits into
BasedHardware:mainfrom
undivisible:fix/memory-conversation-deletion
Open

undivisible wants to merge 5 commits into
BasedHardware:mainfrom
undivisible:fix/memory-conversation-deletion

Conversation

@undivisible

@undivisible undivisible commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An end user ([email protected], recurring report, "#10446 recurrence") cannot delete memories or conversations on desktop or mobile:

  • Desktop: deleting a memory or conversation surfaces an error.
  • Mobile: the delete appears to succeed, then the item resurfaces ~30 seconds later on the next refresh.

Root cause (backend; no client changes needed)

  1. Privacy-delete fail-closed gate (primary). Commit 5fa372e00d (fix(memories): mirror canonical deletes into the store the user still reads #10451) made deletion fail closed when the vector store is unavailable: HistoricalMemoryAdapter.cleanup(required=True) raised 503 when vector_db.index is None, and delete_canonical_memory_vectors returned False on an unconfigured index → RuntimeError → 503 on cascade retraction. Most releases never provision Pinecone (backend/deploy/runtime_env.yaml attaches PINECONE_API_KEY only to llm-gateway; desktop_backend_prod.yml strips it), so every DELETE /v3/memories/{id} and every cascade DELETE /v1/conversations/{id}?cascade=true deterministically 503'd. Desktop surfaces the error verbatim; mobile reads the non-200 as a failed delete, drops the optimistic tombstone, and the item resurfaces on refresh.
  2. Wire contract break (contributing). Commit e22938ac78 (Jul 4) turned DELETE /v1/conversations/{id} from status_code=204 into response_model=StatusResponse (200 + body). The released mobile client (app/lib/backend/http/api/conversations.dart::deleteConversationServer) gates delete success on exactly 204, so even successful server deletes read as failure on mobile.

Fix

Deleting the user's data is the privacy-preserving direction: with no configured vector store there is nothing to purge, so cleanup completes successfully; a configured store that errors still fails closed.

  • Restore status_code=204 (no body) on DELETE /v1/conversations/{conversation_id} (the folders/mcp convention) and pin the contract from both sides in backend/tests/unit/test_conversation_delete_wire_contract.py (router declaration + regenerated docs/api-reference/app-client-openapi.json).
  • backend/database/vector_db.py + backend/utils/memory/memory_service.py: fail deletion open when the vector store is unconfigured.
  • Register failure class FC-privacy-delete-fails-on-unprovisioned-derived-store (.github/failure-classes/), cited by both fixes.

Regression tests would have caught both: wire-contract both-sides test, unconfigured-index canonical vector deletion, required historical cleanup without a vector authority, cascade conversation delete without a vector store.

Product invariants

INV-MEM-1, INV-MEM-3, INV-MEM-4 (per scripts/pr-preflight --suggest; behavior change preserves the invariants — deletion now succeeds where no derived store exists, instead of erroring).

Failure-Class: new

Line-Count-Exception: backend/routers/conversations.py | 2231 -> 2235 | Restores the released 204 contract on DELETE /v1/conversations/{id}; the fix lives at the route declaration where the regression landed.
Line-Count-Exception: backend/utils/memory/memory_service.py | 4310 -> 4312 | HistoricalMemoryAdapter.cleanup must treat an unconfigured vector store as nothing-to-purge; the gate is the adapter's privacy-cleanup boundary.

Verification

From the authoring orb (T-01a0b590-2123-744a-9e4a-16706295c2d3), end to end:

  • Offline harness (PROVIDER_MODE=offline make dev-up, worktree uvicorn on :8001): with the old code DELETE /v3/memories/… → 503 and cascade conversation delete → 503; with the fix memory delete → 200 {"status":"ok"} and cascade delete → HTTP 204, empty body; both items gone from subsequent list reads.
  • bash backend/test.sh — full suite passed (1162 files, exit 0).
  • python3 backend/scripts/scan_async_blockers.py --dirs backend/routers backend/utils — 0 findings.
  • OpenAPI export check (scripts/export_openapi.py --surface app-client --check) — up to date; python3 scripts/check_client_compat.py --base origin/main — clean.
  • ./scripts/failure-class validate — errors [].

Re-verified in the PR checkout: all four touched test files pass under BACKEND_UNIT_TEST_FILE_LIST bash test.sh (172 tests; the one fast-unit CPU guard warning on test_upsert_canonical_memory_vector_writes_user_scoped_id_and_metadata reproduces identically on unpatched origin/main — pre-existing, load-dependent, 0.32–0.44s vs the 0.30s local budget; CI's ceiling is 1.0s). Async-blocker scan on changed paths: 0 findings. black --check on all changed Python files: clean.

Notes / follow-ups

  • Same 2026-07-04 backfill wave also changed 204 → 200 for DELETE /v1/action-items/{id}, POST /v1/action-items/batch-delete, and DELETE /v1/conversations/{id}/action-items (mobile clients in action_items.dart and conversations.dart:482 expect 204). Not fixed here — will file a follow-up issue.
  • Production-config conclusions are read from runtime_env.yaml and desktop_backend_prod.yml in code, not from live deployed state.
  • No desktop changelog fragment: the fix ships via backend deploy, not a desktop release.

Review in cubic

ampagent and others added 5 commits September 19, 2026 02:31
…on deletion

DELETE /v1/conversations/{conversation_id} shipped to released mobile clients
as 204 No Content. The 2026-07-04 response_model backfill (e22938a) turned
it into a 200 with a StatusResponse body, and the released app
(app/lib/backend/http/api/conversations.dart::deleteConversationServer) gates
delete success on exactly 204 — so every conversation delete there reads as a
failure: the optimistic tombstone is dropped immediately, the server-cursor
rebase and fetch-revision bookkeeping are skipped, and once the server delete
cannot complete (e.g. cascade retraction failing closed) the deleted
conversation resurfaces on the next refresh. This is the recurrence of
BasedHardware#10446 for conversations.

Restore status_code=204 with no body (the folders/mcp convention) and pin the
contract from both sides in backend/tests/unit/test_conversation_delete_wire_contract.py:
the router declaration and the regenerated app-client OpenAPI spec.

Verified: offline harness — cascade delete of a conversation with attributed
memories returned 503 before this change, 204 with an empty body after.

Failure-Class: FC-privacy-delete-fails-on-unprovisioned-derived-store
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b590-2123-744a-9e4a-16706295c2d3
Co-authored-by: Max Carter <[email protected]>
…onfigured

BasedHardware#10451 (5fa372e) made Pinecone-unavailable failure handling fail closed:
HistoricalMemoryAdapter.cleanup(required=True) raised 503 when
vector_db.index is None, and delete_canonical_memory_vectors returned False
→ RuntimeError → 503 on cascade retraction. Production never provisions
Pinecone on most releases (backend/deploy/runtime_env.yaml attaches the key
only to llm-gateway releases; desktop_backend_prod.yml explicitly strips it),
so every DELETE /v3/memories/{id} and every cascade
DELETE /v1/conversations/{id}?cascade=true deterministically 503'd — the
desktop app surfaces the error verbatim, and mobile reads the non-200 as a
failed delete, drops the tombstone, and the item resurfaces on refresh
(BasedHardware#10446 recurrence).

Deletion of the user's data is the privacy-preserving direction: when no
derived vector store is configured, there is nothing to purge, so cleanup
completes successfully; a configured store that errors still fails closed.

Tests cover the unconfigured-index deletion path, required historical
cleanup completing without a vector authority, and cascade deletion of a
conversation with attributed memories completing without a vector store.

Verified: offline harness — memory delete returned 503 before this change
and 200 afterwards.

Failure-Class: FC-privacy-delete-fails-on-unprovisioned-derived-store
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b590-2123-744a-9e4a-16706295c2d3
Co-authored-by: Max Carter <[email protected]>
…d-derived-store

Registers the definition for the privacy-delete failure class cited by the
two fixes in this branch.

Failure-Class: none
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b590-2123-744a-9e4a-16706295c2d3
Co-authored-by: Max Carter <[email protected]>
…t contract gate

The gate treats the merge-base spec as the released-clients truth. That
baseline can itself carry a spec-only regression: e22938a (2026-07-04)
flipped DELETE /v1/conversations/{conversation_id} from the released 204
No Content to 200 + StatusResponse while every released mobile client
still gates delete success on exactly 204
(app/lib/backend/http/api/conversations.dart::deleteConversationServer,
BasedHardware#10446 recurrence: desktop delete errors, mobile re-adds on refresh).
With the baseline poisoned, the gate blocked restoring the actual
released contract, and the July regression shipped precisely because no
guard existed to catch it.

Add RELEASED_STATUS_RESTORES, patterned on DELIBERATELY_REMOVED_ENDPOINTS:
an explicit, evidence-cited (route, method, status) record whose
released-client contract predates the baseline regression, so restoring
that status is not flagged as a new success status. Entries are narrow —
an unrecorded operation cannot borrow the allowance — and both the
allow-and-refuse directions are unit-tested.

Evidence: app/lib/backend/http/api/conversations.dart:140 in the
released app source returns response.statusCode == 204 for this call.

Failure-Class: none
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b76d-bb38-749d-a0da-1b0837aa8e2e
Co-authored-by: Max Carter <[email protected]>
Generators: backend/scripts/generate_ts_openapi_types.py,
generate_swift_openapi_types.py (dart --all produced no diffs; the wire
schemas are unchanged — only the conversation-delete response status
moved back to 204).

Failure-Class: none
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b76d-bb38-749d-a0da-1b0837aa8e2e
Co-authored-by: Max Carter <[email protected]>
@cursor

cursor Bot commented Sep 19, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_4bfbbd2e-250d-4c85-9c50-c8ab4d7d6c1e)

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this end to end against main and the PR head — both regressions are real and the fix is sound.

1. Fail-closed privacy delete (primary). Confirmed on main: HistoricalMemoryAdapter.cleanup(required=True) raises 503 when vector_db.index is None (memory_service.py), and delete_canonical_memory_vectors returning False becomes RuntimeError('canonical vector privacy cleanup unavailable') at canonical_memory_adapter.py:3596, so explicit deletes and cascade deletes both 503. The deploy-manifest claim checks out: in backend/deploy/runtime_env.yaml the main backend service has no PINECONE_API_KEY in dev or prod (only pusher and the notifications/memory-maintenance jobs carry it), and desktop_backend_prod.yml strips it. The semantic split in vector_db.py is the right one: index is bound at import time from env, so index is None means 'never configured, nothing to purge' (now logs and returns True), while a configured index that raises at index.delete still fails closed. Deleting the user's data is the privacy-preserving direction here.

2. Wire contract. Confirmed the released client gates on exactly 204 (app/lib/backend/http/api/conversations.dart:143 response.statusCode == 204), so main's current response_model=StatusResponse (200) made every successful server delete read as failure on mobile. Restoring status_code=204 in routers/conversations.py matches the folders/mcp convention.

3. Compatibility gate. RELEASED_STATUS_RESTORES in check_app_client_openapi_compatibility.py is narrow — one evidence-cited (route, method, status) triple consumed only in _check_responses' 'new success status' branch — and both the allow and refuse directions are unit-tested. Good pattern alongside DELIBERATELY_REMOVED_ENDPOINTS.

4. Tests. I ran the new/changed suites locally on this head: test_conversation_delete_wire_contract.py (2), the vector-absence and cleanup-completes tests, test_conversation_delete_cascade_completes_without_vector_store, and the full test_app_client_openapi_compatibility.py — all pass (28 total). The two-layer wire-contract assertion (router declaration + generated spec) is a nice touch.

5. Generated clients/spec. The four TS clients, the Swift client (now returns Void), and docs/api-reference/app-client-openapi.json are consistently regenerated; no bare StatusResponse references remain and nothing non-generated imports the removed type.

CI note. The Backend unit suite failure is not from this PR: test_legacy_summary_source_refs.py::test_flag_off_legacy_composition_validates_all_summary_evidence fails with AttributeError on _detect_duplicate_capture, the identical failure appears on main's own latest run (b930ae1, shard 3/4 vs shard 1/4 here), this PR touches neither that test nor process_conversation.py, and it passes in isolation on this head. That looks like shard-ordering/module pollution on main — worth a follow-up issue. Desktop Swift checks were still queued at review time.

One decision is above automated review: this reverses the #10451 fail-closed hardening so privacy deletes fail open when the vector store was never provisioned. The implementation is verified correct, but the deletion-failure semantics on user-data paths is a maintainer product/security call, so I'm leaving formal sign-off to a human maintainer.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution needs-maintainer-review Needs a human maintainer to sign off before merge backend Backend Task (python) labels Sep 19, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on the CI note in the earlier automated review: I pinned the exact root cause, and it is deterministic and pre-existing on main — not shard-ordering/module pollution.

  • backend/tests/unit/test_legacy_summary_source_refs.py:61 monkeypatches process_conversation._detect_duplicate_capture, which fix(backend): link cross-device overlaps without discarding captures #14370 (b930ae13, merged 03:12 UTC today) removed in favor of link_duplicate_captures from utils/conversations/duplicate_capture.py.
  • Main's own Backend unit run on b930ae13 fails the identical test (test_flag_off_legacy_composition_validates_all_summary_evidence, shard 3/4), so main is red on this suite independently of this PR.
  • This PR touches neither process_conversation.py nor that test; the merge-commit run simply inherits main's breakage. A rebase will not fix it — the remediation belongs on main (update or remove the stale monkeypatch at test line 61).

Everything else from the earlier review stands. The one open item for this PR remains the maintainer decision on deletion-failure semantics: it reverses the #10451 fail-closed gate so privacy deletes complete when no vector store was ever provisioned.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real fix for memory/conversation deletion; CI failure (test_legacy_summary_source_refs.py) looks unrelated to this diff's files, rerun triggered but not yet green at review time - approve only pending clean CI.

@aryanorastar

Copy link
Copy Markdown
Collaborator

The red Backend unit shard 1/4 is stale base, not this diff. The branch is 75 commits behind main, so its copy of backend/tests/unit/test_legacy_summary_source_refs.py still patches process_conversation._detect_duplicate_capture, which main renamed to link_duplicate_captures in 26aa2eee (follows #14370). Merging current main (094514c) into the branch locally clears it:

  • test_legacy_summary_source_refs.py — 2 passed
  • test_conversation_delete_wire_contract.py, test_canonical_memory_vectors.py, test_ws_j_delete_privacy.py, test_universal_memory_service.py, test_app_client_openapi_compatibility.py — all pass, including test_delete_canonical_memory_vectors_confirms_absence_when_index_unconfigured

The fast-unit CPU guard on test_upsert_canonical_memory_vector_writes_user_scoped_id_and_metadata is load-dependent rather than yours: in a clean origin/main worktree it tripped at 0.44s on the first run and passed on the second, while the merged head passed both runs.

Confirming the deployment half of the diagnosis from main: PINECONE_API_KEY is bound only to the dev pusher and to the notifications-job and memory-maintenance-job Cloud Run jobs in dev and prod — no API service — and desktop_backend_prod.yml passes --remove-secrets=PINECONE_API_KEY,PINECONE_HOST. On the request path vector_db.index is therefore None, delete_canonical_memory_vectors returns False, and HistoricalMemoryAdapter.cleanup(required=True) turns that into the 503. It also explains the reporter detail that conversations deleted while memories did not: a non-cascade conversation delete never reaches the vector store.

Not verified here: I did not run the offline harness end to end. The above is the code, the deploy config, and those test suites.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on the earlier automated review — two updates since then, both resolving the open items:

Human sign-off landed. The one decision the earlier review explicitly left to a maintainer — reversing the #10451 fail-closed gate so privacy deletes complete when no vector store was ever provisioned — has been made: kodjima33 approved this exact head. With that, nothing is outstanding from automated review, so I've cleared needs-maintainer-review.

The two red backend checks are main's breakage, not this PR's. Traced fully this time: main's own Backend Unit Tests run on this PR's merge-base commit (b930ae13) failed the identical test — test_legacy_summary_source_refs.py::test_flag_off_legacy_composition_validates_all_summary_evidence, AttributeError: process_conversation has no attribute '_detect_duplicate_capture' — and main fixed it later that morning in 26aa2eea ("test: legacy-summary fixture mocks link_duplicate_captures (follows #14370)"), after which main's unit runs went green. This branch predates that fix, so the stale merge-base still carries the broken fixture. Updating the branch against main (merge or rebase) should turn the unit shards green with no code change — worth doing before merge so the suite actually validates this head.

Everything else from the earlier verification stands: the unconfigured-means-nothing-to-purge semantics in vector_db.py/memory_service.py (a configured store that raises still fails closed), the restored 204 contract in routers/conversations.py, the narrow RELEASED_STATUS_RESTORES carve-out in the compatibility checker, and the consistently regenerated clients/spec.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level removed the needs-maintainer-review Needs a human maintainer to sign off before merge label Sep 20, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genuine, well-verified backend fix restoring memory/conversation deletion on desktop and mobile: (1) makes privacy-delete cleanup succeed when no vector store is provisioned instead of fail-closed 503ing (most deployments never provision Pinecone on the main backend service per runtime_env.yaml), and (2) restores the 204 status code on DELETE /v1/conversations/{id} that the released mobile client gates success on. Wire-contract regression test, canonical-vector tests, and generated-client updates all included; scoped Line-Count-Exceptions documented and justified. Confidence 5/5 on the fix itself.

Not merging: Backend unit shard 1/4 fails on tests/unit/test_legacy_summary_source_refs.py, which touches neither files this PR changes. I triggered a rerun (gh run rerun --failed) and it failed again with the identical test. Independently verified via the GitHub check-runs API that this same test also fails on main itself (commit b930ae1, shard 3/4, 2026-09-19) — this is a pre-existing, shard-order-dependent flake on main, not a regression from this diff. Per the hard floor a failing required check still blocks auto-merge; leaving approved-only for Nik to merge once the pre-existing main flake is fixed or to override.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on 2fb1f42a9b06.

The fail-open half is already on current main via merged #15097: delete_canonical_memory_vectors returns True when index is None, and FC-privacy-delete-fails-on-unprovisioned-derived-store.json is on main. That is why this head CONFLICTS on that file.

What is still unique here is the wire contract: DELETE /v1/conversations/{id} is still response_model=StatusResponse (200) on main, and the released mobile client still gates success on 204. Generated clients, RELEASED_STATUS_RESTORES, and test_conversation_delete_wire_contract.py belong with that leftover.

Please rebase onto current main and drop the already-landed fail-open files. Do not resolve the conflicts in the web editor.

I am not approving or merging this SHA. It is CONFLICTING/DIRTY.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confidence gate ~3/5 (diff exceeds scoped-diff threshold across 16 files; CI shows failing backend unit checks) - approve-only despite well-documented root cause.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-documented backend fix but diff >300 lines across many files and CI backend-unit checks failing + DIRTY — approve-only, not merging.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend delete fix (recurring #10446 report), CI now green, clear root cause + tests — ~4/5, but diff 329 lines >300 cap and mergeStateStatus UNKNOWN — approve only.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-affirmed (backlog reapprove): real backend fix for memory/conversation deletion (#10446 recurrence), root cause well documented. Still DIRTY and Backend unit shard 1/4 + Backend unit suite are failing on current CI — hard floor blocks merge, holding at approve.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix(backend): memory/conversation deletion — verified independently against origin/main. Root cause #1 (vector-store fail-open on 503) is ALREADY FIXED on main via PR #15097 (commit 6a4928c, merged 2026-09-20, co-authored by this same PR's author, undivisible/Max Carter). Root cause #2 (restoring status_code=204 on DELETE /v1/conversations/{id}, which the released mobile client gates success on) is still NOT on main. This PR bundles both — not closing since the 204 fix is still genuinely needed, not merging since it's DIRTY (likely conflicting with the already-merged #15097) and has a failing required check (Backend unit shard 1/4 + suite). Holding at approve; recommend the author rebase off current main to drop the already-merged half and resubmit just the 204 fix.

@Git-on-my-level

Copy link
Copy Markdown
Member

Two notes for this head, following up on the prior automated review.

1) CI attribution. The only test failing in Backend unit shard 1/4 (run 35418033074) is tests/unit/test_legacy_summary_source_refs.py::test_flag_off_legacy_composition_validates_all_summary_evidence, which monkeypatches process_conversation._detect_duplicate_capture. That symbol was removed from backend/utils/conversations/process_conversation.py on main between 9c89f27 (Sep 17) and 955bd6f (Sep 26) — before this PR's merge-base — so the AttributeError is deterministic pre-existing main breakage, not a regression from this PR and not a shard-order flake. Everything this PR touches passes (shards 2–4, guardrails, hermetic merge gate, desktop builds). A rebase will not clear shard 1 until that stale fixture is repaired on main.

2) Supersession state. The fail-open privacy-delete half of this PR (vector_db.py unconfigured-index confirmation, memory_service.py 503-gate removal) landed on main via #15097 (6a4928c, Sep 20) — main now matches this branch for those files. What remains unique and still needed is the 204 restoration for DELETE /v1/conversations/{conversation_id}: main still serves 200 + StatusResponse there, while released mobile clients gate delete success on exactly 204. Rebasing onto current main should naturally drop the already-merged half and shrink this PR to the 204 fix plus its contract tests and regenerated clients.

The earlier verification conclusion stands; leaving the merge/rebase sequencing with the human maintainers already engaged on this PR.


by AI on behalf of David — if you need David's attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed root-cause analysis for memory/conversation deletion failing closed; approve-only — mergeStateStatus is DIRTY and Backend unit shard 1/4 + Backend unit suite are failing in CI, so not merge-eligible; not touching the branch.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix(backend) memory/conversation deletion, stated root cause + tests, but DIRTY (needs manual rebase, left untouched, not merged) and backend unit suite showing a failing check; approve-only.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genuine scoped backend bug fix (memory/conversation deletion 503s + wire-contract break), not already fixed on main (verified conversations.py still uses response_model=StatusResponse, not 204). Confidence 3/5: diff 329 lines > 300 cap, and Backend unit shard 1/4 fails on CI (even after a rerun) — but the failure is in test_legacy_summary_source_refs.py over process_conversation.py, a file this PR never touches, and that test file no longer exists on current main (likely stale/pre-existing drift). No abuse signals. Approve only, do not merge, per hard floor (failing required check) + confidence gate.

@Git-on-my-level

Copy link
Copy Markdown
Member

Diagnosed the red backend checks on this PR — they are not from this diff.

The only failure in Backend unit shard 1/4 is tests/unit/test_legacy_summary_source_refs.py::test_flag_off_legacy_composition_validates_all_summary_evidence, which AttributeErrors while stubbing _detect_duplicate_capture on backend/utils/conversations/process_conversation.py. Neither that test nor that module is touched here. At the time CI ran, the merge commit inherited main's removal of _detect_duplicate_capture while the stale test still referenced it; current main has since deleted that test file outright, so this specific failure self-resolves on the next merge/re-run of the suite.

Everything this PR actually changes is green: shards 2/4–4/4 and the guardrails job pass, including the new unprovisioned-store coverage (test_canonical_memory_vectors.py, test_ws_j_delete_privacy.py cascade, the rewritten test_universal_memory_service.py case) and the wire-contract pins (test_conversation_delete_wire_contract.py, test_app_client_openapi_compatibility.py).

One caveat: main's backend suite is itself red on rotating shards today (3/4 on the latest run, 2/4 on the one before), so a re-run may still surface unrelated main-side noise.

The fix itself remains verified sound: vector_db.py treats an unconfigured index as trivially-confirmed absence while a configured index that raises still fails closed, memory_service.py drops the 503 unprovisioned gate, conversations.py restores the released 204 contract, and the RELEASED_STATUS_RESTORES allowlist in check_app_client_openapi_compatibility.py is narrow and cannot be borrowed by other operations.

Feedback generated by the Omi maintainer automation on David's behalf.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend bug-fix PR. Root-caused and well-documented, but 2 of its 3 fixes (vector_db.py + memory_service.py unconfigured-index handling) are already merged on main via PR #15097 (same author, co-authored as Max Carter). The remaining fix (restoring 204 on DELETE /v1/conversations/{id}, reverting e22938a's 200+body regression) is real and NOT yet on main. Approve-only: mergeStateStatus UNKNOWN + failing Backend unit suite check (pre-existing drift in test_legacy_summary_source_refs.py, unrelated to this diff) block merge under the hard floor; diff size (329 lines/10 files) also misses the ≤300 scoped-diff criterion.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix(backend): memory/conversation deletion -- real bug w/ good test coverage, but 'Backend unit shard 1/4' + 'Backend unit suite' required checks FAIL -- hard floor blocks merge; (area corrected from

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix(backend): memory/conversation deletion -- real bug w/ good test coverage, but 'Backend unit shard 1/4' + 'Backend unit suite' required checks FAIL -- hard floor blocks merge; (area corrected from

kodjima33 pushed a commit that referenced this pull request Oct 13, 2026
…tion (#21329)

* fix(backend): restore the released 204 delete contract for conversation deletion

DELETE /v1/conversations/{conversation_id} shipped to released mobile clients
as 204 No Content. The 2026-07-04 response_model backfill (e22938a) turned
it into a 200 with a StatusResponse body, and the released app
(app/lib/backend/http/api/conversations.dart::deleteConversationServer) gates
delete success on exactly 204 — so every conversation delete there reads as a
failure: the optimistic tombstone is dropped immediately, the server-cursor
rebase and fetch-revision bookkeeping are skipped, and once the server delete
cannot complete (e.g. cascade retraction failing closed) the deleted
conversation resurfaces on the next refresh. This is the recurrence of

Restore status_code=204 with no body (the folders/mcp convention) and pin the
contract from both sides in backend/tests/unit/test_conversation_delete_wire_contract.py:
the router declaration and the regenerated app-client OpenAPI spec.

Verified: offline harness — cascade delete of a conversation with attributed
memories returned 503 before this change, 204 with an empty body after.

Failure-Class: FC-privacy-delete-fails-on-unprovisioned-derived-store
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b590-2123-744a-9e4a-16706295c2d3
Co-authored-by: Max Carter <[email protected]>
(cherry picked from commit 21002a8)

* fix(checks): allow recorded released-status restorations in app-client contract gate

The gate treats the merge-base spec as the released-clients truth. That
baseline can itself carry a spec-only regression: e22938a (2026-07-04)
flipped DELETE /v1/conversations/{conversation_id} from the released 204
No Content to 200 + StatusResponse while every released mobile client
still gates delete success on exactly 204
(app/lib/backend/http/api/conversations.dart::deleteConversationServer,
#10446 recurrence: desktop delete errors, mobile re-adds on refresh).
With the baseline poisoned, the gate blocked restoring the actual
released contract, and the July regression shipped precisely because no
guard existed to catch it.

Add RELEASED_STATUS_RESTORES, patterned on DELIBERATELY_REMOVED_ENDPOINTS:
an explicit, evidence-cited (route, method, status) record whose
released-client contract predates the baseline regression, so restoring
that status is not flagged as a new success status. Entries are narrow —
an unrecorded operation cannot borrow the allowance — and both the
allow-and-refuse directions are unit-tested.

Evidence: app/lib/backend/http/api/conversations.dart:140 in the
released app source returns response.statusCode == 204 for this call.

Failure-Class: none
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b76d-bb38-749d-a0da-1b0837aa8e2e
Co-authored-by: Max Carter <[email protected]>
(cherry picked from commit 11cc3c5)

* chore: regenerate TS/Swift OpenAPI clients for the restored 204 delete contract

Regenerated from the updated app-client spec with
backend/scripts/generate_ts_openapi_types.py and
generate_swift_openapi_types.py rather than cherry-picking 2fb1f42 from
#14691, whose generated files predate current main. Only the conversation
delete function changes: Swift returns Void, TypeScript returns without
parsing a body. No in-tree code calls either generated function.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(backend): expect no body from conversation delete under the 204 contract

test_conversation_tombstones.py (#21000) landed after the 200-with-body
regression and asserted the handler's {'status': 'Ok'} return. The route is
204 No Content again, the contract the released mobile client gates on
(app/lib/backend/http/api/conversations.dart::deleteConversationServer
returns statusCode == 204), so the handler returns None. The tests' subject,
tombstone ordering against retraction and cleanup, is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(backend): assert conversation delete answers 204 with an empty body over HTTP

The wire-contract test pinned the route declaration and the published spec.
This adds the HTTP layer: the real route through FastAPI's TestClient, with
only storage side effects stubbed, for cascade=false and cascade=true. Against
main's route both requests answer 200 (assert 200 == 204), which the released
mobile client reads as a failed delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(backend): keep the 204 delete rationale to one line

The full reasoning lives in test_conversation_delete_wire_contract.py; the
router stays at its line-count baseline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Amp <[email protected]>
Co-authored-by: Max Carter <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real, well-documented root-caused fix for memory/conversation delete, but mergeStateStatus is UNKNOWN (stale) and CI shows a failing backend unit shard on this old run — approving only, not merging, until that's resolved.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked: CI still red (hard floor). Genuine root-caused fix for memory/conversation delete, but mergeStateStatus UNKNOWN (stale) and failing CI shard on old run

@aryanorastar

Copy link
Copy Markdown
Collaborator

Current-main supersession note, reviewed November 5, 2026:

Both original fix boundaries described here are now present on main 396b9c0c9d50b871875a99819fde43db1b8a3b7b: #15097 merged the unconfigured-vector-store deletion handling; #21329 merged the restored 204 response for conversation deletion. backend/routers/conversations.py:1415 declares status_code=204, matching the mobile client's success check. #21605 also merged the separate mobile restoration of a row after a failed server delete.

Brent's newly supplied Discord thread reports deletion failing again across mobile/desktop for conversations, recordings and memories; a second named participant says “same problem.” This recurrence is tracked in #24719. Exact builds, failed operation/response and deployed revision remain unknown; old fixes on main do not prove this incident resolved or establish its cause. The meaning/storage surface of “recordings” also needs confirmation.

This is a support/source-history update, not an approval or closure of this PR. Please use the current-main evidence when assessing remaining PR scope; do not treat this still-open PR as proof that the original two fixes are absent.

This branch has not been deployed

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

Labels

backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants