Skip to content

Commit 8b53cc8

Browse files
fix(service-automation): a run summary node row carries its steps warnings, so a refused notify channel shows in the trigger response (#33438)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DMscMg6AKHasj3ZXEDorLPH)_ Fixes #33341 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: none — the added member is a field of the run summary the platform answers; no metadata author writes it, and no skill teaches the summary's node rows ## 维护者速读 - 改了什么:流程运行摘要 `summary.nodes[]` 的每个节点行,现在会带上该节点步骤产生的告警(`warnings`,字符串数组);spec 的 `FlowRunNodeSummarySchema` 同步声明这个可选字段。 - 为什么改:`notify` 节点唯一的渠道被拒(如未注册的 `push`)时,步骤日志里有告警,但触发接口返回的摘要里该行只显示 `success`、`acted: 0`,调用方看不出其实谁都没通知到。 - 风险与回滚:只加可选字段,节点状态、计数和流程走向都不变;每个节点最多列 5 条不同告警,超出时最后一条写明省略了几条。回滚即 revert 本 PR。 - 先看:`packages/services/service-automation/src/run-summary.ts`(折叠与上限,`nodeWarnings`);`packages/spec/src/automation/execution.zod.ts`(新字段与描述);`packages/services/service-automation/src/builtin/notify-delivery-outcome.integration.test.ts`(末尾新 describe)。 - 两分钟验证:`pnpm --filter @objectstack/service-automation exec vitest run src/builtin/notify-delivery-outcome.integration.test.ts`,预期 12 个用例全绿,其中新 describe 的 4 个用例断言摘要行带有点名 `'push'` 的告警。 - 需要你做的:无,席位落地。 ## What changes - `@objectstack/spec`: `FlowRunNodeSummarySchema` gains `warnings?: string[]`, the same element shape as `ExecutionStepLogSchema.warnings`. Optional and additive: absent when no execution of the node raised a warning, never `[]`. - `@objectstack/service-automation`: `summarizeRun` folds every node's step `warnings` onto that node's row, distinct texts in first-seen order. The list is bounded per node (`MAX_NODE_SUMMARY_WARNINGS = 5`, not exported from the package entry) because the summary's detail is sized by the flow's static shape, which is what keeps a long sweep's persisted `summary_json` under its byte cap; past the bound a final entry says how many distinct warnings were left out, and the step log keeps each execution's own. - Every node type's step warnings ride along, not only `notify`'s: a `create_record` / `update_record` whose requested fields were stripped now says so on its row too. One fold over the step log covers the whole class instead of a `notify` special case. - Unchanged: node `status`, every counter, the run's outcome and flow control. A refused channel is still a successful step, as #32143's fix decided. - Generated: `packages/spec/authorable-surface/automation.json` (+1 key) and `content/docs/references/automation/execution.mdx`, both from `check:generated --fix`. `authorable-surface.base.json` is untouched. - Changeset `.changeset/33341-notify-summary-row-warning.md`: `minor` for both packages, with both declaration lines. The trigger door serves the engine's result verbatim (`deps.success(result)`, `packages/runtime/src/domains/automation.ts`), so the engine's `run.summary` is the trigger response's `summary`; the same summary rides a flow door's `400 FLOW_FAILED` details and the persisted run row. ## Why The run already stopped claiming a false success (#32143), but a caller reading only the trigger response's summary still saw a notify row with `status: 'success'`, `acted: 0` and no reason, so it could not tell "nothing to send" from "the only channel was refused". The card asks for the warning on that row, in the shape other nodes already use for warnings (the step log's `warnings`). Metadata-protocol is `added` and not `none` because `FlowRunNodeSummary` is on the spec's authorable-surface baseline, and the changeset gate refuses `none` beside a moved `authorable-surface/` file. Clause-② is `yes (widening)`: an optional member added to a published response schema. ## Tests All readings on head `c14afda2e9`. - Premise, re-measured before the fix on the real run path (`AutomationEngine.execute` with the real `MessagingService`, outbox and dispatcher): the new describe in `notify-delivery-outcome.integration.test.ts` went **red, 3 failed / 9 passed (12)**, `AssertionError: Target cannot be null or undefined.` on the row's `warnings`; the CONTROL case (registered channel, no warning) stayed green. - New pins: 4 cases in a new top-level describe in `notify-delivery-outcome.integration.test.ts` (durable path, inline path, partial delivery, control); each parses the summary through `FlowRunSummarySchema`, so an undeclared member would be stripped and the case would go red. 5 cases in `run-summary.test.ts` (distinct first-seen fold, absent on other rows and on skipped nodes, a failed execution's warnings, the bound with its overflow entry, a list exactly at the bound). 3 cases in `packages/spec/src/automation/execution.test.ts` (kept through a parse, absent stays absent, a non-string entry is refused at `['warnings', 0]`). - Ablation on the committed fix, through `scripts/ablation-replace.mjs`: anchor `if (warnings) node.warnings = warnings;` 1 → 0, blob `bacf67bb` → `ef6fbf30`; **8 failed / 51 passed (59)**, every new warning pin red and the control green. Restored: blob == HEAD `bacf67bb`, `git diff HEAD` empty. The tests import `run-summary.ts` from `src`, so no dist leg. <details><summary>Suite readings (os-verify-lock VERDICT lines)</summary> - `pnpm --filter @objectstack/service-automation test`: Test Files 281 passed (281), Tests 3916 passed (3916), VERDICT command-exit 0. - `pnpm --filter @objectstack/service-automation typecheck` (tsc + check:test-typecheck): exit 0. - `pnpm --filter @objectstack/spec test`: Test Files 840 passed (840), Tests 26868 passed, 1 todo (26869), VERDICT command-exit 0. - `pnpm --filter @objectstack/spec typecheck`: exit 0. - `pnpm --filter @objectstack/runtime typecheck` + `vitest run` of `flow-failed-inner-refusal`, `endpoint-flow-dispatch-status`, `automation-trigger-paused-run`, `automation-runs-unknown-flow`: Test Files 4 passed (4), Tests 39 passed (39), VERDICT command-exit 0. - `eslint --no-inline-config` over the five touched source and test files: exit 0. </details> ## Acceptance notes - Narrowed dependent testing, declared: the spec change is an optional member on a response schema, so of the downstream consumers only `@objectstack/runtime` (the trigger door and the typed `FlowFailureDetails` builder) was re-run locally, its typecheck plus the four test files that read the summary. Every other dependent is left to CI's `Test Core` and `TypeScript Type Check`. A `turbo ls --affected` set would be blind to tests that read another package's source from disk, and the repo-root suites are not on that graph at all. - Not merged with `origin/main` before opening: the branch is 9 commits behind, none touching `packages/spec/src/automation`, `run-summary.ts`, the authorable-surface or the reference docs (read with `git diff HEAD...origin/main` on those paths); the merge queue tests the merged tree. - A `subflow` child's warnings stay on the child's own run row, as its `skipped` gates do; the parent's `subflow` row carries only warnings its own step raised. - The Console's Runs panel reads step warnings and is not changed here; whether it shows the summary row's warnings is a UI question for another card. ## Verification <details><summary>Derived gates (dispatch-gates --commands at c14afda, 8 paths vs merge base b462444)</summary> - 109 derived commands, each run with its exit code captured before any pipe; `dispatch-gates --ran`: **109 accounted for, 107 run, 2 NOT MEASURED, 0 UNRUN**. - NOT MEASURED, family `check:skill-examples` (spec), reason: exit 3 PREREQUISITE NOT MET, it compiles the skill examples against built `@objectstack/client` / `@objectstack/client-react` declarations, and this container has not built them. - NOT MEASURED, family `check:dual-build-cjs-loads`, reason: exit 3 PREREQUISITE NOT MET, it loads 38 packages' built CJS entries and needs a full `pnpm build`. - Both run in CI's `Lint & Repo Gates` on this PR. - `pnpm --filter @objectstack/spec check:generated` after `--fix`: 14 of 14 artifacts current (it had named `check:docs` stale once, regenerated above); `check:authorable-surface` and `check:api-surface` green. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (eslint run over the touched files; the repo-wide run is CI's). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. Seat: `domain:server#5 · os-elon-musk · session_016WV4cykhsWAtSL6Sr4VWFG`, dispatched to an os-dev subagent on claim 6883603057. --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cykhsWAtSL6Sr4VWFG)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8fdf25a commit 8b53cc8

8 files changed

Lines changed: 231 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/service-automation': minor
4+
---
5+
6+
fix(service-automation): a run summary's node row carries the warnings its steps raised, so a notify whose channel was refused no longer reads as a clean success in the trigger response
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: added
10+
11+
A `notify` step whose only channel was refused (for example `push` on a deployment with no push channel registered) already put a warning naming the channel on its step in the run history. Its row in the run summary's `nodes[]` did not: the trigger response (`POST /api/v1/automation/:name/trigger`), the `summary` a flow door's `400 FLOW_FAILED` details carry, and the persisted run row all said `status: 'success'`, `acted: 0` and nothing else, so a caller reading only the summary could not tell that nobody was notified.
12+
13+
`FlowRunNodeSummarySchema` (`@objectstack/spec/automation`) gains an optional `warnings: string[]`, the same element shape as `ExecutionStepLog.warnings`, and `summarizeRun` fills it on every node row from that node's step warnings: distinct texts in first-seen order, absent when no execution raised one. Every node type's step warnings ride along, not only `notify`'s, so a `create_record` / `update_record` whose requested fields the data engine stripped says so on its row too. The list is bounded per node (five distinct texts); past that a final entry says how many distinct warnings were left out, and the run's step log keeps each execution's own. Node `status`, the counters and flow control are unchanged: a refused channel is still a successful step.
14+
15+
Nothing to migrate: the member is optional and additive. A client that validates the summary with `FlowRunSummarySchema` from an older `@objectstack/spec` strips the new member and reads the row as before.

‎content/docs/references/automation/execution.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa
306306
| **selected** | `integer` | optional | Records read across every execution — omitted for a node that reads none |
307307
| **acted** | `integer` | optional | Records written / effects dispatched across every execution — omitted for a node that writes none |
308308
| **unmeasured** | `integer` | optional | Executions that may have caused an effect the platform cannot count (see ExecutionStepMetrics.unmeasuredEffect) |
309+
| **warnings** | `string[]` | optional | Advisory warnings the node's executions raised (`ExecutionStepLog.warnings`), distinct texts in first-seen order. A `success` node may carry them — e.g. a `notify` whose channel was refused, or a write whose requested fields the data engine stripped — so a node that partly did not do its job never reads as a clean success. Bounded per node like the rest of the summary: past the bound a final entry says how many distinct warnings were left out, and the run's step log holds each execution's own. Absent when no execution raised one |
309310

310311

311312
---
@@ -339,6 +340,7 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa
339340
| **selected** | `integer` | optional | Records read across every execution — omitted for a node that reads none |
340341
| **acted** | `integer` | optional | Records written / effects dispatched across every execution — omitted for a node that writes none |
341342
| **unmeasured** | `integer` | optional | Executions that may have caused an effect the platform cannot count (see ExecutionStepMetrics.unmeasuredEffect) |
343+
| **warnings** | `string[]` | optional | Advisory warnings the node's executions raised (`ExecutionStepLog.warnings`), distinct texts in first-seen order. A `success` node may carry them — e.g. a `notify` whose channel was refused, or a write whose requested fields the data engine stripped — so a node that partly did not do its job never reads as a clean success. Bounded per node like the rest of the summary: past the bound a final entry says how many distinct warnings were left out, and the run's step log holds each execution's own. Absent when no execution raised one |
342344

343345
### Nested Shape: `FlowRunSummary.gates[number]`
344346

‎packages/services/service-automation/src/builtin/notify-delivery-outcome.integration.test.ts‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
NotificationDispatcher,
88
} from '@objectstack/service-messaging';
99
import type { MessagingChannel } from '@objectstack/service-messaging';
10+
import { FlowRunSummarySchema } from '@objectstack/spec/automation';
1011
import { AutomationEngine } from '../engine.js';
1112
import { registerNotifyNode } from './notify-node.js';
1213

