@dcdr/contracts 2.6.0 → 2.7.0

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.
@@ -0,0 +1,1396 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntentProcessingSemantics = exports.PROCESSING_RULE_SCHEMAS = exports.ProcessingValidationIssueCode = exports.ProcessingRegexFlag = exports.ProcessingRuleConfigValueType = exports.ProcessingCacheBehavior = exports.ProcessingRuntimeMode = exports.ProcessingScope = exports.ProcessingEvidenceKind = exports.ProcessingFailureMode = exports.ProcessingReviewQueue = exports.ProcessingOutputPolicyRef = exports.ProcessingPolicyReasonCode = exports.ProcessingPolicyOutcome = exports.ProcessingAction = exports.ProcessingTargetKind = exports.ProcessingRuleGroup = exports.ProcessingRuleKind = exports.ProcessingStage = exports.ConditionOp = exports.ConditionLogicOp = void 0;
4
+ const implementations_contract_1 = require("./implementations.contract");
5
+ const provider_contract_1 = require("./provider.contract");
6
+ var implementations_contract_2 = require("./implementations.contract");
7
+ Object.defineProperty(exports, "ConditionLogicOp", { enumerable: true, get: function () { return implementations_contract_2.ConditionLogicOp; } });
8
+ Object.defineProperty(exports, "ConditionOp", { enumerable: true, get: function () { return implementations_contract_2.ConditionOp; } });
9
+ /**
10
+ * Processing stage around the existing intent execution core.
11
+ *
12
+ * Notes
13
+ * - `INPUT` runs before prompt rendering / provider execution.
14
+ * - `OUTPUT` runs after provider execution and before the final response/report is finalized.
15
+ */
16
+ var ProcessingStage;
17
+ (function (ProcessingStage) {
18
+ ProcessingStage["INPUT"] = "INPUT";
19
+ ProcessingStage["OUTPUT"] = "OUTPUT";
20
+ })(ProcessingStage || (exports.ProcessingStage = ProcessingStage = {}));
21
+ /**
22
+ * Atomic built-in processing rule kinds supported by the governed intent-processing engine.
23
+ *
24
+ * Notes
25
+ * - Keep values stable because frontend preview/testing and runtime execution must share semantics.
26
+ * - These are intentionally small primitives; product-facing processors are composed from them.
27
+ */
28
+ var ProcessingRuleKind;
29
+ (function (ProcessingRuleKind) {
30
+ ProcessingRuleKind["TRIM"] = "TRIM";
31
+ ProcessingRuleKind["COLLAPSE_WHITESPACE"] = "COLLAPSE_WHITESPACE";
32
+ ProcessingRuleKind["NORMALIZE_NEW_LINES"] = "NORMALIZE_NEW_LINES";
33
+ ProcessingRuleKind["REMOVE_CONTROL_CHARS"] = "REMOVE_CONTROL_CHARS";
34
+ ProcessingRuleKind["TO_LOWERCASE"] = "TO_LOWERCASE";
35
+ ProcessingRuleKind["TO_UPPERCASE"] = "TO_UPPERCASE";
36
+ ProcessingRuleKind["REPLACE_LITERAL"] = "REPLACE_LITERAL";
37
+ ProcessingRuleKind["REPLACE_REGEX"] = "REPLACE_REGEX";
38
+ ProcessingRuleKind["PREFIX"] = "PREFIX";
39
+ ProcessingRuleKind["SUFFIX"] = "SUFFIX";
40
+ ProcessingRuleKind["SLICE"] = "SLICE";
41
+ ProcessingRuleKind["JSON_STRINGIFY"] = "JSON_STRINGIFY";
42
+ ProcessingRuleKind["JSON_PARSE_STRING_FIELD"] = "JSON_PARSE_STRING_FIELD";
43
+ ProcessingRuleKind["REMOVE_EMPTY_FIELDS"] = "REMOVE_EMPTY_FIELDS";
44
+ ProcessingRuleKind["COALESCE_NULLISH"] = "COALESCE_NULLISH";
45
+ ProcessingRuleKind["SET_DEFAULT_VALUE"] = "SET_DEFAULT_VALUE";
46
+ ProcessingRuleKind["MAP_ENUM_VALUE"] = "MAP_ENUM_VALUE";
47
+ ProcessingRuleKind["ALLOW_VALUE_SET"] = "ALLOW_VALUE_SET";
48
+ ProcessingRuleKind["DENY_VALUE_SET"] = "DENY_VALUE_SET";
49
+ ProcessingRuleKind["LENGTH_CHECK"] = "LENGTH_CHECK";
50
+ ProcessingRuleKind["REGEX_MATCH_CHECK"] = "REGEX_MATCH_CHECK";
51
+ ProcessingRuleKind["SECRET_DETECTION"] = "SECRET_DETECTION";
52
+ ProcessingRuleKind["PII_DETECTION"] = "PII_DETECTION";
53
+ ProcessingRuleKind["PII_REDACTION"] = "PII_REDACTION";
54
+ ProcessingRuleKind["HASH_VALUE"] = "HASH_VALUE";
55
+ ProcessingRuleKind["MASK_SUBSTRING"] = "MASK_SUBSTRING";
56
+ ProcessingRuleKind["PROVIDER_POLICY_CHECK"] = "PROVIDER_POLICY_CHECK";
57
+ ProcessingRuleKind["MODEL_POLICY_CHECK"] = "MODEL_POLICY_CHECK";
58
+ ProcessingRuleKind["OUTPUT_SCHEMA_VALIDATION"] = "OUTPUT_SCHEMA_VALIDATION";
59
+ ProcessingRuleKind["OUTPUT_POLICY_CHECK"] = "OUTPUT_POLICY_CHECK";
60
+ ProcessingRuleKind["REVIEW_ROUTING"] = "REVIEW_ROUTING";
61
+ })(ProcessingRuleKind || (exports.ProcessingRuleKind = ProcessingRuleKind = {}));
62
+ /**
63
+ * Presentation grouping for built-in atomic rule kinds.
64
+ *
65
+ * Notes
66
+ * - This is metadata for UI discoverability and authoring ergonomics.
67
+ * - Runtime behavior must still be keyed only by `ProcessingRuleKind`.
68
+ */
69
+ var ProcessingRuleGroup;
70
+ (function (ProcessingRuleGroup) {
71
+ ProcessingRuleGroup["TEXT_TRANSFORM"] = "TEXT_TRANSFORM";
72
+ ProcessingRuleGroup["VALUE_NORMALIZATION"] = "VALUE_NORMALIZATION";
73
+ ProcessingRuleGroup["VALIDATION_POLICY"] = "VALIDATION_POLICY";
74
+ ProcessingRuleGroup["SECURITY_PRIVACY"] = "SECURITY_PRIVACY";
75
+ })(ProcessingRuleGroup || (exports.ProcessingRuleGroup = ProcessingRuleGroup = {}));
76
+ /**
77
+ * Logical target family a processing rule operates on.
78
+ */
79
+ var ProcessingTargetKind;
80
+ (function (ProcessingTargetKind) {
81
+ ProcessingTargetKind["DATA_FIELD"] = "DATA_FIELD";
82
+ ProcessingTargetKind["FULL_PAYLOAD"] = "FULL_PAYLOAD";
83
+ ProcessingTargetKind["EXECUTION_CONTEXT"] = "EXECUTION_CONTEXT";
84
+ })(ProcessingTargetKind || (exports.ProcessingTargetKind = ProcessingTargetKind = {}));
85
+ /**
86
+ * Effective action taken by a processing rule.
87
+ */
88
+ var ProcessingAction;
89
+ (function (ProcessingAction) {
90
+ ProcessingAction["NONE"] = "NONE";
91
+ ProcessingAction["WARN"] = "WARN";
92
+ ProcessingAction["BLOCK"] = "BLOCK";
93
+ ProcessingAction["REDACT"] = "REDACT";
94
+ ProcessingAction["REQUIRE_REVIEW"] = "REQUIRE_REVIEW";
95
+ ProcessingAction["ANNOTATE"] = "ANNOTATE";
96
+ })(ProcessingAction || (exports.ProcessingAction = ProcessingAction = {}));
97
+ /**
98
+ * Stable policy-oriented outcome classification for governance rules.
99
+ *
100
+ * Notes
101
+ * - This is intentionally broader than a single trail action so frontend, backend, and
102
+ * reporting can reason about governance decisions without inferring semantics from free text.
103
+ */
104
+ var ProcessingPolicyOutcome;
105
+ (function (ProcessingPolicyOutcome) {
106
+ ProcessingPolicyOutcome["ALLOW"] = "ALLOW";
107
+ ProcessingPolicyOutcome["BLOCK"] = "BLOCK";
108
+ ProcessingPolicyOutcome["REQUIRE_REVIEW"] = "REQUIRE_REVIEW";
109
+ ProcessingPolicyOutcome["REDACT"] = "REDACT";
110
+ ProcessingPolicyOutcome["WARN"] = "WARN";
111
+ })(ProcessingPolicyOutcome || (exports.ProcessingPolicyOutcome = ProcessingPolicyOutcome = {}));
112
+ /**
113
+ * Stable reason codes for policy-oriented processing outcomes.
114
+ *
115
+ * Notes
116
+ * - Keep these values wire-stable because they are intended for frontend previews,
117
+ * backend analytics, and bounded execution trail aggregation.
118
+ * - Region-related reasons are contract-ready today, but runtime may only emit them when
119
+ * explicit region context is available.
120
+ */
121
+ var ProcessingPolicyReasonCode;
122
+ (function (ProcessingPolicyReasonCode) {
123
+ ProcessingPolicyReasonCode["PROVIDER_ALLOWED"] = "PROVIDER_ALLOWED";
124
+ ProcessingPolicyReasonCode["PROVIDER_NOT_ALLOWED"] = "PROVIDER_NOT_ALLOWED";
125
+ ProcessingPolicyReasonCode["PROVIDER_CONTEXT_MISSING"] = "PROVIDER_CONTEXT_MISSING";
126
+ ProcessingPolicyReasonCode["PROVIDER_REGION_NOT_ALLOWED"] = "PROVIDER_REGION_NOT_ALLOWED";
127
+ ProcessingPolicyReasonCode["MODEL_ALLOWED"] = "MODEL_ALLOWED";
128
+ ProcessingPolicyReasonCode["MODEL_NOT_ALLOWED"] = "MODEL_NOT_ALLOWED";
129
+ ProcessingPolicyReasonCode["MODEL_CONTEXT_MISSING"] = "MODEL_CONTEXT_MISSING";
130
+ ProcessingPolicyReasonCode["REGION_ALLOWED"] = "REGION_ALLOWED";
131
+ ProcessingPolicyReasonCode["REGION_CONTEXT_MISSING"] = "REGION_CONTEXT_MISSING";
132
+ ProcessingPolicyReasonCode["OUTPUT_POLICY_FLAGGED"] = "OUTPUT_POLICY_FLAGGED";
133
+ ProcessingPolicyReasonCode["OUTPUT_POLICY_NO_MATCH"] = "OUTPUT_POLICY_NO_MATCH";
134
+ ProcessingPolicyReasonCode["REVIEW_QUEUE_REQUIRED"] = "REVIEW_QUEUE_REQUIRED";
135
+ ProcessingPolicyReasonCode["REVIEW_ROUTING_NO_MATCH"] = "REVIEW_ROUTING_NO_MATCH";
136
+ })(ProcessingPolicyReasonCode || (exports.ProcessingPolicyReasonCode = ProcessingPolicyReasonCode = {}));
137
+ /**
138
+ * Stable catalog of output-policy references exposed to frontend/runtime authoring.
139
+ *
140
+ * Notes
141
+ * - These are DCDR-owned semantic policy identifiers, not backend-generated free text.
142
+ * - Additional values can be added additively as product policy coverage expands.
143
+ */
144
+ var ProcessingOutputPolicyRef;
145
+ (function (ProcessingOutputPolicyRef) {
146
+ ProcessingOutputPolicyRef["DEFAULT_OUTPUT_POLICY"] = "DEFAULT_OUTPUT_POLICY";
147
+ ProcessingOutputPolicyRef["MANUAL_REVIEW_POLICY"] = "MANUAL_REVIEW_POLICY";
148
+ ProcessingOutputPolicyRef["PII_OUTPUT_POLICY"] = "PII_OUTPUT_POLICY";
149
+ ProcessingOutputPolicyRef["SECRET_LEAKAGE_POLICY"] = "SECRET_LEAKAGE_POLICY";
150
+ })(ProcessingOutputPolicyRef || (exports.ProcessingOutputPolicyRef = ProcessingOutputPolicyRef = {}));
151
+ /**
152
+ * Stable catalog of review queues exposed to frontend/runtime authoring.
153
+ *
154
+ * Notes
155
+ * - Keep these values stable because they are intended for UI selects,
156
+ * bounded execution trail projection, and backend aggregation.
157
+ */
158
+ var ProcessingReviewQueue;
159
+ (function (ProcessingReviewQueue) {
160
+ ProcessingReviewQueue["HUMAN_COMPLIANCE"] = "HUMAN_COMPLIANCE";
161
+ ProcessingReviewQueue["SECURITY_REVIEW"] = "SECURITY_REVIEW";
162
+ ProcessingReviewQueue["OUTPUT_QA"] = "OUTPUT_QA";
163
+ ProcessingReviewQueue["MANUAL_REVIEW"] = "MANUAL_REVIEW";
164
+ })(ProcessingReviewQueue || (exports.ProcessingReviewQueue = ProcessingReviewQueue = {}));
165
+ /**
166
+ * Failure behavior when a rule handler itself errors.
167
+ */
168
+ var ProcessingFailureMode;
169
+ (function (ProcessingFailureMode) {
170
+ ProcessingFailureMode["FAIL_CLOSED"] = "FAIL_CLOSED";
171
+ ProcessingFailureMode["FAIL_OPEN"] = "FAIL_OPEN";
172
+ ProcessingFailureMode["WARN_ONLY"] = "WARN_ONLY";
173
+ })(ProcessingFailureMode || (exports.ProcessingFailureMode = ProcessingFailureMode = {}));
174
+ /**
175
+ * Trail/evidence entry family recorded for one processing rule execution.
176
+ */
177
+ var ProcessingEvidenceKind;
178
+ (function (ProcessingEvidenceKind) {
179
+ ProcessingEvidenceKind["RULE_MATCHED"] = "RULE_MATCHED";
180
+ ProcessingEvidenceKind["RULE_MUTATED"] = "RULE_MUTATED";
181
+ ProcessingEvidenceKind["RULE_BLOCKED"] = "RULE_BLOCKED";
182
+ ProcessingEvidenceKind["RULE_WARNED"] = "RULE_WARNED";
183
+ ProcessingEvidenceKind["RULE_FAILED"] = "RULE_FAILED";
184
+ ProcessingEvidenceKind["RULE_REVIEW_REQUIRED"] = "RULE_REVIEW_REQUIRED";
185
+ })(ProcessingEvidenceKind || (exports.ProcessingEvidenceKind = ProcessingEvidenceKind = {}));
186
+ /**
187
+ * Declares where a processor originated in the effective execution pipeline.
188
+ */
189
+ var ProcessingScope;
190
+ (function (ProcessingScope) {
191
+ ProcessingScope["GLOBAL"] = "GLOBAL";
192
+ ProcessingScope["INTENT"] = "INTENT";
193
+ })(ProcessingScope || (exports.ProcessingScope = ProcessingScope = {}));
194
+ /**
195
+ * Declares whether a rule can be executed exactly outside the runtime.
196
+ */
197
+ var ProcessingRuntimeMode;
198
+ (function (ProcessingRuntimeMode) {
199
+ ProcessingRuntimeMode["PURE"] = "PURE";
200
+ ProcessingRuntimeMode["RUNTIME_REQUIRED"] = "RUNTIME_REQUIRED";
201
+ ProcessingRuntimeMode["PREVIEW_APPROXIMABLE"] = "PREVIEW_APPROXIMABLE";
202
+ })(ProcessingRuntimeMode || (exports.ProcessingRuntimeMode = ProcessingRuntimeMode = {}));
203
+ /**
204
+ * Cache/hashing posture for one rule.
205
+ */
206
+ var ProcessingCacheBehavior;
207
+ (function (ProcessingCacheBehavior) {
208
+ ProcessingCacheBehavior["CACHE_SAFE"] = "CACHE_SAFE";
209
+ ProcessingCacheBehavior["CACHE_UNSAFE"] = "CACHE_UNSAFE";
210
+ ProcessingCacheBehavior["CACHE_BYPASS_REQUIRED"] = "CACHE_BYPASS_REQUIRED";
211
+ })(ProcessingCacheBehavior || (exports.ProcessingCacheBehavior = ProcessingCacheBehavior = {}));
212
+ /**
213
+ * UI/runtime-facing configuration field types for rule-specific parameters.
214
+ */
215
+ var ProcessingRuleConfigValueType;
216
+ (function (ProcessingRuleConfigValueType) {
217
+ ProcessingRuleConfigValueType["STRING"] = "STRING";
218
+ ProcessingRuleConfigValueType["NUMBER"] = "NUMBER";
219
+ ProcessingRuleConfigValueType["BOOLEAN"] = "BOOLEAN";
220
+ ProcessingRuleConfigValueType["ENUM"] = "ENUM";
221
+ ProcessingRuleConfigValueType["STRING_LIST"] = "STRING_LIST";
222
+ ProcessingRuleConfigValueType["NUMBER_LIST"] = "NUMBER_LIST";
223
+ ProcessingRuleConfigValueType["BOOLEAN_LIST"] = "BOOLEAN_LIST";
224
+ })(ProcessingRuleConfigValueType || (exports.ProcessingRuleConfigValueType = ProcessingRuleConfigValueType = {}));
225
+ /**
226
+ * Explicit regex flags available to the built-in `REPLACE_REGEX` atomic rule.
227
+ */
228
+ var ProcessingRegexFlag;
229
+ (function (ProcessingRegexFlag) {
230
+ ProcessingRegexFlag["GLOBAL"] = "GLOBAL";
231
+ ProcessingRegexFlag["CASE_INSENSITIVE"] = "CASE_INSENSITIVE";
232
+ ProcessingRegexFlag["MULTILINE"] = "MULTILINE";
233
+ ProcessingRegexFlag["DOT_ALL"] = "DOT_ALL";
234
+ ProcessingRegexFlag["UNICODE"] = "UNICODE";
235
+ })(ProcessingRegexFlag || (exports.ProcessingRegexFlag = ProcessingRegexFlag = {}));
236
+ /**
237
+ * Stable validation issue codes for configured processing rules/processors.
238
+ */
239
+ var ProcessingValidationIssueCode;
240
+ (function (ProcessingValidationIssueCode) {
241
+ ProcessingValidationIssueCode["RULE_KIND_UNSUPPORTED"] = "RULE_KIND_UNSUPPORTED";
242
+ ProcessingValidationIssueCode["RULE_STAGE_NOT_ALLOWED"] = "RULE_STAGE_NOT_ALLOWED";
243
+ ProcessingValidationIssueCode["FIELD_PATHS_NOT_SUPPORTED"] = "FIELD_PATHS_NOT_SUPPORTED";
244
+ ProcessingValidationIssueCode["STOP_ON_MATCH_NOT_SUPPORTED"] = "STOP_ON_MATCH_NOT_SUPPORTED";
245
+ ProcessingValidationIssueCode["CONDITION_INVALID"] = "CONDITION_INVALID";
246
+ ProcessingValidationIssueCode["CONFIG_KEY_UNKNOWN"] = "CONFIG_KEY_UNKNOWN";
247
+ ProcessingValidationIssueCode["CONFIG_REQUIRED_MISSING"] = "CONFIG_REQUIRED_MISSING";
248
+ ProcessingValidationIssueCode["CONFIG_TYPE_INVALID"] = "CONFIG_TYPE_INVALID";
249
+ ProcessingValidationIssueCode["CONFIG_ENUM_INVALID"] = "CONFIG_ENUM_INVALID";
250
+ ProcessingValidationIssueCode["CONFIG_MIN_INVALID"] = "CONFIG_MIN_INVALID";
251
+ ProcessingValidationIssueCode["CONFIG_MAX_INVALID"] = "CONFIG_MAX_INVALID";
252
+ ProcessingValidationIssueCode["PROCESSOR_RULES_REQUIRED"] = "PROCESSOR_RULES_REQUIRED";
253
+ })(ProcessingValidationIssueCode || (exports.ProcessingValidationIssueCode = ProcessingValidationIssueCode = {}));
254
+ /**
255
+ * Static catalog of built-in atomic rule schemas shared across runtime and UI.
256
+ */
257
+ exports.PROCESSING_RULE_SCHEMAS = [
258
+ {
259
+ kind: ProcessingRuleKind.TRIM,
260
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
261
+ label: "Trim",
262
+ description: "Remove leading and trailing whitespace.",
263
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
264
+ supportsFieldPaths: true,
265
+ supportsStopOnMatch: false,
266
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
267
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
268
+ configurationFields: [],
269
+ },
270
+ {
271
+ kind: ProcessingRuleKind.COLLAPSE_WHITESPACE,
272
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
273
+ label: "Collapse whitespace",
274
+ description: "Collapse repeated spaces and tabs into a single space.",
275
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
276
+ supportsFieldPaths: true,
277
+ supportsStopOnMatch: false,
278
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
279
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
280
+ configurationFields: [],
281
+ },
282
+ {
283
+ kind: ProcessingRuleKind.NORMALIZE_NEW_LINES,
284
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
285
+ label: "Normalize new lines",
286
+ description: "Convert CRLF and CR newlines into LF.",
287
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
288
+ supportsFieldPaths: true,
289
+ supportsStopOnMatch: false,
290
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
291
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
292
+ configurationFields: [],
293
+ },
294
+ {
295
+ kind: ProcessingRuleKind.REMOVE_CONTROL_CHARS,
296
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
297
+ label: "Remove control chars",
298
+ description: "Remove non-printable control characters from target strings.",
299
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
300
+ supportsFieldPaths: true,
301
+ supportsStopOnMatch: false,
302
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
303
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
304
+ configurationFields: [],
305
+ },
306
+ {
307
+ kind: ProcessingRuleKind.TO_LOWERCASE,
308
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
309
+ label: "To lowercase",
310
+ description: "Convert target strings to lowercase.",
311
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
312
+ supportsFieldPaths: true,
313
+ supportsStopOnMatch: false,
314
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
315
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
316
+ configurationFields: [],
317
+ },
318
+ {
319
+ kind: ProcessingRuleKind.TO_UPPERCASE,
320
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
321
+ label: "To uppercase",
322
+ description: "Convert target strings to uppercase.",
323
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
324
+ supportsFieldPaths: true,
325
+ supportsStopOnMatch: false,
326
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
327
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
328
+ configurationFields: [],
329
+ },
330
+ {
331
+ kind: ProcessingRuleKind.REPLACE_LITERAL,
332
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
333
+ label: "Replace literal",
334
+ description: "Replace one exact string literal with another.",
335
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
336
+ supportsFieldPaths: true,
337
+ supportsStopOnMatch: false,
338
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
339
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
340
+ configurationFields: [
341
+ {
342
+ key: "search",
343
+ label: "Search",
344
+ type: ProcessingRuleConfigValueType.STRING,
345
+ required: true,
346
+ },
347
+ {
348
+ key: "replacement",
349
+ label: "Replacement",
350
+ type: ProcessingRuleConfigValueType.STRING,
351
+ required: true,
352
+ },
353
+ {
354
+ key: "replaceAll",
355
+ label: "Replace all",
356
+ type: ProcessingRuleConfigValueType.BOOLEAN,
357
+ defaultValue: true,
358
+ },
359
+ {
360
+ key: "caseSensitive",
361
+ label: "Case sensitive",
362
+ type: ProcessingRuleConfigValueType.BOOLEAN,
363
+ defaultValue: true,
364
+ },
365
+ ],
366
+ },
367
+ {
368
+ kind: ProcessingRuleKind.REPLACE_REGEX,
369
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
370
+ label: "Replace regex",
371
+ description: "Apply a regex replacement over target strings.",
372
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
373
+ supportsFieldPaths: true,
374
+ supportsStopOnMatch: false,
375
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
376
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
377
+ configurationFields: [
378
+ {
379
+ key: "pattern",
380
+ label: "Pattern",
381
+ type: ProcessingRuleConfigValueType.STRING,
382
+ required: true,
383
+ },
384
+ {
385
+ key: "replacement",
386
+ label: "Replacement",
387
+ type: ProcessingRuleConfigValueType.STRING,
388
+ required: true,
389
+ },
390
+ {
391
+ key: "flags",
392
+ label: "Flags",
393
+ description: "Optional regex flags as an explicit list of named behaviors.",
394
+ type: ProcessingRuleConfigValueType.STRING_LIST,
395
+ enumValues: Object.values(ProcessingRegexFlag),
396
+ },
397
+ ],
398
+ },
399
+ {
400
+ kind: ProcessingRuleKind.PREFIX,
401
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
402
+ label: "Prefix",
403
+ description: "Prepend a fixed string to target strings.",
404
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
405
+ supportsFieldPaths: true,
406
+ supportsStopOnMatch: false,
407
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
408
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
409
+ configurationFields: [
410
+ {
411
+ key: "value",
412
+ label: "Value",
413
+ type: ProcessingRuleConfigValueType.STRING,
414
+ required: true,
415
+ },
416
+ ],
417
+ },
418
+ {
419
+ kind: ProcessingRuleKind.SUFFIX,
420
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
421
+ label: "Suffix",
422
+ description: "Append a fixed string to target strings.",
423
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
424
+ supportsFieldPaths: true,
425
+ supportsStopOnMatch: false,
426
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
427
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
428
+ configurationFields: [
429
+ {
430
+ key: "value",
431
+ label: "Value",
432
+ type: ProcessingRuleConfigValueType.STRING,
433
+ required: true,
434
+ },
435
+ ],
436
+ },
437
+ {
438
+ kind: ProcessingRuleKind.SLICE,
439
+ group: ProcessingRuleGroup.TEXT_TRANSFORM,
440
+ label: "Slice",
441
+ description: "Slice target strings by start/end indices.",
442
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
443
+ supportsFieldPaths: true,
444
+ supportsStopOnMatch: false,
445
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
446
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
447
+ configurationFields: [
448
+ {
449
+ key: "start",
450
+ label: "Start",
451
+ type: ProcessingRuleConfigValueType.NUMBER,
452
+ required: true,
453
+ },
454
+ {
455
+ key: "end",
456
+ label: "End",
457
+ type: ProcessingRuleConfigValueType.NUMBER,
458
+ },
459
+ ],
460
+ },
461
+ {
462
+ kind: ProcessingRuleKind.JSON_STRINGIFY,
463
+ group: ProcessingRuleGroup.VALUE_NORMALIZATION,
464
+ label: "JSON stringify",
465
+ description: "Serialize the target value into a JSON string.",
466
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
467
+ supportsFieldPaths: true,
468
+ supportsStopOnMatch: false,
469
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
470
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
471
+ configurationFields: [],
472
+ },
473
+ {
474
+ kind: ProcessingRuleKind.JSON_PARSE_STRING_FIELD,
475
+ group: ProcessingRuleGroup.VALUE_NORMALIZATION,
476
+ label: "JSON parse string field",
477
+ description: "Parse a JSON string field into a structured value.",
478
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
479
+ supportsFieldPaths: true,
480
+ supportsStopOnMatch: false,
481
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
482
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
483
+ configurationFields: [],
484
+ },
485
+ {
486
+ kind: ProcessingRuleKind.REMOVE_EMPTY_FIELDS,
487
+ group: ProcessingRuleGroup.VALUE_NORMALIZATION,
488
+ label: "Remove empty fields",
489
+ description: "Remove empty/nullish fields from objects and arrays according to configuration.",
490
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
491
+ supportsFieldPaths: true,
492
+ supportsStopOnMatch: false,
493
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
494
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
495
+ configurationFields: [
496
+ {
497
+ key: "removeNull",
498
+ label: "Remove null",
499
+ type: ProcessingRuleConfigValueType.BOOLEAN,
500
+ defaultValue: true,
501
+ },
502
+ {
503
+ key: "removeUndefined",
504
+ label: "Remove undefined",
505
+ type: ProcessingRuleConfigValueType.BOOLEAN,
506
+ defaultValue: true,
507
+ },
508
+ {
509
+ key: "removeEmptyString",
510
+ label: "Remove empty string",
511
+ type: ProcessingRuleConfigValueType.BOOLEAN,
512
+ defaultValue: false,
513
+ },
514
+ {
515
+ key: "removeEmptyArray",
516
+ label: "Remove empty array",
517
+ type: ProcessingRuleConfigValueType.BOOLEAN,
518
+ defaultValue: false,
519
+ },
520
+ {
521
+ key: "removeEmptyObject",
522
+ label: "Remove empty object",
523
+ type: ProcessingRuleConfigValueType.BOOLEAN,
524
+ defaultValue: false,
525
+ },
526
+ ],
527
+ },
528
+ {
529
+ kind: ProcessingRuleKind.COALESCE_NULLISH,
530
+ group: ProcessingRuleGroup.VALUE_NORMALIZATION,
531
+ label: "Coalesce nullish",
532
+ description: "Replace nullish values with a configured default value.",
533
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
534
+ supportsFieldPaths: true,
535
+ supportsStopOnMatch: false,
536
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
537
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
538
+ configurationFields: [
539
+ {
540
+ key: "fallbackValue",
541
+ label: "Fallback value",
542
+ type: ProcessingRuleConfigValueType.STRING,
543
+ required: true,
544
+ },
545
+ ],
546
+ },
547
+ {
548
+ kind: ProcessingRuleKind.SET_DEFAULT_VALUE,
549
+ group: ProcessingRuleGroup.VALUE_NORMALIZATION,
550
+ label: "Set default value",
551
+ description: "Set a default value when the target field is absent.",
552
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
553
+ supportsFieldPaths: true,
554
+ supportsStopOnMatch: false,
555
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
556
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
557
+ configurationFields: [
558
+ {
559
+ key: "defaultValue",
560
+ label: "Default value",
561
+ type: ProcessingRuleConfigValueType.STRING,
562
+ required: true,
563
+ },
564
+ ],
565
+ },
566
+ {
567
+ kind: ProcessingRuleKind.MAP_ENUM_VALUE,
568
+ group: ProcessingRuleGroup.VALUE_NORMALIZATION,
569
+ label: "Map enum value",
570
+ description: "Map one allowed input value to another canonical value.",
571
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
572
+ supportsFieldPaths: true,
573
+ supportsStopOnMatch: false,
574
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
575
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
576
+ configurationFields: [
577
+ {
578
+ key: "from",
579
+ label: "From",
580
+ type: ProcessingRuleConfigValueType.STRING,
581
+ required: true,
582
+ },
583
+ {
584
+ key: "to",
585
+ label: "To",
586
+ type: ProcessingRuleConfigValueType.STRING,
587
+ required: true,
588
+ },
589
+ ],
590
+ },
591
+ {
592
+ kind: ProcessingRuleKind.ALLOW_VALUE_SET,
593
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
594
+ label: "Allow value set",
595
+ description: "Allow only configured values; everything else is a policy miss.",
596
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
597
+ supportsFieldPaths: true,
598
+ supportsStopOnMatch: true,
599
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
600
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
601
+ configurationFields: [
602
+ {
603
+ key: "values",
604
+ label: "Values",
605
+ type: ProcessingRuleConfigValueType.STRING_LIST,
606
+ required: true,
607
+ },
608
+ ],
609
+ },
610
+ {
611
+ kind: ProcessingRuleKind.DENY_VALUE_SET,
612
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
613
+ label: "Deny value set",
614
+ description: "Block or warn when the target value matches a denied set.",
615
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
616
+ supportsFieldPaths: true,
617
+ supportsStopOnMatch: true,
618
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
619
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
620
+ configurationFields: [
621
+ {
622
+ key: "values",
623
+ label: "Values",
624
+ type: ProcessingRuleConfigValueType.STRING_LIST,
625
+ required: true,
626
+ },
627
+ ],
628
+ },
629
+ {
630
+ kind: ProcessingRuleKind.LENGTH_CHECK,
631
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
632
+ label: "Length check",
633
+ description: "Validate the target string length against optional min/max bounds.",
634
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
635
+ supportsFieldPaths: true,
636
+ supportsStopOnMatch: true,
637
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
638
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
639
+ configurationFields: [
640
+ {
641
+ key: "minLength",
642
+ label: "Min length",
643
+ type: ProcessingRuleConfigValueType.NUMBER,
644
+ min: 0,
645
+ },
646
+ {
647
+ key: "maxLength",
648
+ label: "Max length",
649
+ type: ProcessingRuleConfigValueType.NUMBER,
650
+ min: 0,
651
+ },
652
+ ],
653
+ },
654
+ {
655
+ kind: ProcessingRuleKind.REGEX_MATCH_CHECK,
656
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
657
+ label: "Regex match check",
658
+ description: "Require or forbid a regex match without mutating the value.",
659
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
660
+ supportsFieldPaths: true,
661
+ supportsStopOnMatch: true,
662
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
663
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
664
+ configurationFields: [
665
+ {
666
+ key: "pattern",
667
+ label: "Pattern",
668
+ type: ProcessingRuleConfigValueType.STRING,
669
+ required: true,
670
+ },
671
+ {
672
+ key: "mustMatch",
673
+ label: "Must match",
674
+ type: ProcessingRuleConfigValueType.BOOLEAN,
675
+ defaultValue: true,
676
+ },
677
+ {
678
+ key: "flags",
679
+ label: "Flags",
680
+ type: ProcessingRuleConfigValueType.STRING_LIST,
681
+ enumValues: Object.values(ProcessingRegexFlag),
682
+ },
683
+ ],
684
+ },
685
+ {
686
+ kind: ProcessingRuleKind.SECRET_DETECTION,
687
+ group: ProcessingRuleGroup.SECURITY_PRIVACY,
688
+ label: "Secret detection",
689
+ description: "Detect likely credentials or secrets in target fields.",
690
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
691
+ supportsFieldPaths: true,
692
+ supportsStopOnMatch: true,
693
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
694
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED,
695
+ configurationFields: [
696
+ {
697
+ key: "matchMode",
698
+ label: "Match mode",
699
+ type: ProcessingRuleConfigValueType.ENUM,
700
+ enumValues: ["WARN", "BLOCK", "REDACT"],
701
+ defaultValue: "WARN",
702
+ },
703
+ ],
704
+ },
705
+ {
706
+ kind: ProcessingRuleKind.PII_DETECTION,
707
+ group: ProcessingRuleGroup.SECURITY_PRIVACY,
708
+ label: "PII detection",
709
+ description: "Detect likely personally identifiable information patterns.",
710
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
711
+ supportsFieldPaths: true,
712
+ supportsStopOnMatch: true,
713
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
714
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED,
715
+ configurationFields: [
716
+ {
717
+ key: "entityTypes",
718
+ label: "Entity types",
719
+ type: ProcessingRuleConfigValueType.STRING_LIST,
720
+ },
721
+ {
722
+ key: "matchMode",
723
+ label: "Match mode",
724
+ type: ProcessingRuleConfigValueType.ENUM,
725
+ enumValues: ["WARN", "BLOCK", "REQUIRE_REVIEW"],
726
+ defaultValue: "WARN",
727
+ },
728
+ ],
729
+ },
730
+ {
731
+ kind: ProcessingRuleKind.PII_REDACTION,
732
+ group: ProcessingRuleGroup.SECURITY_PRIVACY,
733
+ label: "PII redaction",
734
+ description: "Redact likely personally identifiable information deterministically.",
735
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
736
+ supportsFieldPaths: true,
737
+ supportsStopOnMatch: false,
738
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
739
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED,
740
+ configurationFields: [
741
+ {
742
+ key: "replacement",
743
+ label: "Replacement",
744
+ type: ProcessingRuleConfigValueType.STRING,
745
+ defaultValue: "[REDACTED]",
746
+ },
747
+ {
748
+ key: "entityTypes",
749
+ label: "Entity types",
750
+ type: ProcessingRuleConfigValueType.STRING_LIST,
751
+ },
752
+ ],
753
+ },
754
+ {
755
+ kind: ProcessingRuleKind.HASH_VALUE,
756
+ group: ProcessingRuleGroup.SECURITY_PRIVACY,
757
+ label: "Hash value",
758
+ description: "Replace a value with a deterministic hash for safe traceability.",
759
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
760
+ supportsFieldPaths: true,
761
+ supportsStopOnMatch: false,
762
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
763
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED,
764
+ configurationFields: [
765
+ {
766
+ key: "algorithm",
767
+ label: "Algorithm",
768
+ type: ProcessingRuleConfigValueType.ENUM,
769
+ enumValues: ["SHA256"],
770
+ defaultValue: "SHA256",
771
+ },
772
+ {
773
+ key: "saltRef",
774
+ label: "Salt ref",
775
+ type: ProcessingRuleConfigValueType.STRING,
776
+ },
777
+ ],
778
+ },
779
+ {
780
+ kind: ProcessingRuleKind.MASK_SUBSTRING,
781
+ group: ProcessingRuleGroup.SECURITY_PRIVACY,
782
+ label: "Mask substring",
783
+ description: "Mask part of a string while preserving surrounding context.",
784
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
785
+ supportsFieldPaths: true,
786
+ supportsStopOnMatch: false,
787
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
788
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED,
789
+ configurationFields: [
790
+ {
791
+ key: "start",
792
+ label: "Start",
793
+ type: ProcessingRuleConfigValueType.NUMBER,
794
+ required: true,
795
+ },
796
+ {
797
+ key: "end",
798
+ label: "End",
799
+ type: ProcessingRuleConfigValueType.NUMBER,
800
+ required: true,
801
+ },
802
+ {
803
+ key: "maskChar",
804
+ label: "Mask char",
805
+ type: ProcessingRuleConfigValueType.STRING,
806
+ defaultValue: "*",
807
+ },
808
+ ],
809
+ },
810
+ {
811
+ kind: ProcessingRuleKind.PROVIDER_POLICY_CHECK,
812
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
813
+ label: "Provider policy check",
814
+ description: "Validate the resolved provider against a configured allow/deny policy.",
815
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
816
+ supportsFieldPaths: false,
817
+ supportsStopOnMatch: true,
818
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
819
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
820
+ configurationFields: [
821
+ {
822
+ key: "allowedProviders",
823
+ label: "Allowed providers",
824
+ type: ProcessingRuleConfigValueType.STRING_LIST,
825
+ enumValues: Object.values(provider_contract_1.IntentProvider),
826
+ },
827
+ {
828
+ key: "deniedProviders",
829
+ label: "Denied providers",
830
+ type: ProcessingRuleConfigValueType.STRING_LIST,
831
+ enumValues: Object.values(provider_contract_1.IntentProvider),
832
+ },
833
+ {
834
+ key: "allowedRegions",
835
+ label: "Allowed regions",
836
+ description: "Optional future-facing region allowlist. Runtime only enforces this when explicit region context is available.",
837
+ type: ProcessingRuleConfigValueType.STRING_LIST,
838
+ },
839
+ {
840
+ key: "deniedRegions",
841
+ label: "Denied regions",
842
+ description: "Optional future-facing region denylist. Runtime only enforces this when explicit region context is available.",
843
+ type: ProcessingRuleConfigValueType.STRING_LIST,
844
+ },
845
+ ],
846
+ },
847
+ {
848
+ kind: ProcessingRuleKind.MODEL_POLICY_CHECK,
849
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
850
+ label: "Model policy check",
851
+ description: "Validate the resolved model or family against a configured policy.",
852
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
853
+ supportsFieldPaths: false,
854
+ supportsStopOnMatch: true,
855
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
856
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
857
+ configurationFields: [
858
+ {
859
+ key: "allowedModels",
860
+ label: "Allowed models",
861
+ type: ProcessingRuleConfigValueType.STRING_LIST,
862
+ },
863
+ {
864
+ key: "deniedModels",
865
+ label: "Denied models",
866
+ type: ProcessingRuleConfigValueType.STRING_LIST,
867
+ },
868
+ {
869
+ key: "allowedRegions",
870
+ label: "Allowed regions",
871
+ description: "Optional future-facing region allowlist. Runtime only enforces this when explicit region context is available.",
872
+ type: ProcessingRuleConfigValueType.STRING_LIST,
873
+ },
874
+ {
875
+ key: "deniedRegions",
876
+ label: "Denied regions",
877
+ description: "Optional future-facing region denylist. Runtime only enforces this when explicit region context is available.",
878
+ type: ProcessingRuleConfigValueType.STRING_LIST,
879
+ },
880
+ ],
881
+ },
882
+ {
883
+ kind: ProcessingRuleKind.OUTPUT_SCHEMA_VALIDATION,
884
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
885
+ label: "Output schema validation",
886
+ description: "Validate the final output structure against a configured schema contract.",
887
+ allowedStages: [ProcessingStage.OUTPUT],
888
+ supportsFieldPaths: true,
889
+ supportsStopOnMatch: true,
890
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
891
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
892
+ configurationFields: [
893
+ {
894
+ key: "schemaRef",
895
+ label: "Schema ref",
896
+ type: ProcessingRuleConfigValueType.STRING,
897
+ },
898
+ ],
899
+ },
900
+ {
901
+ kind: ProcessingRuleKind.OUTPUT_POLICY_CHECK,
902
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
903
+ label: "Output policy check",
904
+ description: "Run output-only policy validation rules without mutating payloads.",
905
+ allowedStages: [ProcessingStage.OUTPUT],
906
+ supportsFieldPaths: true,
907
+ supportsStopOnMatch: true,
908
+ defaultFailureMode: ProcessingFailureMode.FAIL_CLOSED,
909
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
910
+ configurationFields: [
911
+ {
912
+ key: "policyRef",
913
+ label: "Policy ref",
914
+ type: ProcessingRuleConfigValueType.ENUM,
915
+ enumValues: Object.values(ProcessingOutputPolicyRef),
916
+ defaultValue: ProcessingOutputPolicyRef.DEFAULT_OUTPUT_POLICY,
917
+ },
918
+ ],
919
+ },
920
+ {
921
+ kind: ProcessingRuleKind.REVIEW_ROUTING,
922
+ group: ProcessingRuleGroup.VALIDATION_POLICY,
923
+ label: "Review routing",
924
+ description: "Mark the execution for review routing when a configured condition is met.",
925
+ allowedStages: [ProcessingStage.INPUT, ProcessingStage.OUTPUT],
926
+ supportsFieldPaths: true,
927
+ supportsStopOnMatch: true,
928
+ defaultFailureMode: ProcessingFailureMode.FAIL_OPEN,
929
+ defaultCacheBehavior: ProcessingCacheBehavior.CACHE_SAFE,
930
+ configurationFields: [
931
+ {
932
+ key: "queue",
933
+ label: "Queue",
934
+ type: ProcessingRuleConfigValueType.ENUM,
935
+ enumValues: Object.values(ProcessingReviewQueue),
936
+ defaultValue: ProcessingReviewQueue.MANUAL_REVIEW,
937
+ },
938
+ {
939
+ key: "reasonCode",
940
+ label: "Reason code",
941
+ type: ProcessingRuleConfigValueType.STRING,
942
+ },
943
+ ],
944
+ },
945
+ ];
946
+ /**
947
+ * Returns true when the provided value is a string array.
948
+ */
949
+ function isStringArray(value) {
950
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
951
+ }
952
+ /**
953
+ * Returns true when the provided value is a number array.
954
+ */
955
+ function isNumberArray(value) {
956
+ return Array.isArray(value) && value.every((item) => typeof item === "number");
957
+ }
958
+ /**
959
+ * Returns true when the provided value is a boolean array.
960
+ */
961
+ function isBooleanArray(value) {
962
+ return Array.isArray(value) && value.every((item) => typeof item === "boolean");
963
+ }
964
+ /**
965
+ * Returns true when the provided value is a primitive parameter supported by the shared condition DSL.
966
+ */
967
+ function isConditionParameterValue(value) {
968
+ return (value === null ||
969
+ typeof value === "string" ||
970
+ typeof value === "number" ||
971
+ typeof value === "boolean");
972
+ }
973
+ /**
974
+ * Returns true when the provided condition object is a logical condition node.
975
+ */
976
+ function isProcessingLogicalCondition(condition) {
977
+ return (condition.op === implementations_contract_1.ConditionLogicOp.NOT ||
978
+ condition.op === implementations_contract_1.ConditionLogicOp.AND ||
979
+ condition.op === implementations_contract_1.ConditionLogicOp.OR);
980
+ }
981
+ /**
982
+ * Validates one shared condition tree used by processing rules.
983
+ */
984
+ function validateProcessingConditionInternal(args) {
985
+ args.state.nodesSeen += 1;
986
+ if (args.state.nodesSeen > 250) {
987
+ args.issues.push({
988
+ path: args.path,
989
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
990
+ message: "Condition tree exceeds the maximum supported node count (250).",
991
+ });
992
+ return;
993
+ }
994
+ if (isProcessingLogicalCondition(args.condition)) {
995
+ args.state.depth += 1;
996
+ if (args.state.depth > 20) {
997
+ args.issues.push({
998
+ path: args.path,
999
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1000
+ message: "Condition tree exceeds the maximum supported depth (20).",
1001
+ });
1002
+ args.state.depth -= 1;
1003
+ return;
1004
+ }
1005
+ if (!Array.isArray(args.condition.conditions)) {
1006
+ args.issues.push({
1007
+ path: `${args.path}.conditions`,
1008
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1009
+ message: "Logical condition must include conditions[].",
1010
+ });
1011
+ args.state.depth -= 1;
1012
+ return;
1013
+ }
1014
+ if (args.condition.op === implementations_contract_1.ConditionLogicOp.NOT &&
1015
+ args.condition.conditions.length !== 1) {
1016
+ args.issues.push({
1017
+ path: `${args.path}.conditions`,
1018
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1019
+ message: "NOT condition must include exactly 1 child condition.",
1020
+ });
1021
+ args.state.depth -= 1;
1022
+ return;
1023
+ }
1024
+ if ((args.condition.op === implementations_contract_1.ConditionLogicOp.AND ||
1025
+ args.condition.op === implementations_contract_1.ConditionLogicOp.OR) &&
1026
+ args.condition.conditions.length < 1) {
1027
+ args.issues.push({
1028
+ path: `${args.path}.conditions`,
1029
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1030
+ message: `${args.condition.op} condition must include at least 1 child condition.`,
1031
+ });
1032
+ args.state.depth -= 1;
1033
+ return;
1034
+ }
1035
+ for (let i = 0; i < args.condition.conditions.length; i++) {
1036
+ validateProcessingConditionInternal({
1037
+ condition: args.condition.conditions[i],
1038
+ path: `${args.path}.conditions[${i}]`,
1039
+ state: args.state,
1040
+ issues: args.issues,
1041
+ });
1042
+ }
1043
+ args.state.depth -= 1;
1044
+ return;
1045
+ }
1046
+ const path = String(args.condition.path ?? "").trim();
1047
+ if (!path) {
1048
+ args.issues.push({
1049
+ path: `${args.path}.path`,
1050
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1051
+ message: "Leaf condition is missing path.",
1052
+ });
1053
+ }
1054
+ if (!Object.values(implementations_contract_1.ConditionOp).includes(args.condition.op)) {
1055
+ args.issues.push({
1056
+ path: `${args.path}.op`,
1057
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1058
+ message: `Unsupported condition op '${String(args.condition.op)}'.`,
1059
+ });
1060
+ }
1061
+ if (typeof args.condition.value1 !== "undefined" &&
1062
+ !isConditionParameterValue(args.condition.value1)) {
1063
+ args.issues.push({
1064
+ path: `${args.path}.value1`,
1065
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1066
+ message: "Condition value1 must be string|number|boolean|null.",
1067
+ });
1068
+ }
1069
+ if (typeof args.condition.value2 !== "undefined" &&
1070
+ !isConditionParameterValue(args.condition.value2)) {
1071
+ args.issues.push({
1072
+ path: `${args.path}.value2`,
1073
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1074
+ message: "Condition value2 must be string|number|boolean|null.",
1075
+ });
1076
+ }
1077
+ if (typeof args.condition.caseInsensitive !== "undefined" &&
1078
+ typeof args.condition.caseInsensitive !== "boolean") {
1079
+ args.issues.push({
1080
+ path: `${args.path}.caseInsensitive`,
1081
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1082
+ message: "Condition caseInsensitive must be boolean.",
1083
+ });
1084
+ }
1085
+ if (typeof args.condition.trim !== "undefined" &&
1086
+ typeof args.condition.trim !== "boolean") {
1087
+ args.issues.push({
1088
+ path: `${args.path}.trim`,
1089
+ code: ProcessingValidationIssueCode.CONDITION_INVALID,
1090
+ message: "Condition trim must be boolean.",
1091
+ });
1092
+ }
1093
+ }
1094
+ /**
1095
+ * Clones a supported rule configuration value so helpers stay side-effect free.
1096
+ */
1097
+ function cloneProcessingRuleConfigValue(value) {
1098
+ return (Array.isArray(value) ? [...value] : value);
1099
+ }
1100
+ /**
1101
+ * Returns true when the provided value matches the declared config field type.
1102
+ */
1103
+ function isConfigurationValueValidForField(field, value) {
1104
+ switch (field.type) {
1105
+ case ProcessingRuleConfigValueType.STRING:
1106
+ return typeof value === "string";
1107
+ case ProcessingRuleConfigValueType.NUMBER:
1108
+ return typeof value === "number";
1109
+ case ProcessingRuleConfigValueType.BOOLEAN:
1110
+ return typeof value === "boolean";
1111
+ case ProcessingRuleConfigValueType.ENUM:
1112
+ return (typeof value === "string" &&
1113
+ Array.isArray(field.enumValues) &&
1114
+ field.enumValues.includes(value));
1115
+ case ProcessingRuleConfigValueType.STRING_LIST:
1116
+ return (isStringArray(value) &&
1117
+ (!Array.isArray(field.enumValues) ||
1118
+ value.every((item) => field.enumValues?.includes(item))));
1119
+ case ProcessingRuleConfigValueType.NUMBER_LIST:
1120
+ return isNumberArray(value);
1121
+ case ProcessingRuleConfigValueType.BOOLEAN_LIST:
1122
+ return isBooleanArray(value);
1123
+ default:
1124
+ return false;
1125
+ }
1126
+ }
1127
+ /**
1128
+ * Returns true when the field default value is compatible with the declared config field type.
1129
+ */
1130
+ function isDefaultValueValidForField(field) {
1131
+ if (typeof field.defaultValue === "undefined")
1132
+ return true;
1133
+ return isConfigurationValueValidForField(field, field.defaultValue);
1134
+ }
1135
+ /**
1136
+ * Shared pure helpers for intent-processing processor definitions and report scaffolding.
1137
+ */
1138
+ class IntentProcessingSemantics {
1139
+ /** Stable engine version identifier for the initial contracts/runtime slice. */
1140
+ static ENGINE_VERSION_V1 = "1";
1141
+ /**
1142
+ * Returns the shared static schema definition for one built-in rule kind.
1143
+ */
1144
+ static getRuleSchema(kind) {
1145
+ return exports.PROCESSING_RULE_SCHEMAS.find((schema) => schema.kind === kind) ?? null;
1146
+ }
1147
+ /**
1148
+ * Returns true when the given stage is allowed for the provided rule kind.
1149
+ */
1150
+ static isStageAllowedForRuleKind(kind, stage) {
1151
+ const schema = IntentProcessingSemantics.getRuleSchema(kind);
1152
+ if (!schema)
1153
+ return false;
1154
+ return schema.allowedStages.includes(stage);
1155
+ }
1156
+ /**
1157
+ * Builds a configuration map with schema defaults applied first and caller overrides layered on top.
1158
+ */
1159
+ static buildRuleConfigurationWithDefaults(kind, configuration) {
1160
+ const schema = IntentProcessingSemantics.getRuleSchema(kind);
1161
+ const result = {};
1162
+ for (const field of schema?.configurationFields ?? []) {
1163
+ if (typeof field.defaultValue !== "undefined" &&
1164
+ isDefaultValueValidForField(field)) {
1165
+ result[field.key] = cloneProcessingRuleConfigValue(field.defaultValue);
1166
+ }
1167
+ }
1168
+ for (const [key, value] of Object.entries(configuration ?? {})) {
1169
+ const field = schema?.configurationFields.find((candidate) => candidate.key === key);
1170
+ if (!field)
1171
+ continue;
1172
+ if (!isConfigurationValueValidForField(field, value))
1173
+ continue;
1174
+ result[key] = cloneProcessingRuleConfigValue(value);
1175
+ }
1176
+ return result;
1177
+ }
1178
+ /**
1179
+ * Validates one configured atomic rule instance against the shared static schema catalog.
1180
+ */
1181
+ static validateRuleDefinition(rule, stage) {
1182
+ const issues = [];
1183
+ const schema = IntentProcessingSemantics.getRuleSchema(rule.kind);
1184
+ if (!schema) {
1185
+ issues.push({
1186
+ path: "kind",
1187
+ code: ProcessingValidationIssueCode.RULE_KIND_UNSUPPORTED,
1188
+ message: `Unsupported processing rule kind '${rule.kind}'.`,
1189
+ });
1190
+ return { valid: false, issues };
1191
+ }
1192
+ if (!schema.allowedStages.includes(stage)) {
1193
+ issues.push({
1194
+ path: "kind",
1195
+ code: ProcessingValidationIssueCode.RULE_STAGE_NOT_ALLOWED,
1196
+ message: `Rule kind '${rule.kind}' is not allowed in stage '${stage}'.`,
1197
+ });
1198
+ }
1199
+ if (!schema.supportsFieldPaths && (rule.fieldPaths?.length ?? 0) > 0) {
1200
+ issues.push({
1201
+ path: "fieldPaths",
1202
+ code: ProcessingValidationIssueCode.FIELD_PATHS_NOT_SUPPORTED,
1203
+ message: `Rule kind '${rule.kind}' does not support fieldPaths.`,
1204
+ });
1205
+ }
1206
+ if (!schema.supportsStopOnMatch && rule.stopOnMatch === true) {
1207
+ issues.push({
1208
+ path: "stopOnMatch",
1209
+ code: ProcessingValidationIssueCode.STOP_ON_MATCH_NOT_SUPPORTED,
1210
+ message: `Rule kind '${rule.kind}' does not support stopOnMatch=true.`,
1211
+ });
1212
+ }
1213
+ if (rule.condition) {
1214
+ const conditionIssues = [];
1215
+ validateProcessingConditionInternal({
1216
+ condition: rule.condition,
1217
+ path: "condition",
1218
+ state: { depth: 0, nodesSeen: 0 },
1219
+ issues: conditionIssues,
1220
+ });
1221
+ issues.push(...conditionIssues);
1222
+ }
1223
+ const providedConfiguration = rule.configuration ?? {};
1224
+ const schemaFieldsByKey = new Map(schema.configurationFields.map((field) => [field.key, field]));
1225
+ for (const [key, value] of Object.entries(providedConfiguration)) {
1226
+ const field = schemaFieldsByKey.get(key);
1227
+ if (!field) {
1228
+ issues.push({
1229
+ path: `configuration.${key}`,
1230
+ code: ProcessingValidationIssueCode.CONFIG_KEY_UNKNOWN,
1231
+ message: `Unknown configuration key '${key}' for rule kind '${rule.kind}'.`,
1232
+ });
1233
+ continue;
1234
+ }
1235
+ if (!isConfigurationValueValidForField(field, value)) {
1236
+ const isEnumDrivenField = field.type === ProcessingRuleConfigValueType.ENUM ||
1237
+ ((field.type === ProcessingRuleConfigValueType.STRING_LIST ||
1238
+ field.type === ProcessingRuleConfigValueType.NUMBER_LIST ||
1239
+ field.type === ProcessingRuleConfigValueType.BOOLEAN_LIST) &&
1240
+ Array.isArray(field.enumValues) &&
1241
+ field.enumValues.length > 0);
1242
+ issues.push({
1243
+ path: `configuration.${key}`,
1244
+ code: isEnumDrivenField
1245
+ ? ProcessingValidationIssueCode.CONFIG_ENUM_INVALID
1246
+ : ProcessingValidationIssueCode.CONFIG_TYPE_INVALID,
1247
+ message: isEnumDrivenField
1248
+ ? `Configuration key '${key}' must be one of: ${(field.enumValues ?? []).join(", ")}.`
1249
+ : `Configuration key '${key}' must match type '${field.type}'.`,
1250
+ });
1251
+ continue;
1252
+ }
1253
+ if (field.type === ProcessingRuleConfigValueType.NUMBER) {
1254
+ const numericValue = value;
1255
+ if (typeof field.min === "number" && numericValue < field.min) {
1256
+ issues.push({
1257
+ path: `configuration.${key}`,
1258
+ code: ProcessingValidationIssueCode.CONFIG_MIN_INVALID,
1259
+ message: `Configuration key '${key}' must be >= ${field.min}.`,
1260
+ });
1261
+ }
1262
+ if (typeof field.max === "number" && numericValue > field.max) {
1263
+ issues.push({
1264
+ path: `configuration.${key}`,
1265
+ code: ProcessingValidationIssueCode.CONFIG_MAX_INVALID,
1266
+ message: `Configuration key '${key}' must be <= ${field.max}.`,
1267
+ });
1268
+ }
1269
+ }
1270
+ }
1271
+ for (const field of schema.configurationFields) {
1272
+ if (field.required === true &&
1273
+ typeof providedConfiguration[field.key] === "undefined" &&
1274
+ typeof field.defaultValue === "undefined") {
1275
+ issues.push({
1276
+ path: `configuration.${field.key}`,
1277
+ code: ProcessingValidationIssueCode.CONFIG_REQUIRED_MISSING,
1278
+ message: `Missing required configuration key '${field.key}'.`,
1279
+ });
1280
+ }
1281
+ }
1282
+ return { valid: issues.length === 0, issues };
1283
+ }
1284
+ /**
1285
+ * Validates one shared condition tree reused by processing rules.
1286
+ */
1287
+ static validateConditionDefinition(condition) {
1288
+ const issues = [];
1289
+ validateProcessingConditionInternal({
1290
+ condition,
1291
+ path: "condition",
1292
+ state: { depth: 0, nodesSeen: 0 },
1293
+ issues,
1294
+ });
1295
+ return { valid: issues.length === 0, issues };
1296
+ }
1297
+ /**
1298
+ * Validates one configured processor instance and all of its rules.
1299
+ */
1300
+ static validateProcessorDefinition(processor) {
1301
+ const issues = [];
1302
+ if (!Array.isArray(processor.rules) || processor.rules.length < 1) {
1303
+ issues.push({
1304
+ path: "rules",
1305
+ code: ProcessingValidationIssueCode.PROCESSOR_RULES_REQUIRED,
1306
+ message: "A processing processor must contain at least one rule.",
1307
+ });
1308
+ return { valid: false, issues };
1309
+ }
1310
+ for (let i = 0; i < processor.rules.length; i++) {
1311
+ const result = IntentProcessingSemantics.validateRuleDefinition(processor.rules[i], processor.stage);
1312
+ for (const issue of result.issues) {
1313
+ issues.push({
1314
+ ...issue,
1315
+ path: `rules[${i}].${issue.path}`,
1316
+ });
1317
+ }
1318
+ }
1319
+ return { valid: issues.length === 0, issues };
1320
+ }
1321
+ /**
1322
+ * Sorts processors for a given stage deterministically.
1323
+ */
1324
+ static sortProcessorsForStage(processors, stage) {
1325
+ const filtered = (processors ?? []).filter((processor) => processor.stage === stage && processor.enabled !== false);
1326
+ return [...filtered].sort((a, b) => {
1327
+ const aOrder = typeof a.order === "number" ? a.order : 0;
1328
+ const bOrder = typeof b.order === "number" ? b.order : 0;
1329
+ if (aOrder !== bOrder)
1330
+ return aOrder - bOrder;
1331
+ return String(a.id ?? "").localeCompare(String(b.id ?? ""));
1332
+ });
1333
+ }
1334
+ /**
1335
+ * Returns the ordered active rules for the given stage, flattened from processors.
1336
+ */
1337
+ static flattenRulesForStage(processors, stage) {
1338
+ const flattened = [];
1339
+ for (const processor of IntentProcessingSemantics.sortProcessorsForStage(processors, stage)) {
1340
+ for (const rule of processor.rules ?? []) {
1341
+ if (rule.enabled !== false) {
1342
+ flattened.push(rule);
1343
+ }
1344
+ }
1345
+ }
1346
+ return flattened;
1347
+ }
1348
+ /**
1349
+ * Returns true when every active rule for the stage is cache-safe.
1350
+ */
1351
+ static isCacheSafeForStage(processors, stage) {
1352
+ return !IntentProcessingSemantics.flattenRulesForStage(processors, stage).some((rule) => rule.cacheBehavior === ProcessingCacheBehavior.CACHE_UNSAFE ||
1353
+ rule.cacheBehavior === ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED);
1354
+ }
1355
+ /**
1356
+ * Returns true when any active rule for the stage requires bypassing execution cache/dedupe.
1357
+ */
1358
+ static isCacheBypassRequiredForStage(processors, stage) {
1359
+ return IntentProcessingSemantics.flattenRulesForStage(processors, stage).some((rule) => rule.cacheBehavior === ProcessingCacheBehavior.CACHE_BYPASS_REQUIRED);
1360
+ }
1361
+ /**
1362
+ * Builds an empty stage summary with stable defaults.
1363
+ */
1364
+ static buildEmptyStageSummary(stage) {
1365
+ return {
1366
+ stage,
1367
+ processorsConfigured: 0,
1368
+ processorsRun: 0,
1369
+ rulesConfigured: 0,
1370
+ rulesRun: 0,
1371
+ rulesMatched: 0,
1372
+ rulesApplied: 0,
1373
+ mutations: 0,
1374
+ mutated: false,
1375
+ blocked: false,
1376
+ reviewRequired: false,
1377
+ cacheSafe: true,
1378
+ cacheBypassRequired: false,
1379
+ };
1380
+ }
1381
+ /**
1382
+ * Builds an empty bounded processing report.
1383
+ */
1384
+ static buildEmptyExecutionProcessingReport() {
1385
+ return {
1386
+ engineVersion: IntentProcessingSemantics.ENGINE_VERSION_V1,
1387
+ mutated: false,
1388
+ blocked: false,
1389
+ reviewRequired: false,
1390
+ input: IntentProcessingSemantics.buildEmptyStageSummary(ProcessingStage.INPUT),
1391
+ output: IntentProcessingSemantics.buildEmptyStageSummary(ProcessingStage.OUTPUT),
1392
+ trail: [],
1393
+ };
1394
+ }
1395
+ }
1396
+ exports.IntentProcessingSemantics = IntentProcessingSemantics;