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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 228161de4fb614d97b4240e1f62444b5f3cb1cbba6df18cf4477f69d95b96828
4
- data.tar.gz: '0891bd0649800d9cd0f7c81009c6378a650caff0dccf2a3cd5242fa53a4e1d9b'
3
+ metadata.gz: c8b387ef3705f02f31f8b543fc8d85e763a9553ceb2740b4d45df6783fbc7d16
4
+ data.tar.gz: 149c444f36be679f218eab0f31552129675cac92d0af19f874a6398e2d3e71fb
5
5
  SHA512:
6
- metadata.gz: 62f39f21d2daf2dd9af94c3ef70bfd6bdad52202add14653b0013a407974556a66517a2dd492a4e14d9624c2d88f234fe36401eba35604da2aa2ad8f604f76fe
7
- data.tar.gz: eb2f2a67cd5b5422280650c68d8fb706d3b98cdd828777688004e78ca8170f8d9145ba833e4f4cf212a97577291b1a57dee51dc92b04a1548b5aca54f9632bd7
6
+ metadata.gz: d4cb3bcfa83d458e9123a25dfe3ea96d10714e7553f397a8198459340b75a01ef754df95dad13d942f0ef14b1306bfee89574b6a80a63ae96cf3f0eecb018dae
7
+ data.tar.gz: f52b92219301a36ff951369ccad3acdb966351fc03094f911549dbf94917a32ecfd231e140617463e4b7972ef88ed4260519db0e1d99405cef44e28c6757659f
data/CHANGELOG.md CHANGED
@@ -8,6 +8,56 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.193.0] - 2026-11-29
12
+
13
+ ### Added
14
+
15
+ - coordinator 0.10.0: the coordinator attaches what can change an epic's scope (another team's PR, a pipeline, a
16
+ planning page) as context, a PR by its URL and the rest through a small script of its own, instead of polling it;
17
+ each script source asks you first.
18
+
19
+ ### Changed
20
+
21
+ - Peers: a message Claude or Codex starts on its own (or a `VERDICT OK` closer) while chi's prompt cache has gone cold
22
+ no longer wakes chi to re-read the whole conversation at the write price: it waits as a note for your next message,
23
+ the say's line says `held: chi's cache is cold`, the chip `held · cold`. An answer chi asked for still wakes it. Only
24
+ where chi's requests carry cache breakpoints (Claude models remotely), past `cache.ttl` since the last turn, and on
25
+ a conversation over 20,000 tokens.
26
+ - Peers: when chi's model sends to a peer it hasn't exchanged anything with for 30 minutes (`peer.quiet_minutes`, 0
27
+ turns it off), you are asked first ("Claude last heard from chi 2 h ago: its session may be cold. Send?") in a turn
28
+ you started from the web or a TUI; in a schedule's, a delegate's or a wake turn the send is refused at once and the
29
+ model told you decide. A `/claude …` you type never asks, and the pairing stays.
30
+ - Peers: a peer's message cut at 4 KiB in a continue's note now says how chi reads the rest (`claude_read` with the
31
+ previous session as its box) instead of pointing at `chi peer ls`, which never printed it.
32
+ - Peers: `peer.turns` counts across a worker restart, so a peer that speaks every 40 minutes is held after its wakes
33
+ as one that speaks every minute is.
34
+ - Peers: a continue takes the Claude or Codex pairing along, and the peer does nothing: no `moved` message, no pair
35
+ script, no turn of its own spent on it. chi's next send names the new id; a `chi peer say`, `pair`, `unpair` or `ls` to
36
+ the old id runs on the new session, and the say's line ends `session continued as <id8>: answer there`. A chain an
37
+ older chi continued still refuses the say, naming the new id. Run `chi update`: claude-peer 0.8.0 and codex-peer
38
+ 0.7.0 (then `/claude install-skill` or `/codex install-skill`, Replace): the chi-peer skill says its answer from a
39
+ file, so a say refused with "try again" is run again without writing the answer twice.
40
+ - The thin-client docs' iOS Shortcut recipe is checked on an iPhone: a JSON request body, Pick's steps spelled out
41
+ and the accepted `request_id` key formats.
42
+ - A participant's turn can no longer list the owner's sessions or reminders or read the session's attached context
43
+ (`list_sessions`, `list_reminders`, `context_read`); every built-in tool is classified for a participant's turn, so
44
+ a new one can't slip through unexamined.
45
+ - chi web: a peer's answer starts closed, one row with the peer, its verdict, its summary and its length (a tap opens
46
+ it), and every delegate report starts closed, a short one too.
47
+ - chi web: delegate reports, peers' answers and background notes side by side show as one closed line, "1 report ·
48
+ Claude: changes · 3 notes"; a tap on a segment shows those rows under it.
49
+ - chi web: a finished turn's steps join that line as "N calls" when a report or a peer's answer is in it ("1 report ·
50
+ Claude: changes · 2 calls"); a tap shows the steps row as before, the working set's footprint in it. A typed turn's
51
+ steps, also next to its notes, and cancelled or failed steps look as before. At a narrow width the line cuts the
52
+ notes first, then the calls, then the reports, then the peers, one at a time.
53
+
54
+ ### Fixed
55
+
56
+ - A send answered `not_found` while another session is open now keeps the line in the new-session draft and names
57
+ the gone session in a toast instead of losing it to the draft sweep; the toast stays until you dismiss it.
58
+
59
+ Update with `chi update` (claude-peer 0.8.0, codex-peer 0.7.0, coordinator 0.10.0, mcp 0.9.4).
60
+
11
61
  ## [0.192.0] - 2026-11-28
12
62
 
13
63
  ### Added
@@ -7024,7 +7074,8 @@ and long-lived sessions.
7024
7074
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
7025
7075
  hotkey panel that send selected text or the clipboard to your sessions.
7026
7076
 
7027
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.192.0...HEAD
7077
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.193.0...HEAD
7078
+ [0.193.0]: https://github.com/dm1try/samagotchi/compare/v0.192.0...v0.193.0
7028
7079
  [0.192.0]: https://github.com/dm1try/samagotchi/compare/v0.191.0...v0.192.0
7029
7080
  [0.191.0]: https://github.com/dm1try/samagotchi/compare/v0.190.1...v0.191.0
7030
7081
  [0.190.1]: https://github.com/dm1try/samagotchi/compare/v0.190.0...v0.190.1
data/docs/architecture.md CHANGED
@@ -520,8 +520,8 @@ model: [internals/remote-sessions.md](internals/remote-sessions.md).
520
520
  | `POST /api/sessions/:id/context/:name/push` | owner | `text`, `summary`, `wake`, `hint` (a source's JSON output, checked the same way) | 200 `{status: pushed, name, before, revision, changed}` | 404 `not_found`; 409 `not_push`; 410 `context_continued` (`next_id`, `in_flight` while its continue runs); 423 `context_busy` (another change holds its transition lock); 400 `invalid_text` |
521
521
  | `GET /api/sessions/:id/peers` | owner | | 200 `{peers: [{name, label, paired_at, from, address, can_send, messages, exchanges}]}`: one row per mailbox folder, its newest 20 messages with their receipts and `words`, last 20 joined exchanges, newest first; no text; files only ([internals/peers.md](internals/peers.md)) | 404 `not_found` |
522
522
  | `GET /api/sessions/:id/peers/:name/messages/:serial` | owner | | 200 the message (its text) and its receipt | 404 `no_message`; 400 `invalid_peer` |
523
- | `DELETE /api/sessions/:id/peers/:name` | owner | | 200 `{unpaired}`: the pairing ends, its messages stay | 400 `invalid_peer` |
524
- | `POST /api/sessions/:id/peers/:name/pair`, `…/say` | owner | pair: `address`, `from`; say: `text`, `summary`, `wake`, `re`, `wait` (≤ 30: the server waits for the receipt) | pair 200 `{status: paired, link}`; say 200 `PeerSay` and its `line` | 409 refused (`continued` + `next_id` and `in_flight` while its continue runs, `busy` (a say adds `detail`), `old_worker`, …, the same shape); 400 bad name, text or wait |
523
+ | `DELETE /api/sessions/:id/peers/:name` | owner | | 200 `{unpaired, forwarded_to}`: the pairing ends (a continued session's live link's too, named), its messages stay | 400 `invalid_peer` |
524
+ | `POST /api/sessions/:id/peers/:name/pair`, `…/say` | owner | pair: `address`, `from`; say: `text`, `summary`, `wake`, `re`, `wait` (≤ 30: the server waits for the receipt) | pair 200 `{status: paired, link, forwarded_to}` (a continued session's live link it paired); say 200 `PeerSay` (`forwarded_to` likewise) and its `line` | 409 refused (`continued` + `next_id` and `in_flight` while its continue runs, `busy` (a say adds `detail`), `old_worker`, …, the same shape); 400 bad name, text or wait |
525
525
  | `DELETE /api/sessions/:id/context/:name?own=1` | owner | | 200 `{status: detached}`: the session's own only | 409 `project_source` (chi context rm's words); 404 |
526
526
  | `POST /api/sessions/:id/stop` | owner | `wait?` (seconds, capped at `SessionManager::STOP_WAIT`, 10: `chi --remote NAME sessions stop` sends it) | 200 `{status: stopped, session_id, released}`: `released`, whether the worker let go within the wait (without one `STOP_WAIT_SECONDS`, 2 s: the page's Stop) | 409 `owned_by_tui` |
527
527
  | `DELETE /api/sessions/:id?force=` | owner | `force=true` stops a live worker first (the page sends it) | as before | 409 `worker_running` without it |
@@ -682,7 +682,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
682
682
  | Session file | `session.rb` (`Session`, `Session::FIELDS`), `session_field.rb` (`SessionField`), `session_paths.rb` (`SessionPaths`), `session_setup.rb` (`SessionSetup`) | A session's `<uuid>.json`: one `SessionField` row per key (default, cast, what the file gets; the codec on its type), from which `Session.new`, `.from_h` and `#to_h` are built; `SessionPaths` is where the file and the session's dir are and the id rule, a leaf `Session` extends (so `ArchiveStore` and `ContextSources` name no `Session` constant; both still require session.rb at load); `SessionSetup` the settings a fork and a continue carry (`.of`), applied by member name; every new-session request (chi's run flags, the one-shot, `chi send --new`, chi web's create) builds its setup with `SessionSetup.from_request`, and `spec/session_setup_entrypoints_spec.rb` holds each entrypoint's cell for each member. See [sessions.md](sessions.md#session-file). |
