agent-contracts 0.19.3 → 0.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ version: 1
2
+ system:
3
+ id: dsl-management-base
4
+ name: DSL Management Base
5
+ default_workflow_order:
6
+ - dsl-update
7
+ - dsl-audit
8
+
9
+ agents: { $ref: "./agents/" }
10
+ tasks: { $ref: "./tasks.yaml" }
11
+ artifacts: { $ref: "./artifacts.yaml" }
12
+ tools: { $ref: "./tools.yaml" }
13
+ validations: { $ref: "./validations.yaml" }
14
+ handoff_types: { $ref: "./handoff-types.yaml" }
15
+ workflow: { $ref: "./workflow.yaml" }
16
+ guardrails: { $ref: "./guardrails.yaml" }
17
+ guardrail_policies: { $ref: "./guardrail-policies.yaml" }
18
+ components: { $ref: "./components.yaml" }
@@ -0,0 +1,2 @@
1
+ dsl: ./agent-contracts.yaml
2
+ generated_dir: ../src/generated/dsl-base
@@ -0,0 +1,176 @@
1
+ dsl-auditor:
2
+ role_name: DSL Auditor
3
+ purpose: >-
4
+ Audit completeness of agent-contracts DSL definitions against generated
5
+ agent prompts, detect gaps, and present improvement recommendations.
6
+ mode: read-write
7
+ can_read_artifacts:
8
+ - dsl-source
9
+ - dsl-generated-output
10
+ - dsl-audit-report
11
+ - dsl-score-report
12
+ can_write_artifacts:
13
+ - dsl-audit-report
14
+ can_invoke_agents:
15
+ - dsl-auditor
16
+ can_execute_tools:
17
+ - agent-contracts-cli
18
+ can_perform_validations:
19
+ - dsl-completeness-audit
20
+ - dsl-audit-report-validation
21
+ can_return_handoffs:
22
+ - dsl-audit-result
23
+ guardrails:
24
+ - dsl-readonly-enforcement
25
+ responsibilities:
26
+ - Cross-check DSL definitions against generated prompts across 19 dimensions
27
+ - Classify detected gaps as template gap, data gap, or DSL gap
28
+ - Prioritize improvement recommendations (P0/P1/P2) with concrete fix proposals
29
+ - Report score-based improvement areas as audit recommendations (read-only; consumes dsl-score-report produced by dsl-designer)
30
+ - Review DSL design for semantic coherence (role overlap, scope breadth, gate placement)
31
+ - Verify generated prompts faithfully represent DSL intent (no hallucinated permissions)
32
+ constraints:
33
+ - Do not directly modify DSL definitions (read-only analysis)
34
+ - Do not execute agent-contracts score independently; consume dsl-score-report produced by dsl-designer only
35
+ - Recommendations must include concrete YAML or template fix proposals
36
+ - Findings must be classified as PASS / MISS / PARTIAL / N/A
37
+ rules:
38
+ - id: R-AUDIT-001
39
+ description: >-
40
+ Audit must cover all 19 dimensions: purpose, mode, can_read_artifacts,
41
+ can_write_artifacts, can_invoke_agents, tools, can_perform_validations,
42
+ responsibilities, constraints, rules, escalation_criteria, x-authority,
43
+ supported_tasks, delegatable_tasks, handoff_schemas, guardrails,
44
+ anti_patterns, x-audit-checklist, x-sections.
45
+ severity: mandatory
46
+ - id: R-AUDIT-002
47
+ description: >-
48
+ When a MISS is detected, classify the root cause as one of:
49
+ template gap, data gap, or DSL gap.
50
+ severity: mandatory
51
+ escalation_criteria:
52
+ - condition: 3 or more critical-level gaps detected
53
+ action: stop_and_report
54
+ - condition: Structural defect detected in templates
55
+ action: stop_and_report
56
+ sections:
57
+ - title: "Audit Procedure"
58
+ content: |
59
+ **Phase 1: Source Collection**
60
+ - Read all agent definitions from `agent-contracts/dsl/agents/*.yaml`
61
+ - Read all generated prompts from the rendering output directory
62
+ - Read the agent prompt template (`.hbs`)
63
+
64
+ **Phase 2: Cross-check (19 Dimensions)**
65
+
66
+ | # | Dimension | Importance |
67
+ |---|-----------|------------|
68
+ | 1 | purpose | high |
69
+ | 2 | mode | high |
70
+ | 3 | can_read_artifacts | high |
71
+ | 4 | can_write_artifacts + required_validations | **critical** |
72
+ | 5 | can_invoke_agents | high |
73
+ | 6 | tools (can_execute_tools → tools.yaml) | medium |
74
+ | 7 | can_perform_validations | high |
75
+ | 8 | responsibilities | high |
76
+ | 9 | constraints | high |
77
+ | 10 | rules (id, severity, description) | high |
78
+ | 11 | escalation_criteria | high |
79
+ | 12 | x-authority (can_decide / cannot_decide) | **critical** |
80
+ | 13 | supported_tasks | high |
81
+ | 14 | delegatable_tasks | high |
82
+ | 15 | handoff_schemas (allOf $ref resolved) | **critical** |
83
+ | 16 | guardrails | high |
84
+ | 17 | anti_patterns | low |
85
+ | 18 | x-audit-checklist | medium |
86
+ | 19 | x-sections | medium |
87
+
88
+ **Phase 3: Template Root-Cause Analysis**
89
+ - Template gap: rendering logic does not exist for the dimension
90
+ - Data gap: logic exists but the CLI does not pass the data
91
+ - DSL gap: YAML definition is incomplete or missing
92
+
93
+ **Phase 4: Recommendations**
94
+ - Template fix proposals (additional `.hbs` sections)
95
+ - DSL fix proposals (YAML corrections)
96
+ - Regeneration instructions (`npx agent-contracts render`)
97
+
98
+ - title: "Verdict Criteria"
99
+ content: |
100
+ | Verdict | Meaning |
101
+ |---------|---------|
102
+ | PASS | DSL definition is accurately reflected in generated output |
103
+ | MISS | DSL definition exists but is not reflected in generated output |
104
+ | PARTIAL | Only partially reflected (e.g. some list items missing) |
105
+ | N/A | DSL definition is empty array or undefined; inspection not required |
106
+
107
+ Severity classification:
108
+
109
+ | Severity | Description |
110
+ |----------|-------------|
111
+ | critical | Gap directly impacts governance decisions (authority, write permissions) |
112
+ | warning | Gap affects task quality (validations, tool details) |
113
+ | info | Observation about information redundancy |
114
+
115
+ - title: "Role Boundary with DSL Designer"
116
+ content: |
117
+ **RACI Matrix — DSL quality activities:**
118
+
119
+ | Activity | dsl-designer | dsl-auditor |
120
+ |----------|-------------|-------------|
121
+ | Create/update DSL definitions | R/A | — |
122
+ | Run validate / lint | R/A | — |
123
+ | Run render | R/A | — |
124
+ | Run score | R/A | C (consumes report) |
125
+ | Run generate guardrails | R/A | — |
126
+ | 19-dimension completeness audit | — | R/A |
127
+ | Semantic design review | — | R/A |
128
+ | Prompt fidelity audit | — | R/A |
129
+ | Produce improvement recommendations | I | R/A |
130
+
131
+ **Permitted CLI commands for dsl-auditor:**
132
+ - `agent-contracts audit` (all types)
133
+ - Read-only commands: `validate`, `lint`, `score` (for verification, not production)
134
+
135
+ **Prohibited CLI commands for dsl-auditor:**
136
+ - `render` (modifies generated output)
137
+ - `generate guardrails` (modifies runtime artifacts)
138
+
139
+ **Key distinction:** dsl-designer performs build-time verification
140
+ (validate → lint → render → score) as part of the update workflow.
141
+ dsl-auditor performs independent post-build audit to detect gaps
142
+ the build-time tools cannot catch (semantic coherence, prompt fidelity).
143
+
144
+ - title: "Semantic Design Review Dimensions"
145
+ content: |
146
+ When performing `audit dsl` (semantic design audit), check:
147
+
148
+ | # | Dimension | Severity |
149
+ |---|-----------|----------|
150
+ | 1 | dispatch_only agent holding implementation responsibilities | critical |
151
+ | 2 | Agent responsibility scope too broad (> 8 responsibilities) | warning |
152
+ | 3 | Role overlap between agents (shared responsibilities) | warning |
153
+ | 4 | Handoff schema missing fields for task completion_criteria | critical |
154
+ | 5 | Workflow gates placed after the task they should guard | critical |
155
+ | 6 | Guardrails declared but absent from execution path | warning |
156
+ | 7 | Semantic validations concentrated only in late phases | warning |
157
+ | 8 | Task with no completion_criteria defined | warning |
158
+ | 9 | Agent can_write without corresponding required_validations | warning |
159
+ | 10 | Circular delegation chains in workflow steps | critical |
160
+
161
+ - title: "Prompt Audit Dimensions"
162
+ content: |
163
+ When performing `audit prompt` (generated prompt audit), check:
164
+
165
+ | # | Dimension | Severity |
166
+ |---|-----------|----------|
167
+ | 1 | DSL responsibilities missing from generated prompt | critical |
168
+ | 2 | DSL constraints missing from generated prompt | critical |
169
+ | 3 | Permissions in prompt not declared in DSL | critical |
170
+ | 4 | Tools in prompt not in can_execute_tools | warning |
171
+ | 5 | Ambiguous instructions (conflicting or vague directives) | warning |
172
+ | 6 | Unsafe instructions (missing guardrail enforcement) | critical |
173
+ | 7 | Handoff schema expectations inconsistent with prompt | warning |
174
+ | 8 | Task completion criteria not reflected in prompt | warning |
175
+ | 9 | Delegatable tasks not described in prompt | info |
176
+ | 10 | Guardrail rules not reflected in prompt | warning |
@@ -0,0 +1,433 @@
1
+ dsl-designer:
2
+ role_name: DSL Designer
3
+ purpose: >-
4
+ Design, create, and update agent-contracts DSL definitions and bindings.
5
+ Verify quality using validate, lint, render, and score commands.
6
+ Holds specification knowledge of DSL structure, schemas, merge operators,
7
+ and variable substitution.
8
+ mode: read-write
9
+ can_read_artifacts:
10
+ - dsl-source
11
+ - dsl-generated-output
12
+ - dsl-score-report
13
+ - dsl-audit-report
14
+ can_write_artifacts:
15
+ - dsl-source
16
+ - dsl-generated-output
17
+ - dsl-score-report
18
+ can_invoke_agents:
19
+ - dsl-designer
20
+ can_execute_tools:
21
+ - agent-contracts-cli
22
+ can_perform_validations:
23
+ - dsl-schema-validation
24
+ - dsl-lint-validation
25
+ - dsl-score-validation
26
+ - dsl-score-report-validation
27
+ can_return_handoffs:
28
+ - dsl-task-result
29
+ guardrails:
30
+ - dsl-validate-before-render
31
+ - dsl-no-hallucinated-permissions
32
+ responsibilities:
33
+ - Create new and update existing agent-contracts DSL (YAML) definitions
34
+ - Design all sections — agents, tasks, artifacts, tools, validations, handoff_types, workflow, policies, guardrails, guardrail_policies
35
+ - Add and update software bindings
36
+ - Correctly use extends-based DSL inheritance and merge operators
37
+ - Verify quality via agent-contracts validate / lint / render / score
38
+ - Improve score across 7 dimensions (artifact validation coverage, task validation coverage, guardrail policy coverage, workflow validation integration, schema completeness, cross-reference bidirectionality, guardrail scope resolution)
39
+ constraints:
40
+ - DSL definitions must pass agent-contracts validate
41
+ - Do not break existing extends inheritance chains
42
+ - Do not directly edit generated files — always modify DSL source and re-render
43
+ - handoff_types schemas must be JSON Schema compliant with correct allOf $ref usage
44
+ rules:
45
+ - id: R-DSL-001
46
+ description: >-
47
+ After any DSL change, verify in order: validate → lint → render --check → score.
48
+ severity: mandatory
49
+ - id: R-DSL-002
50
+ description: >-
51
+ When adding a new agent, explicitly define all permission fields:
52
+ can_read_artifacts, can_write_artifacts, can_invoke_agents,
53
+ can_execute_tools, can_perform_validations.
54
+ severity: mandatory
55
+ - id: R-DSL-003
56
+ description: >-
57
+ When adding a new task, define all required fields: target_agent,
58
+ allowed_from_agents, workflow, input_artifacts, invocation_handoff,
59
+ result_handoff, validations, responsibilities, completion_criteria,
60
+ execution_steps.
61
+ severity: mandatory
62
+ - id: R-DSL-004
63
+ description: >-
64
+ When adding a guardrail, also add a corresponding enforcement rule
65
+ in guardrail_policies and define check implementation in the binding's
66
+ guardrail_impl.
67
+ severity: mandatory
68
+ - id: R-DSL-005
69
+ description: >-
70
+ Binding outputs should use path variables from agent-contracts.config.yaml
71
+ (e.g. {cursor_root}, {check_scripts_root}).
72
+ severity: recommended
73
+ escalation_criteria:
74
+ - condition: Schema errors from validate cannot be resolved
75
+ action: stop_and_report
76
+ - condition: Unintended override occurring during extends merge
77
+ action: stop_and_report
78
+ - condition: Score below 70% with no clear improvement path
79
+ action: stop_and_report
80
+ sections:
81
+ - title: "Role Boundary with DSL Auditor"
82
+ content: |
83
+ **Build-time verification vs independent audit:**
84
+
85
+ dsl-designer owns all build-time quality activities: validate, lint,
86
+ render, score, and generate guardrails. These run as part of the
87
+ dsl-update workflow and produce structured results (dsl-task-result).
88
+
89
+ dsl-auditor performs independent post-build audits that detect gaps
90
+ the build-time tools cannot catch — semantic coherence issues,
91
+ prompt fidelity problems, and cross-cutting design concerns.
92
+
93
+ **Handoff:** dsl-auditor consumes dsl-score-report (read-only) but
94
+ does not independently run `agent-contracts score`. The dsl-designer
95
+ produces the score report; the auditor uses it as one input to
96
+ audit recommendations.
97
+
98
+ **Feedback loop:** dsl-auditor produces dsl-audit-report with
99
+ prioritized recommendations. dsl-designer consumes these
100
+ recommendations and applies fixes in the next dsl-update cycle.
101
+
102
+ - title: "agent-contracts DSL Specification Reference"
103
+ content: |
104
+ ### Top-Level Structure
105
+
106
+ ```yaml
107
+ version: 1 # Required. Always 1
108
+ extends: "./base/" # Optional. Base DSL path (directory or file)
109
+ system:
110
+ id: string # Project ID (required)
111
+ name: string # Display name (required)
112
+ default_workflow_order: [] # Workflow execution order
113
+ agents: {} # Agent definition map (ID → definition)
114
+ tasks: {} # Task definition map
115
+ artifacts: {} # Artifact definition map
116
+ tools: {} # Tool definition map
117
+ validations: {} # Validation definition map
118
+ handoff_types: {} # Handoff type definition map
119
+ workflow: {} # Workflow definition map
120
+ policies: {} # Policy definition map
121
+ guardrails: {} # Guardrail definition map
122
+ guardrail_policies: {} # Guardrail policy definition map
123
+ components:
124
+ schemas: {} # Shared schemas (for handoff_types allOf $ref)
125
+ ```
126
+
127
+ Multi-file format uses `$ref` per section:
128
+
129
+ ```yaml
130
+ agents: { $ref: "./agents/" } # Directory $ref (auto-loads *.yaml)
131
+ tasks: { $ref: "./tasks.yaml" } # File $ref
132
+ ```
133
+
134
+ ### Agent Schema
135
+
136
+ ```yaml
137
+ <agent-id>:
138
+ role_name: string # Display name (required)
139
+ purpose: string # Agent purpose (required)
140
+ mode: read-write | read-only # Operation mode (default: read-write)
141
+ dispatch_only: boolean # true = dispatch only, no implementation (default: false)
142
+ can_read_artifacts: [] # Readable artifact ID list
143
+ can_write_artifacts: [] # Writable artifact ID list
144
+ can_execute_tools: [] # Executable tool ID list
145
+ can_perform_validations: [] # Executable validation ID list
146
+ can_invoke_agents: [] # Invocable agent ID list
147
+ can_return_handoffs: [] # Returnable handoff_type ID list
148
+ responsibilities: [] # Responsibility list (string array)
149
+ constraints: [] # Constraint list (string array)
150
+ rules: # Rule list
151
+ - id: string # Rule ID (R-XXX-NNN format recommended)
152
+ description: string # Rule description
153
+ severity: mandatory | recommended | optional
154
+ anti_patterns: [] # Anti-pattern list (string array)
155
+ escalation_criteria: # Escalation conditions
156
+ - condition: string
157
+ action: stop_and_report | report_to_architect
158
+ sections: # Structured content sections (rendered in prompts)
159
+ - title: string
160
+ content: string # Markdown text
161
+ ```
162
+
163
+ ### Task Schema
164
+
165
+ ```yaml
166
+ <task-id>:
167
+ description: string # Task description (required)
168
+ target_agent: string # Executing agent ID (required)
169
+ allowed_from_agents: [] # Delegating agent ID list (required)
170
+ workflow: string # Parent workflow ID (required)
171
+ input_artifacts: [] # Input artifact ID list
172
+ invocation_handoff: string # Invocation handoff_type ID
173
+ result_handoff: string # Result handoff_type ID
174
+ validations: [] # Validation ID list to execute
175
+ responsibilities: [] # Task-specific responsibility list
176
+ completion_criteria: [] # Completion criteria list
177
+ execution_steps: # Execution steps (ordered list)
178
+ - id: string # Step ID
179
+ action: string # Action description
180
+ reads_artifact: string # Artifact ID to read
181
+ produces_artifact: string# Artifact ID to produce
182
+ uses_tool: string # Tool ID to use
183
+ required: boolean # Whether step is mandatory
184
+ escalation_criteria:
185
+ - condition: string
186
+ action: string
187
+ ```
188
+
189
+ ### Artifact Schema
190
+
191
+ ```yaml
192
+ <artifact-id>:
193
+ type: doc | schema | code | config | html
194
+ description: string # Description (required)
195
+ owner: string # Owner agent ID (required)
196
+ producers: [] # Producer agent ID list
197
+ editors: [] # Editor agent ID list
198
+ consumers: [] # Consumer agent ID list
199
+ states: [] # Lifecycle states
200
+ required_validations: [] # Required validation ID list
201
+ visibility: project | team | external
202
+ ```
203
+
204
+ ### Tool Schema
205
+
206
+ ```yaml
207
+ <tool-id>:
208
+ kind: cli | api | mcp # Tool kind (required)
209
+ description: string # Description (required)
210
+ input_artifacts: [] # Input artifact ID list
211
+ output_artifacts: [] # Output artifact ID list
212
+ invokable_by: [] # Agent ID list that can invoke
213
+ side_effects: [] # Side effect list
214
+ commands: # Command definitions
215
+ - command: string # Command string
216
+ category: verification | pre-analysis | generation
217
+ reads: [] # Artifact ID list to read
218
+ writes: [] # Artifact ID list to write
219
+ purpose: string # Command purpose
220
+ ```
221
+
222
+ ### Validation Schema
223
+
224
+ ```yaml
225
+ <validation-id>:
226
+ target_artifact: string # Target artifact ID (required)
227
+ kind: schema | semantic | traceability | mechanical
228
+ executor_type: agent | tool # Executor type (required)
229
+ executor: string # Executor agent/tool ID (required)
230
+ blocking: boolean # true = blocking (default: false)
231
+ produces_evidence: string # Evidence artifact ID
232
+ ```
233
+
234
+ ### Handoff Type Schema
235
+
236
+ ```yaml
237
+ <handoff-type-id>:
238
+ version: integer # Version (required)
239
+ description: string # Description (required)
240
+ schema: # JSON Schema (required)
241
+ allOf: # Common schema ref + specific fields
242
+ - $ref: "#/components/schemas/<base-schema>"
243
+ - type: object
244
+ properties: {}
245
+ required: []
246
+ # Direct definition without allOf is also valid
247
+ type: object
248
+ properties: {}
249
+ required: []
250
+ example: {} # Example in YAML format
251
+ ```
252
+
253
+ ### Workflow Schema
254
+
255
+ ```yaml
256
+ <workflow-id>:
257
+ description: string # Description (required)
258
+ entry_conditions: [] # Entry conditions
259
+ trigger: string # Trigger description
260
+ steps: # Step definitions
261
+ - type: delegate # Task delegation step
262
+ task: string # Task ID
263
+ from_agent: string # Delegating agent ID
264
+ description: string
265
+ - type: gate # Gate step
266
+ gate_kind: string # Gate kind (e.g. audit-result)
267
+ description: string
268
+ - type: decision # Decision branch step
269
+ on: string # Decision target (e.g. audit-result.verdict)
270
+ description: string
271
+ branches: {} # Branch target map
272
+ ```
273
+
274
+ ### Guardrail Schema
275
+
276
+ ```yaml
277
+ <guardrail-id>:
278
+ description: string # Description (required)
279
+ scope: # Application scope
280
+ artifacts: []
281
+ workflows: []
282
+ agents: []
283
+ tasks: []
284
+ tools: []
285
+ rationale: string # Rationale
286
+ tags: [] # Tags (for classification)
287
+ ```
288
+
289
+ ### Guardrail Policy Schema
290
+
291
+ ```yaml
292
+ <policy-id>:
293
+ description: string # Description (required)
294
+ rules: # Enforcement rules
295
+ - guardrail: string # Guardrail ID (required)
296
+ severity: critical | mandatory | warning | info
297
+ action: block | warn | shadow | info
298
+ allow_override: boolean # Allow override
299
+ override_requires: [] # Override requirements (e.g. rationale)
300
+ ```
301
+
302
+ ### Config Schema (agent-contracts.config.yaml)
303
+
304
+ ```yaml
305
+ dsl: string # DSL entry point path (required)
306
+ bindings: [] # Binding file path list
307
+ active_guardrail_policy: string # Active policy ID
308
+ paths: # Path variables (used as {key} in binding outputs)
309
+ <key>: string
310
+ vars: # Value substitution variables (referenced as ${vars.key} in DSL)
311
+ <key>: string
312
+ renders: # Rendering definitions
313
+ - template: string # Handlebars template path
314
+ context: system | agent | task | artifact | tool | validation | handoff_type | workflow | policy | guardrail | guardrail_policy
315
+ output: string # Output path ({<context>.id} placeholder available)
316
+ include: [] # Target entity IDs (include/exclude are mutually exclusive)
317
+ exclude: [] # Excluded entity IDs
318
+ skip_empty: boolean # Skip file generation on empty output
319
+ ```
320
+
321
+ - title: "Merge Operator Reference"
322
+ content: |
323
+ Override base DSL inherited via extends using the following merge operators:
324
+
325
+ | Operator | Behavior | Target |
326
+ |----------|----------|--------|
327
+ | `$append` | Append to end | map / array |
328
+ | `$prepend` | Prepend to start | map / array |
329
+ | `$insert_after` | Insert after specified element | array (identified by id field) |
330
+ | `$replace` | Replace entire value | any |
331
+ | `$remove` | Remove by key/ID | map / array |
332
+ | direct value | Override scalar field | scalar |
333
+
334
+ Maps (agents, tasks, etc.) are automatically deep-merged.
335
+ Defining the same key in the project overrides the base;
336
+ adding a new key extends the base.
337
+
338
+ Arrays (responsibilities, constraints, etc.) are replaced by default
339
+ in the project. Use `$append` / `$prepend` to add to the base array.
340
+
341
+ Examples:
342
+
343
+ ```yaml
344
+ # Append a constraint to base implementer
345
+ agents:
346
+ implementer:
347
+ constraints:
348
+ $append:
349
+ - "New constraint appended"
350
+
351
+ # Insert a step after a specific step in base task
352
+ tasks:
353
+ implement-feature:
354
+ execution_steps:
355
+ $insert_after:
356
+ target: run-db-lint
357
+ items:
358
+ - id: run-contract-pipeline
359
+ action: "Run contract pipeline"
360
+
361
+ # Remove an agent from base
362
+ agents:
363
+ $remove:
364
+ - legacy-agent
365
+ ```
366
+
367
+ Processing order: load → extends merge → vars substitution → schema validation
368
+
369
+ - title: "CLI Command Reference"
370
+ content: |
371
+ | Command | Description |
372
+ |---------|-------------|
373
+ | `npx agent-contracts resolve` | Output extends-resolved YAML |
374
+ | `npx agent-contracts resolve --expand-defaults` | Output with Zod default values expanded |
375
+ | `npx agent-contracts validate` | Schema validation and reference checks |
376
+ | `npx agent-contracts lint` | Semantic lint (--strict treats warnings as errors) |
377
+ | `npx agent-contracts render -c <config>` | Template rendering |
378
+ | `npx agent-contracts render -c <config> --check` | Drift detection (for CI) |
379
+ | `npx agent-contracts score` | Completeness score (7 dimensions) |
380
+ | `npx agent-contracts score --threshold 70` | Exit 1 if below threshold (CI gate) |
381
+ | `npx agent-contracts check -c <config>` | Pipeline: resolve → validate → lint → render --check |
382
+ | `npx agent-contracts generate guardrails` | Generate guardrail runtime artifacts |
383
+
384
+ Common options for all commands:
385
+ - `-c, --config <path>`: Config file path (default: agent-contracts.config.yaml)
386
+ - `--format <text|json>`: Output format
387
+
388
+ ### Score 7 Dimensions
389
+
390
+ | Dimension | Measures | Weight |
391
+ |-----------|----------|--------|
392
+ | Artifact validation coverage | Ratio of artifacts with required_validations defined | High |
393
+ | Task validation coverage | Ratio of tasks with validations defined | High |
394
+ | Guardrail policy coverage | Ratio of guardrails referenced in guardrail_policies | Medium |
395
+ | Workflow validation integration | Ratio of blocking validations referenced in workflow/tasks | High |
396
+ | Schema completeness | Fill rate of optional fields (description, rationale, trigger, etc.) | Low |
397
+ | Cross-reference bidirectionality | Bidirectional reference rate between agent↔artifact, agent↔tool | Medium |
398
+ | Guardrail scope resolution | Existence check rate for entities in guardrail scopes | Medium |
399
+
400
+ - title: "Handlebars Template Helpers"
401
+ content: |
402
+ Built-in helpers available in templates:
403
+
404
+ | Helper | Usage | Description |
405
+ |--------|-------|-------------|
406
+ | `eq` | `{{#if (eq a b)}}` | Equality comparison |
407
+ | `notEmpty` | `{{#if (notEmpty obj)}}` | Check if object is non-empty |
408
+ | `inc` | `{{inc @index}}` | 1-based index |
409
+ | `yamlBlock` | `{{{yamlBlock obj}}}` | Render as YAML |
410
+ | `lookupPayloadFields` | `{{#each (lookupPayloadFields schema)}}` | Extract schema fields (resolves allOf) |
411
+ | `join` | `{{join arr ", "}}` | Join array |
412
+ | `contains` | `{{#if (contains arr "x")}}` | Array inclusion check |
413
+ | `groupBy` | `{{#with (groupBy arr "key")}}` | Group by field |
414
+ | `filterByField` | `{{#each (filterByField arr "field" "val")}}` | Filter by field |
415
+ | `keys` / `values` | `{{#each (keys obj)}}` | Object keys/values as array |
416
+ | `size` | `{{size obj}}` | Array length or object key count |
417
+ | `not` | `{{#if (not x)}}` | Negation |
418
+ | `or` / `and` | `{{#if (or a b)}}` | Logical operators (variadic) |
419
+ | `gt` / `gte` / `lt` | `{{#if (gt a b)}}` | Numeric comparison |
420
+ | `sequenceDiagram` | `{{{sequenceDiagram @key ../dsl}}}` | Generate Mermaid sequence diagram |
421
+ | `overviewFlowchart` | `{{{overviewFlowchart dsl}}}` | Generate Mermaid flowchart |
422
+
423
+ Rendering context (agent):
424
+ - `agent` — Agent definition
425
+ - `receivableTasks` — Receivable tasks
426
+ - `delegatableTasks` — Delegatable tasks
427
+ - `relatedArtifacts` — Related artifacts (R/W)
428
+ - `relatedTools` — Related tools
429
+ - `relatedHandoffTypes` — Related handoff types
430
+ - `mergedBehavior` — Merged behavior spec (responsibilities + task-level)
431
+ - `relatedGuardrails` — Related guardrails
432
+ - `relatedValidations` — Related validations
433
+ - `dsl` — Resolved DSL (full)