agent-contracts 0.12.2 → 0.12.4

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/dist/index.d.ts CHANGED
@@ -78,6 +78,7 @@ declare const AgentSchema: z.ZodObject<{
78
78
  target: z.ZodString;
79
79
  required: z.ZodBoolean;
80
80
  }, z.core.$loose>>>;
81
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
81
82
  }, z.core.$loose>;
82
83
  type Agent = z.infer<typeof AgentSchema>;
83
84
 
@@ -91,6 +92,7 @@ declare const ArtifactSchema: z.ZodObject<{
91
92
  states: z.ZodArray<z.ZodString>;
92
93
  required_validations: z.ZodDefault<z.ZodArray<z.ZodString>>;
93
94
  visibility: z.ZodOptional<z.ZodString>;
95
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
96
  }, z.core.$loose>;
95
97
  type Artifact = z.infer<typeof ArtifactSchema>;
96
98
 
@@ -285,6 +287,7 @@ declare const DslSchema: z.ZodObject<{
285
287
  target: z.ZodString;
286
288
  required: z.ZodBoolean;
287
289
  }, z.core.$loose>>>;
290
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
288
291
  }, z.core.$loose>>>;
289
292
  tasks: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
290
293
  description: z.ZodString;
@@ -334,6 +337,7 @@ declare const DslSchema: z.ZodObject<{
334
337
  }>;
335
338
  }, z.core.$loose>>>;
336
339
  validations: z.ZodDefault<z.ZodArray<z.ZodString>>;
340
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
337
341
  }, z.core.$loose>>>;
338
342
  artifacts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
339
343
  type: z.ZodString;
@@ -345,6 +349,7 @@ declare const DslSchema: z.ZodObject<{
345
349
  states: z.ZodArray<z.ZodString>;
346
350
  required_validations: z.ZodDefault<z.ZodArray<z.ZodString>>;
347
351
  visibility: z.ZodOptional<z.ZodString>;
352
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
348
353
  }, z.core.$loose>>>;
349
354
  tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
350
355
  kind: z.ZodString;
@@ -360,6 +365,7 @@ declare const DslSchema: z.ZodObject<{
360
365
  writes: z.ZodDefault<z.ZodArray<z.ZodString>>;
361
366
  purpose: z.ZodOptional<z.ZodString>;
362
367
  }, z.core.$strip>>>;
368
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
363
369
  }, z.core.$loose>>>;
364
370
  validations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
365
371
  target_artifact: z.ZodString;
@@ -721,6 +727,7 @@ declare const TaskSchema: z.ZodObject<{
721
727
  }>;
722
728
  }, z.core.$loose>>>;
723
729
  validations: z.ZodDefault<z.ZodArray<z.ZodString>>;
730
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
724
731
  }, z.core.$loose>;
725
732
  type Task = z.infer<typeof TaskSchema>;
726
733
 
@@ -746,6 +753,7 @@ declare const ToolSchema: z.ZodObject<{
746
753
  writes: z.ZodDefault<z.ZodArray<z.ZodString>>;
747
754
  purpose: z.ZodOptional<z.ZodString>;
748
755
  }, z.core.$strip>>>;
756
+ guardrails: z.ZodOptional<z.ZodArray<z.ZodString>>;
749
757
  }, z.core.$loose>;
750
758
  type Tool = z.infer<typeof ToolSchema>;
751
759
 
@@ -1111,6 +1119,23 @@ interface SystemContext {
1111
1119
  bindings?: SoftwareBinding[];
1112
1120
  [key: string]: unknown;
1113
1121
  }
