Add semantic hash table tools, lock scaffolding, and H2 dual-hash migration scaffold

This commit is contained in:
Bill
2026-02-24 11:13:31 -07:00
parent 1a761c62e5
commit f4f3633b11
12 changed files with 665 additions and 6 deletions

View File

@@ -8,6 +8,9 @@ class ASTNode {
public:
std::string id;
std::string conceptType;
std::string semanticHash; // Optional semantic identity hash: H<version>:<hex>
std::string semanticHashLockState; // "locked" or "unlocked" (empty == unlocked)
std::string semanticHashLockReason; // Optional rationale for lock transitions
ASTNode* parent = nullptr;
int spanStartLine = -1;
int spanStartCol = -1;
@@ -27,6 +30,10 @@ public:
return spanStartLine >= 0 && spanStartCol >= 0 && spanEndLine >= 0 && spanEndCol >= 0;
}
bool isSemanticHashLocked() const {
return semanticHashLockState == "locked";
}
// Multi-valued child: append to role
void addChild(const std::string& role, ASTNode* child) {
child->parent = this;

View File

@@ -602,6 +602,13 @@ inline json toJson(const ASTNode* node) {
json j;
j["id"] = node->id;
j["concept"] = node->conceptType;
if (!node->semanticHash.empty()) j["semanticHash"] = node->semanticHash;
if (node->semanticHashLockState == "locked") {
j["semanticHashLockState"] = "locked";
if (!node->semanticHashLockReason.empty()) {
j["semanticHashLockReason"] = node->semanticHashLockReason;
}
}
j["properties"] = propertiesToJson(node);
if (node->hasSpan()) {
j["span"] = {
@@ -1390,6 +1397,15 @@ inline ASTNode* fromJson(const json& j) {
node->id = j.contains("id") ? j["id"].get<std::string>()
: generateNodeId();
if (j.contains("semanticHash") && j["semanticHash"].is_string()) {
node->semanticHash = j["semanticHash"].get<std::string>();
}
if (j.contains("semanticHashLockState") && j["semanticHashLockState"].is_string()) {
node->semanticHashLockState = j["semanticHashLockState"].get<std::string>();
}
if (j.contains("semanticHashLockReason") && j["semanticHashLockReason"].is_string()) {
node->semanticHashLockReason = j["semanticHashLockReason"].get<std::string>();
}
if (j.contains("span")) {
const auto& span = j["span"];
if (span.contains("start") && span.contains("end")) {