fleet-memory/hindsight-clients/python/hindsight_client_api/models
Nicolò Boschi abbf874d84
feat: webhook system with retain.completed event, UI, and docs (#487)
* doc: update cookbook

* fix(cookbook): preserve tag keys during sync, strip local .md links

- Fix extract_tags_from_readme/notebook to return dict[str,str] preserving
  sdk/topic keys instead of bare values, preventing topics like
  "Customer Service" from being misclassified as SDK
- Add strip_local_md_links() to remove relative .md references that
  would cause broken link errors in Docusaurus build

* ci: run test-doc-examples independently without waiting for test-rust-cli

Build the CLI directly in the job instead of downloading the artifact,
so test-doc-examples can start at the beginning in parallel with all other jobs.

* feat: webhook system with task-owned retry, retain.completed event, and UI

- New webhook system: register per-bank webhooks with HMAC signing, configurable
  HTTP method/timeout/headers/params (http_config JSONB), and PATCH support
- Webhook deliveries run as async_operations (webhook_delivery type) with
  task-owned retry via RetryTaskAt exception and exponential backoff
  (60s / 5m / 30m / 2h / 8h, max 6 attempts)
- New retain.completed event fires per-document for both sync and async retain
- Delivery debug info (status code, response body) stored in result_metadata
- Control plane UI: webhooks tab per bank with create/edit/delete and a
  deliveries table with cursor pagination and expandable response details
- 28 webhook tests covering HMAC signing, delivery retries, CRUD endpoints,
  PATCH update, and retain.completed queuing
- Docs page at developer/api/webhooks documenting event payloads and delivery
- OpenAPI spec and all client SDKs (Python, TypeScript, Rust, Go) regenerated

* fix: update tests for task-owned retry model and guard _webhook_manager attribute

- test_worker.py: test_executor_exception_triggers_retry now raises RetryTaskAt
  (plain exceptions are immediate failures in the new system); rename
  test_executor_exception_marks_failed_after_max_retries to
  test_executor_exception_marks_failed_immediately to reflect new semantics
- test_batch_api.py: remove max_retries kwarg from WorkerPoller constructor
- memory_engine.py: use getattr for _webhook_manager in _fire_retain_webhook
  to avoid AttributeError when engine is created without __init__ (tests)

* fix: remove max_retries from benchmark WorkerPoller call

* fix(webhooks): transactional outbox, observations_deleted tracking, sidebar

- Queue webhook delivery rows atomically with the primary operation using the
  transactional outbox pattern — prevents lost events on process crash:
  - Retain (sync + async): outbox_callback passed into orchestrator.retain_batch
    and called inside the DB transaction, replacing the post-commit fire call
  - Consolidation: new _mark_operation_completed_and_fire_webhook combines the
    status UPDATE and webhook INSERT in one transaction
  - Added fire_event_with_conn() to WebhookManager for in-connection delivery

- Track observations_deleted count in consolidation stats and expose it in the
  consolidation.completed webhook payload (was always None)

- Add Webhooks page to docs sidebar

- Document at-least-once delivery guarantee with operation_id dedup guidance

* fix(ui): add retain.completed to available webhook event types

* feat(ui): add delete confirmation dialog for webhooks

* fix(webhooks): include operation_id in task_payload so delivery is marked completed

The task_payload JSON was missing the operation_id field, causing execute_task
to see operation_id=None and skip _mark_operation_completed — leaving every
delivery row stuck in 'pending' forever.

Added a test that inserts a real async_operations row and verifies the status
transitions to 'completed' after a successful execute_task call.

* style: fix prettier formatting in webhooks-view
2026-03-04 14:17:01 +01:00
..
__init__.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
add_background_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
async_operation_submit_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
background_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
bank_config_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
bank_config_update.py Release v0.4.15 2026-03-03 15:03:42 +01:00
bank_list_item.py Release v0.4.15 2026-03-03 15:03:42 +01:00
bank_list_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
bank_profile_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
bank_stats_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
budget.py Release v0.4.15 2026-03-03 15:03:42 +01:00
cancel_operation_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
child_operation_status.py Release v0.4.15 2026-03-03 15:03:42 +01:00
chunk_data.py Release v0.4.15 2026-03-03 15:03:42 +01:00
chunk_include_options.py Release v0.4.15 2026-03-03 15:03:42 +01:00
chunk_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
clear_memory_observations_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
consolidation_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
create_bank_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
create_directive_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
create_mental_model_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
create_mental_model_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
create_webhook_request.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
delete_document_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
delete_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
directive_list_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
directive_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
disposition_traits.py Release v0.4.15 2026-03-03 15:03:42 +01:00
document_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_detail_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_include_options.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_input.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_list_item.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_list_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_observation_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
entity_state_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
features_info.py Release v0.4.15 2026-03-03 15:03:42 +01:00
file_retain_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
graph_data_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
http_validation_error.py Release v0.4.15 2026-03-03 15:03:42 +01:00
include_options.py Release v0.4.15 2026-03-03 15:03:42 +01:00
list_documents_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
list_memory_units_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
list_tags_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
memory_item.py Release v0.4.15 2026-03-03 15:03:42 +01:00
mental_model_list_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
mental_model_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
mental_model_trigger.py Release v0.4.15 2026-03-03 15:03:42 +01:00
observation_scopes.py Release v0.4.15 2026-03-03 15:03:42 +01:00
operation_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
operation_status_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
operations_list_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
recall_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
recall_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
recall_result.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_based_on.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_directive.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_fact.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_include_options.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_llm_call.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_mental_model.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_tool_call.py Release v0.4.15 2026-03-03 15:03:42 +01:00
reflect_trace.py Release v0.4.15 2026-03-03 15:03:42 +01:00
retain_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
retain_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
source_facts_include_options.py Release v0.4.15 2026-03-03 15:03:42 +01:00
tag_item.py Release v0.4.15 2026-03-03 15:03:42 +01:00
timestamp.py Release v0.4.15 2026-03-03 15:03:42 +01:00
token_usage.py Release v0.4.15 2026-03-03 15:03:42 +01:00
tool_calls_include_options.py Release v0.4.15 2026-03-03 15:03:42 +01:00
update_directive_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
update_disposition_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
update_mental_model_request.py Release v0.4.15 2026-03-03 15:03:42 +01:00
update_webhook_request.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
validation_error.py Release v0.4.15 2026-03-03 15:03:42 +01:00
validation_error_loc_inner.py Release v0.4.15 2026-03-03 15:03:42 +01:00
version_response.py Release v0.4.15 2026-03-03 15:03:42 +01:00
webhook_delivery_list_response.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
webhook_delivery_response.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
webhook_http_config.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
webhook_list_response.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
webhook_response.py feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00