samagotchi 0.192.0 → 0.193.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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -1
  3. data/docs/architecture.md +3 -3
  4. data/docs/bundles.md +45 -28
  5. data/docs/cli.md +22 -8
  6. data/docs/configuration.md +4 -3
  7. data/docs/context.md +8 -5
  8. data/docs/guardrails.md +9 -4
  9. data/docs/internals/bridge.md +3 -1
  10. data/docs/internals/bundles.md +2 -2
  11. data/docs/internals/pages.md +4 -4
  12. data/docs/internals/participants.md +5 -3
  13. data/docs/internals/peers.md +75 -22
  14. data/docs/internals/prompt-caching.md +2 -1
  15. data/docs/internals/remote-sessions.md +6 -0
  16. data/docs/internals/session-lifecycle.md +3 -2
  17. data/docs/internals/web-frontend.md +91 -19
  18. data/docs/internals/working-set.md +5 -1
  19. data/docs/peers.md +71 -22
  20. data/docs/plugins.md +7 -4
  21. data/docs/releasing.md +30 -2
  22. data/docs/scheduling.md +3 -2
  23. data/docs/sessions.md +1 -1
  24. data/docs/testing.md +35 -3
  25. data/docs/thin-clients.md +27 -11
  26. data/lib/samagotchi/bundles/claude-peer/manifest.yml +2 -2
  27. data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +33 -17
  28. data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
  29. data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +34 -17
  30. data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
  31. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
  32. data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
  33. data/lib/samagotchi/bundles/mcp/plugin.rb +0 -7
  34. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  35. data/lib/samagotchi/compat.rb +8 -1
  36. data/lib/samagotchi/config.rb +4 -0
  37. data/lib/samagotchi/continue_offer.rb +13 -1
  38. data/lib/samagotchi/delivery.rb +2 -2
  39. data/lib/samagotchi/engine/models.rb +17 -0
  40. data/lib/samagotchi/engine/plugins.rb +2 -0
  41. data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
  42. data/lib/samagotchi/jsonl_store.rb +13 -2
  43. data/lib/samagotchi/llm/anthropic_messages.rb +11 -0
  44. data/lib/samagotchi/llm/openai_chat.rb +5 -0
  45. data/lib/samagotchi/llm/prompt_cache.rb +5 -0
  46. data/lib/samagotchi/pages/launch.rb +1 -1
  47. data/lib/samagotchi/peer_cold.rb +92 -0
  48. data/lib/samagotchi/peer_command.rb +24 -9
  49. data/lib/samagotchi/peer_continue.rb +32 -16
  50. data/lib/samagotchi/peer_exchanges.rb +7 -0
  51. data/lib/samagotchi/peer_mailbox.rb +21 -4
  52. data/lib/samagotchi/peer_receipts.rb +33 -6
  53. data/lib/samagotchi/peer_say.rb +34 -16
  54. data/lib/samagotchi/plugin/api.rb +2 -1
  55. data/lib/samagotchi/plugin/context.rb +13 -1
  56. data/lib/samagotchi/plugin/peer.rb +118 -53
  57. data/lib/samagotchi/plugin/peers.rb +13 -6
  58. data/lib/samagotchi/session_access/local.rb +98 -37
  59. data/lib/samagotchi/session_access/remote_peers.rb +3 -3
  60. data/lib/samagotchi/session_chain/links.rb +8 -3
  61. data/lib/samagotchi/session_continue.rb +7 -6
  62. data/lib/samagotchi/session_manager/spawn.rb +6 -1
  63. data/lib/samagotchi/session_stores.rb +16 -11
  64. data/lib/samagotchi/system_one/runs.rb +5 -2
  65. data/lib/samagotchi/testing/boundary.rb +0 -1
  66. data/lib/samagotchi/testing/host.rb +1 -0
  67. data/lib/samagotchi/testing/recorder.rb +3 -0
  68. data/lib/samagotchi/version.rb +1 -1
  69. data/lib/samagotchi/web/peer_routes.rb +10 -5
  70. data/lib/samagotchi/web/public/agent_rows.js +206 -0
  71. data/lib/samagotchi/web/public/agent_runs.js +595 -0
  72. data/lib/samagotchi/web/public/answer_fold.js +41 -44
  73. data/lib/samagotchi/web/public/app.js +3 -3
  74. data/lib/samagotchi/web/public/block_fix.js +1 -1
  75. data/lib/samagotchi/web/public/cards_place.js +6 -4
  76. data/lib/samagotchi/web/public/history_reveal.js +5 -2
  77. data/lib/samagotchi/web/public/index.html +38 -2
  78. data/lib/samagotchi/web/public/page_view.js +1 -1
  79. data/lib/samagotchi/web/public/pages.css +1 -7
  80. data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
  81. data/lib/samagotchi/web/public/peer_note.js +4 -2
  82. data/lib/samagotchi/web/public/peer_row.js +37 -0
  83. data/lib/samagotchi/web/public/quiet_notes.js +12 -1
  84. data/lib/samagotchi/web/public/revise_stack.js +5 -2
  85. data/lib/samagotchi/web/public/send_turn.js +11 -3
  86. data/lib/samagotchi/web/public/turn_block.js +4 -0
  87. data/lib/samagotchi/worker/mail.rb +11 -1
  88. data/lib/samagotchi/worker.rb +7 -5
  89. data/lib/samagotchi/worker_inbound/mail.rb +34 -6
  90. data/lib/samagotchi/worker_inbound.rb +11 -3
  91. data/lib/samagotchi/worker_link.rb +13 -1
  92. data/lib/samagotchi/worker_wakes.rb +33 -5
  93. metadata +5 -2
  94. data/lib/samagotchi/web/public/pages_group.js +0 -67
@@ -27,13 +27,16 @@ A bad file is a `BadFile` with its reason. A directory link is never followed: a
27
27
  listed, `serials` reads a linked folder as empty and `post` refuses one.
28
28
 
29
29
  **chi's side, `sessions/<id>/peer_receipts.json`** (`PeerReceipts`), written only by the session's worker, on
30
- its loop thread: `{peers: {<peer>: {box, taken, receipts}}}`, `Receipt(serial, state, reason, turn, outcome,
31
- at)`. `box` is 6 random hex the worker mints (and writes at once) with a peer's first message; `taken` is the
30
+ its loop thread: `{peers: {<peer>: {box, taken, receipts}}, peer_wakes}`, `Receipt(serial, state, reason, turn,
31
+ outcome, at)`. `peer_wakes` is `WorkerWakes#peer_in_a_row` (the `peer.turns` count), saved at each change
32
+ (`Worker::MailPart#save_peer_wakes`, given to `WorkerWakes` as `on_peer_count`: each `count!(peer: true)` and the
33
+ reset in `human_input!(interactive: true)`, all on the loop thread) and read at the worker's start; absent is 0 (a
34
+ 0.192.0 file; an older worker's write drops it: a reset). `box` is 6 random hex the worker mints (and writes at once) with a peer's first message; `taken` is the
32
35
  newest serial it took. The CLI and chi web only read it.
