Skip to content

Commit 78fd762

Browse files
feat(metadata-protocol): a flow draft's verdict carries the connector-action probe as an advisory (#35843)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDxdrYJq965rUfrZBso8FS3)_ Fixes #35256 Clause-②: yes — widening: the draft verdict gains an advisory for a draft flow whose `connector_action` names a connector or action the runtime cannot dispatch; advisory only, never a refusal (the probe "never fails the publish"), so no save or publish accepted today is refused. Seat runs a contract read before ready. Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:在 Studio 的流程草稿和 AI 的草稿工具里,如果某一步调用了本环境没有的连接器或动作,发布之前就会在那一步上看到一条提醒(以前要等发布之后才提示)。 - 为什么做:草稿发布前检查(让作者在按“发布”之前就知道发布会说什么);修的是“连接器步骤写错,草稿显示无问题,发布后每次运行都在那一步失败”。 - 出错会怎样:这只是提醒,不拦截保存或发布;若误报,作者照常发布即可;撤回本次合并即可恢复旧行为。 - 要你做什么:无。 ## What changes The publish's build probe `flow_connector_action_unresolved` (PR #35244) reads no landed data, only the flow body and the automation engine's connector lookups. The draft verdict now asks the same lookups, so a flow draft hears what its publish will report before Publish is pressed. - `build-probes.ts`: the probe's connector judgement moves into one exported function, `unresolvedConnectorSteps(flowName, body, automation, packageId, userTextLocales)`: the same three lookups in the executor's order (`resolveConnectorInstanceFor` for the package, `resolveConnectorAction`, `getConnectorDegradedReason`), the same `message`, `fix` and user sentence, plus the step's position in the body. The probe now maps its result to the same finding it built before (same code, severity, artefact, ref and words). Not exported from the package index; the published surface does not move. - `protocol-authoring-gate.ts`: `draftPublishJudgement` maps each unresolved step of a FLOW draft into its `advisories` in the gate-issue shape: `rule: 'flow_connector_action_unresolved'` (the probe's code), `path: flows[0].nodes[N].connectorConfig` (served on the draft read as `nodes.N.connectorConfig`, which Studio's flow problems map to the node), `where`, `message` (the probe's, the cause readable in it), `hint` (the probe's `fix`), `severity: 'warning'`, `userMessage` (the probe's sentence in the read's `userTextLocales`). It is judged on the body the promotion judges (`storedFlowVerdictBody`) for the draft's own package. Never a refusal. Only the draft door asks it: `judgeRuntimeAuthoringRules` / `assertRuntimeAuthoringRules` (the publish gate) are not touched. - `protocol.ts`, under claim amendment 1 (comment 7036574060), `draftVerdictHost()` only: one host member, `servicesRegistry: () => this.getServicesRegistry`, a forwarding reader. The gate module reads `automation` from it per call and records nothing, as `sealedFlowNodeTypeVocabulary` does; no service, or one without `resolveConnectorAction`, judges nothing. `protocol.ts` sits exactly at its facade line ceiling (11705, ruling 6897467376), so the member is paid for by writing the host's two reader `const`s as one statement: the file stays 11705 lines and `check:facade-delegation-only` stays green. - Cost: the lookups are synchronous in-memory registry calls with no storage read, so the MCP draft list, which judges many drafts, needs no new per-pass cache beyond `packageClosures`. ## Clause-② reading Widening only. The draft verdict gains advisories; it gains no refusal, and nothing on the save, publish or package-publish path refuses anything it accepted before. `assertRuntimeAuthoringRules` and the build probe answer exactly what they answered before; the pins below hold both. ## Tests New top-level describe in the existing draft-verdict harness, `protocol.draft-publish-verdict.test.ts` ("[#35256] a flow draft whose connector step cannot dispatch reads the probe's advisory"), 7 cases (6 in round 1, 1 in round 2), with a real `ObjectStackProtocolImplementation` and a stub automation service in its services registry: - unknown connector action: exactly one advisory, rule `flow_connector_action_unresolved`, path `flows[0].nodes[1].connectorConfig`, `severity: 'warning'`, no refusal, lookups asked for the draft's package; the Studio draft read shows it as a warning at `nodes.1.connectorConfig` in Chinese, and the draft still reads valid; - a step inside a loop body (round 2): the advisory's path is the step's place in its region, `flows[0].nodes[1].config.body.nodes[1].connectorConfig`, with `where` naming the step; - known connector and action: no advisory; - degraded and refused causes each stay readable in `message` and `hint`; - no automation service, or one without the lookup: nothing; - the publish gate (`assertRuntimeAuthoringRules`) does not carry it, and `publishMetaItem` succeeds with no such advisory; - one judgement: the advisory's `message`, `hint` and `userMessage` equal the landed probe's `message`, `fix` and `userMessage` for the same body. The landed probe's own pins (`build-probes-landed-data.test.ts`, `build-probes-user-message.test.ts`) pass unchanged. ## Acceptance notes - The `Clause-②:` line is copied from the claim verbatim. `scripts/pm/clause2-line.mjs` reads it as `yes` with no arm (the arm is read only in the parenthesised spelling); `check-changeset-no-major` and `check-adr-0087-registration` exit 0 on it. - A step inside a structured region (loop, parallel, try_catch) is located inside the region (`nodes[N].config.body.nodes[M]...`), pinned for a loop body in round 2; Studio's flow problems map any `nodes.N...` path to the top-level container node. Read first (by risk): `protocol-authoring-gate.ts` `draftConnectorAdvisories` (the mapping and the never-refuse line); `build-probes.ts` `unresolvedConnectorSteps` (the moved lookup, byte-equal words); `protocol.ts` `draftVerdictHost()` (the forwarding member and the merged `const`). Two-minute check: `pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/protocol.draft-publish-verdict.test.ts -t 35256` shows 7 passed. ## Verification All at head fb7a69f unless stated. <details><summary>Package suite and typecheck</summary> - `pnpm --filter @objectstack/metadata-protocol test` (after build): Test Files 362 passed, 9 skipped (371); Tests 23304 passed, 45 skipped (23349); lock VERDICT command-exit 0. - `pnpm --filter @objectstack/metadata-protocol typecheck`: exit 0 (its tsconfig includes the test files). - Touched files: 3 files, 143 tests passed. `eslint --no-inline-config` on the four touched source files: exit 0. </details> <details><summary>Ablation (at 113f00f + tests, sources read from src)</summary> `scripts/ablation-replace.mjs` replaced the advisory join in `draftPublishJudgement` with `advisories: verdict.advisories,` (anchor 1 to 0, blob ab08e68 to add99735): the new describe went 3 failed, 3 passed (the unknown-action, cause and one-judgement pins red; the three silence pins green, as expected). Restored: blob equals HEAD (ab08e68), `git diff HEAD` empty. </details> <details><summary>Gates</summary> - `dispatch-gates --ran` (exit codes recorded): 75 derived, 74 run with exit 0, 1 NOT MEASURED: `check-plugin-teardown-shape.mjs --self-test` exit 3, PREREQUISITE NOT MET (its fixture needs an unshallow clone); CI runs it. - `check:dts-closure` and `check:dual-build-cjs-loads` first read exit 1 while a build of this package ran beside them; re-run after the build, both exit 0. - `check:facade-delegation-only`: exit 0, `protocol.ts` 11705 lines within its ceiling. - `overlap-check --branch=claude/area-a4C-35256`: origin/main merges cleanly, 0 PR heads, VERDICT clean exit 0. - Dogfood not run locally: no `!` in the title and no narrowing arm. </details> ## Round 2 Round 2 (head 0ea49ba, contract review 7038751715): S1 and N3. - **S1 (prose only):** the `DraftPublishJudgement` and `draftPublishJudgement` docblocks in `protocol-authoring-gate.ts` each gain one paragraph: a flow draft's `advisories` also carry the build probe's `flow_connector_action_unresolved` finding, which a publish reports as a build-probe finding (`PublishPackageDraftsResponse.probes.issues[]`) rather than under `advisories`, and which stays a warning. The one-line comment on `draftPublishJudgement` in `protocol.ts` is reworded on the same line; the file stays 11705 lines (`check:facade-delegation-only` exit 0). - **N3 (pin):** one case in the #35256 describe, a `connector_action` step at index 1 of a `loop` body at `nodes[1]`, asserts the advisory's path `flows[0].nodes[1].config.body.nodes[1].connectorConfig`. Positive control: `scripts/ablation-replace.mjs` replaced the step path's region prefix in `unresolvedConnectorSteps` (`build-probes.ts`) with a bare `nodes[` (anchor 1 to 0, blob e342534 to d3d949c4); the describe went 1 failed, 6 passed (only the new case red). Restored: blob equals HEAD (e342534), `git diff HEAD` empty. - N1: the `Clause-②:` spelling is unchanged. <details><summary>Round 2 verification (head 0ea49ba)</summary> - `src/protocol.draft-publish-verdict.test.ts`: 69 passed; lock VERDICT command-exit 0. - `pnpm --filter @objectstack/metadata-protocol test`: Test Files 362 passed, 9 skipped (371); Tests 23305 passed, 45 skipped (23350); lock VERDICT command-exit 0. - `pnpm --filter @objectstack/metadata-protocol typecheck`: lock VERDICT command-exit 0. - `dispatch-gates --ran`: 75 derived, 75 accounted for; 72 exit 0; 3 NOT MEASURED (exit 3, PREREQUISITE NOT MET): `check-plugin-teardown-shape.mjs --self-test` (shallow clone), `check:dual-build-cjs-loads` and `check:lean-entry-closure` (no full `pnpm build` in this worktree). CI runs all three. - `overlap-check --branch=claude/area-a4C-35256`: origin/main merges cleanly, 0 PR heads, VERDICT clean exit 0. </details> Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#4 · os-elon-musk · session_016WV4d1k1GRsQbF3vCPKxhz --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3c038eb commit 78fd762

5 files changed

Lines changed: 392 additions & 68 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
Clause-②: yes — widening: the draft verdict gains an advisory for a draft flow whose `connector_action` names a connector or action the runtime cannot dispatch; advisory only, never a refusal (the probe "never fails the publish"), so no save or publish accepted today is refused. Seat runs a contract read before ready.
6+
Metadata-protocol: none
7+
8+
fix(metadata-protocol): a flow draft's verdict says when a connector step cannot dispatch
9+
10+
The publish's build probe `flow_connector_action_unresolved` warns, after a flow is published, that a `connector_action` step names a connector or action this environment cannot dispatch, so every run that reaches the step fails. The draft verdict (`draftPublishJudgement`, read by Studio's draft review and by the MCP draft tools' `verdict.advisories`) now says the same thing before Publish is pressed: one advisory per such step, rule `flow_connector_action_unresolved`, `severity: 'warning'`, located at the step (`flows[0].nodes[N].connectorConfig`, which the draft read serves as `nodes.N.connectorConfig`), with the probe's own `message`, its `fix` as the `hint`, and its user sentence in the read's language.
11+
12+
It is never a refusal: a draft with such a step still saves, reads valid, and publishes, as before. The publish gate's own answer is unchanged, and the build probe reports exactly what it reported before; both doors now ask one shared lookup (`unresolvedConnectorSteps`). A host without an automation service, or one without the connector lookups, judges nothing, as the probe does.

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

Lines changed: 119 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,76 +1259,23 @@ export async function runBuildProbes(opts: RunBuildProbesOptions): Promise<Build
12591259

12601260
// ── Flows: a connector step must name a connector and action this kernel has ──
12611261
//
1262-
// [#35146] A `connector_action` step dispatches to whatever the engine
1263-
// resolves for its connector, named from the flow's package, then its
1264-
// action. The flow publishes whichever connector it names; one this
1265-
// environment does not serve fails every run that reaches the step. The
1266-
// probe asks the engine the same questions the step's executor asks, in
1267-
// the same order, with nothing dispatched. An engine without the lookups
1268-
// is not probed.
1262+
// [#35146] The judgement is {@link unresolvedConnectorSteps}, shared with
1263+
// the draft verdict (#35256); this plane only reads the published body.
12691264
const automation = opts.automation;
1270-
const callerPackageId = opts.packageId ?? null;
12711265
if (automation && typeof automation.resolveConnectorAction === 'function') {
12721266
for (const p of published.filter((x) => x.type === 'flow')) {
12731267
const body = asRec(await readItem('flow', p.name));
12741268
if (!body) continue;
1275-
let graphs: ReturnType<typeof collectFlowGraphs>;
1276-
try {
1277-
graphs = collectFlowGraphs(body as Parameters<typeof collectFlowGraphs>[0]);
1278-
} catch {
1279-
continue;
1280-
}
1281-
for (const node of graphs.flatMap((g) => g.nodes as readonly unknown[]).map(asRec)) {
1282-
if (!node || node.type !== 'connector_action') continue;
1283-
const cfg = asRec(node.connectorConfig);
1284-
const connectorId = typeof cfg?.connectorId === 'string' ? cfg.connectorId : undefined;
1285-
const actionId = typeof cfg?.actionId === 'string' ? cfg.actionId : undefined;
1286-
if (!connectorId || !actionId) continue; // the schema's refusal, not a probe's
1287-
const nodeId = typeof node.id === 'string' ? node.id : 'connector_action';
1288-
let cause: 'refused' | 'no-action' | 'degraded' | undefined;
1289-
let why = '';
1290-
try {
1291-
const instance = typeof automation.resolveConnectorInstanceFor === 'function'
1292-
? automation.resolveConnectorInstanceFor(connectorId, callerPackageId)
1293-
: ({ status: 'instance', packageId: callerPackageId } as const);
1294-
if (instance.status === 'refused') {
1295-
cause = 'refused';
1296-
why = instance.refusal.message;
1297-
} else {
1298-
const packageId = instance.status === 'instance' ? instance.packageId : undefined;
1299-
const handler = packageId === undefined ? undefined : automation.resolveConnectorAction(connectorId, actionId, packageId);
1300-
if (!handler) {
1301-
const degraded = packageId === undefined ? undefined : automation.getConnectorDegradedReason?.(connectorId, packageId);
1302-
cause = degraded ? 'degraded' : 'no-action';
1303-
why = degraded
1304-
? `connector "${connectorId}" is degraded — ${degraded.replace(/\.\s*$/, '')}`
1305-
: `no connector on this environment serves "${connectorId}.${actionId}"`;
1306-
}
1307-
}
1308-
} catch {
1309-
continue; // a lookup that threw judges nothing
1310-
}
1311-
if (!cause) continue;
1269+
for (const step of unresolvedConnectorSteps(p.name, body, automation, opts.packageId ?? null, userTextLocales)) {
13121270
issues.push({
13131271
layer: 'runtime',
13141272
severity: 'warning',
13151273
artifact: { type: 'flow', name: p.name },
1316-
ref: { type: 'connector', name: connectorId, member: actionId },
1274+
ref: { type: 'connector', name: step.connectorId, member: step.actionId },
13171275
code: 'flow_connector_action_unresolved',
1318-
message:
1319-
`Flow "${p.name}" step "${nodeId}" (connector_action) dispatches "${connectorId}.${actionId}", but ${why} — ` +
1320-
'every run that reaches the step fails.',
1321-
fix: cause === 'degraded'
1322-
? `Resolve what keeps connector "${connectorId}" degraded (its upstream or its credential), then re-run the flow.`
1323-
: cause === 'refused'
1324-
? `Make "${connectorId}" name one connector from this flow's package (declare the dependency, or hold the connector in the package), then republish.`
1325-
: `Point the step's connectorConfig at a connector and action this environment has, or install the package or plugin that provides "${connectorId}".`,
1326-
userMessage: say('flow_connector_action_unresolved', {
1327-
flow: labelIn(body, p.name),
1328-
step: labelIn(node, nodeId),
1329-
connector: connectorId,
1330-
cause,
1331-
}),
1276+
message: step.message,
1277+
fix: step.fix,
1278+
userMessage: step.userMessage,
13321279
});
13331280
}
13341281
}
@@ -1337,6 +1284,118 @@ export async function runBuildProbes(opts: RunBuildProbesOptions): Promise<Build
13371284
return { issues, checked };
13381285
}
13391286

1287+
/** One `connector_action` step the runtime cannot dispatch ({@link unresolvedConnectorSteps}). */
1288+
export interface UnresolvedConnectorStep {
1289+
/** The step's position in the flow body (`nodes[1]`, `nodes[0].config.body.nodes[2]`). */
1290+
path: string;
1291+
nodeId: string;
1292+
connectorId: string;
1293+
actionId: string;
1294+
cause: 'refused' | 'no-action' | 'degraded';
1295+
/** The finding's developer sentence, fix and user sentence, as the build probe reports them. */
1296+
message: string;
1297+
fix: string;
1298+
userMessage: string;
1299+
}
1300+
1301+
/**
1302+
* [#35146, #35256] The connector steps of one flow body that no connector
1303+
* this environment serves can dispatch. A `connector_action` step dispatches
1304+
* to whatever the engine resolves for its connector, named from the flow's
1305+
* package, then its action; one this environment does not serve fails every
1306+
* run that reaches the step. This asks the engine the same questions the
1307+
* step's executor asks, in the same order, with nothing dispatched.
1308+
*
1309+
* One judgement for two doors: the publish's build probe
1310+
* (`flow_connector_action_unresolved`) and the draft verdict's advisory of
1311+
* the same rule (`draftPublishJudgement`). It reads no landed data, only the
1312+
* body and the engine's in-memory lookups, so a draft can be judged too. An
1313+
* engine without `resolveConnectorAction` is not asked; a lookup that throws
1314+
* judges that step nothing.
1315+
*/
1316+
export function unresolvedConnectorSteps(
1317+
flowName: string,
1318+
body: unknown,
1319+
automation: ProbeAutomation,
1320+
callerPackageId: string | null,
1321+
userTextLocales: readonly (string | null | undefined)[],
1322+
): UnresolvedConnectorStep[] {
1323+
const steps: UnresolvedConnectorStep[] = [];
1324+
const flow = asRec(body);
1325+
if (!flow || typeof automation.resolveConnectorAction !== 'function') return steps;
1326+
let graphs: ReturnType<typeof collectFlowGraphs>;
1327+
try {
1328+
graphs = collectFlowGraphs(flow as Parameters<typeof collectFlowGraphs>[0]);
1329+
} catch {
1330+
return steps;
1331+
}
1332+
const userTextLocale = buildProbeUserTextLocale(userTextLocales);
1333+
const labelIn = (rec: Rec | undefined, name: string): string => {
1334+
const label = resolveI18nLabel(rec?.label as I18nLabel | undefined, userTextLocale);
1335+
return typeof label === 'string' && label.trim() ? label : name;
1336+
};
1337+
for (const graph of graphs) {
1338+
// The graph's own list, as written: an index is where the author put the step.
1339+
const written: unknown = graph.path.reduce<unknown>((at, key) => asRec(at)?.[key] ?? asArr(at)[key as number], flow);
1340+
const listed = asArr(asRec(written)?.nodes);
1341+
const base = graph.path.map((key) => (typeof key === 'number' ? `[${key}]` : `.${key}`)).join('').replace(/^\./, '');
1342+
for (const node of (graph.nodes as readonly unknown[]).map(asRec)) {
1343+
if (!node || node.type !== 'connector_action') continue;
1344+
const cfg = asRec(node.connectorConfig);
1345+
const connectorId = typeof cfg?.connectorId === 'string' ? cfg.connectorId : undefined;
1346+
const actionId = typeof cfg?.actionId === 'string' ? cfg.actionId : undefined;
1347+
if (!connectorId || !actionId) continue; // the schema's refusal, not a probe's
1348+
const nodeId = typeof node.id === 'string' ? node.id : 'connector_action';
1349+
let cause: UnresolvedConnectorStep['cause'] | undefined;
1350+
let why = '';
1351+
try {
1352+
const instance = typeof automation.resolveConnectorInstanceFor === 'function'
1353+
? automation.resolveConnectorInstanceFor(connectorId, callerPackageId)
1354+
: ({ status: 'instance', packageId: callerPackageId } as const);
1355+
if (instance.status === 'refused') {
1356+
cause = 'refused';
1357+
why = instance.refusal.message;
1358+
} else {
1359+
const packageId = instance.status === 'instance' ? instance.packageId : undefined;
1360+
const handler = packageId === undefined ? undefined : automation.resolveConnectorAction(connectorId, actionId, packageId);
1361+
if (!handler) {
1362+
const degraded = packageId === undefined ? undefined : automation.getConnectorDegradedReason?.(connectorId, packageId);
1363+
cause = degraded ? 'degraded' : 'no-action';
1364+
why = degraded
1365+
? `connector "${connectorId}" is degraded — ${degraded.replace(/\.\s*$/, '')}`
1366+
: `no connector on this environment serves "${connectorId}.${actionId}"`;
1367+
}
1368+
}
1369+
} catch {
1370+
continue; // a lookup that threw judges nothing
1371+
}
1372+
if (!cause) continue;
1373+
steps.push({
1374+
path: `${base ? `${base}.` : ''}nodes[${listed.indexOf(node)}]`,
1375+
nodeId,
1376+
connectorId,
1377+
actionId,
1378+
cause,
1379+
message:
1380+
`Flow "${flowName}" step "${nodeId}" (connector_action) dispatches "${connectorId}.${actionId}", but ${why} — ` +
1381+
'every run that reaches the step fails.',
1382+
fix: cause === 'degraded'
1383+
? `Resolve what keeps connector "${connectorId}" degraded (its upstream or its credential), then re-run the flow.`
1384+
: cause === 'refused'
1385+
? `Make "${connectorId}" name one connector from this flow's package (declare the dependency, or hold the connector in the package), then republish.`
1386+
: `Point the step's connectorConfig at a connector and action this environment has, or install the package or plugin that provides "${connectorId}".`,
1387+
userMessage: buildProbeUserMessage('flow_connector_action_unresolved', {
1388+
flow: labelIn(flow, flowName),
1389+
step: labelIn(node, nodeId),
1390+
connector: connectorId,
1391+
cause,
1392+
}, userTextLocales),
1393+
});
1394+
}
1395+
}
1396+
return steps;
1397+
}
1398+
13401399
/**
13411400
* The one field on a child object that points back at `parent`, the
13421401
* foreign key a roll-up resolves when it names no `relationshipField`:

0 commit comments

Comments
 (0)