From 6d1fb4064dd0c5262e2677ab3b6f6bf3bd21f310 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Mon, 18 Mar 2024 10:06:51 -0700 Subject: [PATCH] refactor(daemon): Rename "incarnate" to "formulate" Replaces all references to "incarnate"/"incarnation" with "formulate"/"formulation". Incarnations will live on in the phylacteries of our hearts. --- packages/daemon/src/daemon.js | 242 +++++++++++++++---------------- packages/daemon/src/directory.js | 6 +- packages/daemon/src/host.js | 52 +++---- packages/daemon/src/types.d.ts | 84 +++++------ 4 files changed, 190 insertions(+), 194 deletions(-) diff --git a/packages/daemon/src/daemon.js b/packages/daemon/src/daemon.js index 474a1c4180..b8b5e7761f 100644 --- a/packages/daemon/src/daemon.js +++ b/packages/daemon/src/daemon.js @@ -101,9 +101,9 @@ const makeDaemonCore = async ( /** * Mutations of the formula graph must be serialized through this queue. * "Mutations" include: - * - Creation + * - Formulation * - Removal - * - Incarnation + * - Provision * - Cancellation */ const formulaGraphJobs = makeSerialJobs(); @@ -126,7 +126,7 @@ const makeDaemonCore = async ( node: ownNodeIdentifier, }); - // Prime least authority formula (without incarnation) + // Prepare least authority formula const leastAuthorityFormulaNumber = deriveId( 'none', rootEntropy, @@ -140,7 +140,7 @@ const makeDaemonCore = async ( type: 'least-authority', }); - // Prime main worker formula (without incarnation) + // Prepare main worker formula const mainWorkerFormulaNumber = deriveId( 'main', rootEntropy, @@ -160,7 +160,7 @@ const makeDaemonCore = async ( MAIN: mainWorkerId, }; - // Generate platform formulas (without incarnation) + // Prepare platform formulas const platformNames = Object.fromEntries( await Promise.all( Object.entries(specials).map(async ([specialName, makeFormula]) => { @@ -184,8 +184,8 @@ const makeDaemonCore = async ( * The two functions "formulate" and "provide" share a responsibility for * maintaining the memoization tables "controllerForId" and * "idForRef". - * "formulate" is used for incarnating and persisting new formulas, whereas - * "provide" is used for reincarnating stored formulas. + * "formulate" is used for creating and persisting new formulas, whereas + * "provide" is used for "reincarnating" the values of stored formulas. */ /** @@ -584,7 +584,7 @@ const makeDaemonCore = async ( } const { id: peerId } = // eslint-disable-next-line no-use-before-define - await incarnatePeer(formula.networks, addresses); + await formulatePeer(formula.networks, addresses); await peerPetstore.write(nodeName, peerId); }, }); @@ -741,7 +741,7 @@ const makeDaemonCore = async ( ); // Ensure that failure to flush the formula to storage - // causes a rejection for both the controller and the incarnation value. + // causes a rejection for both the controller and the value. const written = persistencePowers.writeFormula(formulaNumber, formula); resolvePartial(written.then(() => /** @type {any} */ (controllerValue))); await written; @@ -852,8 +852,8 @@ const makeDaemonCore = async ( } }; - /** @type {import('./types.js').DaemonCore['incarnateReadableBlob']} */ - const incarnateReadableBlob = async (readerRef, deferredTasks) => { + /** @type {import('./types.js').DaemonCore['formulateReadableBlob']} */ + const formulateReadableBlob = async (readerRef, deferredTasks) => { const { formulaNumber, contentSha512 } = await formulaGraphJobs.enqueue( async () => { const values = { @@ -878,52 +878,52 @@ const makeDaemonCore = async ( content: contentSha512, }; - return /** @type {import('./types.js').IncarnateResult} */ ( + return /** @type {import('./types.js').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; /** - * Incarnates a `handle` formula and synchronously adds it to the formula graph. + * Formulates a `handle` formula and synchronously adds it to the formula graph. * The returned promise is resolved after the formula is persisted. * - * @param {string} formulaNumber - The formula number of the handle to incarnate. + * @param {string} formulaNumber - The formula number of the handle to formulate. * @param {string} targetId - The formula identifier of the handle's target. - * @returns {import('./types.js').IncarnateResult} The incarnated handle. + * @returns {import('./types.js').FormulateResult} The formulated handle. */ - const incarnateNumberedHandle = (formulaNumber, targetId) => { + const formulateNumberedHandle = (formulaNumber, targetId) => { /** @type {import('./types.js').HandleFormula} */ const formula = { type: 'handle', target: targetId, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; /** - * Incarnates a `pet-store` formula and synchronously adds it to the formula graph. + * Formulates a `pet-store` formula and synchronously adds it to the formula graph. * The returned promise is resolved after the formula is persisted. * - * @param {string} formulaNumber - The formula number of the pet store to incarnate. - * @returns {import('./types.js').IncarnateResult} The incarnated pet store. + * @param {string} formulaNumber - The formula number of the pet store to formulate. + * @returns {import('./types.js').FormulateResult} The formulated pet store. */ - const incarnateNumberedPetStore = async formulaNumber => { + const formulateNumberedPetStore = async formulaNumber => { /** @type {import('./types.js').PetStoreFormula} */ const formula = { type: 'pet-store', }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; /** - * @type {import('./types.js').DaemonCore['incarnateDirectory']} + * @type {import('./types.js').DaemonCore['formulateDirectory']} */ - const incarnateDirectory = async () => { - const { id: petStoreId } = await incarnateNumberedPetStore( + const formulateDirectory = async () => { + const { id: petStoreId } = await formulateNumberedPetStore( await randomHex512(), ); const formulaNumber = await randomHex512(); @@ -932,34 +932,34 @@ const makeDaemonCore = async ( type: 'directory', petStore: petStoreId, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; /** - * Incarnates a `worker` formula and synchronously adds it to the formula graph. + * Formulates a `worker` formula and synchronously adds it to the formula graph. * The returned promise is resolved after the formula is persisted. * * @param {string} formulaNumber - The worker formula number. - * @returns {ReturnType} + * @returns {ReturnType} */ - const incarnateNumberedWorker = formulaNumber => { + const formulateNumberedWorker = formulaNumber => { /** @type {import('./types.js').WorkerFormula} */ const formula = { type: 'worker', }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; /** - * @type {import('./types.js').DaemonCore['incarnateWorker']} + * @type {import('./types.js').DaemonCore['formulateWorker']} */ - const incarnateWorker = async deferredTasks => { - return incarnateNumberedWorker( + const formulateWorker = async deferredTasks => { + return formulateNumberedWorker( await formulaGraphJobs.enqueue(async () => { const formulaNumber = await randomHex512(); @@ -976,13 +976,13 @@ const makeDaemonCore = async ( }; /** - * @type {import('./types.js').DaemonCoreInternal['incarnateHostDependencies']} + * @type {import('./types.js').DaemonCoreInternal['formulateHostDependencies']} */ - const incarnateHostDependencies = async specifiedIdentifiers => { + const formulateHostDependencies = async specifiedIdentifiers => { const { specifiedWorkerId, ...remainingSpecifiedIdentifiers } = specifiedIdentifiers; - const storeId = (await incarnateNumberedPetStore(await randomHex512())).id; + const storeId = (await formulateNumberedPetStore(await randomHex512())).id; return harden({ ...remainingSpecifiedIdentifiers, @@ -990,15 +990,15 @@ const makeDaemonCore = async ( storeId, /* eslint-disable no-use-before-define */ inspectorId: ( - await incarnateNumberedPetInspector(await randomHex512(), storeId) + await formulateNumberedPetInspector(await randomHex512(), storeId) ).id, workerId: await provideWorkerId(specifiedWorkerId), /* eslint-enable no-use-before-define */ }); }; - /** @type {import('./types.js').DaemonCoreInternal['incarnateNumberedHost']} */ - const incarnateNumberedHost = identifiers => { + /** @type {import('./types.js').DaemonCoreInternal['formulateNumberedHost']} */ + const formulateNumberedHost = identifiers => { /** @type {import('./types.js').HostFormula} */ const formula = { type: 'host', @@ -1009,21 +1009,21 @@ const makeDaemonCore = async ( networks: identifiers.networksDirectoryId, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(identifiers.hostFormulaNumber, formula) ); }; - /** @type {import('./types.js').DaemonCore['incarnateHost']} */ - const incarnateHost = async ( + /** @type {import('./types.js').DaemonCore['formulateHost']} */ + const formulateHost = async ( endoId, networksDirectoryId, deferredTasks, specifiedWorkerId, ) => { - return incarnateNumberedHost( + return formulateNumberedHost( await formulaGraphJobs.enqueue(async () => { - const identifiers = await incarnateHostDependencies({ + const identifiers = await formulateHostDependencies({ endoId, networksDirectoryId, specifiedWorkerId, @@ -1041,19 +1041,19 @@ const makeDaemonCore = async ( ); }; - /** @type {import('./types.js').DaemonCoreInternal['incarnateGuestDependencies']} */ - const incarnateGuestDependencies = async hostId => + /** @type {import('./types.js').DaemonCoreInternal['formulateGuestDependencies']} */ + const formulateGuestDependencies = async hostId => harden({ guestFormulaNumber: await randomHex512(), hostHandleId: ( - await incarnateNumberedHandle(await randomHex512(), hostId) + await formulateNumberedHandle(await randomHex512(), hostId) ).id, - storeId: (await incarnateNumberedPetStore(await randomHex512())).id, - workerId: (await incarnateNumberedWorker(await randomHex512())).id, + storeId: (await formulateNumberedPetStore(await randomHex512())).id, + workerId: (await formulateNumberedWorker(await randomHex512())).id, }); - /** @type {import('./types.js').DaemonCoreInternal['incarnateNumberedGuest']} */ - const incarnateNumberedGuest = identifiers => { + /** @type {import('./types.js').DaemonCoreInternal['formulateNumberedGuest']} */ + const formulateNumberedGuest = identifiers => { /** @type {import('./types.js').GuestFormula} */ const formula = { type: 'guest', @@ -1062,16 +1062,16 @@ const makeDaemonCore = async ( worker: identifiers.workerId, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(identifiers.guestFormulaNumber, formula) ); }; - /** @type {import('./types.js').DaemonCore['incarnateGuest']} */ - const incarnateGuest = async (hostId, deferredTasks) => { - return incarnateNumberedGuest( + /** @type {import('./types.js').DaemonCore['formulateGuest']} */ + const formulateGuest = async (hostId, deferredTasks) => { + return formulateNumberedGuest( await formulaGraphJobs.enqueue(async () => { - const identifiers = await incarnateGuestDependencies(hostId); + const identifiers = await formulateGuestDependencies(hostId); await deferredTasks.execute({ agentId: formatId({ @@ -1095,14 +1095,14 @@ const makeDaemonCore = async ( } const workerFormulaNumber = await randomHex512(); - const workerIncarnation = await incarnateNumberedWorker( + const workerFormulation = await formulateNumberedWorker( workerFormulaNumber, ); - return workerIncarnation.id; + return workerFormulation.id; }; - /** @type {import('./types.js').DaemonCore['incarnateEval']} */ - const incarnateEval = async ( + /** @type {import('./types.js').DaemonCore['formulateEval']} */ + const formulateEval = async ( nameHubId, source, codeNames, @@ -1128,7 +1128,7 @@ const makeDaemonCore = async ( return ( /* eslint-disable no-use-before-define */ ( - await incarnateNumberedLookup( + await formulateNumberedLookup( await randomHex512(), nameHubId, formulaIdOrPath, @@ -1154,13 +1154,13 @@ const makeDaemonCore = async ( names: codeNames, values: endowmentIds, }; - return /** @type {import('./types.js').IncarnateResult} */ ( + return /** @type {import('./types.js').FormulateResult} */ ( formulate(evalFormulaNumber, formula) ); }; /** - * Incarnates a `lookup` formula and synchronously adds it to the formula graph. + * Formulates a `lookup` formula and synchronously adds it to the formula graph. * The returned promise is resolved after the formula is persisted. * @param {string} formulaNumber - The lookup formula's number. * @param {string} hubId - The formula identifier of the naming @@ -1169,7 +1169,7 @@ const makeDaemonCore = async ( * @param {string[]} petNamePath - The pet name path to look up. * @returns {Promise<{ id: string, value: import('./types').EndoWorker }>} */ - const incarnateNumberedLookup = (formulaNumber, hubId, petNamePath) => { + const formulateNumberedLookup = (formulaNumber, hubId, petNamePath) => { /** @type {import('./types.js').LookupFormula} */ const formula = { type: 'lookup', @@ -1177,7 +1177,7 @@ const makeDaemonCore = async ( path: petNamePath, }; - return /** @type {import('./types.js').IncarnateResult} */ ( + return /** @type {import('./types.js').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; @@ -1192,21 +1192,19 @@ const makeDaemonCore = async ( return specifiedPowersId; } - const guestIncarnationData = await incarnateGuestDependencies(hostId); - const guestIncarnation = await incarnateNumberedGuest(guestIncarnationData); - return guestIncarnation.id; + const guestFormulationData = await formulateGuestDependencies(hostId); + const guestFormulation = await formulateNumberedGuest(guestFormulationData); + return guestFormulation.id; }; /** - * Helper for `incarnateUnconfined` and `incarnateBundle`. - * @param {'make-bundle' | 'make-unconfined'} formulaType + * Helper for `formulateUnconfined` and `formulateBundle`. * @param {string} hostId * @param {import('./types.js').DeferredTasks} deferredTasks * @param {string} [specifiedWorkerId] * @param {string} [specifiedPowersId] */ - const incarnateCapletDependencies = async ( - formulaType, + const formulateCapletDependencies = async ( hostId, deferredTasks, specifiedWorkerId, @@ -1226,8 +1224,8 @@ const makeDaemonCore = async ( return identifiers; }; - /** @type {import('./types.js').DaemonCore['incarnateUnconfined']} */ - const incarnateUnconfined = async ( + /** @type {import('./types.js').DaemonCore['formulateUnconfined']} */ + const formulateUnconfined = async ( hostId, specifier, deferredTasks, @@ -1236,8 +1234,7 @@ const makeDaemonCore = async ( ) => { const { powersId, capletFormulaNumber, workerId } = await formulaGraphJobs.enqueue(() => - incarnateCapletDependencies( - 'make-unconfined', + formulateCapletDependencies( hostId, deferredTasks, specifiedWorkerId, @@ -1255,8 +1252,8 @@ const makeDaemonCore = async ( return formulate(capletFormulaNumber, formula); }; - /** @type {import('./types.js').DaemonCore['incarnateBundle']} */ - const incarnateBundle = async ( + /** @type {import('./types.js').DaemonCore['formulateBundle']} */ + const formulateBundle = async ( hostId, bundleId, deferredTasks, @@ -1265,8 +1262,7 @@ const makeDaemonCore = async ( ) => { const { powersId, capletFormulaNumber, workerId } = await formulaGraphJobs.enqueue(() => - incarnateCapletDependencies( - 'make-bundle', + formulateCapletDependencies( hostId, deferredTasks, specifiedWorkerId, @@ -1288,19 +1284,19 @@ const makeDaemonCore = async ( * @param {string} formulaNumber * @param {string} petStoreId */ - const incarnateNumberedPetInspector = (formulaNumber, petStoreId) => { + const formulateNumberedPetInspector = (formulaNumber, petStoreId) => { /** @type {import('./types.js').PetInspectorFormula} */ const formula = { type: 'pet-inspector', petStore: petStoreId, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; - /** @type {import('./types.js').DaemonCore['incarnatePeer']} */ - const incarnatePeer = async (networksDirectoryId, addresses) => { + /** @type {import('./types.js').DaemonCore['formulatePeer']} */ + const formulatePeer = async (networksDirectoryId, addresses) => { const formulaNumber = await randomHex512(); // TODO: validate addresses // TODO: mutable state like addresses should not be stored in formula @@ -1310,34 +1306,34 @@ const makeDaemonCore = async ( networks: networksDirectoryId, addresses, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; - /** @type {import('./types.js').DaemonCore['incarnateLoopbackNetwork']} */ - const incarnateLoopbackNetwork = async () => { + /** @type {import('./types.js').DaemonCore['formulateLoopbackNetwork']} */ + const formulateLoopbackNetwork = async () => { const formulaNumber = await randomHex512(); /** @type {import('./types').LoopbackNetworkFormula} */ const formula = { type: 'loopback-network', }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) ); }; - /** @type {import('./types.js').DaemonCore['incarnateNetworksDirectory']} */ - const incarnateNetworksDirectory = async () => { - const { id, value } = await incarnateDirectory(); + /** @type {import('./types.js').DaemonCore['formulateNetworksDirectory']} */ + const formulateNetworksDirectory = async () => { + const { id, value } = await formulateDirectory(); // Make default networks. - const { id: loopbackNetworkId } = await incarnateLoopbackNetwork(); + const { id: loopbackNetworkId } = await formulateLoopbackNetwork(); await E(value).write(['loop'], loopbackNetworkId); return { id, value }; }; - /** @type {import('./types.js').DaemonCore['incarnateEndoBootstrap']} */ - const incarnateEndoBootstrap = async specifiedFormulaNumber => { + /** @type {import('./types.js').DaemonCore['formulateEndoBootstrap']} */ + const formulateEndoBootstrap = async specifiedFormulaNumber => { const identifiers = await formulaGraphJobs.enqueue(async () => { const formulaNumber = await (specifiedFormulaNumber ?? randomHex512()); const endoId = formatId({ @@ -1345,20 +1341,20 @@ const makeDaemonCore = async ( node: ownNodeIdentifier, }); - const { id: defaultHostWorkerId } = await incarnateNumberedWorker( + const { id: defaultHostWorkerId } = await formulateNumberedWorker( await randomHex512(), ); - const { id: networksDirectoryId } = await incarnateNetworksDirectory(); - const { id: newPeersId } = await incarnateNumberedPetStore( + const { id: networksDirectoryId } = await formulateNetworksDirectory(); + const { id: newPeersId } = await formulateNumberedPetStore( peersFormulaNumber, ); if (newPeersId !== peersId) { assert.Fail`Peers PetStore formula identifier did not match expected value, expected ${peersId}, got ${newPeersId}`; } - // Ensure the default host is incarnated and persisted. - const { id: defaultHostId } = await incarnateNumberedHost( - await incarnateHostDependencies({ + // Ensure the default host is formulated and persisted. + const { id: defaultHostId } = await formulateNumberedHost( + await formulateHostDependencies({ endoId, networksDirectoryId, specifiedWorkerId: defaultHostWorkerId, @@ -1381,7 +1377,7 @@ const makeDaemonCore = async ( leastAuthority: leastAuthorityId, }; - return /** @type {import('./types').IncarnateResult} */ ( + return /** @type {import('./types').FormulateResult} */ ( formulate(identifiers.formulaNumber, formula) ); }; @@ -1483,7 +1479,7 @@ const makeDaemonCore = async ( const { makeIdentifiedDirectory, makeDirectoryNode } = makeDirectoryMaker({ provide, getIdForRef, - incarnateDirectory, + formulateDirectory, }); const makeMailbox = makeMailboxMaker({ @@ -1502,13 +1498,13 @@ const makeDaemonCore = async ( provide, provideController, cancelValue, - incarnateWorker, - incarnateHost, - incarnateGuest, - incarnateEval, - incarnateUnconfined, - incarnateBundle, - incarnateReadableBlob, + formulateWorker, + formulateHost, + formulateGuest, + formulateEval, + formulateUnconfined, + formulateBundle, + formulateReadableBlob, makeMailbox, makeDirectoryNode, getAllNetworkAddresses, @@ -1541,7 +1537,7 @@ const makeDaemonCore = async ( } const { number: formulaNumber } = parseId(id); // TODO memoize formulas at the root of the - // id->formula->controller->incarnation tree. + // id->formula->controller->value tree. const formula = await persistencePowers.readFormula(formulaNumber); if ( !['eval', 'lookup', 'make-unconfined', 'make-bundle', 'guest'].includes( @@ -1636,18 +1632,18 @@ const makeDaemonCore = async ( cancelValue, makeMailbox, makeDirectoryNode, - incarnateEndoBootstrap, - incarnateNetworksDirectory, - incarnateLoopbackNetwork, - incarnateDirectory, - incarnateWorker, - incarnateHost, - incarnateGuest, - incarnatePeer, - incarnateEval, - incarnateUnconfined, - incarnateReadableBlob, - incarnateBundle, + formulateEndoBootstrap, + formulateNetworksDirectory, + formulateLoopbackNetwork, + formulateDirectory, + formulateWorker, + formulateHost, + formulateGuest, + formulatePeer, + formulateEval, + formulateUnconfined, + formulateReadableBlob, + formulateBundle, }; return daemonCore; }; @@ -1684,7 +1680,7 @@ const provideEndoBootstrap = async ( daemonCore.provide(endoId) ); } else { - const { value: endoBootstrap } = await daemonCore.incarnateEndoBootstrap( + const { value: endoBootstrap } = await daemonCore.formulateEndoBootstrap( endoFormulaNumber, ); return endoBootstrap; diff --git a/packages/daemon/src/directory.js b/packages/daemon/src/directory.js index 2df2c5ece4..f6dd55b025 100644 --- a/packages/daemon/src/directory.js +++ b/packages/daemon/src/directory.js @@ -9,12 +9,12 @@ const { quote: q } = assert; * @param {object} args * @param {import('./types.js').DaemonCore['provide']} args.provide * @param {import('./types.js').DaemonCore['getIdForRef']} args.getIdForRef - * @param {import('./types.js').DaemonCore['incarnateDirectory']} args.incarnateDirectory + * @param {import('./types.js').DaemonCore['formulateDirectory']} args.formulateDirectory */ export const makeDirectoryMaker = ({ provide, getIdForRef, - incarnateDirectory, + formulateDirectory, }) => { /** @type {import('./types.js').MakeDirectoryNode} */ const makeDirectoryNode = petStore => { @@ -172,7 +172,7 @@ export const makeDirectoryMaker = ({ /** @type {import('./types.js').EndoDirectory['makeDirectory']} */ const makeDirectory = async directoryPetName => { - const { value: directory, id } = await incarnateDirectory(); + const { value: directory, id } = await formulateDirectory(); await petStore.write(directoryPetName, id); return directory; }; diff --git a/packages/daemon/src/host.js b/packages/daemon/src/host.js index e5f2e11333..da5d5c5300 100644 --- a/packages/daemon/src/host.js +++ b/packages/daemon/src/host.js @@ -18,13 +18,13 @@ const assertPowersName = name => { * @param {import('./types.js').DaemonCore['provide']} args.provide * @param {import('./types.js').DaemonCore['provideController']} args.provideController * @param {import('./types.js').DaemonCore['cancelValue']} args.cancelValue - * @param {import('./types.js').DaemonCore['incarnateWorker']} args.incarnateWorker - * @param {import('./types.js').DaemonCore['incarnateHost']} args.incarnateHost - * @param {import('./types.js').DaemonCore['incarnateGuest']} args.incarnateGuest - * @param {import('./types.js').DaemonCore['incarnateEval']} args.incarnateEval - * @param {import('./types.js').DaemonCore['incarnateUnconfined']} args.incarnateUnconfined - * @param {import('./types.js').DaemonCore['incarnateBundle']} args.incarnateBundle - * @param {import('./types.js').DaemonCore['incarnateReadableBlob']} args.incarnateReadableBlob + * @param {import('./types.js').DaemonCore['formulateWorker']} args.formulateWorker + * @param {import('./types.js').DaemonCore['formulateHost']} args.formulateHost + * @param {import('./types.js').DaemonCore['formulateGuest']} args.formulateGuest + * @param {import('./types.js').DaemonCore['formulateEval']} args.formulateEval + * @param {import('./types.js').DaemonCore['formulateUnconfined']} args.formulateUnconfined + * @param {import('./types.js').DaemonCore['formulateBundle']} args.formulateBundle + * @param {import('./types.js').DaemonCore['formulateReadableBlob']} args.formulateReadableBlob * @param {import('./types.js').DaemonCore['getAllNetworkAddresses']} args.getAllNetworkAddresses * @param {import('./types.js').MakeMailbox} args.makeMailbox * @param {import('./types.js').MakeDirectoryNode} args.makeDirectoryNode @@ -34,13 +34,13 @@ export const makeHostMaker = ({ provide, provideController, cancelValue, - incarnateWorker, - incarnateHost, - incarnateGuest, - incarnateEval, - incarnateUnconfined, - incarnateBundle, - incarnateReadableBlob, + formulateWorker, + formulateHost, + formulateGuest, + formulateEval, + formulateUnconfined, + formulateBundle, + formulateReadableBlob, getAllNetworkAddresses, makeMailbox, makeDirectoryNode, @@ -117,7 +117,7 @@ export const makeHostMaker = ({ ); } - const { value } = await incarnateReadableBlob(readerRef, tasks); + const { value } = await formulateReadableBlob(readerRef, tasks); return value; }; @@ -130,7 +130,7 @@ export const makeHostMaker = ({ // eslint-disable-next-line no-use-before-define const workerId = tryGetWorkerId(workerName); // eslint-disable-next-line no-use-before-define - prepareWorkerIncarnation(workerName, workerId, tasks.push); + prepareWorkerFormulation(workerName, workerId, tasks.push); if (workerId !== undefined) { return /** @type {Promise} */ ( @@ -139,7 +139,7 @@ export const makeHostMaker = ({ ); } - const { value } = await incarnateWorker(tasks); + const { value } = await formulateWorker(tasks); return value; }; @@ -161,7 +161,7 @@ export const makeHostMaker = ({ * @param {string | undefined} workerId * @param {import('./types.js').DeferredTasks<{ workerId: string }>['push']} deferTask */ - const prepareWorkerIncarnation = (workerName, workerId, deferTask) => { + const prepareWorkerFormulation = (workerName, workerId, deferTask) => { if (workerId === undefined) { deferTask(identifiers => petStore.write(workerName, identifiers.workerId), @@ -194,7 +194,7 @@ export const makeHostMaker = ({ const tasks = makeDeferredTasks(); const workerId = tryGetWorkerId(workerName); - prepareWorkerIncarnation(workerName, workerId, tasks.push); + prepareWorkerFormulation(workerName, workerId, tasks.push); /** @type {(string | string[])[]} */ const endowmentFormulaIdsOrPaths = petNamePaths.map( @@ -222,7 +222,7 @@ export const makeHostMaker = ({ ); } - const { value } = await incarnateEval( + const { value } = await formulateEval( hostId, source, codeNames, @@ -246,7 +246,7 @@ export const makeHostMaker = ({ const tasks = makeDeferredTasks(); const workerId = tryGetWorkerId(workerName); - prepareWorkerIncarnation(workerName, workerId, tasks.push); + prepareWorkerFormulation(workerName, workerId, tasks.push); const powersId = petStore.identifyLocal(powersName); if (powersId === undefined) { @@ -279,7 +279,7 @@ export const makeHostMaker = ({ // Behold, recursion: // eslint-disable-next-line no-use-before-define - const { value } = await incarnateUnconfined( + const { value } = await formulateUnconfined( hostId, specifier, tasks, @@ -314,7 +314,7 @@ export const makeHostMaker = ({ // Behold, recursion: // eslint-disable-next-line no-use-before-define - const { value } = await incarnateBundle( + const { value } = await formulateBundle( hostId, bundleId, tasks, @@ -326,7 +326,7 @@ export const makeHostMaker = ({ /** * Attempts to introduce the given names to the specified agent. The agent in question - * must be incarnated before this function is called. + * must be formulated before this function is called. * * @param {string} id - The agent's formula identifier. * @param {Record} introducedNames - The names to introduce. @@ -385,7 +385,7 @@ export const makeHostMaker = ({ if (host === undefined) { const { value, id } = // Behold, recursion: - await incarnateHost( + await formulateHost( endoId, networksDirectoryId, getDeferredTasksForAgent(petName), @@ -415,7 +415,7 @@ export const makeHostMaker = ({ if (guest === undefined) { const { value, id } = // Behold, recursion: - await incarnateGuest(hostId, getDeferredTasksForAgent(petName)); + await formulateGuest(hostId, getDeferredTasksForAgent(petName)); guest = { value: Promise.resolve(value), id }; } diff --git a/packages/daemon/src/types.d.ts b/packages/daemon/src/types.d.ts index 9f26fcdda7..a3f37d0678 100644 --- a/packages/daemon/src/types.d.ts +++ b/packages/daemon/src/types.d.ts @@ -698,7 +698,7 @@ export type DaemonicPowers = { control: DaemonicControlPowers; }; -type IncarnateResult = Promise<{ +type FormulateResult = Promise<{ id: string; value: T; }>; @@ -716,20 +716,20 @@ export type DeferredTasks> = { push(value: DeferredTask): void; }; -type IncarnateNumberedGuestParams = { +type FormulateNumberedGuestParams = { guestFormulaNumber: string; hostHandleId: string; storeId: string; workerId: string; }; -type IncarnateHostDependenciesParams = { +type FormulateHostDependenciesParams = { endoId: string; networksDirectoryId: string; specifiedWorkerId?: string; }; -type IncarnateNumberedHostParams = { +type FormulateNumberedHostParams = { hostFormulaNumber: string; workerId: string; storeId: string; @@ -740,27 +740,27 @@ type IncarnateNumberedHostParams = { export interface DaemonCoreInternal { /** - * Helper for callers of {@link incarnateNumberedGuest}. - * @param hostId - The formula identifier of the host to incarnate a guest for. - * @returns The formula identifiers for the guest incarnation's dependencies. + * Helper for callers of {@link formulateNumberedGuest}. + * @param hostId - The formula identifier of the host to formulate a guest for. + * @returns The formula identifiers for the guest formulation's dependencies. */ - incarnateGuestDependencies: ( + formulateGuestDependencies: ( hostId: string, - ) => Promise>; - incarnateNumberedGuest: ( - identifiers: IncarnateNumberedGuestParams, - ) => IncarnateResult; + ) => Promise>; + formulateNumberedGuest: ( + identifiers: FormulateNumberedGuestParams, + ) => FormulateResult; /** - * Helper for callers of {@link incarnateNumberedHost}. - * @param specifiedIdentifiers - The existing formula identifiers specified to the host incarnation. - * @returns The formula identifiers for all of the host incarnation's dependencies. + * Helper for callers of {@link formulateNumberedHost}. + * @param specifiedIdentifiers - The existing formula identifiers specified to the host formulation. + * @returns The formula identifiers for all of the host formulation's dependencies. */ - incarnateHostDependencies: ( - specifiedIdentifiers: IncarnateHostDependenciesParams, - ) => Promise>; - incarnateNumberedHost: ( - identifiers: IncarnateNumberedHostParams, - ) => IncarnateResult; + formulateHostDependencies: ( + specifiedIdentifiers: FormulateHostDependenciesParams, + ) => Promise>; + formulateNumberedHost: ( + identifiers: FormulateNumberedHostParams, + ) => FormulateResult; } export interface DaemonCore { @@ -777,55 +777,55 @@ export interface DaemonCore { }>; getIdForRef: (ref: unknown) => string | undefined; getAllNetworkAddresses: (networksDirectoryId: string) => Promise; - incarnateEndoBootstrap: ( + formulateEndoBootstrap: ( specifiedFormulaNumber: string, - ) => IncarnateResult; - incarnateWorker: ( + ) => FormulateResult; + formulateWorker: ( deferredTasks: DeferredTasks, - ) => IncarnateResult; - incarnateDirectory: () => IncarnateResult; - incarnateHost: ( + ) => FormulateResult; + formulateDirectory: () => FormulateResult; + formulateHost: ( endoId: string, networksDirectoryId: string, deferredTasks: DeferredTasks, specifiedWorkerId?: string | undefined, - ) => IncarnateResult; - incarnateGuest: ( + ) => FormulateResult; + formulateGuest: ( hostId: string, deferredTasks: DeferredTasks, - ) => IncarnateResult; - incarnateReadableBlob: ( + ) => FormulateResult; + formulateReadableBlob: ( readerRef: ERef>, deferredTasks: DeferredTasks, - ) => IncarnateResult; - incarnateEval: ( + ) => FormulateResult; + formulateEval: ( hostId: string, source: string, codeNames: string[], endowmentIdsOrPaths: (string | string[])[], deferredTasks: DeferredTasks, specifiedWorkerId?: string, - ) => IncarnateResult; - incarnateUnconfined: ( + ) => FormulateResult; + formulateUnconfined: ( hostId: string, specifier: string, deferredTasks: DeferredTasks, specifiedWorkerId?: string, specifiedPowersId?: string, - ) => IncarnateResult; - incarnateBundle: ( + ) => FormulateResult; + formulateBundle: ( hostId: string, bundleId: string, deferredTasks: DeferredTasks, specifiedWorkerId?: string, specifiedPowersId?: string, - ) => IncarnateResult; - incarnatePeer: ( + ) => FormulateResult; + formulatePeer: ( networksId: string, addresses: Array, - ) => IncarnateResult; - incarnateNetworksDirectory: () => IncarnateResult; - incarnateLoopbackNetwork: () => IncarnateResult; + ) => FormulateResult; + formulateNetworksDirectory: () => FormulateResult; + formulateLoopbackNetwork: () => FormulateResult; cancelValue: (id: string, reason: Error) => Promise; makeMailbox: MakeMailbox; makeDirectoryNode: MakeDirectoryNode;