from __future__ import annotations def test_change_set_state_machine_separates_canonical_and_projection_completion(): from app.core.knowledge.publish import ChangeSetStateMachine machine = ChangeSetStateMachine() state = "pending" for target in ( "diffed", "building", "validating", "canonical_active", "projecting", "complete", ): state = machine.transition(state, target) assert state == "complete" def test_change_set_cannot_activate_when_impact_was_truncated(): import pytest from app.core.knowledge.publish import ChangeSetStateMachine machine = ChangeSetStateMachine() with pytest.raises(ValueError, match="truncated"): machine.transition("validating", "canonical_active", impact_truncated=True) def test_change_set_rejects_invalid_transition(): import pytest from app.core.knowledge.publish import ChangeSetStateMachine with pytest.raises(ValueError, match="invalid knowledge change-set transition"): ChangeSetStateMachine().transition("pending", "complete")