42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from idea194_attractorforge_verified_attractor import AttractorCompiler
|
|
from idea194_attractorforge_verified_attractor.adapters import ToyOrbitalAdapter, PlantAdapterShim
|
|
from idea194_attractorforge_verified_attractor.verifier import verify
|
|
|
|
|
|
def test_plant_adapter_shim_forwards_step() -> None:
|
|
adapter = ToyOrbitalAdapter()
|
|
shim = PlantAdapterShim(underlying=adapter, name="orbital-shim")
|
|
state = (0.5, -0.5)
|
|
control = (0.1, -0.1)
|
|
next1 = adapter.step(state, control, 0.1)
|
|
next2 = shim.step(state, control, 0.1)
|
|
assert next1 == next2
|
|
|
|
|
|
def test_verifier_returns_ok_and_damage_score() -> None:
|
|
spec = AttractorCompiler().compile(
|
|
AttractorCompiler().compile.__defaults__[0]
|
|
) if False else None
|
|
|
|
# Instead of complex construction, compile a simple spec via known pattern
|
|
from idea194_attractorforge_verified_attractor import AttractorSpec
|
|
|
|
spec = AttractorSpec(
|
|
spec_id="v-demo",
|
|
kind="motion_manifold",
|
|
state_labels=("r", "t"),
|
|
target_state=(0.0, 0.0),
|
|
control_limit=0.5,
|
|
dt=0.1,
|
|
horizon=8,
|
|
basin_radius=0.5,
|
|
convergence_rate=0.2,
|
|
safety_margin=0.05,
|
|
objective="verify-demo",
|
|
)
|
|
|
|
result = AttractorCompiler().compile(spec)
|
|
ok, damage = verify(result.plan_cert, result.plan_delta.spec_id)
|
|
assert isinstance(ok, bool)
|
|
assert 0.0 <= damage <= 1.0
|