@exaudeus/workrail 3.27.0 → 3.29.0
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/dist/console/assets/{index-FtTaDku8.js → index-BZ6HkxGf.js} +1 -1
- package/dist/console/index.html +1 -1
- package/dist/manifest.json +3 -3
- package/docs/README.md +57 -0
- package/docs/adrs/001-hybrid-storage-backend.md +38 -0
- package/docs/adrs/002-four-layer-context-classification.md +38 -0
- package/docs/adrs/003-checkpoint-trigger-strategy.md +35 -0
- package/docs/adrs/004-opt-in-encryption-strategy.md +36 -0
- package/docs/adrs/005-agent-first-workflow-execution-tokens.md +105 -0
- package/docs/adrs/006-append-only-session-run-event-log.md +76 -0
- package/docs/adrs/007-resume-and-checkpoint-only-sessions.md +51 -0
- package/docs/adrs/008-blocked-nodes-architectural-upgrade.md +178 -0
- package/docs/adrs/009-bridge-mode-single-instance-mcp.md +195 -0
- package/docs/adrs/010-release-pipeline.md +89 -0
- package/docs/architecture/README.md +7 -0
- package/docs/architecture/refactor-audit.md +364 -0
- package/docs/authoring-v2.md +527 -0
- package/docs/authoring.md +873 -0
- package/docs/changelog-recent.md +201 -0
- package/docs/configuration.md +505 -0
- package/docs/ctc-mcp-proposal.md +518 -0
- package/docs/design/README.md +22 -0
- package/docs/design/agent-cascade-protocol.md +96 -0
- package/docs/design/autonomous-console-design-candidates.md +253 -0
- package/docs/design/autonomous-console-design-review.md +111 -0
- package/docs/design/autonomous-platform-mvp-discovery.md +525 -0
- package/docs/design/claude-code-source-deep-dive.md +713 -0
- package/docs/design/console-cyberpunk-ui-discovery.md +504 -0
- package/docs/design/console-execution-trace-candidates-final.md +160 -0
- package/docs/design/console-execution-trace-candidates.md +211 -0
- package/docs/design/console-execution-trace-design-candidates-v2.md +113 -0
- package/docs/design/console-execution-trace-design-review.md +74 -0
- package/docs/design/console-execution-trace-discovery.md +394 -0
- package/docs/design/console-execution-trace-final-review.md +77 -0
- package/docs/design/console-execution-trace-review.md +92 -0
- package/docs/design/console-performance-discovery.md +415 -0
- package/docs/design/console-ui-backlog.md +280 -0
- package/docs/design/daemon-architecture-discovery.md +853 -0
- package/docs/design/daemon-design-candidates.md +318 -0
- package/docs/design/daemon-design-review-findings.md +119 -0
- package/docs/design/daemon-engine-design-candidates.md +210 -0
- package/docs/design/daemon-engine-design-review.md +131 -0
- package/docs/design/daemon-execution-engine-discovery.md +280 -0
- package/docs/design/daemon-gap-analysis.md +554 -0
- package/docs/design/daemon-owns-console-plan.md +168 -0
- package/docs/design/daemon-owns-console-review.md +91 -0
- package/docs/design/daemon-owns-console.md +195 -0
- package/docs/design/data-model-erd.md +11 -0
- package/docs/design/design-candidates-consolidate-dev-staleness.md +98 -0
- package/docs/design/design-candidates-walk-cache-depth-limit.md +80 -0
- package/docs/design/design-review-consolidate-dev-staleness.md +54 -0
- package/docs/design/design-review-walk-cache-depth-limit.md +48 -0
- package/docs/design/implementation-plan-consolidate-dev-staleness.md +142 -0
- package/docs/design/implementation-plan-walk-cache-depth-limit.md +141 -0
- package/docs/design/layer3b-ghost-nodes-design-candidates.md +229 -0
- package/docs/design/layer3b-ghost-nodes-design-review.md +93 -0
- package/docs/design/layer3b-ghost-nodes-implementation-plan.md +219 -0
- package/docs/design/list-workflows-latency-fix-plan.md +128 -0
- package/docs/design/list-workflows-latency-fix-review.md +55 -0
- package/docs/design/list-workflows-latency-fix.md +109 -0
- package/docs/design/native-context-management-api.md +11 -0
- package/docs/design/performance-sweep-2026-04.md +96 -0
- package/docs/design/routines-guide.md +219 -0
- package/docs/design/sequence-diagrams.md +11 -0
- package/docs/design/subagent-design-principles.md +220 -0
- package/docs/design/temporal-patterns-design-candidates.md +312 -0
- package/docs/design/temporal-patterns-design-review-findings.md +163 -0
- package/docs/design/test-isolation-from-config-file.md +335 -0
- package/docs/design/v2-core-design-locks.md +2746 -0
- package/docs/design/v2-lock-registry.json +734 -0
- package/docs/design/workflow-authoring-v2.md +1044 -0
- package/docs/design/workflow-docs-spec.md +218 -0
- package/docs/design/workflow-extension-points.md +687 -0
- package/docs/design/workrail-auto-trigger-system.md +359 -0
- package/docs/design/workrail-config-file-discovery.md +513 -0
- package/docs/docker.md +110 -0
- package/docs/generated/v2-lock-closure-plan.md +26 -0
- package/docs/generated/v2-lock-coverage.json +797 -0
- package/docs/generated/v2-lock-coverage.md +177 -0
- package/docs/ideas/backlog.md +3927 -0
- package/docs/ideas/design-candidates-mcp-resilience.md +208 -0
- package/docs/ideas/design-review-findings-mcp-resilience.md +119 -0
- package/docs/ideas/implementation_plan.md +249 -0
- package/docs/ideas/third-party-workflow-setup-design-thinking.md +1948 -0
- package/docs/implementation/02-architecture.md +316 -0
- package/docs/implementation/04-testing-strategy.md +124 -0
- package/docs/implementation/09-simple-workflow-guide.md +835 -0
- package/docs/implementation/13-advanced-validation-guide.md +874 -0
- package/docs/implementation/README.md +21 -0
- package/docs/integrations/claude-code.md +300 -0
- package/docs/integrations/firebender.md +315 -0
- package/docs/migration/v0.1.0.md +147 -0
- package/docs/naming-conventions.md +45 -0
- package/docs/planning/README.md +104 -0
- package/docs/planning/github-ticketing-playbook.md +195 -0
- package/docs/plans/README.md +24 -0
- package/docs/plans/agent-managed-ticketing-design.md +605 -0
- package/docs/plans/agentic-orchestration-roadmap.md +112 -0
- package/docs/plans/assessment-gates-engine-handoff.md +536 -0
- package/docs/plans/content-coherence-and-references.md +151 -0
- package/docs/plans/library-extraction-plan.md +340 -0
- package/docs/plans/mr-review-workflow-redesign.md +1451 -0
- package/docs/plans/native-context-management-epic.md +11 -0
- package/docs/plans/perf-fixes-design-candidates.md +225 -0
- package/docs/plans/perf-fixes-design-review-findings.md +61 -0
- package/docs/plans/perf-fixes-new-issues-candidates.md +264 -0
- package/docs/plans/perf-fixes-new-issues-review.md +110 -0
- package/docs/plans/prompt-fragments.md +53 -0
- package/docs/plans/ui-ux-workflow-design-candidates.md +120 -0
- package/docs/plans/ui-ux-workflow-discovery.md +100 -0
- package/docs/plans/ui-ux-workflow-review.md +48 -0
- package/docs/plans/v2-followup-enhancements.md +587 -0
- package/docs/plans/workflow-categories-candidates.md +105 -0
- package/docs/plans/workflow-categories-discovery.md +110 -0
- package/docs/plans/workflow-categories-review.md +51 -0
- package/docs/plans/workflow-discovery-model-candidates.md +94 -0
- package/docs/plans/workflow-discovery-model-discovery.md +74 -0
- package/docs/plans/workflow-discovery-model-review.md +48 -0
- package/docs/plans/workflow-source-setup-phase-1.md +245 -0
- package/docs/plans/workflow-source-setup-phase-2.md +361 -0
- package/docs/plans/workflow-staleness-detection-candidates.md +104 -0
- package/docs/plans/workflow-staleness-detection-review.md +58 -0
- package/docs/plans/workflow-staleness-detection.md +80 -0
- package/docs/plans/workflow-v2-design.md +69 -0
- package/docs/plans/workflow-v2-roadmap.md +74 -0
- package/docs/plans/workflow-validation-design.md +98 -0
- package/docs/plans/workflow-validation-roadmap.md +108 -0
- package/docs/plans/workrail-platform-vision.md +420 -0
- package/docs/reference/agent-context-cleaner-snippet.md +94 -0
- package/docs/reference/agent-context-guidance.md +140 -0
- package/docs/reference/context-optimization.md +284 -0
- package/docs/reference/example-workflow-repository-template/.github/workflows/validate.yml +125 -0
- package/docs/reference/example-workflow-repository-template/README.md +268 -0
- package/docs/reference/example-workflow-repository-template/workflows/example-workflow.json +80 -0
- package/docs/reference/external-workflow-repositories.md +916 -0
- package/docs/reference/feature-flags-architecture.md +472 -0
- package/docs/reference/feature-flags.md +349 -0
- package/docs/reference/god-tier-workflow-validation.md +272 -0
- package/docs/reference/loop-optimization.md +209 -0
- package/docs/reference/loop-validation.md +176 -0
- package/docs/reference/loops.md +465 -0
- package/docs/reference/mcp-platform-constraints.md +59 -0
- package/docs/reference/recovery.md +88 -0
- package/docs/reference/releases.md +177 -0
- package/docs/reference/troubleshooting.md +105 -0
- package/docs/reference/workflow-execution-contract.md +998 -0
- package/docs/roadmap/README.md +22 -0
- package/docs/roadmap/legacy-planning-status.md +103 -0
- package/docs/roadmap/now-next-later.md +70 -0
- package/docs/roadmap/open-work-inventory.md +389 -0
- package/docs/tickets/README.md +39 -0
- package/docs/tickets/next-up.md +76 -0
- package/docs/workflow-management.md +317 -0
- package/docs/workflow-templates.md +423 -0
- package/docs/workflow-validation.md +184 -0
- package/docs/workflows.md +254 -0
- package/package.json +3 -1
- package/spec/authoring-spec.json +61 -16
- package/workflows/workflow-for-workflows.json +252 -93
- package/workflows/workflow-for-workflows.v2.json +188 -77
|
@@ -0,0 +1,1044 @@
|
|
|
1
|
+
# WorkRail v2 — Workflow Authoring Reference
|
|
2
|
+
|
|
3
|
+
This document describes the v2 JSON authoring model for workflows, including capabilities, features, templates, output contracts, and prompt engineering patterns.
|
|
4
|
+
|
|
5
|
+
See also:
|
|
6
|
+
- `docs/authoring.md` (general guide)
|
|
7
|
+
- `docs/reference/workflow-execution-contract.md` (normative contract)
|
|
8
|
+
- `docs/design/studio.md` (Studio discoverability and catalog)
|
|
9
|
+
|
|
10
|
+
## JSON-first authoring
|
|
11
|
+
|
|
12
|
+
WorkRail v2 uses **JSON** as the canonical authoring format.
|
|
13
|
+
|
|
14
|
+
- DSL and YAML remain possible future input formats, but v2 optimizes for determinism and straightforward validation.
|
|
15
|
+
- Workflows are pinned to a `workflowHash` computed from the **compiled canonical model** (after all templates/features/contracts are expanded), not raw source text.
|
|
16
|
+
|
|
17
|
+
## Top-level workflow structure
|
|
18
|
+
|
|
19
|
+
```jsonc
|
|
20
|
+
{
|
|
21
|
+
"id": "namespace.workflow_name",
|
|
22
|
+
"name": "Human-Readable Name",
|
|
23
|
+
"description": "What this workflow does",
|
|
24
|
+
"agentRole": "Optional: workflow-level stance/persona for the agent",
|
|
25
|
+
"capabilities": { ... },
|
|
26
|
+
"features": [ ... ],
|
|
27
|
+
"references": [ ... ],
|
|
28
|
+
"conditions": [ ... ],
|
|
29
|
+
"steps": [ ... ]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Capabilities (workflow-global)
|
|
34
|
+
|
|
35
|
+
Capabilities declare optional agent environment enhancements that materially affect workflow execution or are required for correctness.
|
|
36
|
+
|
|
37
|
+
```jsonc
|
|
38
|
+
"capabilities": {
|
|
39
|
+
"delegation": "preferred",
|
|
40
|
+
"web_browsing": "required"
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Allowed values**:
|
|
45
|
+
- `required`: workflow cannot run meaningfully without it
|
|
46
|
+
- `preferred`: use when available; degrade gracefully otherwise
|
|
47
|
+
- `disabled`: do not use even if available (rare)
|
|
48
|
+
|
|
49
|
+
**Closed set for v2**:
|
|
50
|
+
- `delegation` (subagents / parallel delegation)
|
|
51
|
+
- `web_browsing` (external knowledge lookup)
|
|
52
|
+
|
|
53
|
+
**Behavior**:
|
|
54
|
+
- WorkRail cannot introspect the agent environment.
|
|
55
|
+
- Capability availability is learned via **explicit probe/attempt steps** and recorded durably as node-attached observations.
|
|
56
|
+
- If required and unavailable:
|
|
57
|
+
- blocking modes → `blocked` with remediation ("install web browsing MCP" or provide sources manually)
|
|
58
|
+
- never-stop → record critical gap + continue
|
|
59
|
+
|
|
60
|
+
## Features (compiler middleware)
|
|
61
|
+
|
|
62
|
+
Features are closed-set, WorkRail-defined behaviors applied globally during workflow compilation.
|
|
63
|
+
|
|
64
|
+
Most features are simple toggles:
|
|
65
|
+
|
|
66
|
+
```jsonc
|
|
67
|
+
"features": [
|
|
68
|
+
"wr.features.mode_guidance",
|
|
69
|
+
"wr.features.durable_recap_guidance"
|
|
70
|
+
]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
A small subset of features can accept typed configuration:
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
"features": [
|
|
77
|
+
{
|
|
78
|
+
"id": "wr.features.capabilities",
|
|
79
|
+
"config": {
|
|
80
|
+
"probeVisibility": "collapsed",
|
|
81
|
+
"recordObservationsAs": "artifact"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "wr.features.output_contracts",
|
|
86
|
+
"config": {
|
|
87
|
+
"enforce": "block_in_blocking_modes_gap_in_never_stop"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Whitelist of configurable features** (initial):
|
|
94
|
+
- `wr.features.capabilities`
|
|
95
|
+
- `wr.features.output_contracts`
|
|
96
|
+
- `wr.features.mode_guidance`
|
|
97
|
+
|
|
98
|
+
Config schemas are WorkRail-owned and validated per feature.
|
|
99
|
+
|
|
100
|
+
## References (workflow-declared external documents)
|
|
101
|
+
|
|
102
|
+
References let a workflow point at authoritative external documents (schemas, specs, team guides, playbooks) without inlining their content into prompts or `metaGuidance`.
|
|
103
|
+
|
|
104
|
+
```jsonc
|
|
105
|
+
"references": [
|
|
106
|
+
{
|
|
107
|
+
"id": "api-schema",
|
|
108
|
+
"title": "API Schema",
|
|
109
|
+
"source": "./spec/api-schema.json", // resolves against user's workspace (default)
|
|
110
|
+
"purpose": "Canonical API contract the implementation must satisfy",
|
|
111
|
+
"authoritative": true
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "authoring-spec",
|
|
115
|
+
"title": "Authoring Specification",
|
|
116
|
+
"source": "./spec/authoring-spec.json", // resolves against workrail package root
|
|
117
|
+
"purpose": "Canonical workflow authoring rules",
|
|
118
|
+
"authoritative": true,
|
|
119
|
+
"resolveFrom": "package"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Fields:**
|
|
125
|
+
- `id` (string, unique): identifier for the reference
|
|
126
|
+
- `title` (string): human-readable display name
|
|
127
|
+
- `source` (string): file path, resolved relative to the base specified by `resolveFrom`
|
|
128
|
+
- `purpose` (string): why this reference matters to the workflow
|
|
129
|
+
- `authoritative` (boolean): whether the agent should treat this as a binding constraint vs advisory guidance
|
|
130
|
+
- `resolveFrom` (optional, `"workspace"` | `"package"`, default `"workspace"`): where to resolve `source` from. Use `"workspace"` for project-specific files; use `"package"` for files shipped with the workflow (specs, schemas, bundled guides)
|
|
131
|
+
|
|
132
|
+
**Behavior:**
|
|
133
|
+
- References are **pointers, not content**. WorkRail resolves paths at start time (against workspace root or package root per `resolveFrom`) and surfaces them to the agent as a separate content section. The agent reads files itself if needed.
|
|
134
|
+
- On `start_workflow`: full reference set with titles, paths, purposes, and authority level.
|
|
135
|
+
- On `rehydrate`: compact reminder (titles and paths only).
|
|
136
|
+
- On `advance`: no references emitted (the agent already has them).
|
|
137
|
+
- Unresolved paths (file missing) produce a warning but do not block the workflow. The reference is surfaced with an `[unresolved]` tag.
|
|
138
|
+
- Reference declarations are included in the `workflowHash` (the declarations, not the file contents), so changing which references a workflow declares creates a new hash.
|
|
139
|
+
|
|
140
|
+
**When to use references vs metaGuidance:**
|
|
141
|
+
- Use **references** only for external documents the agent may genuinely need while **executing the workflow**.
|
|
142
|
+
- Use **metaGuidance** for short behavioral rules surfaced on start and resume (e.g., "always maintain CONTEXT.md", "use Memory MCP for persistence").
|
|
143
|
+
|
|
144
|
+
Good fits for **references**:
|
|
145
|
+
- a shipped rubric the running workflow must consult
|
|
146
|
+
- a workspace spec, policy, schema, or playbook that constrains the task being executed
|
|
147
|
+
- a package-shipped companion document that materially affects runtime judgment
|
|
148
|
+
|
|
149
|
+
Bad fits for **references** in ordinary execution workflows:
|
|
150
|
+
- authoring-only provenance about how the workflow itself was designed
|
|
151
|
+
- the workflow JSON schema, unless the workflow is explicitly a workflow-authoring or validation workflow
|
|
152
|
+
- authoring guides/specs that only matter to workflow maintainers, not to the running agent
|
|
153
|
+
|
|
154
|
+
Rule of thumb:
|
|
155
|
+
- If removing the reference would not make the running workflow materially worse at doing its job, it probably should not be a workflow reference.
|
|
156
|
+
|
|
157
|
+
References are surfaced in `inspect_workflow` output for discoverability before starting execution.
|
|
158
|
+
|
|
159
|
+
## Steps
|
|
160
|
+
|
|
161
|
+
Steps can be either normal steps or template calls.
|
|
162
|
+
|
|
163
|
+
### Template calls versus extension points
|
|
164
|
+
|
|
165
|
+
These mechanisms solve different problems:
|
|
166
|
+
|
|
167
|
+
- **`templateCall`** is for **routine injection**. The compiler expands the called routine into real parent-workflow steps.
|
|
168
|
+
- **`extensionPoints`** are for **project-overridable delegation seams**. The compiler resolves `{{wr.bindings.slotId}}` to a routine/workflow ID in prompt text, but the parent agent still decides whether to call or follow that implementation.
|
|
169
|
+
|
|
170
|
+
Use this default rule:
|
|
171
|
+
|
|
172
|
+
- If you want **visible inline structure**, **confirmation behavior**, or **step-level session traceability**, use **`templateCall`**.
|
|
173
|
+
- If you want an intentionally opaque bounded implementation that a team may swap per project, use **delegation + `extensionPoints`**.
|
|
174
|
+
|
|
175
|
+
Important compiler ordering:
|
|
176
|
+
|
|
177
|
+
- Template expansion runs before binding resolution.
|
|
178
|
+
- Therefore, **extension points cannot currently select which routine a `templateCall` injects**.
|
|
179
|
+
|
|
180
|
+
### Identifier constraints (authoring-time validation, locked)
|
|
181
|
+
To keep execution deterministic and avoid escaping footguns, step and loop identifiers used in execution state must be delimiter-safe.
|
|
182
|
+
|
|
183
|
+
Locks:
|
|
184
|
+
- `step.id` (StepId) MUST match: `[a-z0-9_-]+`
|
|
185
|
+
- `loopId` (when/if loop constructs are used) MUST match: `[a-z0-9_-]+`
|
|
186
|
+
- The following characters are not allowed in these identifiers: `@`, `/`, `:`
|
|
187
|
+
|
|
188
|
+
Studio/CLI should provide deterministic auto-fix suggestions (lowercase + replace invalid characters with `_`).
|
|
189
|
+
|
|
190
|
+
### Loops (explicit, deterministic) (initial v2 authoring)
|
|
191
|
+
Loops are authored as first-class steps to keep execution deterministic and Studio-renderable. The compiler assigns a stable `bodyIndex` corresponding to the index in the authored `body[]` list.
|
|
192
|
+
|
|
193
|
+
Locks:
|
|
194
|
+
- Loops are expressed as `type: "loop"` steps with a unique `loopId` (delimiter-safe).
|
|
195
|
+
- Loop bodies are explicit and ordered: `body[]` is the authoritative step list for `bodyIndex`.
|
|
196
|
+
- Every loop MUST declare `maxIterations` (no defaults).
|
|
197
|
+
- Loop continuation is defined by a `while` condition reference (see Conditions below), not by ad-hoc booleans or free-form strings.
|
|
198
|
+
|
|
199
|
+
Example:
|
|
200
|
+
|
|
201
|
+
```jsonc
|
|
202
|
+
{
|
|
203
|
+
"type": "loop",
|
|
204
|
+
"loopId": "investigation_pass",
|
|
205
|
+
"while": { "kind": "condition_ref", "conditionId": "hypotheses_stable" },
|
|
206
|
+
"maxIterations": 5,
|
|
207
|
+
"body": [
|
|
208
|
+
{ "id": "gather_evidence", "title": "Gather evidence", "prompt": "..." },
|
|
209
|
+
{ "id": "update_hypotheses", "title": "Update hypotheses", "prompt": "..." }
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Conditions (closed set, reusable) (initial v2 authoring)
|
|
215
|
+
Conditions are authored as a closed set of reusable definitions and referenced by loops and (later) other control structures. This keeps control flow based on data state and avoids stringly-typed expression bags.
|
|
216
|
+
|
|
217
|
+
Identifier constraints:
|
|
218
|
+
- `conditions[].id` MUST match: `[a-z0-9_-]+`
|
|
219
|
+
|
|
220
|
+
Shape:
|
|
221
|
+
|
|
222
|
+
```jsonc
|
|
223
|
+
{
|
|
224
|
+
"conditions": [
|
|
225
|
+
{
|
|
226
|
+
"id": "hypotheses_stable",
|
|
227
|
+
"kind": "always_false"
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Initial closed set (minimal, expandable):
|
|
234
|
+
- `always_true`
|
|
235
|
+
- `always_false`
|
|
236
|
+
- `loop_control` (recommended for most real loops)
|
|
237
|
+
|
|
238
|
+
#### `loop_control` condition kind (recommended)
|
|
239
|
+
Because WorkRail cannot infer intent from prompts and we avoid arbitrary expression strings, the most practical deterministic loop exit is an explicit loop control signal produced by the workflow itself.
|
|
240
|
+
|
|
241
|
+
Pattern:
|
|
242
|
+
- A step in the loop body emits a small, contract-validated control artifact indicating whether to continue.
|
|
243
|
+
- The loop’s `while` condition references a `loop_control` condition definition.
|
|
244
|
+
|
|
245
|
+
Example condition definition:
|
|
246
|
+
|
|
247
|
+
```jsonc
|
|
248
|
+
{
|
|
249
|
+
"id": "keep_iterating",
|
|
250
|
+
"kind": "loop_control",
|
|
251
|
+
"continueWhen": "continue" // closed set: continue | stop
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Notes:
|
|
256
|
+
- The control signal should be validated via a WorkRail-owned output contract pack (e.g., `wr.contracts.loop_control`) to keep it self-correcting and deterministic.
|
|
257
|
+
- This avoids reading arbitrary `context` keys or relying on free-form strings for control flow.
|
|
258
|
+
- Deterministic evaluation intent:
|
|
259
|
+
- On each loop iteration, the workflow must produce a validated `wr.loop_control` artifact for the loop’s `loopId`.
|
|
260
|
+
- The loop continues while the most recent validated artifact indicates `decision == continueWhen`.
|
|
261
|
+
- Missing/invalid loop control output is handled by effective autonomy:
|
|
262
|
+
- blocking modes: `blocked` with structured missing/invalid required output
|
|
263
|
+
- never-stop: record a critical gap and treat as `decision="stop"` (fail-safe to prevent runaway loops)
|
|
264
|
+
|
|
265
|
+
#### `wr.contracts.loop_control` (initial contract pack, locked)
|
|
266
|
+
This contract pack validates a loop control artifact emitted via `output.artifacts[]`.
|
|
267
|
+
|
|
268
|
+
Artifact kind:
|
|
269
|
+
- `wr.loop_control`
|
|
270
|
+
|
|
271
|
+
Required fields:
|
|
272
|
+
- `loopId` (must match the enclosing loop step’s `loopId`)
|
|
273
|
+
- `decision`: `continue | stop`
|
|
274
|
+
|
|
275
|
+
Optional fields:
|
|
276
|
+
- `summary` (bounded text)
|
|
277
|
+
|
|
278
|
+
Example artifact:
|
|
279
|
+
|
|
280
|
+
```jsonc
|
|
281
|
+
{
|
|
282
|
+
"kind": "wr.loop_control",
|
|
283
|
+
"loopId": "investigation_pass",
|
|
284
|
+
"decision": "continue",
|
|
285
|
+
"summary": "More hypotheses to test; proceed."
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Notes:
|
|
290
|
+
- The initial set is intentionally tiny; richer condition kinds should be added only when needed and must remain a closed set.
|
|
291
|
+
|
|
292
|
+
### Normal step
|
|
293
|
+
|
|
294
|
+
```jsonc
|
|
295
|
+
{
|
|
296
|
+
"id": "phase-1",
|
|
297
|
+
"title": "Phase 1: Analysis",
|
|
298
|
+
"agentRole": "Optional: override workflow-level role for this step",
|
|
299
|
+
"prompt": "A single prompt string (traditional)"
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Or using structured blocks:
|
|
304
|
+
|
|
305
|
+
```jsonc
|
|
306
|
+
{
|
|
307
|
+
"id": "phase-1",
|
|
308
|
+
"title": "Phase 1: Analysis",
|
|
309
|
+
"promptBlocks": {
|
|
310
|
+
"goal": "What this step accomplishes",
|
|
311
|
+
"constraints": [
|
|
312
|
+
"Follow the selected mode (guided vs full-auto)",
|
|
313
|
+
"Do not assume baseline tools exist in workflows"
|
|
314
|
+
],
|
|
315
|
+
"procedure": [
|
|
316
|
+
"Step 1: ...",
|
|
317
|
+
"Step 2: ..."
|
|
318
|
+
],
|
|
319
|
+
"outputRequired": {
|
|
320
|
+
"notesMarkdown": "Short recap (≤10 lines)"
|
|
321
|
+
},
|
|
322
|
+
"verify": [
|
|
323
|
+
"Check that ..."
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
"output": {
|
|
327
|
+
"contractRef": "wr.contracts.some_contract",
|
|
328
|
+
"hints": {
|
|
329
|
+
"notesMarkdown": "If you can't produce the contract, at least write notes."
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**PromptBlocks** (optional):
|
|
336
|
+
- Canonical block set: `goal`, `constraints`, `procedure`, `outputRequired`, `verify`
|
|
337
|
+
- WorkRail renders blocks in deterministic order into a text-first `pending.prompt`
|
|
338
|
+
- Features can inject/override specific blocks (e.g., mode guidance → constraints)
|
|
339
|
+
|
|
340
|
+
## Authoring for intelligence instead of compliance theater
|
|
341
|
+
|
|
342
|
+
The point of a strong workflow is not to script every thought. The point is to create a structure that preserves quality while still letting the agent use its intelligence well.
|
|
343
|
+
|
|
344
|
+
### Strong skeleton, not a straitjacket
|
|
345
|
+
|
|
346
|
+
Good workflows are rigid about:
|
|
347
|
+
|
|
348
|
+
- required outputs
|
|
349
|
+
- important decision points
|
|
350
|
+
- evidence and uncertainty accounting
|
|
351
|
+
- explicit challenge or validation
|
|
352
|
+
- durable state and handoff expectations
|
|
353
|
+
|
|
354
|
+
Good workflows stay flexible about:
|
|
355
|
+
|
|
356
|
+
- reasoning order
|
|
357
|
+
- synthesis moves
|
|
358
|
+
- ideation style
|
|
359
|
+
- how the agent reaches a sound answer inside the phase boundary
|
|
360
|
+
|
|
361
|
+
In practice: constrain the **failure modes**, not the entire cognitive path.
|
|
362
|
+
|
|
363
|
+
### Anti-lazy wording patterns
|
|
364
|
+
|
|
365
|
+
Adaptive wording is powerful, but it can also make it too easy for the agent to do shallow work.
|
|
366
|
+
|
|
367
|
+
Be careful with phrases like:
|
|
368
|
+
|
|
369
|
+
- `if appropriate`
|
|
370
|
+
- `minimal pass`
|
|
371
|
+
- `light scan`
|
|
372
|
+
- `you may`
|
|
373
|
+
- `smallest`
|
|
374
|
+
- `cheapest`
|
|
375
|
+
|
|
376
|
+
These phrases usually need a quality floor.
|
|
377
|
+
|
|
378
|
+
Bad:
|
|
379
|
+
|
|
380
|
+
- "Do a light landscape scan."
|
|
381
|
+
- "If appropriate, delegate."
|
|
382
|
+
- "Generate 2-3 options."
|
|
383
|
+
|
|
384
|
+
Better:
|
|
385
|
+
|
|
386
|
+
- "Do the lightest landscape scan that still surfaces the main existing approaches, hard constraints, and obvious contradictions."
|
|
387
|
+
- "Delegate if it is likely to improve the result enough to be worth the extra step. If not, keep going yourself and record why."
|
|
388
|
+
- "Generate enough genuinely distinct options to support a real choice. If they cluster too tightly, add another pass."
|
|
389
|
+
|
|
390
|
+
The pattern to aim for is:
|
|
391
|
+
|
|
392
|
+
- creative freedom
|
|
393
|
+
- plus a clear quality floor
|
|
394
|
+
- plus accountability when choosing the lighter path
|
|
395
|
+
|
|
396
|
+
### User-voice prose
|
|
397
|
+
|
|
398
|
+
For bundled, user-facing workflows, prefer prose that often sounds like the user is directly telling the agent what to do.
|
|
399
|
+
|
|
400
|
+
This usually works better than detached author or framework narration for exploratory, creative, or advisory workflows.
|
|
401
|
+
|
|
402
|
+
Less effective:
|
|
403
|
+
|
|
404
|
+
- "The agent should gather stakeholder input and synthesize next actions."
|
|
405
|
+
|
|
406
|
+
More effective:
|
|
407
|
+
|
|
408
|
+
- "Figure out what I actually need, gather the missing context, and then tell me what you think I should do next."
|
|
409
|
+
|
|
410
|
+
This is not a hard rule for every workflow. Internal, infrastructural, or highly mechanical workflows may still read better in neutral system prose. But user-voice should be considered a first-class authoring option.
|
|
411
|
+
|
|
412
|
+
### Extension point ownership
|
|
413
|
+
|
|
414
|
+
Extension points work best when they customize a bounded cognitive unit, not the entire workflow's reasoning contract.
|
|
415
|
+
|
|
416
|
+
Recommended pattern:
|
|
417
|
+
|
|
418
|
+
- parent workflow owns:
|
|
419
|
+
- orchestration
|
|
420
|
+
- synthesis
|
|
421
|
+
- final decision
|
|
422
|
+
- loop exits
|
|
423
|
+
- handoff
|
|
424
|
+
- extension slot owns:
|
|
425
|
+
- bounded candidate generation
|
|
426
|
+
- bounded review or audit
|
|
427
|
+
- bounded challenge or validation pass
|
|
428
|
+
|
|
429
|
+
This preserves customization without letting the core workflow become incoherent.
|
|
430
|
+
|
|
431
|
+
### Prompt references (`wr.refs.*`) (initial v2 authoring)
|
|
432
|
+
Workflows may inject small, canonical WorkRail-owned snippets inline (e.g., “WorkRail v2 definition”, “append-only truth”, “modes semantics”) to avoid copy/paste and keep prompts consistent.
|
|
433
|
+
|
|
434
|
+
Locks (v2 intent):
|
|
435
|
+
- **Compile-time only**: references are resolved during compilation and included in the compiled snapshot (and therefore `workflowHash`).
|
|
436
|
+
- **Closed set**: reference IDs are WorkRail-owned and namespaced: `wr.refs.*`.
|
|
437
|
+
- **No templating**: do not support `{{ }}` interpolation, file-path includes, or URL includes. References must be typed and validated.
|
|
438
|
+
- **Budgets**: references are byte-bounded; budget violations are validation errors (no silent truncation).
|
|
439
|
+
- **Placement discipline**: references are allowed only within structured prompt sections (to keep prompts instruction-first).
|
|
440
|
+
|
|
441
|
+
Locked choice (v2): the compiled workflow snapshot embeds the fully resolved reference text for every `wr.refs.*` usage (not just `{refId, refContentHash}`), so pinned compiled snapshots are self-contained for export/import.
|
|
442
|
+
|
|
443
|
+
Authoring shape (conceptual, code-canonical schema will be generated):
|
|
444
|
+
- `PromptValue = string | PromptParts`
|
|
445
|
+
- `PromptParts = [PromptPart, ...]` (non-empty list)
|
|
446
|
+
- `PromptPart` (closed union):
|
|
447
|
+
- `{ "kind": "text", "text": "..." }`
|
|
448
|
+
- `{ "kind": "ref", "refId": "wr.refs.some_snippet" }`
|
|
449
|
+
|
|
450
|
+
Recommended placements:
|
|
451
|
+
- `promptBlocks.goal`: `PromptValue`
|
|
452
|
+
- `promptBlocks.constraints[]`: `PromptValue[]`
|
|
453
|
+
- `promptBlocks.procedure[]`: `PromptValue[]`
|
|
454
|
+
- `promptBlocks.verify[]`: `PromptValue[]`
|
|
455
|
+
|
|
456
|
+
Example (conceptual):
|
|
457
|
+
|
|
458
|
+
```jsonc
|
|
459
|
+
{
|
|
460
|
+
"id": "project.planning_v2",
|
|
461
|
+
"steps": [
|
|
462
|
+
{
|
|
463
|
+
"id": "plan_storage",
|
|
464
|
+
"title": "Plan the two-stream commit protocol",
|
|
465
|
+
"promptBlocks": {
|
|
466
|
+
"goal": [
|
|
467
|
+
{ "kind": "text", "text": "Plan the durable commit protocol for WorkRail v2." },
|
|
468
|
+
{ "kind": "ref", "refId": "wr.refs.v2_definition" }
|
|
469
|
+
],
|
|
470
|
+
"constraints": [
|
|
471
|
+
[
|
|
472
|
+
{ "kind": "ref", "refId": "wr.refs.append_only_truth" },
|
|
473
|
+
{ "kind": "text", "text": "Do not introduce salvage scanning as a correctness path." }
|
|
474
|
+
]
|
|
475
|
+
],
|
|
476
|
+
"procedure": [
|
|
477
|
+
"Define the AppendPlan commit ordering.",
|
|
478
|
+
"List crash states and recovery rules."
|
|
479
|
+
],
|
|
480
|
+
"verify": [
|
|
481
|
+
[
|
|
482
|
+
{ "kind": "text", "text": "Hashing inputs are canonical and deterministic." },
|
|
483
|
+
{ "kind": "ref", "refId": "wr.refs.jcs_hashing" }
|
|
484
|
+
]
|
|
485
|
+
]
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
**Output object** (optional):
|
|
493
|
+
- `contractRef` (string): references a WorkRail-owned contract pack; WorkRail validates on `continue_workflow`
|
|
494
|
+
- `hints` (object): non-enforced guidance
|
|
495
|
+
|
|
496
|
+
### Template call step
|
|
497
|
+
|
|
498
|
+
```jsonc
|
|
499
|
+
{
|
|
500
|
+
"type": "template_call",
|
|
501
|
+
"templateId": "wr.templates.capability_probe",
|
|
502
|
+
"args": {
|
|
503
|
+
"capability": "web_browsing",
|
|
504
|
+
"when": "early_if_required"
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Templates are WorkRail-owned builtins that expand into one or more steps.
|
|
510
|
+
|
|
511
|
+
**Template-implied contracts**:
|
|
512
|
+
- Templates may automatically imply an `output.contractRef` without the author specifying it.
|
|
513
|
+
- Example: `wr.templates.capability_probe` implies `wr.contracts.capability_observation`.
|
|
514
|
+
|
|
515
|
+
## AgentRole
|
|
516
|
+
|
|
517
|
+
`agentRole` is a stance/persona snippet injected into the rendered prompt.
|
|
518
|
+
|
|
519
|
+
- WorkRail **cannot control the agent's system prompt** (that lives in the agent/IDE runtime).
|
|
520
|
+
- `agentRole` is simply text guidance included in the workflow/step instructions.
|
|
521
|
+
|
|
522
|
+
**Scoping**:
|
|
523
|
+
- Workflow-level `agentRole` applies to all steps unless overridden.
|
|
524
|
+
- Step-level `agentRole` overrides the workflow default.
|
|
525
|
+
|
|
526
|
+
**Best practice**: keep short; rely on templates/features for reusable stance content.
|
|
527
|
+
|
|
528
|
+
## Reusable authoring patterns for adaptive workflows
|
|
529
|
+
|
|
530
|
+
These patterns are emerging as the most reusable v2 design techniques for workflows that need both determinism and adaptive reasoning.
|
|
531
|
+
|
|
532
|
+
### 1. Constrain outcomes, not cognition
|
|
533
|
+
|
|
534
|
+
Author phases so they specify:
|
|
535
|
+
|
|
536
|
+
- what must be established before the phase can end
|
|
537
|
+
- what must be recorded if it cannot be established
|
|
538
|
+
- what control-flow or confidence changes follow
|
|
539
|
+
|
|
540
|
+
Do **not** over-prescribe the exact reasoning order unless the order itself is critical for correctness.
|
|
541
|
+
|
|
542
|
+
This should also influence wording. Avoid soft escape-hatch phrases like `if appropriate`, `minimal pass`, `light scan`, or `you may` unless you also say what still must be achieved and when the lighter path is actually enough.
|
|
543
|
+
|
|
544
|
+
### 2. Locate → Bound → Enrich → Classify front-half
|
|
545
|
+
|
|
546
|
+
For workflows that investigate an external or partially-known target, a strong default front-half pattern is:
|
|
547
|
+
|
|
548
|
+
1. **Locate** the true target
|
|
549
|
+
2. **Bound** the correct scope / boundary
|
|
550
|
+
3. **Enrich** with all realistically available context
|
|
551
|
+
4. **Classify** risk, confidence, shape, and routing needs
|
|
552
|
+
|
|
553
|
+
This is often better than splitting triage, input gating, context gathering, and re-triage into many smaller phases.
|
|
554
|
+
|
|
555
|
+
### 3. Confidence-aware orchestration
|
|
556
|
+
|
|
557
|
+
Treat confidence as workflow state, not hand-wavy prose.
|
|
558
|
+
|
|
559
|
+
Common confidence dimensions:
|
|
560
|
+
|
|
561
|
+
- boundary confidence
|
|
562
|
+
- context / intent confidence
|
|
563
|
+
- policy-context confidence
|
|
564
|
+
- evidence confidence
|
|
565
|
+
- validation confidence
|
|
566
|
+
|
|
567
|
+
Authors should define:
|
|
568
|
+
|
|
569
|
+
- which dimensions the workflow tracks
|
|
570
|
+
- which ones cap final conclusions
|
|
571
|
+
- which ones trigger deeper follow-up versus only downgrade the handoff
|
|
572
|
+
|
|
573
|
+
#### Example confidence matrix
|
|
574
|
+
|
|
575
|
+
| Dimension | High | Medium | Low |
|
|
576
|
+
|---|---|---|---|
|
|
577
|
+
| Boundary confidence | True scope/base is clear | Likely scope with some ambiguity | Scope may be wrong |
|
|
578
|
+
| Context confidence | Intent and constraints are well-supported | Partial intent reconstruction | Intent mostly inferred or missing |
|
|
579
|
+
| Policy-context confidence | Repo/user rules are clear | Some rules known, some gaps | Rules/preferences mostly unknown |
|
|
580
|
+
| Evidence confidence | Findings are directly supported | Mostly reasoned with some missing proof | Major inference gaps |
|
|
581
|
+
| Validation confidence | Strong challenge/verification happened | Some verification happened | Little meaningful verification |
|
|
582
|
+
|
|
583
|
+
#### Example confidence cap rules
|
|
584
|
+
|
|
585
|
+
- if **boundary confidence = Low**, final recommendation confidence should not exceed **Low**
|
|
586
|
+
- if **evidence confidence = Low**, Major/Critical claims should be softened or reopened
|
|
587
|
+
- if **policy-context confidence = Low**, style/philosophy findings should be framed more cautiously than correctness findings
|
|
588
|
+
|
|
589
|
+
### 4. Non-blocking enrichment with durable disclosure
|
|
590
|
+
|
|
591
|
+
Preferred capabilities and enrichment sources should usually follow this pattern:
|
|
592
|
+
|
|
593
|
+
- try to use them
|
|
594
|
+
- record what happened durably
|
|
595
|
+
- degrade gracefully if unavailable
|
|
596
|
+
- disclose the limitation in the final handoff
|
|
597
|
+
|
|
598
|
+
Only block when the target is not meaningfully reviewable/executable or when a truly required capability/output is missing in blocking modes.
|
|
599
|
+
|
|
600
|
+
#### Example gap semantics
|
|
601
|
+
|
|
602
|
+
| Situation | Blocking mode | Never-stop mode |
|
|
603
|
+
|---|---|---|
|
|
604
|
+
| Preferred capability unavailable | degrade + disclose | degrade + record gap |
|
|
605
|
+
| Supporting docs missing | continue + disclose | continue + record gap if material |
|
|
606
|
+
| Boundary remains ambiguous | continue with downgraded confidence | continue with downgraded confidence + gap |
|
|
607
|
+
| Required contract output missing | blocked | continue + critical gap |
|
|
608
|
+
|
|
609
|
+
### 5. Artifact vs context split
|
|
610
|
+
|
|
611
|
+
Use **context** for routing-critical fields that later phases, loops, and conditions need to inspect cheaply and deterministically.
|
|
612
|
+
|
|
613
|
+
Use **artifacts** for richer synthesis, human-readable ledgers, and review/handoff material.
|
|
614
|
+
|
|
615
|
+
Rule of thumb:
|
|
616
|
+
|
|
617
|
+
- **context** = drives control flow
|
|
618
|
+
- **artifact** = drives reading, synthesis, and handoff
|
|
619
|
+
|
|
620
|
+
Authoring implication:
|
|
621
|
+
|
|
622
|
+
- the agent should compute and record route-driving facts in `context`
|
|
623
|
+
- the workflow/engine should evaluate those facts through conditions, loops, and branching constructs
|
|
624
|
+
- avoid leaving material path decisions to free-form prompt wording such as "choose the best next path" when the route can be made declarative
|
|
625
|
+
|
|
626
|
+
#### Example split
|
|
627
|
+
|
|
628
|
+
Keep in **context**:
|
|
629
|
+
|
|
630
|
+
- `boundaryConfidence`
|
|
631
|
+
- `needsFollowup`
|
|
632
|
+
- `reviewMode`
|
|
633
|
+
- `shapeProfile`
|
|
634
|
+
|
|
635
|
+
Keep as **artifacts**:
|
|
636
|
+
|
|
637
|
+
- human-readable review/source ledgers
|
|
638
|
+
- boundary-analysis summaries
|
|
639
|
+
- synthesized findings reports
|
|
640
|
+
|
|
641
|
+
### 6. Shape/type routing as semi-structured guidance
|
|
642
|
+
|
|
643
|
+
Routing guidance should help the agent classify the work, but material pathing should still be encoded in workflow structure wherever practical.
|
|
644
|
+
|
|
645
|
+
Good pattern:
|
|
646
|
+
|
|
647
|
+
- agent classifies shape, risk, or confidence
|
|
648
|
+
- agent records the route-driving outputs in context
|
|
649
|
+
- engine/workflow uses those outputs for branching, loops, or gates
|
|
650
|
+
|
|
651
|
+
Weaker pattern:
|
|
652
|
+
|
|
653
|
+
- prompt prose leaves the next branch to implicit agent choice without a condition, route-driving field, or declared control-flow rule
|
|
654
|
+
|
|
655
|
+
### 7. Prompt wording should resist shallow compliance
|
|
656
|
+
|
|
657
|
+
Prompts should not only be valid or well-structured. They should also be hard to satisfy with shallow compliance.
|
|
658
|
+
|
|
659
|
+
Good prompt wording:
|
|
660
|
+
|
|
661
|
+
- makes success conditions concrete
|
|
662
|
+
- asks for evidence, alternatives, tradeoffs, or uncertainty disclosure when those matter
|
|
663
|
+
- avoids vague opt-out language unless paired with a real quality floor
|
|
664
|
+
|
|
665
|
+
Weak:
|
|
666
|
+
|
|
667
|
+
- "Do a light review."
|
|
668
|
+
- "If appropriate, delegate."
|
|
669
|
+
- "Generate 2-3 ideas."
|
|
670
|
+
|
|
671
|
+
Stronger:
|
|
672
|
+
|
|
673
|
+
- "Do the lightest review that still surfaces the main risks, contradictions, and missing context."
|
|
674
|
+
- "Delegate only if it is likely to improve the result enough to be worth the extra step. Otherwise continue yourself and record why."
|
|
675
|
+
- "Generate enough distinct ideas to support a real choice. If they cluster too tightly, add another pass."
|
|
676
|
+
|
|
677
|
+
### 8. Choose prose stance deliberately
|
|
678
|
+
|
|
679
|
+
Workflow prose has a stance, whether authors choose it consciously or not.
|
|
680
|
+
|
|
681
|
+
Common options:
|
|
682
|
+
|
|
683
|
+
- **user-voice**: sounds like the user directly instructing the agent
|
|
684
|
+
- **neutral system prose**: detached but clear
|
|
685
|
+
- **internal-author prose**: suitable for highly technical or maintenance-oriented workflows
|
|
686
|
+
|
|
687
|
+
For bundled and user-facing workflows, user-voice is often the strongest default. For deeply internal or infrastructural workflows, neutral/system prose may be a better fit. The important thing is to choose deliberately rather than drifting into accidental framework boilerplate.
|
|
688
|
+
|
|
689
|
+
Shape and type classifications are often valuable, but they should remain compact and behavior-linked.
|
|
690
|
+
|
|
691
|
+
Use them to influence:
|
|
692
|
+
|
|
693
|
+
- reviewer-family selection
|
|
694
|
+
- validation depth
|
|
695
|
+
- simulation need
|
|
696
|
+
- false-positive suppression
|
|
697
|
+
- partitioning and follow-up depth
|
|
698
|
+
|
|
699
|
+
Avoid large taxonomies that do not change behavior.
|
|
700
|
+
|
|
701
|
+
#### Example routing table
|
|
702
|
+
|
|
703
|
+
| Shape / Type | Strong default behavior |
|
|
704
|
+
|---|---|
|
|
705
|
+
| tiny isolated + test/docs only | lighter review depth, stronger false-positive suppression |
|
|
706
|
+
| broad cross-cutting + API/contract change | stronger architecture/runtime review and deeper validation |
|
|
707
|
+
| stacked/ambiguous boundary | boundary follow-up before high-confidence conclusions |
|
|
708
|
+
| migration-heavy | stronger rollout, compatibility, and simulation scrutiny |
|
|
709
|
+
|
|
710
|
+
### 7. Auditor-first delegation
|
|
711
|
+
|
|
712
|
+
When using subagents/routines, prefer auditor-style use when the main agent should remain the owner of truth and synthesis.
|
|
713
|
+
|
|
714
|
+
Good uses:
|
|
715
|
+
|
|
716
|
+
- completeness audit
|
|
717
|
+
- depth audit
|
|
718
|
+
- adversarial challenge
|
|
719
|
+
- philosophy alignment review
|
|
720
|
+
- final verification
|
|
721
|
+
|
|
722
|
+
Executor-style delegation is still useful for bounded independent work, but should not silently replace workflow-owned judgment.
|
|
723
|
+
|
|
724
|
+
## Compact end-to-end example
|
|
725
|
+
|
|
726
|
+
For a workflow reviewing an external artifact:
|
|
727
|
+
|
|
728
|
+
1. **Phase 0** establishes target, boundary, context, and confidence fields
|
|
729
|
+
2. **Context keys** store routing-critical outputs such as `boundaryConfidence` and `needsFollowup`
|
|
730
|
+
3. **Artifacts** store richer synthesis such as a `source-ledger` or `boundary-analysis`
|
|
731
|
+
4. An **auditor routine** challenges the current hypothesis
|
|
732
|
+
5. Final confidence is capped by weak boundary/evidence state even if the prose summary sounds strong
|
|
733
|
+
|
|
734
|
+
## Validation Criteria (v1 compatibility, design guidance)
|
|
735
|
+
|
|
736
|
+
Steps can include `validationCriteria` to validate agent output. This is a v1 feature maintained for backward compatibility.
|
|
737
|
+
|
|
738
|
+
### Evidence-Based Validation Design (CRITICAL)
|
|
739
|
+
|
|
740
|
+
**Lock (§19)**: Validate **evidence of work**, not **completion flags**.
|
|
741
|
+
|
|
742
|
+
When agents see validation requirements (via prompt enhancement, error messages, or guidance fields), they may optimize for **passing validation** rather than **doing quality work**. Prevent this with evidence-based validation.
|
|
743
|
+
|
|
744
|
+
#### Anti-Pattern: Flag-Only Validation
|
|
745
|
+
|
|
746
|
+
```json
|
|
747
|
+
{
|
|
748
|
+
"prompt": "Analyze security vulnerabilities",
|
|
749
|
+
"validationCriteria": {
|
|
750
|
+
"type": "contains",
|
|
751
|
+
"value": "analysisComplete = true"
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
**Problem**: Agent writes `analysisComplete = true` without analysis. Passes validation, produces no value.
|
|
757
|
+
|
|
758
|
+
#### Good Pattern: Evidence-Based Validation
|
|
759
|
+
|
|
760
|
+
```json
|
|
761
|
+
{
|
|
762
|
+
"prompt": "Analyze security vulnerabilities. List findings with severity.",
|
|
763
|
+
"validationCriteria": {
|
|
764
|
+
"and": [
|
|
765
|
+
{"type": "regex", "pattern": "Finding \\d+:.*severity:(high|medium|low)", "message": "List numbered findings with severity"},
|
|
766
|
+
{"type": "contains", "value": "file:", "message": "Reference specific file locations"},
|
|
767
|
+
{"type": "length", "min": 200, "max": 5000, "message": "Substantive analysis (200-5000 chars)"}
|
|
768
|
+
]
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
**Why it works**: Can't fake structured findings without doing analysis.
|
|
774
|
+
|
|
775
|
+
#### Design Guidelines
|
|
776
|
+
|
|
777
|
+
**DO**:
|
|
778
|
+
- Check for work products ("Finding N:", "file:line", "rationale:")
|
|
779
|
+
- Require patterns that indicate substance (not just keywords)
|
|
780
|
+
- Use multiple independent criteria (cross-validation)
|
|
781
|
+
- Set reasonable length bounds (ensures substance, prevents spam)
|
|
782
|
+
|
|
783
|
+
**DON'T**:
|
|
784
|
+
- Validate single boolean flags (`complete = true`, `done = yes`)
|
|
785
|
+
- Check for magic phrases alone (`must contain 'finished'`)
|
|
786
|
+
- Make validation trivially satisfiable with minimal text
|
|
787
|
+
- Rely on agent honesty without verification
|
|
788
|
+
|
|
789
|
+
### Migration Note
|
|
790
|
+
|
|
791
|
+
**Existing workflows** using flag-only validation will continue to work (backward compatible), but should be audited and enhanced to follow evidence-based patterns.
|
|
792
|
+
|
|
793
|
+
**New workflows** should follow evidence-based validation from the start.
|
|
794
|
+
|
|
795
|
+
See §19 in `v2-core-design-locks.md` for full rationale.
|
|
796
|
+
|
|
797
|
+
## Output contracts
|
|
798
|
+
|
|
799
|
+
Output contracts enable WorkRail to validate required outputs and return self-correcting `blocked` responses (or record gaps).
|
|
800
|
+
|
|
801
|
+
### Contract packs (closed set)
|
|
802
|
+
|
|
803
|
+
WorkRail defines a small, closed set of contract packs. Initial set (conceptual):
|
|
804
|
+
|
|
805
|
+
- `wr.contracts.capability_observation`
|
|
806
|
+
- `wr.contracts.workflow_divergence`
|
|
807
|
+
- `wr.contracts.loop_control`
|
|
808
|
+
- (and gaps-related contracts when formalized)
|
|
809
|
+
|
|
810
|
+
Each pack includes:
|
|
811
|
+
- allowed artifact kind(s)
|
|
812
|
+
- required fields
|
|
813
|
+
- minimal example payload
|
|
814
|
+
|
|
815
|
+
### Workflow-authored output schemas (rejected for v2)
|
|
816
|
+
v2 does **not** allow workflows to define arbitrary inline JSON schemas (or point to project-local / git-hosted schema files) for required outputs.
|
|
817
|
+
|
|
818
|
+
Instead:
|
|
819
|
+
- Use `output.contractRef` referencing a **WorkRail-owned** contract pack (`wr.contracts.*`).
|
|
820
|
+
- If you need richer structured artifacts than existing packs support, prefer:
|
|
821
|
+
- expanding the WorkRail-owned contract pack catalog (recommended), or
|
|
822
|
+
- using `output.notesMarkdown` temporarily (generic durability) until a pack exists.
|
|
823
|
+
|
|
824
|
+
This preserves determinism, prevents drift, and keeps Studio rendering consistent.
|
|
825
|
+
|
|
826
|
+
### Enforcement
|
|
827
|
+
|
|
828
|
+
When a step declares `output.contractRef`:
|
|
829
|
+
|
|
830
|
+
- On `continue_workflow`, WorkRail validates the contract output.
|
|
831
|
+
- **Blocking modes**: if missing/invalid, return `kind: "blocked"` with structured "missing required output" + example.
|
|
832
|
+
- **Never-stop mode**: if missing/invalid, record critical gap and continue.
|
|
833
|
+
|
|
834
|
+
### Versioning
|
|
835
|
+
|
|
836
|
+
Contract packs are referenced by ID only (no explicit version refs).
|
|
837
|
+
|
|
838
|
+
Versioning is **implicit** via the pinned compiled workflow snapshot (`workflowHash`). The snapshot carries the exact contract schemas resolved at compile time, ensuring deterministic behavior even if packs evolve.
|
|
839
|
+
|
|
840
|
+
## Verify (instructional vs enforceable)
|
|
841
|
+
|
|
842
|
+
The `verify` block (in `promptBlocks`) is **instructional by default**: the agent follows it as a self-check before acknowledging.
|
|
843
|
+
|
|
844
|
+
To make verification **enforceable**, express it as an output contract:
|
|
845
|
+
|
|
846
|
+
```jsonc
|
|
847
|
+
"output": {
|
|
848
|
+
"contractRef": "wr.contracts.verification_report",
|
|
849
|
+
"hints": { ... }
|
|
850
|
+
}
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
Then WorkRail can validate the verification output before advancing.
|
|
854
|
+
|
|
855
|
+
## Divergence markers
|
|
856
|
+
|
|
857
|
+
Agents can report `workflow_divergence` when intentionally deviating from instructions.
|
|
858
|
+
|
|
859
|
+
Divergence is a structured artifact:
|
|
860
|
+
|
|
861
|
+
```jsonc
|
|
862
|
+
{
|
|
863
|
+
"kind": "workflow_divergence",
|
|
864
|
+
"reason": "efficiency_skip", // closed set (WorkRail-owned)
|
|
865
|
+
"summary": "Skipped hypothesis X because ...",
|
|
866
|
+
"relatedStepId": "phase-2"
|
|
867
|
+
}
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
Initial closed set (conceptual; generated from canonical contract pack definitions to prevent drift):
|
|
871
|
+
- `missing_user_context`
|
|
872
|
+
- `capability_unavailable`
|
|
873
|
+
- `efficiency_skip`
|
|
874
|
+
- `safety_stop`
|
|
875
|
+
- `policy_constraint`
|
|
876
|
+
|
|
877
|
+
Studio badges nodes with divergence for auditability.
|
|
878
|
+
|
|
879
|
+
Enforcement: divergence is **optional** (agent reports when applicable); it should not block unless a step explicitly requires it.
|
|
880
|
+
|
|
881
|
+
## Example: complete v2 workflow
|
|
882
|
+
|
|
883
|
+
```jsonc
|
|
884
|
+
{
|
|
885
|
+
"id": "project.bug_investigation_v2",
|
|
886
|
+
"name": "Bug Investigation (v2)",
|
|
887
|
+
"description": "Deterministic, rewind-safe bug investigation with mode-aware ambiguity handling.",
|
|
888
|
+
"agentRole": "You are a senior engineer. Be explicit about assumptions and verification. Follow workflow instructions as the user's process.",
|
|
889
|
+
"capabilities": {
|
|
890
|
+
"delegation": "preferred",
|
|
891
|
+
"web_browsing": "preferred"
|
|
892
|
+
},
|
|
893
|
+
"features": [
|
|
894
|
+
"wr.features.mode_guidance",
|
|
895
|
+
{
|
|
896
|
+
"id": "wr.features.capabilities",
|
|
897
|
+
"config": {
|
|
898
|
+
"probeVisibility": "collapsed",
|
|
899
|
+
"recordObservationsAs": "artifact"
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
],
|
|
903
|
+
"steps": [
|
|
904
|
+
{
|
|
905
|
+
"id": "triage",
|
|
906
|
+
"title": "Triage and focus",
|
|
907
|
+
"promptBlocks": {
|
|
908
|
+
"goal": "Classify scope/risks and choose focus areas for the investigation.",
|
|
909
|
+
"constraints": [
|
|
910
|
+
"Follow the selected mode (guided vs full-auto).",
|
|
911
|
+
"If delegation is unavailable, do sequential passes.",
|
|
912
|
+
"Record a durable recap at the end."
|
|
913
|
+
],
|
|
914
|
+
"procedure": [
|
|
915
|
+
"Summarize the bug in 3 bullets.",
|
|
916
|
+
"List top 3 hypotheses.",
|
|
917
|
+
"Choose 2–4 investigation focus areas."
|
|
918
|
+
],
|
|
919
|
+
"outputRequired": {
|
|
920
|
+
"notesMarkdown": "≤10 lines: scope, hypotheses, focus areas, and what's next."
|
|
921
|
+
},
|
|
922
|
+
"verify": [
|
|
923
|
+
"Hypotheses are testable and mutually distinguishable."
|
|
924
|
+
]
|
|
925
|
+
}
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
"type": "template_call",
|
|
929
|
+
"templateId": "wr.templates.capability_probe",
|
|
930
|
+
"args": {
|
|
931
|
+
"capability": "delegation",
|
|
932
|
+
"when": "lazy_on_first_use"
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
"id": "investigate",
|
|
937
|
+
"title": "Run investigation passes",
|
|
938
|
+
"promptBlocks": {
|
|
939
|
+
"goal": "Test hypotheses via evidence gathering.",
|
|
940
|
+
"constraints": [
|
|
941
|
+
"If delegation is available: run parallel passes; otherwise do sequential passes.",
|
|
942
|
+
"If you intentionally deviate (skip a hypothesis), record a divergence marker."
|
|
943
|
+
],
|
|
944
|
+
"procedure": [
|
|
945
|
+
"For each hypothesis: gather minimal evidence to confirm or falsify.",
|
|
946
|
+
"Record observations durably."
|
|
947
|
+
],
|
|
948
|
+
"outputRequired": {
|
|
949
|
+
"notesMarkdown": "Key observations + updated confidence per hypothesis."
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
"output": {
|
|
953
|
+
"hints": {
|
|
954
|
+
"divergence": "Report if you skip hypotheses or deviate from procedure."
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
"id": "finalize",
|
|
960
|
+
"title": "Finalize root cause",
|
|
961
|
+
"promptBlocks": {
|
|
962
|
+
"goal": "Provide final root cause and recommendations.",
|
|
963
|
+
"procedure": [
|
|
964
|
+
"State the most likely root cause with confidence level.",
|
|
965
|
+
"Propose 2–3 preventative recommendations."
|
|
966
|
+
],
|
|
967
|
+
"outputRequired": {
|
|
968
|
+
"notesMarkdown": "Root cause + recommendations."
|
|
969
|
+
},
|
|
970
|
+
"verify": [
|
|
971
|
+
"Root cause is grounded in observed evidence."
|
|
972
|
+
]
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
]
|
|
976
|
+
}
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
## What happens at compile time
|
|
980
|
+
|
|
981
|
+
WorkRail compiles the source workflow:
|
|
982
|
+
|
|
983
|
+
1) Expands `template_call` steps into their full step sequences (with provenance).
|
|
984
|
+
2) Applies `features` in deterministic order (injects prompt content, adds probe logic, etc.).
|
|
985
|
+
3) Resolves `contractRef` to actual schemas from the contract pack registry.
|
|
986
|
+
4) Validates `references` structurally (unique IDs, non-empty fields).
|
|
987
|
+
5) Renders `promptBlocks` into deterministic text `pending.prompt` strings.
|
|
988
|
+
6) Computes `workflowHash` from the fully expanded canonical model (including reference declarations).
|
|
989
|
+
|
|
990
|
+
## Source vs compiled (Studio)
|
|
991
|
+
|
|
992
|
+
- **Source**: what the author wrote (editable depending on source provenance/namespace).
|
|
993
|
+
- **Compiled**: what WorkRail executes and pins.
|
|
994
|
+
|
|
995
|
+
Studio's compiled view shows:
|
|
996
|
+
- injected steps (collapsed by default, expandable with provenance)
|
|
997
|
+
- effective `agentRole` per step
|
|
998
|
+
- resolved contract schemas
|
|
999
|
+
- rendered `pending.prompt` text
|
|
1000
|
+
|
|
1001
|
+
This makes injection and determinism transparent.
|
|
1002
|
+
|
|
1003
|
+
## Prompt engineering best practices (baked into templates/features)
|
|
1004
|
+
|
|
1005
|
+
WorkRail templates/features should encode:
|
|
1006
|
+
|
|
1007
|
+
- **Instruction clarity**: single clear goal, explicit constraints, prioritized procedure.
|
|
1008
|
+
- **Structured layout**: consistent sections (goal/constraints/procedure/output/verify).
|
|
1009
|
+
- **Role/stance**: appropriate persona per workflow/step.
|
|
1010
|
+
- **Context discipline**: provide only necessary context; avoid bloat.
|
|
1011
|
+
- **Tool-use guidance**: when capabilities matter (delegation/web), include probe + fallback.
|
|
1012
|
+
- **Output format constraints**: explicit schemas via contracts; minimal examples.
|
|
1013
|
+
- **Ambiguity handling**: mode-aware (ask/block vs assume+disclose).
|
|
1014
|
+
- **Verification**: explicit self-check step; optionally enforceable via contracts.
|
|
1015
|
+
- **Error handling as data**: blocked with structured reasons, not vague failures.
|
|
1016
|
+
|
|
1017
|
+
Authors should **rely on templates/features** for repetitive structure rather than hand-rolling best practices in every step.
|
|
1018
|
+
|
|
1019
|
+
## Discoverability
|
|
1020
|
+
|
|
1021
|
+
Builtins (templates/features/contracts/capabilities) should be discoverable via:
|
|
1022
|
+
|
|
1023
|
+
- **Studio Builtins Catalog**: searchable, with copyable snippets and insert actions.
|
|
1024
|
+
- **Contextual autocomplete**: while editing workflows in Studio.
|
|
1025
|
+
- **Validation as suggestions**: "You declared capability X; consider feature Y."
|
|
1026
|
+
|
|
1027
|
+
The catalog is powered by a **generated registry** sourced from the same canonical builtin definitions the compiler uses (to prevent drift).
|
|
1028
|
+
|
|
1029
|
+
See: `docs/design/studio.md` for Studio catalog and autocomplete UX.
|
|
1030
|
+
|
|
1031
|
+
## Anti-patterns (avoid)
|
|
1032
|
+
|
|
1033
|
+
- Assuming WorkRail can control the agent's system prompt (it can't).
|
|
1034
|
+
- Modeling "baseline tools" (file ops, grep, terminal) in workflow capabilities (noise + drift).
|
|
1035
|
+
- Inline schema authoring (use contract pack references instead).
|
|
1036
|
+
- Huge unstructured prompts (use promptBlocks + templates/features for reusable structure).
|
|
1037
|
+
- Silent divergence or assumptions (report via divergence markers/gaps).
|
|
1038
|
+
- Trusting agent-declared capabilities without probe/attempt (WorkRail can't introspect).
|
|
1039
|
+
|
|
1040
|
+
## Related
|
|
1041
|
+
|
|
1042
|
+
- Normative execution protocol: `docs/reference/workflow-execution-contract.md`
|
|
1043
|
+
- Studio UX and catalog: `docs/design/studio.md`
|
|
1044
|
+
- General authoring guide: `docs/authoring.md`
|