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

explicit type exports for agoric/notifier #9305

Merged
merged 14 commits into from
May 1, 2024
Merged

explicit type exports for agoric/notifier #9305

merged 14 commits into from
May 1, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented Apr 29, 2024

refs: #6512

Description

Progress on #6512, spawned from #9300.

This gives the @agoric/notifier package explicit exports.

Many downstream packages were relying on @agoric/notifier ambients for types from @agoric/internal or Endo, so this also adds an exported.js to @agoric/internal to provide those. (E.g. ERef).

Security Considerations

none, types

Scaling Considerations

none, types

Documentation Considerations

might improve API docs of Notifier package

Testing Considerations

CI

Upgrade Considerations

none, types

@turadg turadg requested review from dckc and samsiegart April 29, 2024 16:53
Copy link

cloudflare-workers-and-pages bot commented Apr 29, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 001d8e4
Status: ✅  Deploy successful!
Preview URL: https://d16dd55e.agoric-sdk.pages.dev
Branch Preview URL: https://ta-notifier-types.agoric-sdk.pages.dev

View logs

Copy link
Member

@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.

I don't see any critical problems, but I'm not confident about approving yet; I'd like to hear more about these comments...

packages/cache/src/main.js Show resolved Hide resolved
Comment on lines +3 to +5
import {
EachTopic as _EachTopic,
Copy link
Member

Choose a reason for hiding this comment

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

somewhere I saw a good explanation of why these gymnastics are used, including a stackoverflow reference; is it convenient to add a pointer from here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I resisted coping it an Nth time. I'll write up some docs in Markdown and have the modules reference it

"prepack": "echo \"export {}; \" | cat - src/types-ambient.js > src/types.js && tsc --build tsconfig.build.json",
"prepack": "tsc --build tsconfig.build.json",
Copy link
Member

Choose a reason for hiding this comment

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

👏 good riddance

Copy link
Member Author

Choose a reason for hiding this comment

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

this is the PR's raison d'être

@@ -1,5 +1,7 @@
// @jessie-check

import '@agoric/internal/exported.js';
Copy link
Member

Choose a reason for hiding this comment

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

is it worth an XXX or something on these? or UNTIL #6512 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

there are tons of these but I tried to comment a bunch of them

@@ -26,3 +28,6 @@ export {
} from './asyncIterableAdaptor.js';
export * from './storesub.js';
export * from './stored-notifier.js';

// eslint-disable-next-line import/export -- doesn't know types
export * from './types.js';
Copy link
Member

Choose a reason for hiding this comment

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

so this is a solution to the question of re-exporting?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is the right way to export at the top level. unfortunately it doesn't work for @agoric/ertp because it has AssetKind as both a type and kind

Copy link
Member

Choose a reason for hiding this comment

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

interesting.

considers an issue to change the name of the type to AssetKindT

/**
* @import {ERef} from '@endo/far';
* @import {BaseNotifier, Notifier, StoredFacet} from './types.js';
* @import {Marshaller, StorageNode, Unserializer} from '@agoric/internal/src/lib-chainStorage.js';
Copy link
Member

Choose a reason for hiding this comment

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

having StorageNode in @agoric/internal looks more and more awkward.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. and @agoric/notifier depending on ChainStorage.

  "description": "Notifier allows services to update clients about state changes using a stream of promises",

@@ -97,7 +103,7 @@ export const makeStoredSubscription = (
serializeBodyFormat: 'smallcaps',
}),
) => {
/** @type {Unserializer} */
/** @type {import('@agoric/internal/src/lib-chainStorage.js').Unserializer} */
Copy link
Member

Choose a reason for hiding this comment

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

The @import on line 13 didn't work?

Copy link
Member Author

@turadg turadg Apr 29, 2024

Choose a reason for hiding this comment

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

just extra chars. fixed


/**
* @import {ERef} from '@endo/far';
* @import {IterationObserver, LatestTopic, Notifier, NotifierRecord, PublicationRecord, Publisher, PublishKit, StoredPublishKit, StoredSubscription, StoredSubscriber, Subscriber, Subscription, UpdateRecord} from '../src/types.js';
Copy link
Member

Choose a reason for hiding this comment

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

These long lists make me wonder about qualified imports.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. .ts and its tooling makes the long list easy to work with but for JSDoc we might be better off with a name per module

import '../src/types-ambient.js';
import '../src/types.js';
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised that this works. types.js is now a module, so types defined there are not ambient, right?

Copy link
Member Author

@turadg turadg Apr 29, 2024

Choose a reason for hiding this comment

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

it's a noop but I'll remove it

@turadg turadg requested a review from dckc April 29, 2024 18:25
Copy link
Member

@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.

ok, none of my questions turned up answers that I'm not comfortable with.

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Apr 29, 2024
@turadg turadg force-pushed the ta/notifier-types branch 2 times, most recently from 53f5b00 to 20b9c5e Compare April 30, 2024 00:22
@turadg turadg added force:integration Force integration tests to run on PR and removed automerge:rebase Automatically rebase updates, then merge labels Apr 30, 2024
@turadg turadg requested a review from dckc April 30, 2024 18:57
Copy link
Member

@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 good.

Review by commit gives me reasonable confidence that conflicts with release branches should be manageable.

* WaitUntilQuiescent,
* XSnap,
* } from './types-external.js')
* @import { Bundle, BundleCap, BundleFormat, BundleID, BundleRef, BundleSpec, DeviceInvocation, DeviceInvocationResult, DeviceInvocationResultError, DeviceInvocationResultOk, EndoZipBase64Bundle, GetExportBundle, KernelDeliveryBringOutYourDead, KernelDeliveryChangeVatOptions, KernelDeliveryDropExports, KernelDeliveryMessage, KernelDeliveryNotify, KernelDeliveryObject, KernelDeliveryOneNotify, KernelDeliveryRetireExports, KernelDeliveryRetireImports, KernelDeliveryStartVat, KernelKeeper, KernelOneResolution, KernelOptions, KernelSlog, KernelSyscallDropImports, KernelSyscallExit, KernelSyscallInvoke, KernelSyscallObject, KernelSyscallResolve, KernelSyscallResult, KernelSyscallResultError, KernelSyscallResultOk, KernelSyscallRetireExports, KernelSyscallRetireImports, KernelSyscallSend, KernelSyscallSubscribe, KernelSyscallVatstoreDelete, KernelSyscallVatstoreGet, KernelSyscallVatstoreGetNextKey, KernelSyscallVatstoreSet, ManagerType, Message, MeteringVatPowers, NestedEvaluateBundle, PolicyInput, PolicyInputCrankComplete, PolicyInputCrankFailed, PolicyInputCreateVat, PolicyInputNone, PolicyOutput, ResolutionPolicy, RunPolicy, SlogFinishDelivery, SlogFinishSyscall, SnapshotResult, SnapStore, SourceOfBundle, SourceSpec, StaticVatPowers, SwingSetCapData, SwingSetConfig, SwingSetConfigDescriptor, SwingSetConfigProperties, SwingSetKernelConfig, TerminationVatPowers, VatAdminSvc, VatKeeper, VatPowers, VatSlog, VatStats, WaitUntilQuiescent, XSnap, } from './types-external.js';
Copy link
Member

Choose a reason for hiding this comment

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

does this work?
IME, @import makes this act like a module and hence not produce ambient types.
But I guess it was that way before this PR.

Copy link
Member Author

@turadg turadg Apr 30, 2024

Choose a reason for hiding this comment

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

I don't know all the cases yet but in this one the ambient work, maybe because swingset-vats never builds .d.ts.

When I get it to build types-ambient.d.ts it's empty:

//# sourceMappingURL=types-ambient.d.ts.map

Comment on lines -398 to +415
* @param {Remote<ProtocolImpl>} opts.protocolImpl
* @param {import('@agoric/vow').Remote<ProtocolImpl>} opts.protocolImpl
Copy link
Member

Choose a reason for hiding this comment

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

importing Remote once didn't work?

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Apr 30, 2024
@turadg turadg force-pushed the ta/notifier-types branch 3 times, most recently from cac8216 to ff95b42 Compare April 30, 2024 23:10
@mergify mergify bot merged commit e456308 into master May 1, 2024
67 checks passed
@mergify mergify bot deleted the ta/notifier-types branch May 1, 2024 00:13
@turadg turadg mentioned this pull request May 1, 2024
mergify bot added a commit that referenced this pull request May 2, 2024
refs: #9305

## Description

While working on #9305 I was slowed down by the `types.js` files that
were really ambients.

This makes all `types.js` that aren't modules into `types-ambient.js`. 

The ambients for `zoe/tools` I ditched by making them explicit exports,
to continue supporting that part of the package API that the `prepack`
rename was doing.

### Security Considerations

<!-- Does this change introduce new assumptions or dependencies that, if
violated, could introduce security vulnerabilities? How does this PR
change the boundaries between mutually-suspicious components? What new
authorities are introduced by this change, perhaps by new API calls?
-->

### Scaling Considerations

<!-- Does this change require or encourage significant increase in
consumption of CPU cycles, RAM, on-chain storage, message exchanges, or
other scarce resources? If so, can that be prevented or mitigated? -->

### Documentation Considerations

<!-- Give our docs folks some hints about what needs to be described to
downstream users.

Backwards compatibility: what happens to existing data or deployments
when this code is shipped? Do we need to instruct users to do something
to upgrade their saved data? If there is no upgrade path possible, how
bad will that be for users?

-->

### Testing Considerations

<!-- Every PR should of course come with tests of its own functionality.
What additional tests are still needed beyond those unit tests? How does
this affect CI, other test automation, or the testnet?
-->

### Upgrade Considerations

<!-- What aspects of this PR are relevant to upgrading live production
systems, and how should they be addressed? -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants