@exaudeus/workrail 3.28.0 → 3.30.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.
Files changed (160) hide show
  1. package/dist/console/assets/{index-C146q2kN.js → index-Bl5-Ghuu.js} +1 -1
  2. package/dist/console/index.html +1 -1
  3. package/dist/manifest.json +3 -3
  4. package/docs/README.md +57 -0
  5. package/docs/adrs/001-hybrid-storage-backend.md +38 -0
  6. package/docs/adrs/002-four-layer-context-classification.md +38 -0
  7. package/docs/adrs/003-checkpoint-trigger-strategy.md +35 -0
  8. package/docs/adrs/004-opt-in-encryption-strategy.md +36 -0
  9. package/docs/adrs/005-agent-first-workflow-execution-tokens.md +105 -0
  10. package/docs/adrs/006-append-only-session-run-event-log.md +76 -0
  11. package/docs/adrs/007-resume-and-checkpoint-only-sessions.md +51 -0
  12. package/docs/adrs/008-blocked-nodes-architectural-upgrade.md +178 -0
  13. package/docs/adrs/009-bridge-mode-single-instance-mcp.md +195 -0
  14. package/docs/adrs/010-release-pipeline.md +89 -0
  15. package/docs/architecture/README.md +7 -0
  16. package/docs/architecture/refactor-audit.md +364 -0
  17. package/docs/authoring-v2.md +527 -0
  18. package/docs/authoring.md +873 -0
  19. package/docs/changelog-recent.md +201 -0
  20. package/docs/configuration.md +505 -0
  21. package/docs/ctc-mcp-proposal.md +518 -0
  22. package/docs/design/README.md +22 -0
  23. package/docs/design/agent-cascade-protocol.md +96 -0
  24. package/docs/design/autonomous-console-design-candidates.md +253 -0
  25. package/docs/design/autonomous-console-design-review.md +111 -0
  26. package/docs/design/autonomous-platform-mvp-discovery.md +525 -0
  27. package/docs/design/claude-code-source-deep-dive.md +713 -0
  28. package/docs/design/console-cyberpunk-ui-discovery.md +504 -0
  29. package/docs/design/console-execution-trace-candidates-final.md +160 -0
  30. package/docs/design/console-execution-trace-candidates.md +211 -0
  31. package/docs/design/console-execution-trace-design-candidates-v2.md +113 -0
  32. package/docs/design/console-execution-trace-design-review.md +74 -0
  33. package/docs/design/console-execution-trace-discovery.md +394 -0
  34. package/docs/design/console-execution-trace-final-review.md +77 -0
  35. package/docs/design/console-execution-trace-review.md +92 -0
  36. package/docs/design/console-performance-discovery.md +415 -0
  37. package/docs/design/console-ui-backlog.md +280 -0
  38. package/docs/design/daemon-architecture-discovery.md +853 -0
  39. package/docs/design/daemon-design-candidates.md +318 -0
  40. package/docs/design/daemon-design-review-findings.md +119 -0
  41. package/docs/design/daemon-engine-design-candidates.md +210 -0
  42. package/docs/design/daemon-engine-design-review.md +131 -0
  43. package/docs/design/daemon-execution-engine-discovery.md +280 -0
  44. package/docs/design/daemon-gap-analysis.md +554 -0
  45. package/docs/design/daemon-owns-console-plan.md +168 -0
  46. package/docs/design/daemon-owns-console-review.md +91 -0
  47. package/docs/design/daemon-owns-console.md +195 -0
  48. package/docs/design/data-model-erd.md +11 -0
  49. package/docs/design/design-candidates-consolidate-dev-staleness.md +98 -0
  50. package/docs/design/design-candidates-walk-cache-depth-limit.md +80 -0
  51. package/docs/design/design-review-consolidate-dev-staleness.md +54 -0
  52. package/docs/design/design-review-walk-cache-depth-limit.md +48 -0
  53. package/docs/design/implementation-plan-consolidate-dev-staleness.md +142 -0
  54. package/docs/design/implementation-plan-walk-cache-depth-limit.md +141 -0
  55. package/docs/design/layer3b-ghost-nodes-design-candidates.md +229 -0
  56. package/docs/design/layer3b-ghost-nodes-design-review.md +93 -0
  57. package/docs/design/layer3b-ghost-nodes-implementation-plan.md +219 -0
  58. package/docs/design/list-workflows-latency-fix-plan.md +128 -0
  59. package/docs/design/list-workflows-latency-fix-review.md +55 -0
  60. package/docs/design/list-workflows-latency-fix.md +109 -0
  61. package/docs/design/native-context-management-api.md +11 -0
  62. package/docs/design/performance-sweep-2026-04.md +96 -0
  63. package/docs/design/routines-guide.md +219 -0
  64. package/docs/design/sequence-diagrams.md +11 -0
  65. package/docs/design/subagent-design-principles.md +220 -0
  66. package/docs/design/temporal-patterns-design-candidates.md +312 -0
  67. package/docs/design/temporal-patterns-design-review-findings.md +163 -0
  68. package/docs/design/test-isolation-from-config-file.md +335 -0
  69. package/docs/design/v2-core-design-locks.md +2746 -0
  70. package/docs/design/v2-lock-registry.json +734 -0
  71. package/docs/design/workflow-authoring-v2.md +1044 -0
  72. package/docs/design/workflow-docs-spec.md +218 -0
  73. package/docs/design/workflow-extension-points.md +687 -0
  74. package/docs/design/workrail-auto-trigger-system.md +359 -0
  75. package/docs/design/workrail-config-file-discovery.md +513 -0
  76. package/docs/docker.md +110 -0
  77. package/docs/generated/v2-lock-closure-plan.md +26 -0
  78. package/docs/generated/v2-lock-coverage.json +797 -0
  79. package/docs/generated/v2-lock-coverage.md +177 -0
  80. package/docs/ideas/backlog.md +3927 -0
  81. package/docs/ideas/design-candidates-mcp-resilience.md +208 -0
  82. package/docs/ideas/design-review-findings-mcp-resilience.md +119 -0
  83. package/docs/ideas/implementation_plan.md +249 -0
  84. package/docs/ideas/third-party-workflow-setup-design-thinking.md +1948 -0
  85. package/docs/implementation/02-architecture.md +316 -0
  86. package/docs/implementation/04-testing-strategy.md +124 -0
  87. package/docs/implementation/09-simple-workflow-guide.md +835 -0
  88. package/docs/implementation/13-advanced-validation-guide.md +874 -0
  89. package/docs/implementation/README.md +21 -0
  90. package/docs/integrations/claude-code.md +300 -0
  91. package/docs/integrations/firebender.md +315 -0
  92. package/docs/migration/v0.1.0.md +147 -0
  93. package/docs/naming-conventions.md +45 -0
  94. package/docs/planning/README.md +104 -0
  95. package/docs/planning/github-ticketing-playbook.md +195 -0
  96. package/docs/plans/README.md +24 -0
  97. package/docs/plans/agent-managed-ticketing-design.md +605 -0
  98. package/docs/plans/agentic-orchestration-roadmap.md +112 -0
  99. package/docs/plans/assessment-gates-engine-handoff.md +536 -0
  100. package/docs/plans/content-coherence-and-references.md +151 -0
  101. package/docs/plans/library-extraction-plan.md +340 -0
  102. package/docs/plans/mr-review-workflow-redesign.md +1451 -0
  103. package/docs/plans/native-context-management-epic.md +11 -0
  104. package/docs/plans/perf-fixes-design-candidates.md +225 -0
  105. package/docs/plans/perf-fixes-design-review-findings.md +61 -0
  106. package/docs/plans/perf-fixes-new-issues-candidates.md +264 -0
  107. package/docs/plans/perf-fixes-new-issues-review.md +110 -0
  108. package/docs/plans/prompt-fragments.md +53 -0
  109. package/docs/plans/ui-ux-workflow-design-candidates.md +120 -0
  110. package/docs/plans/ui-ux-workflow-discovery.md +100 -0
  111. package/docs/plans/ui-ux-workflow-review.md +48 -0
  112. package/docs/plans/v2-followup-enhancements.md +587 -0
  113. package/docs/plans/workflow-categories-candidates.md +105 -0
  114. package/docs/plans/workflow-categories-discovery.md +110 -0
  115. package/docs/plans/workflow-categories-review.md +51 -0
  116. package/docs/plans/workflow-discovery-model-candidates.md +94 -0
  117. package/docs/plans/workflow-discovery-model-discovery.md +74 -0
  118. package/docs/plans/workflow-discovery-model-review.md +48 -0
  119. package/docs/plans/workflow-source-setup-phase-1.md +245 -0
  120. package/docs/plans/workflow-source-setup-phase-2.md +361 -0
  121. package/docs/plans/workflow-staleness-detection-candidates.md +104 -0
  122. package/docs/plans/workflow-staleness-detection-review.md +58 -0
  123. package/docs/plans/workflow-staleness-detection.md +80 -0
  124. package/docs/plans/workflow-v2-design.md +69 -0
  125. package/docs/plans/workflow-v2-roadmap.md +74 -0
  126. package/docs/plans/workflow-validation-design.md +98 -0
  127. package/docs/plans/workflow-validation-roadmap.md +108 -0
  128. package/docs/plans/workrail-platform-vision.md +420 -0
  129. package/docs/reference/agent-context-cleaner-snippet.md +94 -0
  130. package/docs/reference/agent-context-guidance.md +140 -0
  131. package/docs/reference/context-optimization.md +284 -0
  132. package/docs/reference/example-workflow-repository-template/.github/workflows/validate.yml +125 -0
  133. package/docs/reference/example-workflow-repository-template/README.md +268 -0
  134. package/docs/reference/example-workflow-repository-template/workflows/example-workflow.json +80 -0
  135. package/docs/reference/external-workflow-repositories.md +916 -0
  136. package/docs/reference/feature-flags-architecture.md +472 -0
  137. package/docs/reference/feature-flags.md +349 -0
  138. package/docs/reference/god-tier-workflow-validation.md +272 -0
  139. package/docs/reference/loop-optimization.md +209 -0
  140. package/docs/reference/loop-validation.md +176 -0
  141. package/docs/reference/loops.md +465 -0
  142. package/docs/reference/mcp-platform-constraints.md +59 -0
  143. package/docs/reference/recovery.md +88 -0
  144. package/docs/reference/releases.md +177 -0
  145. package/docs/reference/troubleshooting.md +105 -0
  146. package/docs/reference/workflow-execution-contract.md +998 -0
  147. package/docs/roadmap/README.md +22 -0
  148. package/docs/roadmap/legacy-planning-status.md +103 -0
  149. package/docs/roadmap/now-next-later.md +70 -0
  150. package/docs/roadmap/open-work-inventory.md +389 -0
  151. package/docs/tickets/README.md +39 -0
  152. package/docs/tickets/next-up.md +76 -0
  153. package/docs/workflow-management.md +317 -0
  154. package/docs/workflow-templates.md +423 -0
  155. package/docs/workflow-validation.md +184 -0
  156. package/docs/workflows.md +254 -0
  157. package/package.json +4 -1
  158. package/spec/authoring-spec.json +61 -16
  159. package/workflows/workflow-for-workflows.json +3 -3
  160. package/workflows/workflow-for-workflows.v2.json +3 -3
