@segmentstream/ontology 0.197.0 → 0.197.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.197.1
4
+
5
+ A workflow run that the runtime fails for reaching its event limit, its replay limit or its
6
+ queue deliveries now says so. Run detail, in `segmentstream workflow run get` and Cloud, shows
7
+ the runtime's classification as the error code (`MAX_EVENTS_EXCEEDED`, `REPLAY_TIMEOUT` or
8
+ `MAX_DELIVERIES_EXCEEDED`) and the runtime's statement of the limit as the message, such as
9
+ `Workflow exceeded the maximum of 25000 events per run`; the runs list carries the code. Before,
10
+ such a run showed only `MaxEventsExceededError` or `FatalError` with no message. Redeploy the
11
+ workspace after upgrading.
12
+
3
13
  ## 0.197.0
4
14
 
5
15
  A workflow run's detail now carries what the run returned and what each completed step returned, as `output`: the value as JSON, redacted by the same rules as logs. A value whose JSON text is longer than 4 KB is cut to that length and marked `outputTruncated: true`; a value the service cannot decrypt or deserialize is answered with `output: null` and `outputUnavailable`, with the reference of its operator report. `segmentstream workflow run get`, its `--output json` and the ontology MCP tool show them. Upgrade and redeploy the workspace to serve them.
@@ -24,3 +24,9 @@ export declare class WorkflowStepFailed extends Error {
24
24
  export declare function stepFailure(cause: Cause.Cause<unknown>, requestId: string, step: WorkflowStepContext, workflow: string, credentials: readonly (string | undefined)[]): WorkflowStepFailed;
25
25
  /** Find our envelope through retry-exhaustion/run wrappers, with bounded cycle-safe traversal. */
26
26
  export declare function workflowErrorView(value: unknown): WorkflowErrorView | null;
27
+ /**
28
+ * A run's error, with the runtime's own classification when it failed the run for outgrowing a
29
+ * per-run limit: the code (`MAX_EVENTS_EXCEEDED`, `REPLAY_TIMEOUT`, `MAX_DELIVERIES_EXCEEDED`) and
30
+ * the first line of the runtime's message, which names the limit. Other failures are unchanged.
31
+ */
32
+ export declare function workflowRunErrorView(value: unknown, errorCode: unknown): WorkflowErrorView | null;
@@ -23,6 +23,18 @@ const DETERMINISTIC_FAILURES = new Set([
23
23
  "AgentTaskRefused",
24
24
  "DeploymentInterrupted",
25
25
  ]);
26
+ /**
27
+ * Run failures the Workflow runtime classifies itself when a run outgrows a per-run limit. The
28
+ * runtime builds these errors itself (`MaxEventsExceededError`, and the `FatalError`s of its replay
29
+ * budget and run delivery count), so their first line states the limit and carries no workspace
30
+ * data; the hint below it names the runtime's environment, which workspaces do not set.
31
+ */
32
+ const RUNTIME_LIMIT_FAILURES = new Set([
33
+ "MAX_EVENTS_EXCEEDED",
34
+ "REPLAY_TIMEOUT",
35
+ "MAX_DELIVERIES_EXCEEDED",
36
+ ]);
37
+ const MAX_RUNTIME_MESSAGE_CHARS = 300;
26
38
  const TAG = /^[A-Za-z][A-Za-z0-9_]{0,99}$/;
27
39
  const ID = /^[A-Za-z0-9_.:-]{1,200}$/;
28
40
  function record(value) {
@@ -179,3 +191,27 @@ export function workflowErrorView(value) {
179
191
  const tag = typeof name === "string" && TAG.test(name) ? name : null;
180
192
  return publicError(item ?? {}, tag);
181
193
  }
194
+ /**
195
+ * A run's error, with the runtime's own classification when it failed the run for outgrowing a
196
+ * per-run limit: the code (`MAX_EVENTS_EXCEEDED`, `REPLAY_TIMEOUT`, `MAX_DELIVERIES_EXCEEDED`) and
197
+ * the first line of the runtime's message, which names the limit. Other failures are unchanged.
198
+ */
199
+ export function workflowRunErrorView(value, errorCode) {
200
+ const view = workflowErrorView(value);
201
+ if (typeof errorCode !== "string" || !RUNTIME_LIMIT_FAILURES.has(errorCode)) {
202
+ return view;
203
+ }
204
+ const item = record(value);
205
+ const firstLine = value instanceof Error || typeof item?.message === "string"
206
+ ? String(item.message)
207
+ .split("\n", 1)[0]
208
+ .trim()
209
+ : "";
210
+ return {
211
+ ...(view ?? { tag: null, message: null, code: errorCode }),
212
+ code: errorCode,
213
+ message: firstLine === ""
214
+ ? (view?.message ?? null)
215
+ : makeRedactor(environmentSecrets(process.env))(firstLine).slice(0, MAX_RUNTIME_MESSAGE_CHARS),
216
+ };
217
+ }
@@ -32,6 +32,8 @@ export interface WorkflowRunRecord {
32
32
  readonly attributes?: Readonly<Record<string, string>> | undefined;
33
33
  readonly deploymentId?: string;
34
34
  readonly error?: unknown;
35
+ /** The runtime's classification of a failed run, such as `MAX_EVENTS_EXCEEDED`. */
36
+ readonly errorCode?: string | undefined;
35
37
  }
36
38
  /** A step of a run, from the Workflow SDK's step record. */
37
39
  export interface WorkflowStepRecord {
@@ -34,7 +34,7 @@ import { CurrentCaller } from "./caller-context.js";
34
34
  import { InvalidActionInput, InvalidRequestBody, RequestId, failureResponse, forbidden, internalError, notFound, toServerResponse, unauthorized, unavailable, } from "./errors.js";
35
35
  import { identityToken as requestIdentityToken, makeOperations, } from "./operations.js";
36
36
  import { OntologyBackend } from "./runtime-contract.js";
37
- import { stepFailure, WorkflowStepFailed, workflowErrorView } from "./workflow-errors.js";
37
+ import { stepFailure, WorkflowStepFailed, workflowErrorView, workflowRunErrorView, } from "./workflow-errors.js";
38
38
  export { WorkflowStepFailed } from "./workflow-errors.js";
39
39
  import { runtimeCredential } from "./runtime-identity.js";
40
40
  import { deploymentWorkflowEngine } from "./workflow-deployment.js";
@@ -542,7 +542,7 @@ function runView(workflow, record, output) {
542
542
  startedAt: iso(record.startedAt),
543
543
  completedAt: iso(record.completedAt),
544
544
  ...(startedBy === undefined ? {} : { startedBy }),
545
- error: workflowErrorView(record.error),
545
+ error: workflowRunErrorView(record.error, record.errorCode),
546
546
  ...output,
547
547
  };
548
548
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.197.0",
3
+ "version": "0.197.1",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",