fix: harden task recovery and DR contract handling
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#include "workflow_fixture.hpp"
|
||||
struct EvidenceDriver:Simulator {
|
||||
std::string sabotage;
|
||||
void send(const GoalRequest& q)override {
|
||||
if(!sabotage.empty()){std::filesystem::remove(sabotage);std::filesystem::create_directory(sabotage);}
|
||||
record_wire_request(q.goal_id,"bt_skill_interfaces/action/ExecuteManipulation_Goal","000102ff");
|
||||
sent.push_back(q);
|
||||
}
|
||||
};
|
||||
int main(){
|
||||
const auto path=Fixture::test_root()+"/evidence.journal"; EvidenceDriver driver; std::string id;
|
||||
GoalRequest q;q.robot_id="robot";q.trace={"task","pick","run",1,1,1,1};q.skill=Skill::PICK;
|
||||
{ActiveGoalRegistry registry(driver,path);id=*registry.start(q,SteadyTime{});
|
||||
assert(registry.find(id)->request.wire_request_snapshot=="000102ff");
|
||||
GoalEvent e;e.goal_id=id;e.trace=q.trace;e.kind=EventKind::ACCEPTED;driver.events.push_back(e);registry.pump(SteadyTime{});
|
||||
e.kind=EventKind::FEEDBACK;e.sequence=2;e.feedback_snapshot="{\"phase\":3,\"message\":\"executing\\nchunk\",\"progress\":0.25}";driver.events.push_back(e);registry.pump(SteadyTime{});
|
||||
e.sequence=1;e.feedback_snapshot="old feedback";driver.events.push_back(e);registry.pump(SteadyTime{});
|
||||
assert(registry.find(id)->feedback_snapshot.find("executing")!=std::string::npos);
|
||||
registry.request_cancel(id,SteadyTime{});e.sequence=3;e.feedback_snapshot="STOPPING";driver.events.push_back(e);registry.pump(SteadyTime{});assert(registry.find(id)->feedback_snapshot=="STOPPING");assert(registry.robot_locked("robot"));
|
||||
e.kind=EventKind::RESULT;e.native_status=NativeStatus::ABORTED;e.result.code=ResultCode::FAILED;e.result.stop=StopState::CONFIRMED;e.result.error_code="VLA_INFERENCE_TIMEOUT";e.result.execution_record_ref="records/run/pick.json";e.result.wire_result_type="bt_skill_interfaces/action/ExecuteManipulation_Result";e.result.wire_result_snapshot="000abbff";driver.events.push_back(e);registry.pump(SteadyTime{});
|
||||
}
|
||||
{ActiveGoalRegistry registry(driver,path);auto r=registry.find(id);assert(r);
|
||||
assert(r->request.wire_request_type=="bt_skill_interfaces/action/ExecuteManipulation_Goal");
|
||||
assert(r->request.wire_request_snapshot=="000102ff");assert(r->feedback_snapshot=="STOPPING");
|
||||
assert(r->result->wire_result_type=="bt_skill_interfaces/action/ExecuteManipulation_Result");assert(r->result->wire_result_snapshot=="000abbff");assert(r->result->error_code=="VLA_INFERENCE_TIMEOUT");assert(r->result->execution_record_ref=="records/run/pick.json");
|
||||
}
|
||||
const auto bad=Fixture::test_root()+"/wire-write-failure.journal";EvidenceDriver broken;broken.sabotage=bad;
|
||||
{ActiveGoalRegistry registry(broken,bad);try{registry.start(q,SteadyTime{});}catch(const std::exception&){}assert(broken.sent.empty());assert(registry.robot_locked("robot"));}
|
||||
std::filesystem::remove(bad);
|
||||
std::cout<<"wire request, ordered feedback and structured result survive restart; snapshot storage failure prevents transport\n";
|
||||
}
|
||||
Reference in New Issue
Block a user