@c4a/context-cli 0.7.15 → 0.7.16

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 (45) hide show
  1. package/browser/diagrams.js +2826 -0
  2. package/cli.js +1267 -845
  3. package/indexers/bundles/context-code-indexer/LICENSE.third-party +25 -0
  4. package/indexers/bundles/context-code-indexer/references/diagram-behavior-examples.md +647 -0
  5. package/indexers/bundles/context-code-indexer/references/diagram-topology-examples.md +387 -0
  6. package/indexers/bundles/context-code-indexer/references/diagrams.md +347 -0
  7. package/indexers/bundles/context-markdown-indexer/LICENSE.third-party +25 -0
  8. package/indexers/bundles/context-markdown-indexer/references/diagram-behavior-examples.md +647 -0
  9. package/indexers/bundles/context-markdown-indexer/references/diagram-topology-examples.md +387 -0
  10. package/indexers/bundles/context-markdown-indexer/references/diagrams.md +347 -0
  11. package/indexers/bundles/context-note-indexer/LICENSE.third-party +25 -0
  12. package/indexers/bundles/context-note-indexer/references/diagram-behavior-examples.md +647 -0
  13. package/indexers/bundles/context-note-indexer/references/diagram-topology-examples.md +387 -0
  14. package/indexers/bundles/context-note-indexer/references/diagrams.md +347 -0
  15. package/indexers/bundles/context-sessions-indexer/LICENSE.third-party +25 -0
  16. package/indexers/bundles/context-sessions-indexer/references/diagram-behavior-examples.md +647 -0
  17. package/indexers/bundles/context-sessions-indexer/references/diagram-topology-examples.md +387 -0
  18. package/indexers/bundles/context-sessions-indexer/references/diagrams.md +347 -0
  19. package/indexers/contracts/profile-contract.json +245 -245
  20. package/indexers/release-manifest.json +57 -9
  21. package/package.json +13 -12
  22. package/parserEntryWorker.js +24 -0
  23. package/plugins/VERSION +1 -1
  24. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  25. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  26. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  27. package/plugins/skills/context-code-indexer/LICENSE.third-party +25 -0
  28. package/plugins/skills/context-code-indexer/references/diagram-behavior-examples.md +647 -0
  29. package/plugins/skills/context-code-indexer/references/diagram-topology-examples.md +387 -0
  30. package/plugins/skills/context-code-indexer/references/diagrams.md +347 -0
  31. package/plugins/skills/context-markdown-indexer/LICENSE.third-party +25 -0
  32. package/plugins/skills/context-markdown-indexer/references/diagram-behavior-examples.md +647 -0
  33. package/plugins/skills/context-markdown-indexer/references/diagram-topology-examples.md +387 -0
  34. package/plugins/skills/context-markdown-indexer/references/diagrams.md +347 -0
  35. package/plugins/skills/context-note-indexer/LICENSE.third-party +25 -0
  36. package/plugins/skills/context-note-indexer/references/diagram-behavior-examples.md +647 -0
  37. package/plugins/skills/context-note-indexer/references/diagram-topology-examples.md +387 -0
  38. package/plugins/skills/context-note-indexer/references/diagrams.md +347 -0
  39. package/plugins/skills/context-sessions-indexer/LICENSE.third-party +25 -0
  40. package/plugins/skills/context-sessions-indexer/references/diagram-behavior-examples.md +647 -0
  41. package/plugins/skills/context-sessions-indexer/references/diagram-topology-examples.md +387 -0
  42. package/plugins/skills/context-sessions-indexer/references/diagrams.md +347 -0
  43. package/providers/context/manifest.json +5 -5
  44. package/providers/context/provider.yaml +1 -1
  45. package/providers/context/resources/manuals/guides/package-outputs.md +36 -2
