honcho/tests/deriver
Rajat Ahuja 3df044e1b7
feat: use token limit from all senders for rollup (#221)
* feat: use token limit from all senders for rollup

* fix: send all messages to queue_manager

* test: fixe tests and move ownership check to separate query

* fix: if first sender message exceeds batch then we should return an empty batch

* feat: separate representation and non-representation processing

* fix: return msg object and queue items

* fix: rollup logic with interleaving messages

* fix: rm TODO

* Fix langfuse trace and add fallback for weird error in deriver

* fix: simplify query

* fix: comment out update_current_generation

* fix: BPR

---------

Co-authored-by: Vineeth Voruganti <13438633+VVoruganti@users.noreply.github.com>
2025-10-01 16:10:10 -04:00
..
README.md Peer Cards (#180) 2025-08-12 17:39:08 -04:00
__init__.py Vineeth/dev 1027 (#177) 2025-08-06 16:20:22 -04:00
conftest.py Peer Cards (#180) 2025-08-12 17:39:08 -04:00
test_deriver_processing.py feat: use token limit from all senders for rollup (#221) 2025-10-01 16:10:10 -04:00
test_queue_operations.py feat: webhooks (#168) 2025-08-06 17:52:35 -04:00
test_queue_processing.py feat: use token limit from all senders for rollup (#221) 2025-10-01 16:10:10 -04:00
test_representation_crud.py feat: targeted peer cards (#204) 2025-09-04 12:13:34 -04:00

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 testing
  • test_queue_operations.py - Tests for basic queue operations
  • test_deriver_processing.py - Tests for deriver processing logic
  • test_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 configurations
  • sample_messages - Creates sample messages for testing
  • sample_queue_items - Creates queue items with various payload types (representation, summary)

Queue Fixtures

  • create_queue_payload - Helper to create queue payloads for testing
  • add_queue_items - Helper to add queue items to the database
  • create_active_queue_session - Helper to create active queue sessions for work unit tracking

Mocking Fixtures

  • mock_critical_analysis_call - Mocks the critical analysis LLM call
  • mock_queue_manager - Mocks the queue manager for testing
  • mock_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)"