samagotchi 0.171.0 → 0.172.1

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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -1
  3. data/bin/chi +6 -4
  4. data/docs/architecture.md +24 -7
  5. data/docs/bundles.md +4 -21
  6. data/docs/cli.md +50 -80
  7. data/docs/configuration.md +11 -13
  8. data/docs/context.md +5 -6
  9. data/docs/guardrails.md +57 -96
  10. data/docs/hooks.md +3 -4
  11. data/docs/internals/attached-context.md +6 -7
  12. data/docs/internals/background-tasks.md +4 -3
  13. data/docs/internals/bridge.md +29 -3
  14. data/docs/internals/engine.md +21 -9
  15. data/docs/internals/objectives.md +3 -5
  16. data/docs/internals/participants.md +118 -143
  17. data/docs/internals/prompt-caching.md +4 -5
  18. data/docs/internals/web-frontend.md +70 -27
  19. data/docs/internals/working-set.md +7 -5
  20. data/docs/memory.md +1 -1
  21. data/docs/plugins.md +2 -16
  22. data/docs/scheduling.md +1 -1
  23. data/docs/sessions.md +15 -49
  24. data/docs/sub-agent.md +2 -2
  25. data/docs/system-one.md +2 -2
  26. data/docs/testing.md +81 -8
  27. data/lib/samagotchi/bridge/card_store.rb +1 -0
  28. data/lib/samagotchi/bridge/sse_writer.rb +1 -0
  29. data/lib/samagotchi/bridge/turn_accumulator.rb +0 -1
  30. data/lib/samagotchi/bridge.rb +26 -9
  31. data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
  32. data/lib/samagotchi/bundle_command/test_run.rb +1 -0
  33. data/lib/samagotchi/bundle_command/try/run.rb +1 -0
  34. data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
  35. data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
  36. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
  37. data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
  38. data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
  39. data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
  40. data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
  41. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  42. data/lib/samagotchi/client_id.rb +126 -67
  43. data/lib/samagotchi/command_intake.rb +15 -3
  44. data/lib/samagotchi/compat.rb +6 -1
  45. data/lib/samagotchi/context_candidate_choice.rb +1 -3
  46. data/lib/samagotchi/context_candidates.rb +3 -4
  47. data/lib/samagotchi/continue_offer.rb +9 -2
  48. data/lib/samagotchi/delivery.rb +23 -12
  49. data/lib/samagotchi/empty_answer_error.rb +5 -0
  50. data/lib/samagotchi/engine/cards.rb +3 -0
  51. data/lib/samagotchi/engine/context_judge.rb +5 -3
  52. data/lib/samagotchi/engine/events.rb +4 -0
  53. data/lib/samagotchi/engine/hooks.rb +3 -0
  54. data/lib/samagotchi/engine/messages.rb +5 -0
  55. data/lib/samagotchi/engine/model_settings.rb +2 -0
  56. data/lib/samagotchi/engine/models.rb +10 -0
  57. data/lib/samagotchi/engine/objectives.rb +6 -0
  58. data/lib/samagotchi/engine/participants.rb +18 -14
  59. data/lib/samagotchi/engine/plugins.rb +8 -0
  60. data/lib/samagotchi/engine/questions.rb +3 -0
  61. data/lib/samagotchi/engine/recap.rb +1 -0
  62. data/lib/samagotchi/engine/session.rb +4 -0
  63. data/lib/samagotchi/engine/side_requests.rb +9 -0
  64. data/lib/samagotchi/engine/steering.rb +2 -0
  65. data/lib/samagotchi/engine/toolkit.rb +5 -0
  66. data/lib/samagotchi/engine/turn_end.rb +7 -0
  67. data/lib/samagotchi/engine/turn_helpers.rb +8 -0
  68. data/lib/samagotchi/engine/verify.rb +2 -0
  69. data/lib/samagotchi/engine.rb +3 -2
  70. data/lib/samagotchi/grants.rb +28 -22
  71. data/lib/samagotchi/guardrail_wiring.rb +23 -18
  72. data/lib/samagotchi/guardrails/approval_use.rb +59 -0
  73. data/lib/samagotchi/guardrails/approvals.rb +9 -11
  74. data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
  75. data/lib/samagotchi/guardrails/gate.rb +10 -5
  76. data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
  77. data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
  78. data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
  79. data/lib/samagotchi/guardrails/review_paths.rb +2 -3
  80. data/lib/samagotchi/guardrails.rb +1 -1
  81. data/lib/samagotchi/llm_context_strategy.rb +2 -0
  82. data/lib/samagotchi/objectives.rb +1 -4
  83. data/lib/samagotchi/objectives_audit.rb +1 -1
  84. data/lib/samagotchi/objectives_track.rb +1 -1
  85. data/lib/samagotchi/owner_prompt.rb +3 -6
  86. data/lib/samagotchi/parent_report.rb +1 -0
  87. data/lib/samagotchi/participant_messages.rb +9 -4
  88. data/lib/samagotchi/participant_turn_mode.rb +50 -0
  89. data/lib/samagotchi/participants.rb +21 -12
  90. data/lib/samagotchi/participants_watch.rb +2 -2
  91. data/lib/samagotchi/plugin/api.rb +2 -2
  92. data/lib/samagotchi/plugin/attached_context.rb +1 -1
  93. data/lib/samagotchi/plugin/context.rb +0 -4
  94. data/lib/samagotchi/plugin/sessions.rb +1 -25
  95. data/lib/samagotchi/run_options.rb +2 -3
  96. data/lib/samagotchi/send_command.rb +10 -10
  97. data/lib/samagotchi/session.rb +0 -3
  98. data/lib/samagotchi/session_access/contract.rb +1 -10
  99. data/lib/samagotchi/session_access/local.rb +10 -23
  100. data/lib/samagotchi/session_access/remote.rb +9 -20
  101. data/lib/samagotchi/session_access.rb +12 -16
  102. data/lib/samagotchi/session_chain.rb +4 -6
  103. data/lib/samagotchi/session_commands.rb +6 -3
  104. data/lib/samagotchi/session_continue.rb +1 -2
  105. data/lib/samagotchi/session_manager/delivery.rb +25 -5
  106. data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
  107. data/lib/samagotchi/session_manager/listing.rb +5 -0
  108. data/lib/samagotchi/session_manager/spawn.rb +2 -2
  109. data/lib/samagotchi/session_manager/worker_command.rb +9 -0
  110. data/lib/samagotchi/session_participants.rb +12 -8
  111. data/lib/samagotchi/session_review.rb +5 -7
  112. data/lib/samagotchi/session_stores.rb +3 -3
  113. data/lib/samagotchi/share_command.rb +10 -12
  114. data/lib/samagotchi/share_terms.rb +41 -0
  115. data/lib/samagotchi/steer.rb +8 -14
  116. data/lib/samagotchi/system_prompt.rb +16 -25
  117. data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
  118. data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
  119. data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
  120. data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
  121. data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
  122. data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
  123. data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
  124. data/lib/samagotchi/terminal_ui.rb +1 -2
  125. data/lib/samagotchi/testing/sessions.rb +2 -10
  126. data/lib/samagotchi/tool_runner.rb +8 -9
  127. data/lib/samagotchi/toolkit.rb +4 -22
  128. data/lib/samagotchi/toolkit_suggest.rb +3 -3
  129. data/lib/samagotchi/tools/deferred_tools.rb +1 -0
  130. data/lib/samagotchi/tools/execute.rb +11 -45
  131. data/lib/samagotchi/tools/leftovers.rb +126 -0
  132. data/lib/samagotchi/tools/memory.rb +70 -26
  133. data/lib/samagotchi/tools/task_get.rb +1 -0
  134. data/lib/samagotchi/tools/task_list.rb +3 -2
  135. data/lib/samagotchi/tools/task_record.rb +6 -4
  136. data/lib/samagotchi/tools/task_runtime.rb +199 -20
  137. data/lib/samagotchi/tools/task_wait.rb +4 -3
  138. data/lib/samagotchi/turn_context.rb +1 -1
  139. data/lib/samagotchi/turn_origin.rb +1 -1
  140. data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
  141. data/lib/samagotchi/turn_stages/objectives.rb +2 -2
  142. data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
  143. data/lib/samagotchi/update_hint.rb +3 -1
  144. data/lib/samagotchi/verify_fresh.rb +1 -1
  145. data/lib/samagotchi/verify_fresh_origin.rb +13 -11
  146. data/lib/samagotchi/version.rb +1 -1
  147. data/lib/samagotchi/web/app.rb +3 -5
  148. data/lib/samagotchi/web/participant_access.rb +14 -18
  149. data/lib/samagotchi/web/participant_review.rb +3 -4
  150. data/lib/samagotchi/web/participant_show.rb +4 -3
  151. data/lib/samagotchi/web/participant_view.rb +3 -3
  152. data/lib/samagotchi/web/participants_admin.rb +21 -40
  153. data/lib/samagotchi/web/public/app.js +7 -48
  154. data/lib/samagotchi/web/public/card_kinds.js +51 -0
  155. data/lib/samagotchi/web/public/cards_place.js +13 -2
  156. data/lib/samagotchi/web/public/data.js +2 -10
  157. data/lib/samagotchi/web/public/delivery_line.js +17 -60
  158. data/lib/samagotchi/web/public/index.html +10 -30
  159. data/lib/samagotchi/web/public/live_turn.js +1 -1
  160. data/lib/samagotchi/web/public/owner_claim.js +2 -2
  161. data/lib/samagotchi/web/public/participant_bar.js +4 -5
  162. data/lib/samagotchi/web/public/participant_names.js +14 -10
  163. data/lib/samagotchi/web/public/participants_panel.js +29 -62
  164. data/lib/samagotchi/web/public/question_cards.js +29 -14
  165. data/lib/samagotchi/web/public/reload_check.js +2 -3
  166. data/lib/samagotchi/web/public/send_turn.js +4 -23
  167. data/lib/samagotchi/web/public/session_actions.js +4 -45
  168. data/lib/samagotchi/web/public/session_fields.js +0 -1
  169. data/lib/samagotchi/web/public/session_state.js +0 -3
  170. data/lib/samagotchi/web/public/session_sync.js +4 -2
  171. data/lib/samagotchi/web/public/session_view.js +2 -3
  172. data/lib/samagotchi/web/public/settings_panel.js +4 -18
  173. data/lib/samagotchi/web/public/stage_answer.js +56 -0
  174. data/lib/samagotchi/web/public/stage_asking.js +30 -11
  175. data/lib/samagotchi/web/public/stage_cloud.js +93 -0
  176. data/lib/samagotchi/web/public/stage_dom.js +100 -0
  177. data/lib/samagotchi/web/public/stage_handoff.js +154 -0
  178. data/lib/samagotchi/web/public/stage_pager.js +59 -0
  179. data/lib/samagotchi/web/public/stage_place.js +144 -0
  180. data/lib/samagotchi/web/public/stage_probe.js +64 -0
  181. data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
  182. data/lib/samagotchi/web/public/stage_view.js +133 -506
  183. data/lib/samagotchi/web/public/stage_waiting.js +30 -13
  184. data/lib/samagotchi/web/public/start_page.js +12 -33
  185. data/lib/samagotchi/web/public/start_settings.js +24 -78
  186. data/lib/samagotchi/web/public/start_toolkit.js +6 -10
  187. data/lib/samagotchi/web/public/stream_handlers.js +1 -9
  188. data/lib/samagotchi/web/public/turn_block.js +3 -7
  189. data/lib/samagotchi/web/public/turn_events.js +15 -6
  190. data/lib/samagotchi/web/public/turn_pieces.js +3 -4
  191. data/lib/samagotchi/web/public/viewer_self.js +8 -2
  192. data/lib/samagotchi/web/qr.rb +1 -1
  193. data/lib/samagotchi/web/session_control.rb +3 -1
  194. data/lib/samagotchi/web/session_create.rb +5 -71
  195. data/lib/samagotchi/web/session_summary.rb +1 -4
  196. data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
  197. data/lib/samagotchi/web/viewer.rb +3 -3
  198. data/lib/samagotchi/worker.rb +16 -14
  199. data/lib/samagotchi/worker_inbound.rb +4 -3
  200. data/lib/samagotchi/worker_link.rb +17 -0
  201. data/lib/samagotchi/working_set.rb +87 -28
  202. metadata +16 -8
  203. data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
  204. data/lib/samagotchi/participant_mode.rb +0 -86
  205. data/lib/samagotchi/review_apply.rb +0 -131
  206. data/lib/samagotchi/review_command.rb +0 -123
  207. data/lib/samagotchi/review_start.rb +0 -196
  208. data/lib/samagotchi/web/public/review_apply.js +0 -34
  209. data/lib/samagotchi/web/public/review_start.js +0 -55