@@ -0,0 +1,687 @@
1
+ # Workflow Extension Points — Bounded Composability for User-Authored Phase Implementations
2
+
3
+ ## Problem
4
+
5
+ WorkRail workflows are most valuable when they are both:
6
+
7
+ - **opinionated** enough to encode strong defaults and best practices
8
+ - **customizable** enough for users and teams to inject their own process where it matters
9
+
10
+ Today, customization often means:
11
+
12
+ - cloning a large workflow
13
+ - editing many unrelated steps
14
+ - drifting away from upstream improvements
15
+ - losing the safety and consistency of the original orchestration
16
+
17
+ That is a poor tradeoff. Users should not need to fork a full task-dev workflow just to customize:
18
+
19
+ - design review
20
+ - planning
21
+ - final verification
22
+ - a domain-specific review phase
23
+
24
+ ## Goal
25
+
26
+ Allow a parent workflow to expose **bounded extension points** where a user can provide a compatible workflow or routine implementation.
27
+
28
+ The parent workflow should still own:
29
+
30
+ - overall sequencing
31
+ - confirmation policy
32
+ - loop control
33
+ - context model
34
+ - final decisions
35
+ - safety boundaries
36
+
37
+ The extension implementation should own only a **bounded cognitive unit**.
38
+
39
+ ## Non-goals
40
+
41
+ This is **not**:
42
+
43
+ - arbitrary nested workflow execution
44
+ - unrestricted recursion
45
+ - child workflows mutating parent state freely
46
+ - user-defined replacements for the entire parent orchestration
47
+ - a mechanism to bypass parent safety or confirmation behavior
48
+
49
+ ## Better framing
50
+
51
+ The right mental model is not:
52
+
53
+ - "a workflow can run another workflow"
54
+
55
+ The better model is:
56
+
57
+ - **the parent workflow defines extension points**
58
+ - **the user provides a compatible phase implementation**
59
+
60
+ This is closer to:
61
+
62
+ - pluggable cognitive modules
63
+ - strategy selection for bounded phases
64
+ - user-authored phase implementations
65
+
66
+ ## Core idea
67
+
68
+ A parent workflow can declare one or more **extension slots**. Each slot has:
69
+
70
+ - a stable identifier
71
+ - a purpose
72
+ - an input contract
73
+ - an output contract
74
+ - allowed implementation kinds
75
+ - guardrails
76
+
77
+ Example slots in a task-dev workflow:
78
+
79
+ - `design_generation`
80
+ - `design_review`
81
+ - `plan_audit`
82
+ - `final_verification`
83
+
84
+ The parent can then say:
85
+
86
+ - use the default implementation
87
+ - or use a user-supplied compatible implementation
88
+
89
+ ## Why this is powerful
90
+
91
+ This unlocks:
92
+
93
+ - **safe customization without forking**
94
+ - **team-specific process modules**
95
+ - **domain-specific cognitive steps**
96
+ - **better reuse across workflows**
97
+ - **faster experimentation**
98
+ - **shared orchestration with custom policy**
99
+
100
+ Instead of copying a 300-line workflow just to change one phase, a user could say:
101
+
102
+ - use my architecture review for `design_review`
103
+ - use my release-readiness verifier for `final_verification`
104
+ - use my migration planner for `plan_audit`
105
+
106
+ ## Parent-child responsibility split
107
+
108
+ ### Parent workflow owns
109
+
110
+ - the order of phases
111
+ - whether a slot is invoked
112
+ - whether QUICK / STANDARD / THOROUGH changes behavior
113
+ - confirmation and user pauses
114
+ - loop decisions
115
+ - synthesis into canonical workflow state
116
+ - final go/no-go decisions
117
+
118
+ ### Child implementation owns
119
+
120
+ - the bounded internal reasoning for that phase
121
+ - the artifact or structured output promised by the slot contract
122
+ - the internal step sequence of the phase implementation
123
+
124
+ ### Important rule
125
+
126
+ The child produces **evidence and recommendations**.
127
+
128
+ The parent still interprets the result and decides what to do next.
129
+
130
+ ## When to expose an extension point
131
+
132
+ Extension points are powerful, but they should stay **bounded and high-value**.
133
+
134
+ A slot earns its place when customization would materially improve one of these:
135
+
136
+ - domain-specific judgment
137
+ - team-specific policy or philosophy alignment
138
+ - final verification quality
139
+ - reusable review/generation policy that multiple teams may want to swap
140
+
141
+ Avoid creating slots for:
142
+
143
+ - generic utility delegations
144
+ - low-value one-off steps
145
+ - phases where the parent should obviously keep full ownership with no meaningful team variation
146
+
147
+ Good default rule:
148
+
149
+ - expose customization where teams genuinely differ
150
+ - keep utility cognition hardcoded where variation would mostly add complexity
151
+
152
+ Examples:
153
+
154
+ - **good slot**: `final_verification`, where teams may want different release/readiness standards
155
+ - **good slot**: `philosophy_review`, where repo-specific principles genuinely vary
156
+ - **bad slot**: generic capability probing, because the variation is low and the utility behavior should stay standardized
157
+ - **bad slot**: parent loop decision logic, because parent-owned control flow should remain canonical
158
+
159
+ ## Structured freedom at the extension boundary
160
+
161
+ Extension points should preserve the same balance as the parent workflow:
162
+
163
+ - **rigid on contracts and parent-owned control flow**
164
+ - **adaptive inside the bounded child implementation**
165
+
166
+ That means:
167
+
168
+ - the parent owns sequencing, loop control, canonical synthesis, and final decisions
169
+ - the child owns bounded reasoning inside the slot contract
170
+ - the child returns evidence/recommendations, not parent workflow truth
171
+
172
+ ## Extension point declaration
173
+
174
+ The parent workflow declares extension points as a top-level field alongside `steps`:
175
+
176
+ ```json
177
+ {
178
+ "id": "coding-task-workflow-agentic",
179
+ "version": "2.2.0",
180
+ "extensionPoints": {
181
+ "design_review": {
182
+ "purpose": "Review a selected design for tradeoff quality, failure modes, simpler alternatives, and philosophy alignment.",
183
+ "defaultBinding": "routine-design-review",
184
+ "acceptedKinds": ["routine", "workflow"],
185
+ "inputContract": {
186
+ "requiredContext": ["selectedApproach", "acceptedTradeoffs", "identifiedFailureModes"],
187
+ "optionalContext": ["runnerUpApproach", "philosophySources"]
188
+ },
189
+ "outputContract": {
190
+ "requiredArtifacts": ["design-review-findings.md"]
191
+ }
192
+ },
193
+ "plan_audit": {
194
+ "purpose": "Audit implementation plan for completeness, risk, and philosophy alignment.",
195
+ "defaultBinding": "routine-plan-analysis",
196
+ "acceptedKinds": ["routine", "workflow"],
197
+ "inputContract": {
198
+ "requiredContext": ["implementationPlan", "slices", "invariants"],
199
+ "optionalContext": ["philosophySources"]
200
+ },
201
+ "outputContract": {
202
+ "requiredArtifacts": ["plan-audit-findings.md"]
203
+ }
204
+ },
205
+ "final_verification": {
206
+ "purpose": "Verify implementation against acceptance criteria, invariants, and philosophy.",
207
+ "defaultBinding": "routine-final-verification",
208
+ "acceptedKinds": ["routine", "workflow"],
209
+ "inputContract": {
210
+ "requiredContext": ["implementationPlan", "acceptanceCriteria", "invariants"],
211
+ "optionalContext": ["philosophySources"]
212
+ },
213
+ "outputContract": {
214
+ "requiredArtifacts": ["final-verification-findings.md"]
215
+ }
216
+ }
217
+ },
218
+ "steps": []
219
+ }
220
+ ```
221
+
222
+ Each extension point has:
223
+
224
+ - a stable key used as the slot identifier
225
+ - a `purpose` describing the cognitive role
226
+ - a `defaultBinding` pointing to the built-in routine/workflow
227
+ - `acceptedKinds` constraining what can fill the slot
228
+ - `inputContract` declaring what context the implementation receives
229
+ - `outputContract` declaring what the implementation must produce
230
+
231
+ ## Child compatibility declaration
232
+
233
+ A routine or workflow declares what it accepts and produces using an `extensionContract` field:
234
+
235
+ ```json
236
+ {
237
+ "id": "my-team-security-review",
238
+ "kind": "routine",
239
+ "extensionContract": {
240
+ "accepts": ["selectedApproach", "acceptedTradeoffs", "identifiedFailureModes"],
241
+ "produces": ["design-review-findings.md"]
242
+ },
243
+ "steps": []
244
+ }
245
+ ```
246
+
247
+ The compiler validates structurally:
248
+
249
+ - the child's `accepts` includes all `requiredContext` from the slot's `inputContract`
250
+ - the child's `produces` includes all `requiredArtifacts` from the slot's `outputContract`
251
+ - the child's kind matches `acceptedKinds`
252
+
253
+ Compatibility is determined by contract structure, not by slot name. A child that accepts the right inputs and produces the right outputs is compatible with any slot whose contract it satisfies -- without knowing the slot's name.
254
+
255
+ This means a security review routine is reusable across any parent workflow that exposes a slot with the same contract, regardless of what that slot is called. The user's binding config is the intent signal; the contract is the safety check.
256
+
257
+ A child without `extensionContract` cannot be bound to any extension point.
258
+
259
+ ## Compiler integration
260
+
261
+ Extension point bindings are resolved at compile time through the existing ref resolution pass.
262
+
263
+ ### Why not step-level fields
264
+
265
+ Workflows reference routines by name in prompt prose, often across multiple steps. A single `extensionPoint` field on one step is insufficient. For example, `design_review` logic is referenced in Phase 1 (architecture decision), Phase 2 (design review loop), and Phase 2's delegation instructions.
266
+
267
+ ### Binding refs
268
+
269
+ The compiler resolves binding references using a new ref kind: `wr.bindings.<slotId>`.
270
+
271
+ Workflow authors use these refs in prompt text instead of hardcoding routine names:
272
+
273
+ ```
274
+ spawn ONE WorkRail Executor running `{{wr.bindings.design_review}}`
275
+ ```
276
+
277
+ The compiler replaces these refs with the resolved routine/workflow ID during the existing `resolveRefsPass`. This means:
278
+
279
+ - binding resolution is global (works across all steps)
280
+ - resolved bindings are automatically included in the compiled hash
281
+ - no new compiler infrastructure is needed beyond a new ref kind in `ref-registry.ts`
282
+
283
+ ### What extension points are not
284
+
285
+ Extension points are **not** a routine-injection mechanism.
286
+
287
+ - They do **not** expand a child routine into inline parent steps.
288
+ - They do **not** create step-level visibility, confirmation behavior, or session traceability for the child implementation.
289
+ - They do **not** currently choose which routine a `templateCall` injects, because template expansion happens before binding resolution.
290
+
291
+ If the parent workflow wants reusable inline structure, use **`templateCall`** instead.
292
+ Use extension points only when the seam is intentionally delegated and the delegated implementation should remain swappable per project.
293
+
294
+ ### What is rebindable
295
+
296
+ Only routines/workflows listed in `extensionPoints` are rebindable. All other routine references (e.g., `routine-context-gathering`, `routine-execution-simulation`) remain hardcoded. The distinction between extension points and utility delegations must be explicit.
297
+
298
+ ## Implementation kinds
299
+
300
+ ### 1. Routine implementation
301
+
302
+ Best for:
303
+
304
+ - reusable bounded cognitive units
305
+ - lightweight, reusable, well-scoped review/generation tasks
306
+
307
+ Examples:
308
+
309
+ - `routine-design-review`
310
+ - `routine-final-verification`
311
+ - `routine-tension-driven-design`
312
+
313
+ ### 2. Workflow implementation
314
+
315
+ Best for:
316
+
317
+ - user-authored multi-step variants with richer internal structure
318
+ - team-specific process modules
319
+ - domain-specific quality bars that exceed a routine’s scope
320
+
321
+ These should still be **bounded by the slot contract** and should not be allowed to take over parent orchestration.
322
+
323
+ ## Guardrails
324
+
325
+ To make this safe, the engine should enforce:
326
+
327
+ ### Contract compatibility
328
+
329
+ Before composition:
330
+
331
+ - validate required inputs are available
332
+ - validate the child declares compatibility with the slot
333
+ - validate required outputs are produced
334
+
335
+ ### No arbitrary state mutation
336
+
337
+ The child should not write arbitrary parent context.
338
+
339
+ It should only be allowed to:
340
+
341
+ - emit declared artifacts
342
+ - optionally emit declared slot-scoped outputs
343
+
344
+ The parent then maps those outputs into workflow-owned decisions.
345
+
346
+ ### No uncontrolled loops
347
+
348
+ The child implementation may have internal loops, but:
349
+
350
+ - loop behavior must remain inside the child boundary
351
+ - parent loop control remains parent-owned
352
+ - the child must not alter parent loop policy
353
+
354
+ ### No recursive chaos
355
+
356
+ At minimum:
357
+
358
+ - prevent cycles
359
+ - prevent unbounded nested composition
360
+ - cap depth of composed implementations
361
+
362
+ The safe default is to keep composition depth shallow.
363
+
364
+ ### Loop correctness
365
+
366
+ When a custom implementation fills a slot inside a loop body, it must honor the loop control contract. The custom implementation must not:
367
+
368
+ - produce artifacts that confuse the loop decision step
369
+ - break loop exit conditions
370
+ - emit loop control artifacts that the parent doesn't expect
371
+
372
+ The parent's loop decision step remains the sole authority on whether to continue or exit.
373
+
374
+ ### Error handling and fallback
375
+
376
+ When a custom implementation fails (crashes, times out, or produces output that doesn't satisfy the output contract):
377
+
378
+ 1. Log the failure with full context (slot ID, bound implementation, error)
379
+ 2. Fall back to the slot's default implementation
380
+ 3. Mark the fallback in provenance: `"design_review: fallback-to-default (original failed)"`
381
+ 4. Continue parent workflow execution
382
+
383
+ The parent workflow must not crash because a child implementation failed. Fallback-to-default is the safe default policy.
384
+
385
+ ### Parent confirmation policy wins
386
+
387
+ Child implementations should not be able to unexpectedly introduce:
388
+
389
+ - extra user pauses
390
+ - extra merges/pushes/commits
391
+ - parent-level confirmation gates
392
+
393
+ Those remain parent-owned.
394
+
395
+ ## Determinism and hashing
396
+
397
+ Compiled workflow identity must include:
398
+
399
+ - the parent workflow
400
+ - the selected implementation for each slot
401
+ - the compiled child content
402
+
403
+ Changing a child implementation must change the compiled hash of any parent workflow that uses it.
404
+
405
+ The compiled workflow should include a **binding manifest**:
406
+
407
+ ```json
408
+ {
409
+ "bindingManifest": {
410
+ "design_review": {
411
+ "resolvedTo": "my-team-security-review",
412
+ "source": "project-config",
413
+ "kind": "routine",
414
+ "hash": "sha256:abc123..."
415
+ },
416
+ "plan_audit": {
417
+ "resolvedTo": "routine-plan-analysis",
418
+ "source": "default",
419
+ "kind": "routine",
420
+ "hash": "sha256:def456..."
421
+ }
422
+ }
423
+ }
424
+ ```
425
+
426
+ This is required for:
427
+
428
+ - determinism
429
+ - reproducibility
430
+ - provenance
431
+ - debugging
432
+
433
+ ### Session resumption
434
+
435
+ The binding manifest must be part of the session snapshot. When a workflow session is resumed (cross-chat), the bindings that were active at checkpoint time must be restored exactly. The resumed session must not silently pick up different bindings from a changed project config.
436
+
437
+ ## Visibility and provenance
438
+
439
+ Users and agents should be able to see:
440
+
441
+ - which extension slots were active
442
+ - which implementation filled each slot
443
+ - whether it was a routine or workflow
444
+ - where it came from
445
+ - what hash/version was used
446
+
447
+ Without this, debugging becomes too opaque.
448
+
449
+ ## UX model
450
+
451
+ The user experience should feel like:
452
+
453
+ - "Use `coding-task-workflow-agentic`"
454
+ - "For `design_review`, use `my-team-security-review`"
455
+
456
+ Not:
457
+
458
+ - "Build a deeply nested workflow graph manually"
459
+
460
+ The system should support:
461
+
462
+ - defaults
463
+ - project-scoped overrides
464
+ - user-provided implementations
465
+ - explicit per-run overrides
466
+
467
+ ### Configuration format
468
+
469
+ Project-level overrides live in `.workrail/bindings.json`:
470
+
471
+ ```json
472
+ {
473
+ "coding-task-workflow-agentic": {
474
+ "design_review": "my-team-security-review",
475
+ "final_verification": "workflow-release-readiness-review"
476
+ }
477
+ }
478
+ ```
479
+
480
+ Per-run overrides via CLI:
481
+
482
+ ```bash
483
+ workrail start coding-task-workflow-agentic \
484
+ --bind design_review=my-team-security-review
485
+ ```
486
+
487
+ ### Resolution order
488
+
489
+ 1. CLI `--bind` override (highest priority)
490
+ 2. `.workrail/bindings.json` project config
491
+ 3. `extensionPoints[slot].defaultBinding` in workflow JSON (lowest priority)
492
+
493
+ ### Discoverability
494
+
495
+ `workrail inspect --extension-points <workflow-id>` should show:
496
+
497
+ - all declared extension slots
498
+ - each slot's purpose and contract
499
+ - the currently active binding and its resolution source
500
+ - whether the binding is default or overridden
501
+
502
+ ## Suggested first version
503
+
504
+ Start narrow.
505
+
506
+ Support only a small set of extension slots in a parent workflow:
507
+
508
+ - `design_review`
509
+ - `plan_audit`
510
+ - `final_verification`
511
+
512
+ Why these first:
513
+
514
+ - naturally bounded
515
+ - high customization value
516
+ - low orchestration risk
517
+ - already close to routine-shaped in task-dev workflows
518
+
519
+ Avoid starting with:
520
+
521
+ - full implementation phases
522
+ - parent workflow replacement
523
+ - arbitrary slot definitions everywhere
524
+
525
+ ## Relation to routines and injection
526
+
527
+ This builds directly on the existing routine model:
528
+
529
+ - routines remain the default reusable bounded implementations
530
+ - injection remains a valid way to inline a known implementation
531
+ - delegation remains valid when parallelism is desired
532
+
533
+ What changes is that the **implementation for a slot becomes configurable**.
534
+
535
+ So the parent is no longer hardcoded to one routine or one inline prompt.
536
+
537
+ It is bound to:
538
+
539
+ - a slot
540
+ - a contract
541
+ - a selected compatible implementation
542
+
543
+ ## Example (end-to-end)
544
+
545
+ ### 1. Parent workflow declares the slot and uses a binding ref
546
+
547
+ In the parent workflow JSON:
548
+
549
+ ```json
550
+ {
551
+ "extensionPoints": {
552
+ "final_verification": {
553
+ "purpose": "Verify implementation against acceptance criteria, invariants, and philosophy.",
554
+ "defaultBinding": "routine-final-verification",
555
+ "acceptedKinds": ["routine", "workflow"],
556
+ "inputContract": {
557
+ "requiredContext": ["implementationPlan", "acceptanceCriteria", "invariants"]
558
+ },
559
+ "outputContract": {
560
+ "requiredArtifacts": ["final-verification-findings.md"]
561
+ }
562
+ }
563
+ },
564
+ "steps": [
565
+ {
566
+ "id": "phase-7a-verify-and-fix",
567
+ "title": "Verify Integration and Fix Issues",
568
+ "prompt": "Perform integration verification.\n\nDelegate to `{{wr.bindings.final_verification}}` for the core verification pass.\n\nInterpret the findings artifact and decide whether to fix, re-verify, or hand off."
569
+ }
570
+ ]
571
+ }
572
+ ```
573
+
574
+ ### 2. User provides a custom implementation that declares its contract
575
+
576
+ ```json
577
+ {
578
+ "id": "workflow-release-readiness-review",
579
+ "kind": "workflow",
580
+ "extensionContract": {
581
+ "accepts": ["implementationPlan", "acceptanceCriteria", "invariants"],
582
+ "produces": ["final-verification-findings.md"]
583
+ },
584
+ "steps": []
585
+ }
586
+ ```
587
+
588
+ ### 3. User configures the binding
589
+
590
+ In `.workrail/bindings.json`:
591
+
592
+ ```json
593
+ {
594
+ "coding-task-workflow-agentic": {
595
+ "final_verification": "workflow-release-readiness-review"
596
+ }
597
+ }
598
+ ```
599
+
600
+ ### 4. Compiler resolves the binding
601
+
602
+ The compiler:
603
+
604
+ 1. Loads `extensionPoints` from the parent workflow
605
+ 2. Resolves `final_verification` to `workflow-release-readiness-review` (from project config)
606
+ 3. Validates that `workflow-release-readiness-review` has an `extensionContract` whose `accepts` covers the slot's `requiredContext` and whose `produces` covers the slot's `requiredArtifacts`
607
+ 4. Validates that its kind (`workflow`) matches `acceptedKinds`
608
+ 5. Replaces `{{wr.bindings.final_verification}}` with `workflow-release-readiness-review` in all prompt text
609
+ 6. Includes the resolved binding in the binding manifest and compiled hash
610
+
611
+ ### 5. Runtime
612
+
613
+ At runtime, the agent reads the compiled prompt which now says:
614
+
615
+ > "Delegate to `workflow-release-readiness-review` for the core verification pass."
616
+
617
+ The agent delegates via the WorkRail Executor as it would for any routine or workflow. No runtime changes are needed. Extension point resolution is entirely a compile-time concern.
618
+
619
+ ### 6. Parent interprets the result
620
+
621
+ The parent workflow:
622
+
623
+ - receives `final-verification-findings.md` from the child
624
+ - interprets the findings
625
+ - decides whether to fix, re-verify, or hand off
626
+
627
+ The child does not own the final workflow decision.
628
+
629
+ ## Risks
630
+
631
+ ### 1. Hidden behavior
632
+
633
+ If it becomes hard to see which implementation is active, users lose trust.
634
+
635
+ ### 2. State drift
636
+
637
+ If outputs are not tightly contracted, parent assumptions break.
638
+
639
+ ### 3. Over-composition
640
+
641
+ Too many extension points make workflows hard to reason about.
642
+
643
+ ### 4. User-authored child workflows breaking invariants
644
+
645
+ Compatibility must be validated, not trusted.
646
+
647
+ ## Design principle
648
+
649
+ The system should optimize for:
650
+
651
+ - **bounded composability**
652
+ - **parent-owned orchestration**
653
+ - **typed contracts**
654
+ - **visible provenance**
655
+
656
+ It should avoid:
657
+
658
+ - arbitrary workflow nesting
659
+ - unconstrained child behavior
660
+ - hidden state sharing
661
+
662
+ ## Recommended terminology
663
+
664
+ Prefer:
665
+
666
+ - **workflow extension points**
667
+ - **phase implementations**
668
+ - **pluggable cognitive modules**
669
+
670
+ Avoid centering the concept around:
671
+
672
+ - nested workflows
673
+ - workflow running workflow
674
+
675
+ The bounded phase implementation framing leads to a better system design.
676
+
677
+ ## Suggested next steps
678
+
679
+ 1. Register `wr.bindings.*` as a new ref kind in `ref-registry.ts`
680
+ 2. Add `extensionPoints` parsing to the workflow definition schema
681
+ 3. Implement binding resolution in `resolveRefsPass` (global, across all steps)
682
+ 4. Add `.workrail/bindings.json` loading and resolution chain (CLI > project > default)
683
+ 5. Include binding manifest in compiled workflow hash and session snapshot
684
+ 6. Add `workrail inspect --extension-points` command
685
+ 7. Convert `coding-task-workflow-agentic` prompt text to use `{{wr.bindings.*}}` refs for the initial 3 slots
686
+ 8. Add slot compatibility metadata to routines/workflows
687
+ 9. Implement contract validation (required inputs available, required outputs produced)