Files
whetstone_DSL/editor/src/cpp_ir/CppTraitRaising.h
Bill 1696b92bb8 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>
2026-02-22 13:18:10 -07:00

40 lines
1.2 KiB
C++

#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;
}
};