samagotchi 0.183.0 → 0.185.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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +84 -1
  3. data/docs/architecture.md +12 -11
  4. data/docs/bundles.md +63 -36
  5. data/docs/cli.md +10 -1
  6. data/docs/configuration.md +3 -2
  7. data/docs/context.md +76 -10
  8. data/docs/guardrails.md +7 -2
  9. data/docs/hooks.md +1 -0
  10. data/docs/internals/block-renderers.md +4 -2
  11. data/docs/internals/bridge.md +7 -3
  12. data/docs/internals/bundles.md +6 -2
  13. data/docs/internals/engine.md +2 -1
  14. data/docs/internals/llm-context-forget.md +6 -0
  15. data/docs/internals/participants.md +5 -2
  16. data/docs/internals/prompt-caching.md +8 -1
  17. data/docs/internals/remote-sessions.md +22 -4
  18. data/docs/internals/session-lifecycle.md +1 -1
  19. data/docs/internals/web-frontend.md +37 -15
  20. data/docs/internals/web-push.md +11 -0
  21. data/docs/internals/working-set.md +238 -6
  22. data/docs/mcp-server.md +11 -3
  23. data/docs/memory.md +2 -1
  24. data/docs/plugins.md +6 -6
  25. data/docs/scheduling.md +19 -0
  26. data/docs/sessions.md +13 -3
  27. data/docs/sub-agent.md +48 -3
  28. data/docs/thin-clients.md +38 -12
  29. data/lib/samagotchi/agent_caller.rb +97 -0
  30. data/lib/samagotchi/bridge.rb +7 -7
  31. data/lib/samagotchi/bridge_client.rb +12 -4
  32. data/lib/samagotchi/bundle_command/check.rb +20 -2
  33. data/lib/samagotchi/bundle_manifest.rb +5 -1
  34. data/lib/samagotchi/bundles/claude-peer/manifest.yml +14 -8
  35. data/lib/samagotchi/bundles/claude-peer/plugin.rb +3 -3
  36. data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +49 -30
  37. data/lib/samagotchi/bundles/claude-peer/scripts/pair +2 -2
  38. data/lib/samagotchi/bundles/claude-peer/scripts/pair-remote +123 -0
  39. data/lib/samagotchi/bundles/claude-peer/skill_claude_peer.md +11 -3
  40. data/lib/samagotchi/bundles/codex-peer/manifest.yml +10 -8
  41. data/lib/samagotchi/bundles/codex-peer/plugin.rb +3 -3
  42. data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +29 -8
  43. data/lib/samagotchi/bundles/codex-peer/scripts/pair +1 -1
  44. data/lib/samagotchi/bundles/codex-peer/skill_codex_peer.md +11 -3
  45. data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
  46. data/lib/samagotchi/bundles/mcp/http_client.rb +96 -54
  47. data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
  48. data/lib/samagotchi/bundles/system/manifest.yml +2 -2
  49. data/lib/samagotchi/bundles/system/self_map.md +9 -2
  50. data/lib/samagotchi/client_id.rb +61 -1
  51. data/lib/samagotchi/command_intake.rb +16 -8
  52. data/lib/samagotchi/context_absorber.rb +212 -46
  53. data/lib/samagotchi/delivery.rb +15 -0
  54. data/lib/samagotchi/driver_command.rb +68 -0
  55. data/lib/samagotchi/engine/block_fix.rb +2 -2
  56. data/lib/samagotchi/engine/session.rb +14 -6
  57. data/lib/samagotchi/engine/turn_helpers.rb +4 -3
  58. data/lib/samagotchi/engine.rb +13 -5
  59. data/lib/samagotchi/engine_peers.rb +6 -0
  60. data/lib/samagotchi/guardrails/pair_boundary.rb +1 -1
  61. data/lib/samagotchi/mcp_command.rb +7 -2
  62. data/lib/samagotchi/mcp_server/http.rb +3 -3
  63. data/lib/samagotchi/mcp_server/protocol.rb +23 -4
  64. data/lib/samagotchi/mcp_server/stdio.rb +1 -0
  65. data/lib/samagotchi/mcp_server/tools.rb +11 -4
  66. data/lib/samagotchi/model_notes.rb +34 -12
  67. data/lib/samagotchi/objectives_track.rb +2 -1
  68. data/lib/samagotchi/owner_prompt.rb +5 -1
  69. data/lib/samagotchi/parent_report.rb +9 -5
  70. data/lib/samagotchi/plugin/peer.rb +10 -4
  71. data/lib/samagotchi/prompt_files.rb +11 -4
  72. data/lib/samagotchi/prompt_layout.rb +88 -0
  73. data/lib/samagotchi/prompt_part.rb +82 -20
  74. data/lib/samagotchi/reply_wait.rb +16 -4
  75. data/lib/samagotchi/schedule_command.rb +18 -4
  76. data/lib/samagotchi/schedules.rb +49 -14
  77. data/lib/samagotchi/send_command/parent_gate.rb +3 -1
  78. data/lib/samagotchi/send_command.rb +45 -8
  79. data/lib/samagotchi/session.rb +9 -1
  80. data/lib/samagotchi/session_access/ask.rb +58 -14
  81. data/lib/samagotchi/session_access/contract.rb +2 -0
  82. data/lib/samagotchi/session_access/exchange.rb +5 -2
  83. data/lib/samagotchi/session_access/local.rb +13 -3
  84. data/lib/samagotchi/session_access/remote.rb +18 -2
  85. data/lib/samagotchi/session_access.rb +4 -2
  86. data/lib/samagotchi/session_command_catalog.rb +8 -0
  87. data/lib/samagotchi/session_commands.rb +9 -0
  88. data/lib/samagotchi/session_continue.rb +4 -1
  89. data/lib/samagotchi/session_inbox.rb +17 -0
  90. data/lib/samagotchi/session_inbox_delivery.rb +4 -2
  91. data/lib/samagotchi/session_manager/delivery.rb +58 -9
  92. data/lib/samagotchi/session_manager/spawn.rb +7 -1
  93. data/lib/samagotchi/steer.rb +95 -20
  94. data/lib/samagotchi/system_prompt.rb +196 -161
  95. data/lib/samagotchi/terminal_ui/formatting.rb +12 -2
  96. data/lib/samagotchi/tool_activity.rb +4 -0
  97. data/lib/samagotchi/tool_declarations.rb +22 -1
  98. data/lib/samagotchi/tool_names.rb +4 -0
  99. data/lib/samagotchi/toolkit.rb +3 -2
  100. data/lib/samagotchi/tools/ask_session.rb +208 -0
  101. data/lib/samagotchi/tools/builtin_calls.rb +1 -0
  102. data/lib/samagotchi/tools/builtins.rb +5 -0
  103. data/lib/samagotchi/tools/memory.rb +11 -3
  104. data/lib/samagotchi/turn_checkpoint.rb +19 -2
  105. data/lib/samagotchi/turn_stages/context_judge.rb +3 -1
  106. data/lib/samagotchi/turn_stages/objectives.rb +4 -2
  107. data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +3 -0
  108. data/lib/samagotchi/turn_stages/warmup.rb +2 -2
  109. data/lib/samagotchi/version.rb +1 -1
  110. data/lib/samagotchi/visitor.rb +37 -0
  111. data/lib/samagotchi/web/app.rb +2 -3
  112. data/lib/samagotchi/web/ask_routes.rb +95 -23
  113. data/lib/samagotchi/web/mcp_route.rb +7 -4
  114. data/lib/samagotchi/web/message_display.rb +15 -2
  115. data/lib/samagotchi/web/public/app.js +1 -1
  116. data/lib/samagotchi/web/public/block_fix.js +11 -3
  117. data/lib/samagotchi/web/public/delete_sheet.js +20 -18
  118. data/lib/samagotchi/web/public/history_shape.js +3 -1
  119. data/lib/samagotchi/web/public/index.html +8 -0
  120. data/lib/samagotchi/web/public/peer_links.js +27 -4
  121. data/lib/samagotchi/web/public/peer_note.js +19 -3
  122. data/lib/samagotchi/web/public/peer_text.js +45 -0
  123. data/lib/samagotchi/web/public/picture_regions.js +2 -2
  124. data/lib/samagotchi/web/public/removal_sheet_model.js +3 -4
  125. data/lib/samagotchi/web/public/running_tasks.js +0 -16
  126. data/lib/samagotchi/web/public/session_actions.js +0 -9
  127. data/lib/samagotchi/web/public/turn_events.js +19 -0
  128. data/lib/samagotchi/web/public/working_set_view.js +178 -23
  129. data/lib/samagotchi/web/public/ws_part_peek.js +277 -0
  130. data/lib/samagotchi/web/public/ws_peek.js +3 -1
  131. data/lib/samagotchi/web/public/ws_preview.css +30 -0
  132. data/lib/samagotchi/web/public/ws_reader.js +7 -3
  133. data/lib/samagotchi/web/public/ws_sections.js +37 -7
  134. data/lib/samagotchi/web/push/notifier.rb +33 -6
  135. data/lib/samagotchi/web/server.rb +1 -1
  136. data/lib/samagotchi/web/session_control.rb +1 -1
  137. data/lib/samagotchi/web/session_create.rb +11 -7
  138. data/lib/samagotchi/web/session_hub.rb +26 -4
  139. data/lib/samagotchi/web/working_set_routes.rb +93 -5
  140. data/lib/samagotchi/worker/command_queue.rb +5 -2
  141. data/lib/samagotchi/worker/senders.rb +79 -0
  142. data/lib/samagotchi/worker.rb +21 -18
  143. data/lib/samagotchi/worker_inbound.rb +12 -4
  144. data/lib/samagotchi/worker_link.rb +2 -2
  145. data/lib/samagotchi/worker_participant_gate.rb +1 -3
  146. data/lib/samagotchi/worker_wakes.rb +12 -0
  147. data/lib/samagotchi/working_set.rb +162 -90
  148. data/lib/samagotchi/working_set_locator.rb +221 -0
  149. data/lib/samagotchi/working_set_own_changes.rb +221 -0
  150. data/lib/samagotchi/working_set_part.rb +281 -0
  151. metadata +13 -1
