Skip to content

Commit 3842e18

Browse files
committed
refactor(metadata-protocol): read the deployment's flow names off the protocol facade
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
1 parent 4a9e48c commit 3842e18

2 files changed

Lines changed: 19 additions & 34 deletions

File tree

‎packages/metadata-protocol/src/protocol-authoring-gate.ts‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ export interface AuthoringGateHost {
111111
formRestoreRefusal: (type: string, item: unknown, name: string, binding: string | null) => Promise<Error | undefined>;
112112
/** [#34776] The automation engine's sealed node-type vocabulary ({@link sealedFlowNodeTypeVocabulary}). */
113113
sealedFlowNodeTypeVocabulary: () => readonly string[] | undefined;
114-
/**
115-
* The names of every flow the automation engine holds
116-
* ({@link automationFlowNames}). Optional: a host that does not state it
117-
* gets no `subflow` / `map` target judgement at the publish gate.
118-
*/
119-
automationFlowNames?: () => Promise<readonly string[] | undefined>;
120-
/**
121-
* The environment's `sys_metadata` rows, read as the stored-collection
122-
* fold reads them. Optional for the same reason; read by
123-
* {@link deploymentFlowNamesOf} for the stored flows of every state.
124-
*/
125-
findEnvironmentRows?: ObjectStackProtocolImplementation['findEnvironmentRows'];
126114
}
127115

128116
/** The body of `ObjectStackProtocolImplementation#restoredBodyDerivation`; the method's docblock there is its contract. */
@@ -354,7 +342,15 @@ export function withTargetFoldedWithout(
354342
* The members {@link judgeRuntimeAuthoringRules} reads: the host facts and
355343
* collections every judgement of the shared rules is made against.
356344
*/
357-
type RuntimeRulesHost = Pick<AuthoringGateHost, 'authoringChannel' | 'automationFlowNames' | 'engine' | 'findEnvironmentRows' | 'foldStoredCollection' | 'hierarchyResolverMounted' | 'orgWallEnforced' | 'resolveSduiManifest' | 'resolveWritePackageScope' | 'rlsMembershipResolverKeys' | 'sealedFlowNodeTypeVocabulary' | 'tenancyPostureInForce'>;
345+
type RuntimeRulesHost = Pick<AuthoringGateHost, 'authoringChannel' | 'engine' | 'foldStoredCollection' | 'hierarchyResolverMounted' | 'orgWallEnforced' | 'resolveSduiManifest' | 'resolveWritePackageScope' | 'rlsMembershipResolverKeys' | 'sealedFlowNodeTypeVocabulary' | 'tenancyPostureInForce'> & {
346+
/**
347+
* [#35143] The protocol's services registry reader, read per call and
348+
* recorded nowhere: {@link deploymentFlowNamesOf} asks its `automation`
349+
* service for the flows the engine holds. Optional: a host that does not
350+
* state it gets no `subflow` / `map` target judgement at the publish gate.
351+
*/
352+
servicesRegistry?: () => (() => Map<string, any>) | undefined;
353+
};
358354

359355
/** The body of `ObjectStackProtocolImplementation#assertRuntimeAuthoringRules`; the method's docblock there is its contract. */
360356
export async function assertRuntimeAuthoringRules(
@@ -730,16 +726,16 @@ export async function judgeRuntimeAuthoringRules(
730726
*
731727
* Union only: every source can only make more names resolvable, never fewer.
732728
* `undefined`, and so no judgement, when the host cannot state one of the
733-
* sources: no stored-row reader or engine reader, or a read that fails (said
729+
* sources: no store or no automation service, or a read that fails (said
734730
* once, at `warn`). Judging against a partial universe would refuse a call to
735731
* a flow the missing source holds.
736732
*/
737733
async function deploymentFlowNamesOf(
738-
this: Pick<AuthoringGateHost, 'automationFlowNames' | 'findEnvironmentRows'>,
734+
this: Pick<RuntimeRulesHost, 'engine' | 'servicesRegistry'>,
739735
registered: readonly unknown[],
740736
): Promise<readonly string[] | undefined> {
741-
if (typeof this.findEnvironmentRows !== 'function' || typeof this.automationFlowNames !== 'function') return undefined;
742-
const engineNames = await this.automationFlowNames();
737+
if (typeof this.engine?.find !== 'function') return undefined;
738+
const engineNames = await automationFlowNames.call({ getServicesRegistry: this.servicesRegistry?.() });
743739
if (engineNames === undefined) return undefined;
744740
const names = new Set<string>(engineNames);
745741
for (const item of registered) {
@@ -748,12 +744,13 @@ async function deploymentFlowNamesOf(
748744
}
749745
try {
750746
for (const type of ['flow', 'flows']) {
751-
// [ADR-0131 D6] The environment's rows, every state, as the
752-
// stored-collection fold reads them (that fold reads `active` only).
753-
const rows = await this.findEnvironmentRows('sys_metadata', {
747+
// Every state (the stored-collection fold reads `active` only).
748+
// Unfiltered for legacy organization rows: a name too many can
749+
// only let a call through, never refuse one.
750+
const rows = await this.engine.find('sys_metadata', {
754751
where: { type },
755752
context: { isSystem: true },
756-
});
753+
} as never);
757754
for (const row of (rows ?? []) as Array<{ name?: unknown }>) {
758755
if (typeof row?.name === 'string' && row.name !== '') names.add(row.name);
759756
}
@@ -1064,7 +1061,7 @@ function draftConnectorAdvisories(
10641061
* `undefined` when no automation service is registered (no flow runs here at
10651062
* all) or its read fails; then no `subflow` / `map` call is judged.
10661063
*/
1067-
export async function automationFlowNames(
1064+
async function automationFlowNames(
10681065
this: { readonly getServicesRegistry?: () => Map<string, any> },
10691066
): Promise<readonly string[] | undefined> {
10701067
let automation: unknown;

‎packages/metadata-protocol/src/protocol.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ import {
273273
restoredBodyWriter,
274274
runAuthoringGate,
275275
sealedFlowNodeTypeVocabulary,
276-
automationFlowNames,
277276
} from './protocol-authoring-gate.js';
278277
// [#25467 cut 9] The credential carry-forward and the credential channel lookup.
279278
import {
@@ -1934,8 +1933,6 @@ export class ObjectStackProtocolImplementation implements
19341933
resolveWritePackageScope: (...a) => this.resolveWritePackageScope(...a),
19351934
rlsMembershipResolverKeys: (...a) => this.rlsMembershipResolverKeys(...a),
19361935
sealedFlowNodeTypeVocabulary: (...a) => this.sealedFlowNodeTypeVocabulary(...a),
1937-
automationFlowNames: (...a) => this.automationFlowNames(...a),
1938-
findEnvironmentRows: (...a) => this.findEnvironmentRows(...a),
19391936
tenancyPostureInForce: (...a) => this.tenancyPostureInForce(...a),
19401937
servicesRegistry: () => this.getServicesRegistry,
19411938
};
@@ -2234,15 +2231,6 @@ export class ObjectStackProtocolImplementation implements
22342231
return rlsMembershipResolverKeys.call(host);
22352232
}
22362233

2237-
/** [#35143] The names of every flow the automation engine holds; the body's docblock is its contract. */
2238-
private automationFlowNames(): Promise<readonly string[] | undefined> {
2239-
const readGetServicesRegistry = () => this.getServicesRegistry;
2240-
const host: ThisParameterType<typeof automationFlowNames> = {
2241-
get getServicesRegistry() { return readGetServicesRegistry(); },
2242-
};
2243-
return automationFlowNames.call(host);
2244-
}
2245-
22462234
/** [#34776] The automation engine's sealed node-type vocabulary; the body's docblock is its contract. */
22472235
private sealedFlowNodeTypeVocabulary(): readonly string[] | undefined {
22482236
const readGetServicesRegistry = () => this.getServicesRegistry;

0 commit comments

Comments
 (0)