fix(simulation): persist command authority provenance
This commit is contained in:
@@ -9,6 +9,7 @@ import pytest
|
||||
from k1link.simulation import (
|
||||
AckermannControlSetpoint,
|
||||
AuthorityProfile,
|
||||
CommandAuthorityScope,
|
||||
DifferentialControlSetpoint,
|
||||
ProviderPin,
|
||||
QualificationArtifact,
|
||||
@@ -223,6 +224,8 @@ def test_ackermann_and_differential_commands_are_typed_and_sequenced(
|
||||
store.submit_command(second)
|
||||
|
||||
assert store.list_commands("run-s1-001") == (first, second)
|
||||
assert first.to_dict()["authority_scope"] == "virtual-only"
|
||||
assert first.to_dict()["source"] == "simulation-orchestrator"
|
||||
|
||||
|
||||
def test_commands_fail_closed_on_state_sequence_authority_and_ttl(tmp_path: Path) -> None:
|
||||
@@ -280,6 +283,21 @@ def test_command_contract_rejects_nonfinite_and_direct_actuator_authority() -> N
|
||||
heartbeat_timeout_monotonic_ns=100,
|
||||
direct_actuator_setpoints_allowed=True,
|
||||
)
|
||||
with pytest.raises(SimulationContractError, match="virtual-only"):
|
||||
replace(
|
||||
AckermannControlSetpoint(
|
||||
run_id="run-s1-001",
|
||||
command_id="command-scope",
|
||||
sequence=1,
|
||||
issued_at_sim_ns=0,
|
||||
valid_until_sim_ns=100,
|
||||
authority_generation=1,
|
||||
speed_mps=0.0,
|
||||
steering_normalized=0.0,
|
||||
),
|
||||
authority_scope="physical", # type: ignore[arg-type]
|
||||
)
|
||||
assert CommandAuthorityScope.VIRTUAL_ONLY.value == "virtual-only"
|
||||
with pytest.raises(SimulationContractError, match="valid explicit UTC"):
|
||||
replace(_run(), created_at_utc="2026-02-30T17:00:00Z")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user