samagotchi 0.170.0 → 0.172.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -1
  3. data/bin/chi +6 -4
  4. data/docs/architecture.md +26 -9
  5. data/docs/bundles.md +4 -21
  6. data/docs/cli.md +81 -97
  7. data/docs/configuration.md +12 -14
  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/block-renderers.md +2 -2
  14. data/docs/internals/bridge.md +34 -7
  15. data/docs/internals/context-telemetry.md +13 -1
  16. data/docs/internals/engine.md +25 -13
  17. data/docs/internals/inline-widgets.md +1 -1
  18. data/docs/internals/objectives.md +4 -6
  19. data/docs/internals/participants.md +340 -249
  20. data/docs/internals/prompt-caching.md +4 -5
  21. data/docs/internals/web-frontend.md +185 -35
  22. data/docs/internals/working-set.md +71 -5
  23. data/docs/memory.md +1 -1
  24. data/docs/plugins.md +2 -16
  25. data/docs/releasing.md +2 -1
  26. data/docs/scheduling.md +1 -1
  27. data/docs/sessions.md +17 -48
  28. data/docs/sub-agent.md +2 -2
  29. data/docs/system-one.md +2 -2
  30. data/docs/testing.md +56 -7
  31. data/lib/samagotchi/bridge/card_store.rb +1 -0
  32. data/lib/samagotchi/bridge/sse_writer.rb +1 -0
  33. data/lib/samagotchi/bridge/turn_accumulator.rb +8 -5
  34. data/lib/samagotchi/bridge.rb +64 -20
  35. data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
  36. data/lib/samagotchi/bundle_command/test_run.rb +1 -0
  37. data/lib/samagotchi/bundle_command/try/run.rb +1 -0
  38. data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
  39. data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
  40. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
  41. data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
  42. data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
  43. data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
  44. data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
  45. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  46. data/lib/samagotchi/client_id.rb +126 -67
  47. data/lib/samagotchi/command_intake.rb +15 -3
  48. data/lib/samagotchi/compat.rb +6 -1
  49. data/lib/samagotchi/context_candidate_choice.rb +1 -3
  50. data/lib/samagotchi/context_candidates.rb +3 -4
  51. data/lib/samagotchi/continue_offer.rb +9 -2
  52. data/lib/samagotchi/delivery.rb +36 -12
  53. data/lib/samagotchi/empty_answer_error.rb +5 -0
  54. data/lib/samagotchi/engine/cards.rb +3 -0
  55. data/lib/samagotchi/engine/context_judge.rb +5 -3
  56. data/lib/samagotchi/engine/events.rb +4 -0
  57. data/lib/samagotchi/engine/hooks.rb +3 -0
  58. data/lib/samagotchi/engine/messages.rb +5 -0
  59. data/lib/samagotchi/engine/model_settings.rb +2 -0
  60. data/lib/samagotchi/engine/models.rb +10 -0
  61. data/lib/samagotchi/engine/objectives.rb +6 -0
  62. data/lib/samagotchi/engine/participants.rb +18 -14
  63. data/lib/samagotchi/engine/plugins.rb +8 -0
  64. data/lib/samagotchi/engine/questions.rb +3 -0
  65. data/lib/samagotchi/engine/recap.rb +1 -0
  66. data/lib/samagotchi/engine/session.rb +4 -0
  67. data/lib/samagotchi/engine/side_requests.rb +9 -0
  68. data/lib/samagotchi/engine/steering.rb +2 -0
  69. data/lib/samagotchi/engine/toolkit.rb +5 -0
  70. data/lib/samagotchi/engine/turn_end.rb +7 -0
  71. data/lib/samagotchi/engine/turn_helpers.rb +8 -0
  72. data/lib/samagotchi/engine/verify.rb +2 -0
  73. data/lib/samagotchi/engine.rb +8 -3
  74. data/lib/samagotchi/event_fanout.rb +22 -1
  75. data/lib/samagotchi/grants.rb +33 -22
  76. data/lib/samagotchi/guardrail_wiring.rb +23 -18
  77. data/lib/samagotchi/guardrails/approval_use.rb +59 -0
  78. data/lib/samagotchi/guardrails/approvals.rb +9 -11
  79. data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
  80. data/lib/samagotchi/guardrails/gate.rb +10 -5
  81. data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
  82. data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
  83. data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
  84. data/lib/samagotchi/guardrails/review_paths.rb +2 -3
  85. data/lib/samagotchi/guardrails.rb +1 -1
  86. data/lib/samagotchi/image_store.rb +51 -12
  87. data/lib/samagotchi/kernel_loop.rb +7 -1
  88. data/lib/samagotchi/llm/stray_tool_call.rb +7 -4
  89. data/lib/samagotchi/llm_context_stale.rb +4 -1
  90. data/lib/samagotchi/llm_context_strategy.rb +2 -0
  91. data/lib/samagotchi/objectives.rb +1 -4
  92. data/lib/samagotchi/objectives_audit.rb +1 -1
  93. data/lib/samagotchi/objectives_track.rb +1 -1
  94. data/lib/samagotchi/owner_prompt.rb +3 -6
  95. data/lib/samagotchi/parent_report.rb +1 -0
  96. data/lib/samagotchi/participant_messages.rb +48 -4
  97. data/lib/samagotchi/participant_revise.rb +61 -0
  98. data/lib/samagotchi/participant_turn_mode.rb +50 -0
  99. data/lib/samagotchi/participant_uploads.rb +98 -0
  100. data/lib/samagotchi/participants.rb +21 -12
  101. data/lib/samagotchi/participants_watch.rb +2 -2
  102. data/lib/samagotchi/plugin/api.rb +2 -2
  103. data/lib/samagotchi/plugin/attached_context.rb +1 -1
  104. data/lib/samagotchi/plugin/context.rb +0 -4
  105. data/lib/samagotchi/plugin/sessions.rb +1 -25
  106. data/lib/samagotchi/reply_wait/poll.rb +5 -1
  107. data/lib/samagotchi/revise_anchor.rb +9 -0
  108. data/lib/samagotchi/run_options.rb +2 -3
  109. data/lib/samagotchi/send_command.rb +15 -10
  110. data/lib/samagotchi/session.rb +0 -3
  111. data/lib/samagotchi/session_access/contract.rb +1 -10
  112. data/lib/samagotchi/session_access/local.rb +10 -23
  113. data/lib/samagotchi/session_access/remote.rb +9 -20
  114. data/lib/samagotchi/session_access.rb +12 -16
  115. data/lib/samagotchi/session_chain.rb +4 -6
  116. data/lib/samagotchi/session_commands.rb +6 -3
  117. data/lib/samagotchi/session_continue.rb +1 -2
  118. data/lib/samagotchi/session_inbox.rb +20 -12
  119. data/lib/samagotchi/session_manager/delivery.rb +32 -5
  120. data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
  121. data/lib/samagotchi/session_manager/listing.rb +5 -0
  122. data/lib/samagotchi/session_manager/spawn.rb +2 -2
  123. data/lib/samagotchi/session_manager/worker_command.rb +9 -0
  124. data/lib/samagotchi/session_participants.rb +12 -8
  125. data/lib/samagotchi/session_review.rb +5 -7
  126. data/lib/samagotchi/session_stores.rb +3 -1
  127. data/lib/samagotchi/share_command.rb +10 -12
  128. data/lib/samagotchi/share_terms.rb +41 -0
  129. data/lib/samagotchi/steer.rb +8 -14
  130. data/lib/samagotchi/system_prompt.rb +16 -25
  131. data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
  132. data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
  133. data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
  134. data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
  135. data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
  136. data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
  137. data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
  138. data/lib/samagotchi/terminal_ui.rb +1 -2
  139. data/lib/samagotchi/testing/sessions.rb +2 -10
  140. data/lib/samagotchi/tool_runner.rb +42 -9
  141. data/lib/samagotchi/toolkit.rb +4 -22
  142. data/lib/samagotchi/toolkit_suggest.rb +3 -3
  143. data/lib/samagotchi/tools/deferred_tools.rb +1 -0
  144. data/lib/samagotchi/tools/execute.rb +11 -45
  145. data/lib/samagotchi/tools/leftovers.rb +122 -0
  146. data/lib/samagotchi/tools/memory.rb +88 -25
  147. data/lib/samagotchi/tools/task_get.rb +1 -0
  148. data/lib/samagotchi/tools/task_list.rb +3 -2
  149. data/lib/samagotchi/tools/task_record.rb +6 -4
  150. data/lib/samagotchi/tools/task_runtime.rb +199 -20
  151. data/lib/samagotchi/tools/task_wait.rb +4 -3
  152. data/lib/samagotchi/turn_anchors.rb +0 -3
  153. data/lib/samagotchi/turn_context.rb +1 -1
  154. data/lib/samagotchi/turn_origin.rb +1 -1
  155. data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
  156. data/lib/samagotchi/turn_stages/objectives.rb +2 -2
  157. data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
  158. data/lib/samagotchi/turn_stages/verify_anchors.rb +13 -1
  159. data/lib/samagotchi/update_hint.rb +3 -1
  160. data/lib/samagotchi/verify_anchor.rb +6 -0
  161. data/lib/samagotchi/verify_fresh.rb +1 -1
  162. data/lib/samagotchi/verify_fresh_origin.rb +13 -11
  163. data/lib/samagotchi/version.rb +1 -1
  164. data/lib/samagotchi/web/app.rb +45 -82
  165. data/lib/samagotchi/web/participant_access.rb +139 -40
  166. data/lib/samagotchi/web/participant_images.rb +185 -0
  167. data/lib/samagotchi/web/participant_review.rb +22 -142
  168. data/lib/samagotchi/web/participant_show.rb +241 -0
  169. data/lib/samagotchi/web/participant_stream_filter.rb +25 -2
  170. data/lib/samagotchi/web/participant_view.rb +334 -27
  171. data/lib/samagotchi/web/participants_admin.rb +21 -40
  172. data/lib/samagotchi/web/public/annotate_bar.css +1 -2
  173. data/lib/samagotchi/web/public/annotate_bar.js +1 -2
  174. data/lib/samagotchi/web/public/app.js +126 -132
  175. data/lib/samagotchi/web/public/block_host.js +7 -4
  176. data/lib/samagotchi/web/public/bubbles.js +9 -1
  177. data/lib/samagotchi/web/public/cards_offscreen.js +69 -0
  178. data/lib/samagotchi/web/public/chip_popover.js +5 -4
  179. data/lib/samagotchi/web/public/claim_link.js +4 -4
  180. data/lib/samagotchi/web/public/composer.css +4 -6
  181. data/lib/samagotchi/web/public/composer_mode.js +11 -6
  182. data/lib/samagotchi/web/public/composer_mount.js +4 -4
  183. data/lib/samagotchi/web/public/ctx.js +12 -3
  184. data/lib/samagotchi/web/public/data.js +2 -10
  185. data/lib/samagotchi/web/public/delivery_line.js +49 -63
  186. data/lib/samagotchi/web/public/history_shape.js +5 -1
  187. data/lib/samagotchi/web/public/images.js +7 -1
  188. data/lib/samagotchi/web/public/index.html +50 -34
  189. data/lib/samagotchi/web/public/info_bar_model.js +2 -1
  190. data/lib/samagotchi/web/public/live_turn.js +1 -1
  191. data/lib/samagotchi/web/public/markdown_place.js +5 -4
  192. data/lib/samagotchi/web/public/owner_claim.js +5 -5
  193. data/lib/samagotchi/web/public/owner_verify.js +0 -2
  194. data/lib/samagotchi/web/public/participant_bar.js +107 -0
  195. data/lib/samagotchi/web/public/participant_main.js +289 -0
  196. data/lib/samagotchi/web/public/participant_model.js +5 -292
  197. data/lib/samagotchi/web/public/participant_names.js +17 -8
  198. data/lib/samagotchi/web/public/participant_revise.js +66 -0
  199. data/lib/samagotchi/web/public/participants_panel.js +32 -74
  200. data/lib/samagotchi/web/public/question_cards.js +14 -3
  201. data/lib/samagotchi/web/public/refs.js +53 -36
  202. data/lib/samagotchi/web/public/reload_check.js +70 -14
  203. data/lib/samagotchi/web/public/revise_stack.js +21 -10
  204. data/lib/samagotchi/web/public/send_turn.js +28 -29
  205. data/lib/samagotchi/web/public/session_actions.js +4 -45
  206. data/lib/samagotchi/web/public/session_fields.js +1 -2
  207. data/lib/samagotchi/web/public/session_state.js +12 -7
  208. data/lib/samagotchi/web/public/session_sync.js +9 -2
  209. data/lib/samagotchi/web/public/session_view.js +14 -5
  210. data/lib/samagotchi/web/public/settings_panel.js +4 -18
  211. data/lib/samagotchi/web/public/stage_answer.js +56 -0
  212. data/lib/samagotchi/web/public/stage_asking.js +7 -5
  213. data/lib/samagotchi/web/public/stage_cloud.js +93 -0
  214. data/lib/samagotchi/web/public/stage_dom.js +100 -0
  215. data/lib/samagotchi/web/public/stage_handoff.js +154 -0
  216. data/lib/samagotchi/web/public/stage_owner_wait.js +35 -0
  217. data/lib/samagotchi/web/public/stage_pager.js +59 -0
  218. data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
  219. data/lib/samagotchi/web/public/stage_view.js +103 -410
  220. data/lib/samagotchi/web/public/stage_waiting.js +74 -6
  221. data/lib/samagotchi/web/public/start_page.js +12 -33
  222. data/lib/samagotchi/web/public/start_settings.js +24 -78
  223. data/lib/samagotchi/web/public/start_toolkit.js +6 -10
  224. data/lib/samagotchi/web/public/storage.js +22 -0
  225. data/lib/samagotchi/web/public/stream_handlers.js +3 -10
  226. data/lib/samagotchi/web/public/tokens.css +1 -1
  227. data/lib/samagotchi/web/public/turn_block.js +2 -5
  228. data/lib/samagotchi/web/public/turn_events.js +30 -12
  229. data/lib/samagotchi/web/public/turn_html.js +9 -2
  230. data/lib/samagotchi/web/public/turn_pieces.js +3 -4
  231. data/lib/samagotchi/web/public/turn_range.js +1 -2
  232. data/lib/samagotchi/web/public/verify_target.js +2 -4
  233. data/lib/samagotchi/web/public/viewer.js +59 -0
  234. data/lib/samagotchi/web/public/viewer_self.js +59 -0
  235. data/lib/samagotchi/web/public/working_set.js +11 -5
  236. data/lib/samagotchi/web/public/working_set_view.js +53 -8
  237. data/lib/samagotchi/web/public/ws_cards.js +89 -0
  238. data/lib/samagotchi/web/public/ws_peek.js +106 -0
  239. data/lib/samagotchi/web/public/ws_preview.css +126 -0
  240. data/lib/samagotchi/web/public/ws_reader.js +319 -0
  241. data/lib/samagotchi/web/public/ws_timeline.js +200 -0
  242. data/lib/samagotchi/web/public/ws_way_in.js +25 -0
  243. data/lib/samagotchi/web/qr.rb +1 -1
  244. data/lib/samagotchi/web/session_control.rb +42 -15
  245. data/lib/samagotchi/web/session_create.rb +6 -72
  246. data/lib/samagotchi/web/session_show.rb +75 -28
  247. data/lib/samagotchi/web/session_summary.rb +1 -4
  248. data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
  249. data/lib/samagotchi/web/viewer.rb +70 -0
  250. data/lib/samagotchi/web/working_set_routes.rb +132 -0
  251. data/lib/samagotchi/worker.rb +35 -28
  252. data/lib/samagotchi/worker_inbound.rb +4 -3
  253. data/lib/samagotchi/worker_link.rb +17 -0
  254. data/lib/samagotchi/working_set.rb +322 -11
  255. metadata +32 -13
  256. data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
  257. data/lib/samagotchi/participant_mode.rb +0 -86
  258. data/lib/samagotchi/review_apply.rb +0 -131
  259. data/lib/samagotchi/review_command.rb +0 -123
  260. data/lib/samagotchi/review_start.rb +0 -196
  261. data/lib/samagotchi/web/public/participant.html +0 -218
  262. data/lib/samagotchi/web/public/participant.js +0 -719
  263. data/lib/samagotchi/web/public/participant_annotate.js +0 -76
  264. data/lib/samagotchi/web/public/review_apply.js +0 -34
  265. data/lib/samagotchi/web/public/review_history.js +0 -72
  266. data/lib/samagotchi/web/public/review_start.js +0 -55
  267. data/lib/samagotchi/web/public/tools_overview.js +0 -42