@@ -27,7 +27,7 @@ rescues its own errors: an observer must never break the running turn.
27
27
  | `CardStore` | `card_store.rb` | The last cards and notices, saved in `cards.json`, each anchored to its turn. |
28
28
  | `TurnDrawings` | `turn_drawings.rb` | Each finished turn as live drew it (`turn_drawings.jsonl`): written by the accumulator's `on_turn_end` hook, read by chi web's show. |
29
29
  | `CardPlaces` | `card_places.rb` | Pure: where `CardStore`'s entries sit in the messages the page draws (`turns_since`, and the `opening_id` stamp). |
30
- | `PendingCard` | `pending_card.rb` | `pending_card.json` `{id:, bundle:}`: the running turn's open card with actions (check-in's Nudge), written and removed with that card, so chi web's hub, which watches files and not workers, can notify. |
30
+ | `PendingCard` | `pending_card.rb` | `pending_card.json` `{id:, bundle:}`: the running turn's open card with command actions (check-in's Nudge); a URL-only card does not ask (`CardWait`), so it writes no pending card, and it is removed with the card, for chi web's file-watching hub. |
31
31
 
32
32
  Per connection there is an `SSEWriter` (with a `BoundedQueue`); `ClientEvent` and `EventId` are pure helpers. The
33
33
  Bridge also owns its **epoch** (`SecureRandom.hex(4)`: `event_seq` starts over in each worker, so the epoch says
@@ -480,8 +480,10 @@ The Bridge exposes:
480
480
  `/continue`) for the worker loop (`{line, client_id, card?, deadline?}`); `202` with a `command_id` its
481
481
  `:command_ran` names, `400` when the line isn't one. `client_id` is required: without one (or a blank one) `400
482
482
  missing_client_id` (`Bridge::UNNAMED_COMMAND`); from a sender that may not send commands (`CommandIntake.allowed?`:
483
- only the owner's senders, `web:`, `tui:`, `cli:send`, and chi answer's `cli:answer`) `403 command_not_permitted`, its
484
- detail `CommandIntake::COMMAND_REFUSED` (`CommandIntake::REFUSED` for a `!` line), nothing queued. A `:command_ran`'s `output` is the command's, up to `Worker::CommandQueuePart::COMMAND_OUTPUT_LIMIT` (64 KiB of chars; past it
483
+ only the owner's senders, `web:`, `tui:`, `cli:send`, an agent's `agent:`, and chi answer's `cli:answer`), or a `!`
484
+ line from an agent (`CommandIntake.refused?`, asked first, as at `POST /turn` and `WorkerInbound#queue_as_command`)
485
+ `403 command_not_permitted`, its detail `CommandIntake::COMMAND_REFUSED` (`CommandIntake::REFUSED` for a `!` line),
486
+ nothing queued. A `:command_ran`'s `output` is the command's, up to `Worker::CommandQueuePart::COMMAND_OUTPUT_LIMIT` (64 KiB of chars; past it
485
487
  the text ends with a `[cut: N of M chars: …]` line, which the UIs print as they print the rest). It carries `thinking`, `reasoning_history` and `llm_context`
486
488
  (the summaries the next turn runs under) when the command changed them or the model, and
487
489
  `confirm: {line, text}` when a `/thinking` or `/reasoning-history` change from a `web:` or `tui:`
@@ -685,6 +687,8 @@ compatibility from its version. `Bridge::FEATURES` advertises:
685
687
  | `participant_client_id` | chi web can identify a participant as `participant:<id>` instead of using the legacy `review:<id>`. |
686
688
  | `block_fix` | `POST /session/:id/blocks/fix` asks again for a block the page couldn't draw; the owner's page without it says "restart this session to fix". |
687
689
  | `working_set_item` | `GET /session/:id/working_set/item` answers one item's timeline (the running turn's mid-turn), so chi web asks for it instead of the whole snapshot. |
690
+ | `agent_sender` | The worker reads an agent's id (`agent:<name>`: a driver's or a visitor's turn, `Visitor`). Without it `SessionManager#deliver_turn_now` sends `cli:send` instead (compat shim agent_client_id), also on the file path while a worker holds the session; chi web lists it in `/api/info` too, for `SessionAccess::Remote#sent_id`. |
691
+ | `ask_session` | The worker runs another session's question (`session:<id8>`) as a visitor's turn. Without it the question is refused (409 `ask_unavailable`), and its file is not written while a worker may hold the session. |
688
692
 
689
693
  `chi web`'s `GET /api/sessions/:id/stream` proxies this bridge
690
694
  (503 `not_live` for no worker, a leaving or stuck worker, or an unreachable Bridge; 502 `worker_newer` for skew and
@@ -142,7 +142,7 @@ one ordered list (parts as listed, then the file; nothing sorts it: not the pars
142
142
  builder). The record keeps them under its plugin, `{"file": …, "sha256": …, "parts": {"client.rb": "sha256:…"}}`
143
143
  (`PluginRef#parts`, `{}` without; `Record#plugin_shas` has every file, so `AssetInstaller`, the `Uninstaller` and
144
144
  `ShippedUpdate#trash_bound` treat parts as recorded files), each with a base at `bases/plugin/<part>`.
145
- `BundleManifest::SINCE` has `"plugin.parts"` (the Unreleased comment until `release:bump`). What other chis do:
145
+ `BundleManifest::SINCE` has `"plugin.parts"` (0.183.0). What other chis do:
146
146
  - The previous release ignores `parts:` in a manifest and in a record. It installs a too-new plugin with only a
147
147
  warning, copying the plugin file alone; after `chi update` this chi refuses that record: `Dir#plugin_refusal`'s
148
148
  `:parts_missing` (`bundle X's plugin parts aren't installed (reinstall the bundle)`, status `[parts missing]`), read
@@ -251,7 +251,11 @@ summarised by `#summary` by word: a file that already holds the bundle's bytes (
251
251
  rule/plugin/script, in a dry run as in the real run) is listed as `Up to date:`, and only the files really left