33
36
 
34
37
  `SessionStores` rows: `link.json`, `in/`, `lock` (removal `:peer_mailbox`: a delete removes the session's
35
- mailbox folder) and `peer_receipts.json` (`:session_files`); a continue leaves all of them with the previous
36
- link (below).
38
+ mailbox folder) and `peer_receipts.json` (`:session_files`); a continue copies `link.json` to the new link and
39
+ leaves the rest with the previous one (below).
37
40
 
38
41
  ## Who is a peer
39
42
 
@@ -53,16 +56,30 @@ starts without it.
53
56
  `chi peer say` (`PeerCommand`) → `SessionAccess::Local#peer_say` (`RemotePeers#peer_say` through `--remote`,
54
57
  which posts `…/peers/NAME/say` with its `wait`: chi web waits, and its read timeout is the wait plus 30 s).
55
58
 
56
- 1. Refused before anything is written: no session, continued (with the next id), no `link.json`, a live worker
57
- without the `peer_mail` Bridge feature (`WorkerLink.live_features`, read only), `UNTAKEN_MAX` (200) untaken
58
- messages or noted receipts.
59
+ 0. **The link it runs on** (`Local#peer_head`): the id said to, or, when it is archived, its chain's first live
60
+ link (`SessionChain::Links#first_live`, `SessionInbox::Head`'s walk; only an archived id lists the sessions).
61
+ Every step below is keyed on that link, never on the id asked (its `taken`, its receipts, its worker, its hold),
62
+ and a received say's `PeerSay#forwarded_to` names it (on the wire; the line ends `· session continued as <id8>:
63
+ answer there`; an older client drops it and prints the old line). One hop: a link continued again meanwhile is
64
+ refused as continued. `peer_pair` (`PeerPaired#forwarded_to`), `peer_unpair` (the asked link's pairing and the
65
+ live link's, `PeerUnpaired`) and `peer_list` walk the same way; `chi peer ls` resolves with the access's `head`
66
+ (chi send's, also through `--remote`) and names the link. chi web's `GET …/peers`, the chip's feed, stays on
67
+ its page's session.
68
+
69
+ 1. Refused before anything is written: no session, continued (with the next id), no `link.json` (on a link
70
+ reached from a continued id: `:continued` naming that link, the words the 0.192.0 skills pair again on), a live
71
+ worker without the `peer_mail` Bridge feature (`WorkerLink.live_features`, read only), `UNTAKEN_MAX` (200)
72
+ untaken messages or noted receipts.
59
73
  2. Under a shared hold of the session's transition lock (`SessionTransition.shared`, `Local#moved_on`), the
60
74
  continued check again, then the delivery (step 3): a continue holding the lock (from after its recap through
61
75
  `PeerContinue`'s carry) refuses the say `:continued` naming its new link (`SessionChain::Successor.of` with
62
- `in_flight: true`; the line `this session is being continued as <id>: say it there in a moment`, `in_flight`
76
+ `in_flight: true`; the line `this session is being continued as <id>: say it again in a moment`, `in_flight`
63
77
  on the wire), or `:busy` (`SessionTransition::Busy`'s words) when the holder names none. So a say never lands
64
- in a mailbox the carry already read (N1). The feature probe before and the receipt wait after stay outside the
65
- hold; the delivery's worker start (`resume_session`, a spawn) is inside it.
78
+ in a mailbox the carry already read (N1). The pairing is read again inside the hold: a continue saves its new
79
+ link, then copies the pairing in its `before_spawn` holding the link's lock, so a say meanwhile is busy, never a
80
+ refusal that sends the peer to pair again. The feature probe before and the receipt wait after stay outside the
81
+ hold; the delivery's worker start (`resume_session`, a spawn) is inside it. A delivery the row's own hold
82
+ refused (`Hold.under`) reads as `:continued` (its successor named) or `:busy`, not as no such session.
66
83
  3. `SessionInbox.deliver(:peer)` (`WakePolicy::ROWS[:peer]`, the push row; `START_EVENTS[:peer] =
67
84
  :peer_woke_session`): a session gone or being deleted refuses before its block writes. Inside the block:
68
85
  the lock, the serial, the write, the trim. The block's "asks for a worker" is the message's own `wake`: no
@@ -70,8 +87,8 @@ which posts `…/peers/NAME/say` with its `wait`: chi web waits, and its read ti
70
87
  4. The line (`PeerSay`): what the say saw at once (a running turn, a stopped or archived session, a one-turn run,
71
88
  a failed start), else a receipt read every 250 ms within the wait, then the peer's other held receipts.
72
89
 
73
- `chi peer pair` makes the old-worker and continued checks too, with the same sentences (`PeerPaired`), and writes
74
- `link.json` under the same shared hold (`:continued` in flight, `:busy`). A context push into the session's own
90
+ `chi peer pair` makes the old-worker and continued checks too, on the link step 0 reached, with the same sentences
91
+ (`PeerPaired`), and writes `link.json` under the same shared hold (`:continued` in flight, `:busy`). A context push into the session's own
75
92
  source does too (`Local#context_push`: 410 `context_continued` with `in_flight`, 423 `context_busy`). The continued
76
93
  words are `SessionChain::Continued`'s, one wording for every refusal of a continued link ("this session" in a
77
94
  peer's line: the installed skills look for `this session was continued as <id>`). Wire: an older chi `--remote`
@@ -90,7 +107,7 @@ why a wake can't run: `:queued`, `:exit`, `:leaving`, `:before_turn` (nil: it ma
90
107
  plus `box`), its text by `PeerNote.body` (a wake note up to the tool output cap, a plain one up to
91
108
  `PeerNote::HELD_CHARS`; over it, `PeerNote.message_text` points at `<peer>_read(serial: N)`).
92
109
  - **Wake:** the batch wakes when a message in it asked, `peer.turns` is above 0 (else `held: off`), the caller
93
- gave no `hold:` and `WorkerWakes#wake_hold(peer: !agreed)` is nil. The turn starts at the batch's last note;
110
+ gave no `hold:`, the cache isn't cold (else `held: cold`, below) and `WorkerWakes#wake_hold(peer: !agreed)` is nil. The turn starts at the batch's last note;
94
111
  its wake line, its origin (`peer:<name>`, `ClientId::PEER_PREFIX`) and the count come from the newest message
95
112
  that asked; an agreeing one (`VERDICT OK`) counts toward `session.max_wakes` only. In the start grace nothing
96
113
  is taken and `mail_wake_waiting?` joins `idle_wait`'s check.
@@ -100,6 +117,20 @@ why a wake can't run: `:queued`, `:exit`, `:leaving`, `:before_turn` (nil: it ma
100
117
  note already in the conversation doesn't wake.
101
118
  - **An unreadable file** (a transient read error) raises and the batch retries on the next pass; a bad file's
102
119
  contents are refused as `invalid` and move `taken`.
120
+ - **The cold hold** (`MailPart#cold_hold?`, `PeerCold`): none of the batch's asking messages is an answer chi asked
121
+ for that doesn't agree (`PeerCold.asked_for?`: its `re` is a `sent` row of `peer_exchanges.jsonl` for that peer,
122
+ in this session or `Session#continues`, that no earlier message of the peer's claimed, as `PeerExchanges.joined`
123
+ pairs them: one answer claims a send, so an old or repeated `re` is held; a log that is there and can't be read,
124
+ `PeerExchanges.read!`, counts as asked), and `PeerCold.cold?`: the host keeps a
125
+ TTL'd cache (`Engine#remote_cache_ttl`: the chat adapter's `cache_breakpoints?`, a remote Claude model's chat
126
+ requests, through `OpenAIChat`, or `AnthropicMessages` with a dialect whose breakpoints weren't refused; `PromptCache.ttl_seconds`;
127
+ nil on a local model), `Session#last_turn`'s `ended_at` is older than it (a `ContinueOffer` stamp or a failed
128
+ turn's taken as it is: never earlier than the last request), and `analytics.json`'s `context.used_tokens` is above
129
+ `PeerCold::FLOOR_TOKENS` (20,000). No `ended_at`, no count or an unparsable time: warm. Side requests (recap,
130
+ `ctx.ask_model`) go through `IdleClient` with no breakpoints, so they neither read nor refresh the cache: the
131
+ turn's end is the cache's last refresh. Its one-time notice is its own (`WorkerWakes#notice_peer_cold!`, reset by
132
+ interactive input), apart from the budget's. The notices' once-flags are the worker's, not saved: a new worker
133
+ (an idle exit, a restart) can say a held message once more, though the count it reads (`peer_wakes`) is saved.
103
134
  - **The wake turn:** `MailWake(peer, turn_id, plain_note, agreed)`, run by `WakeTurnsPart#run_mail_wake_turn`
104
135
  through `run_wake`. The one-time hook notice for a held message (`WorkerInbound#peer_held`) is the TUI's and
105
136
  the web's.
@@ -134,18 +165,40 @@ wake line. The wording is model-visible and eval-tuned (0017).
134
165
  The peer bundles' base: `ctx.peers.link(PEER)` (`Plugin::Peers`, read only) is the pairing whose address the
135
166
  transport sends to; `<peer>_read` reads a message (`ctx.peers.message`) paged by lines, in the peer block; the
136
167
  status card reads the link and the newest message, and says "paired the old way: pair again" when an older
137
- bundle's context source (`LEGACY_INBOX`, `LEGACY_OUTBOX`) is attached. Its quiet init task `tell_moved` posts the
138
- `moved` message to the address of the pairing the previous link kept (`ctx.peers.left_behind`), once (a marker
139
- in the session's data dir).
168
+ bundle's context source (`LEGACY_INBOX`, `LEGACY_OUTBOX`) is attached. A continue tells the peer nothing: the
169
+ pairing is copied (below), and the next send's header names the new id. (An older chi's init task posted a
170
+ `moved` message; the skills still name it as chi's, and don't reply to it.) `ctx.peers.left_behind` reads the
171
+ previous link's pairing, the one the copy came from.
172
+
173
+ A model's send to a dormant pairing (`Peer#quiet_check!`, `by: "model"` only): the newest of the link's `paired_at`,
174
+ `last-send.json`, the `sent` rows of `peer_exchanges.jsonl` and the peer's newest message, over this session and
175
+ `ctx.continues` (one hop: the copied pairing keeps its `paired_at` and the new link's logs start empty), is older than
176
+ `peer.quiet_minutes`. In a turn with `ctx.turn_interactive?` (the turn's origin `ClientId.interactive?`; a person's first prompt
177
+ from a web tab or a TUI keeps that screen's id, `Session#first_turn_client_id`, and a Continue tap on a step-limit
178
+ offer continues an interactive offer turn as its screen's, `ContinueOffer#continue_client`) it asks
179
+ through `ctx.ask_user` (Send tagged `:spend`); in any other turn `ask_user` would block with nobody to answer
180
+ (`QuestionDesk` waits with no timeout), so it raises `SendError` at once. A Don't send (or no answer) is remembered
181
+ until the next `before_turn`. The tools' descriptions don't change (no prompt rebuild).
182
+
183
+ The skills (`scripts/chi-peer-SKILL.md`) say an answer from a file (`$TMPDIR/chi-peer/answer-<ref>.md`, `chi peer
184
+ say … < file`): a say refused with "try again" is run again as it is; after a `#N received` line or a failure with
185
+ no line it is not (a say has no idempotency key, so a second run writes a second message).
140
186
 
141
187
  ## A continue: `PeerContinue`
142
188
 
143
- `SessionContinue::CARRY` step `:peers`, in the new link's `before_spawn` (both workers down): the previous link's
144
- messages never taken and those whose receipts are still `held` or `noted`, in the worker's order, become one note
145
- in the new link (`NOTE_SOURCE` "peer messages"), each text in its peer block and cut past 4 KiB, within the
146
- inbox's note limit, with no `<peer>_read` pointer. The previous link's mailbox, `taken` and receipts are only read,
147
- so there is no undo. The pairing stays; the peer pairs again (`tell_moved`). Moving the pairing with the chain
148
- (and the peer's prompt-cache cost of re-pairing) is a later discussion.
189
+ `SessionContinue::CARRY` step `:peers` (its store `:peer_mailbox`, its file `link.json`), in the new link's
190
+ `before_spawn` (both workers down): first each pairing of the previous link is copied to the new one as it is
191
+ (`PeerMailbox.carry_links`: `address`, `from` and `paired_at` kept), whether or not anything is unread; then the
192
+ previous link's messages never taken and those whose receipts are still `held` or `noted`, in the worker's order,
193
+ become one note in the new link (`NOTE_SOURCE` "peer messages"), each text in its peer block and cut past 4 KiB,
194
+ within the inbox's note limit; a cut text ends pointing at `<peer>_read(serial: N, box: "<previous id8>")`, which
195
+ `Plugin::Peers#message` reads from the link this session continues (that id's first 8 as the box; one hop, this
196
+ session's own chain only). Each part is best effort (logged, the link starts
197
+ without it). The previous link's mailbox, `taken` and receipts are only read, so there is no undo: the copies are
198
+ in the new link's mailbox folder, which a failed continue's delete removes (`discard_failed_link` →
199
+ `delete_session` → `:peer_mailbox`). The previous link keeps its own `link.json`. Forwarded answers that name a
200
+ send of the previous link (`re`) show in the new link's chip as an answer with no send (its `peer_exchanges.jsonl`
201
+ starts empty).
149
202
 
150
203
  ## chi web
151
204
 
@@ -238,7 +238,8 @@ is prefilled once. The native and the chat loop use the same plan.
238
238
  - **TTL.** Anthropic keeps a breakpoint 5 minutes after its last read; a session the user comes back to later
239
239
  writes its prompt again. `cache.ttl: 1h` sends `cache_control: {type: "ephemeral", ttl: "1h"}` on both
240
240
  breakpoints (the log line shows `cache=1h`). Off by default: a 1h write costs 2× the input price, a 5m write
241
- 1.25×, a read 0.1× either way, so 1h pays off only when pauses of 5–60 minutes are common.
241
+ 1.25×, a read 0.1× either way, so 1h pays off only when pauses of 5–60 minutes are common. The peer mail's cold hold
242
+ reads the same TTL (`PromptCache.ttl_seconds`, `Engine#remote_cache_ttl`: [peers.md](peers.md), The worker's mail path).
242
243
  - **Routing.** Every chat request carries a `Session-Id` header, which OpenRouter uses to keep a conversation on
243
244
  one provider. `cache.key: session` also sends the session id as `prompt_cache_key` in the body, the field
244
245
  OpenAI's API routes and caches by (OpenRouter honours it too); the log line shows `cache_by=session`. Only
@@ -227,6 +227,12 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
227
227
  only when its detail starts with `not found: /` (the 404 from `serve_static`, for a path no route takes). A route's
228
228
  own 404 (no such session or source) stays a refusal. **Keep that rule:** a new route's 404 must never use the
229
229
  `not found: /…` wording.
230
+ - **Answers across versions.** The corpus's `wire/remote/` (`CompatRemote`, recorded at each release) pins the shape
231
+ of chi web's answers to `Remote`: `spec/compat/remote_readers_spec.rb` reads the previous release's answers with
232
+ today's `Remote` (exact values, so `head`'s `:same` fallback or a nil `SessionView` field fails) and sends its
233
+ requests to today's chi web (same status, every old key path kept with its JSON type). Canned replies check
234
+ parsing only: a new request field an older chi web ignores still needs a feature of its own (below). Ask, last-ask
235
+ and MCP (`ask_routes.rb`, `last_ask.rb`, `mcp_route.rb`) have no in-repo reader and aren't recorded.
230
236
  - **A field an older chi web would ignore.** A body field whose meaning is a restriction (`share --identity`'s
231
237
  `identity`: an older chi web drops it and issues a link anyone could open) gets a feature of its own
232
238
  (`bound_grants`, `App::BOUND_FEATURE`), and `Remote` requires it before sending the field (`require_feature!`):
@@ -344,7 +344,7 @@ firing counts it a skip; the web composer, a delegate follow-up, a plugin's send
344
344
  | context add / remove (`Local#context_add`/`#context_remove`, chi web's URL add and detach) | shared | `ContextSources.changing`: a continue copies the session's own sources. Refused `ContextSources::Held` (423 `context_busy`). |
345
345
  | context push, peer say, peer pair | shared | Phase 1 (`Local#moved_on`); the say's delivery seat holds again (shared beside shared). |
346
346
  | invite (`Participants.invite`) | shared | A continue archives the link and ends its grants; refused `Grants::Invalid` with Busy's words. |
347
- | revoke, peer unpair | none | Removals: a continue ends every grant at the archive, and the new link's pairing is the peer's to make (`Plugin::Peer#tell_moved`); refusing them would only make the owner retry. |
347
+ | revoke, peer unpair | none | Removals: a continue ends every grant at the archive, and an unpair of a continued id ends the live link's pairing too (`Local#peer_unpair`); refusing them would only make the owner retry. |
348
348
  | `Local#answer` / `#dismiss`, cancel (cut), the attached TUI's `post_turn`, `Bridge#enqueue_turn` (the input fallback) | worker-side | Bridge-only: the live worker's own session (a continue's archive stops that worker and `archivable!` refuses it busy or queued). Over `--remote` the TUI's turn is chi web's turn route, `deliver_turn`'s seat. |
349
349
  | The new link's boot (`ChildMove.adopt`, `NoteMove.adoption`, its objectives notes) | worker-side, none | Runs inside its creator's exclusive hold of the new link: a hold there would be refused until the continue ends. |
350
350
 
@@ -372,8 +372,9 @@ These are documented race boundaries, not promises of an atomic lifecycle transi
372
372
  | A send between a continue's exclusive hold and its archive marker (closed). | Before: `follow_guard` held only for a followed send to an archived link, so a send (any sender) to a link a continue held but had not archived yet went in, and the archive then refused the continue as busy or queued. Now every `:shared` row's delivery takes the hold in its seat: refused naming the new link (`link_continued`), else `transition_busy`. | `spec/session_inbox/hold_spec.rb` (each sender busy under a really held lock; a send to a link not archived yet refused naming the new link); the matrix's transitioning rows. |
373
373
  | A frozen worker's Bridge post under a send's hold. | `deliver_turn` holds the session's lock shared across the Bridge's post (up to `BridgeClient::READ_TIMEOUT` 30 s for a worker that doesn't answer); a continue of that session waits `LOCK_WAIT` per try and is refused `transition_busy`, and a stop or an archive waits its 10 s and is refused (`stop_held` / `transition_held`, "busy with another change"): stopping that frozen worker can take a second try. | No unit pin: a frozen worker's post is a timing case. |
374
374
  | A delete or a send during a continue's recap. | `SessionContinue.continue_once` waits for the recap before it takes the transition lock: in that window a link delete and the delete preview no longer see a continue (`:continuing`): the delete may take the link's lock exclusively, and the continue's lock wait then ends busy ("being deleted"); a followed send to the link goes in. Under the lock the continue checks the link again: deleted → not found (its folder not brought back), continued by another → `Refused :continued`, a turn queued → the archive's refusal. | `session_continue_spec.rb` "the transition lock": the lock not held during the recap, a send then accepted, a link deleted or continued during the recap refused under the lock. |
375
+ | A stop is refused during a live continue. | `ContinueIntent#write` records the new link before archive; if the live continue names it, a stop refusal can name that successor up to a few seconds before it is saved while the archive waits up to 5 s and then spawns it. Opening the named link at once can show gone until it appears, and a failed spawn means it never appears. | `continue_intent.rb` (`in_flight`) and `session_continue.rb`. |
375
376
  | The new link's worker boots inside the continue's hold. | `SessionContinue.spawn_continuation` spawns it while the continue holds the new link's transition lock exclusively; its boot writes (`Worker#start` → `ChildMove.adopt`, `WorkerInbound` → `NoteMove.adoption`, its objectives notes through the note row, `:none`) take no transition hold. A hold added on that path would be refused until the continue ends (drop the new link's hold before the spawn instead). A send or a peer pair to the new link from outside is `transition_busy` until the continue lets go (milliseconds after the spawn): the senders retry. | `session_continue_spec.rb`: the boot's adoption on another thread makes no `SessionTransition` call, adopts the note, and a note through `NoteDelivery` goes in. |
376
- | An unpair or a revoke during a continue. | `:none` (above): an unpair of the old link while the new worker's `tell_moved` re-pairs the peer may leave the peer paired with the new link. | No pin (declared). |
377
+ | An unpair or a revoke during a continue. | `:none` (above): the continue archives the old link, saves the new one, then copies the pairing in the new link's `before_spawn` (`PeerMailbox.carry_links`, reading `link.json` at that moment, so an unpair before it wins). An unpair that lands between the copy's read of the old `link.json` and its write of the new one removes the old link's only; the copy keeps the peer paired with the new link (unpair again). | No pin (declared). |
377
378
  | Sends to a session a delete holds (open, by design). | `SessionChain::Delete` holds the transition locks from before its stop to the end: a send, a push, a peer say or a context change to the link, its previous link or a delegate that goes is refused `transition_busy` "being deleted" for the stop (up to the delete's wait, 10 s from the CLI), the task stop (about 4 s a link) and the removal; a chain delete holds every link's for the whole chain (N links × stop + tasks: minutes for a long chain with `--stop-tasks`). chi send and an ask retry within their wait; the web composer, a delegate, a plugin and a participant report it. Before, those sends went in and the delete stopped or removed them. | `session_chain/delete_spec.rb` "under the transition locks" (a send during the stop refused as being deleted, both locks the delete's). |
378
379
  | A delete meets a send's or another change's hold (closed). | Before: `Delete.link`, `hold_all` took `SH\|NB`, so a continue was refused but another delete, a prune or the retention sweep could run beside it, and a send held nothing off. Now a user's delete waits up to `LOCK_WAIT` for the locks exclusively, then refuses (`continuing` / `transition_held`, the holder named); the prune, the sweep and a leaving worker's delete try once and keep the session. | `session_chain/delete_spec.rb` (a short shared hold waited out, a long one refused, a held delegate refuses), `session_retention_spec.rb`, `session_discardable_spec.rb` (held → kept). |
379
380
  | A prune at a link it can't delete (closed: visible, never skipped). | Before: a link another enabled schedule protects (its anchor inside the chain, a stale head) was refused `prune_stopped` at every firing, after the link's delegates were already deleted, and the chain grew silently. Now the hold is checked before anything in the subtree goes and the prune stops there with a record (`prune_waiting`, list/show) and one log line; a held transition lock on the link or the next does the same, and every tick retries. Still open: the chain grows behind such a link until the other schedule is cancelled (re-linking the chain around it is held, D6). | `schedules_spec.rb` "a prune held at a link" (held link: kept with every later link, resumed next tick; next link held; the mid-chain schedule: one log, list/show lines, nothing deleted around it, gone after cancel). |
@@ -35,9 +35,13 @@ the next release (its baseline refresh) for the same reason, marked as kept for
35
35
  sheet still keeps `isChained` and `format.js deleteConfirmText` that way; and `ws_peek.js`'s `PEEK_WIDTH`, which 0.183.0's
36
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
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`, `quiet_notes.js`, `details_motion.js`,
38
+ `spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `quiet_notes.js`, `agent_rows.js` (a delegate report's and a
39
+ peer answer's row: its element and words; `answer_fold.js` re-exports its `reportLabel`, an import cycle neither side
40
+ uses at its top level, `agent_rows.test.js` loads both orders), `agent_runs.js` (the one owner of reports, peer
41
+ answers and notes: The notes rows and the run line, below; it imports only names the last release's `answer_fold.js`
42
+ and `quiet_notes.js` exported, and `quiet_notes.js installQuietNotes` stays for an older cached `app.js`), `details_motion.js`,
39
43
  `turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
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), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while it is open, a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js), `pages_group.js` (All sessions' former group, kept for an older cached app.js until after 0.189.0) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `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), `peer_mailbox_api.js` (the chip's message and Unpair calls), `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), `drafts.js` (the composer's drafts: The drafts, below), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `answer_write.js` (the answer's live write onto its bubble, kept in its own module so a new `markdown_place.js` or `block_fix.js` importing it never waits on an old `answer_refs.js`) 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).
44
+ `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), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while a view owns the URL (`keepSessionHash`), a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js` (its `showPending` calls the injected `keepSessionHash`, following `views.js`'s rule not to write the session hash while a view owns the URL), `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`, `peer_row.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), `peer_mailbox_api.js` (the chip's message and Unpair calls), `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), `drafts.js` (the composer's drafts: The drafts, below), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `answer_write.js` (the answer's live write onto its bubble, kept in its own module so a new `markdown_place.js` or `block_fix.js` importing it never waits on an old `answer_refs.js`) 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).
41
45
 
42
46
  ## One page, every viewer
43
47
 
@@ -60,7 +64,7 @@ their viewer (The viewer, below), their show and stream are filtered (`Web::Part
60
64
  | **`store.current`** (`session_state.js`: `emptySessionState` / `sessionStateFrom`; per field: `session_fields.js FIELDS`) | the open session's fields, about 40 (info bar, chips, verdicts, timing, worker, stream cursor) | `store.update` / `setStatus` from app.js, `stream_handlers.js`, `session_sync.js`, `session_view.js`, `send_turn.js` (`firstPreview`, `owner`), `session_actions.js` (`status`), `owner_verify.js` (`verdicts`, `verifyFresh`); `forgetSession`'s `replaceCurrent` (`session_view.js`). Two writers in place, on purpose (D8 in `FIELDS`): live_timing.js's `activeTurn`, verdict_fresh.js's running list | the store runs the field's redraws (`FIELDS[key].redraws`) |
61
65
  | **`store.sessions`** (the hub's projection) | every card | `store.update({sessions})` from app.js: `openSessionEvents` (`applySessionEvent`), `refresh` (the list fallback), `addCreatedSession`, `views.js applyView` (re-sorted), `replaceSelectedCard` (`setLiveStatus` through `setStatus`, `readTurnEnd`, `setUsedMemories`), the stream's close (`withoutWorker`); `session_actions.js` (`setSessions`) | the store: `lists` and `infoBar`. **Always a new array**; an entry is replaced, never changed in place. `followSelectedSession` copies the open one's owner and worker (`fieldsFromCard`) and, when not streaming, its status (`setStatus(…, "hub")`) into `store.current` |
62
66
  | **Factory closures**: the `create*` factories (popovers, panels, views) | each component's own state: open-for, busy, error, its own fetched list | the factory | an `onChange` hook back into app.js, or a getter the factory reads at draw time |
63
- | **The history DOM** | the conversation as drawn (a running turn's reason bubble, `.bubble.said`, is live only: see A turn opened in the history): which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers and long prompts (`.folded`), the notes rows over a stretch of background items (`.quiet-notes`, open by its `open` class, the items `.quiet-hidden`; never stored), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `quiet_notes.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js`, `quiet_notes.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
67
+ | **The history DOM** | the conversation as drawn (a running turn's reason bubble, `.bubble.said`, is live only: see A turn opened in the history): which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers, long prompts, delegate reports and peer answers (`.folded`, each behind its `.answer-fold` row; a report's and a peer answer's `.answer-fold.agent-row`), the notes rows over a stretch of background items (`.quiet-notes`, open by its `open` class, the items `.quiet-hidden`; never stored) and the run lines over a run with a report, a peer answer or a finished steps block in it (`.quiet-notes.agent-line`, its open segment its `data-open`, the closed segments' rows and items `.quiet-hidden`, a block under its line `.in-line`; never stored), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `agent_runs.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js`, `agent_runs.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
64
68
  | **A drawn turn** (`turn_drawings` of the full read) | every finished turn, as live drew it: `turnGroups` groups by the stamps only, a turn's stamped items (`drawn: <turn_id>`) one group, and `turnHistoryNodes` draws it by feeding its drawing's events to a live turn block offscreen (`turn_block.js drawnTurnNodes`: the block's own handlers, as the stage's), the stage's extras (a reminder, merged lines, a card that waited when it arrived, an answered question) in the order live left them for the history (`turn_settle.js settleOrder`, pure: from the drawing's `part_settled` and question events, whether the turn was opened, and whether a question had a lead-in) and the end as live, then the answer, the merged lines and the steps' texts from their saved items (markdown, refs). Each of its top-level elements carries `data-drawn`: `cards_place.js` leaves that turn's in-turn CardStore entries (`of_turn`) to it, and a kept reminder bubble of that turn (`data-turn-id`) stays out after a resync. chi web sends a drawing for every finished turn (one made from its messages where live wrote none): `drawnGroup` pairs the record the end names (`end.record_id`, by place for a turn saved before turn ids), else by the turn's id, and the answer's `data-answer-turn` is the end's own `turn_id` only (a made-up id, `m…` or `…~N`, keys none: no Revise). Nothing is rebuilt from messages: an item that comes unstamped is a `plain` group drawn as a plain row of its text (its prompt or answer bubble, no steps), the running turn's as expected (`runningTurnId`, the show's `current_turn`: it has no line yet), any other a miss, marked `data-undrawn`, logged once per render (`console.warn`) and counted by the reload check (`undrawn`), never a throw; a drawing with no parts (a minimal line) draws its prompt, answer and end | chi web (the show) | `renderHistory`, the reload check's render |
65
69
  | **The cards as data** (`card_registry.js`; app.js `cardRegistry`) | every question, continue offer and plugin card of the open session, keyed as `stage_waiting.js` keys them (`q:<id>`, `c:<id>`, `continue`): its kind and folded text (`card_kinds.js`), status (pending, answered, cancelled; resolved or dropped for the continue offer; asks or shown for a plugin card), `of_turn`, `opening_id`, step, `relayed_to` | `observeCards` around the stream handlers (outside the participant wrap: the page's handler first, then `apply`), so a read's replay feeds it too; `session_view.js renderSessionView` seeds it from the read right before the replay (`seed`: CardStore's listing, the pending question, the continue offer; it replaces), `forgetSession` resets it. Idempotent: a merge per key, a final status never back to pending, the first `of_turn`/`opening_id`/step kept, so seed then replay is what live holds. A question still pending at its turn's end is cancelled (the page cancels the card, no event comes) | an observer: nothing on the page draws from it; its one reader is the opt-in reload check (`reload_check.js`: this turn's entries against a registry seeded from a fresh read). `stage_cuts_parity.test.js` checks it against the stage's waiting cards at each cut, `card_registry.test.js` the events against each cut's seed and replay |
66
70
  | **What was opened of a running turn** (`stage_view_memory.js`, in `session_view.js`) | per session, for this tab: the cloud open, the steps opened in it, the working set's reader on an item; a Map of at most 20 sessions, nothing stored or sent (the peek isn't kept: it closes with its popover) | `session_view.js leaveSession`, from `session_sync.js select` and from `forgetSession` itself for the session it drew last (so the start page, `clearSelection`, keeps it too) before its reset (`captureView`); dropped by `endTurnView` | `renderSessionView`, once the read is drawn: put back (`applyView`) only when the read's running turn (`current_turn.turn_id`) is the one saved; taken either way |
@@ -68,20 +72,71 @@ their viewer (The viewer, below), their show and stream are filtered (`Web::Part
68
72
  | **localStorage** (`storage.js` `readStored`/`writeStored`, guarded) | per-browser choices only; a session's view settings per session (`session_prefs.js`) | the module that owns the choice | read at start, a session's view settings again when its view is drawn (see Storage keys) |
69
73
  | **SSE** | see Streams | the server | events go into the DOM directly (a participant's through `participant_main.js wrapHandlers` first) |
70
74
 
71
- **The notes rows** (`quiet_notes.js`): what nobody says in the conversation folds, so a phone shows the prompt and
72
- the answer, not the background under them. A stretch is a run of `#history` children that match `QUIET` (a
73
- `.bubble.hook-notice` but the empty-answer line, a `.bubble.note` that is neither a wake's opening `.turn-start` nor a
74
- `.peer-answer`, so objectives lines too, and a `.bubble.steer-row`); the `.turn-timing` line passes through it, and
75
- anything else ends it (a prompt, an answer, a card, a peer's answer, a time divider, another fold's row). Each stretch
76
- gets one `<button class="quiet-notes">` before its first item, closed, and its items get `.quiet-hidden`. The row is a
77
- sibling tied to its first item (WeakMaps, as `answer_fold.js`'s), not a wrapper: the bubbles stay direct children of
75
+ **The notes rows and the run line** (`agent_runs.js`, the one owner; the notes' words are `quiet_notes.js`'s): text
76
+ written for the user starts open, text agents write to each other starts closed, so a phone shows the prompt and the
77
+ answer, not the background under them. Three levels of the same content (the design: the fold-levels mock-up,
78
+ https://claude.ai/artifact/6Pe1GXxBX4qMmdUsZH2FEp): a segment in a shared line, a row, the full text.
79
+ - A delegate report and a peer's answer in `#history`, finished and keyed (`answer_fold.js answerKey`; a live merged
80
+ report has none until a reload: it stays open with no row and ends a run), get a row before their bubble
81
+ (`agent_rows.js` draws it; `.answer-fold.agent-row`), closed by default, opened by hand kept in the fold store's
82
+ `open` list (Storage keys); a tap opens or closes it, its height animated unless the viewer prefers no motion.
83
+ - A run is those items and the quiet items (`QUIET`: a `.bubble.hook-notice` but the empty-answer line, a
84
+ `.bubble.note` that is neither a wake's opening `.turn-start` nor a `.peer-answer`, so objectives lines too, and a
85
+ `.bubble.steer-row`) side by side among `#history`'s children; the `.turn-timing` line and an objectives line after
86
+ a block (`.obj-moves`, `.obj-nomove`: they stay on view) pass through it, anything
87
+ else ends it (a typed prompt, an answer, a card, a time divider, another fold's row). A run of quiet items only gets
88
+ the notes row: `<button class="quiet-notes">` before its first item, "▸ 3 notes · names ⚠ 1", closed, its items
89
+ `.quiet-hidden`. A run of one report or one peer answer only keeps its row. Anything else gets the run line: a
90
+ `<div class="quiet-notes agent-line">` of segment buttons (`.qn-seg`, `data-seg`: `report`, `peer:<name>`, `calls`,
91
+ `notes`), `segments`' words ("N reports", "<peer>: <verdict>", "<peer> answered" with no verdict, "<peer> ×N" for
92
+ several, "N calls", "N notes" with its "⚠ N"), in the mock-up's order (reports, peers, calls, notes; the owner: order
93
+ doesn't matter). The kinds are one table (`KINDS`: per kind its selector, whether one takes part, its segment key and
94
+ words, and whether its row under the line is a row of its own, a note's compact row or the item itself); the same
95
+ table feeds the runs, the segments, the jump's reveal and the observer. One
96
+ segment is open at a time (the line's `data-open`): its rows show under the line (`.in-line`, indented), each closed
97
+ or open as its bubble is. Under a line every row is the mock-up's compact panel row (`.answer-fold.compact`): a peer
98
+ answer's, a report's (`.report-row`: "child <id6>", its first line, its length; alone it is Build 1's `.report` row
99
+ again, `agent_rows.js drawAgentRow` with `inLine`) and one per note (`.note-row`: its name and text, `noteRowWords`;
100
+ a tap shows the note under it, never stored). A settle redraws an item's row only when its open state, its place in
101
+ a line or its text (the observer's) changed. The line is `role="group"` ("agent run"); a tap on a segment that hides
102
+ the focused row moves the focus to that segment. A segment is per peer by the name it shows (`peerName`). One line at every width: CSS shrinks the notes segment first,
103
+ then the calls', then the reports', then the peers', strictly: their `flex-shrink` is 1e15, 1e10, 1e5 and 1, so a
104
+ higher rank gives up nothing (under 1/64 px) until the ranks below are at their padding (a proportional ladder cut
105
+ every segment a little); on a phone the line is 44px tall, a segment's tap area is, and a segment's side padding is
106
+ 6px so the mock-up's "1 report · Claude: changes · 2 calls · 2 notes" fits at 390 px.
107
+ - A finished turn's steps block (`STEPS`: `.turn-work.done[data-end="completed"]`, with a call in its `data-calls`,
108
+ which `turn_block.js turnEnded` stamps live and on a reload, so no label parses the summary's words) in a run that
109
+ holds a report or a peer answer is the segment "N calls" (the calls of the run's blocks on view summed: one a
110
+ folded Revise version hides doesn't count). Under the line the block is its own row (`.in-line`, indented): today's
111
+ block, open or closed as it was last left, its summary line with the working set's footprint and its count, a tap
112
+ on it opens or closes the steps. So a footprint in a line is one tap deeper (the owner; [working-set.md](working-set.md)).
113
+ A block alone, or beside notes or a steer row only (a typed turn: owner decision (b)), keeps today's look and cuts
114
+ the notes into a notes row on each side; a cancelled or failed block ends a run and stays visible. A running block
115
+ stays out: the stage's joins at the hand-off; one opened in the history mid-turn (`stage_asking.js openTurn`, its
116
+ `data-opened-turn`) is done at its turn's end but joins only when `stage_handoff.js` drops that mark, the hand-off
117
+ that comes after the end. A block an older cached `turn_block.js` drew has no `data-calls` and stays out.
118
+ - A run inside a superseded Revise version folded to its stub (`revise_stack.js`: every item `.stack-hidden`): its
119
+ line or notes row is hidden with them (`.quiet-hidden`; a segment that had the focus gives it to the stub), and back
120
+ when the stub opens (a jump into it opens the stub first). `revise_stack.js`'s divider walk passes over it as over a
121
+ folded item.
122
+ - A notes row that a report or a peer answer joins becomes the line (a button becomes a div): its open state goes to
123
+ the notes segment, and its focus.
124
+ - Never stored: a reload draws every line and notes row closed; a row opened by hand inside a line shows open once its
125
+ segment is.
126
+ Every row and line is a sibling tied to its first item (WeakMaps), not a wrapper: the bubbles stay direct children of
78
127
  `#history`, where every walker (`turn_range.js`, `cards_place.js`, the stage's hand-off, the reload check) and the
79
- other observers expect them; a row something was placed after goes back before its item and keeps its open class.
80
- A between-turn notice is placed after its turn, not below the next divider (`cards_place.js afterTurnEnd`). Its one
81
- observer watches `#history`'s own children, and a settle writes only what changed (the copy, answer-fold,
82
- Revise and objectives observers see class and subtree writes). `revise_stack.js historyTurns`, `history_shape.js
83
- childItems` and `bubbles.js showRecap`'s walk skip the rows, and `history_reveal.js revealInHistory` opens one over a
84
- jump's target.
128
+ other observers expect them; the line has the notes row's class and the item rows `answer_fold.js`'s, so what passes
129
+ over those passes over them (`revise_stack.js historyTurns`, `history_shape.js childItems`, `bubbles.js showRecap`'s
130
+ walk, `cards_place.js afterTurnEnd`). A row or line something was placed after goes back before its item and keeps its
131
+ state. A hidden item's arrival (`ts-arrive`) plays on its row or line. Its one observer watches `#history` (children,
132
+ and class or key changes on them that aren't its own), and a settle writes only what changed (the copy, answer-fold,
133
+ Revise and objectives observers see class and subtree writes). `history_reveal.js revealInHistory` opens a line's
134
+ segment over a jump's target (`agent_runs.js revealRun`) before a notes row's (`quiet_notes.js revealQuiet`).
135
+ A between-turn notice is placed after its turn, not below the next divider (`cards_place.js afterTurnEnd`). A
136
+ between-turn card is not: live it sits where it arrived, after a reload just before the next turn's opening
137
+ (`placeSnapshotCards`), so a card that came before a run lands inside it on a reload and the one line live draws is
138
+ two there (measured: "1 report · Claude ×2 · 3 notes ⚠ 1" live, "Claude ×2 · 2 notes" and "1 report · 1 note ⚠ 1"
139
+ after a reload; the row order drifted the same way before the line).
85
140
 
86
141
  The objectives' strip keeps the list in its own closure (`objectives_strip.js`, seeded by `renderSessionView`, reset by
87
142
  `forgetSession`, updated by `objectives_updated`): [objectives.md](objectives.md#the-page).
@@ -898,6 +953,22 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
898
953
  agent" fold shows the content without the block, and the bubble carries `data-peer-inline`. Without it (an older
899
954
  session, a message over the cap) the bubble draws as before. A mailbox message's note (its hash has `box`) carries
900
955
  `data-peer-box` and no source; an older context answer's keeps its `<peer>-outbox` source as `data-peer-source`.
956
+ - **The answer's row** (`agent_runs.js`, drawn by `agent_rows.js`; its key `answer_fold.js answerKey`): every peer answer
957
+ in `#history`, short too, starts closed as one row before its bubble, `<name> <verdict> <summary> N lines` in a plain
958
+ panel box with no chevron (`.answer-fold.peer`; the verdict in the text colour whatever it says). `peer_row.js`
959
+ (pure) gives the words: the verdict as `verdictWord`'s lower-case word, none without one; the summary the peer sent
960
+ without the verdict mark it wrote into it (`summaryWithoutVerdict`: the last `VERDICT X` when X is the server's
961
+ verdict, the punctuation it leaves tidied), else (`.note-text` marked `data-fallback` by `peer_note.js`) the first
962
+ line of the peer's text; N the lines of the peer's own text (`.peer-text`'s `data-peer-md`), never the bubble's copy
963
+ text, and no length without a body. A tap opens the bubble under the same line (the box's top edge; the bubble's
964
+ `.under-row` class drops its own head, verdict and summary, which the row says, keeping the ↑ to the send), a
965
+ second closes it; opened by hand is kept with the reports' in the fold store's `open` list, keyed
966
+ `peer:<name>#<serial>`, else `peer@<opening id>`; with neither, no row and the bubble stays open. A jump into it (the
967
+ send pill's ↓, a claim link) opens it through `history_reveal.js`, not saved. An answer that arrives while a turn
968
+ runs sits in the stage, open (`stage_place.js`), and gets its row at the hand-off; the arrival motion
969
+ (`ts-arrive`) plays on the row, never on the hidden bubble. `revise_stack.js historyTurns` takes the row as its
970
+ note's head, and `cards_place.js afterTurnEnd` walks over it as over the notes. Next to a report, another answer or a
971
+ note it joins their run line (The notes rows and the run line).
901
972
  - `peer_text.js` (pure): `peerBlock(content)` cuts the text out between the first `[PEER MESSAGE from …]` line and the
902
973
  last `[END PEER MESSAGE]` line and undoes the `PeerNote.block` mark on forged frame lines
903
974
  (`PEER_FORGED_OPENINGS` and `PEER_FORGED_LINES`, the Ruby `PeerNote::FORGED_OPENINGS` and `FORGED_LINES`, and the same line breaks and leads
@@ -987,8 +1058,9 @@ session's id), `unqueue.js` (`putBackTo(text, id)`: into the draft of the sessio
987
1058
  (synchronous). A gone session (`session_actions.js leaveGoneSession`, the one place: a send's `not_found`, a re-read's
988
1059
  404, the hub's `session_gone`) moves its draft to the start page's before the start page opens, unless a delete from
989
1060
  this tab is taking it (the `deleting` set, filled when the sheet's request starts: the open link of a chain deleted
990
- whole too); `afterDelete` drops the deleted ids' drafts after its `clearSelection`. A gone session that isn't open
991
- keeps its draft until the sweep.
1061
+ whole too); `afterDelete` drops the deleted ids' drafts after its `clearSelection`. If a send's `not_found` belongs to
1062
+ a session that isn't open, `send_turn.js` moves that sent line to the start-page draft and shows a toast naming the
1063
+ gone session instead of leaving it in the gone session's swept draft key.
992
1064
 
993
1065
  **Continue →** (`session_actions.js continueSelected`): right after the 201 (`addCreatedSession`), before it looks at
994
1066
  which session is open, `handOverDraft(id, next, created)` = `drafts.handOver(A, A', openerText(created))`: a draft
@@ -1088,7 +1160,7 @@ reach another device or the server.
1088
1160
  | `chi_notify`, `chi_push_device` | `notifications.js` (an injected storage) | the bell's state, this device's push id |
1089
1161
  | `chi_composer_draft:<session>` | `drafts.js` (through `session_prefs.js`; the key is `draft_keys.js COMPOSER_DRAFT`) | the session's composer draft's text (none while empty; its images are never stored) |
1090
1162
  | `chi_start_draft` | `drafts.js` (`draft_keys.js START_DRAFT`) | the start page's draft's text, one per browser; outside the sweep |
1091
- | `chi_answer_fold:<session>` | `answer_fold.js`, `revise_stack.js` | the answers and long prompts (`<turn id>:prompt`) folded by hand, and the Revise stubs unfolded by hand (`stub:<turn id>`) (swept with the session list) |
1163
+ | `chi_answer_fold:<session>` | `answer_fold.js`, `agent_runs.js` (the `open` list), `revise_stack.js` | the answers and long prompts (`<turn id>:prompt`) folded by hand, the delegate reports and peer answers (`peer:<name>#<serial>`, else `peer@<opening id>`) opened by hand (its `open` list), and the Revise stubs unfolded by hand (`stub:<turn id>`) (swept with the session list) |
1092
1164
 
1093
1165
  **A session's view settings** (`session_prefs.js`): the five `<key>:<session>` view keys above and the composer's
1094
1166
  draft (the fifth's name is defined in `ws_sections.js`, the draft's in `draft_keys.js`, new modules, so
@@ -369,7 +369,11 @@ passes `working_set_updated` to it, and does nothing when the flag is off. A new
369
369
  unchanged one). A footprint is a `<span>` in its block's summary line, `.turn-work > summary > .tw-sum`, before the
370
370
  steps' `.turn-steps`: drawn in the reload's template (`turnHistoryNodes`; a drawn turn's from its drawing's rows, `turnGroups`' steps), prepended at the hand-off
371
371
  (`stage_view.js handOff`, while the stage still hides the summary). A click there must not toggle the block:
372
- `details_motion.js` skips `.ws-foot`, and `footClick` cancels the click;
372
+ `details_motion.js` skips `.ws-foot`, and `footClick` cancels the click. A finished block in a run line
373
+ (`agent_runs.js`, [web-frontend.md](web-frontend.md), The notes rows and the run line) is hidden behind the line's
374
+ "N calls" segment, its footprint with it: one tap deeper, the same node in the same summary line (never drawn in
375
+ the line). The chip, the rail and the lens are as without a line, and a step tag's jump (`refs.js showRow`,
376
+ `history_reveal.js`) opens the calls segment before it lands on the row;
373
377
  - the rail (`onServer`, the stage's `scheduleRefresh`).
374
378
 
375
379
  **The list's lens.** The expanded list is always the session's set (`sessionSet()`), seen through a lens: `null`