samagotchi 0.195.0 → 0.196.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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -1
  3. data/docs/architecture.md +2 -1
  4. data/docs/bundle-authoring.md +23 -23
  5. data/docs/bundles.md +11 -3
  6. data/docs/cli.md +4 -0
  7. data/docs/context.md +13 -3
  8. data/docs/guardrails.md +6 -4
  9. data/docs/hooks.md +3 -1
  10. data/docs/internals/block-renderers.md +4 -1
  11. data/docs/internals/engine.md +2 -1
  12. data/docs/internals/knowledge.md +15 -5
  13. data/docs/internals/participants.md +15 -3
  14. data/docs/internals/peers.md +12 -8
  15. data/docs/internals/session-lifecycle.md +26 -12
  16. data/docs/internals/web-frontend.md +64 -27
  17. data/docs/pages.md +1 -1
  18. data/docs/peers.md +1 -1
  19. data/docs/plugins.md +73 -3
  20. data/docs/sessions.md +1 -1
  21. data/docs/system-one.md +3 -1
  22. data/lib/samagotchi/bundle_manifest.rb +30 -5
  23. data/lib/samagotchi/bundles/core/manifest.yml +2 -2
  24. data/lib/samagotchi/bundles/cost-cap/manifest.yml +4 -4
  25. data/lib/samagotchi/bundles/cost-cap/plugin.rb +54 -3
  26. data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
  27. data/lib/samagotchi/bundles/github-pr/manifest.yml +4 -2
  28. data/lib/samagotchi/bundles/knowledge/chi_adapters.rb +43 -25
  29. data/lib/samagotchi/bundles/knowledge/manifest.yml +6 -4
  30. data/lib/samagotchi/bundles/knowledge/plugin.rb +37 -18
  31. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  32. data/lib/samagotchi/context_change.rb +44 -0
  33. data/lib/samagotchi/context_note.rb +1 -1
  34. data/lib/samagotchi/context_providers.rb +14 -0
  35. data/lib/samagotchi/context_sources.rb +3 -25
  36. data/lib/samagotchi/engine/plugins.rb +21 -0
  37. data/lib/samagotchi/events.rb +1 -0
  38. data/lib/samagotchi/guardrails/pair_boundary.rb +12 -4
  39. data/lib/samagotchi/guardrails/targets.rb +24 -2
  40. data/lib/samagotchi/installed_bundles/manifest.rb +7 -1
  41. data/lib/samagotchi/memory_bundle/builder.rb +2 -1
  42. data/lib/samagotchi/memory_bundle/installed_copy.rb +2 -1
  43. data/lib/samagotchi/participants.rb +17 -6
  44. data/lib/samagotchi/peer_exchanges.rb +1 -2
  45. data/lib/samagotchi/peer_note.rb +38 -5
  46. data/lib/samagotchi/peer_presence.rb +20 -7
  47. data/lib/samagotchi/plugin/api.rb +5 -1
  48. data/lib/samagotchi/plugin/chips.rb +125 -0
  49. data/lib/samagotchi/plugin/context.rb +19 -1
  50. data/lib/samagotchi/plugin/peer_pairing.rb +2 -2
  51. data/lib/samagotchi/plugin/peer_start.rb +1 -1
  52. data/lib/samagotchi/plugin/peers.rb +5 -2
  53. data/lib/samagotchi/plugin/tool_spec.rb +19 -9
  54. data/lib/samagotchi/schedules.rb +8 -2
  55. data/lib/samagotchi/session_access/local.rb +34 -33
  56. data/lib/samagotchi/session_chain/sharing.rb +79 -0
  57. data/lib/samagotchi/session_chain/successor.rb +4 -2
  58. data/lib/samagotchi/session_chips.rb +133 -0
  59. data/lib/samagotchi/session_inbox_delivery.rb +11 -11
  60. data/lib/samagotchi/session_manager/emptiness.rb +4 -1
  61. data/lib/samagotchi/session_observer.rb +1 -1
  62. data/lib/samagotchi/session_stats.rb +5 -4
  63. data/lib/samagotchi/session_stores.rb +3 -0
  64. data/lib/samagotchi/speaker.rb +228 -0
  65. data/lib/samagotchi/steer.rb +36 -132
  66. data/lib/samagotchi/testing/bundle.rb +5 -0
  67. data/lib/samagotchi/testing/host.rb +1 -0
  68. data/lib/samagotchi/testing/recorder.rb +10 -0
  69. data/lib/samagotchi/tools/registry.rb +8 -3
  70. data/lib/samagotchi/turn_excerpts.rb +8 -4
  71. data/lib/samagotchi/version.rb +1 -1
  72. data/lib/samagotchi/web/app.rb +21 -10
  73. data/lib/samagotchi/web/participant_view.rb +1 -1
  74. data/lib/samagotchi/web/peer_routes.rb +5 -2
  75. data/lib/samagotchi/web/plugin_chip_rows.rb +39 -0
  76. data/lib/samagotchi/web/public/agent_rows.js +1 -0
  77. data/lib/samagotchi/web/public/app.js +17 -25
  78. data/lib/samagotchi/web/public/chains.js +0 -26
  79. data/lib/samagotchi/web/public/command_list.js +2 -3
  80. data/lib/samagotchi/web/public/composer.js +2 -3
  81. data/lib/samagotchi/web/public/composer_mount.js +3 -6
  82. data/lib/samagotchi/web/public/context_chips.js +240 -93
  83. data/lib/samagotchi/web/public/context_groups.js +84 -0
  84. data/lib/samagotchi/web/public/draft_follow.js +33 -0
  85. data/lib/samagotchi/web/public/drafts.js +26 -22
  86. data/lib/samagotchi/web/public/index.html +32 -0
  87. data/lib/samagotchi/web/public/peer_chip_kind.js +49 -0
  88. data/lib/samagotchi/web/public/peer_note.js +2 -2
  89. data/lib/samagotchi/web/public/peer_row.js +10 -5
  90. data/lib/samagotchi/web/public/peer_wait.js +4 -2
  91. data/lib/samagotchi/web/public/plugin_chip.js +55 -0
  92. data/lib/samagotchi/web/public/plugin_chip_kind.js +48 -0
  93. data/lib/samagotchi/web/public/send_turn.js +8 -21
  94. data/lib/samagotchi/web/public/session_actions.js +10 -23
  95. data/lib/samagotchi/web/public/session_view.js +7 -3
  96. data/lib/samagotchi/web/public/stream_handlers.js +2 -0
  97. metadata +12 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7c4b7b6f54997e228f37bab65e2f4e7270af20bf08216dae3bb33d1bd8e5d8f
4
- data.tar.gz: dbac0184dddb0f2c96e3a26e1c799ba5523cf9039ff5c0b4ded795b248f75a7f
3
+ metadata.gz: 61b4246c39204a15847e353036922eb55ea645677d33cbf7768e2ccba41ce132
4
+ data.tar.gz: 1a2b34a0606785a9a1ebd22fa87ffe6188dc86951aaf763b7f9d1784a65a062d
5
5
  SHA512:
6
- metadata.gz: d8d9da29e9ed29071bdc8d491a0209e16becc1129e0a55e3f48e50990e5a29e25b4acee5c8cf773f38a1c12016f1ec116d0fb090ed95b76d858a5d9d3ad95a76
7
- data.tar.gz: 14f8fb761e6df9e2b5259f8d867f0b93da052b2932dfd9f44af6f04066edd54fdc2e2a9683dd894d157b6539786266446d808abb07ba619fbdd4a540268cd786
6
+ metadata.gz: d55ab046af16ff200f0484f6840929bc2baab9f7e45581c0098c6e2a3165220bb0a0be0cf22b1dfc5965af1e9c176122c01ad520e26542cf5d9bb16d3f360513
7
+ data.tar.gz: 4e567cb82e9cf01dcd733c7c2dd8cdbe4fefb955c5b9c3a5f58fd58bdb9b31e376ca7041c18e53c05b1395cc233bc81b4018b419bf964f24a12765aa6fb619ef
data/CHANGELOG.md CHANGED
@@ -8,6 +8,45 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.196.0] - 2026-11-30
12
+
13
+ ### Added
14
+
15
+ - `ctx.speaker(message)`: who wrote a message (`:owner`, `:participant`, `:chi`, `:sender`, `:plugin`, `:model`, `:tool`) ([docs/plugins.md](docs/plugins.md)).
16
+ - `chi.tool …, participant: :deny`: a bundle tool a participant's turn is refused, by name or through `call_tool`, without asking the owner ([docs/plugins.md](docs/plugins.md)).
17
+ - chi web: two or more attached sources of one bundle are one chip in the session bar, such as `PRs 3 · 2m` for
18
+ **github-pr**'s pull requests, which lists them; a row opens that source's own view. PRs you attached before group
19
+ too, with no re-attach ([docs/context.md](docs/context.md)).
20
+ - A bundle's manifest can name that chip's label with `context_group:` ([docs/plugins.md](docs/plugins.md#context-providers-in-the-manifest)).
21
+ - `ctx.chips`: a bundle can draw a chip of its own in chi web's session bar, with a label, a warn or error look, and
22
+ a small card of text and up to four buttons ([docs/plugins.md](docs/plugins.md#chips-ctxchips)).
23
+ - **cost-cap** 0.3.0: chi web's session bar shows the session's spend against its cap, `cap · $4.10 of $5.00`, warn
24
+ from `warn_at` and red at the cap; its card raises the cap to twice it or turns it off. Run `chi update`
25
+ ([docs/bundles.md](docs/bundles.md#the-cost-cap-bundle)).
26
+
27
+ ### Changed
28
+
29
+ - `chi share` while its session is being continued names the new session to invite in instead of asking to try again
30
+ ([docs/cli.md](docs/cli.md#participants)).
31
+ - A peer say or pair and a context push during a continue say "is being continued as" its new session until the
32
+ continue finishes, and a context add or remove on a session continued earlier names the new session
33
+ ([docs/context.md](docs/context.md)).
34
+ - knowledge: a participant's turn is refused knowledge_add/list/remove up front, without an approval ask to the owner first.
35
+ - `runtime.turn_excerpts` gives no `prompt`, `answer` or `calls` for a participant's turn, so the **reflect** page shows the owner's words only ([docs/pages.md](docs/pages.md#reading-chis-data-runtime)).
36
+
37
+ ### Fixed
38
+
39
+ - chi web: text you were typing in a session now moves to its next link when the session is continued somewhere
40
+ else (a terminal's `/continue`, a chain schedule, `chi send --continues`, another tab), as Continue → does; a next
41
+ link that already has a draft keeps it ([docs/sessions.md](docs/sessions.md#session-chains)).
42
+ - **knowledge**: a participant's turns are no longer indexed as yours ("you:") in a past-sessions source; an existing index re-lists its sessions once ([docs/bundles.md](docs/bundles.md#the-knowledge-bundle)).
43
+ - chi web: a peer chip waiting for its session to pair ("waiting 8 min") now counts down in a session with no
44
+ attached source.
45
+ - `chi schedule cancel` with the id of a schedule that can't be read no longer removes a different schedule whose
46
+ id starts with the same characters ([docs/scheduling.md](docs/scheduling.md)).
47
+
48
+ Update with `chi update` (cost-cap 0.3.0, github-pr 0.6.6, knowledge 0.1.1, the core profile 0.4.5, the dev profile 0.7.14).
49
+
11
50
  ## [0.195.0] - 2026-11-30
12
51
 
13
52
  ### Added
@@ -7187,7 +7226,8 @@ and long-lived sessions.
7187
7226
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
7188
7227
  hotkey panel that send selected text or the clipboard to your sessions.
7189
7228
 
7190
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.195.0...HEAD
7229
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.196.0...HEAD
7230
+ [0.196.0]: https://github.com/dm1try/samagotchi/compare/v0.195.0...v0.196.0
7191
7231
  [0.195.0]: https://github.com/dm1try/samagotchi/compare/v0.194.0...v0.195.0
7192
7232
  [0.194.0]: https://github.com/dm1try/samagotchi/compare/v0.193.0...v0.194.0
7193
7233
  [0.193.0]: https://github.com/dm1try/samagotchi/compare/v0.192.0...v0.193.0
data/docs/architecture.md CHANGED
@@ -527,6 +527,7 @@ model: [internals/remote-sessions.md](internals/remote-sessions.md).
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 |
528
528
  | `GET /api/sessions/:id?brief=1` | participant (theirs: title, status, participants) | | 200 `{brief, session: {id, status (the file's), title, display_title, project_root, project_id, working_directory, model_name, model_typed, parent_answers, owner}, pending_question}` (the file's; no messages): `Remote#show` | 404 |
529
529
  | `POST /api/sessions/:id/turn` (its 202) | owner | | the ack with `via`: `bridge` or `file` (the input file: a remote `chi send --wait` follows that turn) | |
530
+ | `GET /api/sessions/:id/context`, `…/context/:name` | owner | | 200 `{session_id, sources, can_add_url, chips}`: a row per source the session sees (`name`, `scope`, `kind`, `every_seconds`, `why`, `hint`, `summary`, `error`, `fetched_at`, `has_text`, `muted`, `unread`, `provider`: the bundle that made it or null, `group`: that bundle's `context_group:` label or null, read once per bundle per request), never a command; `chips`: the bundles' own chips (`ctx.chips`, the session's `chips.json`, `Web::PluginChipRows`: `{key: "chip:<bundle>/<name>", bundle, name, label, state, dot, title, at, body_html, actions}`, a bundle that isn't usable now left out, no worker needed); `…/:name` one row with its `text` | 404 `context_missing` |
530
531
  | `GET /api/sessions/:id/context?full=1`, `…/context/:name?full=1` | owner | | each row with `source` (`Source#to_h`, its command too; the page's rows never carry one), `snapshot` (`Snapshot#to_h`, no text) and `shadowed`, shadowed project sources included | |
531
532
  | `POST /api/sessions/:id/wake` | owner | `wait` (seconds, default and most 10: `WAKE_MAX_WAIT`) | 200 `{session_id, woke, worker: {epoch, started_at, version, features}, model_name, default_model, parent_strategy, installed}`: the live worker as is (`woke: false`), else resumed and its Bridge waited for (`Local#wake`); `default_model` and `installed` are this machine's | 409 `owned_by_tui`, `scratch` (`Session::SCRATCH_REFUSED`); 504 `worker_timeout` (`LaunchMode::BRIDGE_LATE`); 400 `invalid_wait`; 404 |
532
533
  | `GET /api/sessions/:id/worker` | owner | | 200 `{session_id, live, stopped, owner: worker \| tui \| null, worker: {epoch, started_at, version, features} \| null, default_model, parent_strategy}` (`Local#worker`; never starts one; `default_model` is this machine's) | 404 |
@@ -707,7 +708,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
707
708
  | Toolkits | `toolkit.rb` (`Toolkit`), `toolkit_binding.rb` (`ToolkitBinding`, the Engine's seam), `toolkit_command.rb` (`/toolkit`), `tools/registry.rb` (`Registry#toolkit`), `tools/tool_surface.rb` (`ToolSurface#left_out`, read by the prompt and `/toolkit`), `web/public/toolkit_chip.js` | Which registered tools a session's prompts declare: saved in the session, resolved at a turn's start (`Engine#apply_toolkit!`), named in the prompt's not-loaded line, a kit's prompt text after the appended files; `chi.toolkit` and `ctx.use_toolkit` for plugins ([configuration.md](configuration.md#toolkits)). |
708
709
  | Tool index | `tools/tool_index.rb` (`Tools::ToolIndex`), `tools/deferred_tools.rb` | `find_tools` and `call_tool`: the tools a session knows but doesn't declare one by one (an mcp bundle's servers through `chi.tool_source`, the built-ins its toolkit leaves out), searched and called by name ([plugins.md](plugins.md)). On `api: anthropic` they also go out deferred, a hit loads its matches and the model calls them by name ([internals/anthropic.md](internals/anthropic.md)). |
709
710
  | Tool output cut | `tool_output_cut.rb` (`ToolOutputCut`), `tool_output_files.rb` (`ToolOutputFiles`) | A tool's output over `max_tool_output_chars` (a `memory_read`'s: `memory.read_max_chars`, 0 = none, plus a guard at half a known window), cut by the tool's policy; an execute's whole output saved in the session's `tool_output/` folder ([internals/tool-output-limits.md](internals/tool-output-limits.md)). |
710
- | Steer delivery | `steer.rb` (`Steer`), `delivery.rb` (`Delivery`), `steer_cut.rb` (`SteerCut`), `generation_phase.rb`, `waiting_steer.rb`, `steer_cut_after.rb` (`SteerCutAfter`), `cut_policy.rb` (`CutPolicy`) | A message for a running turn: at the next boundary, cutting a thinking-only generation, or queued for the turn's end ([internals/engine.md](internals/engine.md)). |
711
+ | Steer delivery | `steer.rb` (`Steer`), `speaker.rb` (`Speaker`: who wrote a message, `Speaker.of`; Steer's predicates delegate to it), `delivery.rb` (`Delivery`), `steer_cut.rb` (`SteerCut`), `generation_phase.rb`, `waiting_steer.rb`, `steer_cut_after.rb` (`SteerCutAfter`), `cut_policy.rb` (`CutPolicy`) | A message for a running turn: at the next boundary, cutting a thinking-only generation, or queued for the turn's end ([internals/engine.md](internals/engine.md)). |
711
712
  | Prompt files | `prompt_files.rb` (`PromptFiles`) | The AGENTS.md chain (root → cwd) and the appended files the system prompt carries. |
712
713
  | Model settings | `effective_model.rb` (`EffectiveModel`, `ModelChoice`), `model_lookup.rb` (`ModelLookup`: every layer's input), `model_profile.rb` (`ModelProfile`), `model_settings.rb`, `sampling_settings.rb`, `model_catalog.rb` (`ModelCatalog`), `model_notes.rb` (`ModelNotes`) | The effective model's settings as one snapshot per read, a model's prompt format, its `models:` entry, its request parameters, the pickable model rows (`chi models`, `/api/models`), the notes its prompt loads. |
713
714
  | Session settings | `session_setting.rb` (`SessionSetting`), `session_model_settings.rb` (`SessionModelSettings`), `level_setting_command.rb` (`/thinking`, `/reasoning-history`), `llm_context_command.rb`, `toolkit_command.rb`, `thinking_notices.rb` (`ThinkingNotices`) | A session's own llm_context, thinking, reasoning_history and toolkit: their chips (session state, `/stats`, `:command_ran`, the web), the commands that set them, the thinking level's notices. |
@@ -28,14 +28,9 @@ the bundle's plugin in their own process, as written: run them on code you'd ins
28
28
 
29
29
  ## Trying a bundle
30
30
 
31
- After `chi bundle check --fix`, run `chi bundle try . -p "Say hello"` for one real model call using the user's
32
- configured hosts and keys. It installs the bundle plus chi's shipped guardrails and a default $1 cost cap, then
33
- prints tool calls, hook notices, cards, questions, the answer, token totals and cost.
31
+ After `chi bundle check --fix`, run `chi bundle try . -p "Say hello"` for one real model call using the user's configured hosts and keys. It installs the bundle plus chi's shipped guardrails and a default $1 cost cap, then prints tool calls, hook notices, cards, questions, the answer, token totals and cost.
34
32
 
35
- The child uses a temporary config, state and working directory; the user's other bundles and memories aren't loaded,
36
- nor are the current project's `AGENTS.md` / `CLAUDE.md` files. This is not a security sandbox: the bundle and tools
37
- run with the user's real HOME and account, and can access files and services available there. Use `try` only with
38
- code you trust. See [CLI: Trying a bundle](cli.md#trying-a-bundle) for flags, `--json`, `--keep` and exit statuses.
33
+ The child uses a temporary config, state and working directory; the user's other bundles and memories aren't loaded, nor are the current project's `AGENTS.md` / `CLAUDE.md` files. This is not a security sandbox: the bundle and tools run with the user's real HOME and account, and can access files and services available there. Use `try` only with code you trust. See [CLI: Trying a bundle](cli.md#trying-a-bundle) for flags, `--json`, `--keep` and exit statuses.
39
34
 
40
35
  ## The files
41
36
 
@@ -91,6 +86,22 @@ step), `ctx.card(…)`, `ctx.stop_turn(reason)`, `ctx.ask_user(…)`, `ctx.data_
91
86
  my-bundle)"`, the plugin's label. A bundle hooks events from its plugin only: class-file hooks (`hooks/*.rb`, a
92
87
  manifest `hooks:`) are retired, and chi refuses a source that has them ([hooks.md](hooks.md#class-file-hooks-are-retired)).
93
88
 
89
+ ## A chip in chi web's session bar
90
+
91
+ Something that holds for the whole session (a budget, a remote job) can be a chip of the bundle's own after the bar's sources, its card a text and up to 4 buttons: `ctx.chips` ([plugins.md](plugins.md#chips-ctxchips)). A `/deploy` that keeps one:
92
+
93
+ ```ruby
94
+ chi.command("/deploy", "show or clear the deploy chip: /deploy, /deploy done", anytime: true) do |args, ctx|
95
+ next "deploy: needs a chi with ctx.chips" unless ctx.respond_to?(:chips)
96
+ next(ctx.chips.remove("deploy") ? "deploy: cleared" : "deploy: no chip") if args.strip == "done"
97
+ ctx.chips.set("deploy", label: "deploy · running", state: :warn, at: Time.now, body: "Started **#{Time.now.strftime("%H:%M")}**.",
98
+ actions: [{ label: "Mark done", command: "/deploy done", primary: true }])
99
+ "deploy: chip set"
100
+ end
101
+ ```
102
+
103
+ In a test the chips are in memory: `bundle.command("/deploy")`, then `bundle.chips["deploy"]["label"]` is `"deploy · running"`. Live: `chi bundle install --dev .`, then `/deploy` in a chi web session; the chip shows (warn's look, `· now` ticking up), a tap opens its card, **Mark done** runs `/deploy done` (its reply in the conversation) and the chip goes. The same chip again writes nothing, so a hook may set it every time (`after_generation`, never `generation_progress`). Mark the manifest `requires_chi_next: ctx.chips` until a release has it.
104
+
94
105
  ## Testing it
95
106
 
96
107
  `chi bundle new` writes a Minitest test that passes as written: copy its shape. The kit (`samagotchi/testing`) loads
@@ -126,25 +137,14 @@ class, a hand-built `ctx`), that is a gap in the kit: say so to the user rather
126
137
  ## Pitfalls
127
138
 
128
139
  - **Sandbox and ENV.** A standalone `Testing::Bundle` snapshots `ENV` when built and restores it at shutdown; see [Testing a bundle](plugins.md#testing-a-bundle-experimental).
129
- - **Shas.** Every file the manifest names has a sha256 line, and an edit makes it stale: the install then warns
130
- of a checksum mismatch (not for `install --dev`; `chi bundle check` does), and a line with no sha installs unchecked. `chi bundle check --fix` rewrites them; run it
131
- after the last edit.
132
- - **requires_chi.** Use the chi the user runs (`chi --version`): a bundle whose `requires_chi` that chi doesn't
133
- meet is now **refused at install** (`--force` is the only way past it), not just unloaded. `check` warns when the plugin calls something newer than the floor (`ctx.http` 0.80.0, `ctx.cost` 0.83.0, `ctx.usage` 0.100.0, `ctx.sessions.children` 0.34.0),
134
- or a keyword added later (`ctx.ask_model(model:)` 0.80.0, `ctx.sessions.send(delivery:)` 0.64.0, `chi.toolkit(prompt:)` 0.72.0, `chi.toolkit(groups:)` 0.121.0, `chi.tool(declare:)` the release after 0.194.0), written on `ctx` / `chi` itself rather than through a variable,
135
- or when the manifest itself uses a key newer than the floor (`block_renderers:` 0.151.0, `settings:` 0.143.0, `session_settings:` 0.84.0, `context_providers:` 0.32.0): an older chi ignores that key.
140
+ - **Shas.** Every file the manifest names has a sha256 line, and an edit makes it stale: the install then warns of a checksum mismatch (not for `install --dev`; `chi bundle check` does), and a line with no sha installs unchecked. `chi bundle check --fix` rewrites them; run it after the last edit.
141
+ - **requires_chi.** Use the chi the user runs (`chi --version`): a bundle whose `requires_chi` that chi doesn't meet is now **refused at install** (`--force` is the only way past it), not just unloaded. `check` warns when the plugin calls something newer than the floor (`ctx.http` 0.80.0, `ctx.cost` 0.83.0, `ctx.usage` 0.100.0, `ctx.sessions.children` 0.34.0), or a keyword added later (`ctx.ask_model(model:)` 0.80.0, `ctx.sessions.send(delivery:)` 0.64.0, `chi.toolkit(prompt:)` 0.72.0, `chi.toolkit(groups:)` 0.121.0, `chi.tool(declare:)` the release after 0.194.0), written on `ctx` / `chi` itself rather than through a variable, or when the manifest itself uses a key newer than the floor (`block_renderers:` 0.151.0, `settings:` 0.143.0, `session_settings:` 0.84.0, `context_providers:` 0.32.0): an older chi ignores that key.
136
142
  - **A typo in an API call.** `check` warns (`api`) on a call or keyword this chi lacks, on any path; for a newer chi on purpose, guard it with `ctx.respond_to?(:name)`.
137
143
  - **trust_level.** Leave it out. `reviewed` / `trusted` are for someone who reviewed the bundle, not its author.
138
- - **Restart.** A session loads bundles when it starts: after an install or a settings change, the user starts a
139
- new session (or `chi sessions restart ID`).
140
- - **chi's internals.** A bundle may use `chi.*`, `ctx` and the names
141
- [plugins.md, Stable for bundles](plugins.md#stable-for-bundles) lists; any other `Samagotchi::` name may change
142
- in any release (`check` warns: `boundary`).
144
+ - **Restart.** A session loads bundles when it starts: after an install or a settings change, the user starts a new session (or `chi sessions restart ID`).
145
+ - **chi's internals.** A bundle may use `chi.*`, `ctx` and the names [plugins.md, Stable for bundles](plugins.md#stable-for-bundles) lists; any other `Samagotchi::` name may change in any release (`check` warns: `boundary`).
143
146
  - **Load errors.** A plugin that raises at load is skipped and the session goes on: `check` shows the error at its `plugin.rb:LINE`.
144
147
 
145
148
  ## Verifying it live
146
149
 
147
- `chi bundle try . -p "..."` **is** the live check: a real model turn on the installed bundle, with its trace
148
- (tools, plugin, notices, cards). Don't repeat it with `chi send` sessions on the user's own install. After the
149
- final `chi bundle install .`, `chi bundle list` showing the bundle and its version is enough. Then tell the user
150
- what it adds, how to use it, and that a new session picks it up.
150
+ `chi bundle try . -p "..."` **is** the live check: a real model turn on the installed bundle, with its trace (tools, plugin, notices, cards). Don't repeat it with `chi send` sessions on the user's own install. After the final `chi bundle install .`, `chi bundle list` showing the bundle and its version is enough. Then tell the user what it adds, how to use it, and that a new session picks it up.
data/docs/bundles.md CHANGED
@@ -711,6 +711,12 @@ bundles:
711
711
  model that reports 0) reads unknown: one notice, `the $3.00 cap can't be enforced: <model> reports no cost and has
712
712
  no price`, and it never stops for an unknown cost. A session with some priced generations counts the unpriced
713
713
  ones as $0.
714
+ - **The chip** (chi web): with a cap, the session bar shows `cap · $4.10 of $5.00` after the attached sources, in the
715
+ warn look from `warn_at` and the error look at the cap. It follows each generation (never each streamed token: one
716
+ small write per generation whose spend changed the label) and `/cap` or a Continue at once. A tap opens a card with
717
+ the spend and two buttons, **Raise to** twice the cap (`/cap 10`) and **Turn the cap off** (`/cap off`), whose reply
718
+ shows in the conversation. No cap, or a model it can't watch, has no chip. It needs a chi with `ctx.chips`
719
+ ([plugins.md](plugins.md#chips-ctxchips)).
714
720
 
715
721
  **`/cap`** (works while a turn runs; the next generation reads it):
716
722
 
@@ -1085,7 +1091,9 @@ that line of the session's PR ([Line links](context.md#line-links); `line_links:
1085
1091
  always` for a `chi -p … --non-interactive` one-shot too), and its ref menu offers the file
1086
1092
  here and a "PR diff" action (`event[:refs]`). `auto_attach: attach` attaches
1087
1093
  it at once (the old default), `off` does nothing ([Propose, attach or
1088
- off](context.md#propose-attach-or-off)).
1094
+ off](context.md#propose-attach-or-off)). Two or more attached PRs are one
1095
+ chip in the web's session bar, `PRs 2 · 3m` (`context_group: PRs`), that
1096
+ lists them.
1089
1097
  See [Attached context](context.md#github-prs-the-github-pr-bundle).
1090
1098
 
1091
1099
  ## The coordinator bundle
@@ -1755,8 +1763,8 @@ indexed locally, in one SQLite FTS5 file per catalog, through the system `sqlite
1755
1763
  `refreshing now`); a failing pull clones again. Its tracked text files follow the folder rules (no symlinks,
1756
1764
  submodules or secret-named files). It needs `gh` and `git` on PATH.
1757
1765
  - **Past sessions** (`kind: chi, location: sessions`, opt-in): this project's saved sessions (archived ones too, no
1758
- scratch or test sessions), one item per session, your and the model's text only (no tool output, no thinking, no
1759
- notes, no `!cmd` output), a hit pointing at its message. The searching session is never a hit; a deleted or pruned
1766
+ scratch or test sessions), one item per session, your and the model's text only, never a participant's (no tool output, no thinking, no
1767
+ notes, no `!cmd` output, no participant's turn), a hit pointing at its message. The searching session is never a hit; a deleted or pruned
1760
1768
  session leaves at the next search. Only the sessions written since the last refresh are read again.
1761
1769
  **Privacy:** secrets in that text and the sessions' titles (API keys and tokens by their shape, `token=…`-style
1762
1770
  values) are stored as `[redacted]`, as a participant's page shows them.
data/docs/cli.md CHANGED
@@ -1940,6 +1940,10 @@ chi share revoke --all # every link to every session
1940
1940
  owner.", an expired one "This link expired: ask the session's owner for a new one." A link an older chi issued
1941
1941
  for read-only review turns has ended too: "This link is from an older chi: ask the session's owner for a new one."
1942
1942
  (the panel lists it as "ended (older link)"); invite them again.
1943
+ - `chi share` while the session is being continued names the new session to invite in ("session 3f9a1c2e is being
1944
+ continued as 7b2d41aa-…: invite there in a moment" while the continue runs; "was continued as …: invite there"
1945
+ for a session continued earlier, named whatever holds it, a delete or a stop too); while another change holds it
1946
+ and nothing continues it, try again in a moment.
1943
1947
  - **Their turns (experimental).** A participant sends messages through chi web's `POST …/turn`: each message is a
1944
1948
  turn of its own, queued behind the running one, that **acts** in the session with its tools, writes included,
1945
1949
  under your guardrails: what your rules allow runs, what they ask about comes to you as "Sam's turn asks: approve
data/docs/context.md CHANGED
@@ -232,6 +232,16 @@ The web's session bar shows a chip per source (name · age; a dot when the
232
232
  agent hasn't read a change, red after a failed refresh). A chip opens the
233
233
  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
+ Two or more sources of one bundle that names a label (`context_group:` in
236
+ its manifest; github-pr's is `PRs`) are one chip, `PRs 3 · 2m`, where the
237
+ first of them would be: how many, the newest fetch's age, red when any
238
+ failed its last refresh, a dot when any has a change the agent hasn't read
239
+ (a muted source doesn't count). It opens a list, one row per source (its
240
+ name, summary or why its refresh failed, age); a row opens that source's
241
+ own view with a way back to the list. A lone source keeps its own chip, and
242
+ so does one with no bundle (`--cmd`, `--push`). The group has no action of
243
+ its own: detach each source from its view. PRs attached by an older chi
244
+ group too, with no re-attach (a source records its bundle).
235
245
  A paired peer has a chip of its own there, drawn first, and its messages are
236
246
  bubbles from the peer ([peers.md](peers.md), [bundles.md](bundles.md#the-claude-peer-bundle)). A context note sits in
237
247
  chi web's closed notes row ([cli.md](cli.md#web-markdown-rendering)), or in the closed line it shares with the
@@ -335,12 +345,12 @@ link's id (`chi context push` exits 1; chi web answers 410
335
345
  chi context push: session 3f2a9c1e was continued as 7b1d…: notes stays with the session it was attached to; attach it to 7b1d… (or pair again with 7b1d…) and push there
336
346
  ```
337
347
 
338
- A session being continued right now (its new link not saved yet) is refused the same way, `is being continued as`
348
+ A session being continued right now (its continue still running, its new link saved or not) is refused the same way, `is being continued as`
339
349
  and `… push there in a moment`; one busy with another change (its transition lock held) is refused with `chi context
340
350
  push: session 3f2a9c1e is busy with another change; try again in a moment` (chi web answers 423 `context_busy`).
341
351
  `chi context add` and `chi context rm` of a session's own source (and the page's attach and ×) are refused the same
342
- way while a transition holds the session (a continue copies its sources to the new link): nothing changes, try again
343
- in a moment.
352
+ way while a transition holds the session (a continue copies its sources to the new link): nothing changes, and the
353
+ refusal names the new link when there is one (`… was continued as 7b1d…: change it there`), else try again in a moment.
344
354
 
345
355
  An archived session that nobody continued takes pushes as before; a schedule's anchor whose successor a prune deleted counts as continued by the schedule's head ([sessions.md](sessions.md), *Session chains* → Which link).
346
356
 
data/docs/guardrails.md CHANGED
@@ -572,8 +572,10 @@ message:
572
572
  the owner's other sessions, reminders and schedules and the session's
573
573
  attached context: `list_sessions`, `list_reminders`, `list_schedules`,
574
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;
575
+ `PairBoundary::TOOL_CLASSES` (a spec fails on one that hasn't);
576
+ - a plugin tool its bundle declared `participant: :deny` (`PairBoundary::BUNDLE_OWNER`,
577
+ [plugins](plugins.md#participant-the-owners-only)), by its name or through `call_tool`, before any
578
+ check or ask; any other plugin's or an MCP server's tool goes on to the path and command checks;
577
579
  - `ask_user_question`, with the advice to ask in the reply: nobody on the
578
580
  participant's side answers a card.
579
581
 
@@ -615,8 +617,8 @@ share`, `/bin/SH -c`, `NOHUP`: a disk that folds case, macOS's default, runs
615
617
  them as git, chi, sh, nohup; `ShellLex.program_name`), and so is chi or git
616
618
  config in a script's text.
617
619
 
618
- It asks the owner, fresh and once, before a plugin or MCP tool's call whose
619
- `targets:` name no command or path (`PairBoundary::UNTARGETED`: a browser
620
+ It asks the owner, fresh and once, before a call of a plugin tool not declared
621
+ `participant: :deny`, or of an MCP tool, whose `targets:` name no command or path (`PairBoundary::UNTARGETED`: a browser
620
622
  MCP's navigate, say), since nothing here can tell what it reaches.
621
623
 
622
624
  And it **asks the owner** before a `write` or `edit` that may land outside the
data/docs/hooks.md CHANGED
@@ -176,7 +176,9 @@ A steer is saved in the session as `{role: "user", kind: "steer", source:
176
176
  "<bundle>", content: "…"}`, its text raw. The model reads it as a user turn
177
177
  led by one line naming the sender: `[Steer from the <bundle> plugin,
178
178
  mid-task. Follow it; if it asks for nothing, carry on with the task.]`.
179
- Its `source` is the hook's bundle (a config or turn hook's label otherwise).
179
+ Its `source` is the hook's bundle (a config or turn hook's label otherwise):
180
+ `HookLabel.source` reads it from a bundle hook's label (`<file> (bundle
181
+ <name>)`), as `SessionStats` does for hook notices by bundle.
180
182
  Lines typed into a running turn are saved as `{role: "user", kind: "input",
181
183
  content: "…"}`: part of that turn, not a turn of their own. They carry a
182
184
  `source` when they are not the user's own: `chi_send` (`chi send -m`),
@@ -221,7 +221,10 @@ with an **Ask in chat** button (it fills the composer with "The X block in your
221
221
  send it again, corrected."; never sends), as does an older answer's failed block and an answer's third. A live worker
222
222
  without the feature (`workerPredates`, with the store's `bridgeUp`): "· restart this session to fix"; a worker that
223
223
  isn't up is asked, and chi web's 503 `not_live` gives the plain line. An answer is read again at most once per block
224
- for the page's life, so a copy still failing after the redraw says a fix didn't help. The terminal and a participant's page show nothing new.
224
+ for the page's life, so a copy still failing after the redraw says a fix didn't help. No word within `GIVE_UP_MS`
225
+ (60 s) of a 202 and the page gives up on the blocks it asked for; a redraw it can't show (the answer's re-read fails or
226
+ finds no bubble to write) settles them the same way: the plain line with Ask in chat
227
+ ([web-frontend.md](web-frontend.md#a-failed-block-asked-for-again)). The terminal and a participant's page show nothing new.
225
228
 
226
229
  **The turn's drawing.** A patched `content` changes the digest the turn's drawing line ends on (`TurnDrawings#holds?`),
227
230
  so the Bridge's `TurnDrawings` (an observer of `:block_fix` with `landed: "answer"`) writes that turn's line again with
@@ -598,6 +598,7 @@ Turn events (the main ones; `events.rb` keeps the shared sets):
598
598
  | `:plugin_init_wait` | a turn waits for init tasks that provide tools (`PluginTasks`) | `{tasks: [{bundle, id, label}]}` |
599
599
  | `:used_memories_updated` | a memory was read, and after the loop | `{used_memory_names, read_names?}` |
600
600
  | `:working_set_updated` | after `:generation_started` and once in `end_turn`, only when the set changed (`Engine#emit_working_set`) | [working-set.md](working-set.md) |
601
+ | `:chips_updated` | announced (any thread, observers only) after a bundle's `ctx.chips` change was written (`Engine#announce_chips`, the Host's `chips` store `SessionChips`; the write is outside the event lock, the same chip again announces nothing); the web reads `GET …/context` again; participants never get it | `{session_id, at}`, no chips: [plugins.md](../plugins.md#chips-ctxchips) |
601
602
  | `:hook_notice` | a hook's or plugin's notify | `{hook, text, level}` (`between_turns: true` outside a turn) |
602
603
  | `:guardrail_warning` | a guardrails line | `{message}` |
603
604
  | `:turn_completed` | normal end | `{turn_id, result, turn_summary, display_pending}`, plus `verify`, `verdict`, `revises` when there are; the SSE frame omits `result` |
@@ -617,7 +618,7 @@ form (`#empty?`, `#wire` nil), so events and hooks carry no origin for it. The b
617
618
  when someone other than the owner wrote it (stamped by chi web from the request's `Web::Principal`). **An owner's turn
618
619
  has no `author` anywhere**: not in its input file, its origin or the session.
619
620
 
620
- Where a participant's author (`"p:<id>"`; `Steer.participant_author?`) goes (the model is in
621
+ Where a participant's author (`"p:<id>"`; `Speaker.participant_author?`, `Steer`'s delegates to it) goes (the model is in
621
622
  [participants.md](participants.md)):
622
623
 
623
624
  - **The opening message** gets `author` and `author_name` (`Engine#author_fields`; the name from
@@ -150,10 +150,19 @@ $XDG_STATE_HOME/samagotchi/plugins/knowledge/ (ctx.data_dir, realpath'd onc
150
150
  state dir, is denied; the URL isn't). `updated_at` is the HEAD commit's time. `knowledge_remove` deletes the clone.
151
151
  - **`SessionsAdapter`** (`chi_adapters.rb`): `ctx.sessions.list(changed_since:)` (`SessionStats.summaries` of the
152
152
  session's project, or of no project: no test_run or scratch session, archived ones kept), each changed session read
153
- with `ctx.sessions.read` (the saved file, or a live worker's snapshot): user messages with no kind or `input` and no
154
- `source`, model messages with no kind; never `tool_response`, a steer, a system note or `thinking`, nor the user
155
- messages chi writes: a `!cmd` line (`"!(cmd)\n<output>"`, no `turn_id`: `Steer.shell_line?`'s shape, checked in
156
- the bundle) and `/continue no`'s reason line (an `opening_id`, no `turn_id`). Every message's text and the
153
+ with `ctx.sessions.read` (the saved file, or a live worker's snapshot), each message read by `ctx.speaker`: the
154
+ owner's (`:owner`) with no kind or `input`, the model's (`:model`) with no kind; never `tool_response`, a steer, a
155
+ system note or `thinking`, a sender's or a plugin's line, nor the user lines chi writes (`:chi`: a kind-less `!cmd`
156
+ line or `/continue no`'s reason line). **A participant's turn goes whole** (H1, audit r24): from an opening (a
157
+ message with a `turn_id`, or `turn_start`) that `ctx.speaker` reads as `:participant` to the next opening, their
158
+ prompt, the model's answers and any line merged into it (a live snapshot's merged input has no kind and no
159
+ `turn_id`, so it never ends one: the rule drops more, never less); a participant's line merged into the owner's
160
+ turn goes alone. An item's sig is `"<RULE>:<updated_at>"` (`SessionsAdapter::RULE`, now `"2"`). **The old-rule
161
+ sweep:** every search that selects a sessions source (`Plugin#sweep`, whatever the source's age, project or the
162
+ search's budget) deletes its rows whose sig lacks the prefix (indexed before the rule, a participant's text with
163
+ them; `#sweep_old_rule`, under the catalog lock) and clears its `listed_at`; `Plugin#adapter_for` lists in full
164
+ while any such row is left, so only those sessions are re-chunked, and a listing cut short stays full until one
165
+ completes. A stale worker on the older bundle writes unprefixed sigs again, swept at the next search. Every message's text and the
157
166
  session's title go through `Redact.text(text, Redact::Viewer.new(cwd: nil))` before they are chunked, as
158
167
  `TurnExcerpts` and `ObjectivesRecord` do: a key by shape (`sk-…`, `ghp_…`, …) or by name (`token=…`) is stored
159
168
  as `[redacted]`, and home as `~`. Chunks of
@@ -187,7 +196,8 @@ $XDG_STATE_HOME/samagotchi/plugins/knowledge/ (ctx.data_dir, realpath'd onc
187
196
  `ctx.turn_author` set: `knowledge_search` drops the `chi` sources before the query (a `sources:` of only chi ones is
188
197
  refused; the age line says they were left out) and refuses `catalog:` (a named catalog spans projects; the participant
189
198
  was invited to one session). `open:` refuses (every pointer it reads is chi data). `knowledge_add` /
190
- `knowledge_list` / `knowledge_remove` refuse. A participant's `/` line
199
+ `knowledge_list` / `knowledge_remove` are `participant: :deny` (the pair boundary refuses them, no owner ask; the
200
+ handlers have no participant check of their own). A participant's `/` line
191
201
  is a 403 already, so `/knowledge` is the owner's.
192
202
 
193
203
  ## The query log and the embeddings gate
@@ -72,6 +72,14 @@ participant** and **one role**, until it expires or is revoked.
72
72
  `Participants.invite`, `SessionAccess` Local/Remote `#invite`, the invite route, the web participants panel, the
73
73
  TUI's participant commands, `SessionAccess::Contract` and `SessionAccess::ParticipantView`'s fields. The owner's
74
74
  routes (`public_h`) don't show it yet.
75
+ - **An invite during a transition** (`Participants.invite`): checked and issued under a shared hold of the session's
76
+ transition lock (`SessionChain::Sharing.under`, [session-lifecycle.md](session-lifecycle.md#the-transition-lock-sessiontransition)):
77
+ a continue archives the link and ends its grants, so a grant issued in between would outlive the archive. Held by
78
+ another, the invite is refused `Grants::Invalid` (`invalid_participant`: `chi share` exits 1, chi web answers 400;
79
+ text only, so an older chi's `--remote` prints it as before), naming the session that continues it under any holder
80
+ (`Participants.held_refusal`: "session ab12cd34 is being continued as <new id>: invite there in a moment" while a
81
+ continue names its new link, "… was continued as <id>: invite there" for a saved successor), else with Busy's words
82
+ naming the holder ("session ab12cd34 is being deleted; try again in a moment").
75
83
  - Rotating the owner token (`chi web --new-token`) never touches grants; `chi share revoke --all` ends them all.
76
84
  - **Bound grants** (`identity`, an email in lower case; nil for any, and absent from the store then): a bound grant
77
85
  is honoured only on a request through the proxy (`web.public_url`) whose identity header carries that email; on the
@@ -221,7 +229,8 @@ A participant's turn acts with the session's tools under the owner's guardrails,
221
229
  once only, and `Guardrails::PairBoundary` denies secrets, chi itself and chi web on loopback, background and
222
230
  scheduled jobs, the environment and credential printers, git config writes (reads only) and git's hooks,
223
231
  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
232
+ attached context (`PairBoundary::TOOL_CLASSES`), a bundle tool declared `participant: :deny`, and the model's own
233
+ question, and asks before a command that makes
225
234
  a link and before a write that may land outside the project, failing closed (a global install or a user config write
226
235
  that names no path, `Guardrails::ImplicitWriters`, and a script read from stdin count; a session at or above home has
227
236
  none: every write asks) ([guardrails](../guardrails.md#a-participants-pair-boundary)).
@@ -384,7 +393,9 @@ command that waits for it, and `send --wait -m` skips the owner's busy check (it
384
393
  doesn't refuse it; that check's `wait/prepare` without a turn would be 403 `not_permitted`) and waits on the turn it
385
394
  queued, as `--turn T` does.
386
395
 
387
- **The tool calls.** `Guardrails::PairBoundary` sits in the participant boundary's seat: the owner's checks and rules
396
+ **The tool calls.** `Guardrails::PairBoundary` sits in the participant boundary's seat; a bundle tool declared
397
+ `chi.tool …, participant: :deny` is refused there before any check or ask (`Targets#participant`, read from the
398
+ registered entry; `call_tool(chi/<name>)` is unwrapped to the tool's own name first). The owner's checks and rules
388
399
  decide the rest, as for the owner's turns ([guardrails](../guardrails.md#a-participants-pair-boundary)). It judges a path every way it resolves
389
400
  (`PathResolve.reals`: a `..` after a symlinked folder climbs out of its target, as the read opens it;
390
401
  [guardrails](../guardrails.md#how-paths-resolve)). Approvals and questions are owner-only: the
@@ -499,7 +510,8 @@ fields: a field added to an event later reaches nobody until it is named there.
499
510
  `context_window_tokens`, never `status`, the model-facing line; `generation_completed`: its `speed` only;
500
511
  `working_set_updated`: `.working_set`, below); and bare markers (the type alone) for the answers to a question or
501
512
  offer, and `snapshot` / `reset` (the page re-reads the session at a `reset`, as the owner's). Every other type,
502
- known (`DROPPED`) or new, is dropped. `spec/web/participant_view_spec.rb` scans every `type: :name` chi emits and
513
+ known (`DROPPED`) or new, is dropped (`chips_updated` among them: a bundle's chips are the owner's session bar, and
514
+ `GET …/context` is owner-only). `spec/web/participant_view_spec.rb` scans every `type: :name` chi emits and
503
515
  every handler of the web's stream, and fails until a new one is named in `EVENTS` or `DROPPED`.
504
516
  - **The frames** (`Web::ParticipantStreamFilter`). The Bridge's chunks are cut into frames (`\r?\n\r?\n`, a partial
505
517
  one kept for the next chunk, one over 1 MiB dropped to its end); each frame's JSON goes through `.event` and is
@@ -53,7 +53,10 @@ so nothing reads it as a session):
53
53
  A dead one is removed by whoever reads the folder. A live one on the same address under another session id is superseded by the announce
54
54
  (a `/clear` gives Claude a new session id on the same socket): removed, its pairing files moved, its links'
55
55
  `peer_session` renamed (`Local#peer_retag`).
56
- - `waiting/<chi session>.json`: `PeerWaiting(session, project, at)`, a 10-minute wait (`WAIT_SECONDS`); an `at` in
56
+ - `waiting/<chi session>.json`: `PeerWaiting(session, project, at, app)`, a 10-minute wait (`WAIT_SECONDS`); `app`
57
+ is the peer's product name as its bundle words it (`peer::APP`, "Claude Code": chi web's waiting chip, which loads
58
+ no plugins), written only when given, read only as a String of at most `APP_CHARS` (60), else none (an older
59
+ worker's mark has none); an `at` in
57
60
  the future or unparsable is stale, and `marks` (what an announce and `--here` pair against) skips an archived
58
61
  session's (stale on read: archiving leaves the file). **A stale wait is removed only by its session's worker** (`PeerWaitExpiry`, from
59
62
  `Worker::MailPart#expire_peer_waits` in `idle_pass`: removed, and once per wait `:peer_wait_ended`, the bundle's
@@ -165,11 +168,11 @@ which posts `…/peers/NAME/say` with its `wait`: chi web waits, and its read ti
165
168
  reached from a continued id: `:continued` naming that link, the words the 0.192.0 skills pair again on), a live
166
169
  worker without the `peer_mail` Bridge feature (`WorkerLink.live_features`, read only), `UNTAKEN_MAX` (200)
167
170
  untaken messages or noted receipts.
168
- 2. Under a shared hold of the session's transition lock (`SessionTransition.shared`, `Local#moved_on`), the
171
+ 2. Under a shared hold of the session's transition lock (`SessionChain::Sharing.under`, `Local#moved_on`), the
169
172
  continued check again, then the delivery (step 3): a continue holding the lock (from after its recap through
170
- `PeerContinue`'s carry) refuses the say `:continued` naming its new link (`SessionChain::Successor.of` with
171
- `in_flight: true`; the line `this session is being continued as <id>: say it again in a moment`, `in_flight`
172
- on the wire), or `:busy` (`SessionTransition::Busy`'s words) when the holder names none. So a say never lands
173
+ `PeerContinue`'s carry) refuses the say `:continued` naming its new link (the line `this session is being
174
+ continued as <id>: say it again in a moment`, `in_flight` on the wire, saved or not), any other holder names a
175
+ saved successor, or `:busy` (`SessionTransition::Busy`'s words) when there is none. So a say never lands
173
176
  in a mailbox the carry already read (N1). The pairing is read again inside the hold: a continue saves its new
174
177
  link, then copies the pairing in its `before_spawn` holding the link's lock, so a say meanwhile is busy, never a
175
178
  refusal that sends the peer to pair again. The feature probe before and the receipt wait after stay outside the
@@ -199,7 +202,8 @@ why a wake can't run: `:queued`, `:exit`, `:leaving`, `:before_turn` (nil: it ma
199
202
  - **Which folders:** every `<peer>/in`, whatever its `link.json` (the link gates the say only).
200
203
  - **Order:** by `at`, then peer name, then serial. One note each: id `peer-<name>-<box>-<serial>` (the box keeps
201
204
  a fork's seed notes from hiding its own third message), source `peer <Label>`, the `peer` hash (`PeerNote.payload`
202
- plus `box`), its text by `PeerNote.body` (a wake note up to the tool output cap, a plain one up to
205
+ plus `box`; its `verdict` is `PeerNote.verdict_of`, the one parser `…/peers` answer rows use too, and with a verdict
206
+ `said`, the summary without it, `PeerNote.said`, for the web's peer row), its text by `PeerNote.body` (a wake note up to the tool output cap, a plain one up to
203
207
  `PeerNote::HELD_CHARS`; over it, `PeerNote.message_text` points at `<peer>_read(serial: N)`).
204
208
  - **Wake:** the batch wakes when a message in it asked, `peer.turns` is above 0 (else `held: off`), the caller
205
209
  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;
@@ -300,8 +304,8 @@ starts empty).
300
304
  `Web::PeerRoutes` (all `:owner`, a participant gets 403):
301
305
 
302
306
  - `GET …/peers` → `{peers: [{name, label, paired_at, from, address, can_send, messages, exchanges, waiting}]}`: one
303
- row per mailbox folder (`PeerRoster`), and one per peer this session waits for, with `waiting: {until}` (a fresh
304
- wait only: `#waiting_rows`; the page's waiting chip, `peer_wait.js`), its newest 20 messages with their receipts and `words`
307
+ row per mailbox folder (`PeerRoster`), and one per peer this session waits for, with `waiting: {until}` and, when its mark
308
+ names one, `app` (a fresh wait only: `#waiting_rows`; the page's waiting chip, `peer_wait.js`), its newest 20 messages with their receipts and `words`
305
309
  (`PeerRoster.state_words`), and `exchanges` (`PeerExchanges.joined` over chi's sends and the messages as answer
306
310
  lines). No text.
307
311
  - `GET …/peers/NAME/messages/SERIAL` (the text and its receipt); `DELETE …/peers/NAME` (Unpair, and the waiting
@@ -205,9 +205,9 @@ continue, followed send and delete honour it.
205
205
  moment"). A stop is "being stopped" and an archive "being archived", said as a delete is: a non-continue holder
206
206
  (`other_than_continue?`) names no new link, and `in_flight` reads no continue under it, whatever intent a crashed
207
207
  continue left. `exclusive`'s own Busy, the seats' busy refusal (`deliver_turn`), the continue's `transition_busy`
208
- (its detail, which `--remote` reads back), `ContextSources.changing`, `Participants.invite`, the delete's refusal
209
- (`DeleteRefused.held`) and the delete preview take their words from it; a delete holding the lock makes the seats
210
- name no successor (`Hold.under`). The peer say/pair and the context push answer a status, `:busy`, whose words
208
+ (its detail, which `--remote` reads back), `ContextChange.under`, `Participants.invite`, the delete's refusal
209
+ (`DeleteRefused.held`), the delete preview and `SessionChain::Sharing` (below) take their words from it; a delete
210
+ holding the lock makes the seats name no successor (`Hold.under`). The peer say/pair and the context push answer a status, `:busy`, whose words
211
211
  are the plain ones. Those are `Busy#retry_message`, `#message` for every taker but a stop: a stop's Busy
212
212
  (`taker: :stop`) that met a transition says what to do instead ("session ab12cd34 is being deleted", "… being
213
213
  archived", "… being continued as <new id>: stop that one"). `DeleteRefused.held` and `ArchiveRefused.held` keep
@@ -218,10 +218,21 @@ continue, followed send and delete honour it.
218
218
  folder only for a session whose file is there: a deleted session's folder is never made again, nothing is held and
219
219
  the caller's own gone refusal follows; a lock file it made for a session gone by the block's end is taken back),
220
220
  around every arrival's check and write (the seats, below), a peer say's, a peer pair's and a context push's
221
- continued check and write (`SessionAccess::Local#moved_on`), a context add or remove (`ContextSources.changing`),
221
+ continued check and write (`SessionAccess::Local#moved_on`), a context add or remove (`ContextChange.under`),
222
222
  and an invite (`Participants.invite`). A caller that can't write the session folder
223
223
  (a peer's chi behind the mailbox door) holds an existing lock file read-only, and holds nothing when there is none
224
224
  (no transition holds a file that isn't there; one starting after it is not held off).
225
+ - `SessionChain::Sharing.under(id, state_dir:)` (`session_chain/sharing.rb`) is `shared` with the one answer for a
226
+ hold that failed: nil when the hold was taken (this thread's own exclusive hold too; an id that is no session id
227
+ fails closed, `Held` with Busy's plain words, as `shared` yields false), else, from one `Busy.held` read, a continue's new link in flight
228
+ (`Moved`, kind `:continue`: never under a delete, a stop or an archive, whatever a crashed continue left), else a
229
+ saved successor under any kind (`Moved` with the holder's kind; `Successor.of` without the anchor: one
230
+ `Session.list`, only on that refusal), else `Held` with the holder's kind. Both carry the holder's `Busy`
231
+ (`Held#refusal` is it; `Moved#refusal` is `SessionChain::Continued`); callers add their tail and decide whether to
232
+ name a non-continue `Moved`: the seats (`Hold.under`) and a context add or remove (`ContextChange.under`: "; try
233
+ again in a moment" for a new link in flight, ": change it there" for a saved one) name nobody under a delete, a
234
+ stop or an archive, on purpose, the peer say/pair, the context push and an invite (`Participants.invite`: ": invite
235
+ there", "in a moment" in flight) name the saved successor. Every site that takes the lock shared across a check and a write uses it.
225
236
  - `held?(id, state_dir:)` is a kernel probe (`in_flight`, `DeletePreview`, `holder`): it creates nothing and ignores the
226
237
  registry, so it answers the same inside this thread's own hold.
227
238
  - `forget(id, state_dir:)` takes back the lock file `exclusive` left for a session with no session file (one try
@@ -254,8 +265,9 @@ refused `:transition_busy` (`SessionTransition::Busy.held`'s words naming the ho
254
265
  web; a schedule's chain firing counts it a skip, `Schedules::SKIP_REASONS`); a `last:<id>` continue with tries left
255
266
  resolves again and waits again, so a second firing of the same chain follows the first one's new link. Any sender's turn
256
267
  that meets the hold is refused naming the successor from the intent (`follow_guard`, "Arrivals declare their hold"
257
- below: `SessionChain::Successor.in_flight`), else `transition_busy`; so are a peer say, a peer pair and a context push into the link's own source
258
- (`:continued` with `in_flight`), or `:busy` in `SessionTransition::Busy`'s words when the holder names none. Who
268
+ below: `SessionChain::Sharing`), else `transition_busy`; so are a peer say, a peer pair, a context push into the
269
+ link's own source (`:continued` with `in_flight`, its new link saved or not), a context add or remove and an invite,
270
+ or `:busy` in `SessionTransition::Busy`'s words when the holder names none. Who
259
271
  continues a link is one answer, `SessionChain::Successor.of(id, state_dir:, in_flight:)` (`via` `:next`, `:anchor`
260
272
  or `:in_flight`), and the refusal one wording, `SessionChain::Continued` ("session X was continued as Y", "is being
261
273
  continued as" in flight), each site adding only what to do next. The new link's worker starts inside the hold, in its own process: its boot writes into its
@@ -335,8 +347,9 @@ by `spec/session_lifecycle/allowed_spec.rb`. The hold is taken once, in the thre
335
347
  `Dispatch.deliver` (around the refusal check, the write and the wake), `Dispatch.wake` (around the wake) and
336
348
  `SessionManager.deliver_turn` (`follow_guard`, around all of the delivery: the resume, the Bridge's wait and post, the
337
349
  file and the second liveness check). Not in `resume_session` / `start_for_inbox`: a continue's undo reaches them on its
338
- own token. A seat met by a held lock refuses, nothing written: a continue naming its new link (`Successor.in_flight`,
339
- else a saved one) → `:continued` / 409 `link_continued` with `successor_id`; else `:busy` / 409 `transition_busy`
350
+ own token. A seat met by a held lock refuses, nothing written: a continue naming its new link, else a saved successor
351
+ (`SessionChain::Sharing`'s `Moved`, but never under a delete, a stop or an archive) → `:continued` / 409
352
+ `link_continued` with `successor_id`; else `:busy` / 409 `transition_busy`
340
353
  (`DeliverResult::BUSY`, `SessionTransition::Busy`'s words). chi send, an ask and the Exchange under them retry busy as
341
354
  they follow a continue (`Exchange#relocate busy:`: the same link again, within `CONTINUING_WAIT`); a same-mode schedule
342
355
  firing counts it a skip; the web composer, a delegate follow-up, a plugin's send and a participant's turn report it.
@@ -348,9 +361,9 @@ firing counts it a skip; the web composer, a delegate follow-up, a plugin's send
348
361
  | ring | `:none` | `ChildReports` rings once, no retry; `ChildMove` moves rings (`return_rings` gives them back); a continue's undo wakes for them on its own token. |
349
362
  | fresh_verdict | `:none` | `VerifyFresh.forward` writes once, no retry; the verdict is for the card in the parent it names, continued or not; it starts no worker. |
350
363
  | leave (respawn) | `:none` | After the worker's own release, spanning two processes (outside the lock); a refusal would drop a restart or queued input's start with no retry; a continue stops the worker first and the stop wins. |
351
- | 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`). |
352
- | context push, peer say, peer pair | shared | Phase 1 (`Local#moved_on`); the say's delivery seat holds again (shared beside shared). |
353
- | invite (`Participants.invite`) | shared | A continue archives the link and ends its grants; refused `Grants::Invalid` with Busy's words. |
364
+ | context add / remove (`Local#context_add`/`#context_remove`, chi web's URL add and detach) | shared | `ContextChange.under` (`SessionChain::Sharing`): a continue copies the session's own sources. Refused `ContextSources::Held` (423 `context_busy`), naming who continues the session as the seats do, else Busy's words. |
365
+ | context push, peer say, peer pair | shared | `SessionChain::Sharing.under` (`Local#moved_on`): `:continued` naming a continue's new link in flight, else a saved successor whatever the holder; else `:busy`. The say's delivery seat holds again (shared beside shared). |
366
+ | invite (`Participants.invite`) | shared | `SessionChain::Sharing.under`: a continue archives the link and ends its grants; refused `Grants::Invalid` naming who continues the session (any holder), else Busy's words. |
354
367
  | 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. |
355
368
  | `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. |
356
369
  | 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. |
@@ -398,7 +411,8 @@ These are documented race boundaries, not promises of an atomic lifecycle transi
398
411
  5. A new arrival (a `WakePolicy` row, a delivery outside the seats) declares its hold: `hold: :shared` (the seat
399
412
  takes it) or `hold: :none` with its reason; a raw `SessionInbox.write_*` site is listed with its hold in
400
413
  `spec/session_lifecycle_writers_spec.rb`; one outside the inbox that changes what a transition carries takes
401
- `SessionTransition.shared` around its check and write (see "Arrivals declare their hold").
414
+ `SessionChain::Sharing.under` around its check and write (see "Arrivals declare their hold"), which answers who
415
+ continues the session when a transition holds it.
402
416
  6. If the fact changes a state, update `SessionLifecycle::STATES`/`Reading.derive` and `CANONICAL`, then the
403
417
  `ALLOWED` cells (the literal ones by hand; the delivery ones follow `WakePolicy::ROWS`) and the matrix's rows; a
404
418
  decider that answers otherwise is a `KNOWN_DIFFERENCES` entry with its reason, never a silent cell change.