@@ -0,0 +1,647 @@
1
+ # Workflow, sequence and lifecycle examples
2
+
3
+ Read only the case selected by [the scenario guide](diagrams.md). These examples are synthetic upstream teaching material, not evidence for a user's system. Mermaid preserves explicit nodes and relationships; adjacent tables and verbatim cards retain details that do not belong inside a node. Color, routing and compiler observations are illustrative; Mermaid may produce different geometry. No example establishes behavior absent from an authorized source.
4
+
5
+ ## Agent Tool Call Workflow
6
+
7
+ Example: agent-tool-call.workflow.json.
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ subgraph g_n_ui["User Interface"]
12
+ n_user["User"]
13
+ n_chat["Chat Surface"]
14
+ n_final["Final Reply"]
15
+ end
16
+ subgraph g_n_agent["Agent Runtime"]
17
+ n_planner["Agent Planner"]
18
+ n_router["Tool Router"]
19
+ end
20
+ subgraph g_n_policy["Policy & Recovery"]
21
+ n_approval["Approval Gate"]
22
+ n_blocked["Blocked"]
23
+ n_retry["Retry Path"]
24
+ end
25
+ subgraph g_n_tools["Tool Execution & Evidence"]
26
+ n_tool["Tool Call"]
27
+ n_external["External API"]
28
+ n_store["Context Store"]
29
+ n_trace["Trace Log"]
30
+ end
31
+ n_user --> n_chat
32
+ n_chat -->|"plan"| n_planner
33
+ n_planner --> n_router
34
+ n_router -->|"needs approval?"| n_approval
35
+ n_approval --> n_tool
36
+ n_approval -->|"denied"| n_blocked
37
+ n_blocked -.-> n_retry
38
+ n_tool --> n_external
39
+ n_external --> n_final
40
+ n_external -.->|"record result"| n_trace
41
+ n_store -.->|"trace + memory"| n_trace
42
+ ```
43
+
44
+ **All participants and semantic details**
45
+
46
+ | ID | Label | Detail | Type | Tag | Group |
47
+ | --- | --- | --- | --- | --- | --- |
48
+ | user | User | asks for work | external | | ui |
49
+ | chat | Chat Surface | thread + files | frontend | | ui |
50
+ | final | Final Reply | answer + changes | backend | | ui |
51
+ | planner | Agent Planner | plan next step | backend | context aware | agent |
52
+ | router | Tool Router | choose capability | backend | | agent |
53
+ | approval | Approval Gate | scope + consent | security | block risky ops | policy |
54
+ | blocked | Blocked | wait or reject | security | | policy |
55
+ | retry | Retry Path | revise request | messagebus | | policy |
56
+ | tool | Tool Call | shell / browser / MCP | messagebus | structured result | tools |
57
+ | external | External API | network service | cloud | | tools |
58
+ | store | Context Store | repo + memory | database | | tools |
59
+ | trace | Trace Log | events + output | database | | tools |
60
+
61
+ **Relationship semantics**
62
+
63
+ | From → to | Label | Kind | Classification / role |
64
+ | --- | --- | --- | --- |
65
+ | user → chat | | default | |
66
+ | chat → planner | plan | emphasis | |
67
+ | planner → router | | default | |
68
+ | router → approval | needs approval? | security | |
69
+ | approval → tool | | emphasis | |
70
+ | approval → blocked | denied | security | error |
71
+ | blocked → retry | | dashed | branch |
72
+ | tool → external | | default | |
73
+ | external → final | | emphasis | return |
74
+ | external → trace | record result | dashed | |
75
+ | store → trace | trace + memory | dashed | |
76
+
77
+ Main path (upstream): user → chat → planner → router → approval → tool → external → final.
78
+
79
+ Phase **Intake**: upstream columns 0–1.
80
+
81
+ Phase **Plan + route**: upstream columns 2–3.
82
+
83
+ Phase **Execute + report**: upstream columns 4–5.
84
+
85
+ Group **Planning loop**: agent, upstream columns 2–3.
86
+
87
+ Group **Human or policy stop**: policy, upstream columns 3–5.
88
+
89
+ Group **Evidence path**: tools, upstream columns 1–2.
90
+
91
+ Group **Tool work**: tools, upstream columns 4–5.
92
+
93
+ **Request to result** (user, chat, planner, router, approval, tool, external, final): Follow the successful request from user intent to the final reply.
94
+
95
+ **Policy and recovery** (router, approval, blocked, retry): See where risky work stops, waits for consent, or returns for revision.
96
+
97
+ **Evidence and memory** (external, store, trace): Isolate the durable trace and context path behind the visible answer.
98
+
99
+ **Compiler Contract**
100
+
101
+ - Lanes and columns determine node placement
102
+ - Labels reserve clearance; routes stay orthogonal
103
+
104
+ **Runtime Semantics**
105
+
106
+ - Approval gates risky work before tool execution
107
+ - Evidence returns through isolated trace and memory
108
+
109
+ ## Release Delivery Workflow
110
+
111
+ Example: release-delivery.workflow.json.
112
+
113
+ ```mermaid
114
+ flowchart TD
115
+ subgraph g_n_dev["Developer"]
116
+ n_commit["Commit"]
117
+ n_pull_request["Pull Request"]
118
+ end
119
+ subgraph g_n_ci["Continuous Integration"]
120
+ n_build["Build"]
121
+ n_checks["Quality Gates"]
122
+ end
123
+ subgraph g_n_approval["Release Governance"]
124
+ n_approval["Approve"]
125
+ end
126
+ subgraph g_n_environment["Production Environment"]
127
+ n_deploy["Deploy"]
128
+ n_verify_prod["Verify"]
129
+ end
130
+ subgraph g_n_communication["Release Communication"]
131
+ n_announce["Announce"]
132
+ end
133
+ subgraph g_n_exceptions["Failure + Rollback"]
134
+ n_failed["Stop Release"]
135
+ n_rollback["Rollback"]
136
+ end
137
+ n_commit --> n_pull_request
138
+ n_pull_request -->|"merge"| n_build
139
+ n_build --> n_checks
140
+ n_checks --> n_approval
141
+ n_approval --> n_deploy
142
+ n_deploy --> n_verify_prod
143
+ n_verify_prod -->|"healthy"| n_announce
144
+ n_checks -->|"red"| n_failed
145
+ n_verify_prod --> n_rollback
146
+ n_rollback -.->|"restore"| n_deploy
147
+ ```
148
+
149
+ **All participants and semantic details**
150
+
151
+ | ID | Label | Detail | Type | Tag | Group |
152
+ | --- | --- | --- | --- | --- | --- |
153
+ | commit | Commit | signed change | frontend | | dev |
154
+ | pull_request | Pull Request | reviewed diff | frontend | | dev |
155
+ | build | Build | locked inputs | backend | reproducible | ci |
156
+ | checks | Quality Gates | test + scan | security | blocking | ci |
157
+ | approval | Approve | release owner | security | human gate | approval |
158
+ | deploy | Deploy | canary 10% | cloud | production | environment |
159
+ | verify_prod | Verify | smoke + SLO | backend | | environment |
160
+ | announce | Announce | status + notes | external | | communication |
161
+ | failed | Stop Release | gate failed | security | | exceptions |
162
+ | rollback | Rollback | last good image | messagebus | owner: on-call | exceptions |
163
+
164
+ **Relationship semantics**
165
+
166
+ | From → to | Label | Kind | Classification / role |
167
+ | --- | --- | --- | --- |
168
+ | commit → pull_request | | default | |
169
+ | pull_request → build | merge | emphasis | |
170
+ | build → checks | | default | |
171
+ | checks → approval | | emphasis | |
172
+ | approval → deploy | | security | |
173
+ | deploy → verify_prod | | default | |
174
+ | verify_prod → announce | healthy | emphasis | |
175
+ | checks → failed | red | security | error |
176
+ | verify_prod → rollback | | security | error |
177
+ | rollback → deploy | restore | dashed | return |
178
+
179
+ Main path (upstream): commit → pull_request → build → checks → approval → deploy → verify_prod → announce.
180
+
181
+ Phase **Change**: upstream columns 0–1.
182
+
183
+ Phase **Build + verify**: upstream columns 2–3.
184
+
185
+ Phase **Promote + observe**: upstream columns 4–5.
186
+
187
+ Group **Blocking checks**: ci, upstream columns 2–3.
188
+
189
+ Group **Recovery path**: exceptions, upstream columns 3–5.
190
+
191
+ **Commit to green build** (commit, pull_request, build, checks): Follow the change through reproducible build and blocking quality gates.
192
+
193
+ **Approve and promote** (checks, approval, deploy, verify_prod, announce): See who authorizes production and how success is verified.
194
+
195
+ **Failure and rollback** (checks, failed, verify_prod, rollback, deploy): Isolate the two places where delivery stops or reverses safely.
196
+
197
+ **One Happy Path**
198
+
199
+ - Every change is reviewed before a reproducible build
200
+ - Blocking checks must be green before human approval
201
+ - Production is complete only after smoke and SLO verification
202
+
203
+ **Stop Conditions**
204
+
205
+ - Test or security failure stops promotion
206
+ - Production health can reverse a release
207
+ - Rollback ownership is visible before an incident
208
+
209
+ **Release Evidence**
210
+
211
+ - Approval, immutable image, and check results are retained
212
+ - The release announcement follows verification
213
+ - The main path remains readable without hiding failure
214
+
215
+ ## Incident Response Runbook
216
+
217
+ Example: incident-response.workflow.json.
218
+
219
+ ```mermaid
220
+ flowchart TD
221
+ subgraph g_n_signals["Signals"]
222
+ n_alert["SLO Alert"]
223
+ end
224
+ subgraph g_n_responders["Incident Command"]
225
+ n_page["Page On-call"]
226
+ n_triage["Triage"]
227
+ n_declare["Declare"]
228
+ end
229
+ subgraph g_n_mitigation["Service Mitigation"]
230
+ n_contain["Contain"]
231
+ n_recover["Recover"]
232
+ end
233
+ subgraph g_n_recovery["Recovery Evidence"]
234
+ n_verify["Verify"]
235
+ end
236
+ subgraph g_n_communication["Stakeholder Communication"]
237
+ n_close["Resolve"]
238
+ n_update["Status Update"]
239
+ end
240
+ subgraph g_n_exceptions["Escalation + Rollback"]
241
+ n_escalate["Escalate"]
242
+ n_rollback["Rollback"]
243
+ end
244
+ n_alert -->|"page"| n_page
245
+ n_page --> n_triage
246
+ n_triage --> n_contain
247
+ n_contain --> n_recover
248
+ n_recover --> n_verify
249
+ n_verify --> n_close
250
+ n_triage --> n_declare
251
+ n_declare -.-> n_update
252
+ n_update --> n_escalate
253
+ n_verify --> n_rollback
254
+ ```
255
+
256
+ **All participants and semantic details**
257
+
258
+ | ID | Label | Detail | Type | Tag | Group |
259
+ | --- | --- | --- | --- | --- | --- |
260
+ | alert | SLO Alert | burn rate | messagebus | | signals |
261
+ | page | Page On-call | acknowledge | external | | responders |
262
+ | triage | Triage | scope impact | backend | | responders |
263
+ | declare | Declare | assign commander | security | SEV-1/2 | responders |
264
+ | contain | Contain | stop growth | backend | | mitigation |
265
+ | recover | Recover | restore | cloud | | mitigation |
266
+ | verify | Verify | SLO + traces | database | 15 min stable | recovery |
267
+ | close | Resolve | final update | external | | communication |
268
+ | update | Status Update | impact + ETA | frontend | | communication |
269
+ | escalate | Escalate | specialist | security | | exceptions |
270
+ | rollback | Rollback | last good | messagebus | | exceptions |
271
+
272
+ **Relationship semantics**
273
+
274
+ | From → to | Label | Kind | Classification / role |
275
+ | --- | --- | --- | --- |
276
+ | alert → page | page | emphasis | |
277
+ | page → triage | | default | |
278
+ | triage → contain | | emphasis | |
279
+ | contain → recover | | default | |
280
+ | recover → verify | | emphasis | |
281
+ | verify → close | | emphasis | |
282
+ | triage → declare | | security | |
283
+ | declare → update | | dashed | |
284
+ | update → escalate | | security | |
285
+ | verify → rollback | | security | error |
286
+
287
+ Main path (upstream): alert → page → triage → contain → recover → verify → close.
288
+
289
+ Phase **Detect**: upstream columns 0–1.
290
+
291
+ Phase **Triage + mitigate**: upstream columns 2–3.
292
+
293
+ Phase **Verify + close**: upstream columns 4–5.
294
+
295
+ Group **Incident command**: responders, upstream columns 1–3.
296
+
297
+ Group **If impact persists**: exceptions, upstream columns 3–5.
298
+
299
+ **Detect and establish command** (alert, page, triage, declare): Follow the first minutes from signal to an owned incident.
300
+
301
+ **Mitigate and prove recovery** (triage, contain, recover, verify, close): Keep mitigation separate from the evidence required to close.
302
+
303
+ **Escalation and communication** (declare, escalate, update, rollback): See who is paged, what stakeholders hear, and when rollback begins.
304
+
305
+ **Ownership First**
306
+
307
+ - A page is not an incident until someone owns command
308
+ - Severity and scope are explicit before mitigation spreads
309
+ - Escalation names the missing expertise
310
+
311
+ **Recovery Is Evidence**
312
+
313
+ - Mitigation can reduce impact without proving recovery
314
+ - SLOs and traces must stay healthy for a fixed window
315
+ - The final update follows verification, not optimism
316
+
317
+ **Communication Contract**
318
+
319
+ - Stakeholders receive impact, action, and next update time
320
+ - Rollback remains visible as a deliberate response
321
+ - Every branch has an owner and observable exit
322
+
323
+ ## Cache Miss Request Sequence
324
+
325
+ Example: cache-miss-request.sequence.json.
326
+
327
+ ```mermaid
328
+ sequenceDiagram
329
+ participant n_user as User
330
+ participant n_web as Web App
331
+ participant n_api as API
332
+ participant n_auth as Auth
333
+ participant n_redis as Redis
334
+ participant n_db as Postgres
335
+ participant n_trace as Trace
336
+ n_user->>n_web: open page
337
+ n_web->>n_api: GET /dashboard
338
+ n_api->>n_auth: verify JWT
339
+ n_auth-->>n_api: claims ok
340
+ n_api->>n_redis: read cache
341
+ n_redis-->>n_api: miss
342
+ n_api->>n_db: query profile + metrics
343
+ n_db-->>n_api: rows
344
+ n_api--)n_redis: set cache
345
+ n_api--)n_trace: emit trace
346
+ n_api-->>n_web: 200 JSON
347
+ n_web-->>n_user: render
348
+ ```
349
+
350
+ **All participants and semantic details**
351
+
352
+ | ID | Label | Detail | Type | Tag | Group |
353
+ | --- | --- | --- | --- | --- | --- |
354
+ | user | User | browser session | external | | |
355
+ | web | Web App | React UI | frontend | | |
356
+ | api | API | request handler | backend | | |
357
+ | auth | Auth | JWT verify | security | | |
358
+ | redis | Redis | cache | database | | |
359
+ | db | Postgres | source of truth | database | | |
360
+ | trace | Trace | async event | messagebus | | |
361
+
362
+ **Relationship semantics**
363
+
364
+ | From → to | Label | Kind | Classification / role |
365
+ | --- | --- | --- | --- |
366
+ | user → web | open page | default | |
367
+ | web → api | GET /dashboard | emphasis | |
368
+ | api → auth | verify JWT | security | |
369
+ | auth → api | claims ok | return | |
370
+ | api → redis | read cache | default | |
371
+ | redis → api | miss | return | |
372
+ | api → db | query profile + metrics | emphasis | |
373
+ | db → api | rows | return | |
374
+ | api → redis | set cache | dashed | |
375
+ | api → trace | emit trace | dashed | |
376
+ | api → web | 200 JSON | return | |
377
+ | web → user | render | return | |
378
+
379
+ Sequence segment: **Request**.
380
+
381
+ Sequence segment: **Fallback**.
382
+
383
+ Sequence segment: **Response + trace**.
384
+
385
+ **Request and identity** (user, web, api, auth): Follow the user request through the authentication check.
386
+
387
+ **Cache fallback** (api, redis, db): See the cache miss and the source-of-truth query it triggers.
388
+
389
+ **Return and trace** (db, api, redis, trace, web, user): Separate response latency from the non-blocking observability write.
390
+
391
+ **Happy Path**
392
+
393
+ - The main request is Web App -> API -> data source -> response
394
+ - Return messages are quieter than forward calls
395
+ - Activation bars make ownership duration visible
396
+
397
+ **Policy + Fallback**
398
+
399
+ - JWT verification is colored as a security interaction
400
+ - Cache miss is visible without overpowering the main path
401
+ - Database access only appears after cache fallback
402
+
403
+ **Async Trace**
404
+
405
+ - Trace emission is dashed and secondary
406
+ - It does not block the response path
407
+ - The diagram separates user-facing latency from observability
408
+
409
+ The message order is the original example, not a claim that all optional outcomes occur together. When authoring a real article, use source-supported `alt`, `opt` and `loop` blocks to express mutually exclusive outcomes and retries. The upstream activation spans indicate ownership duration; reproduce exact activation semantics only when the current source proves them.
410
+
411
+ ## Async Job Roundtrip
412
+
413
+ Example: async-job-roundtrip.sequence.json.
414
+
415
+ ```mermaid
416
+ sequenceDiagram
417
+ participant n_client as Client
418
+ participant n_api as Jobs API
419
+ participant n_queue as Queue
420
+ participant n_worker as Worker
421
+ participant n_provider as Provider
422
+ participant n_store as Job Store
423
+ participant n_notify as Notifier
424
+ n_client->>n_api: POST /jobs
425
+ n_api->>n_queue: enqueue job
426
+ n_api-->>n_client: 202 + job id
427
+ n_queue->>n_worker: deliver
428
+ n_worker->>n_provider: perform work
429
+ n_provider-->>n_worker: result / timeout
430
+ n_worker--)n_queue: retry if timeout
431
+ n_worker->>n_store: persist final state
432
+ n_worker--)n_notify: job.completed
433
+ n_notify--)n_client: signed webhook
434
+ n_client->>n_api: GET /jobs/:id
435
+ n_api->>n_store: read status
436
+ n_store-->>n_api: completed
437
+ n_api-->>n_client: 200 final result
438
+ ```
439
+
440
+ **All participants and semantic details**
441
+
442
+ | ID | Label | Detail | Type | Tag | Group |
443
+ | --- | --- | --- | --- | --- | --- |
444
+ | client | Client | mobile app | external | | |
445
+ | api | Jobs API | request edge | backend | | |
446
+ | queue | Queue | durable work | messagebus | | |
447
+ | worker | Worker | background | backend | | |
448
+ | provider | Provider | external API | cloud | | |
449
+ | store | Job Store | source of truth | database | | |
450
+ | notify | Notifier | webhook | messagebus | | |
451
+
452
+ **Relationship semantics**
453
+
454
+ | From → to | Label | Kind | Classification / role |
455
+ | --- | --- | --- | --- |
456
+ | client → api | POST /jobs | emphasis | |
457
+ | api → queue | enqueue job | emphasis | |
458
+ | api → client | 202 + job id | return | |
459
+ | queue → worker | deliver | emphasis | |
460
+ | worker → provider | perform work | default | |
461
+ | provider → worker | result / timeout | return | |
462
+ | worker → queue | retry if timeout | dashed | |
463
+ | worker → store | persist final state | emphasis | |
464
+ | worker → notify | job.completed | dashed | |
465
+ | notify → client | signed webhook | dashed | |
466
+ | client → api | GET /jobs/:id | default | |
467
+ | api → store | read status | default | |
468
+ | store → api | completed | return | |
469
+ | api → client | 200 final result | return | |
470
+
471
+ Sequence segment: **Accept**.
472
+
473
+ Sequence segment: **Background work**.
474
+
475
+ Sequence segment: **Notify + reconcile**.
476
+
477
+ **Accept without blocking** (client, api, queue): The API acknowledges quickly after durable enqueue.
478
+
479
+ **Background work and retry** (queue, worker, provider): Timeouts re-enter the queue instead of holding the original request open.
480
+
481
+ **Observe final consistency** (worker, store, notify, client, api): Webhook delivery is primary; polling remains a bounded fallback.
482
+
483
+ **Fast Acknowledgement**
484
+
485
+ - The caller receives a durable job id before work begins
486
+ - Queue ownership is visible in the acceptance contract
487
+ - The original connection does not wait for provider latency
488
+
489
+ **Bounded Recovery**
490
+
491
+ - Timeouts re-enter the queue with a retry policy
492
+ - Final state is persisted before notification
493
+ - The job store remains the source of truth
494
+
495
+ **Two Observation Paths**
496
+
497
+ - A signed webhook announces completion
498
+ - Status polling is a fallback, not a second workflow
499
+ - Both paths converge on the same final state
500
+
501
+ The message order is the original example, not a claim that all optional outcomes occur together. When authoring a real article, use source-supported `alt`, `opt` and `loop` blocks to express mutually exclusive outcomes and retries. The upstream activation spans indicate ownership duration; reproduce exact activation semantics only when the current source proves them.
502
+
503
+ ## Agent Run Lifecycle
504
+
505
+ Example: agent-run.lifecycle.json.
506
+
507
+ ```mermaid
508
+ stateDiagram-v2
509
+ state "Queued" as n_queued
510
+ state "Planning" as n_planning
511
+ state "Executing" as n_executing
512
+ state "Reviewing" as n_reviewing
513
+ state "Completed" as n_completed
514
+ state "Needs Approval" as n_approval
515
+ state "Blocked" as n_blocked
516
+ state "Failed" as n_failed
517
+ state "Cancelled" as n_cancelled
518
+ state "Expired" as n_expired
519
+ n_executing --> n_approval
520
+ n_reviewing --> n_blocked
521
+ n_executing --> n_failed
522
+ n_failed --> n_executing
523
+ n_blocked --> n_expired
524
+ n_approval --> n_cancelled
525
+ ```
526
+
527
+ **All participants and semantic details**
528
+
529
+ | ID | Label | Detail | Type | Tag | Group |
530
+ | --- | --- | --- | --- | --- | --- |
531
+ | queued | Queued | request accepted | start | entry | main |
532
+ | planning | Planning | build task graph | active | model | main |
533
+ | executing | Executing | tool calls | active | work | main |
534
+ | reviewing | Reviewing | quality gate | decision | check | main |
535
+ | completed | Completed | final response | success | done | main |
536
+ | approval | Needs Approval | human gate | waiting | pause | waiting |
537
+ | blocked | Blocked | missing input | waiting | wait | waiting |
538
+ | failed | Failed | recoverable error | failure | retryable | exceptions |
539
+ | cancelled | Cancelled | user stopped | failure | terminal | terminal |
540
+ | expired | Expired | timeout | failure | terminal | terminal |
541
+
542
+ **Relationship semantics**
543
+
544
+ | From → to | Label | Kind | Classification / role |
545
+ | --- | --- | --- | --- |
546
+ | executing → approval | | security | |
547
+ | reviewing → blocked | | default | |
548
+ | executing → failed | | security | |
549
+ | failed → executing | | emphasis | |
550
+ | blocked → expired | | security | |
551
+ | approval → cancelled | | security | |
552
+
553
+ The upstream main-phase rail orders Queued → Planning → Executing → Reviewing → Completed. This is a visual phase rail, not an explicit transition list. The Mermaid above preserves all explicitly authored transitions; do not invent trigger labels or approval-resume edges from the rail.
554
+
555
+ **Main lifecycle** (queued, planning, executing, reviewing, completed): Follow the ordered phases from accepted request to completed response.
556
+
557
+ **Human and input waits** (executing, approval, reviewing, blocked): See where the run pauses without becoming terminal.
558
+
559
+ **Recovery and terminal exits** (executing, failed, blocked, cancelled, expired): Separate retryable failure from cancellation and expiry.
560
+
561
+ **Main Path + Waits**
562
+
563
+ - The run has five ordered phases from queue to completion
564
+ - Approval and missing input pause the run without ending it
565
+
566
+ **Recovery + Terminal Exits**
567
+
568
+ - Failed loops back while retry budget remains
569
+ - Cancelled and Expired are terminal exits with no return path
570
+
571
+ ## Deployment Release Lifecycle
572
+
573
+ Example: deployment-release.lifecycle.json.
574
+
575
+ ```mermaid
576
+ stateDiagram-v2
577
+ state "Queued" as n_queued
578
+ state "Building" as n_building
579
+ state "Verifying" as n_verifying
580
+ state "Ready" as n_ready
581
+ state "Live" as n_live
582
+ state "Needs Approval" as n_approval
583
+ state "Rolling Back" as n_rollback
584
+ state "Health Paused" as n_paused
585
+ state "Cancelled" as n_cancelled
586
+ state "Failed" as n_failed
587
+ state "Rolled Back" as n_rolled_back
588
+ n_verifying --> n_approval
589
+ n_approval --> n_cancelled
590
+ n_ready --> n_rollback
591
+ n_rollback --> n_failed
592
+ n_live --> n_paused
593
+ n_paused --> n_rolled_back
594
+ ```
595
+
596
+ **All participants and semantic details**
597
+
598
+ | ID | Label | Detail | Type | Tag | Group |
599
+ | --- | --- | --- | --- | --- | --- |
600
+ | queued | Queued | change accepted | start | pending | main |
601
+ | building | Building | immutable image | active | running | main |
602
+ | verifying | Verifying | tests + policy | decision | gate | main |
603
+ | ready | Ready | promotion pending | waiting | approved | main |
604
+ | live | Live | production healthy | success | success | main |
605
+ | approval | Needs Approval | release owner | waiting | pause | waiting |
606
+ | rollback | Rolling Back | last good image | active | automatic | recovery |
607
+ | paused | Health Paused | SLO regression | waiting | observe | waiting |
608
+ | cancelled | Cancelled | approval denied | failure | terminal | terminal |
609
+ | failed | Failed | rollback failed | failure | terminal | terminal |
610
+ | rolled_back | Rolled Back | service restored | success | terminal | terminal |
611
+
612
+ **Relationship semantics**
613
+
614
+ | From → to | Label | Kind | Classification / role |
615
+ | --- | --- | --- | --- |
616
+ | verifying → approval | | security | |
617
+ | approval → cancelled | | security | |
618
+ | ready → rollback | | security | |
619
+ | rollback → failed | | security | |
620
+ | live → paused | | dashed | |
621
+ | paused → rolled_back | | emphasis | |
622
+
623
+ The upstream main-phase rail orders Queued → Building → Verifying → Ready → Live. This is a visual phase rail, not an explicit transition list. The Mermaid above preserves all explicitly authored transitions; do not invent trigger labels or approval-resume edges from the rail.
624
+
625
+ **Promotion rail** (queued, building, verifying, ready, live): Follow the deployment object from accepted change to healthy production.
626
+
627
+ **Approval gate** (verifying, approval, cancelled, ready): Approval pauses promotion and can terminate the release cleanly.
628
+
629
+ **Rollback outcomes** (ready, rollback, failed, live, paused, rolled_back): Separate pre-promotion failure from post-promotion health regression.
630
+
631
+ **Promotion Rail**
632
+
633
+ - The release object moves through five ordered phases
634
+ - Verification and approval remain distinct states
635
+ - Live means production health is currently proven
636
+
637
+ **Wait States**
638
+
639
+ - Human approval can pause without consuming a worker
640
+ - A health regression pauses further rollout
641
+ - Every wait exposes the event required to continue
642
+
643
+ **Explicit Endings**
644
+
645
+ - Denied approval ends as Cancelled
646
+ - Rollback controller failure ends as Failed
647
+ - Successful rollback is a terminal restored outcome