Step 139: library compatibility matrix

This commit is contained in:
Bill
2026-02-09 17:36:59 -07:00
parent dcd44d26ed
commit 8df003ab97
5 changed files with 88 additions and 2 deletions

View File

@@ -382,7 +382,7 @@ vcpkg's imgui 1.91.9 removed the `sdl2-binding` feature (only `sdl3-binding` exi
## What's Next
Sprint 5 in progress. Step 138 (type-aware code generation) done. Next: Step 139 (library compatibility matrix).
Sprint 5 in progress. Step 139 (library compatibility matrix) done. Next: Step 140 (constructive coding tests).
---
@@ -484,5 +484,6 @@ Sprint 5 in progress. Step 138 (type-aware code generation) done. Next: Step 139
| 2026-02-09 | Codex | Step 136: Agent preferImports/strictMode policy checks on mutations with warnings or blocking. 4/4 tests pass. |
| 2026-02-09 | Codex | Step 137: Composition builder panel with pipeline generation and code insertion. 4/4 tests pass. |
| 2026-02-09 | Codex | Step 138: Type-aware C++ generation via library call mappings. 2/2 tests pass. |
| 2026-02-09 | Codex | Step 139: Library compatibility matrix with default mappings. 3/3 tests pass. |
| 2026-02-09 | Codex | Added FEATURE_REQUESTS.md to track security vulnerability awareness and semantic library annotations for future sprints. |
| 2026-02-09 | Codex | Added LLM tooling + MCP bridge feature request to FEATURE_REQUESTS.md. |

View File

@@ -770,6 +770,10 @@ add_executable(step138_test tests/step138_test.cpp)
target_include_directories(step138_test PRIVATE src)
target_link_libraries(step138_test PRIVATE nlohmann_json::nlohmann_json)
add_executable(step139_test tests/step139_test.cpp)
target_include_directories(step139_test PRIVATE src)
target_link_libraries(step139_test PRIVATE nlohmann_json::nlohmann_json)
find_package(SDL2 CONFIG REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glad CONFIG REQUIRED)

View File

@@ -0,0 +1,38 @@
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
class LibraryCompatibility {
public:
void addMapping(const std::string& fromLibrary,
const std::string& fromLang,
const std::string& toLibrary,
const std::string& toLang) {
mappings_[key(fromLibrary, fromLang)].push_back({toLibrary, toLang});
}
std::vector<std::pair<std::string, std::string>> getMappings(
const std::string& fromLibrary,
const std::string& fromLang) const {
auto it = mappings_.find(key(fromLibrary, fromLang));
if (it == mappings_.end()) return {};
return it->second;
}
void loadDefaultMappings() {
addMapping("numpy", "python", "Eigen", "cpp");
addMapping("numpy", "python", "ndarray", "rust");
addMapping("pandas", "python", "dataframe", "rust");
addMapping("pandas", "python", "DataFrame", "cpp");
addMapping("requests", "python", "reqwest", "rust");
addMapping("requests", "python", "cpr", "cpp");
}
private:
static std::string key(const std::string& lib, const std::string& lang) {
return lib + "|" + lang;
}
std::unordered_map<std::string, std::vector<std::pair<std::string, std::string>>> mappings_;
};

View File

@@ -0,0 +1,43 @@
// Step 139 TDD Test: Library compatibility matrix
#include "LibraryCompatibility.h"
#include <iostream>
static void expect(bool cond, const std::string& name, int& passed, int& failed) {
if (cond) {
std::cout << "Test " << (passed + failed + 1) << " PASS: " << name << "\n";
++passed;
} else {
std::cout << "Test " << (passed + failed + 1) << " FAIL: " << name << "\n";
++failed;
}
}
int main() {
int passed = 0;
int failed = 0;
LibraryCompatibility compat;
compat.loadDefaultMappings();
auto mappings = compat.getMappings("numpy", "python");
expect(!mappings.empty(), "numpy mappings present", passed, failed);
bool hasEigen = false;
for (const auto& entry : mappings) {
if (entry.first == "Eigen" && entry.second == "cpp") {
hasEigen = true;
}
}
expect(hasEigen, "numpy -> Eigen mapping", passed, failed);
compat.addMapping("numpy", "python", "armadillo", "cpp");
auto mappings2 = compat.getMappings("numpy", "python");
bool hasArma = false;
for (const auto& entry : mappings2) {
if (entry.first == "armadillo" && entry.second == "cpp") {
hasArma = true;
}
}
expect(hasArma, "custom mapping added", passed, failed);
std::cout << "\n=== Step 139 Results: " << passed << " passed, " << failed << " failed ===\n";
return failed == 0 ? 0 : 1;
}

View File

@@ -146,7 +146,7 @@ what's already available.
Cross-language projection respects library type mappings.
*Modifies:* `CrossLanguageProjector.h`, `Generator.h`
- [ ] **Step 139: Library compatibility matrix**
- [x] **Step 139: Library compatibility matrix**
Track which libraries have equivalents across languages. Example:
`numpy` (Python) ↔ `Eigen` (C++) ↔ `ndarray` (Rust).
When projecting code cross-language, suggest equivalent libraries.