Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
i_storage_backend.h File Reference

Pure C interface contract for storage backends. More...

#include <entropic/types/error.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for i_storage_backend.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct entropic_storage_backendentropic_storage_backend_t
 Opaque handle to a storage backend instance.
 

Functions

ENTROPIC_EXPORT entropic_storage_backend_t entropic_storage_create (const char *db_path)
 Create a storage backend with SQLite at the given path.
 
ENTROPIC_EXPORT entropic_error_t entropic_storage_initialize (entropic_storage_backend_t storage)
 Initialize storage (run migrations, create tables).
 
ENTROPIC_EXPORT void entropic_storage_destroy (entropic_storage_backend_t storage)
 Destroy storage and close connections.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
ENTROPIC_EXPORT entropic_error_t entropic_storage_get_stats (entropic_storage_backend_t storage, char **result_json)
 Get storage statistics.
 

Detailed Description

Pure C interface contract for storage backends.

Defines the .so boundary for librentropic-storage. All functions accept/return C types only (opaque handles, const char*, error codes). No C++ types cross this boundary.

Storage is fully optional. NULL handle checks are the consumer's responsibility — passing NULL to any function returns an error code.

Version
1.8.8

Definition in file i_storage_backend.h.

Typedef Documentation

◆ entropic_storage_backend_t

Opaque handle to a storage backend instance.

Definition at line 28 of file i_storage_backend.h.

Function Documentation

◆ entropic_storage_complete_delegation()

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.

Parameters
storageStorage handle.
delegation_idDelegation ID.
status"completed" or "failed".
result_summarySummary text or NULL.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Mark a delegation as completed or failed.

Parameters
storageHandle.
delegation_idDelegation ID.
statusStatus string.
result_summaryOptional summary.
Returns
Error code.

Definition at line 333 of file c_interface.cpp.

◆ entropic_storage_create()

ENTROPIC_EXPORT entropic_storage_backend_t entropic_storage_create ( const char *  db_path)

Create a storage backend with SQLite at the given path.

Parameters
db_pathPath to SQLite database file. Created if absent.
Returns
Storage handle, or NULL on failure.
Version
1.8.8

Create a storage backend with SQLite at the given path.

Parameters
db_pathDatabase file path.
Returns
Handle or NULL.

Definition at line 80 of file c_interface.cpp.

◆ entropic_storage_create_conversation()

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.

Parameters
storageStorage handle.
titleConversation title (null-terminated).
project_pathProject path or NULL.
model_idModel identifier or NULL.
Returns
Conversation ID string. Caller must free with entropic_free(). NULL on failure.
Version
1.8.8

Create a new conversation.

Parameters
storageHandle.
titleTitle.
project_pathOptional project path.
model_idOptional model ID.
Returns
Conversation ID (caller frees) or NULL.

Definition at line 131 of file c_interface.cpp.

◆ entropic_storage_create_delegation()

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.

Parameters
storageStorage handle.
parent_conversation_idParent conversation ID.
delegating_tierTier initiating delegation.
target_tierTarget tier for child loop.
taskTask description.
max_turnsMax turns for child (0 for unlimited).
result_jsonOutput: JSON with "delegation_id" and "child_conversation_id". Caller must free.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Create a delegation record with a child conversation.

Parameters
storageHandle.
parent_conversation_idParent conversation.
delegating_tierSource tier.
target_tierTarget tier.
taskTask description.
max_turnsTurn limit.
result_jsonOutput JSON.
Returns
Error code.

Definition at line 294 of file c_interface.cpp.

◆ entropic_storage_delete_conversation()

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.

Parameters
storageStorage handle.
conversation_idConversation ID.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Delete a conversation and all associated records.

Parameters
storageHandle.
conversation_idConversation ID.
Returns
Error code.

Definition at line 264 of file c_interface.cpp.

◆ entropic_storage_destroy()