@@ -1,12 +1,12 @@
1
1
  # Participants: identity and routes
2
2
 
3
- A session's owner can invite **participants** to review it: people, or agents, who reach that one session through
4
- chi web with a link of their own. This page is the identity layer: grants, the gate, the routes a participant
5
- reaches, and what is written where; and their **turns**: review turns queued, read-only, limited and capped, pair
6
- turns that act under the owner's guardrails; and what they **see**: their page and its reads, all through one
7
- filter. Participants are experimental. An agent participant waits on its own turns' replies through the API. The
8
- code and docs say "participants", "review" and "pair", never "shared": that word means several UIs
9
- on one worker.
3
+ A session's owner can invite **participants** into it: people who reach that one session through chi web with a
4
+ link of their own. This page is the identity layer: grants, the gate, the routes a participant reaches, and what is
5
+ written where; and their **turns**: queued, limited and capped, acting under the owner's guardrails (one kind of
6
+ invite: there are no read-only turns and no review sessions); and what they **see**: their page and its reads, all
7
+ through one filter. Participants are experimental. An invite link used from the command line (a script, another
8
+ agent, the owner's own second tool) waits on its own turns' replies through the API. The code and docs say
9
+ "participants" and "pair", never "shared": that word means several UIs on one worker.
10
10
 
11
11
  Participants reach chi web on the **LAN** (`web.host: lan`), or **behind an auth proxy** with `web.public_url`
12
12
  (experimental; docs/configuration.md, "Behind an auth proxy"): there every request needs a token, this machine's too,
@@ -26,8 +26,9 @@ participant** and **one role**, until it expires or is revoked.
26
26
  `POST …/participants` prints; chi keeps only its **SHA-256 digest**. Lookup digests the presented token and
27
27
  compares it with every grant's digest (`Rack::Utils.secure_compare`).
28
28
  - **Participant.** The grant's `id`, `p_<8 hex>`, names the participant: a turn they send is authored
29
- `"p:<id>"` (`Grant#author`, `Principal#author`). `kind` is `human` or `agent` (D11: an agent uses the same
30
- token, as a Bearer header; there is no agent UI). `role` is `reviewer`, the only one in v1. `name` is cleaned to
29
+ `"p:<id>"` (`Grant#author`, `Principal#author`). There is no kind: a grant an older chi stored with `kind`
30
+ ( `human`, `agent`) keeps it in `Grant#extra`, never read. `role` remains `reviewer` in stored grants and JSON;
31
+ text output labels it `participant`. It is the only stored role in v1. `name` is cleaned to
31
32
  one line of at most 64 characters with no brackets (`Grants.clean_name`), so it can't forge the
32
33
  `[Review contribution from …]` header.
33
34
  - **Lifetime (D8).** 7 days by default (`web.participants.expires`; `chi share --expires Nh|Nd`, 1 hour to 30 days). Revoked by the owner
@@ -91,7 +92,7 @@ participant** and **one role**, until it expires or is revoked.
91
92
  an identity requires it first, so an older chi web (which would drop the unknown `identity` and issue an unbound
92
93
  grant) is never asked (`RemoteTooOld`). A grant that still comes back unbound is revoked at once and refused, its
93
94
  link never printed. The owner's `/api/info` carries `proxy: {identity_header}` (nil without a proxy):
94
- `Remote#identity_header`, for the warning and `chi review`'s hint.
95
+ `Remote#identity_header`, for the warning.
95
96
  - **The code (decision C).** A bound grant's link code is checked before it is used up: `LinkCodes#redeem` asks its
96
97
  block under the lock, and `App#code_identity_ok?` declines unless the trade is proxied with the grant's identity.
97
98
  Declined, the code stays and the trade answers `token_bound`, so a forwarded link opened by someone else still
@@ -146,10 +147,11 @@ participant** and **one role**, until it expires or is revoked.
146
147
  server on another local port can also answer `Set-Cookie: chi_token=…` and overwrite the owner's cookie (cookie
147
148
  tossing: it logs the owner out, or swaps in a grant's token; visible, nothing leaks; not fixed).
148
149
  4. Anything else: nil. `#token_gate` answers a bound grant's token without its identity **401 `token_bound`**, an
149
- ended grant's token **401 `token_revoked`** or **401
150
- `token_expired`** (the page says the same words as a sentence: "This review link was revoked by the session's
151
- owner." / "This review link expired: ask the session's owner for a new one."), any other **401
152
- `unauthorized`** as before.
150
+ ended grant's token **401 `token_revoked`**, **401 `token_expired`** or **401 `token_outdated`** (the page says
151
+ the same words as a sentence: "This link was revoked by the session's owner." / "This link expired: ask the
152
+ session's owner for a new one." / "This link is from an older chi: ask the session's owner for a new one."), any
153
+ other **401 `unauthorized`** as before. `token_outdated` is an older chi's read-only invite: a grant without
154
+ `mode: "pair"` (`Grant#state :outdated`, derived, never written; it sweeps as any grant once it expires).
153
155
 
154
156
  The `?token=` trade (and `POST /api/token`, with a link's one-time `{code}` or the 401 page's pasted `{token}`; with
155
157
  `web.public_url` only through the proxy, as a direct request takes Bearer only) sets the `chi_token` cookie (`__Host-chi_token`, Secure, on a proxied request) to the token that was
@@ -178,9 +180,11 @@ row answers another session's id 404, so a new route is covered without a new ex
178
180
  | `POST /api/sessions/:id/turn` | participant | a turn of their own, or a line into their own running turn at its next step ([Turns](#turns)) |
179
181
  | `POST /api/sessions/:id/cancel` | participant | their own running turn stopped, named by its `turn_id` ([Turns](#turns), Stopping their turn); no `turn_id`, the owner's turn or another participant's: 403 `not_permitted`, audited |
180
182
  | `POST /api/sessions/:id/turn/:eid/dequeue` | participant | their own queued turn back; another's (the owner's included) is 403 `not_permitted` |
183
+ | `POST /api/sessions/:id/verdicts/:check_turn_id/fresh` | participant | a fresh child to check an unclear verdict, running as the requester under pair rules and counted toward their cap ([Verify fresh](#what-a-participant-sees)) |
181
184
  | `GET /api/sessions/resolve?id=` | participant | their session for its id or a prefix of it; anything else 404 as no session (never an ambiguity listing others) |
182
185
  | `POST /api/sessions/:id/wait/prepare`, `…/wait` | participant | only for a turn of theirs (`turn`: the enqueued id `POST …/turn` answered; else 403); `wait/prepare` answers only what that wait needs, `{session_id, baseline: {last_turn}, known_turn, live, last_turn_id}` (`last_turn_id` only when it is their turn), never the owner's cursor, message count, question or running turn; the answer trimmed to `{status, text, turn_id, outcome, cancel_reason}`, the reply's `text` through `ParticipantView.reply` (no thinking or tool call, redacted) and any other text (an error's exception, a failed turn's summary) `ParticipantMessages::TURN_FAILED`; a question or approval their turn raised, or their turn held by the owner's step-limit Continue offer ([Turns](#turns)), is `{status: "waiting_for_owner", detail: "waiting for the session's owner"}` with nothing of it; a revoke or the expiry ends a `wait` already running (401 `token_revoked` / `token_expired`), as it ends their stream |
183
186
  | `GET /` | participant | the main page (`index.html`) stamped for them (`App#participant_index_data`: their viewer, the grant's session and its title; [web-frontend.md](web-frontend.md#the-participants-page)); the page reads the rest through the show and the stream below |
187
+ | `POST /api/token` | participant | trade a link's one-time code or a pasted token for the `chi_token` cookie (the token is not left in the page URL) |
184
188
  | `GET /api/sessions/:id/stream` | participant | the session's stream through `ParticipantStreamFilter` (only `from_seq` and `snapshot` reach the Bridge); it ends within a poll of a revoke or the expiry |
185
189
  | `GET /api/sessions/:id/working_set` | participant | the working set's project files only (`ParticipantView.working_set`), with `running` |
186
190
  | `POST /api/sessions/:id/images` | participant | their upload ([Participant images](#participant-images)): refused at their cap, past their attempts or quota, a bmp/tiff/heic; the reply `{file, name, width, height}` |
@@ -193,45 +197,58 @@ Everything else is `:owner`: `/answer`, `/command`,
193
197
 
194
198
  ## Turns
195
199
 
196
- `ParticipantMode` is the single resolver for a participant turn's rules:
197
-
198
- - **`:review`**, a review session (its `review:` key; `chi review`), and any participant whose grant wasn't issued
199
- to act: the turn only reads (`Guardrails::ReviewBoundary`), and proposes what the owner applies ([Apply](#apply)).
200
- - **`:pair`**, a working session's participant invited to act: the turn acts with the session's tools under the
201
- owner's guardrails, its asks go to the owner and offer once only, and `Guardrails::PairBoundary` denies secrets,
202
- chi itself and chi web on loopback, background and scheduled jobs, the environment and credential printers, git
203
- config writes (reads only) and git's hooks, owner-voiced tools and the owner's task outputs, and the model's own question, and asks before a command
204
- that makes a link and before a write that may land outside the project, failing closed (a global install or a
205
- user config write that names no path, `Guardrails::ImplicitWriters`, and a script read from stdin count; a
206
- session at or above home has none: every write asks) ([guardrails](../guardrails.md#a-participants-pair-boundary)).
207
- No Apply: it acted itself.
208
-
209
- `ParticipantMode.of(session, features:)` is the session's: what a participant invited now gets. No session is
210
- `:review`. A worker names `pair_turns` (`Delivery::PAIR_FEATURE`) when it runs pair turns; one without it runs
211
- every participant turn as a review turn, so chi web and chi share ask `ParticipantMode.live`, which reads the
212
- session's live worker's features (no live worker: this chi's, the one a delivery starts). `ReviewStart.share_terms`
213
- reads it once for an invite: the warning (a working session's says their turns act, writes included, asks to you;
214
- while an older worker holds it, that a participant invited now only reads, and to invite again after a restart),
215
- the list's `mode` (the panel's words) and the grant's stamp: `Grant#mode` / the `participants.json` entry's
216
- `mode` is `"pair"` only when the warning said their turns act. A grant without it (every grant from before pair
217
- turns) stays review until the owner invites them again.
218
-
219
- A turn's mode is `ParticipantMode.for_turn(session, entry)`: `:pair` only for a stamped entry in a pair session.
220
- The worker decides it once at the turn's start (`GuardrailWiring#begin_turn` → `TurnStart#mode`, into the turn's `TurnContext#participant_mode`, from the entry
221
- `SessionParticipants#entry_for` reads), and everything in the turn reads that: the stamp on the opening message
222
- (`participant_mode`), the boundary in `GuardrailWiring#checks`, `ToolRunner#unreached_group_refusal` (through
223
- the call's `TurnContext`: a review turn's boundary words the refusal; a pair turn gets the owner's), the
224
- mid-turn stop and the cap notice's words. The system prompt's line is the pair one once an active participant is
225
- stamped pair (`SessionParticipants#prompt_mode`); their show's `viewer.mode` is their own grant's
226
- (`ParticipantMode.live_for`).
200
+ A participant's turn acts with the session's tools under the owner's guardrails, its asks go to the owner and offer
201
+ once only, and `Guardrails::PairBoundary` denies secrets, chi itself and chi web on loopback, background and
202
+ scheduled jobs, the environment and credential printers, git config writes (reads only) and git's hooks,
203
+ owner-voiced tools and the owner's task outputs, and the model's own question, and asks before a command that makes
204
+ a link and before a write that may land outside the project, failing closed (a global install or a user config write
205
+ that names no path, `Guardrails::ImplicitWriters`, and a script read from stdin count; a session at or above home has
206
+ none: every write asks) ([guardrails](../guardrails.md#a-participants-pair-boundary)).
207
+
208
+ **One kind of invite, and the safety rule.** Every grant is stamped `mode: "pair"` (`Grants#issue`,
209
+ `ParticipantTurnMode::PAIR_MODE`), and that stamp is the one mark of a grant this chi honours: no turn that an older chi
210
+ ran read-only may run with tool rights here. Whether a participant's turn runs is one function,
211
+ `ParticipantTurnMode.of(entry:, session:, now:)`: `:pair` (it runs), `:revoked` (no current entry: none, revoked,
212
+ expired, or anything that isn't an entry), `:outdated` (an older chi's read-only invite, or a participant's Verify fresh
213
+ child saved read-only) or `:not_invited` (no session, or the owner's own Verify fresh child). The worker
214
+ (`#participant_refusal`: `:outdated` → `outdated`, the other two → `revoked`, no new reason on the wire) and the
215
+ guardrails (`GuardrailWiring#participant_turn_mode`: `:pair` → `PAIR`, else `REFUSED`) both read it; `Grant#state`
216
+ and `Entry#outdated?` use its `invite_mode?`.
217
+ - A grant without it (an older chi's read-only invite) is ended at the gate (`token_outdated`, above), and its
218
+ `participants.json` entry is not active (`Participants::Entry#outdated?`): the worker's `#participant_refusal`
219
+ refuses its turns with `outdated` (every Bridge and inbox-file turn, and every line the own-turn drain would merge,
220
+ passes there: an older chi web still running and files queued before the upgrade are covered), and the system
221
+ prompt's line and the terminal's count leave it out.
222
+ - A Verify fresh child saved with `verify_fresh.mode` other than `pair` (`VerifyFreshOrigin#pair?`) is refused at the
223
+ same place. So is a participant's turn in the owner's own Verify fresh child (`revoked`): chi web never sends one
224
+ there (a participant reaches only their grant's session), but an input file or a Bridge-secret holder could.
225
+ - `GuardrailWiring#participant_turn_mode` decides the turn's mode once at its start (`TurnStart#mode`, into
226
+ `TurnContext#participant_mode`): `GuardrailWiring::PAIR` for a current entry in a session (and a fresh child saved
227
+ pair), else `REFUSED`, whose seat in `#checks` is `Guardrails::ParticipantRefusal`: every call denied, nobody asked
228
+ (the fail-closed fallback, should such a turn start). The opening message is stamped `participant_mode: "pair"`
229
+ for a pair turn only.
230
+ - No invite is issued while the session's live worker lacks `pair_turns` (`Delivery::PAIR_FEATURE`):
231
+ `ShareTerms.of` (chi share, the panel's Invite, `SessionAccess::Local`) gives the refusal "restart the session
232
+ first" (409 `worker_too_old`), and its warning otherwise says their turns act, writes included, asks to you, and
233
+ how many tool outputs the history holds. A participant's turn and a participant's Verify fresh child go only to a
234
+ worker with `pair_turns` (409 `pair_unavailable`, `Delivery::PAIR_UNAVAILABLE`; the file fallback refuses an exiting
235
+ worker as before). New workers still advertise `review_turns` too: an older chi web refuses participants' turns to
236
+ a worker without it, and stamps `pair` only when it sees `pair_turns`.
237
+ - A session an older chi started as a review (its `review:` key) is an ordinary session: its participants' turns are
238
+ pair turns like anyone's.
227
239
 
228
240
  A participant's `POST /api/sessions/:id/turn` (`ParticipantAccess#handle_participant_turn`) takes only the body's
229
241
  `prompt`, `delivery` and `images` (refs to their own uploads). Three layers keep it out of anyone else's turn, inside its mode's boundary: it goes into a
230
242
  running turn only when that turn is theirs (at its next step, as the owner's message does), else it runs as a turn
231
243
  of its own after it.
232
244
 
233
- **chi web.** The author is the grant's (`p:<id>`) and the client id `review:<id>` (`ClientId.review`: a human's
234
- input, origin `review`, source `participant`, labelled `review`); the body's `client_id`, `author` and
245
+ **chi web.** The author is the grant's (`p:<id>`) and the client id `participant:<id>` (`ClientId.participant`, its
246
+ `ClientId::Sender` row: a human's input, never the owner's, origin `participant`, source `participant`, labelled
247
+ `invited`; not the author, which says who wrote it). A `review:<id>` from chi 0.171 and before (in
248
+ `turn_drawings.jsonl`, input files, an older chi web still running) reads the same (`ClientId::LEGACY_REVIEW_PREFIX`,
249
+ compat shim `review_client_id`, until 0.173), and a live worker that doesn't name `participant_client_id`
250
+ (`Delivery::PARTICIPANT_ID_FEATURE`) is sent `review:<id>` (`SessionManager` delivery; a dequeue's id, only echoed
251
+ back, is left as it is); the body's `client_id`, `author` and
235
252
  `no_interrupt` never count, its `images` only as refs to their own uploads, and its `delivery` only as `queue` or
236
253
  next step (none: next step).
237
254
  Refused before delivery, each audited:
@@ -281,11 +298,11 @@ participant's turn takes nobody else's line; the Bridge queues their `POST /turn
281
298
  (`Bridge#same_author_steer?`, under the event log) and never cuts for it; a line merged into their own turn first
282
299
  gets the checks their queued turn gets at its start (below: the link, the cap), and one refused is dropped as that turn
283
300
  would be, never merged; a participant's `/word` or `!line` is refused by the Bridge (403)
284
- and dropped from the worker's file path. A participant's turn goes only to a worker that names the `review_turns`
285
- feature (409 `review_unavailable` otherwise: it has no boundary; restart it), and never as a file while a worker
301
+ and dropped from the worker's file path. A participant's turn goes only to a worker that names the `pair_turns`
302
+ feature (409 `pair_unavailable` otherwise: it would run it read-only; restart it), and never as a file while a worker
286
303
  that may be older holds the session (504 `worker_timeout`: send again). Before a queued participant turn starts, the
287
- worker checks their link (`participants.json`: revoked, expired) and their cap again: either way the turn is
288
- dequeued (`:turn_dequeued`) and audited (`revoked`, `cap_reached`) instead of run, so a revoke also stops what they
304
+ worker checks their link (`participants.json`: revoked, expired, an older chi's) and their cap again: either way the
305
+ turn is dequeued (`:turn_dequeued`) and audited (`revoked`, `outdated`, `cap_reached`) instead of run, so a revoke also stops what they
289
306
  had queued; its settled record (`TurnCheckpoint.record_refused`: canceled, `cancel_reason` the reason) ends their
290
307
  wait on it at once, which `ParentReport` reads as status `refused`, exit 1.
291
308
 
@@ -344,18 +361,16 @@ command that waits for it, and `send --wait -m` skips the owner's busy check (it
344
361
  doesn't refuse it; that check's `wait/prepare` without a turn would be 403 `not_permitted`) and waits on the turn it
345
362
  queued, as `--turn T` does.
346
363
 
347
- **The tool calls.** In a review session `Guardrails::ReviewBoundary` denies a participant's turn everything but
348
- reads of the project ([guardrails](../guardrails.md#a-participants-review-boundary)). In a working session
349
- `Guardrails::PairBoundary` takes its seat: the owner's checks and rules decide the rest, as for the owner's turns
350
- ([guardrails](../guardrails.md#a-participants-pair-boundary)). Both judge a path every way it resolves
364
+ **The tool calls.** `Guardrails::PairBoundary` sits in the participant boundary's seat: the owner's checks and rules
365
+ decide the rest, as for the owner's turns ([guardrails](../guardrails.md#a-participants-pair-boundary)). It judges a path every way it resolves
351
366
  (`PathResolve.reals`: a `..` after a symlinked folder climbs out of its target, as the read opens it;
352
- [guardrails](../guardrails.md#how-paths-resolve)). Approvals and questions are owner-only: either
367
+ [guardrails](../guardrails.md#how-paths-resolve)). Approvals and questions are owner-only: the
353
368
  boundary denies the model's own question, and `/answer` is an owner route. A pair turn's ask reaches the owner's card
354
369
  naming who asks (`approval.author`, `author_name`; `Guardrails::Approval::PARTICIPANT_HEADER`) with Allow once as its
355
370
  only scope, and System 1 never judges it (`GuardrailWiring#system_one_judge`). A grant without `--identity` (a LAN
356
371
  token link) gets the same access: a per-grant trust level, if one is ever needed, would go on the grant and narrow
357
- `ParticipantMode` there. Toolkit suggestions (audit and on mode) skip review
358
- sessions and participant-authored turns; their input is never sent to the separate System 1 classifier, and a
372
+ the turn's mode there (`GuardrailWiring#participant_turn_mode`). Toolkit suggestions (audit and on mode) skip
373
+ participant-authored turns; their input is never sent to the separate System 1 classifier, and a
359
374
  participant's turn never switches the session's toolkit.
360
375
 
361
376
  **Hooks and plugins** run on a participant's turn with the owner's power; every event of the turn carries `author:`
@@ -370,9 +385,8 @@ and `ctx.turn_author` names it ([hooks](../hooks.md#participants-turns)).
370
385
  participant caused (their turn's `ctx.ask_model`, the idle recap after their turn; `SideTotals#by_author`). An
371
386
  owner command's side request is the owner's. `/stats` shows each participant's spend by name. At the cap the
372
387
  participant's next turn is 429 `cap_reached`, and the owner gets one notice per participant and cap: "Alex reached
373
- their $2.00 review cap: their comments are refused until you raise it (chi share cap ID p_… AMOUNT)." (a working
374
- session's: "Alex reached their $2.00 cap: their turns stop and are refused until you raise it (…)"). A review
375
- turn's spend counts from its end, so a review turn can finish past the cap. A pair turn stops mid-turn: before each
388
+ their $2.00 cap: their turns stop and are refused until you raise it (chi share cap ID p_… AMOUNT)." A turn stops
389
+ mid-turn: before each
376
390
  generation (`KernelLoop::Services#generation_guard`, both loops) `Engine#guard_participant_spend` asks the worker's check
377
391
  (`Worker#participant_turn_stop`: `metrics.spend(author)` counts the running turn's finished generations) and, past
378
392
  the cap, stops the turn on the plugins' stop path (`HookRoutes#stop_turn`: "stopped the turn: Alex reached their
@@ -390,7 +404,7 @@ made by `chi share revoke` in another process; the page then reads a 401 and sho
390
404
  ## Participant images
391
405
 
392
406
  A participant attaches images to their own turns, as the owner does (`Viewer::PARTICIPANT_CAPABILITIES`' `images`:
393
- the composer's paste, drop and image button). Review and pair grants alike: an image is input, not tool power; their
407
+ the composer's paste, drop and image button). An image is input, not tool power; their
394
408
  cap and the quota bound the cost (their turn's image tokens count to their cap by author, `SessionMetrics.saved_spend`;
395
409
  later turns that re-send it in history are the owner's). `ImageStore` is content-addressed and keeps no metadata, so
396
410
  who uploaded what is chi web's own record, `ParticipantUploads` (`participant_images.json`, [Files in the session
@@ -423,8 +437,7 @@ headers alike. A revoked or expired grant is refused by the gate (401) as on eve
423
437
  **Their turn** takes only refs they uploaded ([Turns](#turns)); **what they see** is their own images as thumbnails
424
438
  and anyone else's as "N images" ([What a participant sees](#what-a-participant-sees)). A corrupt or unreadable
425
439
  record fails closed (every grant at quota, owning nothing, `Log.warn`); the owner can delete the file. Not covered:
426
- a participant's `chi --remote … --image`; a failed turn of theirs gives the text back without its chips; Apply
427
- doesn't mention a proposal's images.
440
+ a participant's `chi --remote … --image`; a failed turn of theirs gives the text back without its chips.
428
441
 
429
442
  ## What a participant sees
430
443
 
@@ -514,7 +527,7 @@ verdicts' (`fresh_running`, `session.verify_unavailable`).
514
527
  - `session`: id, participant title, status (idle when a worker says running with no turn), `bridge_up`,
515
528
  `worker_features`, `verdicts` (filtered, as the review's) and `verify_unavailable`.
516
529
  - `viewer`: `Web::Viewer`'s kind, id, name, `can` (`Viewer::PARTICIPANT_CAPABILITIES`: `send`, `stop_own_turn`,
517
- `steer_own_turn`, `revise_own_turn`, and of the owner's `working_set` and `images`), `client_id` (`review:<grant id>`, which chi web gives their
530
+ `steer_own_turn`, `revise_own_turn`, and of the owner's `working_set` and `images`), `client_id` (`participant:<grant id>`, which chi web gives their
518
531
  turns), their `participant_kind`, `mode`, `cap_reached` and `usage`, `session_stopped`, and
519
532
  `waiting_for_owner` (the kind the session waits on, the review read's rule: the running turn's question, a
520
533
  Continue offer, a question between turns; nil when nothing).
@@ -540,13 +553,9 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
540
553
  participant's spend, the owner's and the session's totals never reach them (the red-team spec checks the body). Their
541
554
  page draws the spend of the cap in its bottom row ("$0.42 of $2.00 used") and the link's end in its top row; it reads
542
555
  the show again at each turn's end for it (the light re-reads carry no viewer).
543
- - **A fork's note.** A review fork (`chi review --from`, `/coordinate review`) starts with a note holding the source's
544
- recap and, from the coordinator, its handoff's body: a participant's review turn reads it like the rest of the
545
- history and may quote it (host paths, worktree names). That is by design (it is what the review is about); the
546
- owner chose to share it. Nothing else of the source comes along.
547
- - **No file view.** A review session's subjects are not sent to a participant (their page has no file panel; they ask
548
- chi to quote the part they need: [docs/sessions.md](../sessions.md#review-sessions)). Its title for a review session
549
- with no title of its own is `review of docs/plan.md` (`+N` for more), never the first prompt.
556
+ - **No file view.** Their page has no file panel: they ask chi to quote the part they need. A session with no title
557
+ of its own is titled "an untitled session" on their page, never its first prompt (an older chi's review session's
558
+ subjects are never read).
550
559
  - **Annotate** is the main page's (`annotate_bar.js`): a selection in the conversation offers **Annotate** and the
551
560
  owner's `web.annotate_presets` (their `<body>`'s `data-annotate-presets`), which append the quote to the composer,
552
561
  then the built-in **Verify** (`verify_preset.js`), offered only where the Engine takes the claim (`verify_target.js`
@@ -561,7 +570,7 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
561
570
  mirrored in JS (`spec/fixtures/redact_cases.json` holds cases both sides must read the same): secret shapes
562
571
  `[redacted]`, whole even when the selection cuts into one, so a link never carries a secret; on the owner's page
563
572
  also the session's folder relative and the home folder `~` (the page's `data-home`). Not the owner's token (the
564
- page doesn't hold it). With no person (`kind: human`) active in the session, Copy link gives the owner's own form,
573
+ page doesn't hold it). With no participant active in the session, Copy link gives the owner's own form,
565
574
  `#/s/<id>?t=…&q=…&p=…`; the main page opens either form (`owner_claim.js`, a participant's page too: its one
566
575
  session is the claim's). Opening one: the turn's bubbles (answers, own messages and steps) are searched for the prefix and quote, then
567
576
  the quote alone; the match's bubble is ringed (`.claim-hit`), a closed `<details>` around it opened, and the quote
@@ -604,8 +613,8 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
604
613
  participant, and one for the owner; each start passes the cap on saved spend, so parallel children would multiply
605
614
  it), and the parent already running `session.max_children` children of any kind (409 `children_full`, so fresh
606
615
  checks never crowd out the owner's own delegates). For a participant also what refuses their turn: their cap (429
607
- `cap_reached`, counting their fresh children) and a live worker that predates participants' turns (409
608
- `review_unavailable`). A start that involves a participant is audited in the parent's trail (`verify_fresh`:
616
+ `cap_reached`, counting their fresh children) and a live worker that predates their turns (409
617
+ `pair_unavailable`, no `pair_turns`). A start that involves a participant is audited in the parent's trail (`verify_fresh`:
609
618
  `participant` whose child it is, `asked_by` the clicking participant's id or `owner`, `of`, `status`, the child and
610
619
  mode, or the reason); the answer is `{of, running: true}`, the owner's with `child_id` too.
611
620
  - **Whose child it is.** A verdict a participant's turn recorded (`by: p:<id>`) is checked again **as that
@@ -617,8 +626,8 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
617
626
  participant's own for a participant.
618
627
  - **The child is its requester's.** Its session file carries `verify_fresh: {author, mode, of, anchor}`
619
628
  (`VerifyFreshOrigin`), saved before its worker starts. `author` is the participant's (`p:<id>`), none for the
620
- owner. `mode` is the participant's grant's mode in the parent at that moment (`ParticipantMode.live_for`:
621
- `pair` only for a grant stamped to act in a working session whose worker runs pair turns, else `review`). Every
629
+ owner. `mode` is `pair` (`Grants::PAIR_MODE`: every live grant's); a child an older chi saved with `review` is refused,
630
+ never run (`VerifyFreshOrigin#pair?`, `Worker#participant_refusal` `outdated`). Every
622
631
  turn of a participant's child is theirs, whoever starts it (the owner typing into it, a continue, a reminder):
623
632
  `VerifyFreshOrigin#origin_for` sets the author in `Engine#begin_turn` and in the worker, so their boundary
624
633
  (`GuardrailWiring#begin_turn` reads the saved mode, never a lookup), their System 1 skip, their once-only asks to
@@ -626,12 +635,11 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
626
635
  (`Session#participants_source_id`) read the parent's, so a revoke, an expiry or the parent's archive refuses the
627
636
  child's next turn and stops a pair turn mid-turn, as in the parent; their audit lines go to the parent's
628
637
  `participants.jsonl`. A field that doesn't read is `VerifyFreshOrigin::INVALID`: a participant author nobody
629
- has, under review, so its turns are refused, never run as the owner's. Its approvals wait on the child for the
638
+ has, never pair, so its turns are refused, never run as the owner's. Its approvals wait on the child for the
630
639
  owner (D2); the owner's page links to it.
631
640
  - **What follows from that.** The owner typing into a participant's child is that participant's turn: charged to
632
641
  their cap and run under their boundary (open an ordinary session to act with the owner's own). A revoke (or an
633
- expiry, or the parent's archive) stops a pair-mode child mid-turn, as a pair turn; a review-mode child finishes
634
- the turn it is in and is refused at its next turn's start, as a review turn. A continue of the parent archives it
642
+ expiry, or the parent's archive) stops the child mid-turn, as a participant's turn. A continue of the parent archives it
635
643
  (and revokes its grants) and moves a running fresh child to the new link with the other open delegates: the
636
644
  turn it is in still forwards its verdict to the archived link (the parent it started under), which shows it
637
645
  there, and its next turn is refused (its requester's grant isn't on the new link). Nothing reaches the new link's
@@ -674,9 +682,8 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
674
682
  The red-team spec (`spec/participant_red_team_spec.rb`) reads the stream, every show variant, `/output` and images
675
683
  they didn't upload (a guessed name, the owner's by its hash: 404) as a participant, sends another's image refs
676
684
  (the owner's, another participant's, a guessed hash, a forged `source`: 403), with an approval, a question, a tool's call and output, thinking, a memory, a steer, a delegate
677
- report, an unknown event and host paths in the session, and finds none of them. It also names a secret and a file
678
- outside the project as subjects in a review session's file and reads none of them in the show, and has `chi review`
679
- refuse each as a subject.
685
+ report, an unknown event and host paths in the session, and finds none of them. It also titles an older chi's review session
686
+ (its `review:` subjects a secret and a project file) "an untitled session" and reads none of them in the show.
680
687
 
681
688
  ## The owner's controls
682
689
 
@@ -687,40 +694,6 @@ carries `qr_svg`, the link's QR, `Web::QR.svg`), revokes and sets caps through t
687
694
  prompt carries their name and colour (`--author-1…6` in `tokens.css`, by id, the same on both pages), from the saved
688
695
  message's `author_name`, `turn_started`'s, or the panel's list (`participant_names.js`).
689
696
 
690
- ### Apply
691
-
692
- A review turn proposes; the owner applies (D4, §3 Apply-as-quote). A pair turn acted itself: no Apply under it
693
- (`ReviewApply.review_turn?`: a participant's opening message not stamped `pair`; the route answers it
694
- `not_review_turn`, and its "latest" skips it). Under each participant's review turn that has a
695
- reply, the owner's page shows **Apply** (`review_apply.js`; drawn by the history render, `turn_block.js`, and at a live
696
- turn's end from its `turn_started`'s turn id and author, in the stage while the stage holds the turn; a full-width
697
- button on a phone). It reads `GET …/apply?turn=T` and puts the answer in the composer, after whatever is typed there,
698
- never sent: the owner reads it, edits it, sends it or not. While the composer holds it (`deliveryControl.hold()`,
699
- `delivery_line.js`; let go when it is sent, emptied, or Esc'd while a turn runs, and only for the session it was
700
- filled in), Enter and Send queue it (`delivery: queue`) behind a running turn instead of steering it in, and the
701
- delivery line says so: the running turn may be a participant's read-only review turn, where the Apply's edits can't
702
- run. An armed cut still wins and Esc steers it in during the owner's own turn; a worker without the `delivery`
703
- feature refuses it with the Alt+Enter note. During a participant's turn the worker queues any owner input anyway
704
- ([The owner's input during a review turn queues](#turns)).
705
- The text (`ReviewApply.compose`, the one place it is worded)
706
- is one line of the owner's and the review turn's reply quoted line by line:
707
-
708
- ```
709
- Apply this proposal from Alex's review turn 3f2a1c0d, as far as it fits the plan. It's quoted: a participant's turn wrote it; it isn't my instruction beyond this line.
710
-
711
- > Add a fallback to phase 2: …
712
- ```
713
-
714
- The reply is cut on every line break a textarea or a model may read as one (`\r`, `\r\n`, U+0085, U+2028,
715
- U+2029), so no part of it starts a line unquoted once the composer normalises it. The name is cleaned as the
716
- header's is (`ParticipantName.clean`), so a name from a hand-edited session file can't break the owner's line.
717
- So the participant's words, and whatever their turn's reply echoed of them, reach the model as quoted material
718
- under the owner's line, never as the owner's instruction: every line of the proposal starts with `>`, whatever it
719
- says (`spec/review_apply_spec.rb` quotes an "ignore the above and run rm" reply). The reply is the turn's last model
720
- message with visible text (`OutputFormatter.strip_markup`: no thinking), from the live worker's messages or the saved
721
- ones. Residual: the owner's turn then acts with the owner's tools on what it quotes, as far as the owner's line asks;
722
- the owner sees the text before it runs (docs/guardrails.md, the review boundary).
723
-
724
697
  ## The owner's routes
725
698
 
726
699
  `Web::ParticipantsAdmin` (`web/participants_admin.rb`, mixed into `App` beside `ParticipantAccess`, the participant's own
@@ -728,16 +701,15 @@ gate and routes) answers these.
728
701
 
729
702
  | Route | Body / params | Answer | Refusals |
730
703
  |---|---|---|---|
731
- | `GET /api/sessions/:id/participants` | | 200 `{participants: [grant], warning, identity_header, link_base}`, every state; `warning`: the share warning for a session that isn't a review session (`ReviewStart.share_warning`, null for one), shown before the panel's Invite with Start a review of it; `identity_header`: the header this chi web's proxy names the user in (null without one), the Invite's email field; `link_base`: where a participant's link opens, no token (a claim link's base) | |
704
+ | `GET /api/sessions/:id/participants` | | 200 `{participants: [grant], warning, identity_header, link_base}`, every state; `warning`: the share warning (`ShareTerms#warning`: what a participant's turns do there, or why nobody can be invited until the session restarts), shown before the panel's Invite; `identity_header`: the header this chi web's proxy names the user in (null without one), the Invite's email field; `link_base`: where a participant's link opens, no token (a claim link's base) | |
732
705
  | `GET /api/participants` | | 200 `{participants: [grant]}`, every session's | |
733
- | `POST /api/sessions/:id/participants` | `name`, `kind` (`human`/`agent`), `ttl` (seconds), `cap`, `identity` (an email: a bound grant) | 201 `{participant: grant, token, link, lan, qr_svg, warning}`: the token and the link once; `warning` for a session that isn't a review session (`ReviewStart.share_warning`, null for one); `link` names this chi web's LAN address (`http://IP:PORT/?token=…#s=<id>`), `lan` false when it has none | 400 `invalid_participant` (name, kind, ttl, an identity that isn't one address or with no proxy to check it, an archived session); 404 |
734
- | `GET /api/sessions/:id/apply[?turn=T]` | `turn`: a turn id or a prefix (none: the latest review turn with a reply) | 200 `{text, turn_id, author, author_name}`: the Apply turn for the composer, never sent | 404 `not_found` (no such turn, no review turn), 400 `not_review_turn` (an owner's turn), 409 `no_reply` |
706
+ | `POST /api/sessions/:id/participants` | `name`, `ttl` (seconds), `cap`, `identity` (an email: a bound grant) | 201 `{participant: grant, token, link, lan, qr_svg, warning}`: the token and the link once; `warning` (`ShareTerms#warning`); `link` names this chi web's LAN address (`http://IP:PORT/?token=…#s=<id>`), `lan` false when it has none | 400 `invalid_participant` (name, kind, ttl, an identity that isn't one address or with no proxy to check it, an archived session); 404 |
735
707
  | `DELETE /api/sessions/:id/participants[?id=p_…]` | | 200 `{revoked: [grant]}`: one participant, or the session's | 400 `invalid_participant` |
736
708
  | `DELETE /api/participants` | | 200 `{revoked: [grant]}`: every session's | |
737
709
  | `POST /api/sessions/:id/participants/:p/cap` | `cap` (dollars, 0 to 1000) | 200 `{participant: grant}`: their cap from their next turn on | 400 `invalid_participant` (the cap, no such active participant) |
738
710
 
739
- A grant here is `Grant#public_h`: `id, session_id, kind, name, role, created_at, expires_at, revoked_at, revoked_by,
740
- last_used_at, state` (`active | revoked | expired`), `cap` (dollars), `queue` and `identity` (null: unbound). Never
711
+ A grant here is `Grant#public_h`: `id, session_id, name, role, created_at, expires_at, revoked_at, revoked_by,
712
+ last_used_at, state` (`active | revoked | expired | outdated`: an older chi's read-only invite), `cap` (dollars), `queue` and `identity` (null: unbound). Never
741
713
  the token or its digest.
742
714
  `POST …/participants` also takes `cap`. A grant from before caps takes the config's.
743
715
 
@@ -752,13 +724,13 @@ None is in the session JSON (chi web never saves that, and a worker would overwr
752
724
  none is copied to a continue, a fork or a delegate (a continue starts with no participants). A session nobody was
753
725
  invited to has none: its files stay byte for byte as they were.
754
726
 
755
- - **`participants.json`** (0600, `Participants.write`): `{participants: [{id, kind, name, role, added_at,
727
+ - **`participants.json`** (0600, `Participants.write`): `{participants: [{id, name, role, added_at,
756
728
  expires_at, removed_at, cap}]}`, rewritten by whoever changes a grant (chi web, `chi share`), inside the grants
757
729
  store's lock (`Grants#update`'s `on_write`), so two writers can't finish out of order and lose a revoke here. Never
758
730
  a token or a digest.
759
731
  The worker reads it with `Participants.read` (`SessionParticipants#refresh!`, for the system prompt's participants line).
760
732
  - **`participants.jsonl`** (0600, append-only, `Participants.log`): one JSON line per event, with `at`: `issued`
761
- (participant, name, kind, role, expires_at), `revoked` (participant, by), `expired` (the first refused use after the
733
+ (participant, name, role, expires_at, mode), `revoked` (participant, by), `expired` (the first refused use after the
762
734
  expiry, once per chi web), `peer` (the first use and each new peer since chi web started: ip, user agent; behind a
763
735
  proxy, where every ip is 127.0.0.1, the peer is the signed-in identity, else the proxy's X-Forwarded-For hop:
764
736
  `identity`, `peer`), `issued` names a bound grant's `identity`,
@@ -767,7 +739,7 @@ invited to has none: its files stay byte for byte as they were.
767
739
  remembered and audited; or `what: command`, a participant's `/word` or
768
740
  `!line` the Bridge or the worker refused), `turn` (chars, `status: accepted` with its enqueued id, or `refused` with
769
741
  the reason: `not_permitted`, `too_many_turns`, `cap_reached`, `bad_images`, `no_vision` with its `detail`,
770
- `review_unavailable`, `worker_timeout`; `images`: how many it carried), `image` (an upload: `status` accepted with
742
+ `pair_unavailable`, `worker_timeout`; `images`: how many it carried), `image` (an upload: `status` accepted with
771
743
  its `file` and `bytes`, or refused with the `reason`; never its name), `cap` (a new
772
744
  cap), `verify_fresh` (`of`, `status`, the child and mode or the reason). A Verify fresh child's participants' lines
773
745
  are its parent's. It goes with the session (retention, delete).
@@ -786,7 +758,7 @@ means the owner: a turn or session with no author keys reads as the owner's and
786
758
  (`spec/turn_author_record_spec.rb`).
787
759
 
788
760
  - **Messages.** A participant's opening message is saved raw with `author`, `author_name` (the name the sidecar gave
789
- the participant when it was written) and `participant_mode` (`ParticipantMode.of` when `Engine#run_turn` builds it, before any request carries it). Merged input and
761
+ the participant when it was written) and `participant_mode` (`"pair"` for a pair turn, set when `Engine#run_turn` builds it, before any request carries it; a turn this chi refuses gets none). Merged input and
790
762
  steers carry `author` and `author_name`; assistant and tool messages carry none (`Steer.author_at` resolves a
791
763
  turn's author by position).
792
764
  - **The header.** On the wire (both loops, and so the Messages adapter) such a message is led by one line selected
@@ -801,17 +773,17 @@ means the owner: a turn or session with no author keys reads as the owner's and
801
773
  input, a delegate report) goes out led by `(quoted) ` (`Steer.quote_forged_headers`, wire-only and deterministic),
802
774
  so it reads as their text under the real header. The session file never holds the header or the quote mark.
803
775
  - **The system-prompt line.** While the session has an active participant (`participants.json`, read by the
804
- worker's Engine at each turn's start), the system prompt's volatile tail opens with "Participants: people other
805
- than the owner review this session. …" (`SystemPrompt::PARTICIPANTS_LINE`), or in a working session with
806
- `PAIR_PARTICIPANTS_LINE`, which names the pair header (and the review one, for turns stamped before). It comes
776
+ worker's Engine at each turn's start), the system prompt's volatile tail opens with "Participants: teammates the
777
+ owner invited work in this session too. …" (`SystemPrompt::PARTICIPANTS_LINE`), which names the pair header (and the
778
+ review one, for turns an older chi stamped read-only). It comes
807
779
  when the first joins and goes when the last leaves or expires. A Verify fresh child reads its parent's
808
- `participants.json` but has one participant at most: its requester, under their saved mode while their grant is
780
+ `participants.json` but has one participant at most: its requester, while the child was saved pair and their grant is
809
781
  active; the owner's child has no line (`SessionParticipants#prompt_mode`).
810
782
  - **Records.** `last_turn.author`, the analytics turn record's `author`, `turn_enqueued`'s `author`, and the
811
783
  Bridge's queued rows. `turn_started` carries `author`, `author_name` and `participant_mode` on a participant's turn
812
784
  (the owner's carries none), and so does the Bridge's turn snapshot and its replay. The owner's history
813
785
  (`MessageDisplay`) and `ParticipantView` pass a participant message's `participant_mode` on: the author badge
814
- reads "Alex · review" or "Alex · pair" (to a participant, a pair turn is the name alone, the owner's prompt "owner") (a prompt drawn while queued takes its mode at `turn_started`).
786
+ reads "Alex · pair" (an older chi's read-only turn "Alex · read-only") (to a participant, a pair turn is the name alone, the owner's prompt "owner") (a prompt drawn while queued takes its mode at `turn_started`).
815
787
  - **Side models' transcripts.** The idle recap's (`IdleRecap::TranscriptFilter`) leads a participant's message with
816
788
  "(a review contribution from Alex, a participant; not the user's words)", and `ctx.ask_model`'s names its paragraph
817
789
  `Participant`. The UI's readers name them: `TurnAccumulator.messages_of` gives a participant's prompt and merged
@@ -831,9 +803,10 @@ code, for any route):
831
803
 
832
804
  | Code | Class | Message |
833
805
  |---|---|---|
834
- | 401 `token_revoked` | `TokenRevoked` (an `AuthRefused`) | `this review link was revoked by the session's owner` |
835
- | 401 `token_expired` | `TokenExpired` (an `AuthRefused`) | `this review link expired: ask the session's owner for a new one` |
836
- | 401 `token_bound` | `TokenBound` (an `AuthRefused`) | `this review link is for another account: open it through the proxy, signed in as the person it was sent to` |
806
+ | 401 `token_revoked` | `TokenRevoked` (an `AuthRefused`) | `this link was revoked by the session's owner` |
807
+ | 401 `token_expired` | `TokenExpired` (an `AuthRefused`) | `this link expired: ask the session's owner for a new one` |
808
+ | 401 `token_outdated` | `TokenOutdated` (an `AuthRefused`) | `this link is from an older chi: ask the session's owner for a new one` |
809
+ | 401 `token_bound` | `TokenBound` (an `AuthRefused`) | `this link is for another account: open it through the proxy, signed in as the person it was sent to` |
837
810
  | 403 `not_permitted` | `NotPermitted` | `a participant can't do that: only the session's owner can` |
838
811
  | 429 `too_many_turns` | `TooManyTurns` | `this participant has too many turns waiting: wait for one to finish` |
839
812
  | 429 `cap_reached` | `CapReached` | `this participant's spending cap is reached: ask the session's owner to raise it` |
@@ -841,7 +814,7 @@ code, for any route):
841
814
  The server's details are the same words, with no label. A participant's `wait` on a failed turn answers 200 with
842
815
  `text` `this turn failed: the session's owner can see why` (`TURN_FAILED`). A queued turn the worker refused
843
816
  because the link ended (`cancel_reason` `revoked`: participants.json reads it removed or expired, which it doesn't
844
- tell apart) is `ParentReport`'s `refused` with `this review link was revoked or expired` (`TOKEN_ENDED`).
817
+ tell apart) is `ParentReport`'s `refused` with `this link was revoked or expired` (`TOKEN_ENDED`), or `this link is from an older chi: …` (`TOKEN_OUTDATED`) for `outdated`.
845
818
 
846
819
  A 401 `unauthorized` stays `AuthRefused`'s "the token was refused".
847
820
 
@@ -850,14 +823,14 @@ A 401 `unauthorized` stays `AuthRefused`'s "the token was refused".
850
823
  The attached TUI (`TerminalUI::AttachedLoop`, local or through `--remote`) is the owner's only; there is no
851
824
  participant TUI in v1.
852
825
 
853
- - **Who is in the review.** The worker's `ParticipantsWatch` reads `participants.json` again when its mtime moves and
826
+ - **Who is in the session.** The worker's `ParticipantsWatch` reads `participants.json` again when its mtime moves and
854
827
  measures each grant's expiry at every look. On its idle tick (between turns, `Worker::FALLBACK_TICK_SECONDS`) the
855
- worker announces `:participants_changed` (`Engine#announce_participants`: `{participants: [{id, name, kind}],
828
+ worker announces `:participants_changed` (`Engine#announce_participants`: `{participants: [{id, name}],
856
829
  joined: […], left: [{…, reason: revoked | expired}]}`) to every UI; its start announces nobody. "Joined" means
857
830
  invited: participants have no presence of their own yet. `session_state_snapshot`'s `participants` names who is in
858
831
  the review now, so a UI that joins has them. Owner frames only: no participant stream carries them (`Web::ParticipantView`).
859
832
  - **Lines.** A participant's prompt (`turn_enqueued`'s `author`, an origin's, a queued row's, a saved message's
860
- `author` / `author_name`) is led by their name (`Formatting#participant_prefix`: `Alex ▸ review>`, cleaned by
833
+ `author` / `author_name`) is led by their name (`Formatting#participant_prefix`: `Alex ▸ invited>`, cleaned by
861
834
  `ParticipantName`, the id when the TUI knows no name), in a colour picked from their id. Each change is one line per
862
835
  participant; the status row counts who is in.
863
836
  - **Commands.** `/share`, `/participants` (`TerminalUI::ParticipantCommands`) run `ShareCommand` for the attached
@@ -881,11 +854,13 @@ participant TUI in v1.
881
854
  an event type it doesn't name is dropped.
882
855
  - A participant's message is a turn of its own, or goes into their own running turn at its next step (chi web, the
883
856
  Bridge, the inbox), never into anyone else's turn and never a cut, a command or a
884
- shell line (chi web, the Bridge, the worker), and runs only on a worker with the review boundary: in a review
885
- session it denies everything but reads of the project; in a working session (a worker with `pair_turns`) the pair
886
- boundary denies secrets and owner-voiced tools, the owner's guardrails decide the rest, and every ask is the
887
- owner's, once only.
888
- - A participant's message is never sent without its review header, and never merged into the owner's message.
857
+ shell line (chi web, the Bridge, the worker), and runs only on a worker with `pair_turns`: the pair boundary denies secrets and
858
+ owner-voiced tools, the owner's guardrails decide the rest, and every ask is the owner's, once only.
859
+ - No turn an older chi ran read-only runs with tool rights: an invite without `mode: "pair"`, or a Verify fresh child
860
+ saved otherwise, is refused at the worker (`outdated`), and `Guardrails::ParticipantRefusal` denies every call of
861
+ any other participant turn that isn't a current invite's.
862
+ - A participant's message is never sent without its header (`[From …, a teammate …]`, or the review one for an
863
+ older chi's unstamped or read-only message), and never merged into the owner's message.
889
864
  - The owner's input is never merged into a participant's running turn (the Bridge queues it, the drain takes only
890
865
  the participant's own lines): it runs as the owner's own turn after it.
891
866
  - A participant stops only a turn they started, named by its id, which the worker compares under its lock.
@@ -158,14 +158,13 @@ right-hand column happens.
158
158
  notes are (`Prompt::ESCAPED_KINDS`). The turn-end warm-up never warms a drop sent after the turn: it misses once.
159
159
  - **Participants** ([participants.md](participants.md#attribution)). A participant's message carries a wire-only
160
160
  header line (`Steer.review_header`), a pure function of the saved message (its `author_name` and its
161
- `participant_mode` stamp included: a review or a pair header), so a replay sends the same bytes; the owner's
161
+ `participant_mode` stamp included: the pair header, or the review one for an older chi's message), so a replay sends the same bytes; the owner's
162
162
  messages are sent as before (`spec/review_contribution_spec.rb`, per loop and on a Messages host). The
163
163
  participants line opens the system prompt's volatile tail, after breakpoint #1: a new session's cache is
164
- untouched. Its words follow the session's `ParticipantMode` (a review or a working session's line), which never
165
- changes for a session. The Engine checks the sidecar at each turn's start and rebuilds (`reset!`) only when the
164
+ untouched. It has one wording (`SystemPrompt::PARTICIPANTS_LINE`). The Engine checks the sidecar at each turn's start and rebuilds (`reset!`) only when the
166
165
  first participant joins and when the last leaves or expires: one history re-read each, then stable. Under D3(a)
167
- the declared tools stay the session's, so an author switch costs nothing: the review and pair boundaries are
168
- gates on the calls, not a toolkit switch. The forged-header mark (`(quoted) `) is a pure function of the text too.
166
+ the declared tools stay the session's, so an author switch costs nothing: the participant boundary is a gate
167
+ on the calls, not a toolkit switch. The forged-header mark (`(quoted) `) is a pure function of the text too.
169
168
  - Side requests (idle recap, `/btw`) go through `IdleClient` with their own short system prompt (the recap's also
170
169
  asks for its auto title line, `RecapPrompt::TITLE`: static text, still that one request). On a current
171
170
  llama.cpp they don't evict the session (see the server settings below); chi never pins them to a slot.