683
683
  | Session config (`--set`) | `session_config.rb` (`SessionConfig`, `SessionConfig::Settings`) | A session's own settings as one value (`Session#settings`, `SessionSetup#settings`): `core`, the `--set KEY=VALUE` values of the core keys marked `session: true` (`Config::Entry`), typed by `Config.coerce!` and read first through `Config.get(key, session:)` (`RecapSetup`; `Engine#session=` rebuilds the recap job, `IdleScheduler#replace_job`), file key `config_settings`; `bundles`, the `--set BUNDLE.KEY=VALUE` values, checked against the manifest's `session_settings:`, laid over `bundles: <name>:` in `ctx.settings` ([plugins.md](plugins.md)), file key `bundle_settings`. `SessionConfig.clash` refuses a bundle setting named like a core one (install, `chi bundle check`). See [configuration.md](configuration.md#per-session-settings). |
684
684
  | Plugin API | `plugin/api.rb` (`Plugin::Api`), `plugin/tool_spec.rb` (`Plugin::ToolSpec`: a checked tool declaration, how it is registered), `plugin/loader.rb`, `plugin/context.rb` (`ctx`), `plugin/http.rb` + `plugin/http_transport.rb` (`ctx.http`), `plugin/http_stream.rb` (`ctx.http.stream`) + `plugin/sse_reader.rb`, `plugin/http_errors.rb`, `plugin/secrets.rb` (`Plugin::Secrets`, `ctx.secrets`) + `plugin/sign_in.rb` (`Plugin::SignIn`, `ctx.sign_in`), `plugin/card.rb` (`Plugin::Card`) | What a bundle's plugin registers: tools, commands, annotation actions, hooks, services, toolkits, peer sources; what its handlers get as `ctx` ([plugins.md](plugins.md)). |
685
- | Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`), `plugin/peers.rb` (`ctx.peers`) | What claude-peer and codex-peer share (the send and read tools, the command, the cards, payloads, telling the peer a continue's new id); each bundle's subclass sets its strings and transport ([bundles.md](bundles.md#the-claude-peer-bundle)). |
685
+ | Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`), `plugin/peers.rb` (`ctx.peers`) | What claude-peer and codex-peer share (the send and read tools, the command, the cards, payloads); each bundle's subclass sets its strings and transport ([bundles.md](bundles.md#the-claude-peer-bundle)). |
686
686
  | Peers | `peer_mailbox.rb` (`PeerMailbox`: the peer's side, `mailbox/<id>/<peer>/`), `peer_receipts.rb` (`PeerReceipts`: chi's side), `peer_registry.rb` (`chi.peer`), `peer_note.rb`, `peer_say.rb`, `peer_command.rb` (`chi peer`), `peer_roster.rb`, `peer_continue.rb`, `worker_inbound/mail.rb` (`absorb_mail`), `web/peer_routes.rb` | A peer agent's messages: one file each, taken by the worker in order as its notes, a receipt each, the say's line ([internals/peers.md](internals/peers.md)). |
687
687
  | Shipped bundles | `bundles/` (`mcp`, `github-pr`, `loop-guard`, `skills`, `source-links`, …) | Bundles that ship with chi. |
688
688
  | Hooks | `hooks/registry.rb` (`Hooks::Registry`), `hooks/loader.rb`, `hook_routes.rb` (`HookRoutes`), `event_routes.rb` (`EventRoutes`) | Hook registration and dispatch; what a hook or plugin does beyond reading its event (notice, question, stop, steer) routed to the UIs (cards and notices through one set of routes) ([hooks.md](hooks.md)). |
data/docs/bundles.md CHANGED
@@ -1033,6 +1033,19 @@ replies wouldn't come back by themselves there.
1033
1033
  - **Resume.** A new coordinator session (or one asked "where were we?")
1034
1034
  reads the open handoff, checks it against git and the session list (git
1035
1035
  wins; mismatches are reported) and goes on from the first open step.
1036
+ - **Watching what can change the scope** (0.10.0). When the plan or you name
1037
+ something outside the branches that can change mid-epic (another team's
1038
+ PR, an issue, a pipeline, a planning page), the skill has the coordinator
1039
+ attach it as [context](context.md) instead of polling it with reminders or
1040
+ schedules: a PR as `chi context add <PR URL>` (the github-pr bundle), the
1041
+ rest through a script of its own in `~/.local/share/chi-watch/<epic-slug>/`
1042
+ (stable text, a summary in its own words, a wake only for a change that
1043
+ can move the scope) added with `chi context add NAME --cmd …`. Each `--cmd`
1044
+ source asks you first (`chi-context-cmd`), every time; a refusal is left
1045
+ as it is. On a change it tells you what it means for the plan and proposes
1046
+ the next step without starting it. The names go into the handoff
1047
+ ("Watching: …"). A source is fetched only while the session's worker is
1048
+ up: nothing is watched once it has exited or been stopped.
1036
1049
  - **`/coordinate <goal>`** sends this session a turn asking the model to
1037
1050
  follow the skill for the goal (when the session can't take a message, as
1038
1051
  in a `--non-interactive` one-shot, it shows the text to send yourself). Asking "do this in parallel" works too: the index line leads