@@ -118,6 +118,11 @@ module Samagotchi
118
118
  MAX_BODY_BYTES = 1_000_000
119
119
  # A request's deadline (see #handle_post_turn) that isn't epoch seconds.
120
120
  BAD_DEADLINE = [{ "Allow" => "POST" }, 400, { error: "bad_deadline", detail: "deadline must be epoch seconds" }].freeze
121
+ # A POST /command that names no sender: every sender names itself
122
+ # (ClientId::NONE is never the owner's), so it runs nothing.
123
+ UNNAMED_COMMAND = "a session command must name its sender: send client_id (a web tab's web:<id>, a chi TUI's " \
124
+ "tui:<pid>, chi send's cli:send)"
125
+ UNNAMED_COMMAND_REPLY = [{ "Allow" => "POST" }, 400, { error: "missing_client_id", detail: UNNAMED_COMMAND }].freeze
121
126
  # The request header that names the Bridge's secret, lowercased as #read_request keeps it.
122
127
  SECRET_HEADER = BridgeSecret::HEADER.downcase
123
128
  # Bytes of randomness in a Bridge's secret (hex in bridge.json: twice as many characters).
@@ -773,18 +778,32 @@ module Samagotchi
773
778
  # Stop's last_turn carry the turn's enqueued_id (ReplyWait.own_turn).
