@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.
Files changed (160) hide show
  1. package/dist/console/assets/{index-FtTaDku8.js → index-BZ6HkxGf.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 +3 -1
  158. package/spec/authoring-spec.json +61 -16
  159. package/workflows/workflow-for-workflows.json +252 -93
  160. package/workflows/workflow-for-workflows.v2.json +188 -77
@@ -0,0 +1,209 @@
1
+ # Loop Context Optimization
2
+
3
+ ## Overview
4
+
5
+ WorkRail v0.2.0 introduces significant optimizations for loop execution, reducing context size by 60-80% during loop iterations. This feature implements a progressive disclosure pattern where the first iteration receives full context and subsequent iterations receive minimal, optimized context.
6
+
7
+ ## Key Features
8
+
9
+ ### 1. Progressive Context Disclosure
10
+
11
+ - **First Iteration**: Receives complete loop overview including:
12
+ - Full phase information
13
+ - All loop metadata
14
+ - Function definitions
15
+ - Complete array data for forEach loops
16
+
17
+ - **Subsequent Iterations**: Receive minimal context with:
18
+ - Current iteration number
19
+ - Current item only (for forEach loops)
20
+ - Reference to phase overview from first iteration
21
+ - Stripped metadata and large arrays
22
+
23
+ ### 2. Empty Loop Detection
24
+
25
+ Loops with no items to process are automatically skipped, avoiding unnecessary phase overview generation:
26
+
27
+ ```typescript
28
+ // These loops will be skipped entirely:
29
+ { type: 'forEach', items: 'emptyArray' } // where emptyArray = []
30
+ { type: 'for', count: 0 }
31
+ { type: 'while', condition: { var: 'flag', equals: false } } // where flag = false
32
+ ```
33
+
34
+ ### 3. Function DSL Support
35
+
36
+ The schema now natively supports function definitions at multiple scopes:
37
+
38
+ ```json
39
+ {
40
+ "functionDefinitions": [
41
+ {
42
+ "name": "validateItem",
43
+ "definition": "Validates item format and returns boolean",
44
+ "scope": "workflow"
45
+ }
46
+ ],
47
+ "steps": [{
48
+ "id": "process-loop",
49
+ "type": "loop",
50
+ "functionDefinitions": [
51
+ {
52
+ "name": "processSpecific",
53
+ "definition": "Process items in this loop context",
54
+ "scope": "loop"
55
+ }
56
+ ],
57
+ "body": {
58
+ "id": "use-functions",
59
+ "prompt": "Apply validation",
60
+ "functionReferences": ["validateItem()", "processSpecific()"]
61
+ }
62
+ }]
63
+ }
64
+ ```
65
+
66
+ ## Implementation Details
67
+
68
+ ### Architecture
69
+
70
+ The optimization is implemented through:
71
+
72
+ 1. **LoopContextOptimizer Service**: Instance-based service following DI pattern
73
+ 2. **Enhanced LoopExecutionContext**: Supports minimal context generation
74
+ 3. **Modified WorkflowService**: Integrates optimization into main flow
75
+
76
+ ### Context Size Reduction
77
+
78
+ Example context transformation:
79
+
80
+ **First Iteration (Full Context)**:
81
+ ```json
82
+ {
83
+ "dataItems": [/* 1000 items */],
84
+ "currentDataItem": { "id": "item-0" },
85
+ "itemIndex": 0,
86
+ "_currentLoop": {
87
+ "loopId": "process-loop",
88
+ "loopStep": { /* full step definition */ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Second Iteration (Optimized Context)**:
94
+ ```json
95
+ {
96
+ "currentDataItem": { "id": "item-1" },
97
+ "itemIndex": 1,
98
+ "_currentLoop": {
99
+ "loopId": "process-loop",
100
+ "loopType": "forEach",
101
+ "iteration": 1,
102
+ "phaseReference": {
103
+ "loopId": "process-loop",
104
+ "phaseTitle": "Process Items Loop",
105
+ "totalSteps": 2
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ ## Usage Guidelines
112
+
113
+ ### For Workflow Authors
114
+
115
+ 1. **Define Function DSL** at appropriate scopes:
116
+ - Workflow level: Shared across all steps
117
+ - Loop level: Available within loop body
118
+ - Step level: Specific to that step
119
+
120
+ 2. **Use Function References** in step prompts:
121
+ ```json
122
+ {
123
+ "prompt": "Process item using validateItem() and formatOutput()",
124
+ "functionReferences": ["validateItem()", "formatOutput()"]
125
+ }
126
+ ```
127
+
128
+ 3. **Consider Loop Size** when designing workflows:
129
+ - Large arrays benefit most from optimization
130
+ - Nested loops see compounded benefits
131
+
132
+ ### For Agents
133
+
134
+ When processing optimized loops:
135
+
136
+ 1. **First Iteration**: Store phase overview information for reference
137
+ 2. **Subsequent Iterations**: Refer to stored phase overview when needed
138
+ 3. **Function References**: Look up definitions in appropriate scope
139
+ 4. **Minimal Context**: Work with just the current item, not full arrays
140
+
141
+ ## Performance Characteristics
142
+
143
+ Based on benchmarks:
144
+
145
+ - **Context Size Reduction**: 60-80% for large arrays
146
+ - **Processing Overhead**: < 5% additional time
147
+ - **Memory Usage**: Significantly reduced for long-running loops
148
+ - **Network Transfer**: Reduced payload size for remote execution
149
+
150
+ ## Migration Guide
151
+
152
+ ### From v0.1.x to v0.2.0
153
+
154
+ 1. **Schema Version**: Update to v0.2.0
155
+ 2. **Add maxIterations**: Required field for all loops
156
+ 3. **Optional**: Add function definitions to reduce duplication
157
+ 4. **No Code Changes**: Optimization is automatic
158
+
159
+ Example migration:
160
+
161
+ ```diff
162
+ {
163
+ - "version": "0.1.0",
164
+ + "version": "0.2.0",
165
+ "steps": [{
166
+ "type": "loop",
167
+ "loop": {
168
+ "type": "forEach",
169
+ - "items": "data"
170
+ + "items": "data",
171
+ + "maxIterations": 1000
172
+ }
173
+ }]
174
+ }
175
+ ```
176
+
177
+ ## Best Practices
178
+
179
+ 1. **Use Function DSL** for repeated patterns within loops
180
+ 2. **Set Appropriate maxIterations** to prevent runaway loops
181
+ 3. **Use Empty Loop Detection** by checking conditions early
182
+ 4. **Design for Progressive Disclosure** in your prompts
183
+
184
+ ## Troubleshooting
185
+
186
+ ### Large Context Errors
187
+
188
+ If you still encounter context size errors:
189
+
190
+ 1. Check for accumulating data in loop state
191
+ 2. Ensure large arrays aren't being duplicated
192
+ 3. Consider breaking very large loops into batches
193
+
194
+ ### Function Reference Issues
195
+
196
+ If function references aren't working:
197
+
198
+ 1. Verify function is defined at correct scope
199
+ 2. Check reference syntax includes parentheses: `functionName()`
200
+ 3. Ensure agent supports function DSL
201
+
202
+ ## Future Enhancements
203
+
204
+ Planned improvements include:
205
+
206
+ 1. **Loop Resumption**: Ability to resume execution mid-loop
207
+ 2. **Client-Side Caching**: Optional caching of phase references
208
+ 3. **Dynamic Optimization**: Adaptive thresholds based on context size
209
+ 4. **Streaming Support**: Progressive context streaming for very large loops
@@ -0,0 +1,176 @@
1
+ # Loop Validation Best Practices
2
+
3
+ This document describes the enhanced loop validation features in WorkRail and provides best practices for creating maintainable loop workflows.
4
+
5
+ ## Overview
6
+
7
+ WorkRail includes enhanced validation for loop steps that goes beyond basic syntax checking. It helps you identify potential issues with complex conditional logic, excessive prompt lengths, undefined variables, and provides guidance on best practices.
8
+
9
+ ## Validation Categories
10
+
11
+ ### 1. Conditional Logic Complexity
12
+
13
+ **What it checks:**
14
+ - Complex ternary operators (2 or more `?` operators)
15
+ - Nested ternary operators
16
+ - Multi-path conditionals in prompts
17
+
18
+ **Why it matters:**
19
+ - Complex conditionals are hard to read and maintain
20
+ - Template variables may not resolve properly
21
+ - All conditional branches may be included in the output
22
+
23
+ **Best practice:**
24
+ Instead of inline conditionals:
25
+ ```json
26
+ {
27
+ "prompt": "{{iteration === 1 ? 'First step' : iteration === 2 ? 'Second step' : 'Third step'}}"
28
+ }
29
+ ```
30
+
31
+ Use separate steps with `runCondition`:
32
+ ```json
33
+ [
34
+ {
35
+ "id": "step-1",
36
+ "prompt": "First step",
37
+ "runCondition": {"var": "iteration", "equals": 1}
38
+ },
39
+ {
40
+ "id": "step-2",
41
+ "prompt": "Second step",
42
+ "runCondition": {"var": "iteration", "equals": 2}
43
+ },
44
+ {
45
+ "id": "step-3",
46
+ "prompt": "Third step",
47
+ "runCondition": {"var": "iteration", "equals": 3}
48
+ }
49
+ ]
50
+ ```
51
+
52
+ ### 2. Prompt Length Validation
53
+
54
+ **What it checks:**
55
+ - Raw prompt length approaching 1500-2000 character limits
56
+ - Total conditional content size when expanded
57
+
58
+ **Why it matters:**
59
+ - Long prompts can exceed system limits
60
+ - Conditional expansion can make prompts even larger
61
+ - Large prompts reduce readability and maintainability
62
+
63
+ **Best practice:**
64
+ - Keep prompts focused and under 1000 characters
65
+ - Move detailed instructions to the `guidance` array
66
+ - Split complex prompts into multiple steps
67
+
68
+ ### 3. Template Variable Usage
69
+
70
+ **What it checks:**
71
+ - Undefined variables in prompts, titles, and agent roles
72
+ - Proper use of loop iteration variables
73
+
74
+ **Available loop variables:**
75
+ - For all loops: `iteration` (or custom `iterationVar`)
76
+ - For `forEach` loops: `item` (or custom `itemVar`), `index` (or custom `indexVar`)
77
+ - Context variables defined elsewhere in the workflow
78
+
79
+ **Best practice:**
80
+ - Always verify variables are defined before use
81
+ - Use descriptive custom variable names
82
+ - Document expected context variables
83
+
84
+ ### 4. Loop Structure
85
+
86
+ **What it checks:**
87
+ - Reasonable `maxIterations` limits
88
+ - Appropriate loop types for use cases
89
+ - Common loop patterns
90
+
91
+ **Best practice:**
92
+ - Set `maxIterations` to prevent infinite loops (typically < 100)
93
+ - Use `for` loops for fixed iterations
94
+ - Use `while`/`until` for condition-based loops
95
+ - Use `forEach` for processing arrays
96
+
97
+ ## Common Patterns
98
+
99
+ ### Progressive Analysis Pattern
100
+
101
+ Detected when loops perform step-by-step analysis (e.g., Structure → Modules → Dependencies → Patterns).
102
+
103
+ **Recommendation:** Use separate steps with `runCondition` for clarity.
104
+
105
+ ### Multi-Path Pattern
106
+
107
+ Detected when loops have multiple conditional execution paths.
108
+
109
+ **Recommendation:** Refactor to separate steps for better maintainability.
110
+
111
+ ## Example: Well-Structured Loop
112
+
113
+ ```json
114
+ {
115
+ "id": "analysis-loop",
116
+ "type": "loop",
117
+ "loop": {
118
+ "type": "for",
119
+ "count": 4,
120
+ "maxIterations": 4,
121
+ "iterationVar": "analysisStep"
122
+ },
123
+ "body": [
124
+ {
125
+ "id": "step-structure",
126
+ "title": "Structural Analysis",
127
+ "prompt": "Analyze the codebase structure...",
128
+ "runCondition": {"var": "analysisStep", "equals": 1}
129
+ },
130
+ {
131
+ "id": "step-modules",
132
+ "title": "Module Analysis",
133
+ "prompt": "Analyze task-relevant modules...",
134
+ "runCondition": {"var": "analysisStep", "equals": 2}
135
+ },
136
+ {
137
+ "id": "step-dependencies",
138
+ "title": "Dependency Analysis",
139
+ "prompt": "Trace dependencies and flows...",
140
+ "runCondition": {"var": "analysisStep", "equals": 3}
141
+ },
142
+ {
143
+ "id": "step-patterns",
144
+ "title": "Pattern Discovery",
145
+ "prompt": "Identify established patterns...",
146
+ "runCondition": {"var": "analysisStep", "equals": 4}
147
+ }
148
+ ]
149
+ }
150
+ ```
151
+
152
+ ## CLI Validation
153
+
154
+ Run validation to see warnings and suggestions:
155
+
156
+ ```bash
157
+ workrail validate your-workflow.json
158
+ ```
159
+
160
+ The validator will show:
161
+ - **Errors**: Must be fixed for the workflow to run
162
+ - **Warnings**: Should be addressed for better maintainability
163
+ - ℹ️ **Information**: Detected patterns and insights
164
+ - **Suggestions**: Recommendations for improvement
165
+
166
+ ## Summary
167
+
168
+ Good loop design principles:
169
+ 1. Keep logic simple and explicit
170
+ 2. Use `runCondition` for multi-path flows
171
+ 3. Keep prompts concise and focused
172
+ 4. Define and document all variables
173
+ 5. Set reasonable iteration limits
174
+ 6. Test thoroughly with validation
175
+
176
+ Following these practices will result in workflows that are easier to understand, maintain, and debug.