ENTROPIC_EXPORT void entropic_storage_destroy ( entropic_storage_backend_t  storage)

Destroy storage and close connections.

Parameters
storageStorage handle (NULL-safe).
Version
1.8.8

Destroy storage and close connections.

Parameters
storageHandle (NULL-safe).

Definition at line 115 of file c_interface.cpp.

◆ entropic_storage_get_delegations()

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.

Parameters
storageStorage handle.
conversation_idParent conversation ID.
result_jsonOutput: JSON array of delegation records. Caller must free.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Get delegations for a parent conversation.

Parameters
storageHandle.
conversation_idParent conversation.
result_jsonOutput JSON.
Returns
Error code.

Definition at line 360 of file c_interface.cpp.

◆ entropic_storage_get_stats()

ENTROPIC_EXPORT entropic_error_t entropic_storage_get_stats ( entropic_storage_backend_t  storage,
char **  result_json 
)

Get storage statistics.

Parameters
storageStorage handle.
result_jsonOutput: JSON with total_conversations, total_messages, total_tokens. Caller must free.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Get storage statistics.

Parameters
storageHandle.
result_jsonOutput JSON.
Returns
Error code.

Definition at line 415 of file c_interface.cpp.

◆ entropic_storage_initialize()

ENTROPIC_EXPORT entropic_error_t entropic_storage_initialize ( entropic_storage_backend_t  storage)

Initialize storage (run migrations, create tables).

Parameters
storageStorage handle.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Initialize storage (run migrations, create tables).

Parameters
storageHandle.
Returns
Error code.

Definition at line 98 of file c_interface.cpp.

◆ entropic_storage_list_conversations()

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.

Parameters
storageStorage handle.
limitMax results.
offsetPagination offset.
result_jsonOutput: JSON array of conversation summaries. Caller must free with entropic_free().
Returns
ENTROPIC_OK on success.
Version
1.8.8

List conversations with pagination.

Parameters
storageHandle.
limitMax results.
offsetOffset.
result_jsonOutput JSON.
Returns
Error code.

Definition at line 210 of file c_interface.cpp.

◆ entropic_storage_load_conversation()

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.

Parameters
storageStorage handle.
conversation_idConversation ID.
result_jsonOutput: JSON with "conversation" and "messages". Caller must free with entropic_free().
Returns
ENTROPIC_OK on success, ENTROPIC_ERROR_INVALID_ARGUMENT if not found.
Version
1.8.8

Load a conversation with messages.

Parameters
storageHandle.
conversation_idConversation ID.
result_jsonOutput JSON.
Returns
Error code.

Definition at line 181 of file c_interface.cpp.

◆ entropic_storage_save_conversation()

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
storageStorage handle.
conversation_idConversation ID.
messages_jsonJSON array of message objects.
Returns
ENTROPIC_OK on success.
Version
1.8.8
Parameters
storageHandle.
conversation_idConversation ID.
messages_jsonJSON array.
Returns
Error code.

Definition at line 156 of file c_interface.cpp.

◆ entropic_storage_save_snapshot()

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.

Parameters
storageStorage handle.
conversation_idConversation ID.
messages_jsonJSON array of all messages before compaction.
Returns
ENTROPIC_OK on success.
Version
1.8.8

Save a pre-compaction snapshot of full conversation history.

Parameters
storageHandle.
conversation_idConversation ID.
messages_jsonJSON messages.
Returns
Error code.

Definition at line 389 of file c_interface.cpp.

◆ entropic_storage_search_conversations()

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.

Parameters
storageStorage handle.
queryFTS5 query string.
limitMax results.
result_jsonOutput: JSON array of search results with snippets. Caller must free with entropic_free().
Returns
ENTROPIC_OK on success.
Version
1.8.8

Full-text search across conversations.

Parameters
storageHandle.
queryFTS5 query.
limitMax results.
result_jsonOutput JSON.
Returns
Error code.

Definition at line 238 of file c_interface.cpp.