Sprint 286: OperationTaxonomy + LibraryCapabilityLedger (steps 1958-1962)
Phase 6 Library Dispatch foundation. Five new headers: - OperationDomain: dot-key hierarchy with parent traversal - LibraryCapabilityRecord: score/APIs/weaknesses + validator - LibraryCapabilityLedger: (library, domain) -> record registry - OperationTaxonomy: 40+ domain tree, keyword-based classify() - Sprint286IntegrationSummary: 8-library seed ledger + verified lookups 25/25 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
90
editor/tests/step1961_test.cpp
Normal file
90
editor/tests/step1961_test.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
// Step 1961: OperationTaxonomy
|
||||
//
|
||||
// t1: domainCount() >= 40
|
||||
// t2: topLevelCategories() has >= 6 entries
|
||||
// t3: classify("serialize to JSON") == "serialization.json"
|
||||
// t4: classify("matrix multiply on GPU") == "compute.matrix"
|
||||
// t5: classify with several known domains; unknown text returns "unknown"
|
||||
|
||||
#include "OperationTaxonomy.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace ws = whetstone;
|
||||
static int p = 0, f = 0;
|
||||
#define T(n) { std::cout << " " << #n << "... "; }
|
||||
#define P() { std::cout << "PASS\n"; ++p; }
|
||||
#define F(m) { std::cout << "FAIL: " << m << "\n"; ++f; }
|
||||
#define C(c, m) if (!(c)) { F(m); return; }
|
||||
|
||||
void t1() {
|
||||
T(domain_count_at_least_40);
|
||||
auto tax = ws::OperationTaxonomy::buildDefault();
|
||||
auto count = tax.domainCount();
|
||||
C(count >= 40, "at least 40 domains (got " + std::to_string(count) + ")");
|
||||
P();
|
||||
}
|
||||
|
||||
void t2() {
|
||||
T(top_level_categories_at_least_6);
|
||||
auto tax = ws::OperationTaxonomy::buildDefault();
|
||||
auto cats = tax.topLevelCategories();
|
||||
C(cats.size() >= 6, "at least 6 top-level categories (got " + std::to_string(cats.size()) + ")");
|
||||
// Must include the 6 core categories from the plan
|
||||
bool hasSer = false, hasCom = false, hasNet = false;
|
||||
bool hasIo = false, hasCry = false, hasDb = false;
|
||||
for (const auto& c : cats) {
|
||||
if (c == "serialization") hasSer = true;
|
||||
if (c == "compute") hasCom = true;
|
||||
if (c == "network") hasNet = true;
|
||||
if (c == "io") hasIo = true;
|
||||
if (c == "crypto") hasCry = true;
|
||||
if (c == "db") hasDb = true;
|
||||
}
|
||||
C(hasSer && hasCom && hasNet && hasIo && hasCry && hasDb,
|
||||
"all 6 core categories present");
|
||||
P();
|
||||
}
|
||||
|
||||
void t3() {
|
||||
T(classify_serialize_to_json);
|
||||
auto tax = ws::OperationTaxonomy::buildDefault();
|
||||
auto domain = tax.classify("serialize to JSON");
|
||||
C(domain == "serialization.json",
|
||||
"expected serialization.json, got " + domain);
|
||||
// Also check uppercase input is handled
|
||||
auto domain2 = tax.classify("SERIALIZE TO JSON");
|
||||
C(domain2 == "serialization.json", "uppercase handled");
|
||||
P();
|
||||
}
|
||||
|
||||
void t4() {
|
||||
T(classify_matrix_multiply_on_GPU);
|
||||
auto tax = ws::OperationTaxonomy::buildDefault();
|
||||
auto domain = tax.classify("matrix multiply on GPU");
|
||||
C(domain == "compute.matrix",
|
||||
"expected compute.matrix, got " + domain);
|
||||
auto domain2 = tax.classify("dense matrix multiplication using CUDA");
|
||||
C(domain2 == "compute.matrix", "CUDA matrix also compute.matrix");
|
||||
P();
|
||||
}
|
||||
|
||||
void t5() {
|
||||
T(classify_various_domains_and_unknown);
|
||||
auto tax = ws::OperationTaxonomy::buildDefault();
|
||||
auto h = tax.classify("compute sha256 hash of a file");
|
||||
C(h == "crypto.hash", "sha256 -> crypto.hash, got " + h);
|
||||
auto s = tax.classify("sql select query from table");
|
||||
C(s == "db.query.sql", "sql select -> db.query.sql, got " + s);
|
||||
auto y = tax.classify("parse yaml configuration file");
|
||||
C(y == "serialization.yaml", "yaml -> serialization.yaml, got " + y);
|
||||
auto u = tax.classify("xyzzy frobble zogzog");
|
||||
C(u == "unknown", "unknown text -> unknown, got " + u);
|
||||
P();
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << "Step 1961: OperationTaxonomy\n";
|
||||
t1(); t2(); t3(); t4(); t5();
|
||||
std::cout << "\n" << p << "/" << (p + f) << " passed\n";
|
||||
return f > 0 ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user