Skip to content

Commit

Permalink
feat(daemon): add incarnateUnconfined
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Feb 19, 2024
1 parent 628f903 commit b391c25
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
25 changes: 25 additions & 0 deletions packages/daemon/src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,30 @@ const makeDaemonCore = async (
);
};

/**
* @param {string} workerFormulaIdentifier
* @param {string} powersFormulaIdentifiers
* @param {string} specifier
* @returns {Promise<{ formulaIdentifier: string, value: unknown }>}
*/
const incarnateUnconfined = async (
workerFormulaIdentifier,
powersFormulaIdentifiers,
specifier,
) => {
const formulaNumber = await randomHex512();
/** @type {import('./types.js').MakeUnconfinedFormula} */
const formula = {
type: 'make-unconfined',
worker: workerFormulaIdentifier,
powers: powersFormulaIdentifiers,
specifier,
};
return /** @type {Promise<{ formulaIdentifier: string, value: unknown }>} */ (
provideValueForNumberedFormula(formula.type, formulaNumber, formula)
);
};

/**
* @param {string} contentSha512
* @returns {Promise<{ formulaIdentifier: string, value: import('./types.js').FarEndoReadable }>}
Expand Down Expand Up @@ -876,6 +900,7 @@ const makeDaemonCore = async (
incarnateHost,
incarnateGuest,
incarnateEval,
incarnateUnconfined,
incarnateHandle,
storeReaderRef,
randomHex512,
Expand Down
16 changes: 5 additions & 11 deletions packages/daemon/src/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const makeHostMaker = ({
incarnateHost,
incarnateGuest,
incarnateEval,
incarnateUnconfined,
incarnateHandle,
storeReaderRef,
makeSha512,
Expand Down Expand Up @@ -315,19 +316,12 @@ export const makeHostMaker = ({
powersName,
);

const formula = {
/** @type {'make-unconfined'} */
type: 'make-unconfined',
worker: workerFormulaIdentifier,
powers: powersFormulaIdentifier,
specifier,
};

// Behold, recursion:
// eslint-disable-next-line no-use-before-define
const { formulaIdentifier, value } = await provideValueForFormula(
formula,
'make-unconfined',
const { formulaIdentifier, value } = await incarnateUnconfined(
workerFormulaIdentifier,
powersFormulaIdentifier,
specifier,
);
if (resultName !== undefined) {
await petStore.write(resultName, formulaIdentifier);
Expand Down

0 comments on commit b391c25

Please sign in to comment.