Step 660: inference job generator model

This commit is contained in:
Bill
2026-02-17 22:14:21 -07:00
parent c5d7b5b0ad
commit 782af1a77f
4 changed files with 90 additions and 0 deletions

View File

@@ -4819,4 +4819,13 @@ target_link_libraries(step659_test PRIVATE
tree_sitter_javascript tree_sitter_typescript
tree_sitter_java tree_sitter_rust tree_sitter_go)
add_executable(step660_test tests/step660_test.cpp)
target_include_directories(step660_test PRIVATE src)
target_link_libraries(step660_test PRIVATE
nlohmann_json::nlohmann_json
unofficial::tree-sitter::tree-sitter
tree_sitter_python tree_sitter_cpp tree_sitter_elisp
tree_sitter_javascript tree_sitter_typescript
tree_sitter_java tree_sitter_rust tree_sitter_go)
# Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies)

View File

@@ -0,0 +1,32 @@
#pragma once
// Step 660: whetstone_generate_inference_job MCP tool model
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
using json = nlohmann::json;
class InferenceJobGenerator {
public:
static std::string toolName() { return "whetstone_generate_inference_job"; }
static json generate(const std::string& goal,
int entropyScore,
const std::vector<std::string>& files,
const std::string& bounty = "normal") {
if (goal.empty() || entropyScore < 0) {
return {{"success", false}, {"error", "invalid_input"}};
}
return {
{"success", true},
{"job", {
{"type", "refactor"},
{"goal", goal},
{"context", {{"files", files}, {"entropy_score", entropyScore}}},
{"bounty", bounty}
}}
};
}
};

View File

@@ -0,0 +1,24 @@
// Step 660: whetstone_generate_inference_job MCP tool (12 tests)
#include "InferenceJobGenerator.h"
#include <iostream>
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(tool_name_matches_spec);C(InferenceJobGenerator::toolName()=="whetstone_generate_inference_job","tool");P();}
void t2(){T(rejects_empty_goal);auto j=InferenceJobGenerator::generate("",1,{"a.cpp"});C(!j.value("success",true),"should fail");P();}
void t3(){T(rejects_negative_entropy);auto j=InferenceJobGenerator::generate("goal",-1,{"a.cpp"});C(!j.value("success",true),"should fail");P();}
void t4(){T(generates_success_for_valid_input);auto j=InferenceJobGenerator::generate("goal",3,{"a.cpp"});C(j.value("success",false),"success");P();}
void t5(){T(job_type_is_refactor);auto j=InferenceJobGenerator::generate("goal",3,{"a.cpp"});C(j["job"].value("type","")=="refactor","type");P();}
void t6(){T(goal_is_preserved);auto j=InferenceJobGenerator::generate("extract common logic",3,{"a.cpp"});C(j["job"].value("goal","")=="extract common logic","goal");P();}
void t7(){T(entropy_score_is_in_context);auto j=InferenceJobGenerator::generate("goal",7,{"a.cpp"});C(j["job"]["context"].value("entropy_score",-1)==7,"score");P();}
void t8(){T(files_are_included_in_context);auto j=InferenceJobGenerator::generate("goal",3,{"a.cpp","b.cpp"});C(j["job"]["context"]["files"].size()==2,"files");P();}
void t9(){T(default_bounty_is_normal);auto j=InferenceJobGenerator::generate("goal",3,{"a.cpp"});C(j["job"].value("bounty","")=="normal","bounty");P();}
void t10(){T(custom_bounty_is_respected);auto j=InferenceJobGenerator::generate("goal",3,{"a.cpp"},"high");C(j["job"].value("bounty","")=="high","bounty");P();}
void t11(){T(empty_files_allowed);auto j=InferenceJobGenerator::generate("goal",1,{});C(j.value("success",false),"empty files allowed");P();}
void t12(){T(error_code_present_on_invalid_input);auto j=InferenceJobGenerator::generate("",1,{"a.cpp"});C(j.value("error","")=="invalid_input","error");P();}
int main(){std::cout<<"Step 660: Inference job generator\n";t1();t2();t3();t4();t5();t6();t7();t8();t9();t10();t11();t12();std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";return f?1:0;}

View File

@@ -13600,3 +13600,28 @@ unused exports with scoring and refactor-threshold recommendation logic.
- `editor/src/EntropyScannerModel.h` (`65` <= `600`)
- `editor/tests/step659_test.cpp` within test-file size guidance (`24` lines)
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
### Step 660: `whetstone_generate_inference_job` MCP tool
**Status:** PASS (12/12 tests)
Adds inference-job generation model for entropy observations with structured
job payload output (`type`, `goal`, `context.files`, `context.entropy_score`,
`bounty`) and input validation/error signaling.
**Files added:**
- `editor/src/InferenceJobGenerator.h` - inference-job generator model
- `editor/tests/step660_test.cpp` - 12 tests for generation and validation paths
**Files modified:**
- `editor/CMakeLists.txt` - `step660_test` target
**Verification run:**
- `cmake -S editor -B editor/build-native` - PASS
- `cmake --build editor/build-native --target step660_test step659_test` - PASS
- `./editor/build-native/step660_test` - PASS (12/12)
- `./editor/build-native/step659_test` - PASS (12/12) regression coverage
**Architecture gate check:**
- `editor/src/InferenceJobGenerator.h` (`32` <= `600`)
- `editor/tests/step660_test.cpp` within test-file size guidance (`24` lines)
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`