samagotchi 0.164.0 → 0.166.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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -1
  3. data/docs/architecture.md +7 -5
  4. data/docs/cli.md +23 -12
  5. data/docs/configuration.md +8 -2
  6. data/docs/guardrails.md +19 -18
  7. data/docs/internals/block-renderers.md +1 -1
  8. data/docs/internals/bridge.md +10 -3
  9. data/docs/internals/bundles.md +4 -2
  10. data/docs/internals/inline-widgets.md +8 -1
  11. data/docs/internals/remote-sessions.md +1 -1
  12. data/docs/internals/web-frontend.md +73 -13
  13. data/docs/memory.md +12 -7
  14. data/docs/plugins.md +6 -4
  15. data/docs/releasing.md +17 -4
  16. data/docs/scheduling.md +25 -3
  17. data/docs/sessions.md +12 -10
  18. data/docs/testing.md +37 -4
  19. data/lib/samagotchi/block_renderers.rb +3 -6
  20. data/lib/samagotchi/bridge/card_store.rb +2 -1
  21. data/lib/samagotchi/bridge/turn_accumulator.rb +7 -8
  22. data/lib/samagotchi/bridge.rb +45 -3
  23. data/lib/samagotchi/bundle_command/installed_check.rb +2 -1
  24. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  25. data/lib/samagotchi/chi_home.rb +44 -2
  26. data/lib/samagotchi/client_id.rb +34 -3
  27. data/lib/samagotchi/compat.rb +34 -0
  28. data/lib/samagotchi/context_command.rb +3 -0
  29. data/lib/samagotchi/context_providers.rb +5 -6
  30. data/lib/samagotchi/context_sources.rb +2 -2
  31. data/lib/samagotchi/continue_intent.rb +50 -5
  32. data/lib/samagotchi/events.rb +4 -4
  33. data/lib/samagotchi/extension_load.rb +2 -1
  34. data/lib/samagotchi/guardrails/approvals.rb +36 -9
  35. data/lib/samagotchi/guardrails/child_boundary.rb +7 -27
  36. data/lib/samagotchi/guardrails/rules.rb +11 -9
  37. data/lib/samagotchi/guardrails/targets.rb +3 -4
  38. data/lib/samagotchi/inline_widgets.rb +16 -1
  39. data/lib/samagotchi/memory_bundle/provenance.rb +46 -4
  40. data/lib/samagotchi/memory_bundle/status.rb +2 -1
  41. data/lib/samagotchi/memory_command.rb +3 -0
  42. data/lib/samagotchi/memory_orphans.rb +4 -7
  43. data/lib/samagotchi/memory_paths.rb +64 -7
  44. data/lib/samagotchi/memory_usage.rb +1 -1
  45. data/lib/samagotchi/plugin/sessions.rb +8 -3
  46. data/lib/samagotchi/project_command.rb +4 -1
  47. data/lib/samagotchi/project_id_clash.rb +37 -26
  48. data/lib/samagotchi/project_init.rb +24 -7
  49. data/lib/samagotchi/reply_wait/poll.rb +4 -14
  50. data/lib/samagotchi/reply_wait.rb +0 -23
  51. data/lib/samagotchi/run_options.rb +1 -1
  52. data/lib/samagotchi/schedules.rb +124 -106
  53. data/lib/samagotchi/send_command.rb +71 -18
  54. data/lib/samagotchi/session.rb +3 -2
  55. data/lib/samagotchi/session_access/local.rb +19 -2
  56. data/lib/samagotchi/session_access/remote.rb +13 -17
  57. data/lib/samagotchi/session_chain/links.rb +109 -0
  58. data/lib/samagotchi/session_chain.rb +7 -19
  59. data/lib/samagotchi/session_continue.rb +138 -54
  60. data/lib/samagotchi/session_inbox.rb +1 -1
  61. data/lib/samagotchi/session_inbox_delivery.rb +57 -38
  62. data/lib/samagotchi/session_manager/delivery.rb +104 -18
  63. data/lib/samagotchi/session_manager/removal.rb +13 -7
  64. data/lib/samagotchi/session_manager.rb +1 -0
  65. data/lib/samagotchi/session_retention.rb +20 -10
  66. data/lib/samagotchi/session_setup.rb +31 -1
  67. data/lib/samagotchi/state_format.rb +12 -8
  68. data/lib/samagotchi/terminal_ui/attach_launcher.rb +6 -7
  69. data/lib/samagotchi/terminal_ui.rb +20 -9
  70. data/lib/samagotchi/tools/delegate.rb +2 -3
  71. data/lib/samagotchi/verify_fresh.rb +4 -1
  72. data/lib/samagotchi/version.rb +1 -1
  73. data/lib/samagotchi/web/public/activity.js +2 -2
  74. data/lib/samagotchi/web/public/app.js +28 -21
  75. data/lib/samagotchi/web/public/auth_lost.js +3 -1
  76. data/lib/samagotchi/web/public/bar_fold.js +293 -0
  77. data/lib/samagotchi/web/public/card.js +1 -1
  78. data/lib/samagotchi/web/public/chip_popover.js +5 -1
  79. data/lib/samagotchi/web/public/composer_mode.js +5 -7
  80. data/lib/samagotchi/web/public/delivery_line.js +19 -4
  81. data/lib/samagotchi/web/public/index.html +242 -94
  82. data/lib/samagotchi/web/public/info_bar.js +28 -16
  83. data/lib/samagotchi/web/public/info_bar_model.js +76 -2
  84. data/lib/samagotchi/web/public/live_timing.js +3 -0
  85. data/lib/samagotchi/web/public/more_sheet.js +98 -40
  86. data/lib/samagotchi/web/public/resync_reach.js +59 -0
  87. data/lib/samagotchi/web/public/session_fields.js +1 -0
  88. data/lib/samagotchi/web/public/session_state.js +5 -0
  89. data/lib/samagotchi/web/public/stage_frame.js +4 -2
  90. data/lib/samagotchi/web/public/stage_stall.js +134 -0
  91. data/lib/samagotchi/web/public/stage_view.js +78 -7
  92. data/lib/samagotchi/web/public/stream_handlers.js +1 -1
  93. data/lib/samagotchi/web/public/turn_events.js +0 -122
  94. data/lib/samagotchi/web/public/turn_model.js +1 -1
  95. data/lib/samagotchi/web/public/widget_picks.js +18 -3
  96. data/lib/samagotchi/web/session_control.rb +15 -2
  97. data/lib/samagotchi/web/session_create.rb +4 -2
  98. data/lib/samagotchi/web/token.rb +2 -2
  99. data/lib/samagotchi/web/update_check.rb +27 -8
  100. metadata +5 -1
@@ -24,7 +24,7 @@ page. A factory dep a new version stops passing is the same hazard the other way
24
24
  out of `send_turn.js`, `session_actions.js` and `lists_view.js`); a page loaded before keeps all its old modules
25
25
  until a reload, so the risk is a mixed cache, not an open tab. `answer_fold.js`, `details_motion.js`,
26
26
  `turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
27
- `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
27
+ `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says reconnecting / can't reach chi web) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
28
28
 
29
29
  ## Two pages, two models
30
30
 
@@ -218,21 +218,63 @@ createFamilyPop`) still place their own. Every popover behaves the same (`popove
218
218
  none behind. `model_picker.js`, `command_list.js` (listboxes: the focus stays in the input), `ref_menu.js` (a menu)
219
219
  and `update_sheet.js` (a native modal `<dialog>`) aren't popovers in that sense.
220
220
 
221
- **A phone's session bar** (`more_sheet.js`): CSS alone folds the chips and the bar's buttons away at 600 px or less
222
- (`display:none`, so the same `.meta` draws both layouts and `info_bar.js` knows nothing of it); they stay in the DOM.
223
- ⋯'s sheet (`#infoMoreBtn`) draws its rows from the bar's model, and a row or an action clicks the real chip or button, so
224
- each keeps one set of handlers, confirmations and in-flight rules. A chip the sheet opens has no box to be placed at, so
225
- `chip_popover.js` places it, marks `aria-expanded` and gives focus back at the page's `[data-anchor-stand-in]` (⋯); that
226
- matters at exactly 600 px, where the CSS is a phone's but the shell (`SHEET_MAX`, `<`) still draws a popover, not a sheet.
227
- A new chip on the bar needs its place in that CSS's hidden list and a row in `moreRows`, and its attention state in the row, or
228
- it is lost on a phone. `app.js`'s `updateInfoBar` feeds the sheet (`update`) on every redraw; its rows and actions draw into
229
- fixed slots, so a row that joins keeps the focus where it was. `composer_mode.js`'s phone-width listener closes the sheet when the window grows.
230
-
221
+ **The session bar: one row** (`bar_fold.js`, `more_sheet.js`): `#infoBar` is one row at every width, and what doesn't
222
+ fit folds into ⋯. Every chip and button is an **item** of `info_bar_model.js` `BAR_ITEMS`: `{key, selector, group,
223
+ rank, phone, compact, menuOrder}`. `rank` is the desktop fold order (higher stays longer; `pinned` never folds: status,
224
+ ctx, ⋯; `menu` is never on the row: archive, delete); `phone: row` items are the only row candidates at 600 px or less
225
+ (status, ctx, speed, ⚙, ⋯); ⚙ alone has a `compact` form (its icon, the dot when the session set its own), tried before
226
+ it folds, and the phone's from the start. `info_bar.js` draws the `.meta` as four groups (identity: id, status, ctx,
227
+ speed, clock | setup: ⚙, model, 🧰, notes, set/mem | relations | trail: folder, worker badge), each `.bar-sep` classed
228
+ by the group it precedes; `#infoActions` (continue →, stop session) and ⋯ follow, right-aligned.
229
+
230
+ The **fold** is `foldPlan` (pure): every candidate full, then while the row is wider than the bar the lowest rank on it
231
+ (all items of that rank together) goes compact, else folds; pinned items never fold (the row clips). Its widths are
232
+ measured, never read from a squeezed box: the row's children are `flex:none` and the caps (model 40ch, folder 48ch)
233
+ hold always, so a drawn chip's width is its natural one. `createBarFold` caches them per key + text; a folded item has
234
+ no box, so a text first seen while folded is measured by dropping the fold's attributes for one synchronous pass
235
+ (before paint). ⋯'s count joins the row's width once something it counts folds. The live chips (ctx, speed, clock) are
236
+ cached per key as a budget (their CSS reserve is their `min-width`): a tick within it costs a width read, no refold.
237
+ A recompute runs only when an input changes: `foldSignature(bar, buttons)` (the items present and every non-live
238
+ text: a status, `set 9 → set 10`, a delegate starting to wait), the bar's width (`ResizeObserver` on `#infoBar`), the
239
+ phone profile, a live chip past its budget, the fonts ready or a zoom (those clear the cache). A recompute it starts by
240
+ itself calls `onChange` (app.js touches `infoBar`) so ⋯ follows. Call order in `app.js updateInfoBar`: `renderInfoBar`
241
+ → `barFold.update` → `moreSheet.update({bar, buttons, folded})`, in one task. The plan is three attributes on
242
+ `#infoBar` (lit renders into `#infoText` inside it, so they survive the redraws): `data-folded="notes toolkit dir"`,
243
+ `data-compact="settings"`, `data-empty-groups="relations"`; index.html has one `display:none` selector per key and
244
+ hides an empty group with its hairline. **A new chip needs a `BAR_ITEMS` entry and its `data-folded` selector**
245
+ (`bar_fold.test.js` checks every foldable key has one), or it can't fold.
246
+
247
+ ⋯'s menu (`more_sheet.js`) is a popover above 600 px and a bottom sheet under it (`chip_popover.js`, `SHEET_MAX`; its
248
+ own resize handling switches them, so a width change doesn't close it). It holds a row only for a folded item (the id,
249
+ ⚙ when folded and not compact, "earlier links pruned" included), the folded ones of speed, clock and folder on its
250
+ telemetry line (none: no line), archive and delete always, continue and stop when folded. Its dot (`moreAttention`)
251
+ and its count (`moreCount`, a desktop's, none at 0; archive and delete don't count) are from folded items alone: a chip
252
+ on the row shows its own state. Folded items stay in the DOM, display:none: a row or an action clicks the real chip or
253
+ button, so each keeps one set of handlers, confirmations and in-flight rules, and what a chip opens has no box to be
254
+ placed at, so `chip_popover.js` places it, marks `aria-expanded` and gives focus back at the page's
255
+ `[data-anchor-stand-in]` (⋯). Rows and actions draw into fixed slots, so a row that joins keeps the focus where it was.
256
+ The e2e reach an item wherever it is with `spec/e2e/support/layout.js` `clickBarItem` (the row, else ⋯'s `[data-row]`).
257
+
258
+
259
+ ## Safe areas
260
+
261
+ The owner page runs under a phone's notch, status bar and home indicator (`viewport-fit=cover`; the body is `100dvh`,
262
+ so a Safari tab's toolbar never covers the composer). index.html's `:root` names the insets once, `--safe-t/r/b/l`
263
+ (`env(safe-area-inset-*)`, 0 on a desktop), and only these read them: main's padding (16px, or the inset where it is
264
+ wider; its bottom is 16px less than `--safe-b`, since the session's card floats 16px above main's bottom; a phone's
265
+ session panel has no bottom padding and runs to the screen's bottom, its card at `--dock-bottom`, 16px or the
266
+ indicator's line), a bottom
267
+ sheet's offset (`chip_popover.js place`: 8px above the indicator, or a keyboard's offset alone), the update sheet, the
268
+ toast's fallback place (in a session `--toast-bottom` already sits it above the card), the lightbox's padding and the
269
+ signed-out banner (`auth_lost.js`, `env()` itself: the participant page has no `--safe-*`). A new fixed or bottom-anchored
270
+ piece reads `--safe-*`, never `env()`: the e2e set the names by hand (`web.spec.js`, a portrait phone and a landscape one),
271
+ as Chromium has no insets. The theme-color metas are tokens.css's `--bg` per theme (`theme.test.js` pins them).
231
272
 
232
273
  ## The stage's height
233
274
 
234
275
  `stage_frame.js` is the one writer. The cap is a ceiling: 60% of the page, 80% with the cloud open, 85% while a card has
235
- the room, and never above the session panel. The frame is grow-only while a turn runs, so a change inside the stage
276
+ the room, and never above the session panel (less the card, its offset from the panel's bottom as computed: index.html
277
+ `--dock-bottom`, and 16px). The frame is grow-only while a turn runs, so a change inside the stage
236
278
  never moves its top edge, with one exception: **the next step after a blocking card's answer lets the frame go, once**
237
279
  (`stage_view.js releaseHeldWait`, from `generationStarted`). The `held-wait` class says it is due: set with `waiting`,
238
280
  cleared there, so a later step, which calls it again, does nothing. What goes together: the live slots' waiting height, a
@@ -275,6 +317,24 @@ writes for itself: `generationCompleted` and a step's close write its text, a ca
275
317
  `reset`, `turnEnded` and `flush` itself cancel the timer. A frame already requested can't be cancelled that way, so it may
276
318
  run `flush` with nothing to write, which doesn't count as a flush for the interval.
277
319
 
320
+ **Quiet (stall).** The dot blinks the same whether the model works or the line went dead: the Bridge's idle `: ping`
321
+ never reaches EventSource's JS, and a running tool sends nothing between its start and end. So a running turn that
322
+ has had no event for a while says so (`stage_stall.js`; the code says "stall" — `stallOf`, `.ts-stall`,
323
+ `data-stall` — the user reads "quiet": `liveSlots().quiet` and `stage_model.js QUIET_MS` are other things). Alive is
324
+ any `stage_view.js` call a turn event drives (`turnStarted`, the generation and tool events, a chunk, a notice, a
325
+ steer, a card, a place, `questionRefs`; a replay's count too). Kind A (streamed, or between steps) reads "quiet 0:40 ·
326
+ no new events" from 30 s, louder from 90 s; kind B (no token yet in the step; a joiner counts from the snapshot's
327
+ generation age, `delivery_line.js genAge`) reads "thinking quietly 0:50 · no tokens yet" from 45 s, louder from 3 min.
328
+ A phone shows the short text. Nothing is said while a tool runs (its own clock, `.ts-tool-clock`, from 10 s instead),
329
+ a blocking card waits, the live timing line has a note (a retry, plugins' setup: `live_timing.js note`), the turn has
330
+ ended, or for 5 s after the page shows again (`visibilitychange`). The open session's stream not live for a second
331
+ (`streamControl` gone: `workerGone` until the resync streams again) reads "reconnecting… · events paused" and wins.
332
+ It ticks on the live timing line's clock (app.js `createLiveTurn`'s `onTick` → `turnDom.tick`; 200 ms, then 1 s) and
333
+ writes only when its text changes. Expanded, it is a right-aligned span in the now row, its tint by level
334
+ (`.ts-now[data-stall]`); where the now row doesn't show (a collapsed stage, a plain turn's), its short text follows
335
+ the timing line in the status row (`.ts-stall-head`). Hooks: `.turn-stage.stalled` and `data-stall` (1, 2, net) on
336
+ the stage's root. The dot keeps blinking meanwhile.
337
+
278
338
  ## Stale answers
279
339
 
280
340
  The page switches sessions, reopens a popover or asks again while a fetch is out. An answer for the old ask must be
@@ -308,7 +368,7 @@ uses `latest.js`.
308
368
  |---|---|---|
309
369
  | The hub, `GET /api/events` (`data.js openEvents`) | app.js `openSessionEvents` (scoped by `?dir`) | `snapshot` then `session` / `session_gone` → `applySessionEvent` → `allSessions`; EventSource reconnects itself (a fresh snapshot); `onClosed` (a proxy sign-in on reconnect): probe, reopen after `EVENTS_REOPEN_MS` |
310
370
  | A second hub stream, unscoped | `notifications.js` (`allEvents`) on a project's page | the Home Screen app's device tidy-up across projects |
311
- | The open session, `GET /api/sessions/:id/stream?from_seq=` (`data.js openStream`) | app.js `startStream` from `store.current.streamSeq` | events → `stream_handlers.js`. It closes itself on an error; the page resyncs (`resync`: a fresh render and a new stream from its cursor), once at once when it had opened, else after `STREAM_RETRY_MS` |
371
+ | The open session, `GET /api/sessions/:id/stream?from_seq=` (`data.js openStream`) | app.js `startStream` from `store.current.streamSeq` | events → `stream_handlers.js`. It closes itself on an error; the page resyncs (`resync`: a fresh render and a new stream from its cursor), once at once when it had opened, else after `STREAM_RETRY_MS`. Meanwhile a turn the stage holds reads "reconnecting…" (Quiet, under Frames), and the Bridge's `: ping` is invisible to the page. A re-read that can't reach chi web keeps the history it drew (`resync_reach.js`): the session bar's status chip says "reconnecting…" while `retryResync` tries, "can't reach chi web" once the tries ran out (`store.current.reach`), and any hub event for the session then re-reads it (`followSelectedSession`); the next drawn re-read clears it. Only a first load (select's "Loading…") shows the error in the history |
312
372
  | The participant stream | `participant.js connect` | listens for `STREAM_EVENTS`, which is `Web::ParticipantView::EVENTS` (checked by `spec/web/participant_view_spec.rb`); reopened from fresh data when CLOSED |
313
373
 
314
374
  A new event type for the owner page is a handler in `stream_handlers.js` (the participant view spec makes it decide
data/docs/memory.md CHANGED
@@ -32,8 +32,13 @@ the folder is left as is: it is created when missing, nothing is marked).
32
32
  (`chi context --project`) are named by the marker's `id:` (`<folder name>-<8 random hex>`), not
33
33
  by its path, so moving or renaming the folder keeps them: a session started there after the move
34
34
  finds them, and one saved before it (its file stores `project_id`) keys its context sources by the
35
- id too. A folder chi already ran in at its top keeps its memories after `init`: they move to the
36
- id. A later `git init` in the folder makes it a repository, keyed by its path again (git wins): its
35
+ id too. An existing id folder is used only when its `.root` claims this project, or when its
36
+ previous claimant or a saved session's root no longer has this id after a move; otherwise chi
37
+ refuses and says to run `chi project init --new-id`. An id folder with no `.root` is taken when its
38
+ name has a path key's shape (`<name>_<8 hex>`: another project's folder); one of any other name (an
39
+ older chi's id folder) is used and claimed at session start. A folder chi
40
+ already ran in at its top keeps its memories after `init`: they move to the id. A later `git init`
41
+ in the folder makes it a repository, keyed by its path again (git wins): its
37
42
  memories stay in the id folder until you move them, and chi names the id folder at session start
38
43
  (and under a `memory_read` miss) while the repository's own folder holds no memories. Memories saved from a *subfolder* before
39
44
  `init` stay in that subfolder's own folder (keyed by its path); `chi project init` and `chi project`
@@ -59,11 +64,11 @@ the folder is left as is: it is created when missing, nothing is marked).
59
64
  but never moves folders: a folder it marks that already has path-keyed memories gets no id until
60
65
  `chi project init`.
61
66
  - **A copy shares memories.** A copied marked folder (`cp -R`) keeps the id, so the two share one
62
- memories folder; at session start in the copy chi says so (a `memory>` load warning: "… share chi
63
- project id … (a copied folder?)"; the id folder's `.root` names the folder that started a session
64
- with it last, the original keeps it). `chi project init --new-id` in the copy gives it a fresh id,
65
- with a copy of the memories and project context sources it had: each folder goes its own way.
66
- After a move, the new path just takes `.root` over, with no warning.
67
+ id folder. At session start chi claims a new id folder in `.root`; if another marked folder still
68
+ has that id, chi warns and refuses to use the folder's memories or project context sources.
69
+ `chi project init --new-id` in the copy gives it a fresh id, but does not copy an id folder claimed
70
+ by another project. After a move, the new path takes `.root` over when the old path no longer has
71
+ that id, with no warning.
67
72
  - **Restart what runs there.** A session running in the folder when it is marked keeps the old memories
68
73
  folder and AGENTS.md chain in its prompt until `chi sessions restart ID` (init names them); a running
69
74
  `chi web` groups the folder's older sessions under the project after its restart.
data/docs/plugins.md CHANGED
@@ -341,9 +341,9 @@ is what `targets:` says:
341
341
  it when the call writes, never when it only reads (a read's paths are
342
342
  `path:` rule material, not a write); a tool without it is judged as
343
343
  today.
344
- - `command:`: a shell command the call runs; `command:` rules match it, and
345
- a delegate child's boundary checks where it runs and whether it changes
346
- what every checkout shares (as for `execute`).
344
+ - `command:`: a shell command the call runs; `tool: shell` and `command:`
345
+ rules match it, and a delegate child's boundary checks it as it does
346
+ `execute` and `task_create`.
347
347
  - `cwd:`: where it runs, for the repo root and relative paths.
348
348
  - `acts_as:`: the tool a call stands for, when the tool runs other tools
349
349
  (chi's `call_tool`, which calls a tool a [source](#chitool_sourcecall-acts_as-label-wait-prefix) published). Rules keyed by that tool's name match the
@@ -1260,7 +1260,9 @@ ctx.sessions.review(subjects: ["docs/plan.md"], seed: handoff) # => a review se
1260
1260
  review session's id. The test kit's `bundle.sessions` answers `review-1`,
1261
1261
  `review-2`…
1262
1262
  - `send(id, text)` sends a user message to a session (an id or a unique
1263
- prefix); it runs as a turn, and a stopped session is woken. It waits up to
1263
+ prefix); it runs as a turn, and an idle session is woken. A session its
1264
+ owner stopped or archived is not: `Error` (`session_stopped` /
1265
+ `session_archived`), nothing sent. It waits up to
1264
1266
  5 s for the session's worker, so call it from an anytime command or a
1265
1267
  thread of your own, never from a tool or hook of a running turn. A
1266
1268
  session a `--non-interactive` one-shot has can't take it.
data/docs/releasing.md CHANGED
@@ -76,7 +76,7 @@ as the GitHub release body.
76
76
  | `rake lint` / `rake lint:fix` | RuboCop over the repo (must report no offenses; CI runs it) / its safe autocorrect (`rubocop -a`). |
77
77
  | `rake gem:validate`, `gem:build`, `gem:install`, `gem:clean` | Check the gemspec; build the gem into `pkg/`; build and install it locally; remove the built gems. |
78
78
  | `rake release:draft_changelog` | A draft Unreleased section from the commit subjects since the last tag, grouped. Stdout only. |
79
- | `rake release:bump[X.Y.Z]` | VERSION, the system manifest, Gemfile.lock, CHANGELOG, a compatibility corpus at `spec/compat/X.Y.Z/` written through the current state writers, and `requires_chi: ">= X.Y.Z"` for each bundle marked `requires_chi_next` (the marker dropped), then a profile left below a member's `requires_chi` raised to it, with a patch bump of its version (none when it moved since the last tag) and named in the CHANGELOG's "Update with `chi update`" line, and each entry an `# Unreleased` comment in `Plugin::Api::SINCE` or `Manifest::SINCE` names moved into the table at X.Y.Z (the comment dropped). No commit; commit the corpus with the release. |
79
+ | `rake release:bump[X.Y.Z]` | VERSION, the system manifest, Gemfile.lock, CHANGELOG, a compatibility corpus at `spec/compat/X.Y.Z/` written through the current state writers (with `wire/`: a real Engine and Bridge's replies, recorded twice and refused if the two differ), and `requires_chi: ">= X.Y.Z"` for each bundle marked `requires_chi_next` (the marker dropped), then a profile left below a member's `requires_chi` raised to it, with a patch bump of its version (none when it moved since the last tag) and named in the CHANGELOG's "Update with `chi update`" line, and each entry an `# Unreleased` comment in `Plugin::Api::SINCE` or `Manifest::SINCE` names moved into the table at X.Y.Z (the comment dropped). No commit; commit the corpus with the release. |
80
80
  | `rake release:check` | Clean tracked tree, VERSION == system bundle, a CHANGELOG section, no `requires_chi_next` left, no `# Unreleased` comment left in `Plugin::Api::SINCE` or `Manifest::SINCE`, `bundles:check`, `rake lint` (RuboCop) + `npm run lint` (the web frontend's ESLint), rspec (both roots: `spec` and the bundles' own `spec/`) + `rake bundles:specs` + npm test, `gem build`, then a clean install into a temp GEM_HOME that runs `chi --version`, `chi self` and `chi bundle list` with a temp HOME. Needs the network (gem dependencies). |
81
81
  | `rake release:notes[X.Y.Z]` | Prints the CHANGELOG section (default: the current VERSION). |
82
82
 
@@ -98,9 +98,22 @@ The agent does each step and stops where the user has to say yes.
98
98
  each one's version, none for a profile already bumped since the last tag),
99
99
  which it names in the CHANGELOG's "Update with `chi update`" line, and the
100
100
  SINCE entries it moved out of their `# Unreleased` comments. It also records
101
- the release's session, bridge, cards, schedules and bundle state under
102
- `spec/compat/X.Y.Z/`; commit those samples with the release so the next
103
- release's reader spec checks them as N-1 data.
101
+ the release's session, bridge, cards, schedules and bundle state, and a
102
+ session's input file, note, continue intent and stop marker and a bundle's
103
+ install journal, under
104
+ `spec/compat/X.Y.Z/`, and in its `wire/` what a worker answers its clients
105
+ (`GET state`, `snapshot` idle and mid-turn, `tail`, and the session file:
106
+ `script/release/compat_wire.rb` runs a real Engine and Bridge with a
107
+ scripted kernel, in process); commit those samples with the release so the
108
+ next release's reader specs check them as N-1 data. The wire replies are
109
+ recorded twice and must be equal: a bump that stops with "two recordings
110
+ of wire/<file> differ at <JSON path>" found a field that changes per run
111
+ (a new time, a random id, a measured number). Pin it in
112
+ `CompatWire.normalise` (a `*_ms` key is pinned already; an id the script
113
+ chooses is better pinned at its source), check `spec/release/compat_wire_spec.rb`,
114
+ and run the bump again (nothing is written when it stops). The new VERSION may pass a
115
+ compat shim's `remove_after` (`Compat::SHIMS`): `spec/compat_spec.rb` then
116
+ names it, and the shim goes (or its date moves) before the release.
104
117
  5. **Check.** Add all release files, including the new compatibility corpus, then run it:
105
118
  `git add -A && git commit -m "Release X.Y.Z"` and `bundle exec rake release:check`.
106
119
  Fix anything it finds in new commits and run it again.
data/docs/scheduling.md CHANGED
@@ -62,6 +62,10 @@ a participant's review or pair turn is denied them ([guardrails.md](guardrails.m
62
62
  `head` through the chain: once the session is continued — by a chain schedule or
63
63
  by a `chi send --continues` — the turn goes to the new link, not to the archived
64
64
  anchor the schedule was made against.
65
+ Both modes resolve the **chain's end** (`SessionChain::Links#latest`), not the
66
+ first live link a `chi send` takes: a chain firing can only continue the end, and
67
+ an archived end (a chain you retired) fails the firing instead of being brought
68
+ back as a send would.
65
69
 
66
70
  A `scratch` session is refused at `add`: it is deleted when its terminal leaves.
67
71
  A prompt is checked at `add` too — non-empty and at most 16 KiB
@@ -103,6 +107,13 @@ time zones.
103
107
 
104
108
  A cron tick cannot read a worker's memory, so the tick has two paths.
105
109
 
110
+ **Stopped by its owner** (`chi sessions stop`, the web's Stop: the stop marker,
111
+ `WorkerPresence#stop_marked?`) comes first, in both modes: a skip ("the session is
112
+ stopped; only its owner's message starts it again"), never a restart. A stop that
113
+ lands between the check and a same-mode firing is the same skip: `deliver_turn`
114
+ refuses a schedule's wake of a stopped session (a schedule is no person,
115
+ `ClientId.wake_kind`).
116
+
106
117
  **No live worker** (the usual case for a weekly schedule): the files say what can
107
118
  be known — the saved status is not `running` (and not inside the starting grace),
108
119
  `input/` is empty, no step-limit question is open, and, for chain mode, no worker
@@ -150,9 +161,20 @@ are the refusals that mean "not this moment": `ArchiveRefused` with `busy`, `que
150
161
  or `offer`, or `busy_child`/`queued_child`/`offer_child` (a chain's own running
151
162
  delegate refuses the archive, since `archivable!` walks the whole descendant tree),
152
163
  `SessionContinue::Refused(:continued)` (a human continued it while we were
153
- resolving) and `:open_children`.
154
-
155
- Anything else is a **failure** (`failures += 1`): a gone or archived target,
164
+ resolving) and `:open_children`. So is an archived target that a continue is still
165
+ making the next link of (`being continued as 7b2d41aa; retry at the next tick`): a
166
+ person's `chi send --new --continues` or web `continue →` archives the link before
167
+ its successor is saved, and a tick in that moment sees an archived end
168
+ (`ContinueIntent.in_flight`: the intent written, its lock held). It is checked before
169
+ the busy check, in both modes, and again by a same-mode firing's own look at the
170
+ files; the next tick's walk reaches the new link. A continue that ended between the
171
+ tick's listing and that look (its successor saved, its intent gone) is no failure
172
+ either: the firing walks again on a fresh listing, checks the new link as the tick
173
+ would, and queues its turn there. A stale intent (no continue holds
174
+ its lock: a crash, repaired by the next continue or list) is not in flight, so that
175
+ target still fails `archived`.
176
+
177
+ Anything else is a **failure** (`failures += 1`): a gone or archived target (an archived end of the chain: you retired it, and a schedule never brings it back),
156
178
  `SessionContinue::Refused(:folder_gone)`, `SessionManager::DeleteRefused`,
157
179
  `ModelProfile::MissingModel`, `OwnedByTUI`, `Session::NotFound`, and anything a
158
180
  spawn throws (`Errno::ENOSPC` included — `run_locked` re-raises it after undoing