@@ -290,3 +291,78 @@ describe('notify step names a refused channel on its run-history row', () => {
290291
expect(step.warnings![0]).not.toContain("'inbox'");
291292
});
292293
});
294+
295+
/**
296+
* The run's own answer names the refused channel too, not only its step.
297+
*
298+
* The trigger door serves the engine's result verbatim (`deps.success(result)`
299+
* in the runtime's automation domain), so `run.summary` below IS the `summary`
300+
* a `POST /automation/:name/trigger` caller reads. The notify row in
301+
* `summary.nodes[]` used to be a plain `success` with `acted: 0` and no reason:
302+
* a caller reading the summary could not tell "nothing to send" from "the only
303+
* channel was refused". The row now carries the step's advisory `warnings`, in
304+
* the step's own shape (a list of strings), and the run still completes: flow
305+
* control is unchanged.
306+
*
307+
* Each case parses the summary through the spec's `FlowRunSummarySchema`, the
308+
* schema a client validates the response with: an undeclared member is stripped
309+
* there, so a warning the contract does not declare would not reach the caller.
310+
*/
311+
describe('the trigger response summary row of a notify step carries its refused-channel warning', () => {
312+
function notifyRow(run: { summary?: unknown }) {
313+
const summary = FlowRunSummarySchema.parse(run.summary);
314+
const row = summary.nodes.find((n) => n.nodeId === 'notify');
315+
expect(row, 'the notify node has a summary row').toBeDefined();
316+
return row!;
317+
}
318+
319+
it('durable path, the only channel unregistered: the row warns, names the channel, and equals the step warning', async () => {
320+
const { engine } = bootOutboxStack([recordingChannel('inbox').channel]);
321+
engine.registerFlow('nudge', notifyFlow(['push']));
322+
const run = await engine.execute('nudge');
323+
324+
expect(run.success, 'flow control is unchanged: the run is not aborted').toBe(true);
325+
const row = notifyRow(run);
326+
expect(row).toMatchObject({ status: 'success', runs: 1, acted: 0 });
327+
expect(row.warnings).toHaveLength(1);
328+
expect(row.warnings![0]).toContain("'push'");
329+
const [history] = await engine.listRuns('nudge');
330+
const step = history.steps.find((s) => s.nodeId === 'notify')!;
331+
expect(row.warnings, 'the row carries the step warning verbatim').toEqual(step.warnings);
332+
});
333+
334+
it('inline path, the only channel unregistered: the same warning on the row', async () => {
335+
const messaging = new MessagingService({ logger: silentLogger() });
336+
messaging.registerChannel(recordingChannel('inbox').channel);
337+
const engine = engineWith(messaging);
338+
engine.registerFlow('nudge', notifyFlow(['push']));
339+
const run = await engine.execute('nudge');
340+
341+
expect(run.success).toBe(true);
342+
const row = notifyRow(run);
343+
expect(row.warnings).toHaveLength(1);
344+
expect(row.warnings![0]).toContain("'push'");
345+
});
346+
347+
it('partial delivery: the row names only the refused channel', async () => {
348+
const { engine } = bootOutboxStack([recordingChannel('inbox').channel]);
349+
engine.registerFlow('nudge', notifyFlow(['inbox', 'push']));
350+
const run = await engine.execute('nudge');
351+
352+
const row = notifyRow(run);
353+
expect(row.warnings).toHaveLength(1);
354+
expect(row.warnings![0]).toContain("'push'");
355+
expect(row.warnings![0]).not.toContain("'inbox'");
356+
});
357+
358+
it('CONTROL: a registered channel leaves the row with no warnings member at all', async () => {
359+
const { engine } = bootOutboxStack([recordingChannel('inbox').channel]);
360+
engine.registerFlow('nudge', notifyFlow(['inbox']));
361+
const run = await engine.execute('nudge');
362+
363+
expect(run.success).toBe(true);
364+
const row = notifyRow(run);
365+
expect(row.status).toBe('success');
366+
expect('warnings' in row, 'absent, never an empty list').toBe(false);
367+
});
368+
});

