syndicate-js/packages/core
Tony Garnock-Jones 97cfb19852 Move stop continuation *before* a stopping facet's assertions are retracted.
This is a kind of ad-hocish response to an interesting problem. In
previous Syndicates, assertion changes were gathered into *patches*
which *netted out* intra-turn changes. In this implementation, each
change is relayed unchanged, so there is *no netting* going on. The
closest we get is a convention that when things are being replaced,
incoming assertions should be made before outgoing ones are retracted,
so that the kind of glitch that's seen is a double-up of records,
rather than a brief window where no records are present.

So here, by moving the stop continuation into an onStop for the
stopping facet (that nonetheless *executes* in that facet's parent's
context), we allow the following pattern to run without problem
glitching:

    react {
      assert Something(1);
      stop on asserted Condition() => react {
        assert Something(2);
      }
    }

Observers like this...

    during Something(_) => { // **A**
      ...
      during Something($specific) => { // **B**
      }
    }

will see

    + Something(1)
    + Something(2)
    - Something(1)

rather than what they saw before this change,

    + Something(1)
    - Something(1)
    + Something(2)

The consequence is that the line marked **A** above will *remain
active* after this change, with the facet at **B** being replaced,
rather than briefly tearing down the **A** facet when `- Something(1)`
and then creating a fresh one when `+ Something(2)`.

This came up in flappy bird, where I had

    react {
        at mainDs {
            assert ui.html('#board-area', template`<h1 class="score">${score.value}</h1>`);
        }
        at gameDs {
            stop on asserted GameOver() => react {
                at mainDs {
                    assert ui.html(
                        '#board-area',
                        template`<h1 class="score">${score.value}<br/>GAME OVER</h1>`);
                }
            }
        }
    }

which, in combination with the particular implementation of index.ts
in the html package, caused the UIFragment responder to get confused
and to not show the GAME OVER message - the previous score message was
removed, but the new one wasn't manifested in the DOM. Changing the
last `ui.html` above to `ui.context('foo').html` caused the problem to
go away (by making it effectively two unrelated fragments, rather than
a replacement of the content of a single fragment).
2021-12-11 14:04:31 +01:00
..
examples Dataspace.boot 2021-12-09 22:12:41 +01:00
protocols Add 'packages/core/protocols/' from commit 'b42230b96a6f8665fdd8e56a52a5e76072a6d182' 2021-12-01 16:27:11 +01:00
src Move stop continuation *before* a stopping facet's assertions are retracted. 2021-12-11 14:04:31 +01:00
stubs Examples and bug-fixes 2021-12-02 16:04:07 +01:00
test Bulk copyright notice repair 2021-12-01 17:24:29 +01:00
LICENCE Put licences in the place that lerna expects them (?) 2021-12-10 14:02:58 +01:00
Makefile Refactor, improve, and repair 2021-01-18 23:11:53 +01:00
README.md Refactor, improve, and repair 2021-01-18 23:11:53 +01:00
jest.config.ts Bulk copyright notice repair 2021-12-01 17:24:29 +01:00
package.json Publish 2021-12-10 14:03:11 +01:00
rollup.config.js Bulk copyright notice repair 2021-12-01 17:24:29 +01:00
tsconfig.json Use ES2019 dialect in TypeScript (for Symbol.description) 2021-12-09 18:53:17 +01:00

README.md

@syndicate-lang/core

An implementation of the Dataspace model that underpins the Syndicate language design.

Licence

@syndicate-lang/core, an implementation of Syndicate dataspaces for JS.
Copyright (C) 2016-2021 Tony Garnock-Jones tonyg@leastfixedpoint.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.