Commit Graph

55 Commits

Author SHA1 Message Date
Massimo Zaniboni 855b7835f6 Added license header to each source code file 2021-06-04 11:13:49 +02:00
Tony Garnock-Jones f269c02c23 Rearrange for independent packages. 2020-04-27 20:27:48 +02:00
Tony Garnock-Jones 23580010bb Supervision and reloading 2019-01-28 01:14:33 +00:00
Tony Garnock-Jones 7f14dd900c Detect and repair error in error-handling and -recovery. 2018-11-02 12:15:04 +00:00
Tony Garnock-Jones bc4fb5ef94 Ensure patched assertions are added before being removed, to avoid glitching 2018-11-02 00:38:40 +00:00
Tony Garnock-Jones 46ddb47050 Cosmetic - extra logging (when uncommented) 2018-05-04 16:56:56 +01:00
Tony Garnock-Jones bc4c080641 Quasi-useful debug output 2018-05-04 16:04:42 +01:00
Tony Garnock-Jones ab64f71766 Restriction-paths: right idea (?), wrong implementation. This time maybe.
Instead of having restriction-paths as an adjunct to a change, they're
more propertly a part of each assertion itself. The new `skeleton.rkt`
keeps an optional restriction-path with each assertion, treating it as
distinct from its underlying assertion. The idea of not signalling
changes in assertions that have a restriction-path mismatch stays.
2018-05-04 15:55:53 +01:00
Tony Garnock-Jones ef4584a60f Skip apply-patch! make-work if patch is empty 2018-05-03 22:56:40 +01:00
Tony Garnock-Jones 69a8893da3 Add the concept of "restriction-path", which limits assertion visibility.
This is used when relaying: because we don't have access to the full
term, but only the projection results, we are inserting various
`(discard)`s. This is the cause of the failure in
`test/core/nesting-confusion.rkt`.

By adding `restriction-path`, we allow the inner dataspace to avoid
showing a reconstructed term to endpoints that might be able to
observe the reconstructed parts.

An alternative implementation approach is to generalize patterns in
the inner relay actor, translating all `(discard)`s into captures,
which would give us all the relevant terms that we need. The way I've
chosen to go (or at least, to try out) allows us to potentially keep
the "efficient" idea of just transmitting pattern-bound values across
some network link connecting dataspaces. The alternative would require
transmission of the full assertions, eliding no irrelevant detail.
2018-05-03 22:09:33 +01:00
Tony Garnock-Jones f01b17dea4 Reuse apply-patch for initial-assertions too 2018-05-03 20:09:34 +01:00
Tony Garnock-Jones 00d50e6700 Factor out assertion structure definitions 2018-05-03 16:14:30 +01:00
Tony Garnock-Jones 17cee51342 Ensure (??) that relays' assertions can't outlive them 2018-05-02 18:10:52 +01:00
Tony Garnock-Jones eb208f3a10 Handy logging for diagnosing problems 2018-05-01 22:39:50 +01:00
Tony Garnock-Jones 367b39ce39 Eliminate a (mostly harmless) source of #f current-facet. 2018-05-01 22:39:26 +01:00
Tony Garnock-Jones 669122766d Allow multiple "root" facets, by creating a dummy root 2018-05-01 22:39:02 +01:00
Tony Garnock-Jones 869a495392 First sketch of `quit-dataspace!`. 2018-05-01 21:12:54 +01:00
Tony Garnock-Jones 896cfe2498 Multi-assert!/retract! for adhoc assertions 2018-05-01 20:58:26 +01:00
Tony Garnock-Jones ec0933ffdd Clamp `adhoc-retract!` to not drop below zero. 2018-04-30 22:48:27 +01:00
Tony Garnock-Jones f3ca2b6a15 Repair incorrect interleaving of actions and scripts 2018-04-30 22:47:25 +01:00
Tony Garnock-Jones 671e9742c7 Speedup from avoiding uselessly enqueueing an empty work queue 2018-04-30 11:19:03 +01:00
Tony Garnock-Jones 0e37037b6e Eliminate another parameter: now only `current-facet` remains 2018-04-30 11:18:49 +01:00
Tony Garnock-Jones 14ee4f70ef Avoid manipulating `in-script?` all the time 2018-04-30 10:44:35 +01:00
Tony Garnock-Jones a6811f2ba5 Add timer/timestate support; this prompted a change to endpoint registration.
The `add-endpoint!` call is changed in two ways:

 - the old `assertion-fn` has become `update-fn`, yielding both
   an assertion *and* an optional handler, because if the handler
   depends on a field which changes, previously the handler wasn't
   being updated

 - a new parameter, `dynamic?`, can be set to #f (it's usually #t)
   to ensure that the assertion and skeleton-interest are calculated
   only once ever, and are not connected to the dataflow machinery.

The first change makes it possible for the `(later-than (deadline))`
pattern, where `deadline` is a field, to work; the second change makes
`during` and `during/spawn` work correctly in the face of field
updates.
2018-04-29 22:27:55 +01:00
Tony Garnock-Jones 91596b066f External-event and TCP drivers; chat server and stdin echo programs 2018-04-29 18:43:39 +01:00
Tony Garnock-Jones f45323a097 Extract raw dataspace test to separate file 2018-04-29 16:08:52 +01:00
Tony Garnock-Jones b3d6b74dab Repair scheduling of inner dataspaces, thus allowing e.g. double nesting 2018-04-29 16:07:49 +01:00
Tony Garnock-Jones dd2cddb6a7 Nested dataspaces 2018-04-29 14:54:14 +01:00
Tony Garnock-Jones 290170f450 Simple test harness 2018-04-27 23:53:31 +01:00
Tony Garnock-Jones a4abea9d87 Remove current-dataspace parameter 2018-04-27 18:05:33 +01:00
Tony Garnock-Jones edb8e719f7 More robust approach to cleanup of assertions on actor termination.
We now explicitly track *committed* assertions of each actor in a new
field, `actor-cleanup-changes`. Each time a patch action is
*performed*, `actor-cleanup-changes` is updated. When an actor quits,
it enqueues a special new kind of action, a `quit` action.

