move recheck to post-all-actions rather than per-action
[scpubgit/DX.git] / lib / DX / Hypothesis.pm
index ff04996..0386cd0 100644 (file)
@@ -11,10 +11,6 @@ has resolved_propositions => (
   is => 'ro', isa => ResolvedPropositionSet, required => 1
 );
 
-has outstanding_propositions => (
-  is => 'ro', isa => ArrayRef[Proposition], required => 1
-);
-
 has actions => (
   is => 'ro', isa => ArrayRef[Action], required => 1
 );
@@ -28,13 +24,14 @@ has action_policy => (is => 'ro', isa => ActionPolicy, required => 1);
 sub with_actions {
   my ($self, @actions) = @_;
   my $hyp = $self;
+  my @events;
   foreach my $act (@actions) {
     return undef unless $self->action_policy->allows($act);
-    ($hyp, my @events) = $act->dry_run($hyp);
-    return undef unless $hyp;
-    $hyp = $hyp->but_recheck_for(@events);
+    ($hyp, my @these_events) = $act->dry_run($hyp);
     return undef unless $hyp;
+    push @events, @these_events;
   }
+  $hyp = $hyp->but_recheck_for(@events);
   return $hyp;
 }
 
@@ -55,7 +52,6 @@ sub but_recheck_for {
   my $hyp = ref($self)->new(
     scope => $self->scope,
     resolved_propositions => DX::ResolvedPropositionSet->new_empty,
-    outstanding_propositions => \@recheck,
     actions => [],
     action_applications => [],
     action_policy => $ap,
@@ -69,7 +65,7 @@ sub but_recheck_for {
 
   trace 'step.recheck.hyp' => $hyp;
 
-  my $ss = DX::SearchState->new_for($hyp, $pseq);
+  my $ss = DX::SearchProcess->new_for($hyp, $pseq);
 
   my $sol_ss = $ss->find_solution;
 
@@ -93,14 +89,12 @@ sub but_recheck_for {
 
 sub with_resolution {
   my ($self, $prop, $depends) = @_;
-  my ($first, @rest) = @{$self->outstanding_propositions};
   $self->but(
     resolved_propositions => $self->resolved_propositions
                                   ->with_resolution_for(
                                       $prop,
                                       $depends,
                                     ),
-    outstanding_propositions => \@rest,
   );
 }