Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(daemon): Terminator DAG #1836

Merged
merged 9 commits into from
Oct 27, 2023
Merged

feat(daemon): Terminator DAG #1836

merged 9 commits into from
Oct 27, 2023

Conversation

kriskowal
Copy link
Member

This stack of changes gives us a terminate(petName) method on the Endo Host Powers object. This will cause the daemon to forget the current incarnation of that named value and all named values that depend upon it, including parties that received the value through request or adopt. This also terminates workers.

The implications of termination are far-reaching and this is only the beginning. New formulas may self-destruct, like a formula that uses a file watcher to invalidate itself when its on-disk dependencies change. Connections may self-destruct if they disconnect. Weblets might auto-reload if their powers are invalidated.

Also, because the formulas form an acyclic DAG, simple ref-counting should suffice for garbage collecting formulas. Formulas can be retained by pet name paths, but also live values, so using a WeakRef in the future should allow us to automatically terminate and collect provably unreachable formulas.

To make this work, the internal memo now envelopes values in a controller object to track the corresponding terminator (synchronously) and the internal and external facets of the formula. This cleans up some side tables previously held for formula-specific internals like the worker bootstrap and the message bus between parties.

@kriskowal kriskowal requested a review from kumavis October 21, 2023 07:02
@kumavis
Copy link
Member

kumavis commented Oct 27, 2023

might be nice to be able to review termination dependencies, but not a blocker for this pr

maybe interactive cli with "this will terminate x, y, z -- do you want to continue?"

@kriskowal
Copy link
Member Author

Building upon this I’ve realized that cancellation, termination, and kill should all just be cancel. Consolidating under a single abstraction will require further work. Notably, terminate() doesn’t yet take a reason argument like cancel(reason), terminated is Promise whereas cancelled is a Promise. endo cancel works for me, just as a Cancel button in the “familiar“ inventory works.

Viewing termination dependencies is closely related to a discussion I started on Matrix today, but for revealing the dependencies of a formula in a pet name path. I think that will look like:

> endo eval 10 -n ten
10
> endo list META.ten
worker
source
names
values
> endo show META.ten.worker
[alleged Worker]

Where META is an indelible reference to the party’s meta-pet-store. This would happen to reflect all the dependencies of a pet named value, all of the objects that would cause this value to get cancelled if they were cancelled. I don’t have a ready idea for inspecting the inverse.

@kriskowal kriskowal merged commit 980dd57 into endo Oct 27, 2023
@kriskowal kriskowal deleted the kriskowal-endo-terminator-dag branch October 27, 2023 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants