chati-dev 4.5.16 → 4.5.28

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 (122) hide show
  1. package/README.md +8 -3
  2. package/bin/chati.js +124 -66
  3. package/framework/agents/build/dev.md +5 -5
  4. package/framework/agents/deploy/devops.md +7 -7
  5. package/framework/agents/discover/brief.md +4 -4
  6. package/framework/agents/discover/brownfield-wu.md +3 -3
  7. package/framework/agents/discover/greenfield-wu.md +3 -3
  8. package/framework/agents/plan/architect.md +2 -2
  9. package/framework/agents/plan/detail.md +4 -4
  10. package/framework/agents/plan/phases.md +2 -2
  11. package/framework/agents/plan/tasks.md +2 -2
  12. package/framework/agents/plan/ux.md +2 -2
  13. package/framework/agents/quality/qa-implementation.md +11 -10
  14. package/framework/agents/quality/qa-planning.md +3 -3
  15. package/framework/agents/quality/qa-visual.md +1 -1
  16. package/framework/config.yaml +3 -3
  17. package/framework/constitution.md +18 -18
  18. package/framework/context/protocols.md +1 -1
  19. package/framework/context/quality.md +1 -1
  20. package/framework/context/root.md +4 -4
  21. package/framework/data/entity-registry.yaml +1 -1
  22. package/framework/domains/agents/orchestrator.yaml +2 -2
  23. package/framework/domains/constitution.yaml +1 -1
  24. package/framework/hooks/advance-trigger.js +4 -6
  25. package/framework/hooks/git-push-authority.js +45 -37
  26. package/framework/hooks/mode-governance.js +149 -40
  27. package/framework/hooks/model-governance.js +13 -20
  28. package/framework/hooks/prism-engine.js +74 -92
  29. package/framework/hooks/reasoning-escalator.js +23 -40
  30. package/framework/hooks/session-digest.js +12 -13
  31. package/framework/hooks/session-reader.js +224 -0
  32. package/framework/hooks/session-writer.js +195 -0
  33. package/framework/hooks/team-quality-gate.js +34 -24
  34. package/framework/i18n/en.yaml +2 -2
  35. package/framework/i18n/es.yaml +2 -2
  36. package/framework/i18n/fr.yaml +2 -2
  37. package/framework/i18n/pt.yaml +2 -2
  38. package/framework/intelligence/context-engine.md +4 -4
  39. package/framework/intelligence/memory-layer.md +1 -1
  40. package/framework/manifest.json +129 -119
  41. package/framework/manifest.sig +1 -1
  42. package/framework/orchestrator/chati-router.js +252 -25
  43. package/framework/orchestrator/chati.md +238 -70
  44. package/framework/schemas/session.schema.json +1 -1
  45. package/framework/tasks/orchestrator-deviation.md +1 -1
  46. package/framework/tasks/orchestrator-escalate.md +1 -1
  47. package/framework/tasks/orchestrator-handoff.md +6 -6
  48. package/framework/tasks/orchestrator-health.md +5 -9
  49. package/framework/tasks/orchestrator-mode-switch.md +3 -7
  50. package/framework/tasks/orchestrator-resume.md +10 -14
  51. package/framework/tasks/orchestrator-route.md +3 -3
  52. package/framework/tasks/orchestrator-spawn-terminal.md +1 -1
  53. package/framework/tasks/orchestrator-status.md +9 -9
  54. package/framework/tasks/orchestrator-suggest-mode.md +1 -1
  55. package/framework/tasks/qa-impl-consolidate.md +2 -2
  56. package/framework/tasks/qa-impl-performance-test.md +4 -4
  57. package/framework/tasks/qa-impl-regression-check.md +4 -4
  58. package/framework/tasks/qa-impl-sast-scan.md +1 -1
  59. package/framework/tasks/qa-impl-test-execute.md +1 -1
  60. package/framework/tasks/qa-impl-verdict.md +2 -2
  61. package/framework/tasks/qa-planning-consolidate.md +3 -3
  62. package/framework/tasks/qa-planning-coverage-plan.md +2 -2
  63. package/framework/tasks/qa-planning-gate-define.md +4 -4
  64. package/framework/tasks/qa-planning-risk-matrix.md +4 -4
  65. package/framework/tasks/qa-planning-test-strategy.md +2 -2
  66. package/node_modules/@chati/browser-capability/src/index.js +12 -2
  67. package/node_modules/@chati/planning/src/index.js +24 -4
  68. package/node_modules/@chati/provider-registry/src/index.js +11 -0
  69. package/node_modules/@chati/rail/src/index.js +1967 -83
  70. package/node_modules/@chati/release-lane/README.md +12 -8
  71. package/node_modules/@chati/release-lane/package.json +1 -1
  72. package/node_modules/@chati/release-lane/src/index.js +1426 -58
  73. package/node_modules/@chati/review-council/src/index.js +63 -0
  74. package/node_modules/@chati/tracking-clickup/README.md +13 -0
  75. package/node_modules/@chati/tracking-clickup/src/index.js +690 -30
  76. package/package-artifact-manifest.json +1 -0
  77. package/package-artifact-manifest.sig +1 -0
  78. package/package.json +16 -7
  79. package/scripts/verify-real-harness-e2e.js +1581 -0
  80. package/src/config/framework-adapter.js +4 -4
  81. package/src/installer/core.js +148 -53
  82. package/src/installer/manifest.js +140 -9
  83. package/src/installer/package-artifact.js +249 -0
  84. package/src/installer/templates.js +65 -20
  85. package/src/installer-v2/catalog-client.js +531 -23
  86. package/src/installer-v2/index.js +91 -34
  87. package/src/installer-v2/installation-authority.js +327 -0
  88. package/src/installer-v2/provider-executable.js +247 -0
  89. package/src/installer-v2/wizard-installation.js +1 -1
  90. package/src/orchestrator/browser-runtime.js +44 -13
  91. package/src/orchestrator/cli.js +1545 -174
  92. package/src/orchestrator/clickup-projection.js +43 -1
  93. package/src/orchestrator/clickup-runtime.js +355 -39
  94. package/src/orchestrator/doctor.js +16 -3
  95. package/src/orchestrator/index.js +16 -0
  96. package/src/orchestrator/planning-runtime.js +20 -2
  97. package/src/orchestrator/rail-adjudication-evidence.js +234 -0
  98. package/src/orchestrator/rail-evidence-authority.js +147 -0
  99. package/src/orchestrator/rail-execution-evidence.js +45 -0
  100. package/src/orchestrator/rail-runtime.js +836 -56
  101. package/src/orchestrator/release-runtime.js +65 -6
  102. package/src/orchestrator/review-runtime.js +186 -41
  103. package/src/orchestrator/runtime-installation-v2.js +236 -20
  104. package/src/orchestrator/session-manager.js +1167 -53
  105. package/src/terminal/adapters/claude-adapter.js +3 -1
  106. package/src/terminal/adapters/codex-adapter.js +2 -0
  107. package/src/terminal/adapters/grok-adapter.js +7 -4
  108. package/src/terminal/handoff-parser.js +19 -1
  109. package/src/terminal/prompt-builder.js +9 -1
  110. package/src/terminal/provider-preflight.js +36 -3
  111. package/src/terminal/rail-execution-worktree.js +213 -0
  112. package/src/terminal/rail-prompts.js +169 -0
  113. package/src/terminal/rail-readonly-workspace.js +324 -0
  114. package/src/terminal/run-agent.js +384 -24
  115. package/src/terminal/run-parallel.js +5 -0
  116. package/src/terminal/run-rail-adjudication.js +323 -0
  117. package/src/terminal/run-rail-review.js +291 -0
  118. package/src/terminal/run-rail-rework.js +325 -0
  119. package/src/terminal/run-rail-task.js +380 -0
  120. package/src/terminal/run-team.js +5 -0
  121. package/src/terminal/spawner.js +1225 -77
  122. package/src/wizard/index.js +3 -2
