@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,361 @@
1
+ # Workflow Source Setup Phase 2
2
+
3
+ This is the **canonical durable plan/design doc** for the next workflow-source setup phase after rooted-sharing phase 1.
4
+
5
+ Use it for:
6
+
7
+ - the recommended **phase 2A / phase 2B** boundary
8
+ - the canonical **effective source catalog** direction
9
+ - the intended onboarding model for repo/folder-driven setup
10
+ - migration stance for env-first and legacy live/runtime-configured sources
11
+ - the trust, conflict, and explainability guardrails that should constrain implementation
12
+
13
+ Do **not** use this doc as a code-shadow full of exact APIs, file layouts, or ticket-level implementation slices. Those should come later in tickets, code, and tests.
14
+
15
+ ## Goal
16
+
17
+ Make broader workflow hookup feel like a coherent WorkRail product surface without losing the trust model established in phase 1.
18
+
19
+ Phase 2 should make it easier for a user to:
20
+
21
+ - connect a repo or folder without env-first setup
22
+ - inspect all effective workflow sources in one coherent model
23
+ - understand whether a source is rooted, installed, legacy, or external
24
+ - understand the trust, conflict, and migration implications of onboarding a source
25
+
26
+ ## Why phase 2 exists
27
+
28
+ Phase 1 established the trust and visibility baseline for rooted team sharing:
29
+
30
+ - explicit `workspacePath`
31
+ - remembered roots
32
+ - recursive rooted discovery
33
+ - source-aware visibility
34
+ - migration-aware precedence explanation
35
+
36
+ That solved the common team-sharing path, but it did **not** yet provide:
37
+
38
+ - a canonical control surface for all effective workflow sources
39
+ - a WorkRail-owned onboarding path for repo/folder-style source hookup
40
+ - a coherent migration layer for env-first configuration
41
+
42
+ Phase 2 exists to add those capabilities without regressing explainability.
43
+
44
+ ## Core phase-2 stance
45
+
46
+ Phase 2 should **not** be framed as “add an install wizard.”
47
+
48
+ It is better understood as:
49
+
50
+ - a **canonical effective source catalog**
51
+ - plus **managed onboarding** for a narrow set of common intents
52
+ - while preserving compatibility with current runtime source heterogeneity during migration
53
+
54
+ This is a control-layer expansion, not an immediate runtime rewrite.
55
+
56
+ ## Phase-2 structure
57
+
58
+ ### Phase 2A — Catalog + onboarding foundation
59
+
60
+ Phase 2A is the first credible slice of phase 2.
61
+
62
+ It should:
63
+
64
+ - define the **canonical effective source catalog**
65
+ - introduce **managed source entries** for explicit install/connect actions
66
+ - add narrow onboarding for common intents
67
+ - make legacy/env-first sources visible and migration-targetable
68
+ - require trust review and conflict rehearsal before enabling new managed sources
69
+
70
+ ### Phase 2B — Lifecycle and breadth expansion
71
+
72
+ Phase 2B follows after the 2A foundation is stable.
73
+
74
+ It should expand into:
75
+
76
+ - richer update and sync flows
77
+ - clearer health, revision, and last-sync reporting
78
+ - receipts / setup transcripts / stronger observability
79
+ - broader source-type onboarding such as registries, plugins, or community packaging
80
+ - richer console/control-tower integration
81
+
82
+ ## Canonical phase-2 model
83
+
84
+ ### Effective source catalog
85
+
86
+ The **effective source catalog** is the canonical inspectable model of what sources effectively exist right now and how they relate.
87
+
88
+ It should answer, at minimum:
89
+
90
+ - what the source is
91
+ - where it came from
92
+ - what scope it affects
93
+ - what mode it is in
94
+ - whether it is preferred, legacy, or overlapping another source
95
+ - what trust/conflict/migration implications apply
96
+
97
+ The catalog is a **truth surface**, not necessarily the persistence format.
98
+
99
+ ### Internal entry families
100
+
101
+ The preferred internal model is hybrid:
102
+
103
+ #### Derived effective entries
104
+
105
+ These exist because WorkRail can currently observe or derive them from existing behavior:
106
+
107
+ - built-in workflows
108
+ - user-library workflows
109
+ - rooted-sharing sources discovered from remembered roots
110
+ - legacy project `./workflows`
111
+ - env-configured live/runtime-configured sources
112
+
113
+ These should be visible in the catalog even if WorkRail did not explicitly create them.
114
+
115
+ #### Managed source entries
116
+
117
+ These exist because WorkRail explicitly attached, installed, or connected them.
118
+
119
+ They are the right place for durable metadata such as:
120
+
121
+ - selected mode
122
+ - origin
123
+ - revision or branch intent
124
+ - trust/review result
125
+ - migration target state
126
+
127
+ Users should not need to think in terms of “derived” versus “managed,” but this distinction is useful internally and in the planning model.
128
+
129
+ ## User-facing phase-2 language
130
+
131
+ The product should prefer user intents over raw source-kind jargon.
132
+
133
+ The early onboarding surface should be shaped around intents like:
134
+
135
+ - `use folder`
136
+ - `use repo`
137
+ - `share repo workflows`
138
+
139
+ This is better than forcing the user to choose directly among `custom`, `git`, `remote`, or `plugin` semantics.
140
+
141
+ ## Phase-2A onboarding scope
142
+
143
+ ### In scope for onboarding
144
+
145
+ Phase 2A should focus on **repo/folder-first** onboarding.
146
+
147
+ That means:
148
+
149
+ - local folder onboarding
150
+ - local repo onboarding
151
+ - remote repo onboarding
152
+ - rooted-sharing continuity for repo-local `.workrail/workflows/`
153
+
154
+ ### Out of scope for onboarding
155
+
156
+ Phase 2A should **not** try to support every source kind equally from day one.
157
+
158
+ Explicitly defer:
159
+
160
+ - broad registry onboarding
161
+ - broad plugin onboarding
162
+ - community/package distribution breadth
163
+ - richer import flows for archives/chat/shared artifacts
164
+
165
+ Those belong later, once the catalog and onboarding foundation are proven.
166
+
167
+ ## Remote-source stance
168
+
169
+ ### Default for new onboarding
170
+
171
+ For **new remote onboarding**, the default should be:
172
+
173
+ - **managed local sync**
174
+
175
+ That means:
176
+
177
+ - the remote repo is the acquisition/update source
178
+ - WorkRail operates over a local effective copy for discovery, validation, and explainability
179
+
180
+ ### Why this is the default
181
+
182
+ This default:
183
+
184
+ - preserves a local effective state that is easier to inspect and debug
185
+ - supports a stronger provenance and update story
186
+ - avoids forcing users to think in low-level Git/storage modes
187
+ - aligns with the design-thinking direction around managed sync
188
+
189
+ ### Important constraint
190
+
191
+ Managed local sync should be treated as the **default for new onboarding**, not as an immediate semantic rewrite of every existing remote/live source.
192
+
193
+ Legacy live/runtime-configured sources should remain:
194
+
195
+ - supported during migration
196
+ - visible in the catalog
197
+ - explainable as legacy or advanced paths
198
+
199
+ ### Other remote modes
200
+
201
+ The long-term model may also include:
202
+
203
+ - **pinned snapshot**
204
+ - stronger reproducibility, lower-trust, or explicit-update scenarios
205
+ - **live remote**
206
+ - if retained, advanced-only and not the preferred onboarding path
207
+
208
+ Phase 2A does not need to finalize the long-term fate of live remote mode to be useful.
209
+
210
+ ## Migration stance
211
+
212
+ Phase 2 must coexist with current configuration reality instead of pretending it is already gone.
213
+
214
+ The product and docs should continue to acknowledge:
215
+
216
+ - `./workflows`
217
+ - `~/.workrail/workflows`
218
+ - rooted-sharing via remembered roots
219
+ - env-configured custom paths
220
+ - env-configured Git repositories
221
+ - env-configured remote registries
222
+ - env-configured plugin-style sources
223
+
224
+ ### Legacy visibility
225
+
226
+ Env-first and other legacy-configured sources should appear in the catalog as **legacy-effective** or equivalent user-facing categories.
227
+
228
+ ### Migration proposals
229
+
230
+ Visibility alone is not enough.
231
+
232
+ Phase 2A should include **basic migration proposals / change plans** such as:
233
+
234
+ - this source is currently env-configured
235
+ - this is the recommended preferred path
236
+ - this is the target mode WorkRail recommends
237
+ - this is the overlap/conflict implication if you enable it
238
+
239
+ This does **not** require full migration automation in 2A, but it should make the path forward explicit.
240
+
241
+ ## Trust and conflict requirements
242
+
243
+ ### Trust review
244
+
245
+ Phase 2A should require a lightweight explicit trust/review summary before enabling third-party or external managed sources.
246
+
247
+ At minimum, that summary should make clear:
248
+
249
+ - origin
250
+ - scope
251
+ - selected mode
252
+ - any auth implication
253
+ - any important portability warning
254
+
255
+ ### Conflict rehearsal
256
+
257
+ Before attaching or enabling a source, WorkRail should perform a preflight-style conflict rehearsal that can surface:
258
+
259
+ - shadowing / precedence effects
260
+ - workflow ID conflicts
261
+ - bundled-protection implications
262
+ - obvious portability or compatibility concerns
263
+
264
+ This is part of making the onboarding path trustworthy rather than surprising.
265
+
266
+ ## Config and persistence stance
267
+
268
+ ### What is decided now
269
+
270
+ - Phase 2A should avoid overloading `.workrail/config.json` prematurely.
271
+ - The effective catalog does **not** have to be the same as the persistence format.
272
+ - Managed-source durability can be designed separately from the catalog surface.
273
+
274
+ ### What this implies
275
+
276
+ Phase 2A can plausibly use a dedicated WorkRail durable-state pattern for managed source records without first resolving every long-term `.workrail/*` ownership question.
277
+
278
+ ### What is still intentionally unresolved
279
+
280
+ - exact managed-source record schema
281
+ - exact storage/layout path
282
+ - final ownership split between user-global config, repo-local metadata, and durable managed-source state
283
+
284
+ The implementation should preserve flexibility here rather than baking in a premature single-file assumption.
285
+
286
+ ## Acceptance criteria
287
+
288
+ Phase 2A is successful when all of the following are true:
289
+
290
+ ### User-facing outcomes
291
+
292
+ - A user can connect a repo or folder without falling back to raw env-first setup.
293
+ - A user can inspect all effective sources in one coherent model.
294
+ - A user can understand whether a source is rooted, legacy, managed, or external without reading implementation details.
295
+ - A user can understand trust/conflict implications before enabling a managed source.
296
+ - A user can see a migration path for legacy/env-first sources.
297
+
298
+ ### Product/design outcomes
299
+
300
+ - The effective source catalog is canonical for inspection.
301
+ - Managed onboarding exists for repo/folder-first intents.
302
+ - Conflict rehearsal exists before enable/attach.
303
+ - Lightweight trust/review exists before enabling external managed sources.
304
+ - Legacy live/env-configured sources remain visible and supported during migration.
305
+
306
+ ### Maintenance outcomes
307
+
308
+ - Another maintainer can use this doc as the durable phase-2 reference without replaying the exploration.
309
+ - Future ticketing can proceed without reopening the entire option space.
310
+ - The doc preserves clear boundaries between 2A, 2B, and later phases.
311
+
312
+ ## Non-goals for phase 2A
313
+
314
+ Phase 2A is **not**:
315
+
316
+ - a full source-lifecycle platform
317
+ - a richer console control tower
318
+ - a full registry/plugin/community onboarding rollout
319
+ - a complete runtime-source redesign
320
+ - the final answer to every `.workrail/*` ownership question
321
+ - a full receipt/history/transcript system
322
+
323
+ Those may follow in 2B or later phases, but they are not required for 2A to be useful and coherent.
324
+
325
+ ## Risks to guard against
326
+
327
+ - **Wizard over chaos**: guided onboarding without a real canonical catalog
328
+ - **Another hybrid setup story**: old and new source paths coexist without a coherent catalog view
329
+ - **Hidden runtime rewrite**: phase 2A quietly changes source semantics instead of productizing them safely
330
+ - **Config overload**: phase 2A pushes too much state into `.workrail/config.json` too early
331
+ - **Migration theater**: legacy sources are labeled but not meaningfully guided toward a better path
332
+ - **Invisible conflicts**: onboarding enables sources without clear rehearsal of overlap or precedence
333
+
334
+ ## Remaining design decisions
335
+
336
+ These are still important, but now belong inside the chosen direction rather than blocking it:
337
+
338
+ - exact minimal managed-source record schema
339
+ - exact storage/layout recommendation for those records
340
+ - whether any repo-local metadata artifact is worth adding in 2A
341
+ - long-term role of explicit live remote mount
342
+
343
+ ## Recommended next planning step
344
+
345
+ If this phase-2 direction is accepted, the next high-value artifact should be a more focused **phase-2A design / execution plan** that refines:
346
+
347
+ - catalog entry shape
348
+ - managed-source record shape
349
+ - conflict-review / trust-review surface
350
+ - migration-proposal surface
351
+
352
+ before ticket creation begins.
353
+
354
+ ## Companion docs
355
+
356
+ - `docs/plans/workflow-source-setup-phase-1.md`
357
+ - `docs/plans/workrail-platform-vision.md`
358
+ - `docs/ideas/third-party-workflow-setup-design-thinking.md`
359
+ - `docs/configuration.md`
360
+
361
+ `workflow-source-setup-phase-1.md` remains the canonical reference for phase 1. This file is the preferred durable reference for the **next** phase of the initiative.
@@ -0,0 +1,104 @@
1
+ # Workflow Staleness Detection — Design Candidates
2
+
3
+ ## Problem Understanding
4
+
5
+ **Tensions:**
6
+ 1. Explicit stamp vs inferred signal — stamps are precise but require migration; git-date inference works immediately but isn't deterministic
7
+ 2. Noise vs sensitivity — low threshold creates flag fatigue; high threshold misses real staleness
8
+ 3. Where staleness lives — in the workflow file vs computed by the engine vs in a separate manifest
9
+ 4. Agent-side vs user-side surfacing — same signal, different presentation contracts
10
+
11
+ **Likely seam:** `V2WorkflowListItemSchema` in `src/mcp/output-schemas.ts` — add a `staleness` field here. The computation feeds from either a stamp in the workflow JSON or a git-date comparison.
12
+
13
+ **What makes it hard:** Bootstrapping. The right long-term signal requires stamps that don't exist on any current workflow. Any solution must degrade gracefully for unstamped workflows without producing permanent noise.
14
+
15
+ ## Philosophy Constraints
16
+
17
+ - **Determinism over cleverness** — git-date comparison is not deterministic (CI can retouch files). Spec-version stamp is deterministic.
18
+ - **Make illegal states unrepresentable** — `staleness: boolean` is wrong. `staleness: { level: 'none' | 'possible' | 'likely', reason: string, specVersionAtLastReview?: number }` is correct.
19
+ - **Explicit domain types** — the staleness level is a meaningful enum, not a string.
20
+ - **Architectural fixes over patches** — the stamp is the fix; git-date inference is a patch.
21
+
22
+ ## Impact Surface
23
+
24
+ - `spec/workflow.schema.json` — new optional field
25
+ - `workflow-for-workflows.v2.json` — new stamp step in Phase 7
26
+ - `src/mcp/output-schemas.ts` — new field in `V2WorkflowListItemSchema` and `V2WorkflowInspectOutputSchema`
27
+ - `src/mcp/handlers/v2-workflow.ts` — staleness computation at list/inspect time
28
+ - Console workflow list — new staleness indicator (follow `migration`/`staleRoots` visual pattern)
29
+ - `spec/authoring-spec.json` — the source of truth for current spec version (currently `version: 3`)
30
+
31
+ ## Candidates
32
+
33
+ ### Candidate A: Engine-computed staleness from spec git-date
34
+
35
+ **Summary:** At `list_workflows` time, compare `git log -1 %at` for `spec/authoring-spec.json` vs the workflow file. If spec is newer, surface `staleness: { level: 'possible', reason: 'Authoring spec updated since workflow was last committed' }`.
36
+
37
+ - **Tensions resolved:** works on all existing workflows immediately, zero migration
38
+ - **Tensions accepted:** not deterministic, can't distinguish meaningful spec change from typo fix, no way to clear except committing the workflow file
39
+ - **Boundary:** `v2-workflow.ts` + `V2WorkflowListItemSchema` only
40
+ - **Failure mode:** CI pipeline touches `authoring-spec.json` during a release, flagging every workflow simultaneously
41
+ - **Repo pattern:** follows `staleRoots` pattern — computed at list time
42
+ - **Gains:** zero migration, immediate coverage
43
+ - **Losses:** precision, determinism, actionable reason string
44
+ - **Scope:** best-fit for a temporary bridge, too narrow as a final solution
45
+ - **Philosophy:** honors YAGNI; conflicts with Determinism
46
+
47
+ ---
48
+
49
+ ### Candidate B: Spec-version stamp in workflow JSON ✓ RECOMMENDED
50
+
51
+ **Summary:** Add optional `validatedAgainstSpecVersion: number` to the workflow JSON schema. `workflow-for-workflows` stamps this in Phase 7. Engine reads the field and compares against `spec/authoring-spec.json` version. Three-tier signal: `none` (stamp matches current), `likely` (stamp < current), `possible` (no stamp).
52
+
53
+ - **Tensions resolved:** deterministic, precise three-tier signal, actionable reason string, running workflow-for-workflows naturally clears the flag
54
+ - **Tensions accepted:** bootstrapping — existing workflows start as `possible` until reviewed
55
+ - **Boundary:** schema + workflow-for-workflows + output-schemas + handler
56
+ - **Failure mode:** teams run workflow-for-workflows locally but forget to commit the JSON
57
+ - **Repo pattern:** adapts `workflowHash` pattern (content-derived identity) to spec-version identity
58
+ - **Gains:** deterministic, self-documenting, architectural fix, clears naturally with workflow-for-workflows
59
+ - **Losses:** migration cost (organic, not forced), adds schema field most workflows won't have immediately
60
+ - **Scope:** best-fit long-term
61
+ - **Philosophy:** honors Determinism, Make illegal states unrepresentable, Explicit domain types. Minor YAGNI tension.
62
+
63
+ **Implementation steps:**
64
+ 1. `spec/workflow.schema.json`: add `validatedAgainstSpecVersion?: number` (optional, no existing workflow breaks)
65
+ 2. `workflow-for-workflows.v2.json`: Phase 7 stamps `validatedAgainstSpecVersion` to current spec version before handoff
66
+ 3. `src/mcp/output-schemas.ts`: add `staleness?: { level: 'none' | 'possible' | 'likely', reason: string, specVersionAtLastReview?: number }` to `V2WorkflowListItemSchema` and `V2WorkflowInspectOutputSchema`
67
+ 4. `src/mcp/handlers/v2-workflow.ts`: read `validatedAgainstSpecVersion` from compiled workflow; compare against `spec/authoring-spec.json` version; compute staleness
68
+ 5. Console: show staleness indicator in workflow list
69
+ 6. `spec/authoring-spec.json`: keep `version` field updated when meaningful rules change
70
+
71
+ ---
72
+
73
+ ### Candidate C: Hybrid — stamp when available, git-date fallback
74
+
75
+ **Summary:** Use stamp-based comparison when `validatedAgainstSpecVersion` is present; fall back to git-date comparison for unstamped workflows.
76
+
77
+ - **Tensions resolved:** zero migration + precision where stamps exist
78
+ - **Tensions accepted:** git-date fallback inherits A's determinism problem; two code paths
79
+ - **Failure mode:** `possible` from the fallback becomes permanent wallpaper for workflows never run through workflow-for-workflows
80
+ - **Scope:** slightly too broad for a first version, correct long-term shape
81
+ - **Philosophy:** deterministic where stamps exist; conflicts with Determinism in the fallback path
82
+
83
+ ## Comparison and Recommendation
84
+
85
+ **Recommendation: Candidate B**
86
+
87
+ The stamp is the architecturally correct fix. It's deterministic, self-documenting, and cleared by the existing workflow-for-workflows tool. The bootstrap problem is real but manageable: unstamped workflows show `possible` (not `likely`), and teams clear it organically by running workflow-for-workflows. No mass migration needed.
88
+
89
+ **Why A loses:** The CI-noise failure mode is hard to avoid and produces permanent noise. No actionable reason string.
90
+
91
+ **Why C loses:** The hybrid adds complexity, and the git-date fallback is still the same wallpaper problem — just deferred. The right approach is to accept the bootstrap cost of B and let organic adoption clear it.
92
+
93
+ ## Self-Critique
94
+
95
+ **Strongest counter-argument:** Spec version is too coarse — v3 may have added rules that don't apply to a given workflow's archetype, making `likely stale` misleading. Mitigation: add a `changedRules` summary to the reason string when the spec version changes.
96
+
97
+ **Pivot condition:** If teams rarely run workflow-for-workflows and `possible` becomes permanent noise for 80%+ of workflows, add a CI step that reads the spec version and stamps workflows automatically (no human needed, just a `git commit --amend` or separate commit in CI).
98
+
99
+ ## Open Questions for Main Agent
100
+
101
+ 1. Should `workflow-for-workflows` stamp before or after the quality gate loop? (After seems right — only stamp if the workflow passes.)
102
+ 2. Should `validatedAgainstSpecVersion` be a required field for new workflows going forward, or permanently optional?
103
+ 3. Does the console need a new visual treatment, or can it reuse the `migration` badge pattern that already exists?
104
+ 4. Should `inspect_workflow` in `metadata` mode also return the staleness field, or only in `preview` mode?
@@ -0,0 +1,58 @@
1
+ # Workflow Staleness Detection — Design Review Findings
2
+
3
+ ## Tradeoff Review
4
+
5
+ | Tradeoff | Verdict | Hidden Assumption | Fails If |
6
+ |---|---|---|---|
7
+ | Bootstrap: existing workflows show `possible` | Acceptable | Teams will eventually run workflow-for-workflows on important workflows | `possible` shown as equally urgent as `likely` |
8
+ | External workflows never get stamped | Acceptable | Stamp is optional, no workflow breaks | Same as above |
9
+ | Spec granularity: one update flags all workflows | Acceptable with mitigation | Spec has a changelog per version increment | Spec version bumps silently with no explanation |
10
+
11
+ **T3 reveals a required companion piece: the authoring spec needs a per-version changelog.** Not a blocker, but must ship alongside the staleness feature to keep the reason string actionable.
12
+
13
+ ## Failure Mode Review
14
+
15
+ | Failure Mode | Risk | Coverage | Missing Mitigation |
16
+ |---|---|---|---|
17
+ | Spec version not bumped when rules change | **High** | Not in code — process fix needed | Add explicit trigger to `authoring-spec.json` `changeProtocol` |
18
+ | Stamp committed locally but not pushed | Medium | Phase 7 handoff note needed | Note in workflow-for-workflows Phase 7: "stamp must be committed" |
19
+ | `possible` becomes wallpaper | Medium | Three-tier design helps | Ensure `possible` and `likely` are visually distinct in console |
20
+
21
+ **Highest-risk failure mode: spec version not bumped.** This would make the entire system unreliable. Process fix required.
22
+
23
+ ## Runner-Up / Simpler Alternative Review
24
+
25
+ - Candidate A (git-date): nothing worth borrowing. CI-noise failure mode is disqualifying.
26
+ - Simpler variant (embed spec in version string): rejected — conflates human-maintained semver with compliance state.
27
+ - Sidecar file stamp: rejected — state would drift from the workflow file, violating determinism.
28
+
29
+ **Conclusion:** Candidate B as designed is already the minimal correct shape.
30
+
31
+ ## Philosophy Alignment
32
+
33
+ - **Satisfied:** Determinism, Make illegal states unrepresentable, Explicit domain types, Validate at boundaries, Errors are data
34
+ - **Acceptable tensions:** YAGNI (optional field on existing workflows), Architectural fixes over patches (graceful `possible` degradation)
35
+ - **No risky tensions**
36
+
37
+ ## Findings
38
+
39
+ **Orange — Spec version bump process undefined**
40
+ `authoring-spec.json` `changeProtocol` has no explicit trigger for incrementing `version`. If this isn't defined before the staleness feature ships, the `validatedAgainstSpecVersion` comparison is unreliable in either direction. Must be fixed.
41
+
42
+ **Yellow — No per-version changelog in authoring spec**
43
+ The `reason` string in the staleness output must reference what changed between spec versions for the signal to be actionable. Currently there's no changelog. Must be added when version increments.
44
+
45
+ **Yellow — workflow-for-workflows Phase 7 doesn't mention the stamp**
46
+ The Phase 7 handoff step should explicitly tell the agent: "the `validatedAgainstSpecVersion` stamp was written to the workflow file — commit it for the staleness signal to take effect." Without this, teams may miss it.
47
+
48
+ ## Recommended Revisions
49
+
50
+ 1. Add to `authoring-spec.json` `changeProtocol`: "Increment `version` when any required-level rule is added, removed, or materially changed. Add a `changelog` entry for the new version."
51
+ 2. Add `changelog` array to `authoring-spec.json` schema structure — each entry: `{ version, date, summary, affectedRules }`.
52
+ 3. Add stamp reminder to workflow-for-workflows Phase 7 handoff step.
53
+ 4. Ensure console renders `likely` more prominently than `possible` (not just two shades of the same badge).
54
+
55
+ ## Residual Concerns
56
+
57
+ - Routine changes (workflows delegating to routines that were updated) are not tracked by spec version. Accepted as out of scope for v1.
58
+ - If the spec version doesn't increment often (historically it's been at v3 for a while), the `likely` tier may rarely appear. That's okay — it means most workflows will be `none` or `possible`, which is the right coarse signal.
@@ -0,0 +1,80 @@
1
+ # Workflow Staleness Detection
2
+
3
+ ## Context / Ask
4
+
5
+ How to automatically detect when a WorkRail workflow has become stale — out of sync with the authoring spec, schema, or routines it depends on — and surface this transparently to both users (UI/console) and agents (MCP tools).
6
+
7
+ ## Recommendation: Spec-Version Stamp (Candidate B)
8
+
9
+ **Confidence: High.** Grounded in codebase evidence, adversarially challenged, design-reviewed. No direction changes required.
10
+
11
+ ### How it works
12
+
13
+ 1. `spec/authoring-spec.json` has a `version` field (currently `3`). This is the staleness anchor.
14
+ 2. `workflow-for-workflows` stamps `validatedAgainstSpecVersion: <N>` into the workflow JSON at Phase 7 handoff (after the quality gate passes).
15
+ 3. At `list_workflows` and `inspect_workflow` time, the engine reads the stamp and compares it against the current spec version.
16
+ 4. The output schema gains a `staleness` field: `{ level: 'none' | 'possible' | 'likely', reason: string, specVersionAtLastReview?: number }`.
17
+
18
+ ### Three-tier signal
19
+
20
+ | Level | Condition | Meaning |
21
+ |---|---|---|
22
+ | `none` | `validatedAgainstSpecVersion` matches current spec version | Workflow was reviewed against current guidance |
23
+ | `likely` | `validatedAgainstSpecVersion` < current spec version | Spec updated since last review — workflow may need attention |
24
+ | `possible` | No stamp present | Workflow was not created/reviewed via workflow-for-workflows |
25
+
26
+ ### Surfacing
27
+
28
+ - **Agents**: `staleness` field in `list_workflows` and `inspect_workflow` MCP output. Agents can warn users before starting a workflow.
29
+ - **Users**: staleness indicator in console workflow list. `likely` should be visually more prominent than `possible`. Follow the existing `migration`/`staleRoots` visual pattern.
30
+
31
+ ### What clears the flag
32
+
33
+ Running `workflow-for-workflows` on the workflow and committing the result. The Phase 7 step stamps the current spec version. No other action required.
34
+
35
+ ## Implementation Scope
36
+
37
+ | File | Change |
38
+ |---|---|
39
+ | `spec/workflow.schema.json` | Add optional `validatedAgainstSpecVersion?: number` field |
40
+ | `spec/authoring-spec.json` | Add explicit bump trigger to `changeProtocol`; add `changelog` array |
41
+ | `workflow-for-workflows.v2.json` | Phase 7: stamp `validatedAgainstSpecVersion` after quality gate passes; note stamp must be committed |
42
+ | `src/mcp/output-schemas.ts` | Add `staleness?` to `V2WorkflowListItemSchema` and `V2WorkflowInspectOutputSchema` |
43
+ | `src/mcp/handlers/v2-workflow.ts` | Compute staleness from stamp vs current spec version at list/inspect time |
44
+ | Console | Staleness indicator in workflow list; `likely` > `possible` visual hierarchy |
45
+
46
+ ## Constraints / Anti-goals
47
+
48
+ - Must not block workflow execution
49
+ - Must not require per-workflow manual maintenance
50
+ - No auto-fixing (that's workflow-for-workflows territory)
51
+ - No mass migration — bootstrap via organic adoption
52
+
53
+ ## Required Companion Changes (must ship with the feature)
54
+
55
+ 1. **`authoring-spec.json` `changeProtocol`**: add "Increment `version` when any required-level rule is added, removed, or materially changed."
56
+ 2. **`authoring-spec.json` `changelog`**: add a `changelog` array so the `reason` string in staleness output can reference what changed.
57
+ 3. **`workflow-for-workflows` Phase 7**: add note — "The `validatedAgainstSpecVersion` field was written to the workflow file — commit it for the staleness signal to take effect."
58
+
59
+ ## Accepted Tradeoffs
60
+
61
+ - Existing unstamped workflows show `possible` permanently until reviewed — acceptable, `possible` is the correct coarse signal for unreviewed workflows
62
+ - External workflows not using workflow-for-workflows may never get stamped — acceptable, same reason
63
+ - Spec version granularity: a spec update touching one archetype flags all workflows — mitigated by changelog + specific reason string
64
+
65
+ ## Residual Risks
66
+
67
+ - If spec version is not bumped when meaningful rules change (no clear owner), the `likely` signal never fires. Mitigated by adding explicit trigger to `changeProtocol`.
68
+ - Routine changes (delegation to updated routines) not tracked by spec version. Out of scope for v1.
69
+
70
+ ## Switch Trigger
71
+
72
+ If teams rarely run workflow-for-workflows and `possible` becomes permanent noise for 80%+ of workflows, add a CI step that stamps workflows automatically.
73
+
74
+ ## Decision Log
75
+
76
+ - **Candidate A (git-date inference) rejected**: CI-noise failure mode disqualifying; no actionable reason string; not deterministic.
77
+ - **Candidate C (hybrid) rejected**: complexity; git-date fallback inherits A's wallpaper problem.
78
+ - **Candidate B selected**: deterministic, architectural fix, self-clearing via workflow-for-workflows, follows `workflowHash` pattern.
79
+ - **Challenge**: spec version too coarse. Mitigated by changelog + reason string. Position held.
80
+ - **Review**: no direction change. Three companion changes required pre-ship.
@@ -0,0 +1,69 @@
1
+ # Workflow v2 Design
2
+
3
+ This is the **canonical durable design doc** for WorkRail v2.
4
+
5
+ Use it for:
6
+
7
+ - durable architectural intent
8
+ - invariants that should remain true over time
9
+ - the high-level reasoning behind the v2 model
10
+
11
+ Do **not** use this doc as a chat-resumption script or a line-by-line implementation cookbook.
12
+
13
+ ## North star
14
+
15
+ Make agent-driven workflows **deterministic and rewind-safe** while keeping the WorkRail tool surface small, durable, and hard to misuse.
16
+
17
+ ## Durable design principles
18
+
19
+ ### Token-based execution boundary
20
+
21
+ Agents should never assemble engine internals. The MCP boundary should expose opaque tokens and explicit intents instead.
22
+
23
+ ### Append-only truth
24
+
25
+ Execution truth should be append-only, with sessions/runs/dashboard views derived from projections.
26
+
27
+ ### Pinned determinism
28
+
29
+ Runs should be pinned to the fully expanded compiled workflow snapshot so replay/resume behavior stays stable.
30
+
31
+ ### Recovery without transcript dependence
32
+
33
+ WorkRail should not depend on the chat transcript for correctness. Recovery context should come from durable execution truth.
34
+
35
+ ### Closed, typed execution semantics
36
+
37
+ Preferences, contracts, and other workflow-shaping primitives should prefer closed sets and explicit semantics over loose bags of data.
38
+
39
+ ## Important consequences
40
+
41
+ ### Rewinds are an engine concern
42
+
43
+ Rewinds should branch safely rather than pushing structural recovery onto the user or agent.
44
+
45
+ ### Preferences are product semantics, not arbitrary metadata
46
+
47
+ Execution preferences should be WorkRail-defined and durable, not an unbounded preference bag.
48
+
49
+ ### Authoring power should stay deterministic
50
+
51
+ Templates, features, contracts, and related authoring primitives should remain auditable and deterministic, not become ad hoc runtime magic.
52
+
53
+ ### Failure visibility matters
54
+
55
+ The system should prefer explicit blocked/error paths and durable recovery over silent degradation.
56
+
57
+ ## Canonical references
58
+
59
+ - `docs/reference/workflow-execution-contract.md`
60
+ - `docs/reference/mcp-platform-constraints.md`
61
+ - `docs/adrs/005-agent-first-workflow-execution-tokens.md`
62
+ - `docs/adrs/006-append-only-session-run-event-log.md`
63
+ - `docs/adrs/007-resume-and-checkpoint-only-sessions.md`
64
+ - `docs/design/v2-core-design-locks.md`
65
+
66
+ ## Companion docs
67
+
68
+ - `docs/plans/workflow-v2-roadmap.md`
69
+ - `docs/plans/v2-followup-enhancements.md`