Feature: Plan Domain Model As a developer I want a plan domain model that supports the lifecycle So that I can track plans through Action -> Strategize -> Execute -> Apply phases # NamespacedName Tests Scenario: Parse simple name defaults to local namespace When I parse the namespaced name "my-action" Then the parsed namespace should be "local" And the parsed item name should be "my-action" And the parsed server should be empty Scenario: Parse name with explicit local namespace When I parse the namespaced name "local/my-action" Then the parsed namespace should be "local" And the parsed item name should be "my-action" Scenario: Parse name with organization namespace When I parse the namespaced name "myorg/my-action" Then the parsed namespace should be "myorg" And the parsed item name should be "my-action" Scenario: Parse name with server qualifier When I parse the namespaced name "prod:myorg/my-action" Then the parsed server should be "prod" And the parsed namespace should be "myorg" And the parsed item name should be "my-action" Scenario: NamespacedName string representation Given I have a namespaced name with server "prod" namespace "myorg" and name "my-action" Then the namespaced string representation should be "prod:myorg/my-action" Scenario: NamespacedName without server Given I have a namespaced name with namespace "local" and name "test-plan" Then the namespaced string representation should be "local/test-plan" Scenario: Invalid namespace with special characters fails When I try to create a namespaced name with namespace "my@org" and name "test" Then a validation error should be raised Scenario: Empty namespace defaults to local Given I create a namespaced name with an empty namespace and name "test-plan" Then the parsed namespace should be "local" # PlanPhase Tests Scenario: Plan phases are in correct order Then the plan phases should be in order "action, strategize, execute, apply, applied" Scenario: ACTION phase is the starting phase Given I create a new plan Then the plan phase should be "action" # PlanState Tests Scenario: Action phase uses ActionState Given I create a new plan in action phase Then the plan action state should be "draft" And the plan processing state should be empty Scenario: Strategize phase uses ProcessingState Given I create a plan in strategize phase Then the plan processing state should be "queued" And the plan action state should be empty Scenario: Action phase defaults missing action_state and exposes state Given I create a plan in action phase without action state Then the plan action state should be "draft" And the plan state should be "draft" Scenario: Strategize phase defaults processing_state and clears action_state Given I create a plan in strategize phase with action state set and no processing state Then the plan processing state should be "queued" And the plan action state should be empty # Plan Identity Tests Scenario: Plan requires valid ULID When I try to create a plan identity with invalid ULID "not-a-ulid" Then a validation error should be raised Scenario: Plan identity with valid ULID succeeds When I create a plan identity with ULID "01ARZ3NDEKTSV4RRFFQ69G5FAV" Then the plan identity should be valid Scenario: Plan identity supports parent and root plan IDs When I create a plan identity with parent "01ARZ3NDEKTSV4RRFFQ69G5FAV" and root "01ARZ3NDEKTSV4RRFFQ69G5FAW" Then the parent plan ID should be "01ARZ3NDEKTSV4RRFFQ69G5FAV" And the root plan ID should be "01ARZ3NDEKTSV4RRFFQ69G5FAW" # Plan Lifecycle Tests Scenario: New plan starts in ACTION phase with DRAFT state Given I create a new plan with description "Test plan" Then the plan phase should be "action" And the plan action state should be "draft" And the plan should not be terminal Scenario: Plan can check if it can transition to next phase Given I create a plan in action phase with available state Then the plan can transition to next phase Scenario: Draft action cannot transition to next phase Given I create a new plan in action phase Then the plan cannot transition to next phase Scenario: Processing complete allows transition in non-action phase Given I create a plan in execute phase with complete processing state Then the plan can transition to next phase Scenario: Get next phase from ACTION is STRATEGIZE Given I create a new plan Then the next phase should be "strategize" Scenario: Get next phase from APPLIED is None (terminal) Given I create a plan in applied phase Then the next phase should be empty And the plan should be terminal Scenario: Unknown phase returns no next phase Given I create a plan with an unknown phase value Then the next phase should be empty # Phase Transition Validation Tests Scenario: Valid transition from ACTION to STRATEGIZE Then transition from "action" to "strategize" should be valid Scenario: Valid transition from STRATEGIZE to EXECUTE Then transition from "strategize" to "execute" should be valid Scenario: Valid transition from EXECUTE to APPLY Then transition from "execute" to "apply" should be valid Scenario: Valid transition from APPLY to APPLIED Then transition from "apply" to "applied" should be valid Scenario: Invalid transition from ACTION to EXECUTE Then transition from "action" to "execute" should be invalid Scenario: Invalid transition from STRATEGIZE to APPLY Then transition from "strategize" to "apply" should be invalid Scenario: No transition from APPLIED (terminal) Then transition from "applied" to "action" should be invalid # Error State Tests Scenario: Plan in errored state is_errored returns True Given I create a plan in strategize phase with errored state Then the plan should be errored Scenario: Plan in processing state is_errored returns False Given I create a plan in strategize phase with processing state Then the plan should not be errored Scenario: Archived action is terminal Given I create a plan in action phase with archived state Then the plan should be terminal # Model Validation Tests Scenario: Plan requires description When I try to create a plan without description Then a validation error should be raised Scenario: Plan description cannot be empty When I try to create a plan with empty description Then a validation error should be raised Scenario: Action phase rejects processing_state When I try to create a plan in action phase with processing state Then a validation error should be raised Scenario: Applied phase cannot transition to next phase Given I create a plan in applied phase Then the plan cannot transition to next phase