Files
tai/taicpp/tests/store_test.cpp
T
retoor 4eff597be7 sessions: vault discovery tools, shared stdin, ctrl-key fixes
New sessions/session_export tools plus a sessions_block vault map in the system prompt (tai.py, ported to detz); recall/search carry a session footer instead of letting the model grep sealed bytes. write_file refuses new markdown at working/repo roots, and the blanket *.md gitignore is gone so docs stay visible. One LineInput owns fd 0 for every prompt (ask, approvals, shell_ask, secrets), ending phantom-empty answers; Ctrl-C re-prompts (double exits), Ctrl-D exits, Ctrl-Z suspends; mid-turn Ctrl-C announces itself and kills foreground shell children via RunInterrupted. Covered by SessionsTests, repl_keys.py pty checks, agent_diff sessions_block cases.
2026-10-28 13:11:45 +01:00

33 lines
1.8 KiB
C++

// Store smoke test (record CRUD, search, spill). The full parity suite is
// tests/foundation_parity.py; this one has no python dependency.
#include <cstdio>
#include <cstdlib>
#include <string>
#include "../src/store/spill.h"
#include "../src/store/store.h"
int main() {
using namespace detz::store;
auto st = Store::Open(":memory:");
std::string id = st->add_record("note", "hello", "the quick brown fox jumps", {"animals"});
auto r = st->get_record(id);
if (!r || r->get_string("title") != "hello") { std::puts("get_record failed"); return 1; }
if (st->search_records("fox").size() != 1) { std::puts("search_records failed"); return 1; }
if (st->fts_search("fox").empty()) { std::puts("fts_search failed"); return 1; }
if (!st->delete_record(id) || st->get_record(id)) { std::puts("delete_record failed"); return 1; }
std::string big(7000, 'x');
std::string view = Spill::spill_or_truncate(st.get(), "note", "big", big);
if (view.find("chars spilled to mem:") == std::string::npos) { std::puts("spill failed"); return 1; }
if (Spill::truncate("abc") != "abc") { std::puts("truncate failed"); return 1; }
if (!st->list_sessions("default").empty()) { std::puts("list_sessions should start empty"); return 1; }
Json m = Json::object();
m.set("role", "user");
m.set("content", "the lighthouse");
st->save_session("default", {m}, "main", "20240101-000000-p11-abcdef01");
auto sessions = st->list_sessions("default");
if (sessions.size() != 1 || sessions[0].bot != "main" || sessions[0].sid != "20240101-000000-p11-abcdef01" ||
sessions[0].messages != 1 || sessions[0].path.find(".session.20240101-000000-p11-abcdef01.json") == std::string::npos) {
std::puts("list_sessions failed"); return 1; }
std::puts("store OK");
return 0;
}