agent-contracts 0.11.6 → 0.11.8
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 +61 -0
- package/dist/cli.js +405 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +331 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -346,6 +346,9 @@ declare const DslSchema: z.ZodObject<{
|
|
|
346
346
|
mechanical: "mechanical";
|
|
347
347
|
semantic: "semantic";
|
|
348
348
|
approval: "approval";
|
|
349
|
+
provenance: "provenance";
|
|
350
|
+
traceability: "traceability";
|
|
351
|
+
fidelity: "fidelity";
|
|
349
352
|
}>;
|
|
350
353
|
executor_type: z.ZodEnum<{
|
|
351
354
|
tool: "tool";
|
|
@@ -731,6 +734,9 @@ declare const ValidationSchema: z.ZodObject<{
|
|
|
731
734
|
mechanical: "mechanical";
|
|
732
735
|
semantic: "semantic";
|
|
733
736
|
approval: "approval";
|
|
737
|
+
provenance: "provenance";
|
|
738
|
+
traceability: "traceability";
|
|
739
|
+
fidelity: "fidelity";
|
|
734
740
|
}>;
|
|
735
741
|
executor_type: z.ZodEnum<{
|
|
736
742
|
tool: "tool";
|
|
@@ -1204,6 +1210,22 @@ declare class ConfigLoadError extends Error {
|
|
|
1204
1210
|
declare function loadConfig(configPath?: string): Promise<ResolvedConfig | null>;
|
|
1205
1211
|
declare function resolveDslPath(dirArg: string | undefined, dirArgDefault: string, config: ResolvedConfig | null): string;
|
|
1206
1212
|
|
|
1213
|
+
interface DimensionResult {
|
|
1214
|
+
id: string;
|
|
1215
|
+
label: string;
|
|
1216
|
+
score: number;
|
|
1217
|
+
total: number;
|
|
1218
|
+
percent: number;
|
|
1219
|
+
weight: number;
|
|
1220
|
+
recommendations: string[];
|
|
1221
|
+
}
|
|
1222
|
+
interface ScoreResult {
|
|
1223
|
+
overall: number;
|
|
1224
|
+
dimensions: DimensionResult[];
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
declare function score(dsl: Dsl): ScoreResult;
|
|
1228
|
+
|
|
1207
1229
|
interface ResolvedCheck {
|
|
1208
1230
|
guardrail_id: string;
|
|
1209
1231
|
guardrail: Guardrail;
|
|
@@ -1259,4 +1281,4 @@ interface PathResolveResult {
|
|
|
1259
1281
|
}
|
|
1260
1282
|
declare function resolveBindingTargetPath(target: string, paths: Record<string, string>, bindingSoftware: string): PathResolveResult;
|
|
1261
1283
|
|
|
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 };
|
|
1284
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -50660,7 +50660,7 @@ var ToolSchema = z9.object({
|
|
|
50660
50660
|
import { z as z10 } from "zod";
|
|
50661
50661
|
var ValidationSchema = z10.object({
|
|
50662
50662
|
target_artifact: z10.string(),
|
|
50663
|
-
kind: z10.enum(["schema", "mechanical", "semantic", "approval"]),
|
|
50663
|
+
kind: z10.enum(["schema", "mechanical", "semantic", "approval", "provenance", "traceability", "fidelity"]),
|
|
50664
50664
|
executor_type: z10.enum(["tool", "agent"]),
|
|
50665
50665
|
executor: z10.string(),
|
|
50666
50666
|
blocking: z10.boolean(),
|
|
@@ -52388,6 +52388,68 @@ var taskOutputValidationCompletenessRule = {
|
|
|
52388
52388
|
}
|
|
52389
52389
|
};
|
|
52390
52390
|
|
|
52391
|
+
// src/linter/rules/semantic-validation-phase-coverage.ts
|
|
52392
|
+
var SEMANTIC_KINDS = /* @__PURE__ */ new Set(["semantic", "fidelity"]);
|
|
52393
|
+
var semanticValidationPhaseCoverageRule = {
|
|
52394
|
+
id: "semantic-validation-phase-coverage",
|
|
52395
|
+
description: "Semantic and fidelity validations should appear in early workflow phases, not only in late phases.",
|
|
52396
|
+
run(dsl) {
|
|
52397
|
+
const diagnostics = [];
|
|
52398
|
+
const semanticValIds = /* @__PURE__ */ new Set();
|
|
52399
|
+
for (const [valId, val] of Object.entries(dsl.validations)) {
|
|
52400
|
+
if (SEMANTIC_KINDS.has(val.kind)) {
|
|
52401
|
+
semanticValIds.add(valId);
|
|
52402
|
+
}
|
|
52403
|
+
}
|
|
52404
|
+
if (semanticValIds.size === 0) {
|
|
52405
|
+
return diagnostics;
|
|
52406
|
+
}
|
|
52407
|
+
const phaseOrder = dsl.system.default_workflow_order;
|
|
52408
|
+
if (phaseOrder.length < 2) {
|
|
52409
|
+
return diagnostics;
|
|
52410
|
+
}
|
|
52411
|
+
const phaseValidations = /* @__PURE__ */ new Map();
|
|
52412
|
+
for (const phase of phaseOrder) {
|
|
52413
|
+
phaseValidations.set(phase, /* @__PURE__ */ new Set());
|
|
52414
|
+
}
|
|
52415
|
+
for (const [phase, wf] of Object.entries(dsl.workflow)) {
|
|
52416
|
+
if (!phaseValidations.has(phase)) continue;
|
|
52417
|
+
for (const step of wf.steps) {
|
|
52418
|
+
if (step.type === "validation" && semanticValIds.has(step.validation)) {
|
|
52419
|
+
phaseValidations.get(phase).add(step.validation);
|
|
52420
|
+
}
|
|
52421
|
+
}
|
|
52422
|
+
}
|
|
52423
|
+
for (const task of Object.values(dsl.tasks)) {
|
|
52424
|
+
const phase = task.workflow;
|
|
52425
|
+
if (!phaseValidations.has(phase)) continue;
|
|
52426
|
+
for (const valId of task.validations) {
|
|
52427
|
+
if (semanticValIds.has(valId)) {
|
|
52428
|
+
phaseValidations.get(phase).add(valId);
|
|
52429
|
+
}
|
|
52430
|
+
}
|
|
52431
|
+
}
|
|
52432
|
+
const earlyBoundary = Math.ceil(phaseOrder.length / 2);
|
|
52433
|
+
const earlyPhases = phaseOrder.slice(0, earlyBoundary);
|
|
52434
|
+
const latePhases = phaseOrder.slice(earlyBoundary);
|
|
52435
|
+
const earlyHasAny = earlyPhases.some(
|
|
52436
|
+
(p2) => (phaseValidations.get(p2)?.size ?? 0) > 0
|
|
52437
|
+
);
|
|
52438
|
+
const lateWithSemantic = latePhases.filter(
|
|
52439
|
+
(p2) => (phaseValidations.get(p2)?.size ?? 0) > 0
|
|
52440
|
+
);
|
|
52441
|
+
if (!earlyHasAny && lateWithSemantic.length > 0) {
|
|
52442
|
+
diagnostics.push({
|
|
52443
|
+
ruleId: "semantic-validation-phase-coverage",
|
|
52444
|
+
severity: "warning",
|
|
52445
|
+
path: "validations",
|
|
52446
|
+
message: `Semantic validations are only referenced in workflow phases [${lateWithSemantic.join(", ")}]. Consider adding semantic review to earlier phases [${earlyPhases.join(", ")}] to catch issues before implementation.`
|
|
52447
|
+
});
|
|
52448
|
+
}
|
|
52449
|
+
return diagnostics;
|
|
52450
|
+
}
|
|
52451
|
+
};
|
|
52452
|
+
|
|
52391
52453
|
// src/linter/linter.ts
|
|
52392
52454
|
var builtinRules = [
|
|
52393
52455
|
validationCoverageRule,
|
|
@@ -52399,7 +52461,8 @@ var builtinRules = [
|
|
|
52399
52461
|
guardrailPolicyCoverageRule,
|
|
52400
52462
|
yamlReservedKeySafetyRule,
|
|
52401
52463
|
artifactRequiredValidationWiringRule,
|
|
52402
|
-
taskOutputValidationCompletenessRule
|
|
52464
|
+
taskOutputValidationCompletenessRule,
|
|
52465
|
+
semanticValidationPhaseCoverageRule
|
|
52403
52466
|
];
|
|
52404
52467
|
function lint(dsl, rules = builtinRules) {
|
|
52405
52468
|
const diagnostics = [];
|
|
@@ -54544,6 +54607,271 @@ ${issues}`,
|
|
|
54544
54607
|
return results;
|
|
54545
54608
|
}
|
|
54546
54609
|
|
|
54610
|
+
// src/scorer/scorer.ts
|
|
54611
|
+
function pct(n3, d2) {
|
|
54612
|
+
return d2 === 0 ? 100 : Math.round(n3 / d2 * 100);
|
|
54613
|
+
}
|
|
54614
|
+
function artifactValidationCoverage(dsl) {
|
|
54615
|
+
const entries = Object.entries(dsl.artifacts);
|
|
54616
|
+
const total = entries.length;
|
|
54617
|
+
const covered = entries.filter(
|
|
54618
|
+
([, a3]) => a3.required_validations.length > 0
|
|
54619
|
+
).length;
|
|
54620
|
+
const missing = entries.filter(([, a3]) => a3.required_validations.length === 0).map(([id]) => id);
|
|
54621
|
+
return {
|
|
54622
|
+
id: "artifact-validation-coverage",
|
|
54623
|
+
label: "Artifact validation coverage",
|
|
54624
|
+
score: covered,
|
|
54625
|
+
total,
|
|
54626
|
+
percent: pct(covered, total),
|
|
54627
|
+
weight: 3,
|
|
54628
|
+
recommendations: missing.length > 0 ? [`${missing.length} artifacts missing required_validations: ${missing.join(", ")}`] : []
|
|
54629
|
+
};
|
|
54630
|
+
}
|
|
54631
|
+
function taskValidationCoverage(dsl) {
|
|
54632
|
+
const entries = Object.entries(dsl.tasks);
|
|
54633
|
+
const total = entries.length;
|
|
54634
|
+
const covered = entries.filter(([, t3]) => t3.validations.length > 0).length;
|
|
54635
|
+
const missing = entries.filter(([, t3]) => t3.validations.length === 0).map(([id]) => id);
|
|
54636
|
+
return {
|
|
54637
|
+
id: "task-validation-coverage",
|
|
54638
|
+
label: "Task validation coverage",
|
|
54639
|
+
score: covered,
|
|
54640
|
+
total,
|
|
54641
|
+
percent: pct(covered, total),
|
|
54642
|
+
weight: 3,
|
|
54643
|
+
recommendations: missing.length > 0 ? [`${missing.length} tasks missing validations: ${missing.join(", ")}`] : []
|
|
54644
|
+
};
|
|
54645
|
+
}
|
|
54646
|
+
function guardrailPolicyCoverage(dsl) {
|
|
54647
|
+
const guardrailIds = Object.keys(dsl.guardrails);
|
|
54648
|
+
const total = guardrailIds.length;
|
|
54649
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
54650
|
+
for (const policy of Object.values(dsl.guardrail_policies)) {
|
|
54651
|
+
for (const rule of policy.rules) {
|
|
54652
|
+
referenced.add(rule.guardrail);
|
|
54653
|
+
}
|
|
54654
|
+
}
|
|
54655
|
+
const covered = guardrailIds.filter((id) => referenced.has(id)).length;
|
|
54656
|
+
const missing = guardrailIds.filter((id) => !referenced.has(id));
|
|
54657
|
+
return {
|
|
54658
|
+
id: "guardrail-policy-coverage",
|
|
54659
|
+
label: "Guardrail policy coverage",
|
|
54660
|
+
score: covered,
|
|
54661
|
+
total,
|
|
54662
|
+
percent: pct(covered, total),
|
|
54663
|
+
weight: 2,
|
|
54664
|
+
recommendations: missing.length > 0 ? [`${missing.length} guardrails not in any policy: ${missing.join(", ")}`] : []
|
|
54665
|
+
};
|
|
54666
|
+
}
|
|
54667
|
+
function workflowValidationIntegration(dsl) {
|
|
54668
|
+
const blockingValidations = Object.entries(dsl.validations).filter(
|
|
54669
|
+
([, v2]) => v2.blocking
|
|
54670
|
+
);
|
|
54671
|
+
const total = blockingValidations.length;
|
|
54672
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
54673
|
+
for (const wf of Object.values(dsl.workflow)) {
|
|
54674
|
+
for (const step of wf.steps) {
|
|
54675
|
+
if (step.type === "validation") {
|
|
54676
|
+
referenced.add(step.validation);
|
|
54677
|
+
}
|
|
54678
|
+
}
|
|
54679
|
+
}
|
|
54680
|
+
for (const task of Object.values(dsl.tasks)) {
|
|
54681
|
+
for (const valId of task.validations) {
|
|
54682
|
+
referenced.add(valId);
|
|
54683
|
+
}
|
|
54684
|
+
}
|
|
54685
|
+
const covered = blockingValidations.filter(
|
|
54686
|
+
([id]) => referenced.has(id)
|
|
54687
|
+
).length;
|
|
54688
|
+
const missing = blockingValidations.filter(([id]) => !referenced.has(id)).map(([id]) => id);
|
|
54689
|
+
return {
|
|
54690
|
+
id: "workflow-validation-integration",
|
|
54691
|
+
label: "Workflow validation integration",
|
|
54692
|
+
score: covered,
|
|
54693
|
+
total,
|
|
54694
|
+
percent: pct(covered, total),
|
|
54695
|
+
weight: 3,
|
|
54696
|
+
recommendations: missing.length > 0 ? [`${missing.length} blocking validations not wired: ${missing.join(", ")}`] : []
|
|
54697
|
+
};
|
|
54698
|
+
}
|
|
54699
|
+
var OPTIONAL_ENTITY_FIELDS = {
|
|
54700
|
+
agents: {
|
|
54701
|
+
section: "agents",
|
|
54702
|
+
fields: ["responsibilities", "constraints", "rules"]
|
|
54703
|
+
},
|
|
54704
|
+
tasks: {
|
|
54705
|
+
section: "tasks",
|
|
54706
|
+
fields: ["description", "responsibilities", "execution_steps", "completion_criteria"]
|
|
54707
|
+
},
|
|
54708
|
+
artifacts: {
|
|
54709
|
+
section: "artifacts",
|
|
54710
|
+
fields: ["description", "visibility"]
|
|
54711
|
+
},
|
|
54712
|
+
tools: {
|
|
54713
|
+
section: "tools",
|
|
54714
|
+
fields: ["description", "commands"]
|
|
54715
|
+
},
|
|
54716
|
+
workflow: {
|
|
54717
|
+
section: "workflow",
|
|
54718
|
+
fields: ["description", "trigger", "entry_conditions"]
|
|
54719
|
+
},
|
|
54720
|
+
guardrails: {
|
|
54721
|
+
section: "guardrails",
|
|
54722
|
+
fields: ["rationale", "tags"]
|
|
54723
|
+
}
|
|
54724
|
+
};
|
|
54725
|
+
function hasNonEmpty(obj, field) {
|
|
54726
|
+
const val = obj[field];
|
|
54727
|
+
if (val === void 0 || val === null) return false;
|
|
54728
|
+
if (typeof val === "string") return val.length > 0;
|
|
54729
|
+
if (Array.isArray(val)) return val.length > 0;
|
|
54730
|
+
return true;
|
|
54731
|
+
}
|
|
54732
|
+
function schemaCompleteness(dsl) {
|
|
54733
|
+
let totalSlots = 0;
|
|
54734
|
+
let filledSlots = 0;
|
|
54735
|
+
const lowSections = [];
|
|
54736
|
+
for (const [sectionKey, meta] of Object.entries(OPTIONAL_ENTITY_FIELDS)) {
|
|
54737
|
+
const entities = dsl[meta.section];
|
|
54738
|
+
if (!entities) continue;
|
|
54739
|
+
let sectionTotal = 0;
|
|
54740
|
+
let sectionFilled = 0;
|
|
54741
|
+
for (const entity of Object.values(entities)) {
|
|
54742
|
+
for (const field of meta.fields) {
|
|
54743
|
+
sectionTotal++;
|
|
54744
|
+
totalSlots++;
|
|
54745
|
+
if (hasNonEmpty(entity, field)) {
|
|
54746
|
+
sectionFilled++;
|
|
54747
|
+
filledSlots++;
|
|
54748
|
+
}
|
|
54749
|
+
}
|
|
54750
|
+
}
|
|
54751
|
+
if (sectionTotal > 0 && pct(sectionFilled, sectionTotal) < 50) {
|
|
54752
|
+
lowSections.push(sectionKey);
|
|
54753
|
+
}
|
|
54754
|
+
}
|
|
54755
|
+
return {
|
|
54756
|
+
id: "schema-completeness",
|
|
54757
|
+
label: "Schema completeness",
|
|
54758
|
+
score: filledSlots,
|
|
54759
|
+
total: totalSlots,
|
|
54760
|
+
percent: pct(filledSlots, totalSlots),
|
|
54761
|
+
weight: 1,
|
|
54762
|
+
recommendations: lowSections.length > 0 ? [`Low optional field coverage in: ${lowSections.join(", ")}`] : []
|
|
54763
|
+
};
|
|
54764
|
+
}
|
|
54765
|
+
function crossReferenceBidirectionality(dsl) {
|
|
54766
|
+
let totalChecks = 0;
|
|
54767
|
+
let passedChecks = 0;
|
|
54768
|
+
const issues = [];
|
|
54769
|
+
for (const [agentId, agent] of Object.entries(dsl.agents)) {
|
|
54770
|
+
for (const toolId of agent.can_execute_tools) {
|
|
54771
|
+
totalChecks++;
|
|
54772
|
+
const tool = dsl.tools[toolId];
|
|
54773
|
+
if (tool && tool.invokable_by.includes(agentId)) {
|
|
54774
|
+
passedChecks++;
|
|
54775
|
+
} else {
|
|
54776
|
+
issues.push(`agent ${agentId} \u2192 tool ${toolId}`);
|
|
54777
|
+
}
|
|
54778
|
+
}
|
|
54779
|
+
for (const artId of agent.can_write_artifacts) {
|
|
54780
|
+
totalChecks++;
|
|
54781
|
+
const art = dsl.artifacts[artId];
|
|
54782
|
+
if (art && (art.producers.includes(agentId) || art.editors.includes(agentId))) {
|
|
54783
|
+
passedChecks++;
|
|
54784
|
+
} else {
|
|
54785
|
+
issues.push(`agent ${agentId} \u2192 artifact ${artId} (write)`);
|
|
54786
|
+
}
|
|
54787
|
+
}
|
|
54788
|
+
for (const artId of agent.can_read_artifacts) {
|
|
54789
|
+
totalChecks++;
|
|
54790
|
+
const art = dsl.artifacts[artId];
|
|
54791
|
+
if (art && (art.consumers.includes(agentId) || art.producers.includes(agentId) || art.editors.includes(agentId))) {
|
|
54792
|
+
passedChecks++;
|
|
54793
|
+
} else {
|
|
54794
|
+
issues.push(`agent ${agentId} \u2192 artifact ${artId} (read)`);
|
|
54795
|
+
}
|
|
54796
|
+
}
|
|
54797
|
+
}
|
|
54798
|
+
for (const [toolId, tool] of Object.entries(dsl.tools)) {
|
|
54799
|
+
for (const agentId of tool.invokable_by) {
|
|
54800
|
+
totalChecks++;
|
|
54801
|
+
const agent = dsl.agents[agentId];
|
|
54802
|
+
if (agent && agent.can_execute_tools.includes(toolId)) {
|
|
54803
|
+
passedChecks++;
|
|
54804
|
+
} else {
|
|
54805
|
+
issues.push(`tool ${toolId} \u2192 agent ${agentId}`);
|
|
54806
|
+
}
|
|
54807
|
+
}
|
|
54808
|
+
}
|
|
54809
|
+
return {
|
|
54810
|
+
id: "cross-reference-bidirectionality",
|
|
54811
|
+
label: "Cross-reference bidirectionality",
|
|
54812
|
+
score: passedChecks,
|
|
54813
|
+
total: totalChecks,
|
|
54814
|
+
percent: pct(passedChecks, totalChecks),
|
|
54815
|
+
weight: 2,
|
|
54816
|
+
recommendations: issues.length > 0 ? [`${issues.length} unreciprocated cross-references: ${issues.slice(0, 5).join(", ")}${issues.length > 5 ? `, ... (${issues.length - 5} more)` : ""}`] : []
|
|
54817
|
+
};
|
|
54818
|
+
}
|
|
54819
|
+
function guardrailScopeResolution(dsl) {
|
|
54820
|
+
let totalRefs = 0;
|
|
54821
|
+
let resolvedRefs = 0;
|
|
54822
|
+
const unresolved = [];
|
|
54823
|
+
const sectionMap = {
|
|
54824
|
+
agents: dsl.agents,
|
|
54825
|
+
tasks: dsl.tasks,
|
|
54826
|
+
tools: dsl.tools,
|
|
54827
|
+
artifacts: dsl.artifacts,
|
|
54828
|
+
workflows: dsl.workflow
|
|
54829
|
+
};
|
|
54830
|
+
for (const [guardrailId, guardrail] of Object.entries(dsl.guardrails)) {
|
|
54831
|
+
const scope = guardrail.scope;
|
|
54832
|
+
for (const [scopeKey, entityIds] of Object.entries(scope)) {
|
|
54833
|
+
if (!Array.isArray(entityIds)) continue;
|
|
54834
|
+
const section = sectionMap[scopeKey];
|
|
54835
|
+
if (!section) continue;
|
|
54836
|
+
for (const entityId of entityIds) {
|
|
54837
|
+
totalRefs++;
|
|
54838
|
+
if (section[entityId]) {
|
|
54839
|
+
resolvedRefs++;
|
|
54840
|
+
} else {
|
|
54841
|
+
unresolved.push(`${guardrailId}.scope.${scopeKey}: ${entityId}`);
|
|
54842
|
+
}
|
|
54843
|
+
}
|
|
54844
|
+
}
|
|
54845
|
+
}
|
|
54846
|
+
return {
|
|
54847
|
+
id: "guardrail-scope-resolution",
|
|
54848
|
+
label: "Guardrail scope resolution",
|
|
54849
|
+
score: resolvedRefs,
|
|
54850
|
+
total: totalRefs,
|
|
54851
|
+
percent: pct(resolvedRefs, totalRefs),
|
|
54852
|
+
weight: 2,
|
|
54853
|
+
recommendations: unresolved.length > 0 ? [`${unresolved.length} unresolved scope refs: ${unresolved.join(", ")}`] : []
|
|
54854
|
+
};
|
|
54855
|
+
}
|
|
54856
|
+
function score(dsl) {
|
|
54857
|
+
const dimensions = [
|
|
54858
|
+
artifactValidationCoverage(dsl),
|
|
54859
|
+
taskValidationCoverage(dsl),
|
|
54860
|
+
guardrailPolicyCoverage(dsl),
|
|
54861
|
+
workflowValidationIntegration(dsl),
|
|
54862
|
+
schemaCompleteness(dsl),
|
|
54863
|
+
crossReferenceBidirectionality(dsl),
|
|
54864
|
+
guardrailScopeResolution(dsl)
|
|
54865
|
+
];
|
|
54866
|
+
const totalWeight = dimensions.reduce((s2, d2) => s2 + d2.weight, 0);
|
|
54867
|
+
const weightedSum = dimensions.reduce(
|
|
54868
|
+
(s2, d2) => s2 + d2.percent * d2.weight,
|
|
54869
|
+
0
|
|
54870
|
+
);
|
|
54871
|
+
const overall = totalWeight === 0 ? 100 : Math.round(weightedSum / totalWeight);
|
|
54872
|
+
return { overall, dimensions };
|
|
54873
|
+
}
|
|
54874
|
+
|
|
54547
54875
|
// src/guardrail-generator/generator.ts
|
|
54548
54876
|
import { readFile as readFile5, writeFile as writeFile2, mkdir as mkdir2, chmod, unlink as unlink2 } from "fs/promises";
|
|
54549
54877
|
import { resolve as resolve6, dirname as dirname6 } from "path";
|
|
@@ -54856,6 +55184,7 @@ export {
|
|
|
54856
55184
|
resolveBindingTargetPath,
|
|
54857
55185
|
resolveChecks,
|
|
54858
55186
|
resolveDslPath,
|
|
55187
|
+
score,
|
|
54859
55188
|
spectralLint,
|
|
54860
55189
|
validateHandoffSchemas,
|
|
54861
55190
|
validateSchema,
|