@@ -43,11 +43,11 @@ When the user invokes the provider-native Chati entry point, execute this sequen
43
43
  ### Step 1: Load Context
44
44
 
45
45
  ```
46
- 1. Read .chati/session.yaml (session state)
46
+ 1. Use the validated `session` object returned by the deterministic router
47
47
  2. Read .chati/project-context.md (provider-neutral project context)
48
48
  3. Read chati.dev/constitution.md (if first run or FRESH bracket - governance rules)
49
49
  4. Read chati.dev/config.yaml (version info, provider overrides)
50
- 5. Detect language from session.yaml → respond in that language
50
+ 5. Use `session.language` from the router → respond in that language
51
51
  ```
52
52
 
53
53
  ### Step 2: Check Subcommands
@@ -98,21 +98,42 @@ node .chati.dev/orchestrator/chati-router.js next
98
98
 
99
99
  Parse the JSON output. The `action` field tells you what to do:
100
100
 
101
+ <!-- ROUTER_ACTION_CATALOG:START -->
101
102
  | action | Go to |
102
103
  |--------|-------|
103
104
  | `setup` | Action: Setup |
104
105
  | `activate_interactive` | Action: Interactive Agent |
105
106
  | `spawn_routed_interactive` | Action: Routed Interactive Agent |
106
107
  | `resume_pending_interaction` | Action: Resume Pending Interaction |
108
+ | `pending_interaction_in_flight` | Action: Pending Interaction In Flight |
109
+ | `agent_execution_in_flight` | Action: Agent Execution In Flight |
110
+ | `awaiting_agent_advance` | Action: Awaiting Agent Advance |
111
+ | `pending_interaction_escalation_required` | Action: Pending Interaction Escalation |
107
112
  | `spawn_autonomous` | Action: Autonomous Agent |
108
113
  | `spawn_parallel` | Action: Parallel Spawn |
109
114
  | `spawn_team` | Action: Spawn Team (Article XXI) |
110
115
  | `rail_execute` | Action: RAIL Execution |
111
- | `resume` | Action: Resume |
116
+ | `rail_task_executed` | Action: RAIL Execution |
117
+ | `rail_task_execution_failed` | Action: RAIL Execution |
118
+ | `rail_review_recorded` | Action: RAIL Execution |
119
+ | `rail_rework_executed` | Action: RAIL Execution |
120
+ | `rail_rework_failed` | Action: RAIL Execution |
121
+ | `rail_adjudication_recorded` | Action: RAIL Execution |
112
122
  | `user_preview` | Action: User Preview |
123
+ | `scaffold_decision` | Action: Scaffold Decision (legacy runtime only) |
124
+ | `scaffold_decision_pending` | Action: Scaffold Decision Pending (legacy runtime only) |
125
+ | `correction_loop` | Action: Correction Loop (legacy runtime only) |
126
+ | `escalate` | Action: Correction Escalation (legacy runtime only) |
113
127
  | `complete` | Action: Complete |
114
128
  | `error` | Display error, suggest `/chati status` |
115
- | `version_mismatch` (in any response) | "Your CLI bundle is out of date. Run `npx chati-dev upgrade` to fix." Display once per session, then continue. |
129
+ | `proceed` | Continue after the requested operational check |
130
+ | `license_resolution_required` | Present the returned license recovery action |
131
+ | `remediation_required` | Present the returned doctor remediation action |
132
+ <!-- ROUTER_ACTION_CATALOG:END -->
133
+
134
+ If `version_mismatch` appears in any response, say: "Your CLI bundle is out of
135
+ date. Run `npx chati-dev upgrade` to fix." Display it once per session, then
136
+ continue.
116
137
 
117
138
  **Internal: track context bracket from JSON `context_bracket` but DO NOT display it to the user.** The bracket is internal telemetry - users should never see "Context: FRESH (90%)" or framework jargon like "Initiating handoff protocol". Speak in natural language about what you are doing, not the internal state.
118
139
 
@@ -162,7 +183,9 @@ Run via Bash:
162
183
  node .chati.dev/orchestrator/chati-router.js init --type {detected_type} --language {detected_lang} --name "{detected_name}" --workflow {detected_workflow}
163
184
  ```
164
185
 
165
- Parse JSON read `first_agent_file` activate that agent immediately (go to **Action: Interactive Agent**).
186
+ Parse the JSON, then run the deterministic router again with `next`. Follow the
187
+ returned action. V2 must dispatch conversational work through **Action: Routed
188
+ Interactive Agent** and must never execute an agent inside the opened harness.
166
189
 
167
190
  The user should experience a smooth start: they describe their project, the orchestrator confirms what it detected, and the first agent begins immediately.
168
191
 
@@ -170,12 +193,13 @@ The user should experience a smooth start: they describe their project, the orch
170
193
 
171
194
  ## Action: Interactive Agent
172
195
 
173
- These agents (greenfield-wu, brownfield-wu, brief) run in the same conversation.
196
+ This action is retained only for legacy v1 installations. A v2 installation
197
+ must reject it and run the deterministic router again to obtain a routed action.
174
198
 
175
199
  1. Treat `model_info` as internal routing evidence. Do not display it or ask the user to switch models. V2 conversational work uses Routed Interactive Agent instead.
176
- 2. Read the **FULL** agent file from `agent_file` in the JSON response (do NOT use limit/offset - read the entire file)
177
- 3. Load its full content and **become** that agent
178
- 4. Follow the agent's instructions - the user interacts with you directly
200
+ 2. Read the **FULL** agent file from `agent_file` in the JSON response (do NOT use limit/offset, read the entire file)
201
+ 3. Follow the legacy agent instructions in the current conversation.
202
+ 4. Keep this path isolated from v2 installations.
179
203
  5. When the agent completes its work and self-validates, extract the score
180
204
  6. Present **Completion Options** (see below) - wait for user choice before advancing
181
205
  7. **MANDATORY - On user approval, run via Bash:**
@@ -197,9 +221,11 @@ internal router.
197
221
  2. Execute the exact `spawn_command` returned by the router.
198
222
  3. Parse the JSON result:
199
223
  - `complete`: present Completion Options. On approval, advance the agent.
200
- - `needs_input`: ask only `needs_input_question` in the user's language,
201
- relay the response through `--additional-context`, then rerun the same
202
- exact provider and model binding. Limit this relay to three cycles.
224
+ - `needs_input`: do not construct or modify a runner command. Run the
225
+ deterministic router again, which returns `resume_pending_interaction`,
226
+ then follow Action: Resume Pending Interaction. This keeps the exact
227
+ question, response transport and provider binding under the canonical
228
+ relay contract.
203
229
  - `error`: use the Recovery Protocol. Never silently change provider or
204
230
  model in a v2 installation.
205
231
  4. The opened CLI remains the conversation orchestrator. The routed process
@@ -208,16 +234,76 @@ internal router.
208
234
  ## Action: Resume Pending Interaction
209
235
 
210
236
  The routed process already asked a question and the canonical session stored
211
- it. Do not execute `spawn_command` yet and do not dispatch the agent again.
237
+ it. `spawn_command` is intentionally null. Do not dispatch the agent again.
212
238
 
213
239
  1. Present only the exact `question` returned by the router, using
214
240
  `session.language`.
215
- 2. When the user answers, execute the returned `spawn_command` once with
216
- `--additional-context "{user_response}"` appended.
241
+ 2. When the user answers, write `{ "response": "<exact user response>" }` to
242
+ `response_file` using the harness's native file-write tool, never a shell
243
+ command. Then execute `deferred_spawn_command` exactly once and unchanged.
217
244
  3. Parse the new result using Action: Routed Interactive Agent.
218
245
  4. Read `relay_cycles` from the router response. After three unresolved relay cycles, use the configured reasoning
219
246
  escalation. Do not invent an answer or silently switch providers.
220
247
 
248
+ ## Action: Agent Execution In Flight
249
+
250
+ Another opened CLI already owns the exact execution claim for this step. Do
251
+ not build, copy, or re-run a spawn command. Tell the user that the current step
252
+ is already running in another CLI and keep the canonical session unchanged.
253
+
254
+ ## Action: Awaiting Agent Advance
255
+
256
+ The routed process finished successfully, but its exact result has not yet
257
+ been committed through canonical `advance`.
258
+
259
+ 1. Do not dispatch the agent again and do not synthesize a replacement result.
260
+ 2. If this CLI owns the completed process result, immediately submit that exact
261
+ handoff and score through `orchestrate advance`.
262
+ 3. If another CLI owns the result, present `status_summary` and wait for that
263
+ CLI to finish canonical advance. A different CLI may resume only through an
264
+ explicit recovery path that preserves the original execution evidence.
265
+ 4. Run `next` again only after canonical advance succeeds.
266
+
267
+ ## Action: Pending Interaction In Flight
268
+
269
+ Another process already owns this exact relay. Do not execute any command and
270
+ do not ask the question again. Tell the user briefly that the response is still
271
+ being processed. The router automatically recovers an abandoned claim after
272
+ the runner timeout plus its safety margin.
273
+
274
+ ## Action: Pending Interaction Escalation
275
+
276
+ The same interaction remained unresolved after three complete relays. Do not
277
+ run a fourth deferred command and do not escalate a technical judgment directly
278
+ to the user. The router has already selected the installation-eligible top-tier
279
+ adjudication route in `model_info`. Execute `spawn_command` exactly once and
280
+ parse its result using Action: Routed Interactive Agent. Ask the user only when
281
+ the adjudicator returns `needs_input` because the remaining issue requires
282
+ authority, product intent or information no configured model can infer safely.
283
+
284
+ ## Action: Scaffold Decision (legacy runtime only)
285
+
286
+ Present the three exact options returned by the router in the session language.
287
+ Do not apply files before the user selects `apply`. Route `dryrun`, `apply`, or
288
+ `skip` back through `advance --decision` with the unchanged agent and score.
289
+
290
+ ## Action: Scaffold Decision Pending (legacy runtime only)
291
+
292
+ Present the dry-run result in the session language. The next executable choice
293
+ must be either `apply` or `skip`, sent through `advance --decision` with the
294
+ unchanged agent and score.
295
+
296
+ ## Action: Correction Loop (legacy runtime only)
297
+
298
+ Invoke only the returned correction target, with the returned findings and
299
+ fault origin. Do not advance another agent until that correction completes and
300
+ passes its normal gate.
301
+
302
+ ## Action: Correction Escalation (legacy runtime only)
303
+
304
+ The bounded correction limit was reached. Present the returned evidence and
305
+ options in the session language, then wait for the explicit human decision.
306
+
221
307
  ---
222
308
 
223
309
  ## Completion Options (Protocol 3 - Guided Options)
@@ -277,11 +363,15 @@ or the kind is `agent`, skip this entirely and use the normal agent path. This
277
363
  is purely a dispatch optimization: it never changes WHAT a task must achieve,
278
364
  only what executes it, and it is invisible when the feature is off.
279
365
 
280
- - **script**: run it deterministically with no LLM. Via Bash:
281
- `node .chati.dev/orchestrator/chati-router.js run-script-task --ref "{execution_ref}" --id "{task_id}" --title "{task_title}"`
366
+ - **script**: run it deterministically with no LLM. Write the task fields as
367
+ JSON (`kind`, `ref`, `id`, `title`) to
368
+ `.chati/runtime/script-task-request.json` using the harness's native file
369
+ tool. Then execute the fixed command below. Never interpolate task fields
370
+ into a shell command:
371
+ `node .chati.dev/orchestrator/chati-router.js run-script-task --request-file .chati/runtime/script-task-request.json`
282
372
  Handle the JSON `status`:
283
373
  - `passed` → the task is done. Advance: `node .chati.dev/orchestrator/chati-router.js advance --agent {current_agent} --score 100`
284
- - `failed` → the deterministic check is negative. Route to dev (Fault Vector Protocol: CODE) to fix, then re-run the script task.
374
+ - `failed` → the deterministic check is negative. In v2, return the sealed task to the RAIL implementation or rework lane, then re-run the script task. Legacy v1 may use its existing implementation agent.
285
375
  - `error` → the executor could not run. Surface the summary to the user and check the execution_ref against the executor registry.
286
376
  - `ran: false` → the feature is off or the kind is not script; fall back to the agent path silently.
287
377
  - **human**: present the decision in the user's language as a Guided Option and wait for their choice. Record it, then advance. Never decide for them.
@@ -305,23 +395,15 @@ These agents run in separate processes using the exact provider and model bindin
305
395
  3. Execute `spawn_command` via Bash tool (the full command is in the JSON)
306
396
  4. Wait for JSON output from the spawned process. Handle `status`:
307
397
  - `"complete"` → Present **Completion Options** (see above) → on approval, run `node chati.dev/orchestrator/chati-router.js advance --agent {name} --score {score}`
308
- - `"needs_input"` → Read `needs_input_question`, present to user in their language, then re-run spawn with `--additional-context "{user_response}"` (max 3 relay cycles)
398
+ - `"needs_input"` → Run the deterministic router again and follow **Action: Resume Pending Interaction**. Never interpolate the response into a command.
309
399
  - `"error"` → Apply Recovery Protocol (see below)
310
400
 
311
- ### Sequential Fallback
401
+ ### Provider Failure
312
402
 
313
- If terminal spawning fails (CLI not found, system error), fall back **silently**:
314
- ```
315
- 1. Do NOT display any error or fallback message to the user
316
- 2. Read the agent .md file directly and become that agent in-conversation
317
- 3. Execute the agent's mission and write all deliverables (artifact + handoff)
318
- 4. MANDATORY on completion — before presenting any summary:
319
- - Run via Bash: `node .chati.dev/orchestrator/chati-router.js advance --agent {name} --score {score}`
320
- - This persists the completion to session.yaml, updates Magic Docs, and
321
- activates the next agent. Skipping it leaves the pipeline frozen.
322
- 5. Present Completion Options exactly as the normal spawn path does
323
- 6. Continue pipeline normally — the user should not notice any difference
324
- ```
403
+ If terminal spawning fails (CLI not found, authentication or system error), do
404
+ not execute the task inside the opened conversation CLI and do not substitute a
405
+ provider or model. Preserve the signed route and pending response, then apply
406
+ the Recovery Protocol. The conversation CLI remains the orchestrator only.
325
407
 
326
408
  **NOTE:** A provider-native post-tool hook may also fire on handoff write when
327
409
  supported. In interactive mode, the explicit router advance call remains the
@@ -347,12 +429,9 @@ Planning phase agents (detail, architect, ux) run simultaneously.
347
429
  3. Consolidate and parse the member outputs without replacing their bindings
348
430
  4. Present **Completion Options** (Parallel Group variant) - wait for user choice
349
431
  5. On approval, for each completed agent, run `node chati.dev/orchestrator/chati-router.js advance --agent {name} --score {score}`
350
- 6. If partial or total failure (spawning unavailable):
351
- ```
352
- Fall back silently to sequential in-conversation execution.
353
- Do NOT display error messages about spawning or CLI availability.
354
- Read each agent .md file and execute sequentially within the conversation.
355
- ```
432
+ 6. If partial or total failure (spawning unavailable), preserve each signed
433
+ member binding and apply the Recovery Protocol. Never execute a task agent
434
+ inside the opened conversation CLI.
356
435
 
357
436
  ### Parallelization Rules
358
437
  - GROUP 1 (Planning Team): detail, architect, ux, qa-planning - run as team (QA-Planning activates after trio completes)
@@ -672,10 +751,10 @@ If the Agent tool is unavailable or any sub-agent spawn fails:
672
751
  Use the existing Action: Parallel Spawn or Action: Autonomous Agent flow
673
752
  2. Do NOT display any error or fallback message to the user
674
753
  3. Run: node .chati.dev/orchestrator/chati-router.js team-dissolve --team-id {team_id}
675
- to mark the team as degraded in session.yaml
754
+ to mark the team as degraded through the canonical session manager
676
755
  4. All quality gates and thresholds remain unchanged
677
- 5. Alternatively, if spawn_parallel also fails, use Sequential Fallback:
678
- read each agent .md file and execute sequentially in-conversation
756
+ 5. If `spawn_parallel` also fails, preserve the signed member bindings and
757
+ apply the Recovery Protocol. Do not execute the agents in-conversation.
679
758
  ```
680
759
 
681
760
  ---
@@ -690,36 +769,123 @@ review, bounded rework, ClickUp projection and the Release Lane.
690
769
  ```
691
770
  node .chati.dev/orchestrator/chati-router.js rail-next --handoff-id {handoff_id}
692
771
  ```
693
- 3. Execute only a dependency-ready task. Use its selected provider and model
694
- binding from `.chati/v2/installation.json`. Never substitute an unselected
695
- vendor or model.
696
- 4. Record every claim, review, completion, rework count and ClickUp projection
772
+ 3. Dispatch one returned task only through the production RAIL boundary:
773
+ ```
774
+ node .chati.dev/orchestrator/chati-router.js rail-dispatch --handoff-id {handoff_id} --task-id {task_id} --harness {current_harness}
775
+ ```
776
+ This command reads the task binding from the sealed handoff, verifies it
777
+ against the signed installation, claims the attempt, checks provider
778
+ readiness, and invokes the exact provider, model and reasoning setting.
779
+ Before creating the provider process, RAIL persists a claim-bound initial
780
+ launch reservation. Authority-bearing providers run inside a Linux
781
+ Bubblewrap PID namespace bound to the authenticated local PID, host and
782
+ process group. Missing or untrusted containment fails closed before process
783
+ creation. If the supervisor stops after the initial dispatch and before
784
+ canonical execution evidence, that attempt can never auto-recover or launch
785
+ a second mutating provider; it requires explicit operator remediation.
786
+ Never invoke the task CLI directly or substitute another binding.
787
+ If execution returns `rail_task_execution_failed`, keep the returned
788
+ `attempt_id`. Transient retries run inside that same command while its
789
+ supervisor and lease remain live. After the command exits, another process
790
+ cannot reuse the claim. Wait for lease expiry, then run `rail-recover` for
791
+ that same attempt instead of `rail-dispatch`; recovery and provider launch
792
+ occur atomically in the new supervisor process. A failed execution is canonical
793
+ audit evidence but does not consume the attempt's successful result slot.
794
+ Any post-claim error also returns the canonical `attempt_id` with
795
+ `rail_recover_same_attempt_after_lease_expiry`. On an orderly failure, the
796
+ owning supervisor expires its own lease before exiting; an abrupt stop uses
797
+ the original lease deadline. Never mint a replacement attempt for
798
+ that task: let the current supervisor retry internally, or recover that
799
+ exact attempt after the lease has expired only when the prior failure
800
+ already has canonical execution evidence.
801
+ 4. After a successful dispatch, run the independent selected reviewer:
802
+ ```
803
+ The executor must have committed a clean result that descends from the
804
+ sealed base. The reviewer binds its evidence to that exact result commit.
805
+ node .chati.dev/orchestrator/chati-router.js rail-review-run --handoff-id {handoff_id} --attempt-id {attempt_id} --harness {current_harness}
806
+ ```
807
+ `rail-review-run` is the only accepted review entry point. Never construct
808
+ or submit a review decision directly: RAIL accepts only the decision parsed
809
+ from output bound to the authorized terminal completion receipt.
810
+ Review and adjudication run through the selected provider's native read-only
811
+ mode. RAIL also snapshots the complete project filesystem recursively,
812
+ including ignored files, nested repositories, Git internals and non-journal
813
+ `.chati` state, then rejects any mutation before accepting evidence. External
814
+ symlinks and special files fail closed. Only exact canonical RAIL journal
815
+ paths remain outside the postcondition.
816
+ Follow only `next_required_action`. For `rail_rework_required`, run:
817
+ ```
818
+ node .chati.dev/orchestrator/chati-router.js rail-rework --handoff-id {handoff_id} --attempt-id {attempt_id} --harness {current_harness}
819
+ ```
820
+ If this returns `rail_rework_failed`, reconcile or recover the lease when
821
+ required and rerun `rail-rework` with that same attempt id. A failed rework
822
+ does not consume its authorizing decision. Do not start another review until
823
+ a successful rework result is journaled. Before a mutating rework provider
824
+ starts, RAIL reserves the exact source decision under the current claim
825
+ generation. A concurrent rework is rejected before launch; an unreceipted
826
+ prior launch requires reconciliation rather than a second provider.
827
+ Then run a fresh `rail-review-run`. Never reuse a prior acceptance.
828
+ 5. If review returns `rail_adjudication_required`, run the selected top-tier
829
+ council. It may use only providers enabled by the signed installation:
830
+ ```
831
+ node .chati.dev/orchestrator/chati-router.js rail-adjudicate --handoff-id {handoff_id} --attempt-id {attempt_id} --harness {current_harness}
832
+ ```
833
+ A bounded correction returns to `rail-rework`. A handoff revision returns to
834
+ Planning. Human authority is valid only for scope, security, privacy, cost
835
+ or an external action.
836
+ 6. Record every claim, review, completion, rework count and ClickUp projection
697
837
  through RAIL. ClickUp is a projection, while the local journal remains
698
838
  canonical during an outage. For the internal profile, a merged completion
699
839
  MUST include `actual_human_effort`, `actual_ai_processing`, `rework_cycles`
700
840
  and one verified review reference per rework cycle. RAIL writes the
701
841
  in-progress, ready-to-merge and closed projections automatically; do not
702
842
  create a parallel manual tracking path.
703
- 5. After two normal rework cycles, use the configured top-tier adjudication
704
- route. Escalate to a human only for an authority decision, not an ordinary
705
- technical correction.
706
- 6. When `rail-next` has no ready work, check the Release Lane. It may prepare
707
- evidence, but cannot deploy or publish without explicit authorization.
708
-
709
- ## Action: Resume
710
-
711
- The user is returning to an active session.
712
-
713
- 1. Present a natural-language summary of where we are in the user's language. Translate the internal `status_summary` into user-friendly terms - never say "qa-planning completed" or expose internal agent names.
714
- 2. Track context bracket internally - do NOT display.
715
- 3. Offer options in plain language (translate internal agent names to user-facing phase descriptions):
843
+ Reconcile canonical state with `rail-tracking-reconcile`; never invent a
844
+ ClickUp receipt. For external delivery, run `rail-tracking-pending` before
845
+ any remote call. A new item is durably marked `sent_unconfirmed` before its
846
+ operation and payload are returned. Send that payload at most once, then
847
+ record a successful response with `rail-tracking-ack`. If the response is
848
+ absent or uncertain, rerunning `rail-tracking-pending` returns only
849
+ `lookup_before_resend`, without an operation or payload. Perform an
850
+ idempotency-key lookup and record its JSON result through
851
+ `rail-tracking-lookup`. Resend only after that lookup proves `not_found` and
852
+ a subsequent `rail-tracking-pending` returns a fresh send instruction.
853
+ Every signed acknowledgement or lookup must echo the returned
854
+ `delivery_attempt` and `delivery_attempted_at`; receipts from an earlier
855
+ generation fail closed.
856
+ The runtime maintains live leases automatically. There are no standalone
857
+ public claim or heartbeat commands. Each task, review, rework, adjudication
858
+ and completion action owns the claim from one long-lived supervisor, then
859
+ explicitly relinquishes it after persisting its canonical result. The next
860
+ action atomically recovers that released claim before any provider launch.
861
+ If an interrupted build process requires explicit recovery, use only the
862
+ installed router:
716
863
  ```
717
- 1. Continue (Recommended)
718
- 2. Review what we just produced
719
- 3. Show me the full project status
864
+ node .chati.dev/orchestrator/chati-router.js rail-recover --handoff-id {handoff_id} --attempt-id {attempt_id} --operator-id {operator_id}
720
865
  ```
721
-
722
- ---
866
+ Recovery accepts no caller-supplied process identity, lease duration or
867
+ reconciliation. It requires an expired lease and canonical evidence for the
868
+ prior failed execution, then records recovery and launches the selected
869
+ provider in that same live process, which remains the lease supervisor until
870
+ execution ends. An interrupted initial dispatch without canonical execution
871
+ evidence is permanently ineligible for automatic recovery, even if its
872
+ original processes appear stopped. An unresolved launch reservation or
873
+ unreceipted prepared effect likewise fails closed for explicit operator
874
+ handling.
875
+ 7. Completion requires real Git, passed CI, accepted review and acceptance
876
+ evidence in `--completion-json`. CI and acceptance evidence each require an
877
+ exact signed receipt from the project-bound authority certified by CHATI at
878
+ `.chati/v2/rail/evidence-authority.json`; a missing, expired or mismatched
879
+ authority fails closed. `git.base_ref` must equal the sealed base,
880
+ `git.result_ref` must be its non-base descendant, `git.commit_refs` must
881
+ include both, and `ci.commit_ref` plus the latest accepted review must equal
882
+ that result commit. Call `rail-complete` first for
883
+ `ready_to_merge`, then again for `merged`. Never synthesize CI or effort
884
+ evidence. A dependency unlocks only after the merged journal record.
885
+ 8. When `rail-next` has no ready work, run `rail-release-ready`. The Release
886
+ Lane may prepare evidence, but its production transport cannot deploy,
887
+ publish or roll back without explicit human authorization scoped to the
888
+ immutable release attempt and passed smoke evidence.
723
889
 
