move recheck logic into resolution step
[scpubgit/DX.git] / lib / DX / Hypothesis.pm
index 5e9a147..0131688 100644 (file)
@@ -31,72 +31,27 @@ sub with_actions {
     return undef unless $hyp;
     push @events, @these_events;
   }
-  $hyp = $hyp->but_recheck_for(@events);
-  return $hyp;
-}
-
-sub but_recheck_for {
-  my ($self, @events) = @_;
-  my ($still_resolved, @recheck) = $self->resolved_propositions
-                                        ->but_expire_for(@events);
-  return $self unless @recheck;
-
-  my $ap = DX::ActionPolicy::LockScope->new(
-    lock_to_depth => $self->scope->depth,
-    next_policy => $self->action_policy,
+  my ($still_resolved, @recheck) = $hyp->resolved_propositions
+                                       ->but_expire_for(@events);
+  return (
+    $hyp->but(resolved_propositions => $still_resolved),
+    @recheck
   );
-
-  # we should probably be doing something about pruning the scope
-  # but that's completely pointless until we have rules
-
-  my $hyp = ref($self)->new(
-    scope => $self->scope,
-    resolved_propositions => DX::ResolvedPropositionSet->new_empty,
-    actions => [],
-    action_applications => [],
-    action_policy => $ap,
-  );
-
-  my $pseq = DX::PropositionSequence->new(
-    members => \@recheck,
-    external_names => {},
-    internal_names => {},
-  );
-
-  trace 'step.recheck.hyp' => $hyp;
-
-  my $ss = DX::SearchProcess->new_for($hyp, $pseq);
-
-  my $sol_ss = $ss->find_solution;
-
-  unless ($sol_ss) {
-    trace 'step.recheck.fail' => 'argh';
-    return undef;
-  }
-
-  my $sol_rps = $sol_ss->current_hypothesis->resolved_propositions;
-
-  my $rps = $still_resolved;
-
-  $rps = $rps->with_updated_dependencies_for(
-    $_, $sol_rps->dependencies_for($_)
-  ) for @recheck;
-
-  trace 'step.recheck.done' => 'yay';
-
-  return $self->but(resolved_propositions => $rps);
 }
 
 sub with_resolution {
   my ($self, $prop, $depends, $actions) = @_;
-  my $hyp = $self->with_actions(@$actions);
+  (my $hyp, my @recheck) = $self->with_actions(@$actions);
   return undef unless $hyp;
-  $hyp->but(
-    resolved_propositions => $self->resolved_propositions
-                                  ->with_resolution_for(
-                                      $prop,
-                                      $depends,
-                                    ),
+  return (
+    $hyp->but(
+      resolved_propositions => $self->resolved_propositions
+                                    ->with_resolution_for(
+                                        $prop,
+                                        $depends,
+                                      ),
+    ),
+    @recheck
   );
 }