1122
+ interface EntityGuardrailEntry {
1123
+ guardrail_id: string;
1124
+ description: string;
1125
+ rationale?: string;
1126
+ tags: string[];
1127
+ source: "entity" | "scope" | "both";
1128
+ severity?: string;
1129
+ action?: string;
1130
+ }
1131
+ interface EntityValidationEntry {
1132
+ validation_id: string;
1133
+ kind: string;
1134
+ target_artifact: string;
1135
+ executor_type: string;
1136
+ blocking: boolean;
1137
+ produces_evidence?: string;
1138
+ }
1114
1139
  interface PerTaskContext {
1115
1140
  task: Task & {
1116
1141
  id: string;
@@ -1118,6 +1143,8 @@ interface PerTaskContext {
1118
1143
  targetAgent: (Agent & {
1119
1144
  id: string;
1120
1145
  }) | null;
1146
+ relatedGuardrails: EntityGuardrailEntry[];
1147
+ relatedValidations: EntityValidationEntry[];
1121
1148
  dsl: Dsl;
1122
1149
  [key: string]: unknown;
1123
1150
  }
@@ -1131,6 +1158,7 @@ interface PerArtifactContext {
1131
1158
  consumerAgents: Dsl["agents"];
1132
1159
  editorAgents: Dsl["agents"];
1133
1160
  createdInWorkflows: string[];
1161
+ relatedGuardrails: EntityGuardrailEntry[];
1134
1162
  dsl: Dsl;
1135
1163
  [key: string]: unknown;
1136
1164
  }
@@ -1141,6 +1169,8 @@ interface PerToolContext {
1141
1169
  invokableAgents: Dsl["agents"];
1142
1170
  inputArtifactDetails: Dsl["artifacts"];
1143
1171
  outputArtifactDetails: Dsl["artifacts"];
1172
+ relatedGuardrails: EntityGuardrailEntry[];
1173
+ relatedValidations: EntityValidationEntry[];
1144
1174
  dsl: Dsl;
1145
1175
  [key: string]: unknown;
1146
1176
  }
@@ -1231,6 +1261,8 @@ interface PerAgentContext {
1231
1261
  relatedTools: Dsl["tools"];
1232
1262
  relatedHandoffTypes: Dsl["handoff_types"];
1233
1263
  mergedBehavior: MergedBehavioralSpec;
1264
+ relatedGuardrails: EntityGuardrailEntry[];
1265
+ relatedValidations: EntityValidationEntry[];
1234
1266
  dsl: Dsl;
1235
1267
  [key: string]: unknown;
1236
1268
  }
@@ -1239,6 +1271,13 @@ declare function buildSystemContext(dsl: Dsl, options?: {
1239
1271
  loadedBindings?: LoadedBinding[];
1240
1272
  activeGuardrailPolicy?: string;
1241
1273
  }): SystemContext;
1274
+ type EntityType = "agents" | "tasks" | "tools" | "artifacts";
1275
+ declare function resolveEffectiveGuardrails(dsl: Dsl, entityType: EntityType, entityId: string): EntityGuardrailEntry[];
1276
+ /**
1277
+ * Resolves validation IDs for an agent, task, or tool into full entries for prompts.
1278
+ * For tools, includes validations where executor_type is "tool" and executor is the tool id.
1279
+ */
1280
+ declare function resolveEntityValidations(dsl: Dsl, entityType: "agents" | "tasks" | "tools", entityId: string): EntityValidationEntry[];
1242
1281
  declare function buildTaskContext(dsl: Dsl, taskId: string): PerTaskContext;
1243
1282
  declare function buildArtifactContext(dsl: Dsl, artifactId: string): PerArtifactContext;
1244
1283
  declare function buildToolContext(dsl: Dsl, toolId: string): PerToolContext;
@@ -1330,4 +1369,4 @@ interface PathResolveResult {
1330
1369
  }
1331
1370
  declare function resolveBindingTargetPath(target: string, paths: Record<string, string>, bindingSoftware: string): PathResolveResult;
1332
1371
 
1333
- export { type Agent, type AgentContractsConfig, AgentContractsConfigSchema, AgentSchema, type AppendOperator, AppendOperatorSchema, type Artifact, ArtifactSchema, BaseResolveError, type BindingOutput, BindingOutputSchema, CONTEXT_TYPES, type Check, CheckSchema, type Command, CommandSchema, type Components, ComponentsSchema, ConfigLoadError, type ContextType, ContextTypeSchema, type DelegatableTaskView, type DiagnosticMessage, type DimensionResult, type Dsl, DslLoadError, DslSchema, type EscalationCriterion, EscalationCriterionSchema, type ExecutionStep, ExecutionStepSchema, type Extends, ExtendsSchema, type ExternalParticipant, type GenerateDiagnostic, type GenerateGuardrailsOptions, type GenerateResult, type GlobalContext, type Guardrail, type GuardrailGenerationContext, type GuardrailPolicy, type GuardrailPolicyRule, type GuardrailPolicyRuleEscalation, GuardrailPolicyRuleEscalationSchema, GuardrailPolicyRuleSchema, GuardrailPolicySchema, GuardrailSchema, type GuardrailScope, GuardrailScopeSchema, type HandoffType, HandoffTypeSchema, type InsertAfterOperator, InsertAfterOperatorSchema, type LintDiagnostic, type LintRule, type LoadResult, type LoadedBinding, type Matcher, MatcherSchema, MergeError, type MergeableRecord, type MergedBehavioralSpec, type PathResolveResult, type PerAgentContext, type PerArtifactContext, type PerGuardrailContext, type PerGuardrailPolicyContext, type PerHandoffTypeContext, type PerPolicyContext, type PerTaskContext, type PerToolContext, type PerValidationContext, type PerWorkflowContext, type Policy, PolicySchema, type PolicyWhen, PolicyWhenSchema, type PrependOperator, PrependOperatorSchema, type Prerequisite, PrerequisiteSchema, type ReferenceDiagnostic, type RemoveOperator, RemoveOperatorSchema, type RenderTarget, RenderTargetSchema, type ReplaceOperator, ReplaceOperatorSchema, type Reporting, ReportingSchema, type ResolveChecksResult, type ResolveResult, type ResolvedCheck, type ResolvedConfig, type ResolvedRenderTarget, type Retry, type Rule, RuleSchema, type SchemaValidationResult, type ScoreResult, type Severity, type SoftwareBinding, SoftwareBindingSchema, type System, type SystemContext, SystemSchema, type Task, TaskSchema, type Tool, ToolSchema, type Validation, ValidationSchema, type VersionLiteral, VersionLiteralSchema, type Workflow, WorkflowSchema, type WorkflowStep, WorkflowStepSchema, type XExtensionDecl, XExtensionDeclSchema, buildArtifactContext, buildGlobalContext, buildGuardrailContext, buildGuardrailPolicyContext, buildHandoffTypeContext, buildPerAgentContext, buildPolicyContext, buildSystemContext, buildTaskContext, buildToolContext, buildValidationContext, buildWorkflowContext, builtinRules, checkDriftFromConfig, checkReferences, expandDefaults, generateGuardrails, lint, loadBindings, loadConfig, loadDsl, mergeDsl, renderFromConfig, resolve, resolveAllOf, resolveBase, resolveBindingTargetPath, resolveChecks, resolveDslPath, score, spectralLint, validateHandoffSchemas, validateSchema, yamlReservedKeySafetyRule };
1372
+ export { type Agent, type AgentContractsConfig, AgentContractsConfigSchema, AgentSchema, type AppendOperator, AppendOperatorSchema, type Artifact, ArtifactSchema, BaseResolveError, type BindingOutput, BindingOutputSchema, CONTEXT_TYPES, type Check, CheckSchema, type Command, CommandSchema, type Components, ComponentsSchema, ConfigLoadError, type ContextType, ContextTypeSchema, type DelegatableTaskView, type DiagnosticMessage, type DimensionResult, type Dsl, DslLoadError, DslSchema, type EntityGuardrailEntry, type EntityValidationEntry, type EscalationCriterion, EscalationCriterionSchema, type ExecutionStep, ExecutionStepSchema, type Extends, ExtendsSchema, type ExternalParticipant, type GenerateDiagnostic, type GenerateGuardrailsOptions, type GenerateResult, type GlobalContext, type Guardrail, type GuardrailGenerationContext, type GuardrailPolicy, type GuardrailPolicyRule, type GuardrailPolicyRuleEscalation, GuardrailPolicyRuleEscalationSchema, GuardrailPolicyRuleSchema, GuardrailPolicySchema, GuardrailSchema, type GuardrailScope, GuardrailScopeSchema, type HandoffType, HandoffTypeSchema, type InsertAfterOperator, InsertAfterOperatorSchema, type LintDiagnostic, type LintRule, type LoadResult, type LoadedBinding, type Matcher, MatcherSchema, MergeError, type MergeableRecord, type MergedBehavioralSpec, type PathResolveResult, type PerAgentContext, type PerArtifactContext, type PerGuardrailContext, type PerGuardrailPolicyContext, type PerHandoffTypeContext, type PerPolicyContext, type PerTaskContext, type PerToolContext, type PerValidationContext, type PerWorkflowContext, type Policy, PolicySchema, type PolicyWhen, PolicyWhenSchema, type PrependOperator, PrependOperatorSchema, type Prerequisite, PrerequisiteSchema, type ReferenceDiagnostic, type RemoveOperator, RemoveOperatorSchema, type RenderTarget, RenderTargetSchema, type ReplaceOperator, ReplaceOperatorSchema, type Reporting, ReportingSchema, type ResolveChecksResult, type ResolveResult, type ResolvedCheck, type ResolvedConfig, type ResolvedRenderTarget, type Retry, type Rule, RuleSchema, type SchemaValidationResult, type ScoreResult, type Severity, type SoftwareBinding, SoftwareBindingSchema, type System, type SystemContext, SystemSchema, type Task, TaskSchema, type Tool, ToolSchema, type Validation, ValidationSchema, type VersionLiteral, VersionLiteralSchema, type Workflow, WorkflowSchema, type WorkflowStep, WorkflowStepSchema, type XExtensionDecl, XExtensionDeclSchema, buildArtifactContext, buildGlobalContext, buildGuardrailContext, buildGuardrailPolicyContext, buildHandoffTypeContext, buildPerAgentContext, buildPolicyContext, buildSystemContext, buildTaskContext, buildToolContext, buildValidationContext, buildWorkflowContext, builtinRules, checkDriftFromConfig, checkReferences, expandDefaults, generateGuardrails, lint, loadBindings, loadConfig, loadDsl, mergeDsl, renderFromConfig, resolve, resolveAllOf, resolveBase, resolveBindingTargetPath, resolveChecks, resolveDslPath, resolveEffectiveGuardrails, resolveEntityValidations, score, spectralLint, validateHandoffSchemas, validateSchema, yamlReservedKeySafetyRule };
package/dist/index.js CHANGED
@@ -50463,7 +50463,8 @@ var AgentSchema = z.object({
50463
50463
  rules: z.array(RuleSchema).optional(),
50464
50464
  anti_patterns: z.array(z.string()).optional(),
50465
50465
  escalation_criteria: z.array(EscalationCriterionSchema).optional(),
50466
- prerequisites: z.array(PrerequisiteSchema).optional()
50466
+ prerequisites: z.array(PrerequisiteSchema).optional(),
50467
+ guardrails: z.array(z.string()).optional()
50467
50468
  }).passthrough();
50468
50469
 
50469
50470
  // src/schema/artifact.ts
@@ -50477,7 +50478,8 @@ var ArtifactSchema = z2.object({
50477
50478
  consumers: z2.array(z2.string()),
50478
50479
  states: z2.array(z2.string()),
50479
50480
  required_validations: z2.array(z2.string()).default([]),
50480
- visibility: z2.string().optional()
50481
+ visibility: z2.string().optional(),
50482
+ guardrails: z2.array(z2.string()).optional()
50481
50483
  }).passthrough();
50482
50484
 
50483
50485
  // src/schema/binding.ts
@@ -50641,7 +50643,8 @@ var TaskSchema = z8.object({
50641
50643
  rules: z8.array(RuleSchema).optional(),
50642
50644
  anti_patterns: z8.array(z8.string()).optional(),
50643
50645
  escalation_criteria: z8.array(EscalationCriterionSchema).optional(),
50644
- validations: z8.array(z8.string()).default([])
50646
+ validations: z8.array(z8.string()).default([]),
50647
+ guardrails: z8.array(z8.string()).optional()
50645
50648
  }).passthrough();
50646
50649
 
50647
50650
  // src/schema/tool.ts
@@ -50660,7 +50663,8 @@ var ToolSchema = z9.object({
50660
50663
  output_artifacts: z9.array(z9.string()).default([]),
50661
50664
  invokable_by: z9.array(z9.string()),
50662
50665
  side_effects: z9.array(z9.string()).default([]),
50663
- commands: z9.array(CommandSchema).default([])
50666
+ commands: z9.array(CommandSchema).default([]),
50667
+ guardrails: z9.array(z9.string()).optional()
50664
50668
  }).passthrough();
50665
50669
 
50666
50670
  // src/schema/validation.ts
@@ -51776,6 +51780,34 @@ function checkReferences(dsl) {
51776
51780
  }
51777
51781
  }
51778
51782
  }
