Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

2.5 KB
Raw Blame

Hardened research_history deletes against out-of-repo and partial schemas. DELETE /api/delete/{id}, POST /api/clear_history, and ChatService.delete_attempt now route through a single application-level cascade (_delete_research_with_dependents) instead of trusting the schema's ON DELETE CASCADE rules alone. Newly created in-repo direct FKs on research_history.id use CASCADE/SET NULL, but legacy migration-0008 schemas can retain depth-2 NO ACTION FKs below research_resources. Partial schemas and third-party plugins can also lack CASCADE; deleting such a research could raise sqlcipher3.IntegrityError: FOREIGN KEY constraint failed (with PRAGMA foreign_keys = ON) and surface as a 500. (With SQLite's default foreign_keys = OFF the same delete succeeds silently and orphans rows instead — a separate orphaning mode the explicit deletes also repair, but not the 500 discriminated here.) The #5074 IN_PROGRESS / claimed-queue predicates now run inside the helper's parent DELETE so a worker that wins the race between the route's pre-check and the cascade is still observed.

The cascade now handles the full transitive closure derived from Base.metadata at runtime (_research_cascade_plan), so plain new data tables are picked up automatically at any depth — including depth-2 rows under research_resources (download_tracker / download_duplicates / download_attempts / download_queue / paper_appearances), whose FKs are NO ACTION in live schemas and aborted deletes of researches with downloaded sources even with the first-level cascade. Rows that must survive (chat history, library/sync/synthesis links) are cleared via an explicit survival policy (_CASCADE_SET_NULL); the introspection test asserts plan completeness over the full descendant closure, so a new table needing survival semantics fails CI until it gains a policy entry. Each research's child writes run inside a SAVEPOINT: when the parent DELETE guard refuses the row (concurrent IN_PROGRESS flip or queue claim), the helper rolls back that research's children and returns False, so clear_history can safely commit siblings in the same transaction. The helper forces a DEFERRED BEGIN before the savepoint when the driver has no transaction yet (legacy SQLite/SQLCipher mode leaves SELECT-only sessions without one, where a standalone savepoint's RELEASE would commit early), so a caller rollback() after a later failure still restores parent, children and preserved links.