Step 650: HiveMind auto-update model
This commit is contained in:
@@ -4729,4 +4729,13 @@ target_link_libraries(step649_test PRIVATE
|
|||||||
tree_sitter_javascript tree_sitter_typescript
|
tree_sitter_javascript tree_sitter_typescript
|
||||||
tree_sitter_java tree_sitter_rust tree_sitter_go)
|
tree_sitter_java tree_sitter_rust tree_sitter_go)
|
||||||
|
|
||||||
|
add_executable(step650_test tests/step650_test.cpp)
|
||||||
|
target_include_directories(step650_test PRIVATE src)
|
||||||
|
target_link_libraries(step650_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)
|
# Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies)
|
||||||
|
|||||||
41
editor/src/HiveMindAutoUpdateModel.h
Normal file
41
editor/src/HiveMindAutoUpdateModel.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
// Step 650: HiveMind-push auto-update mechanism model
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct UpdateJob {
|
||||||
|
std::string version;
|
||||||
|
std::string downloadUrl;
|
||||||
|
std::string expectedSha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UpdateExecutionResult {
|
||||||
|
bool accepted = false;
|
||||||
|
bool hashVerified = false;
|
||||||
|
bool binaryReplaced = false;
|
||||||
|
bool restartScheduled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
class HiveMindAutoUpdateModel {
|
||||||
|
public:
|
||||||
|
static bool isValidJob(const UpdateJob& job) {
|
||||||
|
return !job.version.empty() && !job.downloadUrl.empty() && !job.expectedSha256.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool verifyHash(const std::string& actualSha256,
|
||||||
|
const std::string& expectedSha256) {
|
||||||
|
return !actualSha256.empty() && actualSha256 == expectedSha256;
|
||||||
|
}
|
||||||
|
|
||||||
|
static UpdateExecutionResult execute(const UpdateJob& job,
|
||||||
|
const std::string& downloadedSha256) {
|
||||||
|
UpdateExecutionResult out;
|
||||||
|
out.accepted = isValidJob(job);
|
||||||
|
if (!out.accepted) return out;
|
||||||
|
out.hashVerified = verifyHash(downloadedSha256, job.expectedSha256);
|
||||||
|
if (!out.hashVerified) return out;
|
||||||
|
out.binaryReplaced = true;
|
||||||
|
out.restartScheduled = true;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
};
|
||||||
26
editor/tests/step650_test.cpp
Normal file
26
editor/tests/step650_test.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Step 650: HiveMind-push auto-update mechanism (12 tests)
|
||||||
|
|
||||||
|
#include "HiveMindAutoUpdateModel.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;}
|
||||||
|
|
||||||
|
static UpdateJob job(){return {"1.2.3","https://apiary/whetstone.AppImage","abc123"};}
|
||||||
|
|
||||||
|
void t1(){T(valid_job_true);C(HiveMindAutoUpdateModel::isValidJob(job()),"valid expected");P();}
|
||||||
|
void t2(){T(invalid_job_missing_version);auto j=job();j.version="";C(!HiveMindAutoUpdateModel::isValidJob(j),"invalid expected");P();}
|
||||||
|
void t3(){T(invalid_job_missing_url);auto j=job();j.downloadUrl="";C(!HiveMindAutoUpdateModel::isValidJob(j),"invalid expected");P();}
|
||||||
|
void t4(){T(invalid_job_missing_hash);auto j=job();j.expectedSha256="";C(!HiveMindAutoUpdateModel::isValidJob(j),"invalid expected");P();}
|
||||||
|
void t5(){T(hash_verify_true_for_match);C(HiveMindAutoUpdateModel::verifyHash("abc123","abc123"),"hash match");P();}
|
||||||
|
void t6(){T(hash_verify_false_for_mismatch);C(!HiveMindAutoUpdateModel::verifyHash("abc124","abc123"),"hash mismatch");P();}
|
||||||
|
void t7(){T(execute_rejects_invalid_job);auto j=job();j.version="";auto r=HiveMindAutoUpdateModel::execute(j,"abc123");C(!r.accepted,"should reject");P();}
|
||||||
|
void t8(){T(execute_accepts_valid_job);auto r=HiveMindAutoUpdateModel::execute(job(),"abc123");C(r.accepted,"should accept");P();}
|
||||||
|
void t9(){T(execute_sets_hash_verified_on_match);auto r=HiveMindAutoUpdateModel::execute(job(),"abc123");C(r.hashVerified,"hash verified");P();}
|
||||||
|
void t10(){T(execute_blocks_replace_on_hash_mismatch);auto r=HiveMindAutoUpdateModel::execute(job(),"zzz");C(!r.binaryReplaced,"replace blocked");P();}
|
||||||
|
void t11(){T(execute_replaces_binary_on_verified_hash);auto r=HiveMindAutoUpdateModel::execute(job(),"abc123");C(r.binaryReplaced,"replace expected");P();}
|
||||||
|
void t12(){T(execute_schedules_restart_on_success);auto r=HiveMindAutoUpdateModel::execute(job(),"abc123");C(r.restartScheduled,"restart expected");P();}
|
||||||
|
|
||||||
|
int main(){std::cout<<"Step 650: HiveMind auto-update mechanism\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;}
|
||||||
24
progress.md
24
progress.md
@@ -13325,3 +13325,27 @@ project release attributes.
|
|||||||
- `editor/src/PackageScriptGenerator.h` (`29` <= `600`)
|
- `editor/src/PackageScriptGenerator.h` (`29` <= `600`)
|
||||||
- `editor/tests/step649_test.cpp` within test-file size guidance (`24` lines)
|
- `editor/tests/step649_test.cpp` within test-file size guidance (`24` lines)
|
||||||
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
|
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
|
||||||
|
|
||||||
|
### Step 650: HiveMind-push auto-update mechanism
|
||||||
|
**Status:** PASS (12/12 tests)
|
||||||
|
|
||||||
|
Adds an auto-update execution model for `update_editor` jobs with job-shape
|
||||||
|
validation, hash verification, binary replace gating, and restart scheduling.
|
||||||
|
|
||||||
|
**Files added:**
|
||||||
|
- `editor/src/HiveMindAutoUpdateModel.h` - update execution model
|
||||||
|
- `editor/tests/step650_test.cpp` - 12 tests for validation, hash checks, and apply flow
|
||||||
|
|
||||||
|
**Files modified:**
|
||||||
|
- `editor/CMakeLists.txt` - `step650_test` target
|
||||||
|
|
||||||
|
**Verification run:**
|
||||||
|
- `cmake -S editor -B editor/build-native` - PASS
|
||||||
|
- `cmake --build editor/build-native --target step650_test step649_test` - PASS
|
||||||
|
- `./editor/build-native/step650_test` - PASS (12/12)
|
||||||
|
- `./editor/build-native/step649_test` - PASS (12/12) regression coverage
|
||||||
|
|
||||||
|
**Architecture gate check:**
|
||||||
|
- `editor/src/HiveMindAutoUpdateModel.h` (`41` <= `600`)
|
||||||
|
- `editor/tests/step650_test.cpp` within test-file size guidance (`26` lines)
|
||||||
|
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
|
||||||
|
|||||||
Reference in New Issue
Block a user