51783
+ for (const [id, agent] of Object.entries(dsl.agents)) {
51784
+ if (agent.guardrails) {
51785
+ for (const ref of agent.guardrails) {
51786
+ checkExists(ref, guardrailIds, "guardrails", `agents.${id}.guardrails`, "entity-guardrail-ref-not-found");
51787
+ }
51788
+ }
51789
+ }
51790
+ for (const [id, task] of Object.entries(dsl.tasks)) {
51791
+ if (task.guardrails) {
51792
+ for (const ref of task.guardrails) {
51793
+ checkExists(ref, guardrailIds, "guardrails", `tasks.${id}.guardrails`, "entity-guardrail-ref-not-found");
51794
+ }
51795
+ }
51796
+ }
51797
+ for (const [id, tool] of Object.entries(dsl.tools)) {
51798
+ if (tool.guardrails) {
51799
+ for (const ref of tool.guardrails) {
51800
+ checkExists(ref, guardrailIds, "guardrails", `tools.${id}.guardrails`, "entity-guardrail-ref-not-found");
51801
+ }
51802
+ }
51803
+ }
51804
+ for (const [id, art] of Object.entries(dsl.artifacts)) {
51805
+ if (art.guardrails) {
51806
+ for (const ref of art.guardrails) {
51807
+ checkExists(ref, guardrailIds, "guardrails", `artifacts.${id}.guardrails`, "entity-guardrail-ref-not-found");
51808
+ }
51809
+ }
51810
+ }
51779
51811
  for (const [id, guardrail] of Object.entries(dsl.guardrails)) {
51780
51812
  if (guardrail.scope.agents) {
51781
51813
  for (const ref of guardrail.scope.agents) {
@@ -52457,6 +52489,148 @@ var semanticValidationPhaseCoverageRule = {
52457
52489
  }
52458
52490
  };
52459
52491
 
52492
+ // src/linter/rules/entity-guardrail-binding.ts
52493
+ var entityGuardrailUndefinedRule = {
52494
+ id: "entity-guardrail-undefined",
52495
+ description: "Entity references a guardrail ID not defined in guardrails",
52496
+ run(dsl) {
52497
+ const diagnostics = [];
52498
+ const guardrailIds = new Set(Object.keys(dsl.guardrails));
52499
+ const sections = [
52500
+ { name: "agents", entities: dsl.agents },
52501
+ { name: "tasks", entities: dsl.tasks },
52502
+ { name: "tools", entities: dsl.tools },
52503
+ { name: "artifacts", entities: dsl.artifacts }
52504
+ ];
52505
+ for (const { name, entities } of sections) {
52506
+ for (const [entityId, entity] of Object.entries(entities)) {
52507
+ for (const ref of entity.guardrails ?? []) {
52508
+ if (!guardrailIds.has(ref)) {
52509
+ diagnostics.push({
52510
+ ruleId: "entity-guardrail-undefined",
52511
+ severity: "error",
52512
+ path: `${name}.${entityId}.guardrails`,
52513
+ message: `${name.slice(0, -1)} "${entityId}" references guardrail "${ref}" which is not defined in guardrails`
52514
+ });
52515
+ }
52516
+ }
52517
+ }
52518
+ }
52519
+ return diagnostics;
52520
+ }
52521
+ };
52522
+ var entityNoGuardrailsRule = {
52523
+ id: "entity-no-guardrails",
52524
+ description: "Entity has no effective guardrails (neither entity-side nor scope-side)",
52525
+ run(dsl) {
52526
+ const diagnostics = [];
52527
+ const scopeBindings = {
52528
+ agents: /* @__PURE__ */ new Set(),
52529
+ tasks: /* @__PURE__ */ new Set(),
52530
+ tools: /* @__PURE__ */ new Set(),
52531
+ artifacts: /* @__PURE__ */ new Set()
52532
+ };
52533
+ for (const guardrail of Object.values(dsl.guardrails)) {
52534
+ for (const key of Object.keys(scopeBindings)) {
52535
+ const ids = guardrail.scope[key];
52536
+ if (ids) {
52537
+ for (const id of ids) scopeBindings[key].add(id);
52538
+ }
52539
+ }
52540
+ }
52541
+ const sections = [
52542
+ { name: "agents", entities: dsl.agents },
52543
+ { name: "tasks", entities: dsl.tasks },
52544
+ { name: "tools", entities: dsl.tools },
52545
+ { name: "artifacts", entities: dsl.artifacts }
52546
+ ];
52547
+ for (const { name, entities } of sections) {
52548
+ for (const [entityId, entity] of Object.entries(entities)) {
52549
+ const hasEntitySide = (entity.guardrails ?? []).length > 0;
52550
+ const hasScopeSide = scopeBindings[name].has(entityId);
52551
+ if (!hasEntitySide && !hasScopeSide) {
52552
+ diagnostics.push({
52553
+ ruleId: "entity-no-guardrails",
52554
+ severity: "info",
52555
+ path: `${name}.${entityId}`,
52556
+ message: `${name.slice(0, -1)} "${entityId}" has no effective guardrails`
52557
+ });
52558
+ }
52559
+ }
52560
+ }
52561
+ return diagnostics;
52562
+ }
52563
+ };
52564
+ var guardrailOrphanedRule = {
52565
+ id: "guardrail-orphaned",
52566
+ description: "Guardrail is not referenced by any entity and not bound to any entity via scope",
52567
+ run(dsl) {
52568
+ const diagnostics = [];
52569
+ const referencedByEntities = /* @__PURE__ */ new Set();
52570
+ const sections = [
52571
+ dsl.agents,
52572
+ dsl.tasks,
52573
+ dsl.tools,
52574
+ dsl.artifacts
52575
+ ];
52576
+ for (const entities of sections) {
52577
+ for (const entity of Object.values(entities)) {
52578
+ for (const ref of entity.guardrails ?? []) {
52579
+ referencedByEntities.add(ref);
52580
+ }
52581
+ }
52582
+ }
52583
+ for (const [guardrailId, guardrail] of Object.entries(dsl.guardrails)) {
52584
+ const hasEntityRef = referencedByEntities.has(guardrailId);
52585
+ const scope = guardrail.scope;
52586
+ const hasScopeBinding = (scope.agents?.length ?? 0) > 0 || (scope.tasks?.length ?? 0) > 0 || (scope.tools?.length ?? 0) > 0 || (scope.artifacts?.length ?? 0) > 0 || (scope.workflows?.length ?? 0) > 0;
52587
+ if (!hasEntityRef && !hasScopeBinding) {
52588
+ diagnostics.push({
52589
+ ruleId: "guardrail-orphaned",
52590
+ severity: "warning",
52591
+ path: `guardrails.${guardrailId}`,
52592
+ message: `Guardrail "${guardrailId}" is not referenced by any entity and has no scope bindings`
52593
+ });
52594
+ }
52595
+ }
52596
+ return diagnostics;
52597
+ }
52598
+ };
52599
+
52600
+ // src/linter/rules/validation-executor-no-context.ts
52601
+ var validationExecutorNoContextRule = {
52602
+ id: "validation-executor-no-context",
52603
+ description: "Validation executor is not wired so the validation appears in the executor's rendered context",
52604
+ run(dsl) {
52605
+ const diagnostics = [];
52606
+ for (const [validationId, val] of Object.entries(dsl.validations)) {
52607
+ if (val.executor_type === "agent") {
52608
+ const agent = dsl.agents[val.executor];
52609
+ if (!agent) continue;
52610
+ const allowed = new Set(agent.can_perform_validations ?? []);
52611
+ if (!allowed.has(validationId)) {
52612
+ diagnostics.push({
52613
+ ruleId: "validation-executor-no-context",
52614
+ severity: "warning",
52615
+ path: `agents.${val.executor}.can_perform_validations`,
52616
+ message: `Validation "${validationId}" is executed by agent "${val.executor}" but is not listed in can_perform_validations, so it will be missing from that agent's prompt context`
52617
+ });
52618
+ }
52619
+ } else if (val.executor_type === "tool") {
52620
+ if (!dsl.tools[val.executor]) {
52621
+ diagnostics.push({
52622
+ ruleId: "validation-executor-no-context",
52623
+ severity: "warning",
52624
+ path: `validations.${validationId}.executor`,
52625
+ message: `Validation "${validationId}" references tool executor "${val.executor}" which is not defined in tools`
52626
+ });
52627
+ }
52628
+ }
52629
+ }
52630
+ return diagnostics;
52631
+ }
52632
+ };
52633
+
52460
52634
  // src/linter/linter.ts
52461
52635
  var builtinRules = [
52462
52636
  validationCoverageRule,
@@ -52469,7 +52643,11 @@ var builtinRules = [
52469
52643
  yamlReservedKeySafetyRule,
52470
52644
  artifactRequiredValidationWiringRule,
52471
52645
  taskOutputValidationCompletenessRule,
52472
- semanticValidationPhaseCoverageRule
52646
+ semanticValidationPhaseCoverageRule,
52647
+ entityGuardrailUndefinedRule,
52648
+ entityNoGuardrailsRule,
52649
+ guardrailOrphanedRule,
52650
+ validationExecutorNoContextRule
52473
52651
  ];
52474
52652
  function lint(dsl, rules = builtinRules) {
52475
52653
  const diagnostics = [];
@@ -53183,12 +53361,96 @@ function buildGuardrailEnforcement(dsl, policy, loadedBindings) {
53183
53361
  }
53184
53362
  return entries;
53185
53363
  }
53364
+ function resolveEffectiveGuardrails(dsl, entityType, entityId) {
53365
+ const entityDef = dsl[entityType][entityId];
53366
+ const entitySide = new Set(entityDef?.guardrails ?? []);
53367
+ const scopeSide = /* @__PURE__ */ new Set();
53368
+ for (const [guardrailId, guardrail] of Object.entries(dsl.guardrails)) {
53369
+ const scopeIds = guardrail.scope[entityType];
53370
+ if (scopeIds?.includes(entityId)) {
53371
+ scopeSide.add(guardrailId);
53372
+ }
53373
+ }
53374
+ const allIds = /* @__PURE__ */ new Set([...entitySide, ...scopeSide]);
53375
+ const activePolicyRules = /* @__PURE__ */ new Map();
53376
+ for (const policy of Object.values(dsl.guardrail_policies)) {
53377
+ for (const rule of policy.rules) {
53378
+ if (!activePolicyRules.has(rule.guardrail)) {
53379
+ activePolicyRules.set(rule.guardrail, {
53380
+ severity: rule.severity,
53381
+ action: rule.action
53382
+ });
53383
+ }
53384
+ }
53385
+ }
53386
+ const entries = [];
53387
+ for (const id of allIds) {
53388
+ const guardrail = dsl.guardrails[id];
53389
+ if (!guardrail) continue;
53390
+ const fromEntity = entitySide.has(id);
53391
+ const fromScope = scopeSide.has(id);
53392
+ const source = fromEntity && fromScope ? "both" : fromEntity ? "entity" : "scope";
53393
+ const policyInfo = activePolicyRules.get(id);
53394
+ entries.push({
53395
+ guardrail_id: id,
53396
+ description: guardrail.description,
53397
+ rationale: guardrail.rationale,
53398
+ tags: guardrail.tags,
53399
+ source,
53400
+ severity: policyInfo?.severity,
53401
+ action: policyInfo?.action
53402
+ });
53403
+ }
53404
+ return entries;
53405
+ }
53406
+ function validationToEntityEntry(validationId, validation) {
53407
+ return {
53408
+ validation_id: validationId,
53409
+ kind: validation.kind,
53410
+ target_artifact: validation.target_artifact,
53411
+ executor_type: validation.executor_type,
53412
+ blocking: validation.blocking,
53413
+ produces_evidence: validation.produces_evidence
53414
+ };
53415
+ }
53416
+ function resolveEntityValidations(dsl, entityType, entityId) {
53417
+ if (entityType === "agents") {
53418
+ const agent = dsl.agents[entityId];
53419
+ if (!agent) return [];
53420
+ const entries2 = [];
53421
+ for (const vid of agent.can_perform_validations ?? []) {
53422
+ const v2 = dsl.validations[vid];
53423
+ if (v2) entries2.push(validationToEntityEntry(vid, v2));
53424
+ }
53425
+ return entries2;
53426
+ }
53427
+ if (entityType === "tasks") {
53428
+ const task = dsl.tasks[entityId];
53429
+ if (!task) return [];
53430
+ const entries2 = [];
53431
+ for (const vid of task.validations ?? []) {
53432
+ const v2 = dsl.validations[vid];
53433
+ if (v2) entries2.push(validationToEntityEntry(vid, v2));
53434
+ }
53435
+ return entries2;
53436
+ }
53437
+ const entries = [];
53438
+ for (const [vid, v2] of Object.entries(dsl.validations)) {
53439
+ if (v2.executor_type === "tool" && v2.executor === entityId) {
53440
+ entries.push(validationToEntityEntry(vid, v2));
53441
+ }
53442
+ }
53443
+ entries.sort((a3, b3) => a3.validation_id.localeCompare(b3.validation_id));
53444
+ return entries;
53445
+ }
53186
53446
  function buildTaskContext(dsl, taskId) {
53187
53447
  const taskDef = dsl.tasks[taskId];
53188
53448
  const task = { ...taskDef, id: taskId };
53189
53449
  const agentDef = dsl.agents[taskDef.target_agent];
53190
53450
  const targetAgent = agentDef ? { ...agentDef, id: taskDef.target_agent } : null;
53191
- return { task, targetAgent, dsl };
53451
+ const relatedGuardrails = resolveEffectiveGuardrails(dsl, "tasks", taskId);
53452
+ const relatedValidations = resolveEntityValidations(dsl, "tasks", taskId);
53453
+ return { task, targetAgent, relatedGuardrails, relatedValidations, dsl };
53192
53454
  }
53193
53455
  function buildArtifactContext(dsl, artifactId) {
53194
53456
  const artifactDef = dsl.artifacts[artifactId];
@@ -53231,6 +53493,7 @@ function buildArtifactContext(dsl, artifactId) {
53231
53493
  }
53232
53494
  }
53233
53495
  }
53496
+ const relatedGuardrails = resolveEffectiveGuardrails(dsl, "artifacts", artifactId);
53234
53497
  return {
53235
53498
  artifact,
53236
53499
  relatedTools,
@@ -53239,6 +53502,7 @@ function buildArtifactContext(dsl, artifactId) {
53239
53502
  consumerAgents,
53240
53503
  editorAgents,
53241
53504
  createdInWorkflows,
53505
+ relatedGuardrails,
53242
53506
  dsl
53243
53507
  };
53244
53508
  }
@@ -53256,11 +53520,15 @@ function buildToolContext(dsl, toolId) {
53256
53520
  }
53257
53521
  return result;
53258
53522
  };
53523
+ const relatedGuardrails = resolveEffectiveGuardrails(dsl, "tools", toolId);
53524
+ const relatedValidations = resolveEntityValidations(dsl, "tools", toolId);
53259
53525
  return {
53260
53526
  tool,
53261
53527
  invokableAgents,
53262
53528
  inputArtifactDetails: pickArtifacts(toolDef.input_artifacts),
53263
53529
  outputArtifactDetails: pickArtifacts(toolDef.output_artifacts),
53530
+ relatedGuardrails,
53531
+ relatedValidations,
53264
53532
  dsl
53265
53533
  };
53266
53534
  }
@@ -53492,6 +53760,8 @@ function buildPerAgentContext(dsl, agent) {
53492
53760
  }
53493
53761
  const rawReceivableTasks = receivableTasks.map(({ id: _id, ...rest }) => rest);
53494
53762
  const mergedBehavior = mergeBehavioralSpec(agent, rawReceivableTasks);
53763
+ const relatedGuardrails = resolveEffectiveGuardrails(dsl, "agents", agentId);
53764
+ const relatedValidations = resolveEntityValidations(dsl, "agents", agentId);
53495
53765
  return {
53496
53766
  agent,
53497
53767
  tasks: receivableTasks,
@@ -53501,6 +53771,8 @@ function buildPerAgentContext(dsl, agent) {
53501
53771
  relatedTools,
53502
53772
  relatedHandoffTypes,
53503
53773
  mergedBehavior,
53774
+ relatedGuardrails,
53775
+ relatedValidations,
53504
53776
  dsl
53505
53777
  };
53506
53778
  }
@@ -54911,6 +55183,52 @@ function crossReferenceBidirectionality(dsl) {
54911
55183
  recommendations: issues.length > 0 ? [`${issues.length} unreciprocated cross-references: ${issues.slice(0, 5).join(", ")}${issues.length > 5 ? `, ... (${issues.length - 5} more)` : ""}`] : []
54912
55184
  };
54913
55185
  }
55186
+ function entityGuardrailCoverage(dsl) {
55187
+ const entitySections = [
55188
+ { name: "agents", entities: dsl.agents },
55189
+ { name: "tasks", entities: dsl.tasks },
55190
+ { name: "tools", entities: dsl.tools },
55191
+ { name: "artifacts", entities: dsl.artifacts }
55192
+ ];
55193
+ const scopeBindings = {
55194
+ agents: /* @__PURE__ */ new Set(),
55195
+ tasks: /* @__PURE__ */ new Set(),
55196
+ tools: /* @__PURE__ */ new Set(),
55197
+ artifacts: /* @__PURE__ */ new Set()
55198
+ };
55199
+ for (const guardrail of Object.values(dsl.guardrails)) {
55200
+ for (const key of Object.keys(scopeBindings)) {
55201
+ const ids = guardrail.scope[key];
55202
+ if (ids) {
55203
+ for (const id of ids) scopeBindings[key].add(id);
55204
+ }
55205
+ }
55206
+ }
55207
+ let total = 0;
55208
+ let covered = 0;
55209
+ const missing = [];
55210
+ for (const { name, entities } of entitySections) {
55211
+ for (const [entityId, entity] of Object.entries(entities)) {
55212
+ total++;
55213
+ const hasEntitySide = (entity.guardrails ?? []).length > 0;
55214
+ const hasScopeSide = scopeBindings[name].has(entityId);
55215
+ if (hasEntitySide || hasScopeSide) {
55216
+ covered++;
55217
+ } else {
55218
+ missing.push(`${name}.${entityId}`);
55219
+ }
55220
+ }
55221
+ }
55222
+ return {
55223
+ id: "entity-guardrail-coverage",
55224
+ label: "Entity guardrail coverage",
55225
+ score: covered,
55226
+ total,
55227
+ percent: pct(covered, total),
55228
+ weight: 1,
55229
+ recommendations: missing.length > 0 ? [`${missing.length} entities without guardrails: ${missing.slice(0, 5).join(", ")}${missing.length > 5 ? `, ... (${missing.length - 5} more)` : ""}`] : []
55230
+ };
55231
+ }
54914
55232
  function guardrailScopeResolution(dsl) {
54915
55233
  let totalRefs = 0;
54916
55234
  let resolvedRefs = 0;
@@ -54956,7 +55274,8 @@ function score(dsl) {
54956
55274
  workflowValidationIntegration(dsl),
54957
55275
  schemaCompleteness(dsl),
54958
55276
  crossReferenceBidirectionality(dsl),
54959
- guardrailScopeResolution(dsl)
55277
+ guardrailScopeResolution(dsl),
55278
+ entityGuardrailCoverage(dsl)
54960
55279
  ];
54961
55280
  const totalWeight = dimensions.reduce((s2, d2) => s2 + d2.weight, 0);
54962
55281
  const weightedSum = dimensions.reduce(
@@ -55383,6 +55702,8 @@ export {
55383
55702
  resolveBindingTargetPath,
55384
55703
  resolveChecks,
55385
55704
  resolveDslPath,
55705
+ resolveEffectiveGuardrails,
55706
+ resolveEntityValidations,
55386
55707
  score,
55387
55708
  spectralLint,
55388
55709
  validateHandoffSchemas,