include/entropic/interfaces/i_storage_backend.h¶
include/entropic/interfaces/i_storage_backend.h
Functions
ENTROPIC_EXPORT entropic_storage_backend_t entropic_storage_create(const char *db_path)
Create a storage backend with SQLite at the given path.
Create a storage backend with SQLite at the given path.
- Parameters
db_path— Path to SQLite database file. Created if absent.db_path— Database file path.
- Returns
- Storage handle, or NULL on failure.
- Handle or NULL.
ENTROPIC_EXPORT entropic_error_t entropic_storage_initialize(entropic_storage_backend_t storage)
Initialize storage (run migrations, create tables).
Initialize storage (run migrations, create tables).
- Parameters
storage— Storage handle.storage— Handle.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT void entropic_storage_destroy(entropic_storage_backend_t storage)
Destroy storage and close connections.
Destroy storage and close connections.
- Parameters
storage— Storage handle (NULL-safe).storage— Handle (NULL-safe).
ENTROPIC_EXPORT char * entropic_storage_create_conversation(entropic_storage_backend_t storage, const char *title, const char *project_path, const char *model_id)
Create a new conversation.
Create a new conversation.
- Parameters
storage— Storage handle.title— Conversation title (null-terminated).project_path— Project path or NULL.model_id— Model identifier or NULL.storage— Handle.title— Title.project_path— Optional project path.model_id— Optional model ID.
- Returns
- Conversation ID string. Caller must free with entropic_free(). NULL on failure.
- Conversation ID (caller frees) or NULL.
ENTROPIC_EXPORT entropic_error_t entropic_storage_save_conversation(entropic_storage_backend_t storage, const char *conversation_id, const char *messages_json)
Save messages to a conversation.
- Parameters
storage— Storage handle.conversation_id— Conversation ID.messages_json— JSON array of message objects.storage— Handle.messages_json— JSON array.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_load_conversation(entropic_storage_backend_t storage, const char *conversation_id, char **result_json)
Load a conversation with messages.
Load a conversation with messages.
- Parameters
storage— Storage handle.conversation_id— Conversation ID.result_json— Output: JSON with "conversation" and "messages". Caller must free with entropic_free().storage— Handle.result_json— Output JSON.
- Returns
- ENTROPIC_OK on success, ENTROPIC_ERROR_INVALID_ARGUMENT if not found.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_list_conversations(entropic_storage_backend_t storage, int limit, int offset, char **result_json)
List conversations with pagination.
List conversations with pagination.
- Parameters
storage— Storage handle.limit— Max results.offset— Pagination offset.result_json— Output: JSON array of conversation summaries. Caller must free with entropic_free().storage— Handle.offset— Offset.result_json— Output JSON.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_search_conversations(entropic_storage_backend_t storage, const char *query, int limit, char **result_json)
Full-text search across conversations.
Full-text search across conversations.
- Parameters
storage— Storage handle.query— FTS5 query string.limit— Max results.result_json— Output: JSON array of search results with snippets. Caller must free with entropic_free().storage— Handle.query— FTS5 query.result_json— Output JSON.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_delete_conversation(entropic_storage_backend_t storage, const char *conversation_id)
Delete a conversation and all associated records.
Delete a conversation and all associated records.
- Parameters
storage— Storage handle.conversation_id— Conversation ID.storage— Handle.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_create_delegation(entropic_storage_backend_t storage, const char *parent_conversation_id, const char *delegating_tier, const char *target_tier, const char *task, int max_turns, char **result_json)
Create a delegation record with a child conversation.
Create a delegation record with a child conversation.
- Parameters
storage— Storage handle.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 for unlimited).result_json— Output: JSON with "delegation_id" and "child_conversation_id". Caller must free.storage— Handle.parent_conversation_id— Parent conversation.delegating_tier— Source tier.target_tier— Target tier.max_turns— Turn limit.result_json— Output JSON.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_complete_delegation(entropic_storage_backend_t storage, const char *delegation_id, const char *status, const char *result_summary)
Mark a delegation as completed or failed.
Mark a delegation as completed or failed.
- Parameters
storage— Storage handle.delegation_id— Delegation ID.status— "completed" or "failed".result_summary— Summary text or NULL.storage— Handle.status— Status string.result_summary— Optional summary.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_get_delegations(entropic_storage_backend_t storage, const char *conversation_id, char **result_json)
Get delegations for a parent conversation.
Get delegations for a parent conversation.
- Parameters
storage— Storage handle.conversation_id— Parent conversation ID.result_json— Output: JSON array of delegation records. Caller must free.storage— Handle.conversation_id— Parent conversation.result_json— Output JSON.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_save_snapshot(entropic_storage_backend_t storage, const char *conversation_id, const char *messages_json)
Save a pre-compaction snapshot of full conversation history.
Save a pre-compaction snapshot of full conversation history.
- Parameters
storage— Storage handle.conversation_id— Conversation ID.messages_json— JSON array of all messages before compaction.storage— Handle.messages_json— JSON messages.
- Returns
- ENTROPIC_OK on success.
- Error code.
ENTROPIC_EXPORT entropic_error_t entropic_storage_get_stats(entropic_storage_backend_t storage, char **result_json)
Get storage statistics.
Get storage statistics.
- Parameters
storage— Storage handle.result_json— Output: JSON with total_conversations, total_messages, total_tokens. Caller must free.storage— Handle.result_json— Output JSON.
- Returns
- ENTROPIC_OK on success.
- Error code.
Types
typedef struct entropic_storage_backend* entropic_storage_backend_t
Opaque handle to a storage backend instance.