|
Entropic 2.3.8
Local-first agentic inference engine
|
SQLite-based storage backend. More...
#include <entropic/storage/backend.h>
Public Member Functions | |
| SqliteStorageBackend (const std::filesystem::path &db_path) | |
| Construct with database file path. | |
| bool | initialize () |
| Initialize storage (open database, run migrations). | |
| void | close () |
| Close storage and database connection. | |
| std::string | create_conversation (const std::string &title="New Conversation", const std::optional< std::string > &project_path=std::nullopt, const std::optional< std::string > &model_id=std::nullopt) |
| Create a new conversation. | |
| bool | save_messages (const std::string &conversation_id, const std::string &messages_json) |
| Save messages to a conversation. | |
| bool | load_conversation (const std::string &conversation_id, std::string &result_json) |
| Load a conversation with messages. | |
| bool | list_conversations (int limit, int offset, std::string &result_json) |
| List conversations with pagination. | |
| bool | delete_conversation (const std::string &conversation_id) |
| Delete a conversation and all associated records. | |
| bool | update_title (const std::string &conversation_id, const std::string &title) |
| Update a conversation's title. | |
| bool | search_conversations (const std::string &query, int limit, std::string &result_json) |
| Full-text search across conversations. | |
| bool | create_delegation (const std::string &parent_conversation_id, const std::string &delegating_tier, const std::string &target_tier, const std::string &task, int max_turns, std::string &delegation_id, std::string &child_conversation_id) |
| Create a delegation record with a child conversation. | |
| bool | complete_delegation (const std::string &delegation_id, const std::string &status, const std::optional< std::string > &result_summary=std::nullopt) |
| Mark a delegation as completed or failed. | |
| bool | get_delegations (const std::string &conversation_id, std::string &result_json) |
| Get delegations for a parent conversation. | |
| bool | get_delegation_by_id (const std::string &delegation_id, std::string &result_json) |
| Look up a single delegation record by id (gh#32, v2.1.6). | |
| bool | search_delegations (const std::string &query, int max_results, std::string &result_json) |
| Search delegations across all conversations (gh#32, v2.1.6). | |
| bool | save_snapshot (const std::string &conversation_id, const std::string &messages_json) |
| Save a pre-compaction snapshot of full conversation history. | |
| bool | get_stats (std::string &result_json) |
| Get storage statistics. | |
SQLite-based storage backend.
Provides conversation persistence, message storage, delegation record management, full-text search, and compaction snapshots. Thread-safe via SqliteDatabase's internal mutex.
|
explicit |
Construct with database file path.
| db_path | Path to SQLite database file. |
| db_path | Path to SQLite file. |
Definition at line 97 of file backend.cpp.
| void entropic::SqliteStorageBackend::close | ( | ) |
Close storage and database connection.
Close storage.
Definition at line 116 of file backend.cpp.
| bool entropic::SqliteStorageBackend::complete_delegation | ( | const std::string & | delegation_id, |
| const std::string & | status, | ||
| const std::optional< std::string > & | result_summary = std::nullopt |
||
| ) |
Mark a delegation as completed or failed.
| delegation_id | Delegation ID. |
| status | "completed" or "failed". |
| result_summary | Summary text (optional). |
| delegation_id | Delegation ID. |
| status | "completed" or "failed". |
| result_summary | Optional summary text. |
Definition at line 602 of file backend.cpp.
| std::string entropic::SqliteStorageBackend::create_conversation | ( | const std::string & | title = "New Conversation", |
| const std::optional< std::string > & | project_path = std::nullopt, |
||
| const std::optional< std::string > & | model_id = std::nullopt |
||
| ) |
Create a new conversation.
| title | Conversation title. |
| project_path | Project path (optional). |
| model_id | Model identifier (optional). |
| title | Conversation title. |
| project_path | Optional project path. |
| model_id | Optional model identifier. |
Definition at line 131 of file backend.cpp.
| bool entropic::SqliteStorageBackend::create_delegation | ( | const std::string & | parent_conversation_id, |
| const std::string & | delegating_tier, | ||
| const std::string & | target_tier, | ||
| const std::string & | task, | ||
| int | max_turns, | ||
| std::string & | delegation_id, | ||
| std::string & | child_conversation_id | ||
| ) |
Create a delegation record with a child conversation.
Create a delegation with a child conversation.
| parent_conversation_id | Parent conversation ID. | |
| delegating_tier | Tier initiating delegation. | |
| target_tier | Target tier for child loop. | |
| task | Task description. | |
| max_turns | Max turns for child (0 = unlimited). | |
| [out] | delegation_id | Created delegation ID. |
| [out] | child_conversation_id | Created child conversation ID. |
| parent_conversation_id | Parent conversation. | |
| delegating_tier | Source tier. | |
| target_tier | Target tier. | |
| task | Task description. | |
| max_turns | Turn limit (0 = unlimited). | |
| [out] | delegation_id | Created delegation ID. |
| [out] | child_conversation_id | Created child conversation ID. |
Definition at line 540 of file backend.cpp.
| bool entropic::SqliteStorageBackend::delete_conversation | ( | const std::string & | conversation_id | ) |
Delete a conversation and all associated records.
Delete a conversation and all cascading records.
| conversation_id | Conversation ID. |
| conversation_id | Conversation ID. |
Definition at line 385 of file backend.cpp.
| bool entropic::SqliteStorageBackend::get_delegation_by_id | ( | const std::string & | delegation_id, |
| std::string & | result_json | ||
| ) |
Look up a single delegation record by id (gh#32, v2.1.6).
Used by entropic.followup and entropic.resume_delegation to resolve a delegation's target_tier and child_conversation_id without scanning all parents.
| delegation_id | Delegation id. | |
| [out] | result_json | Single-object JSON with the delegation row. |
| delegation_id | Delegation id. | |
| [out] | result_json | Object JSON of the delegation row. |
Definition at line 708 of file backend.cpp.
| bool entropic::SqliteStorageBackend::get_delegations | ( | const std::string & | conversation_id, |
| std::string & | result_json | ||
| ) |
Get delegations for a parent conversation.
| conversation_id | Parent conversation ID. | |
| [out] | result_json | JSON array of delegation records. |
| conversation_id | Parent conversation ID. | |
| [out] | result_json | JSON array of delegation records. |
Definition at line 681 of file backend.cpp.
| bool entropic::SqliteStorageBackend::get_stats | ( | std::string & | result_json | ) |
Get storage statistics.
| [out] | result_json | JSON with total_conversations, total_messages, total_tokens. |
| [out] | result_json | JSON with counts. |
Definition at line 807 of file backend.cpp.
| bool entropic::SqliteStorageBackend::initialize | ( | ) |
Initialize storage (open database, run migrations).
Initialize storage.
Definition at line 107 of file backend.cpp.
| bool entropic::SqliteStorageBackend::list_conversations | ( | int | limit, |
| int | offset, | ||
| std::string & | result_json | ||
| ) |
List conversations with pagination.
| limit | Maximum results. | |
| offset | Pagination offset. | |
| [out] | result_json | JSON array of conversation summaries. |
| limit | Max results. | |
| offset | Pagination offset. | |
| [out] | result_json | JSON array of summaries. |
Definition at line 349 of file backend.cpp.
| bool entropic::SqliteStorageBackend::load_conversation | ( | const std::string & | conversation_id, |
| std::string & | result_json | ||
| ) |
Load a conversation with messages.
Load a conversation with its messages.
| conversation_id | Conversation ID. | |
| [out] | result_json | JSON with "conversation" and "messages". |
| conversation_id | Conversation ID. | |
| [out] | result_json | JSON result. |
Definition at line 309 of file backend.cpp.
| bool entropic::SqliteStorageBackend::save_messages | ( | const std::string & | conversation_id, |
| const std::string & | messages_json | ||
| ) |
Save messages to a conversation.
| conversation_id | Conversation ID. |
| messages_json | JSON array of message objects. |
| conversation_id | Conversation ID. |
| messages_json | JSON array of message objects. |
Definition at line 225 of file backend.cpp.
| bool entropic::SqliteStorageBackend::save_snapshot | ( | const std::string & | conversation_id, |
| const std::string & | messages_json | ||
| ) |
Save a pre-compaction snapshot of full conversation history.
Save a pre-compaction snapshot.
| conversation_id | Conversation ID. |
| messages_json | JSON array of all messages before compaction. |
| conversation_id | Conversation ID. |
| messages_json | JSON array of all messages. |
Definition at line 774 of file backend.cpp.
| bool entropic::SqliteStorageBackend::search_conversations | ( | const std::string & | query, |
| int | limit, | ||
| std::string & | result_json | ||
| ) |
Full-text search across conversations.
Full-text search across conversations via FTS5.
| query | FTS5 query string. | |
| limit | Maximum results. | |
| [out] | result_json | JSON array of search results with snippets. |
| query | FTS5 query string. | |
| limit | Max results. | |
| [out] | result_json | JSON array of search results. |
Definition at line 426 of file backend.cpp.
| bool entropic::SqliteStorageBackend::search_delegations | ( | const std::string & | query, |
| int | max_results, | ||
| std::string & | result_json | ||
| ) |
Search delegations across all conversations (gh#32, v2.1.6).
Substring-match delegations across all conversations.
Substring match against result_summary (case-insensitive). Returns the top-N most recently completed delegations whose summary contains query.
| query | Keyword/phrase to match. | |
| max_results | Maximum records to return. | |
| [out] | result_json | JSON array of matching delegation rows. |
Bound to top-N most recently completed records. Uses sqlite's LIKE for portability — FTS5 is wired for messages, not delegation summaries.
| query | Substring to match (LIKE query%). | |
| max_results | Cap on returned rows. | |
| [out] | result_json | JSON array of delegation rows. |
Definition at line 744 of file backend.cpp.
| bool entropic::SqliteStorageBackend::update_title | ( | const std::string & | conversation_id, |
| const std::string & | title | ||
| ) |
Update a conversation's title.
| conversation_id | Conversation ID. |
| title | New title. |
| conversation_id | Conversation ID. |
| title | New title. |
Definition at line 404 of file backend.cpp.