fleet-memory/hindsight-api/hindsight_api/alembic/versions
Nicolò Boschi 0560f6260d
fix: cancel in-flight async ops when bank is deleted (#545)
* fix: cancel async ops on bank delete via CASCADE FK + heartbeat checkpoints

- Add migration e5f6g7h8i9j0: FK ON DELETE CASCADE from async_operations
  and webhooks to banks, so deleting a bank auto-removes all its ops/webhooks
- Add _check_op_alive() helper: returns False if op row was deleted (cascade)
- Add consolidation checkpoint: after each LLM batch commit, abort early if
  op was deleted mid-run (returns status='cancelled')
- Add retain checkpoint: between sub-batches, abort early if op was deleted
- _mark_operation_completed/failed/completed_and_fire_webhook: gracefully
  handle missing row (UPDATE 0) with log instead of silent error
- Thread operation_id into run_consolidation_job() for checkpoint access
- Fix y0t1u2v3w4x5 and a1b2c3d4e5f6 migrations: add IF NOT EXISTS to prevent
  failure on idempotent re-runs
- Add 10 tests covering cascade delete, _check_op_alive, graceful mark methods,
  consolidation checkpoint, and retain checkpoint

* refactor: use RETURNING + fetchrow instead of execute + string comparison

* fix: add bank upsert before async_operations FK inserts and update tests

- memory_engine.py: upsert bank in submit_async_retain before async_operations INSERT
- http.py: upsert bank in api_create_webhook before webhooks INSERT
- test_worker.py, test_async_batch_retain.py, test_webhooks.py: add _ensure_bank
  helper calls before direct async_operations/webhooks inserts to satisfy FK constraint

* fix: mock bank_utils.get_bank_profile in unit test with mocked pool
2026-03-12 09:39:31 +01:00
..
5a366d414dce_initial_schema.py feat: support azure pg_diskann (#381) 2026-02-16 16:08:54 +01:00
a1b2c3d4e5f6_add_file_storage_table.py fix: cancel in-flight async ops when bank is deleted (#545) 2026-03-12 09:39:31 +01:00
a2b3c4d5e6f7_add_text_signals_column.py feat: entity labels — optional, free_values, multi_value, UI polish (#450) 2026-03-02 13:05:25 +01:00
a2b3c4d5e6f8_add_gin_index_source_memory_ids.py perf: add GIN index on source_memory_ids for observation lookup (#485) 2026-03-05 10:15:40 +01:00
aa2b3c4d5e6f_nullable_event_date.py feat: support timestamp="unset" to retain content without a date (#465) 2026-03-02 12:03:23 +01:00
b3c4d5e6f7g8_add_temporal_date_indexes.py fix(performance): improve recall and retain performance on large banks (#469) 2026-03-03 13:35:22 +01:00
b4c5d6e7f8a9_backfill_observation_scopes.py feat: entity labels — optional, free_values, multi_value, UI polish (#450) 2026-03-02 13:05:25 +01:00
b7c4d8e9f1a2_add_chunks_table.py misc: add mcp integration tests and increase test coverage (#98) 2026-01-05 11:16:55 +01:00
c1a2b3d4e5f6_enable_pg_trgm_and_entities_trgm_index.py fix(performance): improve recall and retain performance on large banks (#469) 2026-03-03 13:35:22 +01:00
c3d4e5f6g7h8_add_history_to_mental_models.py feat: mental model history tracking and UI diff view (#516) 2026-03-06 17:50:48 +01:00
c8e5f2a3b4d1_add_retain_params_to_documents.py misc: add mcp integration tests and increase test coverage (#98) 2026-01-05 11:16:55 +01:00
d2e3f4a5b6c7_add_memory_links_expansion_indexes.py fix(performance): improve recall and retain performance on large banks (#469) 2026-03-03 13:35:22 +01:00
d4e5f6g7h8i9_gin_source_memory_ids_fastupdate_off.py feat: add jina-mlx reranker provider for Apple Silicon (#542) 2026-03-11 15:15:58 +01:00
d5e6f7a8b9c0_add_bank_internal_id_and_per_bank_hnsw.py perf: replace window-function retrieval with UNION ALL + per-bank HNSW indexes (#541) 2026-03-11 12:09:50 +01:00
d9f6a3b4c5e2_rename_bank_to_interactions.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
e0a1b2c3d4e5_disposition_to_3_traits.py misc: add mcp integration tests and increase test coverage (#98) 2026-01-05 11:16:55 +01:00
e4f5a6b7c8d9_add_webhooks_tables.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
e5f6g7h8i9j0_cascade_delete_ops_on_bank_delete.py fix: cancel in-flight async ops when bank is deleted (#545) 2026-03-12 09:39:31 +01:00
f1a2b3c4d5e6_add_memory_links_composite_index.py fix: improve mpfp retrieval (#146) 2026-01-12 18:58:05 +01:00
f7g8h9i0j1k2_add_webhook_http_config.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
g2a3b4c5d6e7_add_tags_column.py feat: add memory tags (#152) 2026-01-13 18:28:40 +01:00
h3c4d5e6f7g8_mental_models_v4.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
i4d5e6f7g8h9_delete_opinions.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
j5e6f7g8h9i0_mental_model_versions.py feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
k6f7g8h9i0j1_add_directive_subtype.py feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
l7g8h9i0j1k2_add_worker_columns.py feat: new 'worker' service (#176) 2026-01-20 10:17:56 +01:00
m8h9i0j1k2l3_mental_model_id_to_text.py feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
n9i0j1k2l3m4_learnings_and_pinned_reflections.py feat: support azure pg_diskann (#381) 2026-02-16 16:08:54 +01:00
o0j1k2l3m4n5_migrate_mental_models_data.py feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
p1k2l3m4n5o6_new_knowledge_architecture.py feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
q2l3m4n5o6p7_fix_mental_model_fact_type.py feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
r3m4n5o6p7q8_add_reflect_response_to_reflections.py feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
rename_personality_to_disposition.py misc: add mcp integration tests and increase test coverage (#98) 2026-01-05 11:16:55 +01:00
s4n5o6p7q8r9_add_consolidated_at_to_memory_units.py fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
t5o6p7q8r9s0_rename_mental_models_to_observations.py chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
u6p7q8r9s0t1_mental_models_text_id.py fix: misc fixes for observations and mental models (#209) 2026-01-27 15:37:57 +01:00
v7q8r9s0t1u2_add_max_tokens_to_mental_models.py fix: misc fixes for observations and mental models (#209) 2026-01-27 15:37:57 +01:00
w8r9s0t1u2v3_fix_mental_models_pk_isolation.py feat: support markdown in reflect and mental models (#307) 2026-02-06 10:49:13 +01:00
x9s0t1u2v3w4_add_bank_config_column.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
y0t1u2v3w4x5_add_result_metadata_gin_index.py fix: cancel in-flight async ops when bank is deleted (#545) 2026-03-12 09:39:31 +01:00
z1u2v3w4x5y6_add_observation_tags_to_memory_units.py feat: observation_scopes field to drive observations granularity (#447) 2026-02-28 10:46:21 +01:00