11#include <nlohmann/json.hpp>
19using json = nlohmann::json;
33inline bool su8_is_cont(uint8_t b) {
return (b & 0xC0) == 0x80; }
40inline int su8_follow(uint8_t b) {
42 if (b < 0x80) { n = 0; }
43 else if (b >= 0xC2 && b < 0xE0) { n = 1; }
44 else if (b >= 0xE0 && b < 0xF0) { n = 2; }
45 else if (b >= 0xF0 && b < 0xF5) { n = 3; }
54inline bool su8_first_cont_ok(uint8_t lead, uint8_t c1) {
55 bool ok = su8_is_cont(c1);
56 if (lead == 0xE0) {
ok =
ok && c1 >= 0xA0; }
57 else if (lead == 0xED) {
ok =
ok && c1 <= 0x9F; }
58 else if (lead == 0xF0) {
ok =
ok && c1 >= 0x90; }
59 else if (lead == 0xF4) {
ok =
ok && c1 <= 0x8F; }
68size_t su8_seq_len(
const uint8_t* p,
const uint8_t* end) {
69 int n = su8_follow(*p);
71 && (n == 0 || (p + n < end && su8_first_cont_ok(*p, p[1])));
72 for (
int i = 2;
ok && i <= n; ++i) {
ok = su8_is_cont(p[i]); }
73 return ok ?
static_cast<size_t>(n + 1) : 0;
83std::string sanitize_storage_utf8(
const std::string& s) {
84 static constexpr const char* kRepl =
"\xEF\xBF\xBD";
85 const auto* p =
reinterpret_cast<const uint8_t*
>(s.data());
86 const auto* end = p + s.size();
88 out.reserve(s.size());
90 size_t len = su8_seq_len(p, end);
92 out.append(
reinterpret_cast<const char*
>(p), len);
114static std::string
col_text(sqlite3_stmt* stmt,
int col) {
115 auto* p = sqlite3_column_text(stmt, col);
116 return p ?
reinterpret_cast<const char*
>(p) :
"";
127static std::optional<std::string>
col_opt_text(sqlite3_stmt* stmt,
int col) {
128 auto* p = sqlite3_column_text(stmt, col);
129 if (!p)
return std::nullopt;
130 return std::string(
reinterpret_cast<const char*
>(p));
142 if (sqlite3_column_type(stmt, col) == SQLITE_NULL) {
return json(
nullptr); }
143 return json(sqlite3_column_int(stmt, col));
155 const std::optional<std::string>& val) {
157 sqlite3_bind_text(stmt, idx, val->c_str(), -1, SQLITE_TRANSIENT);
159 sqlite3_bind_null(stmt, idx);
172 const std::optional<int>& val) {
174 sqlite3_bind_int(stmt, idx, *val);
176 sqlite3_bind_null(stmt, idx);
189 const std::filesystem::path& db_path)
223 const std::string& title,
224 const std::optional<std::string>& project_path,
225 const std::optional<std::string>& model_id) {
229 "INSERT INTO conversations "
230 "(id, title, created_at, updated_at, project_path, model_id, metadata) "
231 "VALUES (?, ?, ?, ?, ?, ?, ?)",
232 [&](sqlite3_stmt* s) {
233 sqlite3_bind_text(s, 1, rec.id.c_str(), -1, SQLITE_TRANSIENT);
234 sqlite3_bind_text(s, 2, rec.title.c_str(), -1, SQLITE_TRANSIENT);
235 sqlite3_bind_text(s, 3, rec.created_at.c_str(), -1, SQLITE_TRANSIENT);
236 sqlite3_bind_text(s, 4, rec.updated_at.c_str(), -1, SQLITE_TRANSIENT);
239 sqlite3_bind_text(s, 7, rec.metadata.c_str(), -1, SQLITE_TRANSIENT);
246 logger->error(
"Failed to create conversation '{}' — INSERT did not "
247 "land, returning empty id", rec.id);
248 return std::string{};
250 logger->info(
"Created conversation: {}", rec.id);
261 std::string tool_calls;
262 std::string tool_results;
263 long long token_count;
265 std::optional<std::string> tier;
275MessageRow build_message_row(
const json& m) {
278 r.role = m.value(
"role",
"");
279 r.content = m.value(
"content",
"");
280 r.tool_calls = m.contains(
"tool_calls") ? m[
"tool_calls"].dump() :
"[]";
282 m.contains(
"tool_results") ? m[
"tool_results"].dump() :
"[]";
283 r.token_count = m.value(
"token_count", 0);
284 r.is_compacted = m.value(
"is_compacted",
false);
285 if (m.contains(
"identity_tier") && !m[
"identity_tier"].is_null()) {
286 r.tier = m[
"identity_tier"].get<std::string>();
300void bind_message_insert(sqlite3_stmt* s,
const std::string& conversation_id,
301 const std::string& now,
const MessageRow& r) {
302 sqlite3_bind_text(s, 1, r.id.c_str(), -1, SQLITE_TRANSIENT);
303 sqlite3_bind_text(s, 2, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
304 sqlite3_bind_text(s, 3, r.role.c_str(), -1, SQLITE_TRANSIENT);
305 sqlite3_bind_text(s, 4, r.content.c_str(), -1, SQLITE_TRANSIENT);
306 sqlite3_bind_text(s, 5, r.tool_calls.c_str(), -1, SQLITE_TRANSIENT);
307 sqlite3_bind_text(s, 6, r.tool_results.c_str(), -1, SQLITE_TRANSIENT);
308 sqlite3_bind_int64(s, 7, r.token_count);
309 sqlite3_bind_text(s, 8,
now.c_str(), -1, SQLITE_TRANSIENT);
310 sqlite3_bind_int(s, 9, r.is_compacted ? 1 : 0);
325 const std::string& conversation_id,
326 const std::string& messages_json) {
329 "UPDATE conversations SET updated_at = ? WHERE id = ?",
330 [&](sqlite3_stmt* s) {
331 sqlite3_bind_text(s, 1, now.c_str(), -1, SQLITE_TRANSIENT);
332 sqlite3_bind_text(s, 2, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
335 auto msgs = json::parse(messages_json,
nullptr,
false);
336 if (!msgs.is_array()) {
337 logger->error(
"save_messages: invalid JSON array");
341 static constexpr const char* kInsertSql =
342 "INSERT INTO messages "
343 "(id, conversation_id, role, content, tool_calls, tool_results, "
344 "token_count, created_at, is_compacted, identity_tier) "
345 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
350 for (
const auto& m : msgs) {
351 auto row = build_message_row(m);
352 all_ok &= db_.
execute(kInsertSql, [&](sqlite3_stmt* s) {
353 bind_message_insert(s, conversation_id, now, row);
358 logger->error(
"save_messages: one or more rows failed to insert for "
359 "conversation '{}' ({} message(s) attempted)",
360 conversation_id, msgs.size());
374json conversation_row_to_json(sqlite3_stmt* s) {
382 o[
"metadata"] = json::parse(
col_text(s, 6),
nullptr,
false);
393json message_row_to_json(sqlite3_stmt* s) {
398 m[
"tool_calls"] = json::parse(
col_text(s, 4),
nullptr,
false);
399 m[
"tool_results"] = json::parse(
col_text(s, 5),
nullptr,
false);
400 m[
"token_count"] = sqlite3_column_int64(s, 6);
402 m[
"is_compacted"] = sqlite3_column_int(s, 8) != 0;
418 const std::string& conversation_id,
419 std::string& result_json) {
422 "SELECT * FROM conversations WHERE id = ?",
423 [&](sqlite3_stmt* s) {
424 sqlite3_bind_text(s, 1, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
426 [&](sqlite3_stmt* s) { conv_obj = conversation_row_to_json(s); });
428 if (!found)
return false;
430 json messages = json::array();
432 "SELECT * FROM messages WHERE conversation_id = ? "
433 "ORDER BY created_at ASC",
434 [&](sqlite3_stmt* s) {
435 sqlite3_bind_text(s, 1, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
437 [&](sqlite3_stmt* s) {
438 messages.push_back(message_row_to_json(s));
442 result[
"conversation"] = std::move(conv_obj);
443 result[
"messages"] = std::move(messages);
444 result_json = result.dump();
458 int limit,
int offset, std::string& result_json) {
459 json arr = json::array();
461 "SELECT c.id, c.title, c.updated_at, c.project_path, "
462 "COUNT(m.id) as message_count "
463 "FROM conversations c "
464 "LEFT JOIN messages m ON c.id = m.conversation_id "
466 "ORDER BY c.updated_at DESC "
468 [&](sqlite3_stmt* s) {
469 sqlite3_bind_int(s, 1, limit);
470 sqlite3_bind_int(s, 2, offset);
472 [&](sqlite3_stmt* s) {
476 entry[
"updated_at"] =
col_text(s, 2);
477 entry[
"project_path"] =
col_opt_text(s, 3).value_or(
"");
478 entry[
"message_count"] = sqlite3_column_int(s, 4);
479 arr.push_back(std::move(entry));
482 result_json = arr.dump();
495 const std::string& conversation_id) {
497 "DELETE FROM conversations WHERE id = ?",
498 [&](sqlite3_stmt* s) {
499 sqlite3_bind_text(s, 1, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
501 if (
ok) logger->info(
"Deleted conversation: {}", conversation_id);
514 const std::string& conversation_id,
515 const std::string& title) {
517 "UPDATE conversations SET title = ? WHERE id = ?",
518 [&](sqlite3_stmt* s) {
519 sqlite3_bind_text(s, 1, title.c_str(), -1, SQLITE_TRANSIENT);
520 sqlite3_bind_text(s, 2, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
536 const std::string& query,
int limit,
537 std::string& result_json) {
538 json arr = json::array();
540 "SELECT DISTINCT c.id, c.title, c.updated_at, "
541 "snippet(messages_fts, 0, '>>>', '<<<', '...', 32) as snippet "
543 "JOIN messages m ON messages_fts.rowid = m.rowid "
544 "JOIN conversations c ON m.conversation_id = c.id "
545 "WHERE messages_fts MATCH ? "
548 [&](sqlite3_stmt* s) {
549 sqlite3_bind_text(s, 1, query.c_str(), -1, SQLITE_TRANSIENT);
550 sqlite3_bind_int(s, 2, limit);
552 [&](sqlite3_stmt* s) {
556 entry[
"updated_at"] =
col_text(s, 2);
558 arr.push_back(std::move(entry));
561 result_json = arr.dump();
582 sqlite3_bind_text(s, 1, rec.
id.c_str(), -1, SQLITE_TRANSIENT);
584 -1, SQLITE_TRANSIENT);
586 -1, SQLITE_TRANSIENT);
588 -1, SQLITE_TRANSIENT);
590 -1, SQLITE_TRANSIENT);
591 sqlite3_bind_text(s, 6, rec.
task.c_str(), -1, SQLITE_TRANSIENT);
593 sqlite3_bind_text(s, 8, rec.
status.c_str(), -1, SQLITE_TRANSIENT);
595 sqlite3_bind_text(s, 10, rec.
created_at.c_str(),
596 -1, SQLITE_TRANSIENT);
620 const std::string& parent_conversation_id,
621 const std::string& delegating_tier,
622 const std::string& target_tier,
623 std::string& delegation_id,
624 std::string& child_conversation_id) {
625 if (!parent_conversation_id.empty()) {
return true; }
626 logger->error(
"create_delegation refused: parent_conversation_id "
627 "is empty (delegating_tier={}, target_tier={}). "
628 "Root conversation must be created before "
629 "delegating (gh#48).",
630 delegating_tier, target_tier);
631 delegation_id.clear();
632 child_conversation_id.clear();
650 const std::string& parent_conversation_id,
651 const std::string& delegating_tier,
652 const std::string& target_tier,
653 const std::string& task,
655 std::string& delegation_id,
656 std::string& child_conversation_id) {
658 delegating_tier, target_tier,
660 child_conversation_id)) {
664 auto child_title =
"Delegation: " + target_tier +
" — " +
667 child_title, std::nullopt, target_tier);
670 parent_conversation_id, child_conversation_id,
671 delegating_tier, target_tier, task);
672 if (max_turns > 0) rec.max_turns = max_turns;
673 rec.status =
"running";
676 "INSERT INTO delegations "
677 "(id, parent_conversation_id, child_conversation_id, "
678 "delegating_tier, target_tier, task, max_turns, "
679 "status, result_summary, created_at, completed_at) "
680 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
683 delegation_id = rec.id;
690 logger->info(
"Created delegation {}: {} -> {}",
691 rec.id, delegating_tier, target_tier);
693 logger->error(
"Failed to insert delegation {} ({} -> {}): "
694 "parent_conversation_id='{}' — check the SQL "
695 "execute error logged immediately above",
696 rec.id, delegating_tier, target_tier,
697 parent_conversation_id);
712 const std::string& delegation_id,
713 const std::string& status,
714 const std::optional<std::string>& result_summary) {
717 "UPDATE delegations "
718 "SET status = ?, result_summary = ?, completed_at = ? "
720 [&](sqlite3_stmt* s) {
721 sqlite3_bind_text(s, 1, status.c_str(), -1, SQLITE_TRANSIENT);
723 sqlite3_bind_text(s, 3, now.c_str(), -1, SQLITE_TRANSIENT);
724 sqlite3_bind_text(s, 4, delegation_id.c_str(), -1, SQLITE_TRANSIENT);
737json delegation_row_to_json(sqlite3_stmt* s) {
740 entry[
"parent_conversation_id"] =
col_text(s, 1);
741 entry[
"child_conversation_id"] =
col_text(s, 2);
742 entry[
"delegating_tier"] =
col_text(s, 3);
743 entry[
"target_tier"] =
col_text(s, 4);
744 entry[
"task"] = sanitize_storage_utf8(
col_text(s, 5));
747 entry[
"result_summary"] = sanitize_storage_utf8(
col_opt_text(s, 8).value_or(
""));
748 entry[
"created_at"] =
col_text(s, 9);
749 entry[
"completed_at"] =
col_opt_text(s, 10).value_or(
"");
764json delegation_summary_to_json(sqlite3_stmt* s) {
767 entry[
"parent_conversation_id"] =
col_text(s, 1);
768 entry[
"child_conversation_id"] =
col_text(s, 2);
769 entry[
"delegating_tier"] =
col_text(s, 3);
770 entry[
"target_tier"] =
col_text(s, 4);
771 entry[
"task"] = sanitize_storage_utf8(
col_text(s, 5));
773 entry[
"result_summary"] = sanitize_storage_utf8(
col_opt_text(s, 8).value_or(
""));
774 entry[
"completed_at"] =
col_opt_text(s, 10).value_or(
"");
790 const std::string& conversation_id,
791 std::string& result_json) {
792 json arr = json::array();
794 "SELECT * FROM delegations "
795 "WHERE parent_conversation_id = ? "
796 "ORDER BY created_at ASC",
797 [&](sqlite3_stmt* s) {
798 sqlite3_bind_text(s, 1, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
800 [&](sqlite3_stmt* s) {
801 arr.push_back(delegation_row_to_json(s));
804 result_json = arr.dump();
818 const std::string& delegation_id,
819 std::string& result_json) {
823 "SELECT * FROM delegations WHERE id = ? LIMIT 1",
824 [&](sqlite3_stmt* s) {
825 sqlite3_bind_text(s, 1, delegation_id.c_str(), -1,
828 [&](sqlite3_stmt* s) {
830 entry = delegation_row_to_json(s);
835 result_json = entry.dump();
855 const std::string& query,
int max_results,
856 std::string& result_json) {
857 json arr = json::array();
858 std::string like =
"%" + query +
"%";
860 "SELECT * FROM delegations "
861 "WHERE result_summary LIKE ? AND status = 'completed' "
862 "ORDER BY completed_at DESC LIMIT ?",
863 [&](sqlite3_stmt* s) {
864 sqlite3_bind_text(s, 1, like.c_str(), -1, SQLITE_TRANSIENT);
865 sqlite3_bind_int(s, 2, max_results);
867 [&](sqlite3_stmt* s) {
868 arr.push_back(delegation_summary_to_json(s));
870 result_json = arr.dump();
885 const std::string& conversation_id,
886 const std::string& messages_json) {
891 auto msgs = json::parse(messages_json,
nullptr,
false);
892 int msg_count = msgs.is_array() ?
static_cast<int>(msgs.size()) : 0;
895 "INSERT INTO compaction_snapshots "
896 "(id, conversation_id, messages_json, message_count, "
897 "token_count_estimate, created_at) "
898 "VALUES (?, ?, ?, ?, NULL, ?)",
899 [&](sqlite3_stmt* s) {
900 sqlite3_bind_text(s, 1, snap_id.c_str(), -1, SQLITE_TRANSIENT);
901 sqlite3_bind_text(s, 2, conversation_id.c_str(), -1, SQLITE_TRANSIENT);
902 sqlite3_bind_text(s, 3, messages_json.c_str(), -1, SQLITE_TRANSIENT);
903 sqlite3_bind_int(s, 4, msg_count);
904 sqlite3_bind_text(s, 5, now.c_str(), -1, SQLITE_TRANSIENT);
918 int64_t total_convs = 0;
919 int64_t total_msgs = 0;
920 int64_t total_tokens = 0;
922 db_.
fetch_one(
"SELECT COUNT(*) FROM conversations",
924 [&](sqlite3_stmt* s) { total_convs = sqlite3_column_int64(s, 0); });
926 db_.
fetch_one(
"SELECT COUNT(*) FROM messages",
928 [&](sqlite3_stmt* s) { total_msgs = sqlite3_column_int64(s, 0); });
930 db_.
fetch_one(
"SELECT COALESCE(SUM(token_count), 0) FROM messages",
932 [&](sqlite3_stmt* s) { total_tokens = sqlite3_column_int64(s, 0); });
935 stats[
"total_conversations"] = total_convs;
936 stats[
"total_messages"] = total_msgs;
937 stats[
"total_tokens"] = total_tokens;
938 result_json = stats.dump();
951 static thread_local std::mt19937 gen(std::random_device{}());
952 std::uniform_int_distribution<uint32_t> dist(0, 15);
953 std::uniform_int_distribution<uint32_t> dist2(8, 11);
955 const char hex[] =
"0123456789abcdef";
956 std::string uuid(36,
'-');
959 static constexpr int positions[] = {
960 0,1,2,3,4,5,6,7, 9,10,11,12, 14,15,16,17,
961 19,20,21,22, 24,25,26,27,28,29,30,31,32,33,34,35
964 for (
int pos : positions) {
965 uuid[pos] = hex[dist(gen)];
968 uuid[19] = hex[dist2(gen)];
980 auto now = std::chrono::system_clock::now();
981 auto time = std::chrono::system_clock::to_time_t(now);
983 gmtime_r(&time, &utc);
986 std::strftime(buf,
sizeof(buf),
"%Y-%m-%dT%H:%M:%S", &utc);
1000 const std::string& title,
1001 const std::optional<std::string>& project_path,
1002 const std::optional<std::string>& model_id) {
1004 return {
generate_uuid(), title, now, now, project_path, model_id,
"{}"};
1020 const std::string& parent_conversation_id,
1021 const std::string& child_conversation_id,
1022 const std::string& delegating_tier,
1023 const std::string& target_tier,
1024 const std::string& task) {
1026 child_conversation_id, delegating_tier, target_tier,
1027 task, std::nullopt,
"pending", std::nullopt,
bool execute(std::string_view sql, std::function< void(sqlite3_stmt *)> binder=nullptr)
Execute a write statement (INSERT, UPDATE, DELETE).
void close()
Close database connection.
size_t fetch_all(std::string_view sql, std::function< void(sqlite3_stmt *)> binder, std::function< void(sqlite3_stmt *)> row_handler)
Fetch all matching rows.
bool fetch_one(std::string_view sql, std::function< void(sqlite3_stmt *)> binder, std::function< void(sqlite3_stmt *)> extractor)
Fetch a single row.
bool initialize()
Initialize database and run pending migrations.
bool save_messages(const std::string &conversation_id, const std::string &messages_json)
Save messages to a 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 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 update_title(const std::string &conversation_id, const std::string &title)
Update a conversation's title.
SqliteStorageBackend(const std::filesystem::path &db_path)
Construct with database file path.
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 search_conversations(const std::string &query, int limit, std::string &result_json)
Full-text search across conversations.
bool get_delegations(const std::string &conversation_id, std::string &result_json)
Get delegations for a parent conversation.
bool save_snapshot(const std::string &conversation_id, const std::string &messages_json)
Save a pre-compaction snapshot of full conversation history.
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.
void close()
Close storage and database connection.
bool load_conversation(const std::string &conversation_id, std::string &result_json)
Load a conversation with messages.
bool get_stats(std::string &result_json)
Get storage statistics.
bool delete_conversation(const std::string &conversation_id)
Delete a conversation and all associated records.
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 list_conversations(int limit, int offset, std::string &result_json)
List conversations with pagination.
bool initialize()
Initialize storage (open database, run migrations).
spdlog initialization and logger access.
auto now()
Get current time for timing measurements.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Activate model on GPU (WARM → ACTIVE).
static std::string col_text(sqlite3_stmt *stmt, int col)
Get text from a sqlite3 column, returning empty string for NULL.
std::string utc_timestamp()
Get current UTC time as ISO 8601 string.
@ ok
Tool dispatched, returned non-empty content.
static void bind_opt_int(sqlite3_stmt *stmt, int idx, const std::optional< int > &val)
Bind optional int to a parameter position (NULL if unset).
static void bind_opt_text(sqlite3_stmt *stmt, int idx, const std::optional< std::string > &val)
Bind optional text to a parameter position.
static bool guard_parent_conversation(const std::string &parent_conversation_id, const std::string &delegating_tier, const std::string &target_tier, std::string &delegation_id, std::string &child_conversation_id)
Reject an empty parent_conversation_id with a clear error and reset the out params (gh#48 defense-in-...
std::string generate_uuid()
Generate a UUID v4 string.
static void bind_delegation_insert(sqlite3_stmt *s, const DelegationRecord &rec)
Bind a Delegation record onto the delegations-INSERT statement's 11 placeholders.
ConversationRecord make_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 ConversationRecord with generated UUID and timestamps.
static json col_nullable_int(sqlite3_stmt *stmt, int col)
Get a nullable integer column as a JSON value.
static std::optional< std::string > col_opt_text(sqlite3_stmt *stmt, int col)
Get optional text from a sqlite3 column.
DelegationRecord make_delegation(const std::string &parent_conversation_id, const std::string &child_conversation_id, const std::string &delegating_tier, const std::string &target_tier, const std::string &task)
Create a new DelegationRecord with generated UUID and timestamp.
SqliteStorageBackend — conversation persistence via SQLite.
Database record for a conversation.
Database record for a delegation.
std::string target_tier
Target tier for child loop.
std::string created_at
ISO 8601 timestamp.
std::string delegating_tier
Tier that initiated delegation.
std::string status
pending/running/completed/failed
std::optional< std::string > completed_at
Completion timestamp (nullable)
std::optional< int > max_turns
Turn limit (nullable)
std::string parent_conversation_id
Parent conversation FK.
std::optional< std::string > result_summary
Result summary (nullable)
std::string task
Task description.
std::string id
UUID primary key.
std::string child_conversation_id
Child conversation FK.