From 1fa5167e20933728ddde47c9e7d782beaf84daf3 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 27 Mar 2018 21:58:57 +1300 Subject: [PATCH] Fix a design flaw in Syndicate-HLL for syndicate/rkt. If: - a field is used in an assertion of interest in facet A - and that field changes - to a value that causes the assertion of interest to overlap with some facet B's assertion of interest - and an assertion matching that interest was already known to the actor, Then: - previously, facet A would not be informed of the matching assertion - but now, it is informed of the matching assertion. This more or less only affects "on asserted" endpoints. The change here should be written up as an erratum to chapter 5 in my dissertation. Also, syndicate/js needs to be checked for the bug and probably fixed in an analogous way. --- racket/syndicate/actor.rkt | 14 ++++++++++++-- .../examples/actor/example-synthetic-patch-2.rkt | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/racket/syndicate/actor.rkt b/racket/syndicate/actor.rkt index 54d2ae3..b16eb38 100644 --- a/racket/syndicate/actor.rkt +++ b/racket/syndicate/actor.rkt @@ -1171,8 +1171,18 @@ (with-current-facet fid #f (define ep (hash-ref (facet-endpoints f) eid)) (define new-patch ((endpoint-patch-fn ep))) - (update-stream! eid (compose-patch new-patch - (core:retract ?)))))))) + (define a (current-actor-state)) + (define new-interests + (trie-subtract (patch-added new-patch) + (mux-interests-of (actor-state-mux a) eid) + #:combiner (lambda (v1 v2) trie-empty))) + (define newly-relevant-knowledge + (biased-intersection (actor-state-knowledge a) new-interests)) + (update-stream! eid (compose-patch new-patch (core:retract ?))) + (facet-handle-event! fid + (lookup-facet fid) + (patch newly-relevant-knowledge trie-empty) + #t)))))) (define (update-stream! eid patch) (define a (current-actor-state)) diff --git a/racket/syndicate/examples/actor/example-synthetic-patch-2.rkt b/racket/syndicate/examples/actor/example-synthetic-patch-2.rkt index 2075abe..7888285 100644 --- a/racket/syndicate/examples/actor/example-synthetic-patch-2.rkt +++ b/racket/syndicate/examples/actor/example-synthetic-patch-2.rkt @@ -1,7 +1,7 @@ #lang syndicate -;; Illustrates a bug where an endpoint whose interest moves with time, -;; where that interest eventually overlaps with existing interest, -;; fails to be notified of an otherwise-known assertion. +;; Illustrates a (fixed) bug where an endpoint whose interest moves +;; with time, where that interest eventually overlaps with existing +;; interest, fails to be notified of an otherwise-known assertion. ;; ;; Symptomatic output: ;;