agent-contracts 0.11.4 → 0.11.6
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/README.md +86 -12
- package/dist/cli.js +227 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +34 -4
- package/dist/index.js +226 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -198,6 +198,17 @@ declare const ComponentsSchema: z.ZodObject<{
|
|
|
198
198
|
schemas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
199
199
|
}, z.core.$loose>;
|
|
200
200
|
type Components = z.infer<typeof ComponentsSchema>;
|
|
201
|
+
/**
|
|
202
|
+
* Declaration of project-specific `x-*` extension fields.
|
|
203
|
+
* Each key must start with `x-` and describes the expected type/shape
|
|
204
|
+
* so that tooling can validate custom extensions in the future.
|
|
205
|
+
*/
|
|
206
|
+
declare const XExtensionDeclSchema: z.ZodObject<{
|
|
207
|
+
type: z.ZodString;
|
|
208
|
+
items: z.ZodOptional<z.ZodString>;
|
|
209
|
+
description: z.ZodOptional<z.ZodString>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
type XExtensionDecl = z.infer<typeof XExtensionDeclSchema>;
|
|
201
212
|
declare const DslSchema: z.ZodObject<{
|
|
202
213
|
version: z.ZodLiteral<1>;
|
|
203
214
|
extends: z.ZodOptional<z.ZodString>;
|
|
@@ -390,7 +401,8 @@ declare const DslSchema: z.ZodObject<{
|
|
|
390
401
|
}, z.core.$loose>, z.ZodObject<{
|
|
391
402
|
type: z.ZodLiteral<"decision">;
|
|
392
403
|
description: z.ZodOptional<z.ZodString>;
|
|
393
|
-
on: z.ZodString
|
|
404
|
+
on: z.ZodOptional<z.ZodString>;
|
|
405
|
+
routing_key: z.ZodOptional<z.ZodString>;
|
|
394
406
|
branches: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
395
407
|
group: z.ZodOptional<z.ZodString>;
|
|
396
408
|
}, z.core.$loose>], "type">>;
|
|
@@ -452,6 +464,11 @@ declare const DslSchema: z.ZodObject<{
|
|
|
452
464
|
components: z.ZodDefault<z.ZodObject<{
|
|
453
465
|
schemas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
454
466
|
}, z.core.$loose>>;
|
|
467
|
+
"x-extensions": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
468
|
+
type: z.ZodString;
|
|
469
|
+
items: z.ZodOptional<z.ZodString>;
|
|
470
|
+
description: z.ZodOptional<z.ZodString>;
|
|
471
|
+
}, z.core.$strip>>>;
|
|
455
472
|
}, z.core.$loose>;
|
|
456
473
|
type Dsl = z.infer<typeof DslSchema>;
|
|
457
474
|
|
|
@@ -777,7 +794,8 @@ declare const WorkflowStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
777
794
|
}, z.core.$loose>, z.ZodObject<{
|
|
778
795
|
type: z.ZodLiteral<"decision">;
|
|
779
796
|
description: z.ZodOptional<z.ZodString>;
|
|
780
|
-
on: z.ZodString
|
|
797
|
+
on: z.ZodOptional<z.ZodString>;
|
|
798
|
+
routing_key: z.ZodOptional<z.ZodString>;
|
|
781
799
|
branches: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
782
800
|
group: z.ZodOptional<z.ZodString>;
|
|
783
801
|
}, z.core.$loose>], "type">;
|
|
@@ -822,7 +840,8 @@ declare const WorkflowSchema: z.ZodObject<{
|
|
|
822
840
|
}, z.core.$loose>, z.ZodObject<{
|
|
823
841
|
type: z.ZodLiteral<"decision">;
|
|
824
842
|
description: z.ZodOptional<z.ZodString>;
|
|
825
|
-
on: z.ZodString
|
|
843
|
+
on: z.ZodOptional<z.ZodString>;
|
|
844
|
+
routing_key: z.ZodOptional<z.ZodString>;
|
|
826
845
|
branches: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
827
846
|
group: z.ZodOptional<z.ZodString>;
|
|
828
847
|
}, z.core.$loose>], "type">>;
|
|
@@ -866,6 +885,15 @@ interface ResolveResult {
|
|
|
866
885
|
}
|
|
867
886
|
declare function resolve(projectDirOrFile: string): Promise<ResolveResult>;
|
|
868
887
|
|
|
888
|
+
/**
|
|
889
|
+
* Parse the resolved DSL through Zod to fill all schema-defined default
|
|
890
|
+
* values, then return the fully-expanded plain object.
|
|
891
|
+
*
|
|
892
|
+
* If parsing fails (e.g. the DSL has validation errors), the original
|
|
893
|
+
* data is returned unchanged so that `resolve` remains non-destructive.
|
|
894
|
+
*/
|
|
895
|
+
declare function expandDefaults(data: Record<string, unknown>): Record<string, unknown>;
|
|
896
|
+
|
|
869
897
|
interface DiagnosticMessage {
|
|
870
898
|
path: string;
|
|
871
899
|
message: string;
|
|
@@ -916,6 +944,8 @@ declare function lint(dsl: Dsl, rules?: LintRule[]): LintDiagnostic[];
|
|
|
916
944
|
*/
|
|
917
945
|
declare function spectralLint(dslObject: Record<string, unknown>): Promise<LintDiagnostic[]>;
|
|
918
946
|
|
|
947
|
+
declare const yamlReservedKeySafetyRule: LintRule;
|
|
948
|
+
|
|
919
949
|
declare const CONTEXT_TYPES: readonly ["agent", "task", "artifact", "tool", "validation", "handoff_type", "workflow", "policy", "guardrail", "guardrail_policy", "system"];
|
|
920
950
|
declare const ContextTypeSchema: z.ZodEnum<{
|
|
921
951
|
guardrail: "guardrail";
|
|
@@ -1229,4 +1259,4 @@ interface PathResolveResult {
|
|
|
1229
1259
|
}
|
|
1230
1260
|
declare function resolveBindingTargetPath(target: string, paths: Record<string, string>, bindingSoftware: string): PathResolveResult;
|
|
1231
1261
|
|
|
1232
|
-
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 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 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, buildArtifactContext, buildGlobalContext, buildGuardrailContext, buildGuardrailPolicyContext, buildHandoffTypeContext, buildPerAgentContext, buildPolicyContext, buildSystemContext, buildTaskContext, buildToolContext, buildValidationContext, buildWorkflowContext, builtinRules, checkDriftFromConfig, checkReferences, generateGuardrails, lint, loadBindings, loadConfig, loadDsl, mergeDsl, renderFromConfig, resolve, resolveAllOf, resolveBase, resolveBindingTargetPath, resolveChecks, resolveDslPath, spectralLint, validateHandoffSchemas, validateSchema };
|
|
1262
|
+
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 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 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, spectralLint, validateHandoffSchemas, validateSchema, yamlReservedKeySafetyRule };
|
package/dist/index.js
CHANGED
|
@@ -50712,7 +50712,9 @@ var WorkflowValidationStepSchema = z11.object({
|
|
|
50712
50712
|
var WorkflowDecisionStepSchema = z11.object({
|
|
50713
50713
|
type: z11.literal("decision"),
|
|
50714
50714
|
description: z11.string().optional(),
|
|
50715
|
-
on
|
|
50715
|
+
/** @deprecated Use `routing_key` instead. `on` is kept for backward compatibility. */
|
|
50716
|
+
on: z11.string().optional(),
|
|
50717
|
+
routing_key: z11.string().optional(),
|
|
50716
50718
|
branches: z11.record(z11.string(), z11.array(z11.string())),
|
|
50717
50719
|
group: z11.string().optional()
|
|
50718
50720
|
}).passthrough();
|
|
@@ -50735,6 +50737,11 @@ var WorkflowSchema = z11.object({
|
|
|
50735
50737
|
var ComponentsSchema = z12.object({
|
|
50736
50738
|
schemas: z12.record(z12.string(), z12.record(z12.string(), z12.any())).default({})
|
|
50737
50739
|
}).passthrough();
|
|
50740
|
+
var XExtensionDeclSchema = z12.object({
|
|
50741
|
+
type: z12.string(),
|
|
50742
|
+
items: z12.string().optional(),
|
|
50743
|
+
description: z12.string().optional()
|
|
50744
|
+
});
|
|
50738
50745
|
var DslSchema = z12.object({
|
|
50739
50746
|
version: z12.literal(1),
|
|
50740
50747
|
extends: z12.string().optional(),
|
|
@@ -50749,7 +50756,8 @@ var DslSchema = z12.object({
|
|
|
50749
50756
|
policies: z12.record(z12.string(), PolicySchema).default({}),
|
|
50750
50757
|
guardrails: z12.record(z12.string(), GuardrailSchema).default({}),
|
|
50751
50758
|
guardrail_policies: z12.record(z12.string(), GuardrailPolicySchema).default({}),
|
|
50752
|
-
components: ComponentsSchema.default({ schemas: {} })
|
|
50759
|
+
components: ComponentsSchema.default({ schemas: {} }),
|
|
50760
|
+
"x-extensions": z12.record(z12.string(), XExtensionDeclSchema).optional()
|
|
50753
50761
|
}).passthrough();
|
|
50754
50762
|
|
|
50755
50763
|
// src/schema/json-schema-utils.ts
|
|
@@ -51422,6 +51430,13 @@ async function resolve3(projectDirOrFile) {
|
|
|
51422
51430
|
};
|
|
51423
51431
|
}
|
|
51424
51432
|
|
|
51433
|
+
// src/resolver/expand-defaults.ts
|
|
51434
|
+
function expandDefaults(data) {
|
|
51435
|
+
const result = DslSchema.safeParse(data);
|
|
51436
|
+
if (!result.success) return data;
|
|
51437
|
+
return JSON.parse(JSON.stringify(result.data));
|
|
51438
|
+
}
|
|
51439
|
+
|
|
51425
51440
|
// src/validator/schema-validator.ts
|
|
51426
51441
|
import { z as z14 } from "zod";
|
|
51427
51442
|
function unwrap(schema) {
|
|
@@ -51484,6 +51499,47 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51484
51499
|
}
|
|
51485
51500
|
return [];
|
|
51486
51501
|
}
|
|
51502
|
+
function checkXExtensionsKeys(data) {
|
|
51503
|
+
const extensions = data["x-extensions"];
|
|
51504
|
+
if (typeof extensions !== "object" || extensions === null) return [];
|
|
51505
|
+
const diagnostics = [];
|
|
51506
|
+
for (const key of Object.keys(extensions)) {
|
|
51507
|
+
if (!key.startsWith("x-")) {
|
|
51508
|
+
diagnostics.push({
|
|
51509
|
+
path: `x-extensions.${key}`,
|
|
51510
|
+
message: `Extension key "${key}" must start with "x-" prefix.`,
|
|
51511
|
+
code: "x-extension-key-prefix"
|
|
51512
|
+
});
|
|
51513
|
+
}
|
|
51514
|
+
}
|
|
51515
|
+
return diagnostics;
|
|
51516
|
+
}
|
|
51517
|
+
function checkDecisionStepRoutingKey(data) {
|
|
51518
|
+
const workflow = data["workflow"];
|
|
51519
|
+
if (typeof workflow !== "object" || workflow === null) return [];
|
|
51520
|
+
const diagnostics = [];
|
|
51521
|
+
for (const [wfKey, wf] of Object.entries(
|
|
51522
|
+
workflow
|
|
51523
|
+
)) {
|
|
51524
|
+
if (typeof wf !== "object" || wf === null) continue;
|
|
51525
|
+
const steps = wf["steps"];
|
|
51526
|
+
if (!Array.isArray(steps)) continue;
|
|
51527
|
+
for (let i3 = 0; i3 < steps.length; i3++) {
|
|
51528
|
+
const step = steps[i3];
|
|
51529
|
+
if (typeof step !== "object" || step === null) continue;
|
|
51530
|
+
const s2 = step;
|
|
51531
|
+
if (s2["type"] !== "decision") continue;
|
|
51532
|
+
if (s2["routing_key"] === void 0 && s2["on"] === void 0) {
|
|
51533
|
+
diagnostics.push({
|
|
51534
|
+
path: `workflow.${wfKey}.steps[${i3}]`,
|
|
51535
|
+
message: 'Decision step requires "routing_key" (or deprecated "on"). Prefer "routing_key".',
|
|
51536
|
+
code: "decision-missing-routing-key"
|
|
51537
|
+
});
|
|
51538
|
+
}
|
|
51539
|
+
}
|
|
51540
|
+
}
|
|
51541
|
+
return diagnostics;
|
|
51542
|
+
}
|
|
51487
51543
|
function validateSchema(data) {
|
|
51488
51544
|
const result = DslSchema.safeParse(data);
|
|
51489
51545
|
if (!result.success) {
|
|
@@ -51498,6 +51554,14 @@ function validateSchema(data) {
|
|
|
51498
51554
|
if (customPropDiagnostics.length > 0) {
|
|
51499
51555
|
return { success: false, diagnostics: customPropDiagnostics };
|
|
51500
51556
|
}
|
|
51557
|
+
const decisionDiagnostics = checkDecisionStepRoutingKey(data);
|
|
51558
|
+
if (decisionDiagnostics.length > 0) {
|
|
51559
|
+
return { success: false, diagnostics: decisionDiagnostics };
|
|
51560
|
+
}
|
|
51561
|
+
const xExtDiagnostics = checkXExtensionsKeys(data);
|
|
51562
|
+
if (xExtDiagnostics.length > 0) {
|
|
51563
|
+
return { success: false, diagnostics: xExtDiagnostics };
|
|
51564
|
+
}
|
|
51501
51565
|
return { success: true, data: result.data, diagnostics: [] };
|
|
51502
51566
|
}
|
|
51503
51567
|
|
|
@@ -51812,6 +51876,7 @@ var validationCoverageRule = {
|
|
|
51812
51876
|
}
|
|
51813
51877
|
validationsByArtifact.get(val.target_artifact).add(val.kind);
|
|
51814
51878
|
}
|
|
51879
|
+
const strictArtifactTypes = ["code", "config", "schema"];
|
|
51815
51880
|
for (const [artId, art] of Object.entries(dsl.artifacts)) {
|
|
51816
51881
|
const kinds = validationsByArtifact.get(artId);
|
|
51817
51882
|
if (!kinds || kinds.size === 0) {
|
|
@@ -51823,8 +51888,7 @@ var validationCoverageRule = {
|
|
|
51823
51888
|
});
|
|
51824
51889
|
continue;
|
|
51825
51890
|
}
|
|
51826
|
-
|
|
51827
|
-
if (mechanicalTypes.includes(art.type) && !kinds.has("mechanical") && !kinds.has("schema")) {
|
|
51891
|
+
if (strictArtifactTypes.includes(art.type) && !kinds.has("mechanical") && !kinds.has("schema")) {
|
|
51828
51892
|
diagnostics.push({
|
|
51829
51893
|
ruleId: "validation-coverage",
|
|
51830
51894
|
severity: "warning",
|
|
@@ -51833,6 +51897,16 @@ var validationCoverageRule = {
|
|
|
51833
51897
|
});
|
|
51834
51898
|
}
|
|
51835
51899
|
}
|
|
51900
|
+
for (const [artId, art] of Object.entries(dsl.artifacts)) {
|
|
51901
|
+
if (art.required_validations.length === 0) {
|
|
51902
|
+
diagnostics.push({
|
|
51903
|
+
ruleId: "validation-coverage",
|
|
51904
|
+
severity: "warning",
|
|
51905
|
+
path: `artifacts.${artId}`,
|
|
51906
|
+
message: `Artifact "${artId}" has empty required_validations`
|
|
51907
|
+
});
|
|
51908
|
+
}
|
|
51909
|
+
}
|
|
51836
51910
|
const referencedValidations = /* @__PURE__ */ new Set();
|
|
51837
51911
|
for (const wf of Object.values(dsl.workflow)) {
|
|
51838
51912
|
for (const step of wf.steps) {
|
|
@@ -52174,6 +52248,146 @@ var guardrailPolicyCoverageRule = {
|
|
|
52174
52248
|
}
|
|
52175
52249
|
};
|
|
52176
52250
|
|
|
52251
|
+
// src/linter/rules/yaml-reserved-key-safety.ts
|
|
52252
|
+
var YAML_11_RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
52253
|
+
"on",
|
|
52254
|
+
"off",
|
|
52255
|
+
"yes",
|
|
52256
|
+
"no",
|
|
52257
|
+
"true",
|
|
52258
|
+
"false",
|
|
52259
|
+
"y",
|
|
52260
|
+
"n"
|
|
52261
|
+
]);
|
|
52262
|
+
var yamlReservedKeySafetyRule = {
|
|
52263
|
+
id: "yaml-reserved-key-safety",
|
|
52264
|
+
description: "Warns when YAML 1.1 reserved words are used as field values in positions where they may be misinterpreted by non-1.2 parsers",
|
|
52265
|
+
run(dsl) {
|
|
52266
|
+
const diagnostics = [];
|
|
52267
|
+
for (const [wfKey, wf] of Object.entries(dsl.workflow)) {
|
|
52268
|
+
for (let i3 = 0; i3 < wf.steps.length; i3++) {
|
|
52269
|
+
const step = wf.steps[i3];
|
|
52270
|
+
if (step.type !== "decision") continue;
|
|
52271
|
+
if (step.on !== void 0 && step.routing_key === void 0) {
|
|
52272
|
+
diagnostics.push({
|
|
52273
|
+
ruleId: "yaml-reserved-key-safety",
|
|
52274
|
+
severity: "warning",
|
|
52275
|
+
path: `workflow.${wfKey}.steps[${i3}].on`,
|
|
52276
|
+
message: 'Field name "on" is a YAML 1.1 reserved word and may be interpreted as boolean true by some parsers. Use "routing_key" instead.'
|
|
52277
|
+
});
|
|
52278
|
+
}
|
|
52279
|
+
const branchKeys = Object.keys(step.branches);
|
|
52280
|
+
for (const key of branchKeys) {
|
|
52281
|
+
if (YAML_11_RESERVED_KEYS.has(key.toLowerCase())) {
|
|
52282
|
+
diagnostics.push({
|
|
52283
|
+
ruleId: "yaml-reserved-key-safety",
|
|
52284
|
+
severity: "warning",
|
|
52285
|
+
path: `workflow.${wfKey}.steps[${i3}].branches.${key}`,
|
|
52286
|
+
message: `Branch key "${key}" is a YAML 1.1 reserved word and may be interpreted as a boolean by some parsers. Consider quoting or renaming.`
|
|
52287
|
+
});
|
|
52288
|
+
}
|
|
52289
|
+
}
|
|
52290
|
+
}
|
|
52291
|
+
}
|
|
52292
|
+
return diagnostics;
|
|
52293
|
+
}
|
|
52294
|
+
};
|
|
52295
|
+
|
|
52296
|
+
// src/linter/rules/artifact-required-validation-wiring.ts
|
|
52297
|
+
var artifactRequiredValidationWiringRule = {
|
|
52298
|
+
id: "artifact-required-validation-wiring",
|
|
52299
|
+
description: "Every validation listed in artifact.required_validations must exist, target the artifact, and be referenced in a workflow step or task.",
|
|
52300
|
+
run(dsl) {
|
|
52301
|
+
const diagnostics = [];
|
|
52302
|
+
const referencedValidations = /* @__PURE__ */ new Set();
|
|
52303
|
+
for (const wf of Object.values(dsl.workflow)) {
|
|
52304
|
+
for (const step of wf.steps) {
|
|
52305
|
+
if (step.type === "validation") {
|
|
52306
|
+
referencedValidations.add(step.validation);
|
|
52307
|
+
}
|
|
52308
|
+
}
|
|
52309
|
+
}
|
|
52310
|
+
for (const task of Object.values(dsl.tasks)) {
|
|
52311
|
+
for (const valId of task.validations) {
|
|
52312
|
+
referencedValidations.add(valId);
|
|
52313
|
+
}
|
|
52314
|
+
}
|
|
52315
|
+
for (const [artId, art] of Object.entries(dsl.artifacts)) {
|
|
52316
|
+
for (const reqValId of art.required_validations) {
|
|
52317
|
+
const val = dsl.validations[reqValId];
|
|
52318
|
+
if (!val) {
|
|
52319
|
+
diagnostics.push({
|
|
52320
|
+
ruleId: "artifact-required-validation-wiring",
|
|
52321
|
+
severity: "error",
|
|
52322
|
+
path: `artifacts.${artId}`,
|
|
52323
|
+
message: `required_validation "${reqValId}" does not exist in validations`
|
|
52324
|
+
});
|
|
52325
|
+
continue;
|
|
52326
|
+
}
|
|
52327
|
+
if (val.target_artifact !== artId) {
|
|
52328
|
+
diagnostics.push({
|
|
52329
|
+
ruleId: "artifact-required-validation-wiring",
|
|
52330
|
+
severity: "error",
|
|
52331
|
+
path: `artifacts.${artId}`,
|
|
52332
|
+
message: `required_validation "${reqValId}" has target_artifact "${val.target_artifact}" instead of "${artId}"`
|
|
52333
|
+
});
|
|
52334
|
+
}
|
|
52335
|
+
if (!referencedValidations.has(reqValId)) {
|
|
52336
|
+
diagnostics.push({
|
|
52337
|
+
ruleId: "artifact-required-validation-wiring",
|
|
52338
|
+
severity: "warning",
|
|
52339
|
+
path: `artifacts.${artId}`,
|
|
52340
|
+
message: `required_validation "${reqValId}" is defined but not referenced in any workflow step or task`
|
|
52341
|
+
});
|
|
52342
|
+
}
|
|
52343
|
+
}
|
|
52344
|
+
}
|
|
52345
|
+
return diagnostics;
|
|
52346
|
+
}
|
|
52347
|
+
};
|
|
52348
|
+
|
|
52349
|
+
// src/linter/rules/task-output-validation-completeness.ts
|
|
52350
|
+
var taskOutputValidationCompletenessRule = {
|
|
52351
|
+
id: "task-output-validation-completeness",
|
|
52352
|
+
description: "Tasks producing artifacts should cover those artifacts' required_validations in their validations list.",
|
|
52353
|
+
run(dsl) {
|
|
52354
|
+
const diagnostics = [];
|
|
52355
|
+
for (const [taskId, task] of Object.entries(dsl.tasks)) {
|
|
52356
|
+
const producedArtifacts = /* @__PURE__ */ new Set();
|
|
52357
|
+
if (task.execution_steps) {
|
|
52358
|
+
for (const step of task.execution_steps) {
|
|
52359
|
+
if (step.produces_artifact) {
|
|
52360
|
+
producedArtifacts.add(step.produces_artifact);
|
|
52361
|
+
}
|
|
52362
|
+
}
|
|
52363
|
+
}
|
|
52364
|
+
const agent = dsl.agents[task.target_agent];
|
|
52365
|
+
if (agent) {
|
|
52366
|
+
for (const artId of agent.can_write_artifacts) {
|
|
52367
|
+
producedArtifacts.add(artId);
|
|
52368
|
+
}
|
|
52369
|
+
}
|
|
52370
|
+
const taskValidations = new Set(task.validations);
|
|
52371
|
+
for (const artId of producedArtifacts) {
|
|
52372
|
+
const art = dsl.artifacts[artId];
|
|
52373
|
+
if (!art || art.required_validations.length === 0) continue;
|
|
52374
|
+
const missing = art.required_validations.filter(
|
|
52375
|
+
(v2) => !taskValidations.has(v2)
|
|
52376
|
+
);
|
|
52377
|
+
if (missing.length > 0) {
|
|
52378
|
+
diagnostics.push({
|
|
52379
|
+
ruleId: "task-output-validation-completeness",
|
|
52380
|
+
severity: "warning",
|
|
52381
|
+
path: `tasks.${taskId}`,
|
|
52382
|
+
message: `Task produces artifact "${artId}" which requires validations [${missing.join(", ")}] but task.validations does not include them`
|
|
52383
|
+
});
|
|
52384
|
+
}
|
|
52385
|
+
}
|
|
52386
|
+
}
|
|
52387
|
+
return diagnostics;
|
|
52388
|
+
}
|
|
52389
|
+
};
|
|
52390
|
+
|
|
52177
52391
|
// src/linter/linter.ts
|
|
52178
52392
|
var builtinRules = [
|
|
52179
52393
|
validationCoverageRule,
|
|
@@ -52182,7 +52396,10 @@ var builtinRules = [
|
|
|
52182
52396
|
mergeIntegrityRule,
|
|
52183
52397
|
artifactOwnershipRule,
|
|
52184
52398
|
toolCommandsRule,
|
|
52185
|
-
guardrailPolicyCoverageRule
|
|
52399
|
+
guardrailPolicyCoverageRule,
|
|
52400
|
+
yamlReservedKeySafetyRule,
|
|
52401
|
+
artifactRequiredValidationWiringRule,
|
|
52402
|
+
taskOutputValidationCompletenessRule
|
|
52186
52403
|
];
|
|
52187
52404
|
function lint(dsl, rules = builtinRules) {
|
|
52188
52405
|
const diagnostics = [];
|
|
@@ -54609,6 +54826,7 @@ export {
|
|
|
54609
54826
|
VersionLiteralSchema,
|
|
54610
54827
|
WorkflowSchema,
|
|
54611
54828
|
WorkflowStepSchema,
|
|
54829
|
+
XExtensionDeclSchema,
|
|
54612
54830
|
buildArtifactContext,
|
|
54613
54831
|
buildGlobalContext,
|
|
54614
54832
|
buildGuardrailContext,
|
|
@@ -54624,6 +54842,7 @@ export {
|
|
|
54624
54842
|
builtinRules,
|
|
54625
54843
|
checkDriftFromConfig,
|
|
54626
54844
|
checkReferences,
|
|
54845
|
+
expandDefaults,
|
|
54627
54846
|
generateGuardrails,
|
|
54628
54847
|
lint,
|
|
54629
54848
|
loadBindings,
|
|
@@ -54639,7 +54858,8 @@ export {
|
|
|
54639
54858
|
resolveDslPath,
|
|
54640
54859
|
spectralLint,
|
|
54641
54860
|
validateHandoffSchemas,
|
|
54642
|
-
validateSchema
|
|
54861
|
+
validateSchema,
|
|
54862
|
+
yamlReservedKeySafetyRule
|
|
54643
54863
|
};
|
|
54644
54864
|
/*! Bundled license information:
|
|
54645
54865
|
|