move actions to a separate state attribute
[scpubgit/DKit.git] / lib / DX / Op / ProposeAction.pm
index b1aa7f3..e63eb40 100644 (file)
@@ -21,11 +21,12 @@ sub run {
   my @deps = $state->action_dependencies(map $_->id, @vars);
   my $action = $self->builder->(map $state->resolve_value($_), @vars)
                     ->but(dependencies => \@deps);
+  my ($rec_state, $action_id) = $state->record_action($action);
   my ($fact_type, $value) = $action->expected_effect;
-  my $final_value = $value->but(required_action => $action);
+  my $final_value = $value->but(required_action => $action_id);
   my $fact_set = $state->facts->{$fact_type}->with_value($final_value);
-  $state->but(facts => { %{$state->facts}, $fact_type => $fact_set })
-        ->then($self->next);
+  $rec_state->but(facts => { %{$state->facts}, $fact_type => $fact_set })
+            ->then($self->next);
 }
 
 1;