agent-contracts 0.12.3 → 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/README.md +22 -9
- package/dist/cli.js +82 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +83 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -999,10 +999,10 @@ Each `context` type provides a different rendering scope:
|
|
|
999
999
|
| Context | Scope | Output | Key variables |
|
|
1000
1000
|
|---------|-------|--------|---------------|
|
|
1001
1001
|
| `system` | Single file | `output` as-is | `system`, `dsl`, `guardrailEnforcement`\*, `bindings`\* |
|
|
1002
|
-
| `agent` | Per agent | `{agent.id}` in output path | `agent`, `receivableTasks`, `delegatableTasks`, `relatedArtifacts`, `relatedTools`, `relatedHandoffTypes`, `mergedBehavior`, `dsl` |
|
|
1003
|
-
| `task` | Per task | `{task.id}` in output path | `task`, `targetAgent`, `dsl` |
|
|
1004
|
-
| `artifact` | Per artifact | `{artifact.id}` in output path | `artifact`, `relatedTools`, `relatedValidations`, `producerAgents`, `consumerAgents`, `editorAgents`, `createdInWorkflows`, `dsl` |
|
|
1005
|
-
| `tool` | Per tool | `{tool.id}` in output path | `tool`, `invokableAgents`, `inputArtifactDetails`, `outputArtifactDetails`, `dsl` |
|
|
1002
|
+
| `agent` | Per agent | `{agent.id}` in output path | `agent`, `receivableTasks`, `delegatableTasks`, `relatedArtifacts`, `relatedTools`, `relatedHandoffTypes`, `mergedBehavior`, `relatedGuardrails`, `relatedValidations`, `dsl` |
|
|
1003
|
+
| `task` | Per task | `{task.id}` in output path | `task`, `targetAgent`, `relatedGuardrails`, `relatedValidations`, `dsl` |
|
|
1004
|
+
| `artifact` | Per artifact | `{artifact.id}` in output path | `artifact`, `relatedTools`, `relatedValidations`, `relatedGuardrails`, `producerAgents`, `consumerAgents`, `editorAgents`, `createdInWorkflows`, `dsl` |
|
|
1005
|
+
| `tool` | Per tool | `{tool.id}` in output path | `tool`, `invokableAgents`, `inputArtifactDetails`, `outputArtifactDetails`, `relatedGuardrails`, `relatedValidations`, `dsl` |
|
|
1006
1006
|
| `validation` | Per validation | `{validation.id}` in output path | `validation`, `dsl` |
|
|
1007
1007
|
| `handoff_type` | Per handoff type | `{handoff_type.id}` in output path | `handoff_type`, `relatedTasks`, `dsl` |
|
|
1008
1008
|
| `workflow` | Per workflow phase | `{workflow.id}` in output path | `workflow`, `relatedAgents`, `relatedTasks`, `relatedTools`, `relatedArtifacts`, `relatedValidations`, `dsl` |
|
|
@@ -1027,6 +1027,23 @@ Each `context` type provides a different rendering scope:
|
|
|
1027
1027
|
* `producerAgents` / `consumerAgents` / `editorAgents` — resolved agent records
|
|
1028
1028
|
* `createdInWorkflows` — workflow phases where this artifact is written
|
|
1029
1029
|
|
|
1030
|
+
**`agent` context** provides merged behavioral specs and cross-references:
|
|
1031
|
+
|
|
1032
|
+
* `relatedGuardrails` — guardrails bound via `agent.guardrails[]` or guardrail `scope.agents[]`, merged and deduplicated
|
|
1033
|
+
* `relatedValidations` — validations from `agent.can_perform_validations`, resolved into full entries (kind, target_artifact, executor_type, blocking)
|
|
1034
|
+
|
|
1035
|
+
**`task` context** provides execution details:
|
|
1036
|
+
|
|
1037
|
+
* `relatedGuardrails` — guardrails bound via `task.guardrails[]` or guardrail `scope.tasks[]`
|
|
1038
|
+
* `relatedValidations` — validations from `task.validations[]`, resolved into full entries
|
|
1039
|
+
|
|
1040
|
+
**`tool` context** provides invocation and artifact details:
|
|
1041
|
+
|
|
1042
|
+
* `relatedGuardrails` — guardrails bound via `tool.guardrails[]` or guardrail `scope.tools[]`
|
|
1043
|
+
* `relatedValidations` — validations where `executor_type` is `"tool"` and `executor` matches this tool ID
|
|
1044
|
+
* `invokableAgents` — agents listed in `invokable_by`
|
|
1045
|
+
* `inputArtifactDetails` / `outputArtifactDetails` — resolved artifact records
|
|
1046
|
+
|
|
1030
1047
|
**`system` context** includes binding-aware guardrail enforcement data when `bindings` and `active_guardrail_policy` are configured:
|
|
1031
1048
|
|
|
1032
1049
|
* `guardrailEnforcement` — array of enforcement entries, each with `guardrail_id`, `description`, `severity`, `action`, scoped entities (`scoped_agents`, `scoped_tasks`, `scoped_workflows`, `scoped_tools`, `scoped_artifacts`), `allow_override`, `override_requires`, `trigger` (from binding matcher type), and `escalation`
|
|
@@ -1039,11 +1056,6 @@ These fields are only populated when the config specifies `bindings` and `active
|
|
|
1039
1056
|
* `guardrailCoverageMatrix` — generates a Guardrail Coverage Matrix table (guardrail × severity × action × scoped entities × trigger × override × escalation)
|
|
1040
1057
|
* `taskGuardrailMatrix` — generates a Task × Guardrail cross-reference table showing which action applies to each task
|
|
1041
1058
|
|
|
1042
|
-
**`tool` context** resolves agent and artifact references:
|
|
1043
|
-
|
|
1044
|
-
* `invokableAgents` — agents listed in `invokable_by`
|
|
1045
|
-
* `inputArtifactDetails` / `outputArtifactDetails` — resolved artifact records
|
|
1046
|
-
|
|
1047
1059
|
### Handlebars helpers
|
|
1048
1060
|
|
|
1049
1061
|
Templates can use these built-in helpers:
|
|
@@ -1306,6 +1318,7 @@ Checks:
|
|
|
1306
1318
|
* artifact ownership — `produces_artifact`/`reads_artifact` in execution steps vs. artifact producers/editors/consumers
|
|
1307
1319
|
* tool commands — `commands[].reads`/`commands[].writes` reference valid artifacts and align with `output_artifacts`
|
|
1308
1320
|
* semantic validation phase coverage — warns when `semantic` or `fidelity` validations only appear in late workflow phases (e.g., audit) but not earlier phases (e.g., specify, plan)
|
|
1321
|
+
* validation executor context wiring — warns when a validation's executor (agent or tool) exists in the DSL but the validation is not surfaced in the executor's prompt context
|
|
1309
1322
|
* YAML safety — warns when YAML 1.1 reserved words (`on`, `yes`, `no`, `true`, `false`, etc.) are used in positions where they may be misinterpreted by non-1.2 parsers
|
|
1310
1323
|
* naming/style issues through Spectral rules
|
|
1311
1324
|
|
package/dist/cli.js
CHANGED
|
@@ -53009,6 +53009,40 @@ var guardrailOrphanedRule = {
|
|
|
53009
53009
|
}
|
|
53010
53010
|
};
|
|
53011
53011
|
|
|
53012
|
+
// src/linter/rules/validation-executor-no-context.ts
|
|
53013
|
+
var validationExecutorNoContextRule = {
|
|
53014
|
+
id: "validation-executor-no-context",
|
|
53015
|
+
description: "Validation executor is not wired so the validation appears in the executor's rendered context",
|
|
53016
|
+
run(dsl) {
|
|
53017
|
+
const diagnostics = [];
|
|
53018
|
+
for (const [validationId, val] of Object.entries(dsl.validations)) {
|
|
53019
|
+
if (val.executor_type === "agent") {
|
|
53020
|
+
const agent = dsl.agents[val.executor];
|
|
53021
|
+
if (!agent) continue;
|
|
53022
|
+
const allowed = new Set(agent.can_perform_validations ?? []);
|
|
53023
|
+
if (!allowed.has(validationId)) {
|
|
53024
|
+
diagnostics.push({
|
|
53025
|
+
ruleId: "validation-executor-no-context",
|
|
53026
|
+
severity: "warning",
|
|
53027
|
+
path: `agents.${val.executor}.can_perform_validations`,
|
|
53028
|
+
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`
|
|
53029
|
+
});
|
|
53030
|
+
}
|
|
53031
|
+
} else if (val.executor_type === "tool") {
|
|
53032
|
+
if (!dsl.tools[val.executor]) {
|
|
53033
|
+
diagnostics.push({
|
|
53034
|
+
ruleId: "validation-executor-no-context",
|
|
53035
|
+
severity: "warning",
|
|
53036
|
+
path: `validations.${validationId}.executor`,
|
|
53037
|
+
message: `Validation "${validationId}" references tool executor "${val.executor}" which is not defined in tools`
|
|
53038
|
+
});
|
|
53039
|
+
}
|
|
53040
|
+
}
|
|
53041
|
+
}
|
|
53042
|
+
return diagnostics;
|
|
53043
|
+
}
|
|
53044
|
+
};
|
|
53045
|
+
|
|
53012
53046
|
// src/linter/linter.ts
|
|
53013
53047
|
var builtinRules = [
|
|
53014
53048
|
validationCoverageRule,
|
|
@@ -53024,7 +53058,8 @@ var builtinRules = [
|
|
|
53024
53058
|
semanticValidationPhaseCoverageRule,
|
|
53025
53059
|
entityGuardrailUndefinedRule,
|
|
53026
53060
|
entityNoGuardrailsRule,
|
|
53027
|
-
guardrailOrphanedRule
|
|
53061
|
+
guardrailOrphanedRule,
|
|
53062
|
+
validationExecutorNoContextRule
|
|
53028
53063
|
];
|
|
53029
53064
|
function lint(dsl, rules = builtinRules) {
|
|
53030
53065
|
const diagnostics = [];
|
|
@@ -53813,13 +53848,54 @@ function resolveEffectiveGuardrails(dsl, entityType, entityId) {
|
|
|
53813
53848
|
}
|
|
53814
53849
|
return entries;
|
|
53815
53850
|
}
|
|
53851
|
+
function validationToEntityEntry(validationId, validation) {
|
|
53852
|
+
return {
|
|
53853
|
+
validation_id: validationId,
|
|
53854
|
+
kind: validation.kind,
|
|
53855
|
+
target_artifact: validation.target_artifact,
|
|
53856
|
+
executor_type: validation.executor_type,
|
|
53857
|
+
blocking: validation.blocking,
|
|
53858
|
+
produces_evidence: validation.produces_evidence
|
|
53859
|
+
};
|
|
53860
|
+
}
|
|
53861
|
+
function resolveEntityValidations(dsl, entityType, entityId) {
|
|
53862
|
+
if (entityType === "agents") {
|
|
53863
|
+
const agent = dsl.agents[entityId];
|
|
53864
|
+
if (!agent) return [];
|
|
53865
|
+
const entries2 = [];
|
|
53866
|
+
for (const vid of agent.can_perform_validations ?? []) {
|
|
53867
|
+
const v2 = dsl.validations[vid];
|
|
53868
|
+
if (v2) entries2.push(validationToEntityEntry(vid, v2));
|
|
53869
|
+
}
|
|
53870
|
+
return entries2;
|
|
53871
|
+
}
|
|
53872
|
+
if (entityType === "tasks") {
|
|
53873
|
+
const task = dsl.tasks[entityId];
|
|
53874
|
+
if (!task) return [];
|
|
53875
|
+
const entries2 = [];
|
|
53876
|
+
for (const vid of task.validations ?? []) {
|
|
53877
|
+
const v2 = dsl.validations[vid];
|
|
53878
|
+
if (v2) entries2.push(validationToEntityEntry(vid, v2));
|
|
53879
|
+
}
|
|
53880
|
+
return entries2;
|
|
53881
|
+
}
|
|
53882
|
+
const entries = [];
|
|
53883
|
+
for (const [vid, v2] of Object.entries(dsl.validations)) {
|
|
53884
|
+
if (v2.executor_type === "tool" && v2.executor === entityId) {
|
|
53885
|
+
entries.push(validationToEntityEntry(vid, v2));
|
|
53886
|
+
}
|
|
53887
|
+
}
|
|
53888
|
+
entries.sort((a3, b3) => a3.validation_id.localeCompare(b3.validation_id));
|
|
53889
|
+
return entries;
|
|
53890
|
+
}
|
|
53816
53891
|
function buildTaskContext(dsl, taskId) {
|
|
53817
53892
|
const taskDef = dsl.tasks[taskId];
|
|
53818
53893
|
const task = { ...taskDef, id: taskId };
|
|
53819
53894
|
const agentDef = dsl.agents[taskDef.target_agent];
|
|
53820
53895
|
const targetAgent = agentDef ? { ...agentDef, id: taskDef.target_agent } : null;
|
|
53821
53896
|
const relatedGuardrails = resolveEffectiveGuardrails(dsl, "tasks", taskId);
|
|
53822
|
-
|
|
53897
|
+
const relatedValidations = resolveEntityValidations(dsl, "tasks", taskId);
|
|
53898
|
+
return { task, targetAgent, relatedGuardrails, relatedValidations, dsl };
|
|
53823
53899
|
}
|
|
53824
53900
|
function buildArtifactContext(dsl, artifactId) {
|
|
53825
53901
|
const artifactDef = dsl.artifacts[artifactId];
|
|
@@ -53890,12 +53966,14 @@ function buildToolContext(dsl, toolId) {
|
|
|
53890
53966
|
return result;
|
|
53891
53967
|
};
|
|
53892
53968
|
const relatedGuardrails = resolveEffectiveGuardrails(dsl, "tools", toolId);
|
|
53969
|
+
const relatedValidations = resolveEntityValidations(dsl, "tools", toolId);
|
|
53893
53970
|
return {
|
|
53894
53971
|
tool,
|
|
53895
53972
|
invokableAgents,
|
|
53896
53973
|
inputArtifactDetails: pickArtifacts(toolDef.input_artifacts),
|
|
53897
53974
|
outputArtifactDetails: pickArtifacts(toolDef.output_artifacts),
|
|
53898
53975
|
relatedGuardrails,
|
|
53976
|
+
relatedValidations,
|
|
53899
53977
|
dsl
|
|
53900
53978
|
};
|
|
53901
53979
|
}
|
|
@@ -54128,6 +54206,7 @@ function buildPerAgentContext(dsl, agent) {
|
|
|
54128
54206
|
const rawReceivableTasks = receivableTasks.map(({ id: _id, ...rest }) => rest);
|
|
54129
54207
|
const mergedBehavior = mergeBehavioralSpec(agent, rawReceivableTasks);
|
|
54130
54208
|
const relatedGuardrails = resolveEffectiveGuardrails(dsl, "agents", agentId);
|
|
54209
|
+
const relatedValidations = resolveEntityValidations(dsl, "agents", agentId);
|
|
54131
54210
|
return {
|
|
54132
54211
|
agent,
|
|
54133
54212
|
tasks: receivableTasks,
|
|
@@ -54138,6 +54217,7 @@ function buildPerAgentContext(dsl, agent) {
|
|
|
54138
54217
|
relatedHandoffTypes,
|
|
54139
54218
|
mergedBehavior,
|
|
54140
54219
|
relatedGuardrails,
|
|
54220
|
+
relatedValidations,
|
|
54141
54221
|
dsl
|
|
54142
54222
|
};
|
|
54143
54223
|
}
|