252
252
  out (`:kept_own`, a memory's dry-run `:would_skip`) as `Skipped:`. A memory's dry-run word is its action's through
253
253
  `Installer::DRY_WORDS`. A dry run's `would_update` (a plugin or script an upgrade would change) is `Would update:`; an asset
254
- row is never `would_skip`. A plain install over a bundle already installed from the same source ends with `NAME was already
254
+ row is never `would_skip`.
255
+ `BundleCommand#version_line` heads the summary. It reads the old version from the installed record before the run and
256
+ the new one from the manifest: `NAME OLD → NEW` for a change, `NAME VER` otherwise, or `NAME VER (already current)` when
257
+ nothing changed and `Installer#current?` is true. In that case `Installer#summary(current: true)` leaves out `Up to date:`.
258
+ A plain install over a bundle already installed from the same source ends with `NAME was already
255
259
  installed from SOURCE: its rules, plugin and scripts now match it and its record was rewritten`, plus
256
260
  `; your own copies of its memories were kept (chi bundle upgrade NAME merges the bundle's changes into them)` when
257
261
  a memory was left out as the user's (`:kept_own`: an edited one, or one the bundle doesn't own; a never-edited one takes the new text and isn't named there). An upgrade with conflicts keeps an
@@ -784,7 +784,7 @@ are in [architecture.md](../architecture.md)'s file table.
784
784
  | `engine/models.rb` | `Engine::ModelsPart`: model names, identity, notes, `switch_model!`, the profile, `backend` |
785
785
  | `engine/model_settings.rb` | `Engine::ModelSettingsPart`: SessionModelSettings and EngineSnapshots, forwarded |
786
786
  | `engine/events.rb` | `Engine::EventsPart`: observers, `#announce`, the event lock, held announcements |
787
- | `engine/cards.rb` | `Engine::CardsPart`: `#show_card`, anytime commands |
787
+ | `engine/cards.rb` | `Engine::CardsPart`: `#show_card` (and `between_turns:`), anytime commands |
788
788
  | `engine/objectives.rb` | `Engine::ObjectivesPart`: the objectives stage's builder and forwards (`announce_objectives`, `show_objective_proposals`, `track_objectives_after`), Check this's and the tracker's side requests (`ask_objective_check`, `ask_objective_track`) |
789
789
  | `engine/messages.rb` | `Engine::MessagesPart`: out-of-turn message edits, checkpoints, the live conversation |
790
790
  | `engine/plugins.rb` | `Engine::PluginsPart`: plugins, init tasks, staged tools, `Plugin::Host` |
@@ -794,6 +794,7 @@ are in [architecture.md](../architecture.md)'s file table.
794
794
  | `engine/session.rb` | `Engine::SessionPart`: `#session=`, the state dir, the relay's view, the system prompt |
795
795
  | `engine/verify.rb` | `Engine::VerifyPart`: the Verify/Revise anchors' stage builder |
796
796
  | `engine/questions.rb` | `Engine::QuestionsPart`: ask-user-question (QuestionDesk, forwarded: the hosts hold `Engine#question_desk`; the forwards stay for the Engine's parts, the one-shot and Engine-only specs) |
797
+ | `engine/sign_in.rb` | `Engine::SignInPart`: `ctx.sign_in` flows and cards, `/callback`, and ending flows at shutdown (idle exit waits for a waiting flow) |
797
798
  | `engine/toolkit.rb` | `Engine::ToolkitPart`: the toolkit, `ctx.load_tools`, the toolkit suggestion's builder |
798
799
  | `engine/context_judge.rb` | `Engine::ContextJudgePart`: the candidate judge's builder and `judge_late_candidates` |
799
800
  | `engine/turn_helpers.rb` | `Engine::TurnHelpersPart`: turn settings, images, model ref, used memories, the warm-up's builder |
@@ -73,3 +73,9 @@ lets the model forget its own tool outputs. The pieces:
73
73
  - **Persistence**: the edits ride on the entries (plan D3), so `--resume`, rollbacks and forks keep the stubs and the
74
74
  restores; `/stats` counts each applied batch's re-prefill.
75
75
  - **Measuring**: the bench's `forget_outputs` strategy (internals/llm-context-bench.md).
76
+ - **A peer's note text is history, not a tool output.** A peer agent's answer comes with its text in its context
77
+ note (`ContextAbsorber.peer_block`, [context.md](../context.md#peer-sources-the-peer-loop)), so the model needs no
78
+ `context_read` for it. No layer stubs a note: neither `forget` nor `stale` acts on it, and it stays for the
79
+ session's life. Before, the text came as a `context_read` result that `forget_outputs` could drop (`stale` never
80
+ covered it). The caps bound it: a waking answer holds up to the tool output cap, one that doesn't wake up to 2,000
81
+ characters (`ContextAbsorber::PEER_HELD_CHARS`), and a longer one is still a `context_read` (forgettable as ever).
@@ -201,7 +201,7 @@ row answers another session's id 404, so a new route is covered without a new ex
201
201
  | `POST /api/sessions/:id/turn/:eid/dequeue` | participant | their own queued turn back; another's (the owner's included) is 403 `not_permitted` |
202
202
  | `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)) |
203
203
  | `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) |
204
- | `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 |
204
+ | `POST /api/sessions/:id/wait/prepare`, `…/wait` | participant | only for a turn of theirs (`turn`: the enqueued id `POST …/turn` answered; else 403); a wait token (`{token}`) is the owner's: a participant's token wait is 400 `invalid_wait` (`a participant's wait takes a turn, not a token`); `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 |
205
205
  | `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 |
206
206
  | `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) |
