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) = @_;
27 foreach my $act (@actions) {
28 return undef unless $self->action_policy->allows($act);
29 ($hyp, my @events) = $act->dry_run($hyp);
30 return undef unless $hyp;
31 $hyp = $hyp->but_recheck_for(@events);
32 return undef unless $hyp;
38 my ($self, @events) = @_;
39 my ($still_resolved, @recheck) = $self->resolved_propositions
40 ->but_expire_for(@events);
41 return $self unless @recheck;
43 my $ap = DX::ActionPolicy::LockScope->new(
44 lock_to_depth => $self->scope->depth,
45 next_policy => $self->action_policy,
48 # we should probably be doing something about pruning the scope
49 # but that's completely pointless until we have rules
51 my $hyp = ref($self)->new(
52 scope => $self->scope,
53 resolved_propositions => DX::ResolvedPropositionSet->new_empty,
55 action_applications => [],
59 my $pseq = DX::PropositionSequence->new(
65 trace 'step.recheck.hyp' => $hyp;
67 my $ss = DX::SearchProcess->new_for($hyp, $pseq);
69 my $sol_ss = $ss->find_solution;
72 trace 'step.recheck.fail' => 'argh';
76 my $sol_rps = $sol_ss->current_hypothesis->resolved_propositions;
78 my $rps = $still_resolved;
80 $rps = $rps->with_updated_dependencies_for(
81 $_, $sol_rps->dependencies_for($_)
84 trace 'step.recheck.done' => 'yay';
86 return $self->but(resolved_propositions => $rps);
90 my ($self, $prop, $depends) = @_;
92 resolved_propositions => $self->resolved_propositions
93 ->with_resolution_for(