774
779
  # unqueue: POST turn/dequeue (#handle_dequeue_turn) takes a queued
775
780
  # message back before it runs.
776
- # review_turns: a participant's turn runs as its own, inside the review
777
- # boundary (Guardrails::ReviewBoundary); a worker without it has none,
778
- # so chi web sends it no participant's turn (Delivery::REVIEW_FEATURE).
779
- # pair_turns: a participant's turn in a working session runs as a pair
780
- # turn (Guardrails::PairBoundary); a worker without it runs it as a
781
- # review turn, and chi web says so (Delivery::PAIR_FEATURE).
781
+ # review_turns: a participant's turn runs as its own, inside a
782
+ # boundary; kept for an older chi web, which sends no participant's turn
783
+ # to a worker without it (Delivery::REVIEW_FEATURE).
784
+ # pair_turns: a participant's turn runs under the owner's guardrails
785
+ # (Guardrails::PairBoundary); chi web sends no participant's turn to a
786
+ # worker without it, nor invites anyone to its session (Delivery::PAIR_FEATURE).
787
+ # participant_steer: a participant's message sent while their own turn
788
+ # runs goes in at its next step (a worker without it queues it); only
789
+ # what the page's delivery line and chi web's ack say depends on it
790
+ # (Delivery::OWN_TURN_STEER_FEATURE).
791
+ # cancel_turn_id: POST cancel with a turn_id cancels that turn only
792
+ # (Delivery::CANCEL_TURN_ID_FEATURE), what chi web needs to relay a
793
+ # participant's cancel.
794
+ # participant_revise: a participant's Revise draft is kept, and the
795
+ # Engine checks it at the stamp (ParticipantRevise): what chi web needs
796
+ # to pass one on (ReviseAnchor::PARTICIPANT_FEATURE).
782
797
  # activity: GET /activity answers with Worker#activity_snapshot, so
783
798
  # `chi schedule tick` can ask a live worker what it is busy with.
799
+ # participant_client_id: it reads a participant's client id as
800
+ # participant:<id>; chi web sends a worker without it review:<id>
801
+ # (Delivery::PARTICIPANT_ID_FEATURE).
784
802
  FEATURES = ["restart", "task_stop", "reparent", Delivery::QUEUE_FEATURE, ReplyWait::TURN_IDS_FEATURE,
785
803
  VerifyAnchor::FEATURE, ReviseAnchor::FEATURE,
786
804
  SessionInbox::UNQUEUE_FEATURE, Delivery::REVIEW_FEATURE, Delivery::PAIR_FEATURE, TurnDrawings::FEATURE,
787
- WorkerLink::ACTIVITY_FEATURE, ObjectivesTrack::FEATURE].freeze
805
+ WorkerLink::ACTIVITY_FEATURE, ObjectivesTrack::FEATURE, Delivery::OWN_TURN_STEER_FEATURE,
806
+ Delivery::CANCEL_TURN_ID_FEATURE, ReviseAnchor::PARTICIPANT_FEATURE, Delivery::PARTICIPANT_ID_FEATURE].freeze
788
807
 
789
808
  # The routes, by method and what follows /session/:id/: a handler takes
790
809
  # the session id and the request body and returns [headers, status, body].
@@ -1062,11 +1081,20 @@ module Samagotchi
1062
1081
  return [{ "Allow" => "POST" }, 400, { error: "unknown_command", detail: detail }]
1063
1082
  end
1064
1083
 
1084
+ client_id = fetched(parsed, "client_id")
1085
+ return UNNAMED_COMMAND_REPLY if client_id.to_s.strip.empty?
1086
+
1087
+ # Only the owner's senders and chi answer's (CommandIntake.allowed?),
1088
+ # as for a command sent as a message.
1089
+ unless CommandIntake.allowed?(client_id)
1090
+ Log.warn(:bridge, "command_refused", client_id: client_id)
1091
+ return [{}, 403, { error: CommandIntake::REFUSED_ERROR, detail: CommandIntake.refusal(line) }]
1092
+ end
1093
+
1065
1094
  deadline = fetched(parsed, "deadline")
1066
1095
  return BAD_DEADLINE unless deadline_valid?(deadline)
1067
1096
 
1068
- queue_command_request(session_id, line, client_id: fetched(parsed, "client_id"), deadline: deadline,
1069
- card: fetched(parsed, "card") == true)
1097
+ queue_command_request(session_id, line, client_id: client_id, deadline: deadline, card: fetched(parsed, "card") == true)
1070
1098
  end
1071
1099
 
1072
1100
  # Queues +line+ (a session command) for the worker and announces its
@@ -1249,10 +1277,10 @@ module Samagotchi
1249
1277
  # request's principal; the Bridge is loopback and trusts its caller).
1250
1278
  author = fetched(parsed, "author")
1251
1279
  author = nil unless author.is_a?(String) && !author.empty?
1252
- # A Verify turn's claim, a Revise turn's draft; a participant can't
1253
- # Revise (chi web drops it first, this is the worker's own layer).
1280
+ # A Verify turn's claim, a Revise turn's draft. A participant's draft
1281
+ # is checked by chi web at the send and by the Engine at the stamp
1282
+ # (TurnStages::VerifyAnchors#revision_target, ParticipantRevise).
1254
1283
  anchors = TurnAnchors.from(parsed)
1255
- anchors = anchors.without_revises if Steer.participant_author?(author)
1256
1284
  if sid.to_s.strip.empty? || prompt.to_s.strip.empty?
1257
1285
  return [{ "Allow" => "POST" }, 400,
1258
1286
  { error: "missing_fields", detail: "session_id and prompt are required" }]
@@ -1275,12 +1303,14 @@ module Samagotchi
1275
1303
  # (chi web's, from their grant: its queue limit plus the running one).
1276
1304
  pending_limit = nil
1277
1305
  if Steer.participant_author?(author)
1278
- # A participant's message is a turn of its own, whatever the body
1279
- # asks (D6), and never a command or a shell line: chi web refuses
1280
- # those first, and this is the worker's own layer.
1306
+ # A participant's message never cuts, nor is a command or a shell
1307
+ # line: chi web refuses those first, and this is the worker's own
1308
+ # layer. It goes into a running turn only when that turn is theirs
1309
+ # (#enqueue_post_turn, under the event log), else it is a turn of
1310
+ # its own (D6).
1281
1311
  return participant_refused(sid, author, "command") if command_registry.command?(prompt.to_s)
1282
1312
 
1283
- delivery = Delivery::QUEUE
1313
+ delivery = Delivery::NEXT_STEP if Delivery.cut?(delivery)
1284
1314
  pending_limit = fetched(parsed, "pending_limit")
1285
1315
  pending_limit = nil unless pending_limit.is_a?(Integer) && pending_limit.positive?
1286
1316
  end
@@ -1336,10 +1366,11 @@ module Samagotchi
1336
1366
  next :too_many if pending_limit && pending_turns(author) >= pending_limit
1337
1367
  next :duplicate unless @engine.reserve_enqueued_id(enqueued_id)
1338
1368
 
1339
- # The owner's input never goes into a participant's read-only
1340
- # review turn (a steer, a cut): it queues behind it as the owner's
1341
- # own turn, and the ack and :turn_enqueued say so.
1342
- delivery = Delivery::QUEUE if @accumulator.participant_turn?
1369
+ # Input goes into a running turn only of its own author: the
1370
+ # owner's never into a participant's turn (a steer, a cut), a
1371
+ # participant's only into their own; else it queues behind it as
1372
+ # a turn of its own, and the ack and :turn_enqueued say so.
1373
+ delivery = Delivery::QUEUE unless same_author_steer?(author)
1343
1374
  queued_behind_turn = Delivery.queue?(delivery) && !@accumulator.current_turn.nil?
1344
1375
  unless enqueue_turn(prompt: prompt, client_id: client_id, enqueued_id: enqueued_id,
1345
1376
  no_interrupt: no_interrupt, images: images, delivery: delivery, author: author, anchors: anchors)
@@ -1430,6 +1461,19 @@ module Samagotchi
1430
1461
  dequeue_reply(taken, id, input)
1431
1462
  end
1432
1463
 
1464
+ # Whether input from +author+ may go into the running turn: the owner's
1465
+ # into the owner's (or none running), a participant's into their own
1466
+ # only (none running: theirs runs as the next turn, a queue). Read with
1467
+ # the event log held.
1468
+ def same_author_steer?(author)
1469
+ sender = Steer.sender_author(author)
1470
+ running = @accumulator.participant_author
1471
+ return running.nil? if sender.nil?
1472
+ return false if @accumulator.current_turn.nil?
1473
+
1474
+ running == sender
1475
+ end
1476
+
1433
1477
  # +author+'s turns running or waiting: the running turn when it is
1434
1478
  # theirs, and their queued ones. Read with the event log held.
1435
1479
  def pending_turns(author)
@@ -3,6 +3,8 @@
3
3
  require "json"
4
4
  require "uri"
5
5
  require_relative "../bridge_secret"
6
+ require_relative "sse_parser"
7
+ require_relative "stream_open"
6
8
 
7
9
  module Samagotchi
8
10
  class BridgeClient
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "rbconfig"
4
4
  require_relative "../cli/flags"
5
+ require_relative "../cli/exit"
5
6
 
6
7
  module Samagotchi
7
8
  class BundleCommand
@@ -4,6 +4,7 @@ require "open3"
4
4
  require "rbconfig"
5
5
  require_relative "../../cli/exit"
6
6
  require_relative "../../process_group"
7
+ require_relative "sandbox"
7
8
 
8
9
  module Samagotchi
9
10
  class BundleCommand
@@ -1,21 +1,20 @@
1
1
  ---
2
2
  name: coordinator
3
- version: 0.8.1
3
+ version: 0.9.0
4
4
  scope: system
5
- description: "Coordinate parallel work: the coordinator skill (split the work, one worktree and child session per task, check each report, merges under a guardrail approval (the git-merge rule) or a question, a handoff memory to resume from), /coordinate <goal>, /coordinate resume, /coordinate end, /coordinate review (experimental: a sprint review session to share) and /children; the coordinator toolkit (lean + delegate, delegate_result, list_sessions, objectives) and the coding toolkit for build children (child + be concise)"
5
+ description: "Coordinate parallel work: the coordinator skill (split the work, one worktree and child session per task, check each report, merges under a guardrail approval (the git-merge rule) or a question, a handoff memory to resume from), /coordinate <goal>, /coordinate resume, /coordinate end and /children; the coordinator toolkit (lean + delegate, delegate_result, list_sessions, objectives) and the coding toolkit for build children (child + be concise)"
6
6
  trust_level: reviewed
7
7
  files:
8
8
  skill_coordinator.md:
9
- sha256: sha256:1cac885facd28757aaa0197b28889246f845834c17101d59b5625d1b2b89679a
9
+ sha256: sha256:21a56711f4ac1252ff6012a6ed0a743cb90732939abed406a9b8753a755c8d0c
10
10
  description: "Coordinate parallel work: split it, delegate each task wait:false in its own worktree (cwd:), check each report, merge under the git-merge approval or ask the user; resume from a handoff_* memory"
11
11
  plugin:
12
12
  file: plugin.rb
13
- sha256: sha256:540dd6369342ea4dcbc6ba5ee17fb20d980b880df614a475668c70115e7ec6b8
13
+ sha256: sha256:406b9827485535a8be17d4f1b291997ebf5c3f7d5616d20812c53b4ea153f601
14
14
  # the coordinator toolkit needs chi.toolkit and ctx.use_toolkit (0.66.0); the
15
15
  # coding toolkit (chi.toolkit prompt:) and the skill's delegate toolkit: need
16
16
  # the next chi.
17
17
  requires_chi: ">= 0.107.0"
18
- # /coordinate review uses ctx.sessions.review (the next chi).
19
18
  # No requires_chi_next for guardrails/merge.yml: its keys are long supported, and first-ever too-new rules would make a
20
19
  # live older worker deny every call. A chi without `chi guardrails rule` gives a usage error, and the skill then asks.
21
20
  # Nor for the objectives tool in the kit and the skill: on an older chi the kit's add names nothing (it declares only what
@@ -27,14 +27,6 @@
27
27
  # (/coordinate resume <name>); none: says so. It reads the project's
28
28
  # memories folder, nothing else.
29
29
  #
30
- # /coordinate review [handoff] (experimental) opens a sprint review: a review
31
- # session of this one (ctx.sessions.review: its recap, never its transcript;
32
- # this session keeps running), seeded with the open handoff's body (the one
33
- # named, the only one open, or a card with a Review action each when several
34
- # are), for participants (chi share): its model answers their new context
35
- # with a hand-off diff and the owner applies it (the skill's Sprint review).
36
- # With none open it starts from the recap alone and says so.
37
- #
38
30
  # /coordinate end ends the day: the model is asked to follow the skill's End
39
31
  # of day (bring its handoff up to date, keep it OPEN unless all is done, give
40
32
  # a short report). It reads nothing itself; "end" with more words is a goal.
@@ -64,21 +56,9 @@ class Plugin
64
56
  TEXT_CHARS = 80
65
57
  USAGE = "usage: /children [all] | /children stop <id>"
66
58
  COORDINATE_USAGE = "usage: /coordinate <goal> — chi splits it into tasks, one child session and worktree each; " \
67
- "/coordinate resume [name] — pick up an open handoff; /coordinate end — save the handoff, end-of-day report; " \
68
- "/coordinate review [name] — a sprint review session to share (experimental)"
59
+ "/coordinate resume [name] — pick up an open handoff; /coordinate end — save the handoff, end-of-day report"
69
60
  RESUME_CARD_ID = "coordinate-resume"
70
- REVIEW_CARD_ID = "coordinate-review"
71
- # The seed's note: what to do (the skill's Sprint review section, copied:
72
- # a participant's turn may read project memories only, and the skill is
73
- # where its bundle was installed, usually system) and the handoff's body.
74
- REVIEW_SEED = "This is a sprint review of the coordinator session %<source>s (experimental). The " \
75
- "skill_coordinator memory's Sprint review section, which you follow here:"
76
- SKILL = "skill_coordinator"
77
- SPRINT_REVIEW_HEADING = /^## Sprint review\b.*$/
78
- # The section's gist when the skill's file can't be read.
79
- SPRINT_REVIEW_FALLBACK = "A participant's turn may only read. Answer new context with a hand-off diff (the " \
80
- "handoff's lines as they would change, in a diff block) and what it means per branch. When " \
81
- "the owner applies it, update the handoff and re-plan in words; start, stop or merge nothing here."
61
+ REVIEW_GONE = "/coordinate review is gone (coordinator 0.9.0): chi has no review sessions; invite someone with chi share"
82
62
  # A card takes 6 actions.
83
63
  MAX_RESUMES = 6
84
64
  HANDOFF_LINE = /^- \*\*(handoff_[^*\s]+)\*\*(.*)$/
@@ -98,8 +78,7 @@ class Plugin
98
78
  children_command(args.to_s.strip, ctx)
99
79
  end
100
80
  chi.command "/coordinate", "run work in parallel: chi splits <goal> into tasks, each in a child session and worktree; " \
101
- "resume: pick up an open handoff; end: save the handoff, end-of-day report; " \
102
- "review: a sprint review session to share (experimental)",
81
+ "resume: pick up an open handoff; end: save the handoff, end-of-day report",
103
82
  anytime: true do |args, ctx|
104
83
  coordinate(args.to_s.strip, ctx)
105
84
  end
@@ -163,8 +142,9 @@ class Plugin
163
142
  verb, rest = goal.split(/\s+/, 2)
164
143
  # "resume" and at most a name; "resume the old work" is a goal.
165
144
  return resume(rest.to_s.strip, ctx) if verb == "resume" && !rest.to_s.strip.match?(/\s/)
166
- # "review" and at most a name; "review the specs" is a goal.
167
- return review(rest.to_s.strip, ctx) if verb == "review" && !rest.to_s.strip.match?(/\s/)
145
+ # "review" and at most a name (an old card's action, a habit): gone, said
146
+ # once rather than run as a goal; "review the specs" is a goal.
147
+ return REVIEW_GONE if verb == "review" && !rest.to_s.strip.match?(/\s/)
168
148
  # A bare "end" only; "end the flaky specs" is a goal.
169
149
  return end_of_day(ctx) if verb == "end" && rest.to_s.strip.empty?
170
150
 
@@ -198,59 +178,6 @@ class Plugin
198
178
  "asked chi to end the day; a running turn gets it at its next step")
199
179
  end
200
180
 
201
- # /coordinate review [name]
202
- def review(name, ctx)
203
- open = open_handoffs(ctx)
204
- if name.empty?
205
- return handoff_card(open, ctx, verb: "review", id: REVIEW_CARD_ID) if open.size > 1
206
-
207
- name = open.first&.dig(:name)
208
- else
209
- name = "handoff_#{name}" unless name.start_with?("handoff_")
210
- unless open.any? { |handoff| handoff[:name] == name }
211
- return "/coordinate review: no open handoff #{name} in this project (#{open.empty? ? "none is open" : "open: #{open.map { |h| h[:name] }.join(", ")}"})"
212
- end
213
- end
214
- start_review(name, ctx)
215
- end
216
-
217
- def start_review(name, ctx)
218
- seed = "#{format(REVIEW_SEED, source: ctx.session_id.to_s[0, 8])}\n\n#{sprint_review_section(ctx)}"
219
- seed += "\n\nThe coordinator's handoff #{name} as of now (memory_read it, scope: project, for the latest):\n\n#{handoff_body(name, ctx)}" if name
220
- id = ctx.sessions.review(seed: seed)
221
- short = id.to_s[0, 8]
222
- ["sprint review #{short} started from this session (experimental), #{name ? "seeded with #{name}" : "from its recap alone: no open handoff"}; " \
223
- "this session keeps running.",
224
- "invite someone: chi share #{short} --name NAME (or the participants chip on its page); their new context comes " \
225
- "back as a hand-off diff; Apply under it (on its page) puts the change in your composer there."].join("\n")
226
- rescue Samagotchi::Plugin::Sessions::Error => e
227
- "/coordinate review: #{e.message}"
228
- end
229
-
230
- # The skill's Sprint review section as installed (system scope, else the
231
- # project's), heading to the next heading; the fallback without one.
232
- def sprint_review_section(ctx)
233
- %w[system project].each do |scope|
234
- file = File.join(Samagotchi::MemoryPaths.scope_dir(scope, cwd: ctx.cwd).to_s, "#{SKILL}.md")
235
- next unless File.file?(file)
236
-
237
- text = File.read(file, encoding: "UTF-8")
238
- start = text.index(SPRINT_REVIEW_HEADING) or next
239
- rest = text[start..]
240
- stop = rest.index(/^## /, 1)
241
- return (stop ? rest[0...stop] : rest).strip
242
- end
243
- SPRINT_REVIEW_FALLBACK
244
- rescue SystemCallError
245
- SPRINT_REVIEW_FALLBACK
246
- end
247
-
248
- def handoff_body(name, ctx)
249
- File.read(File.join(Samagotchi::MemoryPaths.scope_dir("project", cwd: ctx.cwd).to_s, "#{name}.md"), encoding: "UTF-8").strip
250
- rescue SystemCallError
251
- "(its file couldn't be read)"
252
- end
253
-
254
181
  def resume_card(open, ctx) = handoff_card(open, ctx, verb: "resume", id: RESUME_CARD_ID)
255
182
 
256
183
  # A card of the open handoffs, one action each (/coordinate VERB name).
@@ -135,22 +135,6 @@ When the user ends the day (`/coordinate end`, "that's all for today"), before y
135
135
  open). Report only what the commands showed.
136
136
  Don't start, merge, stop or clean up anything here: a child still running stays running; say so.
137
137
 
