intentdna 1.4.2 → 1.4.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/.claude-plugin/hooks/hooks.json +8 -8
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/cli/commands/generate.d.ts +16 -0
- package/dist/cli/commands/generate.js +151 -0
- package/dist/cli/commands/verify.js +51 -5
- package/dist/cli/index.js +22 -0
- package/dist/compiler/workflow.d.ts +9 -1
- package/dist/compiler/workflow.js +107 -5
- package/dist/hooks/cli.js +40 -1
- package/dist/hooks/enforce.d.ts +3 -0
- package/dist/hooks/enforce.js +7 -2
- package/dist/hooks/state.d.ts +2 -0
- package/dist/schema/types.d.ts +6 -0
- package/package.json +2 -1
- package/spec/parallel-isolation.md +205 -0
- package/spec/schema-spec.md +676 -0
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
# Intent DNA Schema Specification
|
|
2
|
+
|
|
3
|
+
Version: 0.1.0 | For: LLM code generation | Format: YAML (preferred) or JSON
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Intent DNA is a declarative policy layer that compiles human intent into agent behavioral constraints. A DNA config file defines **what an agent should prefer, avoid, and enforce** — not how to implement it.
|
|
8
|
+
|
|
9
|
+
The compiler pipeline: **DNA Config** -> Cascade (merge layers) -> Activate (apply context) -> Compile -> **Constraint IR** -> Adapter output (CLAUDE.md, hooks, SDK config, skills)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Document Structure
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
# Required top-level fields
|
|
17
|
+
version: "0.1.0" # Schema version (always "0.1.0")
|
|
18
|
+
id: my_project_dna # Unique identifier (snake_case recommended)
|
|
19
|
+
name: My Project DNA # Human-readable name
|
|
20
|
+
type: project # DNA type (see below)
|
|
21
|
+
|
|
22
|
+
cascade: # Required: inheritance config
|
|
23
|
+
inherits: ["species:default"]
|
|
24
|
+
priority: 100
|
|
25
|
+
|
|
26
|
+
genes: {} # Required: intent definitions (can be empty {})
|
|
27
|
+
contexts: {} # Required: situational overrides (can be empty {})
|
|
28
|
+
|
|
29
|
+
# Optional top-level fields
|
|
30
|
+
namespace: myns # 2-8 lowercase alphanumeric, starts with letter
|
|
31
|
+
roles: {} # Agent role definitions
|
|
32
|
+
workflow: {} # Single workflow (mutually exclusive with workflows)
|
|
33
|
+
workflows: {} # Multiple workflows (mutually exclusive with workflow)
|
|
34
|
+
variables: {} # Template variables for {{var}} substitution
|
|
35
|
+
mcp: {} # MCP server definitions
|
|
36
|
+
epigenetic: # Experience-driven markers
|
|
37
|
+
markers: []
|
|
38
|
+
metadata: {} # Timestamps and stats
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### DNA Types
|
|
42
|
+
|
|
43
|
+
| Type | Priority | Use Case |
|
|
44
|
+
|------|----------|----------|
|
|
45
|
+
| `species` | 0 | Universal base DNA (rarely authored manually) |
|
|
46
|
+
| `enterprise` | 50 | Organization-wide policies |
|
|
47
|
+
| `project` | 100 | Project-specific rules (most common) |
|
|
48
|
+
| `personal` | 100 | Individual developer preferences |
|
|
49
|
+
| `context` | 150 | Situational overlays (e.g., "migration mode") |
|
|
50
|
+
| `task` | 200 | Task-specific overrides (highest priority) |
|
|
51
|
+
|
|
52
|
+
Higher priority overrides lower in cascade merge.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Genes
|
|
57
|
+
|
|
58
|
+
Genes are the atomic unit of intent. Each gene has a description and one or more codons.
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
genes:
|
|
62
|
+
quality_over_speed:
|
|
63
|
+
description: Prefer thoroughness over velocity
|
|
64
|
+
tags: [quality, core] # Optional: for categorization
|
|
65
|
+
codons:
|
|
66
|
+
- type: attract
|
|
67
|
+
target: comprehensive_tests
|
|
68
|
+
- type: attract
|
|
69
|
+
target: code_review
|
|
70
|
+
- type: repel
|
|
71
|
+
target: quick_and_dirty
|
|
72
|
+
- type: weight
|
|
73
|
+
a: quality
|
|
74
|
+
b: speed
|
|
75
|
+
ratio: 0.7 # 70% quality, 30% speed
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Codon Types (5 primitives)
|
|
79
|
+
|
|
80
|
+
#### 1. attract — Prefer/seek a behavior
|
|
81
|
+
```yaml
|
|
82
|
+
- type: attract
|
|
83
|
+
target: descriptive_variable_names # What to prefer (free-form string)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### 2. repel — Avoid a behavior
|
|
87
|
+
```yaml
|
|
88
|
+
- type: repel
|
|
89
|
+
target: magic_numbers # What to avoid
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### 3. threshold — Hard constraint (compiles to gates/hooks)
|
|
93
|
+
```yaml
|
|
94
|
+
- type: threshold
|
|
95
|
+
condition: "test_regression == false" # Condition string
|
|
96
|
+
# Compiles to a pre-execution gate that blocks when condition triggers
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### 4. weight — Trade-off between two values
|
|
100
|
+
```yaml
|
|
101
|
+
- type: weight
|
|
102
|
+
a: safety # First value
|
|
103
|
+
b: speed # Second value
|
|
104
|
+
ratio: 0.8 # 0.0-1.0, weight of 'a' (b = 1 - ratio)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### 5. sense — Detect signal and respond
|
|
108
|
+
```yaml
|
|
109
|
+
- type: sense
|
|
110
|
+
signal: uncertain_information # What to detect
|
|
111
|
+
response: verify_before_share # How to respond
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Valid responses**: `escalate_to_human`, `verify_before_share`, `compare_alternatives`, `retry_with_more_depth`, `block`, `warn`, `log`, or any custom string.
|
|
115
|
+
|
|
116
|
+
### Gene Validation Rules
|
|
117
|
+
- `description`: required, non-empty string
|
|
118
|
+
- `codons`: required, at least 1 codon
|
|
119
|
+
- `weight.ratio`: must be 0.0 to 1.0
|
|
120
|
+
- `sense.signal` and `sense.response`: both required
|
|
121
|
+
- `threshold.condition`: required, non-empty string
|
|
122
|
+
|
|
123
|
+
### Gene Naming Conventions
|
|
124
|
+
Use snake_case descriptive names. Common patterns:
|
|
125
|
+
- Behavioral: `quality_over_speed`, `small_steps`, `test_first`
|
|
126
|
+
- Safety: `data_privacy`, `no_force_push`, `scope_discipline`
|
|
127
|
+
- Process: `review_rigor`, `constructive_feedback`, `behavior_preservation`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Contexts
|
|
132
|
+
|
|
133
|
+
Contexts are situational overlays that modulate gene expression when active.
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
contexts:
|
|
137
|
+
migration:
|
|
138
|
+
description: Active during codebase migration
|
|
139
|
+
modifiers:
|
|
140
|
+
- gene: quality_over_speed
|
|
141
|
+
action: amplify
|
|
142
|
+
factor: 1.5 # 1.5x stronger (default: 2.0 for amplify)
|
|
143
|
+
- gene: scope_discipline
|
|
144
|
+
action: suppress
|
|
145
|
+
factor: 0.3 # Reduced to 30% (default: 0.5 for suppress)
|
|
146
|
+
activate_genes: [extra_caution] # Turn on specific genes
|
|
147
|
+
deactivate_genes: [fast_iteration] # Turn off specific genes
|
|
148
|
+
threshold_overrides: # Add extra thresholds
|
|
149
|
+
- condition: "migration_test_pass == false"
|
|
150
|
+
response: block
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Modifier Actions
|
|
154
|
+
|
|
155
|
+
| Action | Effect | Default Factor |
|
|
156
|
+
|--------|--------|---------------|
|
|
157
|
+
| `amplify` | Increase gene strength | 2.0 |
|
|
158
|
+
| `suppress` | Decrease gene strength | 0.5 |
|
|
159
|
+
| `activate` | Turn gene on (level -> 1.0 if was 0) | — |
|
|
160
|
+
| `deactivate` | Turn gene off (level -> 0) | — |
|
|
161
|
+
|
|
162
|
+
### Context Validation Rules
|
|
163
|
+
- `modifiers[].gene`: must reference an existing gene name
|
|
164
|
+
- `modifiers[].factor`: must be positive number
|
|
165
|
+
- `activate_genes` / `deactivate_genes`: must reference existing gene names
|
|
166
|
+
- No gene can appear in both `activate_genes` and `deactivate_genes`
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Roles
|
|
171
|
+
|
|
172
|
+
Roles define agent personas in a workflow with permissions and scope constraints.
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
roles:
|
|
176
|
+
reviewer:
|
|
177
|
+
description: Code reviewer — read-only analysis
|
|
178
|
+
model: sonnet # Optional: sonnet | opus | haiku
|
|
179
|
+
tool_permissions:
|
|
180
|
+
allow: [Read, Grep, Glob, Bash]
|
|
181
|
+
deny: [Edit, Write, NotebookEdit]
|
|
182
|
+
scope:
|
|
183
|
+
read: ["**/*"] # Glob patterns
|
|
184
|
+
write: [] # Empty = no write permission
|
|
185
|
+
instructions: # Behavior directives for the agent
|
|
186
|
+
- Check design compliance against task specification
|
|
187
|
+
- Verify test coverage for new functionality
|
|
188
|
+
- Give clear PASS/FAIL verdict with line references
|
|
189
|
+
post_checks: # Commands to run after execution
|
|
190
|
+
- vitest_run
|
|
191
|
+
- tsc_no_errors
|
|
192
|
+
success_criteria:
|
|
193
|
+
- All critical issues addressed
|
|
194
|
+
failure_modes:
|
|
195
|
+
- Rubber-stamp approval without thorough check
|
|
196
|
+
|
|
197
|
+
implementer:
|
|
198
|
+
description: Code implementer — scoped write access
|
|
199
|
+
tool_permissions:
|
|
200
|
+
allow: [Read, Edit, Write, Grep, Glob, Bash]
|
|
201
|
+
scope:
|
|
202
|
+
read: ["**/*"]
|
|
203
|
+
write: ["src/**", "test/**"] # Can only write to src/ and test/
|
|
204
|
+
output_schema: # Structured output requirements
|
|
205
|
+
required_sections: [Changes, Testing]
|
|
206
|
+
format: markdown
|
|
207
|
+
activates_genes: [thoroughness]
|
|
208
|
+
suppresses_genes: [fast_iteration]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Tool Names (Claude Code)
|
|
212
|
+
`Read`, `Edit`, `Write`, `Bash`, `Grep`, `Glob`, `NotebookEdit`, `Agent`, `WebFetch`, `WebSearch`
|
|
213
|
+
|
|
214
|
+
### Scope Patterns
|
|
215
|
+
- `**/*` — all files (default read)
|
|
216
|
+
- `src/**` — everything under src/
|
|
217
|
+
- `test/**/*.test.ts` — test files only
|
|
218
|
+
- `docs/behavior/**` — specific doc directory
|
|
219
|
+
- `*.md` — markdown files at root
|
|
220
|
+
|
|
221
|
+
### Output Schema (structured form)
|
|
222
|
+
```yaml
|
|
223
|
+
output_schema:
|
|
224
|
+
path: "docs/reviews/{{task_id}}.md" # Supports {{var}} substitution
|
|
225
|
+
required_sections: [Summary, Issues, Verdict]
|
|
226
|
+
format: markdown # markdown | json | csv
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Role Validation Rules
|
|
230
|
+
- `description`: required
|
|
231
|
+
- `tool_permissions.allow` / `deny`: tool names must be non-empty strings
|
|
232
|
+
- `scope.write` / `read`: glob patterns must be non-empty strings
|
|
233
|
+
- `activates_genes` / `suppresses_genes`: must reference existing genes, no overlap
|
|
234
|
+
- `instructions`: array of non-empty strings
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Workflows
|
|
239
|
+
|
|
240
|
+
Workflows define multi-step agent pipelines with dependency ordering, parallel execution, retry, and artifact handoff.
|
|
241
|
+
|
|
242
|
+
### Single Workflow
|
|
243
|
+
```yaml
|
|
244
|
+
workflow:
|
|
245
|
+
name: review-cycle
|
|
246
|
+
description: Implement then review with retry on failure
|
|
247
|
+
steps:
|
|
248
|
+
- id: implement
|
|
249
|
+
role: implementer
|
|
250
|
+
description: Implement the feature
|
|
251
|
+
prompt: "Implement task {{task_id}} according to the design document."
|
|
252
|
+
handoff:
|
|
253
|
+
produces:
|
|
254
|
+
- type: git_commit
|
|
255
|
+
description: "Implementation commit"
|
|
256
|
+
|
|
257
|
+
- id: review
|
|
258
|
+
role: reviewer
|
|
259
|
+
description: Review the implementation
|
|
260
|
+
depends_on: [implement] # Explicit dependency
|
|
261
|
+
prompt: "Review all changes for task {{task_id}}. Output PASS or FAIL."
|
|
262
|
+
handoff:
|
|
263
|
+
consumes:
|
|
264
|
+
- type: git_commit
|
|
265
|
+
from: implement
|
|
266
|
+
description: "Implementation to review"
|
|
267
|
+
produces:
|
|
268
|
+
- type: summary
|
|
269
|
+
description: "Review verdict"
|
|
270
|
+
|
|
271
|
+
transitions:
|
|
272
|
+
- from: review
|
|
273
|
+
to: implement
|
|
274
|
+
condition: fail # Retry on failure
|
|
275
|
+
|
|
276
|
+
retry_policy:
|
|
277
|
+
max_retries: 2
|
|
278
|
+
retry_from: implement
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Multiple Workflows
|
|
282
|
+
```yaml
|
|
283
|
+
workflows:
|
|
284
|
+
dev_pipeline:
|
|
285
|
+
name: dev-pipeline
|
|
286
|
+
steps: [...]
|
|
287
|
+
|
|
288
|
+
release_pipeline:
|
|
289
|
+
name: release-pipeline
|
|
290
|
+
steps: [...]
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Note**: `workflow` (singular) and `workflows` (plural) are mutually exclusive.
|
|
294
|
+
|
|
295
|
+
### Step Fields
|
|
296
|
+
|
|
297
|
+
```yaml
|
|
298
|
+
- id: step_name # Required: unique within workflow
|
|
299
|
+
role: role_name # Required: must exist in roles section
|
|
300
|
+
description: What this step does
|
|
301
|
+
depends_on: [other_step] # Step IDs for ordering (optional)
|
|
302
|
+
optional: false # Skip if dependency fails (default: false)
|
|
303
|
+
run_if: "round == 1" # Condition: "always" (default) | "round == 1" (first run only)
|
|
304
|
+
prompt: "Do X for {{task_id}}" # Agent prompt (supports {{var}})
|
|
305
|
+
checkpoints: # Boundary conditions
|
|
306
|
+
- assert: clean_working_tree
|
|
307
|
+
message: "Commit changes before proceeding"
|
|
308
|
+
action: block # block (default) | warn
|
|
309
|
+
handoff: # Artifact flow
|
|
310
|
+
consumes: [...]
|
|
311
|
+
produces: [...]
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Dependency Rules
|
|
315
|
+
- If NO step has `depends_on`, steps run **sequentially** in array order
|
|
316
|
+
- If ANY step has `depends_on`, only explicit dependencies are used
|
|
317
|
+
- Steps with no dependencies (and explicit mode active) run in **parallel**
|
|
318
|
+
- No circular dependencies allowed
|
|
319
|
+
- Steps cannot depend on themselves
|
|
320
|
+
|
|
321
|
+
### Handoff Artifacts
|
|
322
|
+
|
|
323
|
+
```yaml
|
|
324
|
+
handoff:
|
|
325
|
+
produces:
|
|
326
|
+
- type: file # Artifact type
|
|
327
|
+
path: docs/behavior/home.md # File path (enables re-run detection)
|
|
328
|
+
description: Behavior spec # Required
|
|
329
|
+
|
|
330
|
+
consumes:
|
|
331
|
+
- type: file
|
|
332
|
+
path: docs/behavior/home.md
|
|
333
|
+
from: write_doc # Source step ID
|
|
334
|
+
description: Behavior spec from write-doc step
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Artifact types**: `file`, `directory`, `test_result`, `git_commit`, `summary`, `state`
|
|
338
|
+
|
|
339
|
+
**Re-run idempotency**: When a workflow is re-run, the enforcement engine checks if consumed artifacts with `path` fields already exist on disk. If they do, the dependency is considered satisfied even if the producing step hasn't run in the current session.
|
|
340
|
+
|
|
341
|
+
### Transitions
|
|
342
|
+
|
|
343
|
+
```yaml
|
|
344
|
+
transitions:
|
|
345
|
+
- from: review # Source step
|
|
346
|
+
to: implement # Target step
|
|
347
|
+
condition: fail # pass | fail | always | error
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Retry Policy
|
|
351
|
+
|
|
352
|
+
```yaml
|
|
353
|
+
retry_policy:
|
|
354
|
+
max_retries: 2 # 0 = no retry
|
|
355
|
+
retry_from: implement # Step to restart from
|
|
356
|
+
backoff: none # none | linear | exponential
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Or shorthand: `max_rounds: 3` (equivalent to max_retries: 2)
|
|
360
|
+
|
|
361
|
+
### Checkpoints (predefined asserts)
|
|
362
|
+
|
|
363
|
+
| Assert | Description |
|
|
364
|
+
|--------|-------------|
|
|
365
|
+
| `clean_working_tree` | `git status --porcelain` is empty |
|
|
366
|
+
| `no_test_regression` | Test failure count didn't increase |
|
|
367
|
+
| `lint_passing` | Lint command exits 0 |
|
|
368
|
+
| `build_passing` | Build command exits 0 |
|
|
369
|
+
| Custom string | Requires `command` field |
|
|
370
|
+
|
|
371
|
+
### Workflow Validation Rules
|
|
372
|
+
- `name`: required
|
|
373
|
+
- `steps`: required, at least 1 step
|
|
374
|
+
- `steps[].id`: required, unique within workflow
|
|
375
|
+
- `steps[].role`: required, must exist in `roles`
|
|
376
|
+
- `depends_on`: referenced step IDs must exist, no self-reference
|
|
377
|
+
- `transitions.from` / `to`: must reference existing step IDs
|
|
378
|
+
- `transitions.condition`: must be `pass`, `fail`, `always`, or `error`
|
|
379
|
+
- `retry_policy.retry_from`: must reference existing step ID
|
|
380
|
+
- `max_rounds` >= 1
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Cascade (Inheritance)
|
|
385
|
+
|
|
386
|
+
DNA configs inherit from parent layers using CSS-like cascade.
|
|
387
|
+
|
|
388
|
+
```yaml
|
|
389
|
+
cascade:
|
|
390
|
+
inherits: ["species:default"] # Parent DNA IDs to inherit from
|
|
391
|
+
priority: 100 # Higher = more specific, wins on conflict
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Merge Rules
|
|
395
|
+
1. **Genes**: Same-name genes merge codons; thresholds always union (never dropped); non-threshold codons replaced by higher priority
|
|
396
|
+
2. **Contexts**: Higher priority replaces entirely
|
|
397
|
+
3. **Roles**: With namespace, keys get `{ns}_` prefix; same namespace higher priority replaces
|
|
398
|
+
4. **Workflows**: With namespace, names/roles get `{ns}_` prefix
|
|
399
|
+
5. **Epigenetic markers**: All collected (union)
|
|
400
|
+
|
|
401
|
+
### Threshold Protection
|
|
402
|
+
Threshold codons from lower-priority layers **cannot be removed** by higher-priority layers. This ensures safety invariants propagate up the chain.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Variables
|
|
407
|
+
|
|
408
|
+
Template variables for `{{var}}` substitution in prompts, descriptions, and output paths.
|
|
409
|
+
|
|
410
|
+
```yaml
|
|
411
|
+
variables:
|
|
412
|
+
task_id: "PROJ-123" # Simple string value
|
|
413
|
+
target_module: # With description
|
|
414
|
+
description: Module being worked on
|
|
415
|
+
default: home
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
All `{{var_name}}` references in the DNA are replaced with the variable value at compile time.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## MCP Servers
|
|
423
|
+
|
|
424
|
+
Define MCP (Model Context Protocol) servers for tool integration.
|
|
425
|
+
|
|
426
|
+
```yaml
|
|
427
|
+
mcp:
|
|
428
|
+
project_db:
|
|
429
|
+
description: Project database access
|
|
430
|
+
command: npx
|
|
431
|
+
args: ["-y", "@mcp/sqlite", "--db", "{{db_path}}"]
|
|
432
|
+
env:
|
|
433
|
+
DB_PATH: "{{db_path}}"
|
|
434
|
+
optional: false # Default: false
|
|
435
|
+
|
|
436
|
+
remote_api:
|
|
437
|
+
description: Remote API server
|
|
438
|
+
url: https://mcp.example.com/sse
|
|
439
|
+
timeout: 30 # Connection timeout in seconds
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
**Rules**: Must have either `command` OR `url` (not both). `description` required.
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Namespace
|
|
447
|
+
|
|
448
|
+
Namespaces prevent name collisions when multiple DNA layers define roles/workflows.
|
|
449
|
+
|
|
450
|
+
```yaml
|
|
451
|
+
namespace: crp # 2-8 chars, lowercase alphanumeric, starts with letter
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Effect**: Role `reviewer` becomes `crp_reviewer` in cascade. Workflow steps referencing `reviewer` auto-resolve to `crp_reviewer`.
|
|
455
|
+
|
|
456
|
+
**When to use**: Always use namespace when defining roles + workflows to avoid collisions with other DNA layers.
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## Epigenetic Markers
|
|
461
|
+
|
|
462
|
+
Experience-driven modifiers generated by the evolution engine. Rarely authored manually.
|
|
463
|
+
|
|
464
|
+
```yaml
|
|
465
|
+
epigenetic:
|
|
466
|
+
markers:
|
|
467
|
+
- id: marker_1
|
|
468
|
+
trigger: "test failure after refactoring"
|
|
469
|
+
timestamp: "2026-03-21T10:00:00Z"
|
|
470
|
+
decay: 0.95 # 0.0-1.0, strength over time
|
|
471
|
+
effects:
|
|
472
|
+
- gene: test_first
|
|
473
|
+
action: amplify
|
|
474
|
+
factor: 1.5
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Decay formula**: `strength = decay ^ (age_days / 30)`. Markers with strength < 0.01 are ignored.
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## Common Patterns
|
|
482
|
+
|
|
483
|
+
### Pattern 1: Simple Behavioral Policy (no roles/workflows)
|
|
484
|
+
Best for personal preferences or basic project rules.
|
|
485
|
+
|
|
486
|
+
```yaml
|
|
487
|
+
version: "0.1.0"
|
|
488
|
+
id: my_preferences
|
|
489
|
+
name: My Preferences
|
|
490
|
+
type: personal
|
|
491
|
+
cascade:
|
|
492
|
+
inherits: ["species:default"]
|
|
493
|
+
priority: 100
|
|
494
|
+
genes:
|
|
495
|
+
quality:
|
|
496
|
+
description: Prefer quality over speed
|
|
497
|
+
codons:
|
|
498
|
+
- type: attract
|
|
499
|
+
target: comprehensive_testing
|
|
500
|
+
- type: repel
|
|
501
|
+
target: shortcuts
|
|
502
|
+
- type: weight
|
|
503
|
+
a: correctness
|
|
504
|
+
b: velocity
|
|
505
|
+
ratio: 0.7
|
|
506
|
+
contexts: {}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Pattern 2: Role-Based Pipeline (most common)
|
|
510
|
+
For structured multi-agent workflows.
|
|
511
|
+
|
|
512
|
+
```yaml
|
|
513
|
+
version: "0.1.0"
|
|
514
|
+
id: my_pipeline
|
|
515
|
+
name: My Pipeline
|
|
516
|
+
type: project
|
|
517
|
+
namespace: mp
|
|
518
|
+
cascade:
|
|
519
|
+
inherits: ["species:default"]
|
|
520
|
+
priority: 100
|
|
521
|
+
genes:
|
|
522
|
+
thoroughness:
|
|
523
|
+
description: Be thorough in all steps
|
|
524
|
+
codons:
|
|
525
|
+
- type: attract
|
|
526
|
+
target: complete_analysis
|
|
527
|
+
- type: repel
|
|
528
|
+
target: skip_steps
|
|
529
|
+
contexts: {}
|
|
530
|
+
roles:
|
|
531
|
+
planner:
|
|
532
|
+
description: Plans the approach
|
|
533
|
+
tool_permissions:
|
|
534
|
+
allow: [Read, Grep, Glob]
|
|
535
|
+
deny: [Edit, Write]
|
|
536
|
+
scope:
|
|
537
|
+
read: ["**/*"]
|
|
538
|
+
write: []
|
|
539
|
+
implementer:
|
|
540
|
+
description: Implements the plan
|
|
541
|
+
scope:
|
|
542
|
+
read: ["**/*"]
|
|
543
|
+
write: ["src/**", "test/**"]
|
|
544
|
+
tester:
|
|
545
|
+
description: Runs and writes tests
|
|
546
|
+
scope:
|
|
547
|
+
read: ["**/*"]
|
|
548
|
+
write: ["test/**"]
|
|
549
|
+
workflow:
|
|
550
|
+
name: dev-cycle
|
|
551
|
+
steps:
|
|
552
|
+
- id: plan
|
|
553
|
+
role: planner
|
|
554
|
+
description: Analyze and plan
|
|
555
|
+
run_if: "round == 1"
|
|
556
|
+
- id: implement
|
|
557
|
+
role: implementer
|
|
558
|
+
description: Write the code
|
|
559
|
+
- id: test
|
|
560
|
+
role: tester
|
|
561
|
+
description: Verify with tests
|
|
562
|
+
retry_policy:
|
|
563
|
+
max_retries: 2
|
|
564
|
+
retry_from: implement
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### Pattern 3: Handoff-Driven Pipeline
|
|
568
|
+
For workflows where steps produce artifacts consumed by later steps.
|
|
569
|
+
|
|
570
|
+
```yaml
|
|
571
|
+
workflow:
|
|
572
|
+
name: behavior-lock
|
|
573
|
+
steps:
|
|
574
|
+
- id: write-doc
|
|
575
|
+
role: doc_writer
|
|
576
|
+
description: Write behavior specification
|
|
577
|
+
handoff:
|
|
578
|
+
produces:
|
|
579
|
+
- type: file
|
|
580
|
+
path: "docs/behavior/{{module}}.md"
|
|
581
|
+
description: "Behavior specification"
|
|
582
|
+
- id: write-test
|
|
583
|
+
role: test_writer
|
|
584
|
+
depends_on: [write-doc]
|
|
585
|
+
description: Write tests from spec
|
|
586
|
+
handoff:
|
|
587
|
+
consumes:
|
|
588
|
+
- type: file
|
|
589
|
+
path: "docs/behavior/{{module}}.md"
|
|
590
|
+
from: write-doc
|
|
591
|
+
description: "Behavior spec to test against"
|
|
592
|
+
produces:
|
|
593
|
+
- type: directory
|
|
594
|
+
path: "test/behavior/{{module}}/"
|
|
595
|
+
description: "Test files"
|
|
596
|
+
- id: verify
|
|
597
|
+
role: reviewer
|
|
598
|
+
depends_on: [write-test]
|
|
599
|
+
description: Verify tests match spec
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Pattern 4: Safety-First with Thresholds
|
|
603
|
+
For high-stakes environments where certain actions must be blocked.
|
|
604
|
+
|
|
605
|
+
```yaml
|
|
606
|
+
genes:
|
|
607
|
+
data_safety:
|
|
608
|
+
description: Protect sensitive data
|
|
609
|
+
codons:
|
|
610
|
+
- type: threshold
|
|
611
|
+
condition: "personal_data_exposure == false"
|
|
612
|
+
- type: repel
|
|
613
|
+
target: logging_pii
|
|
614
|
+
- type: sense
|
|
615
|
+
signal: sensitive_data_detected
|
|
616
|
+
response: escalate_to_human
|
|
617
|
+
no_destructive_ops:
|
|
618
|
+
description: Block dangerous operations
|
|
619
|
+
codons:
|
|
620
|
+
- type: threshold
|
|
621
|
+
condition: "force_push == false"
|
|
622
|
+
- type: repel
|
|
623
|
+
target: drop_table
|
|
624
|
+
- type: repel
|
|
625
|
+
target: rm_rf
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
## Generation Checklist
|
|
631
|
+
|
|
632
|
+
When generating a DNA config, verify:
|
|
633
|
+
|
|
634
|
+
1. All required fields present: `version`, `id`, `name`, `type`, `cascade`, `genes`, `contexts`
|
|
635
|
+
2. `cascade.inherits` includes `["species:default"]` unless intentionally standalone
|
|
636
|
+
3. Every gene has `description` and at least 1 codon
|
|
637
|
+
4. `weight.ratio` is between 0.0 and 1.0
|
|
638
|
+
5. Context modifiers reference existing gene names
|
|
639
|
+
6. Role `tool_permissions` use valid Claude Code tool names
|
|
640
|
+
7. Workflow step `role` values match defined role names
|
|
641
|
+
8. `depends_on` references are valid step IDs (no cycles, no self-ref)
|
|
642
|
+
9. Handoff `from` references are valid step IDs
|
|
643
|
+
10. `namespace` is 2-8 lowercase alphanumeric if specified
|
|
644
|
+
11. `workflow` and `workflows` are not both present
|
|
645
|
+
12. Variables referenced as `{{var}}` have matching entries in `variables`
|
|
646
|
+
|
|
647
|
+
---
|
|
648
|
+
|
|
649
|
+
## Available Templates
|
|
650
|
+
|
|
651
|
+
These templates can be used as starting points (install with `dna init --template <name>`):
|
|
652
|
+
|
|
653
|
+
| Template | Description |
|
|
654
|
+
|----------|-------------|
|
|
655
|
+
| `safe-refactoring` | Step-by-step safe refactoring with test guards |
|
|
656
|
+
| `code-review-pipeline` | Implement-review cycle with retry |
|
|
657
|
+
| `tdd-strict` | Test-driven development enforcement |
|
|
658
|
+
| `full-pipeline` | Plan-implement-test-review 4-step pipeline |
|
|
659
|
+
| `systematic-debugging` | Structured debugging workflow |
|
|
660
|
+
| `verification-loop` | Iterative verification cycle |
|
|
661
|
+
| `secure-dev` | Security-focused development |
|
|
662
|
+
| `enterprise-baseline` | Organization-wide base policies |
|
|
663
|
+
| `frontend-quality` | Frontend-specific quality rules |
|
|
664
|
+
| `api-backend` | API/backend development standards |
|
|
665
|
+
| `mobile-dev` | Mobile development (Flutter/RN) |
|
|
666
|
+
| `documentation-writer` | Documentation generation |
|
|
667
|
+
| `devops-cicd` | CI/CD pipeline management |
|
|
668
|
+
| `monorepo-governance` | Monorepo rules and boundaries |
|
|
669
|
+
| `flutter-behavior-lock` | Flutter behavior specification + test locking |
|
|
670
|
+
| `flutter-rewrite` | Flutter rewrite with behavior preservation |
|
|
671
|
+
| `multi-perspective-review` | Multi-reviewer parallel review |
|
|
672
|
+
| `subagent-parallel` | Parallel subagent execution |
|
|
673
|
+
| `yolo-with-guardrails` | Fast iteration with safety nets |
|
|
674
|
+
| `brainstorming-first` | Exploration before implementation |
|
|
675
|
+
| `branch-finishing` | Branch cleanup and PR prep |
|
|
676
|
+
| `pr-submitter` | PR creation workflow |
|