724
890
  ## Action: User Preview (legacy runtime only)
725
891
 
@@ -826,7 +992,7 @@ Before routing to the current agent, check for inline queries. Handle them WITHO
826
992
  | Signal | Action |
827
993
  |--------|--------|
828
994
  | "what did we learn", "show memories", "past decisions" | Load `.chati/memories/`, present summary grouped by type |
829
- | "what happened today", "show progress", "session summary" | Read session.yaml, present timeline with scores |
995
+ | "what happened today", "show progress", "session summary" | Run `node .chati.dev/orchestrator/chati-router.js status`, validate its JSON, and present the returned timeline and scores |
830
996
  | "how does this work", "what agents exist", "what phase" | Explain pipeline position, list agents, show next steps |
831
997
 
832
998
  Multi-language signals also apply (e.g., "o que aprendemos", "mostra o progresso", "como funciona").
@@ -971,7 +1137,7 @@ When the independent RAIL reviewer classifies a fault:
971
1137
 
972
1138
  ### ALLOWED
973
1139
  - Read any file in the project (for state detection)
974
- - Write to .chati/session.yaml (session state)
1140
+ - Request session transitions through the CLI session manager or deterministic router
975
1141
  - Reconcile every enabled harness's native session-lock file
976
1142
  - Present status dashboards
977
1143
  - Generate session digests
@@ -1005,12 +1171,14 @@ Level 1 - Retry:
1005
1171
  Level 2 - Escalate:
1006
1172
  Agent fails 3 consecutive times → present options:
1007
1173
  1. Retry with different approach
1008
- 2. Skip agent (document risk in session.yaml)
1174
+ 2. Skip agent through `deviation --type skip --target {agent}`. Show its impact first and rerun with `--confirm true` only after explicit user confirmation; the returned deviation record is the risk evidence.
1009
1175
  3. Return to previous agent
1010
1176
 
1011
1177
  Level 3 - Session Recovery:
1012
- session.yaml corruptedattempt reconstruction from .chati/project-context.md + artifacts
1013
- If reconstruction fails suggest re-init preserving artifacts
1178
+ Router reports unsafe session staterun `node .chati.dev/orchestrator/chati-router.js doctor`
1179
+ Report the validated diagnostics and stop. A model or harness MUST NOT read,
1180
+ reconstruct, or edit canonical session state. Recovery requires an explicit
1181
+ user-owned backup restore or re-init outside the active session.
1014
1182
 
1015
1183
  Level 4 - Graceful Degradation:
1016
1184
  Critical error → save state, notify user with recovery instructions
@@ -1023,7 +1191,7 @@ Level 4 - Graceful Degradation:
1023
1191
 
1024
1192
  1. **Single Entry Point**: The orchestrator is the ONLY way users interact with Chati.dev
1025
1193
  2. **Transparent Routing**: Users should understand which agent is active and why
1026
- 3. **State Preservation**: Every state change is logged in session.yaml. No action is lossy
1194
+ 3. **State Preservation**: Every state change is logged through the canonical session manager. No action is lossy
1027
1195
  4. **Fail-Safe Defaults**: When uncertain, default to planning mode and the safest agent
1028
1196
  5. **Progressive Disclosure**: Start simple, reveal depth on demand
1029
1197
  6. **Pipeline Respect**: Never skip pipeline steps without explicit user consent
@@ -1040,7 +1208,7 @@ Self-validation checklist for orchestrator decisions:
1040
1208
  2. **Mode compliance**: Operation respects current mode restrictions?
1041
1209
  3. **Pipeline integrity**: Routing follows defined pipeline order?
1042
1210
  4. **Deviation handling**: Deviation properly logged and context preserved?
1043
- 5. **Session consistency**: session.yaml in sync with actual state?
1211
+ 5. **Session consistency**: validated router state in sync with actual state?
1044
1212
  6. **Language consistency**: All interactions in user's chosen language?
1045
1213
  7. **Constitution compliance**: No constitutional article violated?
1046
1214
  8. **Handoff completeness**: Handoff contains all required data?
@@ -142,7 +142,7 @@
142
142
  "type": "object",
143
143
  "required": ["status", "score", "criteria_count"],
