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): Undeniable host INFO tool #1916

Merged
merged 6 commits into from
Jan 30, 2024
Merged

Conversation

kriskowal
Copy link
Member

@kriskowal kriskowal commented Dec 29, 2023

Problem: Commands like endo make counter.js --name counter implicitly create a unique worker for the counter. This makes it impossible to address the worker for follow-up commands, like an eval co-located with the counter.

This change introduces an undeniable INFO name to all hosts that allows the host to address the values used to create pet named values. For example, INFO -> counter -> worker addresses the worker that was used to create counter. Until we have pet name path lookup (#1915), you need multiple invocations of E() to perform of depth greater than 1, for example:

> endo make counter.js --name counter
  Object [Alleged: Counter] {}
> endo eval 'E(INFO).lookup("counter")' INFO --name inspector
  Object [Alleged: Inspector (make-bundle ... )]
> endo eval 'E(inspector).lookup("worker")' inspector
  Object [Alleged: EndoWorker] {}

This facility is intended to compose well with follow-up changes for inspecting a worker’s log or copy one of these “unnamed” capabilities to a name.

@kriskowal kriskowal requested review from dckc and kumavis December 29, 2023 22:40
Copy link
Contributor

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks plausible. I don't see any correctness issues.

without tests, I defer to others to approve

packages/daemon/src/daemon.js Outdated Show resolved Hide resolved
packages/daemon/src/daemon.js Outdated Show resolved Hide resolved
@kriskowal kriskowal assigned kriskowal and kumavis and unassigned kriskowal Jan 5, 2024
packages/daemon/src/daemon.js Outdated Show resolved Hide resolved
Copy link
Member

@kumavis kumavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see types for these interfaces. I'd also suggest that because we control all these keys (no user specified keys), they don't need to be capitalized

eval
  SOURCE
  WORKER
  ENDOWMENTS
import-unsafe
  SPECIFIER
  WORKER
  POWERS
import-bundle
  WORKER
  BUNDLE
  POWERS
guest
  HOST
web-bundle
  BUNDLE
  POWERS

@rekmarks rekmarks assigned rekmarks and unassigned kumavis Jan 23, 2024
@rekmarks rekmarks force-pushed the kriskowal-daemon-inspector branch from d149e64 to c369498 Compare January 23, 2024 06:35
@rekmarks rekmarks marked this pull request as draft January 23, 2024 06:36
@rekmarks rekmarks force-pushed the kriskowal-daemon-inspector branch 2 times, most recently from ae27dc1 to 1362fd8 Compare January 25, 2024 04:24
@rekmarks rekmarks force-pushed the kriskowal-daemon-inspector branch 3 times, most recently from b4ba0f9 to aeac064 Compare January 30, 2024 07:18
- Updates INFO-related internals to refer to "inspector"
  instead of "info".
- Adds types for different "known" inspectors (e.g.
  for `eval` formulas).
- Lower-cases known inspector special names (e.g. `bundle`).
@rekmarks rekmarks force-pushed the kriskowal-daemon-inspector branch from 7f4adfb to 585e17d Compare January 30, 2024 17:56
Comment on lines 739 to 741
// TODO: This test verifies existing behavior when pet-naming workers.
// This behavior is undesirable.
test('eval-mediated worker name', async t => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went for a passing test rather than test.failing() because the test could otherwise start to fail for an unexpected reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue for this: #2021

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We like embedding links to issues in the code, especially for something like this.

Comment on lines +635 to +640
/**
* @param {string} petName - The pet name to inspect.
* @returns {Promise<import('./types').KnownEndoInspectors[string]>} An
* inspector for the value of the given pet name.
*/
const lookup = async petName => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have types for the individual known inspectors (see types.d.ts), but due to the indirection between the petName argument and the formulaType, it is difficult (impossible?) to map the petName to the "correct" return type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We can’t be more specific than a union of all known inspector types. Lookup in general has this limitation. For some Endo APIs, we could overload a formula type argument and provide guarantees of specific types, to make some casts unnecessary.

@rekmarks rekmarks requested a review from kumavis January 30, 2024 18:43
@rekmarks rekmarks marked this pull request as ready for review January 30, 2024 18:44
Copy link
Member Author

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve, but as the author can’t authorize a merge. Need a second opinion, possibly from coauthor @rekmarks, better from @kumavis.

@@ -1,10 +1,11 @@
const { quote: q } = assert;

const numberlessFormulasIdentifiers = new Set([
'pet-store',
'host',
'endo',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add a comment that these are sorted, to maintain that invariant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer this to when I look into our lint configs.

Comment on lines 739 to 741
// TODO: This test verifies existing behavior when pet-naming workers.
// This behavior is undesirable.
test('eval-mediated worker name', async t => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We like embedding links to issues in the code, especially for something like this.

Copy link
Member

@kumavis kumavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whee

@rekmarks rekmarks force-pushed the kriskowal-daemon-inspector branch from 585e17d to 4b45a7a Compare January 30, 2024 22:50
@rekmarks rekmarks merged commit c2f3c9a into endo Jan 30, 2024
14 checks passed
@rekmarks rekmarks deleted the kriskowal-daemon-inspector branch January 30, 2024 23:03
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.

4 participants