207
207
  | `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 |
@@ -839,7 +839,10 @@ means the owner: a turn or session with no author keys reads as the owner's and
839
839
  when nothing is left), so a name can't close it. The header always comes first, so text under it stays the
840
840
  participant's. A line of their text that opens like one of chi's headers (a review contribution, a steer, automatic
841
841
  input, a delegate report) goes out led by `(quoted) ` (`Steer.quote_forged_headers`, wire-only and deterministic),
842
- so it reads as their text under the real header. The session file never holds the header or the quote mark.
842
+ so it reads as their text under the real header. A line starts after any break a model reads as one
843
+ (`Steer::FORGED_BREAKS`), and spaces, format characters and markdown leads may come before the bracket
844
+ (`Steer::FORGED_LEAD`, the one shape `Steer.forged_frames` builds for every forged-frame match). Widening that
845
+ shape changed the wire bytes once for an older text with such a line (a one-time cache miss on its replay). The session file never holds the header or the quote mark.
843
846
  - **The system-prompt line.** While the session has an active participant (`participants.json`, read by the
844
847
  worker's Engine at each turn's start), the system prompt's volatile tail opens with "Participants: teammates the
845
848
  owner invited work in this session too. …" (`SystemPrompt::PARTICIPANTS_LINE`), which names the pair header (and the
@@ -65,7 +65,14 @@ right-hand column happens.
65
65
 
66
66
  - The sections above are recorded as `prompt_parts` (`SystemPrompt#prompt_parts`, `PromptPart`: kind, label, chars,
67
67
  tokens at `TokenUsage::CHARS_PER_TOKEN`, ref, a memory part's scope; one per memory, file and plugin section, plus a
68
- `tools` part): sizes only, worked out once with the build and saved on the session; the prompt's text is unchanged.
68
+ `tools` part): sizes, and each part's place in the built prompt (`at`, `len`, `lead`, a 12-hex `digest` of its own
69
+ text, the prompt's 16-hex `head` digest, `params` to fetch it again), worked out once with the build
70
+ (`PromptLayout`) and saved on the session; the prompt's text is unchanged. Each builder returns its `Section` with
71
+ its `Item`s (lead and text) where it renders them; the parts derive from the items, so their places can't drift
72
+ from the bytes. `spec/prompt_parts_spec.rb` holds today's parts to a golden and every slice to its item. The text
73
+ itself is not copied: the head is the session's `messages[0]`, which a part's place points into
74
+ ([working-set.md](working-set.md#prompt-parts-as-sent)). `Engine#system_prompt` reads prompt, parts, notes and
75
+ index from the one `Built` (`SystemPrompt#built_for`), and the turn-end warm-up builds with `record: false`.
69
76
  - The system prompt is built **once per key** and kept (`SystemPrompt#build`, keyed by `[chat, thinking, layers]`:
70
77
  the loop, the thinking level, the turn's LLM context layers; a `/thinking` change builds under another key). All
71
78
  of them are dropped only on `@prompt_builder.reset!`: a model switch (`Engine#switch_model!`), a plugin's
@@ -90,11 +90,27 @@ specs' stubs); `CLI::ParentWait` (chi send's and chi answer's wait) calls `wait`
90
90
  (`session_access/ask.rb`) is its own short loop over the same pieces for one message and one wait slice on one
91
91
  deadline (chi web's starts with the request: `locate`'s `deadline:` and `relocate`'s `bounded: true` end the continue
92
92
  waits `Ask::MIN_SLICE` before it, a continue that takes the link after it gets no second delivery, and the Bridge wait
93
- of a worker starting draws on it too; chi web stopping cuts the continue waits at the next look, `Refused :canceled`,
93
+ of a worker starting draws on it too, as does the post to a live worker: `AskRoutes#ask_bridge`, used by `POST …/ask`
94
+ and `POST /api/mcp` (one deadline per POST, `Tools::CAP`), gives the BridgeClient a read of what is left but
95
+ `MIN_SLICE`, within `POST_FLOOR` (8 s, so a loaded worker still reads it) and `READ_TIMEOUT`; the body's `deadline`
96
+ is a `DEADLINE_SHARE` of that read and at least `POST_MARGIN` (2.5 s) short of it (BridgeClient's `deadline_margin`,
97
+ so a worker that took the turn just in time still answers its 202 before the client gives up), so a worker that reads the turn late drops it (408 `deadline_passed`, the route's
98
+ 504 `worker_timeout`) rather than run it after the call gave up: about 44 s at worst; chi web stopping cuts the continue waits at the next look, `Refused :canceled`,
94
99
  503 `server_stopping`; a client that goes away is not seen (WEBrick), so its handler runs on to that deadline),
95
- answering `Reply` (with an `Exchange::Token` on timeout), `Ran` or `Refused`: chi web's `POST …/ask`
100
+ answering `Reply` (with an `Exchange::Token` on timeout), `Ran` or `Refused` (a `/continue yes` the worker ran as a
101
+ command, on an idle session with its offer standing and a live worker, is bound with `ReplyWait::Target.answer(start)`
102
+ instead, the offer's turn id from `ReplyWait.own_turn`, as chi answer follows it; the worker's ack is not read): chi web's `POST …/ask`
96
103
  builds one per request over a `Local` that delivers through chi web's own manager and Bridge (`Web::AskRoutes::
97
- AskAccess`), and plan 2's MCP server reuses it without chi web. The routes: [thin-clients.md](../thin-clients.md).
104
+ AskAccess`), and `McpServer::Tools` reuses `SessionAccess::Ask` / `Exchange` through the MCP server without chi web.
105
+ An ask's `request_id` becomes its turn's enqueued id (`SessionInbox.enqueued_id_for("ask:" + it)`, a UUID v5 shape a
106
+ Bridge keeps): `Ask#call` first reads `prepare_wait(turn: E)`, and a `known_turn` (running, a queued input file, the
107
+ last to end, a reply file, settled, merged) is waited on again with `Target.wait_only(start, requested: E).with(queued:)`, nothing
108
+ sent (`Reply#rebound`, so the route skips the history line), unless E only waits as an input file and no worker runs
109
+ (`Local#waiting_turn?`): then it is sent again with E, which wakes one (the worker runs an id once: `input_taken?`,
110
+ `TurnState#claim_enqueued_id`); else `Exchange#attempt(enqueued_id: E)` carries it to
111
+ `deliver_turn`, and the Bridge's H6 dedupe answers a copy it still remembers with the original ack (409
112
+ `enqueued_id_conflict` for another prompt; a known turn is rebound without a prompt check). A retry on a newer link (a continue) is not deduped.
113
+ The routes: [thin-clients.md](../thin-clients.md); the MCP protocol: [mcp-server.md](../mcp-server.md).
98
114
 
99
115
  ## One request, end to end
100
116
 
@@ -281,7 +297,9 @@ with a "Machine-local" comment; the rest branch on `@access.remote?` (`SendComma
281
297
  `cross_site?` lets CLI clients through because they send no `Origin` or `Sec-Fetch-Site`.
282
298
  - **`client_id` only tightens.** `handle_question_answer` (`Web::SessionControl`) forwards `client_id` only when it is `ClientId::CLI_ANSWER`
283
299
  and drops any other value, so a remote answer is held to the parent rules and can't pass for the user's own. On
284
- create and turn, a `cli:send` / `cli:answer` id adds checks (`CLI_SEND_IDS`) and never removes any.
300
+ create and turn, a `cli:send` / `cli:answer` / `agent:` id adds checks (`ClientId.parent_line?`) and never removes
301
+ any. An agent's id goes to a chi web without `agent_sender` in its `/api/info` features as `cli:send`
302
+ (`Remote#sent_id`, compat shim agent_client_id), for a turn and a create.
285
303
  - **A remote attach's `client_id`** (`tui:<pid>@<host>`, P4-D6) is forwarded as given on `/turn` and `/command`, as
286
304
  the page's is: the token is the owner. Only the cli ids (`cli:send`, `cli:answer`) add checks there; a parent
287
305
  agent driving the TUI from a pipe answers as `cli:answer`, held to that machine's `guardrails.parent_answers`.
@@ -74,7 +74,7 @@ state. A cell is `:go`, `:wait` or the decider's own refusal reason; `SessionLif
74
74
  `:go`, `:wait` or `:refused` (resume's `live` and `starting` wait, restart's `fallback` goes).
75
75
 
76
76
  - **Delivery columns** (send, note, push, ring, fresh_verdict, leave, schedule, plugin, delegate, participant,
77
- automatic) are generated at load from `SessionInbox::WakePolicy::ROWS`, unchanged: each row's `decide` on
77
+ agent, automatic) are generated at load from `SessionInbox::WakePolicy::ROWS`, unchanged: each row's `decide` on
78
78
  `CANONICAL[state]` (a worker asked for, no scratch file), `:start`/`:live` as go, `:starting`/`:stopped`/
79
79
  `:archived`/`:none` as wait, `:gone`/`:owned`/`:deleting` as themselves. `:off` and `:scratch` are op-local.
80
80
  `deleting` refuses every kind: `WakePolicy#refusal` before the write (nothing written), `#decide` after it (a
@@ -32,13 +32,12 @@ page. A factory dep a new version stops passing is the same hazard the other way
32
32
  out of `send_turn.js`, `session_actions.js` and `lists_view.js`); a page loaded before keeps all its old modules
33
33
  until a reload, so the risk is a mixed cache, not an open tab. An export a new version stops importing stays until
34
34
  the next release (its baseline refresh) for the same reason, marked as kept for an older cached module (the delete
35
- sheet kept `isChained`, `format.js deleteConfirmText` and `running_tasks.js tasksConfirmText` that way; and, for the
36
- same release, the hooks 0.182.0's modules still call: `session_actions.js` passes `plain` and a `failed` that toasts
37
- when the sheet is gone, and gives archive's ask a `deletePlan` that rejects with the refusal, and `delete_sheet.js`'s
38
- `deleteToast` leaves out the stopped tasks the old `session_actions.js` adds itself; `delete_mixed_cache.test.js` loads
39
- each pair, the old file from `spec/web/public/fixtures/v0.182.0/`). `answer_fold.js`, `details_motion.js`,
35
+ sheet still keeps `isChained` and `format.js deleteConfirmText` that way; and `ws_peek.js`'s `PEEK_WIDTH`, which 0.183.0's
36
+ `working_set_view.js` imports though the view is 520 wide always now: `ws_part_peek_mixed_cache.test.js` loads this view
37
+ with 0.183.0's `ws_reader.js` and `ws_peek.js`, and 0.183.0's view with this `ws_reader.js`, from
38
+ `spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `details_motion.js`,
40
39
  `turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
41
- `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
40
+ `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
42
41
 
43
42
  ## One page, every viewer
44
43
 
@@ -423,7 +422,9 @@ it says what goes, what is stopped first and what stays, with one button that na
423
422
  A `409 plan_changed` and a `409 tasks_running` (a task that started since) both re-read the plan and show it with
424
423
  "What this deletes changed; check again." Any other refusal `runDeleteFlow` shows in the sheet (`refusalModel`: a
425
424
  moved delegate that can't go back offers "Stop its worker, then delete" only when the 409 says `stoppable`; it stops
426
- each, retries only once the stop answers `released`, and says so otherwise, never looping, one stop at a time).
425
+ each, retries only once the stop answers `released`, and says so otherwise, never looping, one stop at a time). While
426
+ it stops, the refusal view says `Stopping…` with the stop choice and Cancel off; if the sheet closes meanwhile, it
427
+ goes on with the delete and puts the delete toast or a sticky `failed` refusal in a toast.
427
428
  - **Archive** stays one tap and the Undo toast when nothing is in the way. Its 409 opens the same sheet