@@ -1145,7 +1158,21 @@ Claude pairs; without one the bundle costs one tool declaration.
1145
1158
  word: `ok`, `changes`, `unsure`), `answered after 6m`, or `not sent` (the
1146
1159
  send didn't go out); a tap on an answered one jumps down to the answer. The
1147
1160
  row's line of advice to the model is its hover instead. The answer stays
1148
- where it arrived, as a bubble from Claude: "Claude answered", the send it
1161
+ where it arrived, closed to one row, `Claude changes <its summary> 21
1162
+ lines` (the verdict's word, the summary without its `VERDICT` mark, else
1163
+ the first line of its text, and the length of Claude's text; on a phone the
1164
+ summary is cut short, the length stays). A tap opens it, a second closes
1165
+ it; this browser remembers which you opened, per session, and a jump to it
1166
+ (the send's pill, a claim link) opens it. Open, the row stays its top
1167
+ line and Claude's text and "what chi told the agent" are under it. Where
1168
+ An answer next to other agent-to-agent text (a delegate report, another
1169
+ peer's answer, a background note) joins their one line, `1 report ·
1170
+ Claude: changes · 3 notes` (`Claude ×2` for two of its answers, `Claude
1171
+ answered` without a verdict): a tap on `Claude: changes` shows its row under
1172
+ the line, a tap on the row opens its text; a reload shows the line closed
1173
+ again. Where
1174
+ it has no row (in the running turn, before it ends) it is a bubble from
1175
+ Claude: "Claude answered", the send it
1149
1176
  answers (a tap jumps back up to that row, opening a folded turn), its
1150
1177
  verdict (`VERDICT OK` with "round closed" when Claude agreed), its summary,
1151
1178
  the answer's text under it (rendered as markdown), and chi's instruction to
@@ -1217,7 +1244,10 @@ Claude pairs; without one the bundle costs one tool declaration.
1217
1244
  chi fixes what Claude flagged or disagrees and sends again, up to
1218
1245
  `peer.turns` (3) wake turns in a row, and a `VERDICT OK` answer wakes chi
1219
1246
  once to close the round (carry on, or tell you what was agreed). Only a
1220
- message you type in the web or a TUI starts the count again.
1247
+ message you type in the web or a TUI starts the count again. A message
1248
+ Claude starts while chi's cache is cold waits for your next message
1249
+ ([peers.md](peers.md#a-cold-cache)), and a send the model starts after
1250
+ 30 quiet minutes asks you first ([peers.md](peers.md#quiet-pairings)).
1221
1251
  - **The skill.** `skill_claude_peer` (system scope) tells the model to send
1222
1252
  only when you ask or to reply in a peer turn, to pick the part rather than
1223
1253
  the session, not to wait or poll, and how to read Claude's answer in its
@@ -1270,24 +1300,14 @@ Claude pairs; without one the bundle costs one tool declaration.
1270
1300
  session (sshd makes it the user's, mode 0600 by default): fine on your own
1271
1301
  machine or pod, not a shared host. Codex has no socket: codex-peer has no
1272
1302
  `pair-remote`.
1273
- - **A continue.** The pairing and the mailbox stay with the old session when
1274
- you continue it ([peers.md](peers.md#continuing-a-session)). The new
1275
- session's worker posts Claude one message, from a quiet init task, to the
1276
- socket the old session's pairing names:
1277
-
1278
- ```
1279
- chi <old> · moved · continued as <new id>
1280
- This chi session was continued as <new id>. Pair with <new id> the way you paired with <old>, then answer there (chi peer say claude <new id> …).
1281
- ```
1282
-
1283
- Claude's skill pairs again with the new id the same way it paired before
1284
- (the same `CHI_REMOTE`; over SSH, `pair-remote` with the new id). It is
1285
- posted once (a marker under the bundle's `sessions/<id>/`, so a worker
1286
- restart doesn't post it again); a post that fails (that Claude session
1287
- ended) is logged and dropped. An answers-only pairing has no address to
1288
- post to: Claude's next say to the old id is refused with the new one
1289
- (`this session was continued as <id>`), and the skill pairs again and says
1290
- the answer there. What Claude said that the old session hadn't read
1303
+ - **A continue.** The pairing follows the chain
1304
+ ([peers.md](peers.md#continuing-a-session)): the continue copies it to the
1305
+ new session, Claude is told nothing, and chi's next send names the new id
1306
+ in its header. A say to the old id goes to the new session, its line ending
1307
+ `session continued as <id8>: answer there`. Over SSH the forwarded socket
1308
+ keeps the old id's name and still works. A chain an older chi continued has
1309
+ no copy: the say is refused (`this session was continued as <id>`), and the
1310
+ skill pairs again there. What Claude said that the old session hadn't read
1291
1311
  reaches the new one as one note.
1292
1312
  - **Asking first.** The tool has no `targets:`, so guardrails match it by name
1293
1313
  only: to be asked before each send, add a rule ([Rules in
@@ -1417,15 +1437,12 @@ skill install card, the web's linked send and answer: "Codex answered") works th
1417
1437
  guardrails rule with `tool: codex_send` (see the claude-peer section).
1418
1438
  - **The peer loop** works as claude-peer's: Codex is declared a peer
1419
1439
  (`chi.peer codex`), its messages wake chi up to `peer.turns` turns in a
1420
- row, and `VERDICT OK` wakes chi once to close the round; `codex_read`
1421
- reads a long message. Needs the chi that has the mailbox; an older
1440
+ row, and `VERDICT OK` wakes chi once to close the round, with the same
1441
+ cold hold and quiet ask; `codex_read` reads a long message. Needs the chi that has the mailbox; an older
1422
1442
  codex-peer fails to load there with "upgrade this bundle".
1423
- - **A continue** works as claude-peer's: the new session queues Codex the
1424
- `moved` message on the thread the old session's pairing names, once, and
1425
- Codex's skill pairs again with the new id (the same `CHI_REMOTE`, if any).
1426
- An answers-only pairing has no address: Codex pairs again when its next
1427
- say is refused. A closed Codex session still takes the message; it waits
1428
- for `codex resume` there.
1443
+ - **A continue** works as claude-peer's: the pairing is copied to the new
1444
+ session, Codex is told nothing, and its say to the old id goes to the new
1445
+ one.
1429
1446
 
1430
1447
  ## The ruby bundle
1431
1448
 
data/docs/cli.md CHANGED
@@ -22,7 +22,7 @@
22
22
  - `chi note [--source NAME] [-m TEXT] (ID|PREFIX)... | --all` — add a context note (TEXT or stdin) to sessions: background the model sees on its next turn; it starts no turn (see [Sessions: Context notes](sessions.md#context-notes))
23
23
  - `chi broadcast [-m TEXT] [--all] [--dry-run]`, `chi broadcast log [--last N] [--format json]`, `chi broadcast deliver BROADCAST_ID (ID|PREFIX)...` — share one piece of information (TEXT or stdin) with every session it may concern, as a context note from `broadcast` (see [Broadcast](broadcast.md))
24
24
  - `chi context <add|push|ls|show|refresh|rm|mute|unmute> …` — attach live external text to sessions (a command chi runs every so often, or text pushed in); the model gets a short note when it changes and reads it with `context_read`; `chi context add <URL>` attaches a GitHub PR with the github-pr bundle; `chi context push NAME -m TEXT` (the long form is `--message TEXT`) gives a `--push` source its new text, read from stdin when no `-m` is given (see [Attached context](context.md))
25
- - `chi peer pair|unpair|say|ls …` — a peer agent's side of a session (a Claude Code or Codex session paired with it; see [Peers](peers.md)): `pair NAME ID [--address ADDR] [--from TEXT]` pairs (refused for a continued session, naming its next id, and for a live worker older than the mailbox: restart it), `unpair NAME ID` ends the pairing (its messages stay), `say NAME ID (--wake|--nowake) [--summary TEXT] [--re REF] [-m TEXT] [--wait SECONDS]` leaves a message and prints what chi did with it (`#12 received · woke chi`, `held: … · waits for the user's next message`, `noted`, or why it can't say yet), `ls ID [--format json]` the session's peers, their messages and receipts. A refusal exits 1 (nothing written), a usage error 2; `--remote` runs it through that machine's chi web, which waits for the say
25
+ - `chi peer pair|unpair|say|ls …` — a peer agent's side of a session (a Claude Code or Codex session paired with it; see [Peers](peers.md)): `pair NAME ID [--address ADDR] [--from TEXT]` pairs (a continued session's chain's live link, named; refused for a live worker older than the mailbox: restart it), `unpair NAME ID` ends the pairing (its messages stay), `say NAME ID (--wake|--nowake) [--summary TEXT] [--re REF] [-m TEXT] [--wait SECONDS]` leaves a message and prints what chi did with it (`#12 received · woke chi`, `held: … · waits for the user's next message`, `noted`, or why it can't say yet), `ls ID [--format json]` the session's peers, their messages and receipts. A refusal exits 1 (nothing written), a usage error 2; `--remote` runs it through that machine's chi web, which waits for the say
26
26
  - `chi context report [--days N]` — the candidate judge's counts from `context_candidates.jsonl`: candidates proposed, mentioned, attached or declined by you; the judge's asks; what it would attach per threshold, and how that agrees with what you did (this machine only; see [The log and the report](context.md#the-log-and-the-report))
27
27
  - `chi send [-m TEXT] [--image PATH]... [--cut | --queue] [--as NAME] (ID|PREFIX)...` — send a message to sessions as if typed there (from an agent, as that agent: `--as NAME` or its marker, see [An agent's messages](sub-agent.md#an-agents-messages-driver-and-visitor); `--new --driver NAME` names a new session's driver): a turn starts (or a running one takes it at its next step; `--cut` asks it to cut long thinking for it; `--queue` runs it as a turn of its own after the running one, and `--queue --wait` waits for that turn's own answer); piped stdin goes above `-m` as quoted context, and `--image` attaches images (see [Sessions: Sending a message](sessions.md#sending-a-message)); to a session that was continued it goes to its chain's newest link (`3f9a1c2e → 7b2d41aa (continued) sent`; the old link stays archived; one being continued right now waits up to 10 s for its new link, then `refused: session 3f9a1c2e is being continued as 7b2d41aa-…; send again in a moment`), so a chain's first id is a stable address; `--new` starts a session with it instead (`--new --continues ID|last:ID` the next link of that session's chain, see [Session chains](sessions.md#session-chains)), and `--wait` prints the answer (`--wait ID` with no message waits for the next reply without sending — to an idle session whose last turn already ended, that ended turn's reply or end comes back; `--wait --turn T ID` with no message waits for exactly turn T, whether running, queued or last ended; `--format json` includes its `turn_id` when known, for waiting again after exit 3 or 4; exit 3 a question waits, its options on stderr; exit 4 `--timeout` passed with the turn still running; see [Starting a session](sessions.md#starting-a-session))
28
28
  - `chi answer ID --question QID (--option N|LABEL)... [--text T] [--timeout S] [--format json]` (or `--dismiss`) — answer the question a session waits on (the one `chi send --wait` exited 3 with), then wait and print what comes next as `chi send --wait` does: the reply (0), the next question (3), still running after `--timeout` (4). `--option` is 1-based or the label, repeated on a multi-select question; `--text` is free text, or a Deny's reason; `--dismiss` leaves it unanswered and the model finishes its reply. A question no longer open (the web answered first) isn't answered again: it waits for that turn's reply. An option the question doesn't offer exits 2; a worker that is gone exits 1 (`send the task again: chi send --wait -m "…" ID`). What a parent may pick follows `guardrails.parent_answers`, or the session's own `parent_answers` when stricter (`soft`, the default: a deny, a plain answer, Continue and "Allow once"; `standard`: no allow; `hard`: no Continue either), never a wider scope or an allow on chi's own config; a refused pick exits 1 with what to answer instead (a convention, not a security boundary; see [Guardrails](guardrails.md#answers-from-a-parent-agent))
@@ -531,8 +531,9 @@ fire twice.
531
531
 
532
532
  The model can register its own schedules with `schedule_task` (defaulting to the
533
533
  session it is in), list them with `list_schedules` and stop them with
534
- `cancel_schedule`; like `register_reminder`, these are owner-voiced tools, refused
535
- in a participant's turn.
534
+ `cancel_schedule`. A participant's turn is refused all three: like
535
+ `register_reminder`, `schedule_task` and `cancel_schedule` are owner-voiced, and
536
+ `list_schedules` reads the owner's schedules.
536
537
 
537
538
  ## Flags
538
539
 
@@ -1349,7 +1350,8 @@ first line of what a hook presented in its place, else its first heading,
1349
1350
  else its first line); click again to unfold. A delegate report's reply
1350
1351
  folds the same way, and so does a long prompt you sent (over the same
1351
1352
  threshold; its folded row shows its first line as typed). A delegate
1352
- report itself starts folded. Folding is this browser's choice, kept per session in
1353
+ report itself starts folded, a short one too, and so does a peer's answer
1354
+ (one row: the peer, its verdict, its summary and its length). Folding is this browser's choice, kept per session in
1353
1355
  localStorage (`chi_answer_fold:<session id>`, the last 200 folded answers and prompts;
1354
1356
  the keys of sessions gone from the list are dropped when the list loads);
1355
1357
  other viewers (a participant's browser too) are not affected. A jump into a
@@ -1361,10 +1363,22 @@ nothing, an objectives line and a plugin's nudge fold into one closed row where
1361
1363
  the first of them sits, "▸ 3 notes · claude-inbox, source-links, skills". A tap
1362
1364
  (or a click, Enter, Space) opens it and the items show under it as they are;
1363
1365
  another closes it. A warning among them marks the row with a yellow edge and
1364
- "⚠ 1", and it stays closed. Your prompt, the answer, a peer's answer and a note
1365
- that starts a turn stay as they are, and a time divider or a peer's answer
1366
- between two items gives each side a row of its own. The row isn't remembered:
1367
- a reload or another session shows it closed again.
1366
+ "⚠ 1", and it stays closed. Your prompt, the answer and a note that starts a
1367
+ turn stay as they are, and a time divider between two items gives each side a
1368
+ row of its own. The row isn't remembered: a reload or another session shows it
1369
+ closed again.
1370
+
1371
+ Delegate reports and peers' answers next to each other and to those notes are
1372
+ one line too, a segment per kind: "1 report · Claude: changes · 3 notes ⚠ 1"
1373
+ ("Claude ×2" for two of one peer's answers, "Claude answered" without a
1374
+ verdict). A tap on a segment shows that kind's rows under the line, one compact
1375
+ row each ("check-in 50 tool calls, no answer yet", "child ab12cd The guard is in. 17 lines"), one segment at a
1376
+ time; a tap on a row opens its text. A report
1377
+ or a peer's answer alone keeps its own row, notes alone their notes row. What
1378
+ ends a line: your prompt, chi's answer, a card, a time divider. On a phone it
1379
+ stays one line, the notes segment cut short first. The line isn't remembered
1380
+ either: a report or an answer you opened shows open again once you tap its
1381
+ segment.
1368
1382
 
1369
1383
  **Revise** rewrites an answer and stacks the versions. A finished turn's
1370
1384
  final answer has a Revise button on its bottom edge (on hover; always shown
@@ -167,7 +167,7 @@ or `chi web` restart.
167
167
  | `toolkit.kits`, `execute.description`, `llm_context.policy` | Worker start | These are held by the engine's toolkit or tool registry. |
168
168
  | `toolkit.suggest.mode`, `toolkit.suggest.threshold`, `toolkit.suggest.defer_turns`, `toolkit.suggest.defer_tokens` | Worker start | Suggestion settings are config-only and are resolved when the worker runs its audit or on-mode ask. |
169
169
  | `skip_agents_md` | Prompt rebuild | A running engine caches its built prompt; a new worker or `/model` rebuild uses the changed value. |
170
- | `context.*` except `context.every_seconds`, `peer.turns`, `objectives.*`, `llm_context.*` except `llm_context.policy`, `steer.cut_after`, `memory.index_warn_tokens`, `memory.entry_warn_tokens`, `status.line`, `web.participants.*` | Next matching turn, display, poll or write | Readers resolve these settings when they perform that operation. Session-specific LLM context and thinking values remain saved in the session. A participant's grant keeps the expiry and cap it was issued with; `web.participants.*` is what the next invite gets, and the cap and queue of a grant from before caps. |
170
+ | `context.*` except `context.every_seconds`, `peer.turns`, `peer.quiet_minutes`, `objectives.*`, `llm_context.*` except `llm_context.policy`, `steer.cut_after`, `memory.index_warn_tokens`, `memory.entry_warn_tokens`, `status.line`, `web.participants.*` | Next matching turn, display, poll or write | Readers resolve these settings when they perform that operation. Session-specific LLM context and thinking values remain saved in the session. A participant's grant keeps the expiry and cap it was issued with; `web.participants.*` is what the next invite gets, and the cap and queue of a grant from before caps. |
171
171
  | `context.every_seconds` | Next context poll | The poller checks it for each source that has no explicit interval. |
172
172
  | `guardrails.*` | Next tool call or approval | Guardrail rules and disable lists are reloaded when the config file changes; rule settings take effect on that evaluation. `guardrails.parent_answers` is checked when a parent answers a question. |
173
173
  | `system_one.host`, `system_one.model`, `system_one.timeout_ms`, `system_one.runs`, `system_one.judgments` | Next tool call or approval | Each ask reads them. |
@@ -2365,7 +2365,8 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2365
2365
  | `context.status_thresholds` | `20,40,60,80` | yes | Percentages that put the estimate into a bucket; the rise into a guidance bucket (from the second up) leaves the model its own `[CONTEXT: …]` line, and the bucket decides the guidance. |
2366
2366
  | `context.every_seconds` | `300` | | How often an attached context source's command runs when it has no `--every` (seconds, at least 30). See [Attached context](context.md). |
2367
2367
  | `context.wake` | `true` | yes | A source whose update says `wake: true` may start a turn in a live, idle session (one per source per 10 minutes, within `session.max_wakes`); so may a session's pushed source's first push. `false`: updates wait as notes for the next turn. Attached context's only: a peer's messages have `peer.turns`. See [Waking](context.md#waking). |
2368
- | `peer.turns` | `3` | yes | Wake turns in a row a peer agent's messages may start (`chi peer say --wake`, a peer a loaded bundle declares), with no message typed in the web or a TUI in between (`chi send` doesn't count); within `session.max_wakes`. Then messages wait as notes, the say's line says so (`held: … (peer.turns)`), and the UIs hear it once. A message whose summary ends its verdicts with `VERDICT OK` wakes once to close the round, counted toward `session.max_wakes` only. `0`: a peer's message never wakes chi. Replaces `context.peer_turns` (no alias: an old key is ignored). See [peers.md](peers.md). |
2368
+ | `peer.turns` | `3` | yes | Wake turns in a row a peer agent's messages may start (`chi peer say --wake`, a peer a loaded bundle declares), with no message typed in the web or a TUI in between (`chi send` doesn't count; the count survives a worker restart); within `session.max_wakes`. Then messages wait as notes, the say's line says so (`held: … (peer.turns)`), and the UIs hear it once. A message whose summary ends its verdicts with `VERDICT OK` wakes once to close the round, counted toward `session.max_wakes` only. `0`: a peer's message never wakes chi. Replaces `context.peer_turns` (no alias: an old key is ignored). See [peers.md](peers.md). |
2369
+ | `peer.quiet_minutes` | `30` | yes | Minutes with no exchange between chi and a peer (no send to it, no message from it, no pairing; the link a continue came from counts too) after which the pairing is dormant: the peer's session may be cold. A send the model starts then asks you first (Send / Don't send) in a turn you started from the web or a TUI, and is refused at once in any other turn (a schedule's, a delegate's, a wake turn, `chi send`'s), the model told that you decide; "Don't send" holds for the rest of the turn. A `/claude …` or `/codex …` you type never asks. The status card says `quiet 2 h: a send from the model asks first`. The pairing stays. `0`: never asks. See [peers.md](peers.md#quiet-pairings). |
2369
2370
  | `context.candidates.mode` | `off` | | The candidate judge: `off` (the default: no conversation text goes to a System 1 host), `audit` (asks System 1 whether the session's work is about each proposed candidate and logs it in `context_candidates.jsonl`; attaches nothing), `on` (the same asks, acted on: attached at `threshold`, a card from `offer_threshold`; see [On mode](context.md#on-mode)). Its host and model are `system_one.host` / `.model`. config.yml only. See [The judge](context.md#the-judge). |
2370
2371
  | `context.candidates.threshold` | `0.8` | | The probability at which the judge attaches a candidate in on mode (a judged line's `would: attach`). config.yml only. |
2371
2372
  | `context.candidates.offer_threshold` | `0.6` | | The probability from which on mode shows the candidate's card, once (`would: offer`, below `threshold`). config.yml only. |
@@ -2390,7 +2391,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2390
2391
  | `memory.read_max_chars` | `0` | yes | The most characters one `memory_read` result holds. `0`: no fixed cap, a memory is read whole (`max_tool_output_chars` does not apply to `memory_read`, in any form: one name, a comma list, a blank name). A positive value cuts a longer result and ends it with `[cut: N of M chars; the rest is in the memory's .md file in <dir>: read it with start_line]`. `memory:` is its own section. See [Memory](memory.md). |
2391
2392
  | `max_tool_output_chars` | `10000` | yes | Characters of each tool output kept in the conversation (both loops). A longer one is cut: an `execute` result keeps its first and last lines with a gap line between them and is saved whole in the session's folder (`sessions/<id>/tool_output/`; the gap line names the file, and the model reads it there instead of running the command again); any other tool's keeps its head and ends with `[cut: N of M chars; read it in parts]`. `memory_read` is the exception: `memory.read_max_chars` caps it. See [Tool output guardrails](internals/tool-output-limits.md#the-runners-cut-max_tool_output_chars). A top-level key (see below). |
2392
2393
  | `cache.warmup` | `auto` | | `auto`: after a turn, send the next turn's prompt (up to the next message) to a local llama.cpp host on the native loop, so the next turn prefills only its message; never a remote or `api: openai` host. `off`: never. See [prompt caching](internals/prompt-caching.md#the-turn-end-warm-up). |
2393
- | `cache.ttl` | `5m` | | How long Anthropic keeps the prompt-cache breakpoints of a Claude model on a remote host: `5m` (Anthropic's default) or `1h`. A 1h cache write costs 2× the input price (5m: 1.25×), a read the same 0.1×. See "Remote or local". |
2394
+ | `cache.ttl` | `5m` | | How long Anthropic keeps the prompt-cache breakpoints of a Claude model on a remote host: `5m` (Anthropic's default) or `1h`. A 1h cache write costs 2× the input price (5m: 1.25×), a read the same 0.1×. It is also how long after a turn a peer's own message counts as finding the cache cold ([peers.md](peers.md#a-cold-cache)). See "Remote or local". |
2394
2395
  | `cache.key` | `off` | | `session`: send the session id as `prompt_cache_key` to OpenAI's API and OpenRouter, which route and cache by it; no other host gets it. `off`: none. |
2395
2396
  | `retry.max` | `5` | yes | See "Llama Network Retry Behavior". |
2396
2397
  | `retry.base_delay` | `0.5` | yes | |
data/docs/context.md CHANGED
@@ -234,8 +234,9 @@ summary, the hint's link, the text and detach (or mute here, for a project
234
234
  source). The web attaches nothing itself: `chi context add <URL>` does.
235
235
  A paired peer has a chip of its own there, drawn first, and its messages are
236
236
  bubbles from the peer ([peers.md](peers.md), [bundles.md](bundles.md#the-claude-peer-bundle)). A context note sits in
237
- chi web's closed notes row ([cli.md](cli.md#web-markdown-rendering)) unless it starts a turn: a wake's note is that turn's
238
- opening and stays a bubble.
237
+ chi web's closed notes row ([cli.md](cli.md#web-markdown-rendering)), or in the closed line it shares with the
238
+ delegate reports and peers' answers next to it, unless it starts a turn: a wake's note is that turn's opening and
239
+ stays a bubble.
239
240
 
240
241
  ## Waking
241
242
 
@@ -345,8 +346,8 @@ An archived session that nobody continued takes pushes as before; a schedule's a
345
346
 
346
347
  ### Peers and a continue
347
348
 
348
- A peer's pairing and mailbox stay with the old session; the peer is told the
349
- new id and pairs again, and what it said that the old session hadn't read
349
+ A peer's pairing follows the chain (the continue copies it) and its messages
350
+ stay with the old session; what it said that the old session hadn't read
350
351
  reaches the new one as one note: [peers.md](peers.md#continuing-a-session).
351
352
 
352
353
  ## Candidates
@@ -615,7 +616,9 @@ that way for simplicity). Whoever can define a source can run code later, so:
615
616
  in every mode, once at a time (the guardrails bundle's `chi-context-cmd`
616
617
  rule); a parent agent can't approve it for a child. A URL resolved by an
617
618
  installed bundle and `push` aren't asked about: their command is the
618
- bundle's, or there is none.
619
+ bundle's, or there is none. The [coordinator skill](bundles.md#the-coordinator-bundle)
620
+ is a shipped text that has the agent attach sources itself (a script of its own under
621
+ `~/.local/share/chi-watch/`), so its watches ask here.
619
622
  - The file tools can't write the store: `<state dir>/context/` is a protected
620
623
  path (denied), and a shell command that names it asks (`shell-touches-chi`).
621
624
  - The web adds URLs only.
data/docs/guardrails.md CHANGED
@@ -561,14 +561,19 @@ message:
561
561
  `batch`;
562
562
  - owner-voiced tools, which act in the owner's name beyond the turn:
563
563
  `delegate` and any `delegate_*` tool, `register_reminder`,
564
- `cancel_reminder`, `schedule_task`, `list_schedules`, `cancel_schedule`
564
+ `cancel_reminder`, `schedule_task`, `cancel_schedule`
565
565
  (a durable schedule outlives the session and fires on this machine),
566
- `send_note`, `forget_outputs`, `task_create`,
566
+ `send_note`, `ask_session`, `forget_outputs`, `task_create`,
567
567
  `task_stop`, `find_tools` (it loads tools into the session), `objectives`
568
568
  (a move on the owner's list), and
569
- `memory_write` (a memory reaches the owner's later sessions); and the tools
569
+ `memory_write` (a memory reaches the owner's later sessions); the tools
570
570
  that read the owner's background tasks and their output, `task_wait`,
571
- `task_get`, `task_list` (a pair turn starts none);
571
+ `task_get`, `task_list` (a pair turn starts none); and the ones that read
572
+ the owner's other sessions, reminders and schedules and the session's
573
+ attached context: `list_sessions`, `list_reminders`, `list_schedules`,
574
+ `context_read`. Every built-in tool has its place in
575
+ `PairBoundary::TOOL_CLASSES` (a spec fails on one that hasn't); a plugin's
576
+ or an MCP server's tool goes on to the path and command checks;
572
577
  - `ask_user_question`, with the advice to ask in the reply: nobody on the
573
578
  participant's side answers a card.
574
579
 
@@ -661,7 +661,9 @@ newer worker; never driven, `wake` answers 409 `worker_newer`); else `Live` (its
661
661
  holder as the caller already read it (nil: free), so one read serves a summary and its status. `WorkerLink.client` is
662
662
  the Live's client or nil; `WorkerLink.await` polls for a new worker's Live (an `until:` check tells a restart's
663
663
  successor from the old worker); chi web's `App#worker_link` / `#await_worker_link` wrap them. The Bridge writes
664
- `pid` and `protocol` with its port and removes its sidecar on stop only when the file still carries its epoch.
664
+ `pid` and `protocol` with its port and removes its sidecar on stop only when the file still carries its epoch. When to
665
+ bump `protocol` (the owner's OK each time; additive changes never) is in docs/releasing.md, "Bumping
666
+ WorkerLink::PROTOCOL"; `spec/worker_link_contract_spec.rb` pins each protocol's sidecar keys, routes and features.
665
667
 
666
668
  The sidecar's `features` array is the worker's capability handshake: clients check a name rather than infer
667
669
  compatibility from its version. `Bridge::FEATURES` advertises:
@@ -23,7 +23,7 @@ read side, never the reverse.
23
23
  <system memories>/.bundles/ MemoryPaths.bundles_dir
24
24
  <name>/manifest.json the install record (Provenance#write, read as InstalledBundles::Record)
25
25
  <name>/manifest.yml the bundle's own manifest as installed (Provenance#write's manifest_from:), its sha
26
- the record's manifest_sha; a dev install links it to the source (DEV_SHA)
26
+ the record's manifest_sha; a dev install links it to the source (`InstalledBundles::Sha::DEV`)
27
27
  <name>/bases/ each file's base for the next upgrade's 3-way merge: as installed, or the
28
28
  bundle's own text after a merge
29
29
  <name>/incoming/ the bundle's text for each file marked conflict, until the file settles (Provenance:
@@ -67,7 +67,7 @@ read side, never the reverse.
67
67
  | `TextMerge` | the text merge: `.merge(base:, ours:, theirs:)` → a `Result` (`status` `:clean` with `text`, `:conflict` with `hunks`, `:failed` with `why`). `git merge-file -p --diff3 --marker-size=20` on temp copies in a temp cwd, with every `GIT_*` that points at a repository or a config unset or at `/dev/null` (it can run inside another tool's hook). git isn't a runtime dependency: none on PATH, or macOS's `/usr/bin/git` with no developer tools behind it (`.apple_stub?`, by `xcode-select -p`; running it pops a dialog), is `:failed`. So is a git past `TIMEOUT` (10 s; its process group is killed: this runs under `SystemBundle`'s lock), and any doubt about the answer: `min(hunks, 127)` against the exit status, a status over 127, a NUL in a side, marker lines that don't pair up (a user's line equal to one), a line no input holds, or an empty answer to non-empty inputs. `Scan` reads the output: a hunk unions (ours, then the entries of theirs that ours lacks) only when the last heading before it, at level 1 or 2 and outside code fences, HTML comments and any hunk, is titled exactly `Changelog` or `Change log`, with nothing but list entries (an item and its indented lines) since that heading and no fence or comment open, and base, ours and theirs each hold only list entries, with every base entry still on both sides: both only added. Any other hunk is a real conflict, and markers never leave the module. An entry is an item and the lines indented deeper under it, nested items too, and the union compares whole entries. `.changed_sections(base, theirs, ours)`: the headings of the sections the bundle changed and the file hasn't got, and whether text under no heading did, which is what names a miss: a conflict's hunks can't, since the whole file stays and the one hunk may be a Changelog line beside a whole new section. `Hunk#heading` counts the places under no heading |
68
68
  | `InstalledBundles::FileStanding` (installed_bundles/file_standing.rb) | the one owner of what chi says of an edited bundle file, used by every surface: `Behind` (`#state`, `#line`: `x.md stays behind 0.8.0: no merge possible (why); missed ## A, ## B, ## C and 2 more`, `would stay` in a dry run), `MergeNote`, `.merged_line`, `.no_merge` (for `LEGACY_BASE` it says chi can't tell whether the file holds edits), `.clauses` (a report's clauses for one bundle), `.behind_count`, `.stay_behind`, `.counts_sentence` (the push), `.still_behind`, `.text` (UTF-8, whatever a name or heading was tagged), `FORCE_TAKES`, `FORCE_MOVES`, `IN_THE_TRASH`. Behind means marked and bytes other than the mark's `incoming_sha` (`.behind?`, read by `InstalledBundles::Record#behind_files` and `Remerge` alike): a file brought level by hand isn't, a missing one is a missing file, and one that can't be read is. An older mark no retry has looked at reads `may be behind` (`Behind#unsure`, and the counts say so), and isn't behind at all when level with its recorded source on disk (`InstalledBundles::Record#behind_file?`). A new surface reads these and adds no wording |
69
69
  | `Remerge` | the retry at the same version, memory files only, for a file marked `conflict` (its `FileState` and `REMERGE` row; a `:decide` cell through `Merger::Upgrade#decision`): `#run(dry_run:)` → a `Result` (`merged`, `settled`, `stamped`, `behind`, `warnings`, `trash_copy`). It merges what merges and settles those entries (`Provenance#resolve_conflicts`, the index line refreshed), checking a merged incoming file against the manifest's sha256, in a dry run too. It leaves `version`, `installed_at` and the assets alone: the Installer would `rm_rf` guardrails, plugin and scripts under live sessions. Every file it leaves is in `behind`, with why: one not shipped now (`MemoryFiles.select`) keeps its mark, base and text; one whose `incoming_sha` isn't the shipped text (a checkout at one VERSION) is left alone, no git runs, and it reads as its mark says; a mark with no digest (older chi) is tried as well, and a real conflict then records it (`Provenance#refresh_marks`, which writes only when the mark would read differently, so a conflict at each start writes nothing). A mark whose digest matches is tried on every run, since the file or git may have changed. `noop` and `keep` settle quietly; `fast_forward` waits for the next upgrade, reading as behind until then; `install` is a missing file, which isn't behind, and a warning says so. A file it can't read or replace stays as it is, saying why. Called from `ShippedUpdate.plan_row`/`apply` (`chi update`) and `SystemBundle.sync`'s equal-version branch, under its lock (each chi start and `chi update`); a bundle chi doesn't ship retries through `chi bundle upgrade`. No marks: nothing is read beyond the record. One marked file costs one git run per Engine start, about 12 ms on the Studio (0.1 ms with none) |
70
- | `Provenance` | the `.bundles/<name>/` dir's write side (an `InstalledBundles::Dir`): `#write` the record + bases (its `files:` is the full list: a key left out is dropped, a nil value keeps the entry with no base; `marks:` are the files left behind, each a `FileStanding::Behind`, and `incoming_dir:` the bundle text each speaks of, recorded as `incoming_sha` and saved at `#incoming_path`; an older mark that stays keeps `legacy_base`), `#resolve_conflicts` (base to the incoming file, mark and its fields (`MARK_FIELDS`) and saved text gone; a file whose incoming copy is gone keeps both), `#refresh_marks` (what a retry found: why, missed, the digest and `legacy_base`, the saved text), `#note_merged` and `#clear_merge_notes(notes)` (`MERGE_NOTE_FIELDS`, kept through `#write`; the saved text is best effort, after the manifest, so it can't leave a plugin under the old record's sha; any other failure writing the record still can, until a retry), `#record` → `InstalledBundles::Record` (the Dir's). `#write(manifest_from: DIR)` keeps `DIR/manifest.yml` at `#kept_manifest_path` (written aside and renamed; for `dev:` a link to its realpath) and records `manifest_sha` (`FileDigest.sha256`, `DEV_SHA` for dev) and `installed_by` (this chi's VERSION); the Installer and `Profile.install` pass their source dir, and a write without it carries the existing record's two fields, the kept file left alone. The in-place edits (`#resolve_conflicts`, `#record_restored`, `#refresh_marks`, `#note_merged`, `#clear_merge_notes`) keep them. The record's mirror of the manifest keys (`requires_chi` … `setting_types`) is still written from the kwargs, exactly as before: an older chi sharing the memories dir (an old worker, chi web, gem or worktree) reads only the record, and without the mirror's `requires_chi` it would load a too-new bundle's plugin. A key a later manifest gains is never mirrored. Any chi without the kept manifest that rewrites a record drops `manifest_sha` and `installed_by` (it rebuilds the record from its own kwargs). `#adopt_manifest(dir, dry_run:)` heals such a record (`InstalledBundles::Record#manifest_unkept?`: no `manifest_sha`, or its file gone): when `dir` is the source of what's installed (its manifest names the bundle at the recorded version; each mirrored key, normalised as `#mirror_fields` records it (the one shape `#write` uses too), equals the record's, a key the record lacks being fine only when `BundleManifest::SINCE` has it, since an older chi couldn't have recorded it (a recorded hook doesn't count: retired); and every recorded plugin, hook, script, rule and unmarked memory sha is that of `dir`'s file; else the why names the key or file) it keeps `dir/manifest.yml` and records `manifest_sha`, nothing else (not `installed_at`, the mirror or `installed_by`); otherwise it returns why and writes nothing. Never for a dev record (its next `install --dev` links the file) |
70
+ | `Provenance` | the `.bundles/<name>/` dir's write side (an `InstalledBundles::Dir`): `#write` the record + bases (its `files:` is the full list: a key left out is dropped, a nil value keeps the entry with no base; `marks:` are the files left behind, each a `FileStanding::Behind`, and `incoming_dir:` the bundle text each speaks of, recorded as `incoming_sha` and saved at `#incoming_path`; an older mark that stays keeps `legacy_base`), `#resolve_conflicts` (base to the incoming file, mark and its fields (`MARK_FIELDS`) and saved text gone; a file whose incoming copy is gone keeps both), `#refresh_marks` (what a retry found: why, missed, the digest and `legacy_base`, the saved text), `#note_merged` and `#clear_merge_notes(notes)` (`MERGE_NOTE_FIELDS`, kept through `#write`; the saved text is best effort, after the manifest, so it can't leave a plugin under the old record's sha; any other failure writing the record still can, until a retry), `#record` → `InstalledBundles::Record` (the Dir's). `#write(manifest_from: DIR)` keeps `DIR/manifest.yml` at `#kept_manifest_path` (written aside and renamed; for `dev:` a link to its realpath) and records `manifest_sha` (`FileDigest.sha256`, `InstalledBundles::Sha::DEV` for dev) and `installed_by` (this chi's VERSION); the Installer and `Profile.install` pass their source dir, and a write without it carries the existing record's two fields, the kept file left alone. The in-place edits (`#resolve_conflicts`, `#record_restored`, `#refresh_marks`, `#note_merged`, `#clear_merge_notes`) keep them. The record's mirror of the manifest keys (`requires_chi` … `setting_types`) is still written from the kwargs, exactly as before: an older chi sharing the memories dir (an old worker, chi web, gem or worktree) reads only the record, and without the mirror's `requires_chi` it would load a too-new bundle's plugin. A key a later manifest gains is never mirrored. Any chi without the kept manifest that rewrites a record drops `manifest_sha` and `installed_by` (it rebuilds the record from its own kwargs). `#adopt_manifest(dir, dry_run:)` heals such a record (`InstalledBundles::Record#manifest_unkept?`: no `manifest_sha`, or its file gone): when `dir` is the source of what's installed (its manifest names the bundle at the recorded version; each mirrored key, normalised as `#mirror_fields` records it (the one shape `#write` uses too), equals the record's, a key the record lacks being fine only when `BundleManifest::SINCE` has it, since an older chi couldn't have recorded it (a recorded hook doesn't count: retired); and every recorded plugin, hook, script, rule and unmarked memory sha is that of `dir`'s file; else the why names the key or file) it keeps `dir/manifest.yml` and records `manifest_sha`, nothing else (not `installed_at`, the mirror or `installed_by`); otherwise it returns why and writes nothing. Never for a dev record (its next `install --dev` links the file) |
71
71
  | `InstalledBundles::Manifest` (installed_bundles/manifest.rb) | the one answer to "this installed bundle's manifest" (`InstalledBundles::Record#manifest`): requires_chi, trust_level, needs, the scripts' names, context providers, block renderers, pages (`pages:`, kept file only: never mirrored, so `[]` from the record), session settings and settings with their types, file descriptions, a profile's includes. Read from the kept `manifest.yml` (`origin: :kept`) when the record's `manifest_sha` is set and the file still has it (`InstalledBundles::Sha.matches?`, so a dev link is never checked), else from the record's `mirror` (`origin: :record`), in these cases: no kept file and no `manifest_sha` (a record from before chi kept it; no problem); no kept file, or something other than a file in its place, while `manifest_sha` is set (`:missing`); a kept file and no `manifest_sha` (a chi without the kept manifest rewrote the record: `problems["manifest.yml"] = :stale`); a kept file with another sha, or one that isn't a YAML mapping (`:edited`); the sha matches (`:kept`). `#standing` is that symbol, `#key_problems` the rest. The kept file is read by `BundleManifest.tolerant` key by key in a fixed order (its comment): a key that doesn't parse under this chi takes the mirror's value if that parses, else empty, with its message in `problems` (a reader that logged it logs that); `block_renderers` is checked against the record's scripts when the kept `scripts:` fails, and an older install's `hooks:` is ignored (no problem row). `description` and `unknown_keys` come only from a kept file; a profile's `includes` is always the record's (its members, identity). The value is deep-frozen, since callers share it. One process-wide cache (a Hash under a Mutex, cleared at `CACHE_LIMIT`) keyed by the record value and the kept file's stat (mtime, size, inode, device; a dev link's target): chi web asks per request, a worker at start and per `ContextProviders.resolve`. `#requires_chi_failure(version = VERSION)` is the one requires_chi gate; `#experimental?`, `#needs?`, `#context_providers?`, `#block_renderers?`, `#pages?` |
72
72
  | `ManifestStanding` (manifest_standing.rb) | the one owner of the words for an installed bundle's `manifest.yml` as `InstalledBundles::Manifest` read it: `.state` (`:kept`, `:legacy`, `:stale`, `:missing`, `:edited`), `.label` (`[kept]` / `[from the install record]`), `.line(bundle, refused:)` (the case and the command: `chi bundle upgrade NAME` (reads it again from a git URL, or a source that didn't match, with why), `chi update keeps it` while untried, the source is gone (`Installer.source_gone_line`), `chi bundle install --dev SOURCE` for a dev record; for a kept one, only the keys whose `BundleManifest::SINCE` floor is above the record's `installed_by`: newer than its installer), `.keep(bundle, source_dir:, dry_run:)` → `Outcome` (the record after, the line, `kept`): `Provenance#adopt_manifest` from `source_dir`, else from the recorded source (a dir; a zip/tar through `PreparedSource`, cleaned up; never a git clone). Read by `ShippedUpdate` (`Row#manifest`, the plan's dry `keep` and apply's), `UpdateCommand#external_rows` (a `kept its manifest` row, else a warn row, before the bundle's re-check, which then sees the kept file) and `chi bundle status NAME` (`BundleCommand#manifest_line`: `Manifest:`, the label, `.status_line`: for a record with a folder source (a bundle chi ships: this chi's shipped copy at the recorded version, which `chi update` reads), a dry `adopt_manifest` first, so the line says whether `chi update` keeps it or why not; an archive isn't extracted there, its line says `chi update tries to keep it`; a profile chi doesn't ship is never kept by `chi update`, so its line names `chi bundle upgrade NAME`) |
73
73
  | `InstalledBundles::Record`, `BundleHook`, `PluginRef` (installed_bundles/record.rb, bundle_hook.rb, plugin_ref.rb) | value objects for the record; tolerant of older records (missing keys read as empty). `InstalledBundles::Record`'s members are identity and state (name, version, scope, source, `installed_at`, `source_commit`, files and their marks, hooks, guardrails, scripts and the plugin with their shas, a profile's `includes`, `dev`, `dir`, the kept manifest's `manifest_sha` and `installed_by`, nil on a record from before it was kept); the manifest keys it records sit in one `mirror` Hash (`MIRROR_KEYS`, frozen: a key a later manifest gains is never mirrored) that only `InstalledBundles::Manifest` reads, so manifest data is read through `#manifest`. `BundleHook` is an older record's hook entry: `.parse` and `#sha256` (what the retire, uninstall and the trash selection read) |
@@ -48,7 +48,7 @@ runner too (its `Pages.script_path`), accepted: the shipped one loads the schedu
48
48
  ## The one launch path
49
49
 
50
50
  `chi page run` does not run the script in its own process. `Launch.run` starts the runner, exactly as chi web's
51
- Refresh will (Build 2), so a page that passes from the terminal passes on Refresh (the spike saw two paths give a
51
+ Refresh does, so a page that passes from the terminal passes on Refresh (the spike saw two paths give a
52
52
  script 152 against 73 preloaded libraries and a stale `PWD`). It costs about 70 ms more per terminal run.
53
53
 
54
54
  1. `Pages.check_name!`, then the script must exist (`Missing`), then `Store.locked(name)`: a non-blocking `flock` on
@@ -58,7 +58,8 @@ script 152 against 73 preloaded libraries and a stale `PWD`). It costs about 70
58
58
  2. `ProcessGroup.spawn(env, RbConfig.ruby, "-I", <this chi's lib>, "-e", 'require "samagotchi/pages/runner"; exit
59
59
  Samagotchi::Pages::Runner.run(ARGV)', NAME, TIMEOUT, DEADLINE, 3 => lock)`, in a group of its own, `chdir:` the
60
60
  pages folder, stdin closed, the lock on fd 3. The env is a worker's changes
61
- (`SessionManager::WorkerCommand#spawn_options`): `ChildEnv.unbundled` (an installed gem's Bundler changes undone),
61
+ (`SessionManager::WorkerCommandPart#spawn_options`, private in `session_manager/worker_command.rb`):
62
+ `ChildEnv.unbundled` (an installed gem's Bundler changes undone),
62
63
  `ChildEnv.unset` (the spawner's guardrails settings and session markers), `Launch.cleared_keys` unset
63
64
  (`CHI_REMOTE`, every `SAMAGOTCHI_WORKER_*` key and the vendor agent markers `AgentCaller::VENDOR_MARKERS`:
64
65
  `CLAUDECODE`, `CODEX_THREAD_ID`, `AI_AGENT`, read from those constants), `Paths.absolute_xdg`, and `PWD` set to the
@@ -187,8 +188,7 @@ pages: `load` shares a read that is out, `reload` asks again, a failed read keep
187
188
  `pages_list.js` (the Pages list, `#/pages`: its hash, its cards in `/api/pages`'s order), `page_view.js` (the header, the states, the calls; an answer for a page no longer open is
188
189
  dropped, `latest.js`), `page_model.js` (the words: meta, the failed and changed lines, Copy the error), `page_blocks.js`
189
190
  (text, walk in a widget host with `drawWalk`, an unknown type as one muted line), `page_table.js` and
190
- `page_table_model.js` (cells, sort, the phone's rows), `pages_group.js` (All sessions' former group, kept for an
191
- older cached app.js until after 0.189.0; nothing new imports it), `page_links.js` (the
191
+ `page_table_model.js` (cells, sort, the phone's rows), `page_links.js` (the
192
192
  delegated click on the turn roots and the page view for `#/p/` anchors), `pages.css`. What a script wrote reaches the
193
193
  page as text or attributes, never as markup, except the server's sanitised `html`.
194
194
 
@@ -220,7 +220,8 @@ Everything else is `:owner`: `/answer`, `/command`,
220
220
  A participant's turn acts with the session's tools under the owner's guardrails, its asks go to the owner and offer
221
221
  once only, and `Guardrails::PairBoundary` denies secrets, chi itself and chi web on loopback, background and
222
222
  scheduled jobs, the environment and credential printers, git config writes (reads only) and git's hooks,
223
- owner-voiced tools and the owner's task outputs, and the model's own question, and asks before a command that makes
223
+ owner-voiced tools, the owner's task outputs, the owner's other sessions, reminders and schedules and the
224
+ attached context (`PairBoundary::TOOL_CLASSES`), and the model's own question, and asks before a command that makes
224
225
  a link and before a write that may land outside the project, failing closed (a global install or a user config write
225
226
  that names no path, `Guardrails::ImplicitWriters`, and a script read from stdin count; a session at or above home has
226
227
  none: every write asks) ([guardrails](../guardrails.md#a-participants-pair-boundary)).
@@ -921,8 +922,9 @@ participant TUI in v1.
921
922
  an event type it doesn't name is dropped.
922
923
  - A participant's message is a turn of its own, or goes into their own running turn at its next step (chi web, the
923
924
  Bridge, the inbox), never into anyone else's turn and never a cut, a command or a
924
- shell line (chi web, the Bridge, the worker), and runs only on a worker with `pair_turns`: the pair boundary denies secrets and
925
- owner-voiced tools, the owner's guardrails decide the rest, and every ask is the owner's, once only.
925
+ shell line (chi web, the Bridge, the worker), and runs only on a worker with `pair_turns`: the pair boundary denies secrets,
926
+ owner-voiced tools and the owner's readers (tasks, other sessions, reminders, schedules, attached context), the
927
+ owner's guardrails decide the rest, and every ask is the owner's, once only.
926
928
  - No turn an older chi ran read-only runs with tool rights: an invite without `mode: "pair"`, or a Verify fresh child
927
929
  saved otherwise, is refused at the worker (`outdated`), and `Guardrails::ParticipantRefusal` denies every call of
928
930
  any other participant turn that isn't a current invite's.