Remove the browser UI, its Python server and the web API contract test. Add the Qt6 tray app (status, findings, process search, policy controls, notifications) and EvidenceStore, the read-only view of the daemon's evidence that the app and MCP server share. The GUI demo config becomes strawberry.demo.conf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
// EvidenceStore (the app/MCP read-only view) over the event store: it sees
|
|
// the daemon's writes through Database::refresh(), reports "nothing changed"
|
|
// when nothing did, and explains missing/legacy paths.
|
|
|
|
#include "strawberry/evidence_store.hpp"
|
|
|
|
#include <cassert>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
#include <unistd.h>
|
|
|
|
namespace fs = std::filesystem;
|
|
using namespace strawberry;
|
|
|
|
int main() {
|
|
const fs::path root = fs::temp_directory_path() / ("sb-evidence-store-" + std::to_string(::getpid()));
|
|
fs::remove_all(root);
|
|
fs::create_directories(root);
|
|
const std::string path = (root / "evidence.db").string();
|
|
|
|
EvidenceStore view;
|
|
view.set_path(path);
|
|
assert(!view.reload_if_changed());
|
|
assert(!view.available() && view.error().find("no evidence stored yet") != std::string::npos);
|
|
|
|
Database writer;
|
|
assert(writer.open(path));
|
|
assert(view.reload_if_changed() && view.available());
|
|
assert(view.findings().empty());
|
|
assert(!view.reload_if_changed()); // nothing changed
|
|
|
|
FindingRecord f;
|
|
f.id = "finding-1";
|
|
f.title = "t";
|
|
f.severity = "high";
|
|
f.score = 80;
|
|
assert(writer.store_finding(f));
|
|
assert(view.reload_if_changed());
|
|
assert(view.findings().size() == 1 && view.finding("finding-1")->score == 80);
|
|
assert(!view.reload_if_changed());
|
|
|
|
// A transaction becomes visible on commit.
|
|
assert(writer.begin_transaction());
|
|
f.score = 90;
|
|
assert(writer.store_finding(f));
|
|
assert(writer.commit_transaction());
|
|
assert(view.reload_if_changed() && view.finding("finding-1")->score == 90);
|
|
assert(view.size_bytes() > 0);
|
|
|
|
writer.close();
|
|
assert(!view.reload_if_changed()); // close syncs; content unchanged
|
|
|
|
// A legacy database file at the path is explained, not misread.
|
|
const std::string legacy = (root / "legacy.db").string();
|
|
std::ofstream(legacy) << "not an event store";
|
|
EvidenceStore old;
|
|
old.set_path(legacy);
|
|
old.reload_if_changed();
|
|
assert(!old.available() && old.error().find("legacy") != std::string::npos);
|
|
|
|
fs::remove_all(root);
|
|
std::cout << "evidence store: PASSED" << std::endl;
|
|
return 0;
|
|
}
|