* feat: webhooks * feat: Enhance webhook security and typing, fix validation and encryption bugs * fix: lint / types * fix: rm files * fix: rm mcp * fix: pydantic issue with TypedDict in python version <= 3.11 * fix: pre-commit hook for test coverage * fix: simplify API -- store url on workspace * fix: redo architecture * fix: webhook body * fix: make workspace optional * fix: comments * refactor: add webhook secret * fix: CR comments * feat: use deriver for webhooks * use key-value approach * feat: add work unit key to deriver * fix: add work unit key to webhooks * fix: tests * fix: cr comments #2 * fix: endpoint structure; make webhook delivery into a function; add tests; other general comments * chore: change webhook secret, fix test event and workspace_id, use async with * feat: implement queue.empty and backfill * fix: unique constraint * refactor: queue to use outerjoin and remove skip locked; also fix publish queue.empty * fix: tests * fix: migration - make columns non-nullable |
||
|---|---|---|
| .. | ||
| README.md | ||
| __init__.py | ||
| conftest.py | ||
| test_deriver_processing.py | ||
| test_queue_operations.py | ||
| test_queue_processing.py | ||
README.md
Deriver Testing
This directory contains tests for the deriver system, which handles background processing of messages to extract insights and update working representations.
Structure
conftest.py- Shared fixtures for deriver testingtest_queue_operations.py- Tests for basic queue operationstest_deriver_processing.py- Tests for deriver processing logictest_queue_processing.py- Tests for queue manager and work unit processing
Key Fixtures
Database Fixtures
sample_session_with_peers- Creates a session with multiple peers having different observation configurationssample_messages- Creates sample messages for testingsample_queue_items- Creates queue items with various payload types (representation, summary)
Queue Fixtures
create_queue_payload- Helper to create queue payloads for testingadd_queue_items- Helper to add queue items to the databasecreate_active_queue_session- Helper to create active queue sessions for work unit tracking
Mocking Fixtures
mock_deriver_process- Mocks the deriver process_message methodmock_critical_analysis_call- Mocks the critical analysis LLM callmock_queue_manager- Mocks the queue manager for testingmock_embedding_store- Mocks the embedding store operations
Testing Patterns
Creating Queue Items
# Create representation payloads
payload = create_queue_payload(
message=message,
task_type="representation",
sender_name=message.peer_name,
target_name=observer_peer.name,
)
# Add to queue
queue_items = await add_queue_items([payload], session.id)
Testing Work Units
# Create a work unit
work_unit = WorkUnit(
session_id=session.id,
sender_name=sender.name,
target_name=target.name,
task_type="representation",
)
# Test string representation
assert str(work_unit) == f"({session.id}, {sender.name}, {target.name}, representation)"
Mocking Deriver Processing
# Use the mock_deriver_process fixture to avoid actual LLM calls
async def test_with_mocked_deriver(mock_deriver_process):
# Deriver processing will use the mock
await process_item(queue_item.payload)