1 package DX::Hypothesis;
3 use DX::ActionPolicy::LockScope;
4 use Types::Standard qw(ArrayRef);
5 use DX::Utils qw(deparse);
8 has scope => (is => 'ro', isa => Scope, required => 1);
10 has resolved_propositions => (
11 is => 'ro', isa => ResolvedPropositionSet, required => 1
15 is => 'ro', isa => ArrayRef[Action], required => 1
18 has action_applications => (
19 is => 'ro', isa => ArrayRef[Action], required => 1
22 has action_policy => (is => 'ro', isa => ActionPolicy, required => 1);
25 my ($self, @actions) = @_;
28 foreach my $act (@actions) {
29 return undef unless $self->action_policy->allows($act);
30 ($hyp, my @these_events) = $act->dry_run($hyp);
31 return undef unless $hyp;
32 push @events, @these_events;
34 $hyp = $hyp->but_recheck_for(@events);
39 my ($self, @events) = @_;
40 my ($still_resolved, @recheck) = $self->resolved_propositions
41 ->but_expire_for(@events);
42 return $self unless @recheck;
44 my $ap = DX::ActionPolicy::LockScope->new(
45 lock_to_depth => $self->scope->depth,
46 next_policy => $self->action_policy,
49 # we should probably be doing something about pruning the scope
50 # but that's completely pointless until we have rules
52 my $hyp = ref($self)->new(
53 scope => $self->scope,
54 resolved_propositions => DX::ResolvedPropositionSet->new_empty,
56 action_applications => [],
60 my $pseq = DX::PropositionSequence->new(
66 trace 'step.recheck.hyp' => $hyp;
68 my $ss = DX::SearchProcess->new_for($hyp, $pseq);
70 my $sol_ss = $ss->find_solution;
73 trace 'step.recheck.fail' => 'argh';
77 my $sol_rps = $sol_ss->current_hypothesis->resolved_propositions;
79 my $rps = $still_resolved;
81 $rps = $rps->with_updated_dependencies_for(
82 $_, $sol_rps->dependencies_for($_)
85 trace 'step.recheck.done' => 'yay';
87 return $self->but(resolved_propositions => $rps);
91 my ($self, $prop, $depends) = @_;
93 resolved_propositions => $self->resolved_propositions
94 ->with_resolution_for(