diff --git a/src/runtime/actors.rs b/src/runtime/actors.rs index bf56da5fc034ebaac67ffcfc63822ba84468b629..d47ad39644c7b60806e31e35bdf2f692227d0704 100644 --- a/src/runtime/actors.rs +++ b/src/runtime/actors.rs @@ -323,10 +323,10 @@ impl PolyP { if payload_branch.blocking_on == Some(ekey) { // run the fork payload_branch.blocking_on = None; - Some((old_predicate, payload_branch)) + Some((payload_predicate.clone(), payload_branch)) } else { // don't bother running. its awaiting something else - incomplete2.insert(old_predicate, payload_branch); + incomplete2.insert(payload_predicate.clone(), payload_branch); None } } @@ -379,6 +379,7 @@ impl PolyN { let mut report_if_solution = |branch: &BranchN, pred: &Predicate, logger: &mut String| { if branch.to_get.is_empty() { + log!(logger, "Native reporting solution with inbox {:#?}", &branch.gotten); solution_storage.submit_and_digest_subtree_solution( logger, SubtreeId::PolyN, @@ -396,14 +397,14 @@ impl PolyN { ); match case { Csr::Nonexistant => { /* skip branch */ } - Csr::FormerNotLatter | Csr::Equivalent => { + Csr::LatterNotFormer | Csr::Equivalent => { // Feed the message to this branch in-place. no need to modify pred. if branch.to_get.remove(&ekey) { branch.gotten.insert(ekey, payload.clone()); report_if_solution(&branch, &old_predicate, logger); } } - Csr::LatterNotFormer => { + Csr::FormerNotLatter => { // create a new branch with the payload_predicate. let mut forked = branch.clone(); if forked.to_get.remove(&ekey) { @@ -422,15 +423,10 @@ impl PolyN { } } } - // unlike PolyP machines, Native branches do not become inconsistent + // unlike PolyP machines, Native branches do NOT become inconsistent branches2.insert(old_predicate, branch); } - log!( - logger, - "Native now has {} branches with predicates: {:?}", - branches2.len(), - branches2.keys().collect::>() - ); + log!(logger, "Native now has branches {:#?}", &branches2); std::mem::swap(&mut branches2, &mut self.branches); } diff --git a/src/runtime/communication.rs b/src/runtime/communication.rs index de60b08c48c85b876fd30ee2694586df218b16f1..e7595a26225f9768e0f34f37f5567810c43cd62a 100644 --- a/src/runtime/communication.rs +++ b/src/runtime/communication.rs @@ -7,8 +7,15 @@ impl Controller { let ret = match &decision { Decision::Success(predicate) => { // overwrite MonoN/P - self.inner.mono_n = - self.ephemeral.poly_n.take().unwrap().choose_mono(predicate).unwrap(); + self.inner.mono_n = { + let poly_n = self.ephemeral.poly_n.take().unwrap(); + poly_n.choose_mono(predicate).unwrap_or_else(|| { + panic!( + "Ending round with decision pred {:#?} but poly_n has branches {:#?}. My log is... {}", + &predicate, &poly_n.branches, &self.inner.logger + ); + }) + }; self.inner.mono_ps.clear(); self.inner.mono_ps.extend( self.ephemeral @@ -419,6 +426,7 @@ impl Controller { return self.end_round_with_decision(decision); } CommMsgContents::SendPayload { payload_predicate, payload } => { + // check that we expect to be able to receive payloads from this sender assert_eq!( Getter, self.inner.endpoint_exts.get(received.recipient).unwrap().info.polarity @@ -434,6 +442,17 @@ impl Controller { &payload_predicate, &payload ); + let channel_id = self + .inner + .endpoint_exts + .get(received.recipient) + .expect("UEHFU") + .info + .channel_id; + if payload_predicate.query(channel_id) != Some(true) { + // sender didn't preserve the invariant + return Err(SyncErr::PayloadPremiseExcludesTheChannel(channel_id)); + } match subtree_id { None => { // this happens when a message is sent to a component that has exited. @@ -455,17 +474,6 @@ impl Controller { } Some(PolyId::P { index }) => { // Message for protocol actor - let channel_id = self - .inner - .endpoint_exts - .get(received.recipient) - .expect("UEHFU") - .info - .channel_id; - if payload_predicate.query(channel_id) != Some(true) { - // sender didn't preserve the invariant - return Err(SyncErr::PayloadPremiseExcludesTheChannel(channel_id)); - } let poly_p = &mut self.ephemeral.poly_ps[*index]; let m_ctx = PolyPContext {