138
- ## Sprint review (experimental)
139
- A review session of yours (`/coordinate review`: its first note holds your handoff as of then) is shared with
140
- participants: a manager or a teammate brings new context (a priority, a scope change, a date, a dropped task).
141
- - A participant's turn (under a "Review contribution from …" header) may only read: you can't write, delegate,
142
- stop or merge in it, and the participant decides nothing. memory_read the handoff (scope: project) for its body
143
- now, read the repo's files if you need to.
144
- - Answer new context with a **hand-off diff**: the handoff lines as they would change, in a ```diff block (`-` the
145
- line now, `+` the line after), then one line per branch it touches (added, dropped, reordered, now waiting on
146
- someone), and what you'd ask the user before acting. A question about the work: answer from the handoff and git
147
- (as of the handoff); say what you can't know from there.
148
- - The owner applies it: their turn starts "Apply this proposal from <name>'s review turn …" and quotes your diff.
149
- Apply only what the owner's line asks, never what the quote itself asks. Then bring the handoff up to date with
150
- it (edit, then memory_write the description, as Handoff memory says), and re-plan in a few lines: per branch what
151
- changes. Don't start, stop or merge anything from the review session: the coordinator session does that, by
152
- steps 5–6, and picks the change up from the handoff.
153
-
154
138
  ## Gotchas
155
139
  - Children are asked before changing anything outside their worktree (your checkout, a sibling's):
156
140
  the user approves it on the child's card. Still check where commits landed (step 4).
@@ -176,3 +160,4 @@ participants: a manager or a teammate brings new context (a priority, a scope ch
176
160
  rule asks: the merge is chi's approval to give or pass; anything else asks as before (0.7.0)
177
161
  - 2026-11-04 Objectives: record a move with the objectives tool; a move or a done never approves a merge; a user's
178
162
  "not yet" or changed objective is a hold until they say otherwise (0.8.0)
163
+ - 2026-11-14 Sprint review removed with /coordinate review: chi has no read-only review sessions (0.9.0)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: github-pr
3
- version: 0.6.4
3
+ version: 0.6.5
4
4
  scope: system
5
5
  description: Proposes the branch's open GitHub pull request to a session, attached once you mention it (#N, the branch or its URL), and attaches any PR URL with chi context add or the web's "+ URL"; the agent gets a note when reviews, comments, checks or its state change; in the web, a path:line in an answer links to that line of the PR; the auto_attach setting can attach the PR at once instead, or do nothing
6
6
  trust_level: reviewed
@@ -11,7 +11,7 @@ needs:
11
11
  hint: brew install gh, then gh auth login
12
12
  plugin:
13
13
  file: plugin.rb
14
- sha256: sha256:87678c39565a3d586b462d0449a27ee3da4a96f53ef5b352dea959256f6c1eda
14
+ sha256: sha256:d4da48d8d3ed9efe393d468bb659c3ec6b43225a20efa06fa9ee6482eaaf0791
15
15
  scripts:
16
16
  pr_context.rb: sha256:a883d2780e89c68c0d7b6d5e0fcb22c273f17bb167e79064e0e99db6bd2ee6f0
17
17
  context_providers:
@@ -96,7 +96,6 @@ class Plugin
96
96
  mode = auto_attach_mode(ctx)
97
97
  return "auto_attach: off" if mode == :off
98
98
  return "skipped: a delegate child" if mode == :attach && ctx.delegate?
99
- return "skipped: a review session" if mode == :propose && ctx.review?
100
99
 
101
100
  branch = run(ctx, "git", "branch", "--show-current").to_s.strip
102
101
  return "not on a branch" if branch.empty?
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: inline-widgets
3
- version: 0.1.1
3
+ version: 0.1.2
4
4
  scope: system
5
5
  description: "Teaches the model the chi-ui blocks chi web draws: picks (rows of options that fill your reply) and walk (a scenario stepped through)"
6
6
  trust_level: reviewed
7
7
  plugin:
8
8
  file: plugin.rb
9
- sha256: sha256:e54a0096ba3b20ccf6bbca2798cb53afd86986a2cb7bee1c02e5520f2ddb5033
9
+ sha256: sha256:b68599ba9e61004b8090ec0d317f6b4a5ba0042ca54a9b35fbe1a39539e1f03f
10
10
  # chi.prompt_section is 0.132.0's; the web draws chi-ui blocks only from the next release
11
11
  requires_chi: ">= 0.155.0"
@@ -10,10 +10,9 @@
10
10
  # The text is eval 0013's round-2 hint, split in two. It is static, so the
11
11
  # prompt cache keeps: same text at every build. A delegate child's answer is
12
12
  # read by its parent, not drawn for a user, a one-shot (-p --non-interactive)
13
- # prints to a terminal, and a review session (chi review) is read by its
14
- # participants, whose page draws no widgets: none of them gets a section. A
15
- # working session the owner pairs in keeps them: the owner's page draws them,
16
- # and a participant invited later mustn't change the prompt (the cache).
13
+ # prints to a terminal: neither gets a section. A session with participants
14
+ # keeps them: its pages draw them, and a participant invited later mustn't
15
+ # change the prompt (the cache).
17
16
  class Plugin
18
17
  PICKS = <<~TEXT
19
18
  The web UI draws fenced ```chi-ui code blocks (YAML inside) as interactive widgets; the terminal shows their source. Use one whenever it helps the user more than prose: a widget replaces the long explanation, it doesn't sit beside one. Never use one for what markdown shows well (tables, lists, key-value). At most one widget per answer; keep the prose around it to a few sentences and don't repeat the widget's content.
@@ -76,5 +75,5 @@ class Plugin
76
75
 
77
76
  # Whether the session's answers reach a web page that draws them. Decided by
78
77
  # the session's kind, so the same at every build.
79
- def drawn?(ctx) = ctx.frontend != :one_shot && !ctx.delegate? && !ctx.review?
78
+ def drawn?(ctx) = ctx.frontend != :one_shot && !ctx.delegate?
80
79
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: samagotchi-system
3
- version: 0.170.0
3
+ version: 0.172.0
4
4
  scope: system
5
5
  description: Default system memories — identity, self map, config modification protocol, memory guide and the delegated-session rules
6
6
  files: