CONV-001: Conversation Interface Infrastructure #131

Closed
opened 2026-04-11 03:11:50 +00:00 by Mark · 1 comment
Owner

Overview

Implement thread-based conversation management for multi-turn interactions.

Current State

Mesh is stateless. Each intent is independent with no context from previous interactions.

Missing Components

Thread Management

  • Thread ID generation and tracking
  • Thread lifecycle (create, update, close, archive)
  • Thread metadata (created_at, last_activity, participant count)

HTTP API

# New endpoints needed:
POST /threads                    # Create new conversation thread
GET /threads/{thread_id}         # Get thread status
POST /threads/{thread_id}/intents # Submit intent within thread context
GET /threads/{thread_id}/history  # Get conversation history
DELETE /threads/{thread_id}      # Close/archive thread

Intent Payload Extension

{
  "type": "write_article",
  "payload": {...},
  "thread_id": "uuid-here",  // NEW: Link to conversation
  "context_window": 5          // NEW: How many previous turns to include
}

Storage

  • Threads table in ledger
  • Intent-to-thread mapping
  • Message sequence ordering

Acceptance Criteria

  • Thread can be created via API
  • Intents can reference thread_id
  • Workers receive thread context
  • Thread history retrievable
  • Threads can be closed/archived
  • EMBED-004: Conversational Memory (depends on this)
  • CONV-002: Multi-turn Context Management

Priority

HIGH - Required for conversational agents

## Overview Implement thread-based conversation management for multi-turn interactions. ## Current State Mesh is stateless. Each intent is independent with no context from previous interactions. ## Missing Components ### Thread Management - [ ] Thread ID generation and tracking - [ ] Thread lifecycle (create, update, close, archive) - [ ] Thread metadata (created_at, last_activity, participant count) ### HTTP API ```python # New endpoints needed: POST /threads # Create new conversation thread GET /threads/{thread_id} # Get thread status POST /threads/{thread_id}/intents # Submit intent within thread context GET /threads/{thread_id}/history # Get conversation history DELETE /threads/{thread_id} # Close/archive thread ``` ### Intent Payload Extension ```json { "type": "write_article", "payload": {...}, "thread_id": "uuid-here", // NEW: Link to conversation "context_window": 5 // NEW: How many previous turns to include } ``` ### Storage - [ ] Threads table in ledger - [ ] Intent-to-thread mapping - [ ] Message sequence ordering ## Acceptance Criteria - [ ] Thread can be created via API - [ ] Intents can reference thread_id - [ ] Workers receive thread context - [ ] Thread history retrievable - [ ] Threads can be closed/archived ## Related - EMBED-004: Conversational Memory (depends on this) - CONV-002: Multi-turn Context Management ## Priority HIGH - Required for conversational agents
Mark 2026-06-16 03:05:59 +00:00
Author
Owner

Review Summary: CONV-001 Conversation Interface Infrastructure

Verdict: PARTIAL — data structures only, no integration.

Implemented

  • Thread and Turn dataclasses in substrate/ledger/models.py:370-472 with to_dict()/from_dict() and JSON metadata handling.

Critical Gaps

  1. No DB schema — threads/turns tables missing from substrate/ledger/schema.py init_db().
  2. No repository — substrate/ledger/repositories/ has no ThreadRepository.
  3. No ledger ops — MeshLedger has zero thread/turn methods (create_thread, get_thread, add_turn, get_thread_history, etc.).
  4. No API endpoints — docker/api_gateway.py lacks POST /threads, GET /threads/{id}, POST /threads/{id}/intents, GET /threads/{id}/history, DELETE /threads/{id}.
  5. Intent payload not extended — submit_intent() does not accept thread_id/context_window.
  6. Workers don't receive context — EphemeralWorker._execute_single_intent() ignores thread context.
  7. No tests — zero coverage in tests/unit/test_ledger.py or elsewhere.

Acceptance Criteria

Criterion Status
Thread can be created via API FAIL
Intents can reference thread_id FAIL
Workers receive thread context FAIL
Thread history retrievable FAIL
Threads can be closed/archived FAIL
  1. Add threads/turns tables + indexes in schema.py.
  2. Create ThreadRepository in substrate/ledger/repositories/.
  3. Add MeshLedger.create_thread/get_thread/add_turn/get_thread_history/close_thread/archive_thread.
  4. Add the 5 thread endpoints to api_gateway.py.
  5. Extend submit_intent to accept + forward thread_id and context_window.
  6. Update EphemeralWorker to read thread context from env and pass into execution.
  7. Add unit + integration tests for models, repository, API, and worker flow.

The models are well-designed but completely disconnected from persistence, API, and runtime. Closing this as a model-only stub does not satisfy the spec.

## Review Summary: CONV-001 Conversation Interface Infrastructure **Verdict: PARTIAL — data structures only, no integration.** ### Implemented - `Thread` and `Turn` dataclasses in `substrate/ledger/models.py:370-472` with `to_dict()`/`from_dict()` and JSON metadata handling. ### Critical Gaps 1. **No DB schema** — `threads`/`turns` tables missing from `substrate/ledger/schema.py` `init_db()`. 2. **No repository** — `substrate/ledger/repositories/` has no `ThreadRepository`. 3. **No ledger ops** — `MeshLedger` has zero thread/turn methods (`create_thread`, `get_thread`, `add_turn`, `get_thread_history`, etc.). 4. **No API endpoints** — `docker/api_gateway.py` lacks `POST /threads`, `GET /threads/{id}`, `POST /threads/{id}/intents`, `GET /threads/{id}/history`, `DELETE /threads/{id}`. 5. **Intent payload not extended** — `submit_intent()` does not accept `thread_id`/`context_window`. 6. **Workers don't receive context** — `EphemeralWorker._execute_single_intent()` ignores thread context. 7. **No tests** — zero coverage in `tests/unit/test_ledger.py` or elsewhere. ### Acceptance Criteria | Criterion | Status | |---|---| | Thread can be created via API | FAIL | | Intents can reference thread_id | FAIL | | Workers receive thread context | FAIL | | Thread history retrievable | FAIL | | Threads can be closed/archived | FAIL | ### Recommended Next Steps 1. Add `threads`/`turns` tables + indexes in `schema.py`. 2. Create `ThreadRepository` in `substrate/ledger/repositories/`. 3. Add `MeshLedger.create_thread/get_thread/add_turn/get_thread_history/close_thread/archive_thread`. 4. Add the 5 thread endpoints to `api_gateway.py`. 5. Extend `submit_intent` to accept + forward `thread_id` and `context_window`. 6. Update `EphemeralWorker` to read thread context from env and pass into execution. 7. Add unit + integration tests for models, repository, API, and worker flow. The models are well-designed but completely disconnected from persistence, API, and runtime. Closing this as a model-only stub does not satisfy the spec.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/mesh-seed#131
No description provided.