144
144
  "properties": {
145
- "status": { "enum": ["pending", "in_progress", "waiting_for_user", "completed", "skipped", "needs_revalidation"] },
145
+ "status": { "enum": ["pending", "in_progress", "waiting_for_user", "awaiting_advance", "completed", "skipped", "needs_revalidation"] },
146
146
  "score": { "type": "number", "minimum": 0, "maximum": 100 },
147
147
  "criteria_count": { "type": "integer", "minimum": 0 },
148
148
  "completed_at": { "type": ["string", "null"], "format": "date-time" }
@@ -21,7 +21,7 @@ criteria:
21
21
  Handle changes to project scope, priorities, or approach that deviate from the current plan. Evaluate impact, propose alternatives, and re-route the pipeline.
22
22
 
23
23
  ## Prerequisites
24
- - Session state at `.chati/session.yaml`
24
+ - Router-validated canonical session context
25
25
  - Current plan in artifacts (brief, requirements, phases, etc.)
26
26
  - Constitution at `chati.dev/constitution.md`
27
27
  - User input describing the change
@@ -22,7 +22,7 @@ Handle agent failures, blockers, and critical issues by collecting context, clas
22
22
 
23
23
  ## Prerequisites
24
24
  - Failure signal from agent
25
- - Session state at `.chati/session.yaml`
25
+ - Router-validated canonical session context
26
26
  - Agent definition with failure handling rules
27
27
  - Error logs or stack traces (if available)
28
28
 
@@ -23,7 +23,7 @@ Receive output from a completed agent, validate it, create a handoff document, u
23
23
  ## Prerequisites
24
24
  - Agent has signaled completion
25
25
  - Agent output available
26
- - Session file at `.chati/session.yaml`
26
+ - Deterministic router and canonical session manager available
27
27
  - Handoff directory at `.chati/artifacts/handoffs/`
28
28
  - Agent definition with success criteria
29
29
 
@@ -68,7 +68,7 @@ Write handoff to file system:
68
68
  - Set appropriate permissions
69
69
 
70
70
  ### 6. Update Session State
71
- Modify `.chati/session.yaml`:
71
+ Run the router's canonical completion or `advance --agent <agent> --score <score>` action. The session manager must atomically:
72
72
  - Set agent status to `completed`
73
73
  - Add completion timestamp
74
74
  - Increment pipeline progress
@@ -143,10 +143,10 @@ If handoff document can't be saved:
143
143
  - Escalate with write error details
144
144
 
145
145
  ### Session Update Failure
146
- If `.chati/session.yaml` update fails:
147
- - Retry with backup creation
148
- - If persistent: Continue with in-memory state
149
- - Warn user about state persistence issue
146
+ If the router reports a session update failure:
147
+ - Report the exact error and stop
148
+ - Do not retry by editing, replacing or reconstructing session state
149
+ - Preserve the handoff artifact for a later canonical retry
150
150
 
151
151
  ### Circular Routing Detected
152
152
  If next agent would create a loop:
@@ -64,7 +64,7 @@ Verify task files in `chati.dev/tasks/`:
64
64
 
65
65
  ### 4. Validate Schema Files
66
66
  Check schema definitions in `chati.dev/schemas/`:
67
- - session.yaml
67
+ - canonical session schema
68
68
  - handoff.yaml
69
69
  - config.yaml
70
70
  - Agent-specific schemas
@@ -74,12 +74,8 @@ Verify:
74
74
  - Required fields documented
75
75
  - Data types specified
76
76
 
77
- ### 5. Test Session File
78
- If session exists at `.chati/session.yaml`:
79
- - Validate YAML syntax
80
- - Check schema compliance
81
- - Verify referenced artifacts exist
82
- - Check for corruption indicators
77
+ ### 5. Test Canonical Session State
78
+ Run `node chati.dev/orchestrator/chati-router.js doctor`. Consume the returned checks without opening the session file. Report unsafe or corrupt state exactly as returned and stop any mutable workflow.
83
79
 
84
80
  ### 6. Verify Directory Structure
85
81
  Ensure required directories exist:
@@ -199,7 +195,7 @@ health_report:
199
195
  - file: "chati.dev/installer/install.js"
200
196
  status: "ok"
201
197
  executable: true
202
- - file: ".chati/session.yaml"
198
+ - file: "canonical-session-state (validated by router doctor)"
203
199
  status: "ok"
204
200
  valid: true
205
201
  schema_compliant: true
@@ -237,7 +233,7 @@ health_report:
237
233
  valid_schemas: 8
238
234
  issues: []
239
235
  schemas:
240
- - "session.yaml"
236
+ - "canonical-session-schema"
241
237
  - "handoff.yaml"
242
238
  - "config.yaml"
243
239
 
@@ -21,7 +21,7 @@ criteria:
21
21
  Execute transitions between modes (planning, build, deploy) while enforcing Article XI governance rules and validating quality gates.
22
22
 
23
23
  ## Prerequisites
24
- - Session state at `.chati/session.yaml`
24
+ - Validated session state returned by `chati-router.js status`
25
25
  - Constitution Article XI at `chati.dev/constitution.md`
26
26
  - Quality scores from QA agents
27
27
  - Agent completion statuses
@@ -36,7 +36,7 @@ Identify the transition request:
36
36
  - **Backward**: QA-Implementation found spec issues, reverting to planning
37
37
 
38
38
  ### 2. Load Current Mode State
39
- Read session to understand current position:
39
+ Run `node chati.dev/orchestrator/chati-router.js status` and use only the returned validated session context to understand:
40
40
  - Current mode (planning/build/deploy)
41
41
  - Last completed agent in current mode
42
42
  - Quality scores
@@ -104,11 +104,7 @@ Based on autonomous_gate and confidence:
104
104
  - **Block**: confidence low → escalate with issues
105
105
 
106
106
  ### 8. Update Session Mode
107
- If transition approved:
108
- - Change `mode` field in session.yaml
109
- - Set `current_agent` to first agent of new mode
110
- - Log transition in `mode_transitions` array
111
- - Update `pipeline_position`
107
+ If transition is approved, execute the router-returned transition action. The canonical session manager changes `mode`, selects the first agent, appends `mode_transitions` and updates pipeline position. Never edit the session file directly.
112
108
 
113
109
  ### 9. Apply Mode Scope Restrictions
114
110
  Enforce Article XI scope rules for new mode: