Wire availableLibraries into taskitem generation dispatch
This commit is contained in:
@@ -39,6 +39,9 @@
|
||||
#include "ASTFeatureExtractor.h"
|
||||
#include "LanguageIdiomProfile.h"
|
||||
#include "LanguageFitnessScorer.h"
|
||||
#include "TaskitemLibraryAnnotator.h"
|
||||
#include "Sprint286IntegrationSummary.h"
|
||||
#include "Sprint288IntegrationSummary.h"
|
||||
#include "PolyglotProjectSpec.h"
|
||||
#include "ABIBoundaryExtractor.h"
|
||||
#include "FFIGlueDispatcher.h"
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
{"description", "Normalized requirements from whetstone_architect_intake."}}},
|
||||
{"conflicts", {{"type", "array"},
|
||||
{"description", "Optional requirement conflicts from whetstone_architect_intake."}}},
|
||||
{"availableLibraries", {{"type", "array"},
|
||||
{"description", "Optional candidate libraries for deterministic library/API dispatch."}}},
|
||||
{"strictExecutionContract", {{"type", "boolean"},
|
||||
{"description", "Require concrete execution contract metadata (stepIds/files/tools/tests)."}}}
|
||||
}}, {"required", json::array({"normalizedRequirements"})}}
|
||||
@@ -477,10 +479,50 @@
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> availableLibraries;
|
||||
if (args.contains("availableLibraries")) {
|
||||
if (!args["availableLibraries"].is_array()) {
|
||||
return {
|
||||
{"success", false},
|
||||
{"error", "available_libraries_not_array"}
|
||||
};
|
||||
}
|
||||
for (const auto& libJson : args["availableLibraries"]) {
|
||||
if (!libJson.is_string()) {
|
||||
return {
|
||||
{"success", false},
|
||||
{"error", "available_library_entry_not_string"}
|
||||
};
|
||||
}
|
||||
const std::string lib = libJson.get<std::string>();
|
||||
if (lib.empty()) continue;
|
||||
bool seen = false;
|
||||
for (const auto& existing : availableLibraries) {
|
||||
if (existing == lib) {
|
||||
seen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!seen) availableLibraries.push_back(lib);
|
||||
}
|
||||
}
|
||||
const bool libraryDispatchEnabled = !availableLibraries.empty();
|
||||
auto capabilityLedger = whetstone::Sprint286IntegrationSummary::buildSeedLedger();
|
||||
auto symbolCatalog = whetstone::Sprint288IntegrationSummary::buildSeedCatalog();
|
||||
whetstone::TaskitemLibraryAnnotator libraryAnnotator;
|
||||
std::string libraryDispatchContext;
|
||||
for (const auto& requirement : normalized.requirements) {
|
||||
if (!requirement.normalizedText.empty()) {
|
||||
if (!libraryDispatchContext.empty()) libraryDispatchContext.push_back(' ');
|
||||
libraryDispatchContext += requirement.normalizedText;
|
||||
}
|
||||
}
|
||||
|
||||
const bool strictExecutionContract = args.value("strictExecutionContract", false);
|
||||
const json executionHints = collectExecutionHints(normalized.requirements);
|
||||
int escalateCount = 0;
|
||||
int missingContractCount = 0;
|
||||
int enrichedTaskCount = 0;
|
||||
json tasksJson = json::array();
|
||||
for (const auto& task : annotated) {
|
||||
json taskJson = {
|
||||
@@ -496,6 +538,31 @@
|
||||
{"reasons", task.reasons}
|
||||
};
|
||||
json contract = buildExecutionContract(task, executionHints, strictExecutionContract);
|
||||
if (libraryDispatchEnabled) {
|
||||
std::string dispatchText = task.base.title;
|
||||
if (!libraryDispatchContext.empty()) {
|
||||
dispatchText += " ";
|
||||
dispatchText += libraryDispatchContext;
|
||||
}
|
||||
auto enriched = libraryAnnotator.annotate(dispatchText, availableLibraries, capabilityLedger, symbolCatalog);
|
||||
if (enriched.isEnriched()) {
|
||||
contract["selectedLibrary"] = enriched.selectedLibrary;
|
||||
contract["operationDomain"] = enriched.operationDomain;
|
||||
contract["capabilityScore"] = enriched.capabilityScore;
|
||||
contract["preferredAPIs"] = enriched.preferredAPIs;
|
||||
contract["justification"] = enriched.justification;
|
||||
json avoided = json::array();
|
||||
for (const auto& item : enriched.avoidedLibraries) {
|
||||
avoided.push_back({
|
||||
{"name", item.name},
|
||||
{"reason", item.reason},
|
||||
{"score", item.score}
|
||||
});
|
||||
}
|
||||
contract["avoidedLibraries"] = avoided;
|
||||
++enrichedTaskCount;
|
||||
}
|
||||
}
|
||||
taskJson["executionContract"] = contract;
|
||||
taskJson["resourceLocks"] = inferResourceLocks(task);
|
||||
if (strictExecutionContract && contract.value("executionSpecificityScore", 0) < 60) {
|
||||
@@ -522,7 +589,12 @@
|
||||
{"ambiguousRequirementCount", countAmbiguousRequirements(normalized.requirements)},
|
||||
{"escalateCount", escalateCount},
|
||||
{"strictExecutionContract", strictExecutionContract},
|
||||
{"missingExecutionContractCount", missingContractCount}
|
||||
{"missingExecutionContractCount", missingContractCount},
|
||||
{"libraryDispatch", {
|
||||
{"enabled", libraryDispatchEnabled},
|
||||
{"availableLibraries", availableLibraries},
|
||||
{"enrichedTaskCount", enrichedTaskCount}
|
||||
}}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user