fix(daemon)+fix(client): close four fool-proofing gaps
C++ (equipment_service.hpp): - ReportSubstrate ARRIVED: check CreateResult and return INVALID_OBJECT when the substrate ID already exists, instead of silently doing nothing - ReportSubstrate/ReportModule default switch branches: return false (→ CANNOT_DO_NOW) for unknown enum values instead of silently accepting Python (_client.py): - @eq.command: raise NameError (client-side name validation) instead of SecsGemError (which means "daemon declined a request") — wrong type - Module docstring: update example to show @eq.command / eq.names API Test (test_daemon_service.cpp): - Add duplicate-ARRIVED check (expects INVALID_OBJECT) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -536,7 +536,8 @@ class EquipmentService final : public pb::Equipment::Service {
|
||||
auto outcome = rt_.read_sync([this, sid, cid, slot, m]() -> std::optional<bool> {
|
||||
auto& subs = rt_.model().substrates;
|
||||
if (m == pb::SubstrateReport::ARRIVED) {
|
||||
subs.create(sid, cid, slot); // AtSource / NeedsProcessing
|
||||
if (subs.create(sid, cid, slot) == gem::SubstrateStore::CreateResult::Denied_AlreadyExists)
|
||||
return std::nullopt; // → INVALID_OBJECT: duplicate substrate ID
|
||||
return true;
|
||||
}
|
||||
if (!subs.has(sid)) return std::nullopt;
|
||||
@@ -550,7 +551,7 @@ class EquipmentService final : public pb::Equipment::Service {
|
||||
case pb::SubstrateReport::PROCESSED:
|
||||
return subs.fire_processing_event(sid, gem::SubstrateProcessingEvent::EndProcessing);
|
||||
default:
|
||||
return true;
|
||||
return false; // unknown milestone
|
||||
}
|
||||
});
|
||||
ack_from_outcome(outcome, resp, "substrate '" + sid + "'",
|
||||
@@ -575,7 +576,7 @@ class EquipmentService final : public pb::Equipment::Service {
|
||||
case pb::ModuleReport::NOT_EXECUTING:
|
||||
return mods.fire(mid, gem::ModuleEvent::Reset);
|
||||
default:
|
||||
return true;
|
||||
return false; // unknown state
|
||||
}
|
||||
});
|
||||
// Module auto-creates, so "not found" can't happen; only the FSM verdict.
|
||||
|
||||
Reference in New Issue
Block a user