-
Notifications
You must be signed in to change notification settings - Fork 75
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
Pet Daemon #1413
Pet Daemon #1413
Conversation
83a03e7
to
31169ac
Compare
8afee77
to
b5dd152
Compare
How do I run p.s. found it: packages/cli |
more struggles:
fwiw, const makeCounter = () => {
let value = 0;
return {
incr: () => (value += 1),
decr: () => (value -= 1),
};
};
makeCounter; |
I tried to
|
Is there a missing I kept getting
|
does this thing use sloppy eval? shouldn't this give
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notes so far...
packages/daemon/index.d.ts
Outdated
@@ -1,9 +1,16 @@ | |||
import type { FarRef } from '@endo/far'; | |||
|
|||
type Pet = any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... would unknown
work? Or should Pet
be a type parameter?
packages/daemon/src/daemon.js
Outdated
|
||
const { quote: q } = assert; | ||
|
||
const validNamePattern = /^[a-z][a-z0-9]*$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these used as filenames? that implies a length limit, no?
packages/daemon/src/daemon.js
Outdated
stream() { | ||
const storageDirectoryPath = path.join(locator.statePath, 'store-sha512'); | ||
const storagePath = path.join(storageDirectoryPath, sha512); | ||
const nodeReadStream = fs.createReadStream(storagePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ambient authority? hm.
packages/daemon/src/daemon.js
Outdated
// but also because we won't know the name we will use until we've | ||
// completed the hash. | ||
const digester = crypto.createHash('sha512'); | ||
const storageUuid = crypto.randomUUID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ambient authority?
packages/daemon/src/daemon.js
Outdated
await fs.promises.mkdir(workerCachePath, { recursive: true }); | ||
await fs.promises.mkdir(workerStatePath, { recursive: true }); | ||
await fs.promises.mkdir(workerEphemeralStatePath, { recursive: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the order of these matter? optimize turns with Promise.all([])
?
packages/daemon/src/daemon.js
Outdated
* @param {Array<string>} petNames | ||
* @param {string} resultName | ||
*/ | ||
async evaluate(source, codeNames, petNames, resultName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endo doesn't follow the agoric-sdk arrow function style?
packages/daemon/src/daemon.js
Outdated
const output = fs.openSync(logPath, 'w'); | ||
const child = popen.fork(endoWorkerPath, [uuid, workerCachePath], { | ||
stdio: ['ignore', output, output, 'pipe', 'ipc'], | ||
const provideReadableSha512 = (locator, sha512) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we discussed, seems to make a new one always. should be called makeReadableSha512
packages/cli/src/endo.js
Outdated
'Assigns a pet name to the result for future reference', | ||
) | ||
.action(async (storablePath, cmd) => { | ||
const { name } = cmd.options(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { name } = cmd.options(); | |
const { name } = cmd.opts(); |
packages/daemon/src/daemon.js
Outdated
sha512() { | ||
return sha512; | ||
}, | ||
stream() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a text()
method a la:
index c8b964637..42e6bbd71 100644
--- a/packages/daemon/src/daemon.js
+++ b/packages/daemon/src/daemon.js
@@ -47,13 +47,21 @@ const sinkError = error => {
* @param {string} sha512
*/
const provideReadableSha512 = (locator, sha512) => {
+ const getPath = () => {
+ const storageDirectoryPath = path.join(locator.statePath, 'store-sha512');
+ const storagePath = path.join(storageDirectoryPath, sha512);
+ return storagePath;
+ };
+
return Far(`Readable file with SHA-512 ${sha512.slice(0, 8)}...`, {
sha512() {
return sha512;
},
+ text() {
+ return fs.promises.readFile(getPath(), 'utf8');
+ },
stream() {
- const storageDirectoryPath = path.join(locator.statePath, 'store-sha512');
- const storagePath = path.join(storageDirectoryPath, sha512);
+ const storagePath = getPath();
const nodeReadStream = fs.createReadStream(storagePath);
const reader = makeNodeReader(nodeReadStream);
return makeReaderRef(reader);
~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that allowed me to do:
$ ./bin/endo eval w1 'E(mkc).text()' mkc
const makeCounter = () => {
let value = 0;
return {
incr: () => (value += 1),
decr: () => (value -= 1),
};
};
makeCounter;
but this hangs:
./bin/endo eval w1 'E(mkc).text().then(eval)' mkc
I couldn't find a worker log. (I did find a worker .pid file.)
Is it as-designed that objects-as-closures don't keep their internal state across restarts? This surprised me:
That was after...
|
31169ac
to
24b73ea
Compare
b5dd152
to
3e633fb
Compare
3b4673c
to
50fef2f
Compare
3e633fb
to
ae6bea4
Compare
50fef2f
to
84d11e4
Compare
ae6bea4
to
6370979
Compare
84d11e4
to
c5c9ec6
Compare
6370979
to
83abba9
Compare
c5c9ec6
to
13c7181
Compare
83abba9
to
ab1d625
Compare
13c7181
to
a7b052f
Compare
ab1d625
to
40aa584
Compare
a7b052f
to
111cf83
Compare
40aa584
to
32a77d4
Compare
111cf83
to
b7c2441
Compare
32a77d4
to
9155f58
Compare
0ce8a5e
to
af2a376
Compare
dea9f89
to
02d7399
Compare
… termination refactor
02d7399
to
ed3c23e
Compare
All feedback captured in the |
Individually reviewable commits.
This change will introduce pet-named workers, storage, and values to the Endo Daemon and expose them with its CLI. With this change, the following workflows become possible:
Ephemeral evaluation in an isolated worker:
Persisted evaluation from a worker, using a pet name and a derivation path.
Evaluation with endowments:
Storage:
Storage of archive:
These are a preamble to composite commands like
endo install
, which would store, spawn, and eval (or rather, importBundle), and subsequent work to reveal pet named capabilities to workers on-demand at the user’s discretion.endo follow [name]
is also an obvious next step, for following a pet-named async iterator.