428
429
  (`session_actions.js setArchived` → `runDeleteFlow` with `archive: {refusal}`): `tasks_running` is
429
430
  `archiveSheetModel` (Hidden: it and the 409's `sessions` − 1 delegates; Stopped first: the tasks; `Stop them and
@@ -544,8 +545,10 @@ how it went); only the redraw is counted: an answer is read again at most once p
544
545
  (the route's 200 `fixed` or the event's), and a block failing after it says a fix didn't help. The stream's `block_fix` handler
545
546
  (`stream_handlers.js`, dep `blockFix`) hands the worker's word over: `fixed` re-reads that turn's answer (`getSession(id,
546
547
  {tail, turnId})`) and writes the bubble as `applyFinalAnswer` writes it, which can't find it by its old text; `failed`
547
- and `dropped` say a fix didn't help. A block is marked asked (`data-block-fix-asked`) before its POST, since the word can
548
- come before the 202 (a quick side answer); a 202 after it starts no give-up. No word within 60 s of a 202: the line
548
+ and `dropped` say a fix didn't help. Both 202 answers carry the block's key (`data-block-fix-key`); a keyed event settles
549
+ only that asked block, leaving another block's give-up timer running. A block is marked asked before its POST, since the
550
+ word can come before the 202 (a quick side answer); an event before the 202 or an older worker's keyless 202 keeps the
551
+ all-asked fallback for unkeyed blocks. A 202 after the word starts no give-up. No word within 60 s of a 202: the line
549
552
  gives up (today's words and Ask in chat);
550
553
  a session switch drops the timers. The line's words are `data-text` (CSS), Ask in chat a button whose label is CSS
551
554
  (`data-label`) with an `aria-label`, one delegated click listener per root; it fills the composer after the draft
@@ -793,9 +796,13 @@ What chi has of one working-set item ([working-set.md](working-set.md#timeline-w
793
796
  `ws_timeline.js` is the pure part (the server's events into cards newest first, reads merged by state, and between the same edits, into line
794
797
  slices, the file strip, the peek's pick, the step tags from the item's `runs`: working_set.js `itemsOfTurn` keeps each
795
798
  row's `tool_id` with its place), `ws_cards.js` the cards' templates (`diff_view.js` for diffs, `.read-line` for lines),
796
- `ws_peek.js` the popover's peek (one row at a time; working_set_view.js draws it under the row and grows the popover to
797
- `PEEK_WIDTH`, a phone's sheet to `SHEET_TALL`: `chip_popover.js` reads `width`/`sheetShare` as functions per
798
- placing), `ws_reader.js` the reader and the wiring (`createWorkingSetPreview`: the peek, the reader, `attach(workingSet)`
799
+ `ws_peek.js` the popover's peek (one row at a time; working_set_view.js draws it under the row; the popover is 520 wide
800
+ open or closed, so no row moves sideways, and a peek grows a phone's sheet to `SHEET_TALL`: `chip_popover.js` reads
801
+ `width`/`sheetShare` as functions per placing), `ws_part_peek.js` the "From the start" rows' prompt peek (the part
802
+ route's text as sent, the tools' names and sizes, a tab per hold with the item peek as a read's tab; one peek open at a
803
+ time across both; [working-set.md](working-set.md#prompt-parts-as-sent)), `ws_reader.js` the reader and the wiring
804
+ (`createWorkingSetPreview`: the peek, with the prompt peek as its `part` (no new export: a view without it, an older
805
+ cached one, draws today's rows), the reader, `attach(workingSet)`
799
806
  for the set, its jumps and its list, and `whatChiHas` for refs.js), `ws_way_in.js` a tool row's `timeline` button (a
800
807
  flag turn_html.js reads; on only once the reader is attached). State: the reader's own closure (the open item, its
801
808
  answer, the tab), never `store.current`. The reader is a `section` in `#center` over the history and the composer
@@ -833,7 +840,8 @@ conversation ([bundles.md](../bundles.md#the-claude-peer-bundle), In the web). T
833
840
  `peer_exchanges.jsonl`, the peers from its pushed sources) gives each peer's last exchanges, newest first, with their
834
841
  `state` (waiting, answered, none_expected, failed) and an answer's `serial` and `verdict`; a send row carries the
835
842
  send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `label`, `re`, `summary`, `serial`,
836
- `verdict`, `agreed`). The page joins and parses nothing.
843
+ `verdict`, `agreed`, and `inline` when the note's content holds the peer's text). The page joins nothing; the one
844
+ parse is `peer_text.js`'s cut of an `inline` note's text block.
837
845
 
838
846
  - `peer_data.js` (state): `listPeers` (an older chi web's 404 is an empty list) and `createPeers`, the page's one model
839
847
  of the open session's peers (app.js `peers`, made only with the `context` capability, so a participant's page has
@@ -851,7 +859,17 @@ send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `labe
851
859
  - `peer_note.js`: `peerNoteTemplate`, which `turn_html.js noteBubbleTemplate` draws a note with `peer` as. It keeps
852
860
  what an opening note has (`bubble note`, `turn-start`, `data-opening-id`, the time title), so `TURN_PROMPT`,
853
861
  `card_stamps.js`, `stage_handoff.js OPENING`, `reload_check.js` and `revise_stack.js` (its `.note-text` is the
854
- summary) read it as any wake note.
862
+ summary) read it as any wake note. With `peer.inline` the peer's text goes in `.peer-text` under the summary (an
863
+ element of its own, not a `data-peer-slot`, its source in `data-peer-md`): already as markdown when a history
864
+ read sent the note's `peer_html` (`MessageDisplay#peer_text_html`, `ContextAbsorber.peer_text_of`, rendered and
865
+ sanitized as an answer is), else as plain text (a live `context_added`, an older server), the "what chi told the
866
+ agent" fold shows the content without the block, and the bubble carries `data-peer-inline`. Without it (an older
867
+ session, an answer over the cap) the bubble draws as before.
868
+ - `peer_text.js` (pure): `peerBlock(content)` cuts the text out between the first `[PEER MESSAGE from …]` line and the
869
+ last `[END PEER MESSAGE]` line and undoes the absorber's `(quoted) ` mark on forged frame lines
870
+ (`PEER_FORGED_OPENINGS` and `PEER_FORGED_LINES`, the Ruby `ContextAbsorber`'s, and the same line breaks and leads
871
+ as `Steer::FORGED_BREAKS` / `FORGED_LEAD`: `peer_text.test.js` keeps the lists alike and undoes the Ruby specs' cases);
872
+ null without a block.
855
873
  - **The slot idiom.** Finished rows are never drawn again and a reload makes them anew, so what arrives later is
856
874
  drawn into empty slots the templates leave: a send row's `<span class="peer-slot" data-peer-ref>` after its params
857
875
  (`turn_html.js toolRowInnerTemplate`; the row's output line isn't drawn on a send that didn't fail, its text the
@@ -862,7 +880,11 @@ send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `labe
862
880
  sent" when its row failed, or once its turn has ended when its peer's list is under the server's cap of 20
863
881
  (`EXCHANGES_CAP`) or holds a send drawn before it; else it is unknown and gets no pill, as are the sends of a peer
864
882
  the read doesn't name), the ↑ into each answer (none for an answer no send claims) and "Read the full
865
- answer" into the last answer of each source only. Its one delegated click handler on the turn roots does the jumps,
883
+ answer" into the last answer of each source only, unless that bubble is `data-peer-inline` (its text is there). It
884
+ also swaps a plain inline bubble's `.peer-text` (not `.markdown`: one that came with `peer_html` asks nothing) for
885
+ its markdown (`renderMarkdown`, POST /api/render, sanitized there; an
886
+ optional factory dep, so a cached older app.js leaves the text plain), once per element; `history_shape.js` reads a
887
+ `[data-peer-md]` element as its source, so live and an offscreen reload compare alike. Its one delegated click handler on the turn roots does the jumps,
866
888
  buttons, never an `href` (the page routes by its hash): ↓ `revealInHistory` + `scrollIntoView` on the answer; ↑
867
889
  `refs.js showRow` on the last row of that id before the answer (its `ref:reveal` opens a folded step or the stage's
868
890
  cloud); focus moves to the target (`tabindex="-1"`). "Read the full answer" calls `context_chips.js showText(name)`,
@@ -186,6 +186,17 @@ from saying it twice across restarts). The key's `chi:` prefix keeps sw.js from
186
186
  | `updated` | `chi:updated:<X>` | "chi updated to X" / "chi web and 3 sessions restarted; 1 restarts when idle." + the edited files |
187
187
  | `restart_failed` | `chi:restart_failed:<X>` | "chi X is installed; chi web didn't restart" / why (a failed `--version` preflight, no wrapper), "Restart chi web in its terminal." |
188
188
 
189
+ **A disabled schedule's show.** `SessionHub#run_schedule_tick` emits one `schedule_disabled` hub event per
190
+ `Schedules::Outcome#disabled` of its tick (`#publish_disabled`, under `@monitor` like `publish_notice`): `{id, title,
191
+ kind: skipped|failed, count, reason, session_id, at}`, `session_id` being `Schedules#session_of` (the resolved
192
+ target, else the head) and `at` the tick's wall time. The page's event stream passes it to the tabs, which have no
193
+ listener. The Notifier shows it with reason `schedule`, key and tag `chi:schedule_disabled:<id>:<at>` (`chi:`: not
194
+ a waiting key; `<at>`: a later disable shows again; the same event twice shows once, `@updates_seen`), title
195
+ "Schedule disabled: <title or the id's first 8>", body "skipped 12 times: <reason>" + a line `chi schedule enable
196
+ <short id>`, url `Notifier.session_url` of the session's summary, `/` when it has none. Two exceptions to the rules
197
+ above: it is pushed with a page in front (`UNSEEN_ON_PAGE`: the page has no schedules view), and it gets
198
+ `UPDATE_TTL` (24 h) like an update. A cron tick or `chi schedule run-now` emits nothing (no hub).
199
+
189
200
  `updated` is sent by the **restarted** chi web (its AutoUpdate finds the run at `phase: web`): the exec ends the
190
201
  old process, and `Notifier#stop` does not flush the shows still in their hold, so a push queued just before it would
191
202
  be lost. Sending from the new process also proves it came up. The workers left then restart without another show.