‎packages/services/service-automation/src/run-summary.test.ts‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { describe, it, expect } from 'vitest';
1111
import { assertEngineDeleteDispatch, assertEngineFindOnePredicate, type EngineFindOneQueryInput } from '@objectstack/objectql';
1212
import { AutomationEngine } from './engine.js';
1313
import type { StepLogEntry, NodeExecutor, RunRecord } from './engine.js';
14-
import { summarizeRun, formatRunSummaryLine } from './run-summary.js';
14+
import { summarizeRun, formatRunSummaryLine, MAX_NODE_SUMMARY_WARNINGS } from './run-summary.js';
1515
import { InMemorySuspendedRunStore, ObjectStoreSuspendedRunStore } from './suspended-run-store.js';
1616
import { registerCrudNodes } from './builtin/crud-nodes.js';
1717
import { registerLoopNode } from './builtin/loop-node.js';
@@ -135,6 +135,54 @@ describe('summarizeRun', () => {
135135
});
136136
});
137137

138+
describe('summarizeRun carries each node\'s step warnings onto its row', () => {
139+
const refused = "notify delivered nothing: every delivery it attempted failed (1). channel 'push' (1 delivery): not registered.";
140+
141+
it('folds a node\'s warnings across its executions: distinct texts, first-seen order', () => {
142+
const s = summarizeRun([
143+
step({ nodeId: 'nudge', nodeType: 'notify', warnings: [refused], metrics: { selected: 1, acted: 0 } }),
144+
step({ nodeId: 'nudge', nodeType: 'notify', warnings: ['second', refused], metrics: { selected: 1, acted: 0 } }),
145+
step({ nodeId: 'nudge', nodeType: 'notify', metrics: { selected: 1, acted: 1 } }),
146+
]);
147+
expect(s.nodes[0]).toMatchObject({ nodeId: 'nudge', runs: 3, status: 'success', warnings: [refused, 'second'] });
148+
});
149+
150+
it('keeps warnings on the node that raised them and leaves every other row without the member', () => {
151+
const s = summarizeRun([
152+
step({ nodeId: 'write', nodeType: 'update_record', warnings: ['dropped'], metrics: { acted: 1 } }),
153+
step({ nodeId: 'gate', nodeType: 'decision' }),
154+
step({ nodeId: 'nudge', nodeType: 'notify', status: 'skipped', skippedBy: { nodeId: 'gate' } }),
155+
]);
156+
expect(s.nodes.find((n) => n.nodeId === 'write')!.warnings).toEqual(['dropped']);
157+
expect('warnings' in s.nodes.find((n) => n.nodeId === 'gate')!).toBe(false);
158+
expect('warnings' in s.nodes.find((n) => n.nodeId === 'nudge')!).toBe(false);
159+
});
160+
161+
it('carries a failed execution\'s warnings too', () => {
162+
const s = summarizeRun([step({ nodeId: 'w', nodeType: 'update_record', status: 'failure', warnings: ['partial'] })]);
163+
expect(s.nodes[0]).toMatchObject({ status: 'failure', warnings: ['partial'] });
164+
});
165+
166+
it('bounds the list per node and says how many distinct texts it left out', () => {
167+
const steps = Array.from({ length: MAX_NODE_SUMMARY_WARNINGS + 3 }, (_, i) =>
168+
step({ nodeId: 'nudge', nodeType: 'notify', warnings: [`failed (${i + 1})`], parentNodeId: 'each', iteration: i }),
169+
);
170+
const warnings = summarizeRun(steps).nodes[0].warnings!;
171+
expect(warnings).toHaveLength(MAX_NODE_SUMMARY_WARNINGS + 1);
172+
expect(warnings.slice(0, MAX_NODE_SUMMARY_WARNINGS)).toEqual(
173+
Array.from({ length: MAX_NODE_SUMMARY_WARNINGS }, (_, i) => `failed (${i + 1})`),
174+
);
175+
expect(warnings[MAX_NODE_SUMMARY_WARNINGS]).toMatch(/^3 more distinct warnings/);
176+
});
177+
178+
it('a list exactly at the bound is published whole, with no overflow entry', () => {
179+
const steps = Array.from({ length: MAX_NODE_SUMMARY_WARNINGS }, (_, i) =>
180+
step({ nodeId: 'nudge', nodeType: 'notify', warnings: [`w${i}`] }),
181+
);
182+
expect(summarizeRun(steps).nodes[0].warnings).toEqual(Array.from({ length: MAX_NODE_SUMMARY_WARNINGS }, (_, i) => `w${i}`));
183+
});
184+
});
185+
138186
describe('formatRunSummaryLine', () => {
139187
it('is one greppable line carrying selected / acted and the top gate', () => {
140188
const line = formatRunSummaryLine(

‎packages/services/service-automation/src/run-summary.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ import type { StepLogEntry } from './engine.js';
7070
* It is folded from the per-node array rather than accumulated alongside it,
7171
* so the run-level count can never disagree with the breakdown it summarizes;
7272
* `unmeasured` above is a genuinely independent tally and stays one.
73+
*
74+
* Each node's row also carries the advisory `warnings` its executions put on
75+
* their steps, distinct texts in first-seen order. A step that succeeded with
76+
* a warning used to fold into a row that read as a clean `success`: a `notify`
77+
* whose only channel was refused said `acted: 0` and nothing else, so a caller
78+
* reading the trigger response's summary could not tell "nothing to send"
79+
* from "nobody could be reached". The list is bounded per node
80+
* ({@link MAX_NODE_SUMMARY_WARNINGS}), like the rest of the detail. A
81+
* `subflow` child's warnings stay on the child's own run row, as its `skipped`
82+
* gates do.
7383
*/
7484
export function summarizeRun(steps: readonly StepLogEntry[]): FlowRunSummary {
7585
// Mutable accumulators; `status` is decided once the counts are final.
@@ -85,6 +95,10 @@ export function summarizeRun(steps: readonly StepLogEntry[]): FlowRunSummary {
8595
// different questions: `FlowRunNodeSummary.status` is judged on this
8696
// node's OWN executions, while its `failures` publishes own + rolled-up.
8797
const rolledUp = new Map<string, number>();
98+
// The distinct advisory warnings each node's executions raised, in
99+
// first-seen order (a `Set` keeps insertion order). Published per node by
100+
// `nodeWarnings` once the fold is done.
101+
const warningsSeen = new Map<string, Set<string>>();
88102

89103
for (const step of steps) {
90104
let node = nodes.get(step.nodeId);
@@ -131,6 +145,15 @@ export function summarizeRun(steps: readonly StepLogEntry[]): FlowRunSummary {
131145
node.runs += 1;
132146
if (step.status === 'failure') node.failures += 1;
133147

148+
if (step.warnings?.length) {
149+
let seen = warningsSeen.get(step.nodeId);
150+
if (!seen) {
151+
seen = new Set<string>();
152+
warningsSeen.set(step.nodeId, seen);
153+
}
154+
for (const warning of step.warnings) seen.add(warning);
155+
}
156+
134157
const metrics = step.metrics;
135158
if (metrics?.selected !== undefined) {
136159
node.selected = (node.selected ?? 0) + metrics.selected;
@@ -177,6 +200,8 @@ export function summarizeRun(steps: readonly StepLogEntry[]): FlowRunSummary {
177200
// declares: it is no longer only this node's own failed executions.
178201
node.failures += rolledUp.get(node.nodeId) ?? 0;
179202
failed += node.failures;
203+
const warnings = nodeWarnings(warningsSeen.get(node.nodeId));
204+
if (warnings) node.warnings = warnings;
180205
}
181206

182207
return {
@@ -194,6 +219,39 @@ export function summarizeRun(steps: readonly StepLogEntry[]): FlowRunSummary {
194219
};
195220
}
196221

222+
/**
223+
* How many distinct warning texts one node's summary row carries before the
224+
* rest are counted instead of listed.
225+
*
226+
* The summary's detail is bounded by the flow's STATIC shape, never by how
227+
* often a node ran — that is what keeps a 5000-row sweep's persisted
228+
* `summary_json` under its byte cap (`serializeSummaryBounded`). A warning
229+
* text can embed a per-execution count (a `notify` names how many deliveries
230+
* failed), so a long loop could raise many distinct texts; the row lists the
231+
* first few and says how many it left out.
232+
*/
233+
export const MAX_NODE_SUMMARY_WARNINGS = 5;
234+
235+
/**
236+
* The `warnings` a node's summary row publishes: the distinct texts its
237+
* executions raised, in first-seen order, or `undefined` when none did —
238+
* absent, never `[]`, so "no warning" and "not tracked" read the same way the
239+
* step log's own member does. Past {@link MAX_NODE_SUMMARY_WARNINGS} the list
240+
* is cut and a final entry states how many distinct texts were left out, so
241+
* the cut is visible rather than silent; the run's step log keeps each
242+
* execution's own warnings.
243+
*/
244+
function nodeWarnings(seen: ReadonlySet<string> | undefined): string[] | undefined {
245+
if (!seen || seen.size === 0) return undefined;
246+
const all = [...seen];
247+
if (all.length <= MAX_NODE_SUMMARY_WARNINGS) return all;
248+
const omitted = all.length - MAX_NODE_SUMMARY_WARNINGS;
249+
return [
250+
...all.slice(0, MAX_NODE_SUMMARY_WARNINGS),
251+
`${omitted} more distinct ${omitted === 1 ? 'warning was' : 'warnings were'} raised by this node and left out of the summary; the run's step log holds each execution's own.`,
252+
];
253+
}
254+
197255
/**
198256
* The single structured line a terminal run logs (#4354) — the minimum viable
199257
* version of this feature, and the one that works with no console at all:

‎packages/spec/authorable-surface/automation.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@
242242
"automation/FlowRunNodeSummary:skipped",
243243
"automation/FlowRunNodeSummary:status",
244244
"automation/FlowRunNodeSummary:unmeasured",
245+
"automation/FlowRunNodeSummary:warnings",
245246
"automation/FlowRunSummary:acted",
246247
"automation/FlowRunSummary:detailOmitted",
247248
"automation/FlowRunSummary:failed",

‎packages/spec/src/automation/execution.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,29 @@ describe('FlowRunSummarySchema', () => {
434434
expect(() => FlowRunSummarySchema.parse({ ...brokenSweep, acted: -1 })).toThrow();
435435
});
436436

437+
describe('a node row\'s warnings', () => {
438+
const refusedNotify = {
439+
nodeId: 'nudge', nodeType: 'notify', status: 'success' as const, runs: 1, failures: 0, skipped: 0,
440+
selected: 1, acted: 0, warnings: ["notify delivered nothing: channel 'push' (1 delivery): not registered."],
441+
};
442+
443+
it('keeps them through a parse, so a client validating the response still reads them', () => {
444+
const summary = FlowRunSummarySchema.parse({ selected: 1, acted: 0, skipped: 0, gates: [], nodes: [refusedNotify] });
445+
expect(summary.nodes[0].warnings).toEqual(refusedNotify.warnings);
446+
});
447+
448+
it('stays absent on a row that carries none, never defaulted to []', () => {
449+
const row = FlowRunNodeSummarySchema.parse({ nodeId: 'gate', nodeType: 'decision', status: 'success', runs: 1, failures: 0, skipped: 0 });
450+
expect('warnings' in row).toBe(false);
451+
});
452+
453+
it('refuses a non-string entry at its path', () => {
454+
const res = FlowRunNodeSummarySchema.safeParse({ ...refusedNotify, warnings: [{ message: 'w' }] });
455+
expect(res.success).toBe(false);
456+
expect(res.error?.issues[0].path).toEqual(['warnings', 0]);
457+
});
458+
});
459+
437460
it('carries an uncountable-effect tally distinct from acted', () => {
438461
// A connector-driven run: `acted: 0` is INCOMPLETE, not zero. The third
439462
// clause of the broken-sweep FIRST FILTER

0 commit comments

Comments
 (0)