When a `quit` action is performed, any remaining contents of
`actor-cleanup-changes` are processed in order to fully remove any
leftover assertions. (Leftover assertions will only arise in
exceptional cases: when some stop-script or facet boot-script raises
an uncaught exception.)

As part of this commit, we undo the effect of commit 8624047.
2018-04-27 17:30:26 +01:00
Tony Garnock-Jones 0d5b7e9c02 Cosmetic 2018-04-27 10:54:58 +01:00
Tony Garnock-Jones a247d8fd2b Switch adhoc-assertions to a bag (from a set).
This repairs a bug regarding crashes in a new actor's boot-proc.

Previously, if boot-proc raised an exception, the initial assertions
would stick around forever. By changing adhoc-assertions to a bag
rather than a set, and putting the initial assertions in the bag, we
put them somewhere they are guaranteed to be processed during actor
termination, even when an exception is signalled during boot.

This is an API change wrt the previous Syndicate implementation:
assert!/retract! now have bag semantics, not set semantics. We can add
set-semantics APIs if we end up needing them, of course, layered on
top of the bag implementation.
2018-04-27 09:59:03 +01:00
Tony Garnock-Jones 8624047ecd The failing test now passes. The reasons for this are subtle:
The patch here removes a terminated facet from its parent's
`facet-children` set only in a script, and only after all other
scripts enqueued as part of facet termination have executed without an
uncaught exception.

This means that, if (say) a stop script raises an uncaught exception,
it might have happened after some *but not all* scripts resulting from
calls to `retract-facet-assertions-and-subscriptions!` have already
executed. So some endpoints' assertions and subscriptions will have
been removed.

When the uncaught exception is caught by the handler in
`with-current-facet`, a call to `abandon-queued-work!` is made, which
discards queued scripts, including the remaining assertion-cleanup
scripts as well as the scripts for removing dead facets from their
parents' `facet-children` sets. It also (crucially) discards queued
patch actions, including those resulting from already-executed
assertion-cleanup scripts.

At this point, we have a facet tree with some dead facets still in it,
and no queued outbound patches. The assertions for the still-present
dead facets are still logically asserted.

Then, a call to `terminate-actor!` happens, which traverses the whole
tree enqueueing assertion-cleanup scripts. No user code is enqueued,
so (in principle) no exceptions can be signalled.

Once these `terminate-actor!`-enqueued scripts execute, a pending
patch exists that will remove all remaining endpoint assertions.

The remaining sticky point is the calls to `dataspace-unsubscribe!`.
Happily, these are idempotent because of the implementation in
`skeleton.rkt`.

Prior to this patch, terminating facets were removed early from their
parents' `facet-children` sets, meaning there was no way to find them
again to clean up if a failure occurred during a stop script.

Ideally, it'd be easy to see that the code is correct in this respect.
We're not there yet.
2018-04-25 20:43:25 +01:00
Tony Garnock-Jones ce6cd58930 Run stop-scripts in one scheduled execution 2018-04-25 19:54:58 +01:00
Tony Garnock-Jones dfe8a3e96e Be specific in for-loops 2018-04-25 19:47:18 +01:00
Tony Garnock-Jones c06d5ba3ce Guard against double-adhoc-assertion 2018-04-25 19:46:08 +01:00
Tony Garnock-Jones 9726376c82 Remove redundant `facet-live?` test 2018-04-25 19:40:53 +01:00
Tony Garnock-Jones bc9b931312 Omit "name" to ctor for dataspace struct - name is/will be a property of the downward relay connection 2018-04-25 19:30:45 +01:00
Tony Garnock-Jones f58c2fb8dc Repair error: stop-facet scripts must run in parent facet's context! 2018-04-22 21:03:21 +01:00
Tony Garnock-Jones a3dfb2c5aa Notice attempts to install more than one root facet in an actor 2018-04-22 21:03:01 +01:00
Tony Garnock-Jones 4be935a160 Introduce action-groups 2018-04-22 21:02:40 +01:00
Tony Garnock-Jones 634b114afc Improve debug-printing of facets 2018-04-22 21:00:35 +01:00
Tony Garnock-Jones b50d18cd46 Remove unused dataspace-actors field 2018-04-22 20:59:57 +01:00
Tony Garnock-Jones 55f4b55784 Implement during and ad-hoc assertions 2018-04-19 17:55:52 +01:00
Tony Garnock-Jones 5377a486c9 Better Isolated Turn Principle 2018-04-11 12:28:09 +01:00
Tony Garnock-Jones 3452f1fe6e Script suspend and resume 2018-04-09 10:23:22 +01:00
Tony Garnock-Jones eb24d566e9 Progress on syntax veneer 2018-04-08 11:44:32 +01:00
Tony Garnock-Jones e84f2e2e39 Eliminate (interesting uses of) facet IDs by storing references directly 2018-04-08 08:52:37 +01:00
Tony Garnock-Jones fe6b895d8a More structured FID representation. 2018-04-08 07:58:17 +01:00