Add Sprints 46-59: governance, porting foundation, and language graduation prep (Steps 689-828)
Sprints 46-58 implement the cross-language porting foundation: language-to-IR adapters, equivalence checking, gate validation, legacy ingestion, managed/dynamic families, low-level/logic-actor semantics, debug workflow tooling, AST-native family tools, Rust/CPP raising tools, system-level orchestration, query family, and porting gates. Sprint 59 adds the governance layer (policy packs, review boards, waiver packets, ambiguity triage, decision ledger) with the whetstone_review_porting_decision MCP tool. Also includes: sprint plans 46-130, MCP taskitem pipeline scripts, CLAUDE.md, docs, and full test matrix (steps 689-828). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
32
editor/src/cpp_ir/CppAlgorithmLifting.h
Normal file
32
editor/src/cpp_ir/CppAlgorithmLifting.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
// Step 715: STL algorithm lifting from intent tags.
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
class CppAlgorithmLifting {
|
||||
public:
|
||||
static std::set<std::string> lift(const SemanticCoreIR& ir) {
|
||||
std::set<std::string> out;
|
||||
for (const auto& n : ir.nodes) {
|
||||
for (const auto& t : n.intentTags) {
|
||||
if (t == "algorithmic") out.insert("std::transform");
|
||||
if (t == "pure") out.insert("std::accumulate");
|
||||
if (t == "io") out.insert("std::for_each");
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const std::set<std::string>& algos) {
|
||||
nlohmann::json j = nlohmann::json::array();
|
||||
for (const auto& a : algos) j.push_back(a);
|
||||
return j;
|
||||
}
|
||||
};
|
||||
38
editor/src/cpp_ir/CppAsyncMappingStrategy.h
Normal file
38
editor/src/cpp_ir/CppAsyncMappingStrategy.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
// Step 714: async mapping strategy.
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
struct CppAsyncDecision {
|
||||
std::string nodeId;
|
||||
std::string runtimeProfile; // coroutine_std, task_runtime
|
||||
};
|
||||
|
||||
class CppAsyncMappingStrategy {
|
||||
public:
|
||||
static std::vector<CppAsyncDecision> map(const SemanticCoreIR& ir,
|
||||
const std::string& profile = "safe-first") {
|
||||
std::vector<CppAsyncDecision> out;
|
||||
for (const auto& n : ir.nodes) {
|
||||
if (n.kind != IRNodeKind::ConcurrencyRegion && n.kind != IRNodeKind::Function) continue;
|
||||
bool hasAsync = false;
|
||||
for (const auto& t : n.intentTags) if (t == "async") hasAsync = true;
|
||||
if (!hasAsync) continue;
|
||||
out.push_back({n.id, profile == "interop-first" ? "task_runtime" : "coroutine_std"});
|
||||
}
|
||||
std::sort(out.begin(), out.end(), [](const auto& a, const auto& b){ return a.nodeId < b.nodeId; });
|
||||
return out;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const std::vector<CppAsyncDecision>& d) {
|
||||
nlohmann::json j = nlohmann::json::array();
|
||||
for (const auto& x : d) j.push_back({{"nodeId", x.nodeId}, {"runtimeProfile", x.runtimeProfile}});
|
||||
return j;
|
||||
}
|
||||
};
|
||||
45
editor/src/cpp_ir/CppBorrowMappingStrategy.h
Normal file
45
editor/src/cpp_ir/CppBorrowMappingStrategy.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
// Step 710: borrow semantics to references/views.
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
struct CppBorrowDecision {
|
||||
std::string fromId;
|
||||
std::string toId;
|
||||
std::string cppForm; // const_ref, mut_ref, span_view
|
||||
};
|
||||
|
||||
class CppBorrowMappingStrategy {
|
||||
public:
|
||||
static std::vector<CppBorrowDecision> map(const SemanticCoreIR& ir,
|
||||
const std::string& profile = "safe-first") {
|
||||
std::vector<CppBorrowDecision> out;
|
||||
for (const auto& e : ir.edges) {
|
||||
if (e.relation != "borrows" && e.relation != "borrows_mut") continue;
|
||||
CppBorrowDecision d;
|
||||
d.fromId = e.fromId;
|
||||
d.toId = e.toId;
|
||||
if (e.relation == "borrows_mut") d.cppForm = "mut_ref";
|
||||
else if (profile == "perf-first") d.cppForm = "span_view";
|
||||
else d.cppForm = "const_ref";
|
||||
out.push_back(std::move(d));
|
||||
}
|
||||
std::sort(out.begin(), out.end(), [](const auto& a, const auto& b) {
|
||||
if (a.fromId != b.fromId) return a.fromId < b.fromId;
|
||||
return a.toId < b.toId;
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const std::vector<CppBorrowDecision>& d) {
|
||||
nlohmann::json j = nlohmann::json::array();
|
||||
for (const auto& x : d) j.push_back({{"fromId", x.fromId}, {"toId", x.toId}, {"cppForm", x.cppForm}});
|
||||
return j;
|
||||
}
|
||||
};
|
||||
38
editor/src/cpp_ir/CppBuildArtifactGenerator.h
Normal file
38
editor/src/cpp_ir/CppBuildArtifactGenerator.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
// Step 716: build artifact generator.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
struct CppBuildArtifacts {
|
||||
std::string cmakeLists;
|
||||
std::vector<std::string> headers;
|
||||
std::vector<std::string> sources;
|
||||
};
|
||||
|
||||
class CppBuildArtifactGenerator {
|
||||
public:
|
||||
static CppBuildArtifacts generate(const std::string& projectName,
|
||||
const std::string& profile = "safe-first") {
|
||||
CppBuildArtifacts a;
|
||||
const std::string target = projectName.empty() ? "generated_cpp" : projectName;
|
||||
a.cmakeLists =
|
||||
"cmake_minimum_required(VERSION 3.20)\n"
|
||||
"project(" + target + " LANGUAGES CXX)\n"
|
||||
"set(CMAKE_CXX_STANDARD 20)\n"
|
||||
"add_library(" + target + " STATIC src/generated.cpp)\n"
|
||||
"target_include_directories(" + target + " PUBLIC include)\n";
|
||||
if (profile == "safe-first") {
|
||||
a.cmakeLists += "target_compile_definitions(" + target + " PUBLIC CPP_SAFE_FIRST=1)\n";
|
||||
}
|
||||
a.headers = {"include/generated.hpp"};
|
||||
a.sources = {"src/generated.cpp"};
|
||||
return a;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const CppBuildArtifacts& a) {
|
||||
return {{"cmakeLists", a.cmakeLists}, {"headers", a.headers}, {"sources", a.sources}};
|
||||
}
|
||||
};
|
||||
38
editor/src/cpp_ir/CppErrorModelMapping.h
Normal file
38
editor/src/cpp_ir/CppErrorModelMapping.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
// Step 713: error model mapping policy.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
struct CppErrorModelDecision {
|
||||
std::string profile;
|
||||
std::string resultType; // expected, status_or, exceptions
|
||||
bool panicTranslatedToTerminate = false;
|
||||
};
|
||||
|
||||
class CppErrorModelMapping {
|
||||
public:
|
||||
static CppErrorModelDecision map(const SemanticCoreIR& ir,
|
||||
const std::string& profile = "safe-first") {
|
||||
CppErrorModelDecision d;
|
||||
d.profile = profile;
|
||||
if (profile == "interop-first") d.resultType = "status_or";
|
||||
else if (profile == "perf-first") d.resultType = "expected";
|
||||
else d.resultType = "expected";
|
||||
|
||||
const std::string dump = ir.contracts.dump();
|
||||
d.panicTranslatedToTerminate = dump.find("panic") != std::string::npos;
|
||||
return d;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const CppErrorModelDecision& d) {
|
||||
return {
|
||||
{"profile", d.profile},
|
||||
{"resultType", d.resultType},
|
||||
{"panicTranslatedToTerminate", d.panicTranslatedToTerminate}
|
||||
};
|
||||
}
|
||||
};
|
||||
59
editor/src/cpp_ir/CppOwnershipMappingPolicy.h
Normal file
59
editor/src/cpp_ir/CppOwnershipMappingPolicy.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
// Step 709: ownership mapping policy engine.
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
struct CppOwnershipDecision {
|
||||
std::string nodeId;
|
||||
std::string strategy; // unique_ptr, shared_ptr, value
|
||||
std::string reason;
|
||||
};
|
||||
|
||||
class CppOwnershipMappingPolicy {
|
||||
public:
|
||||
static std::vector<CppOwnershipDecision> map(const SemanticCoreIR& ir,
|
||||
const std::string& profile = "safe-first") {
|
||||
std::vector<CppOwnershipDecision> out;
|
||||
for (const auto& n : ir.nodes) {
|
||||
if (n.kind != IRNodeKind::OwnershipRegion && n.kind != IRNodeKind::Type) continue;
|
||||
CppOwnershipDecision d;
|
||||
d.nodeId = n.id;
|
||||
if (hasTag(n, "shared")) {
|
||||
d.strategy = "shared_ptr";
|
||||
d.reason = "shared_access_detected";
|
||||
} else if (hasTag(n, "stateful") || profile == "safe-first") {
|
||||
d.strategy = "unique_ptr";
|
||||
d.reason = "exclusive_owner_default";
|
||||
} else {
|
||||
d.strategy = "value";
|
||||
d.reason = "perf_value_default";
|
||||
}
|
||||
if (profile == "interop-first" && d.strategy == "unique_ptr") {
|
||||
d.strategy = "value";
|
||||
d.reason = "interop_abi_friendly";
|
||||
}
|
||||
out.push_back(std::move(d));
|
||||
}
|
||||
std::sort(out.begin(), out.end(), [](const auto& a, const auto& b) { return a.nodeId < b.nodeId; });
|
||||
return out;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const std::vector<CppOwnershipDecision>& d) {
|
||||
nlohmann::json j = nlohmann::json::array();
|
||||
for (const auto& x : d) j.push_back({{"nodeId", x.nodeId}, {"strategy", x.strategy}, {"reason", x.reason}});
|
||||
return j;
|
||||
}
|
||||
|
||||
private:
|
||||
static bool hasTag(const IRNode& n, const std::string& tag) {
|
||||
for (const auto& t : n.intentTags) if (t == tag) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
42
editor/src/cpp_ir/CppTemplateRaisingPolicy.h
Normal file
42
editor/src/cpp_ir/CppTemplateRaisingPolicy.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
// Step 712: generics/template raising policy.
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
struct CppTemplateDecision {
|
||||
std::string nodeId;
|
||||
std::string templateForm; // class_template, fn_template, concrete
|
||||
bool conceptConstrained = false;
|
||||
};
|
||||
|
||||
class CppTemplateRaisingPolicy {
|
||||
public:
|
||||
static std::vector<CppTemplateDecision> raise(const SemanticCoreIR& ir,
|
||||
const std::string& profile = "safe-first") {
|
||||
std::vector<CppTemplateDecision> out;
|
||||
for (const auto& n : ir.nodes) {
|
||||
if (!n.metadata.contains("genericParams")) continue;
|
||||
CppTemplateDecision d;
|
||||
d.nodeId = n.id;
|
||||
d.templateForm = (n.kind == IRNodeKind::Type) ? "class_template" : "fn_template";
|
||||
d.conceptConstrained = profile != "interop-first";
|
||||
out.push_back(std::move(d));
|
||||
}
|
||||
std::sort(out.begin(), out.end(), [](const auto& a, const auto& b){ return a.nodeId < b.nodeId; });
|
||||
return out;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const std::vector<CppTemplateDecision>& v) {
|
||||
nlohmann::json j = nlohmann::json::array();
|
||||
for (const auto& d : v) {
|
||||
j.push_back({{"nodeId", d.nodeId}, {"templateForm", d.templateForm}, {"conceptConstrained", d.conceptConstrained}});
|
||||
}
|
||||
return j;
|
||||
}
|
||||
};
|
||||
39
editor/src/cpp_ir/CppTraitRaising.h
Normal file
39
editor/src/cpp_ir/CppTraitRaising.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
// Step 711: trait-to-interface/composition raising.
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "SemanticCoreIR.h"
|
||||
|
||||
struct CppTraitArtifact {
|
||||
std::string name;
|
||||
std::string kind; // interface/composition
|
||||
};
|
||||
|
||||
class CppTraitRaising {
|
||||
public:
|
||||
static std::vector<CppTraitArtifact> raise(const SemanticCoreIR& ir,
|
||||
const std::string& profile = "safe-first") {
|
||||
std::vector<CppTraitArtifact> out;
|
||||
for (const auto& n : ir.nodes) {
|
||||
if (n.kind != IRNodeKind::Type) continue;
|
||||
if (!n.annotations.contains("trait")) continue;
|
||||
CppTraitArtifact a;
|
||||
a.name = n.name;
|
||||
a.kind = profile == "perf-first" ? "composition" : "interface";
|
||||
out.push_back(std::move(a));
|
||||
}
|
||||
std::sort(out.begin(), out.end(), [](const auto& a, const auto& b) { return a.name < b.name; });
|
||||
return out;
|
||||
}
|
||||
|
||||
static nlohmann::json toJson(const std::vector<CppTraitArtifact>& v) {
|
||||
nlohmann::json j = nlohmann::json::array();
|
||||
for (const auto& a : v) j.push_back({{"name", a.name}, {"kind", a.kind}});
|
||||
return j;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user