diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 8f7d718..96cf8e4 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -4729,4 +4729,13 @@ target_link_libraries(step649_test PRIVATE tree_sitter_javascript tree_sitter_typescript 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) diff --git a/editor/src/HiveMindAutoUpdateModel.h b/editor/src/HiveMindAutoUpdateModel.h new file mode 100644 index 0000000..fcfa17c --- /dev/null +++ b/editor/src/HiveMindAutoUpdateModel.h @@ -0,0 +1,41 @@ +#pragma once +// Step 650: HiveMind-push auto-update mechanism model + +#include + +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; + } +}; diff --git a/editor/tests/step650_test.cpp b/editor/tests/step650_test.cpp new file mode 100644 index 0000000..93e0489 --- /dev/null +++ b/editor/tests/step650_test.cpp @@ -0,0 +1,26 @@ +// Step 650: HiveMind-push auto-update mechanism (12 tests) + +#include "HiveMindAutoUpdateModel.h" +#include +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: "<