samagotchi 0.191.0 → 0.192.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -1
- data/docs/architecture.md +5 -4
- data/docs/bundles.md +1 -1
- data/docs/cli.md +15 -7
- data/docs/configuration.md +6 -1
- data/docs/internals/inline-widgets.md +2 -1
- data/docs/internals/participants.md +1 -5
- data/docs/internals/remote-sessions.md +3 -0
- data/docs/internals/session-lifecycle.md +33 -19
- data/docs/internals/web-frontend.md +107 -9
- data/docs/scheduling.md +7 -1
- data/docs/sessions.md +2 -2
- data/docs/testing.md +1 -2
- data/docs/thin-clients.md +98 -12
- data/lib/samagotchi/bridge.rb +2 -3
- data/lib/samagotchi/bundles/mcp/manifest.yml +4 -2
- data/lib/samagotchi/bundles/mcp/plugin.rb +7 -398
- data/lib/samagotchi/bundles/mcp/server_config.rb +158 -0
- data/lib/samagotchi/bundles/mcp/sign_in.rb +261 -0
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +2 -19
- data/lib/samagotchi/compat.rb +1 -7
- data/lib/samagotchi/config.rb +3 -0
- data/lib/samagotchi/delivery.rb +1 -5
- data/lib/samagotchi/schedule_command.rb +1 -0
- data/lib/samagotchi/schedules/prune_part.rb +32 -0
- data/lib/samagotchi/schedules.rb +14 -9
- data/lib/samagotchi/session.rb +7 -0
- data/lib/samagotchi/session_access/remote.rb +1 -1
- data/lib/samagotchi/session_continue.rb +8 -1
- data/lib/samagotchi/session_lifecycle.rb +4 -0
- data/lib/samagotchi/session_manager/delivery.rb +0 -6
- data/lib/samagotchi/session_manager/lifecycle.rb +30 -17
- data/lib/samagotchi/session_manager/listing.rb +2 -1
- data/lib/samagotchi/session_manager/removal.rb +7 -5
- data/lib/samagotchi/session_manager/spawn.rb +2 -3
- data/lib/samagotchi/session_manager.rb +4 -0
- data/lib/samagotchi/session_row.rb +2 -0
- data/lib/samagotchi/session_transition.rb +61 -15
- data/lib/samagotchi/tools/cancel_schedule.rb +10 -6
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -1
- data/lib/samagotchi/web/ask_create.rb +138 -0
- data/lib/samagotchi/web/ask_routes.rb +56 -9
- data/lib/samagotchi/web/last_ask.rb +78 -0
- data/lib/samagotchi/web/public/answer_refs.js +3 -9
- data/lib/samagotchi/web/public/answer_write.js +28 -0
- data/lib/samagotchi/web/public/app.js +72 -96
- data/lib/samagotchi/web/public/block_fix.js +30 -12
- data/lib/samagotchi/web/public/chains.js +3 -1
- data/lib/samagotchi/web/public/command_list.js +5 -3
- data/lib/samagotchi/web/public/composer.js +9 -6
- data/lib/samagotchi/web/public/composer_mount.js +18 -11
- data/lib/samagotchi/web/public/draft_keys.js +10 -0
- data/lib/samagotchi/web/public/drafts.js +278 -0
- data/lib/samagotchi/web/public/owner_claim.js +7 -12
- data/lib/samagotchi/web/public/prompt_history.js +6 -0
- data/lib/samagotchi/web/public/send_turn.js +51 -20
- data/lib/samagotchi/web/public/session_actions.js +80 -16
- data/lib/samagotchi/web/public/session_prefs.js +9 -3
- data/lib/samagotchi/web/public/session_view.js +7 -2
- data/lib/samagotchi/web/public/turn_events.js +0 -2
- data/lib/samagotchi/web/public/unqueue.js +22 -9
- data/lib/samagotchi/web/public/viewer_self.js +1 -6
- data/lib/samagotchi/web/public/views.js +12 -1
- data/lib/samagotchi/web/session_access_routes.rb +6 -3
- data/lib/samagotchi/web/session_control.rb +4 -2
- data/lib/samagotchi/web/session_create.rb +50 -33
- data/lib/samagotchi/web/session_hub.rb +52 -36
- data/lib/samagotchi/web/session_summary.rb +45 -7
- data/lib/samagotchi/web/start_dir.rb +6 -4
- data/lib/samagotchi/worker_presence.rb +22 -6
- metadata +8 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 228161de4fb614d97b4240e1f62444b5f3cb1cbba6df18cf4477f69d95b96828
|
|
4
|
+
data.tar.gz: '0891bd0649800d9cd0f7c81009c6378a650caff0dccf2a3cd5242fa53a4e1d9b'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62f39f21d2daf2dd9af94c3ef70bfd6bdad52202add14653b0013a407974556a66517a2dd492a4e14d9624c2d88f234fe36401eba35604da2aa2ad8f604f76fe
|
|
7
|
+
data.tar.gz: eb2f2a67cd5b5422280650c68d8fb706d3b98cdd828777688004e78ca8170f8d9145ba833e4f4cf212a97577291b1a57dee51dc92b04a1548b5aca54f9632bd7
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,44 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.192.0] - 2026-11-28
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Phone Shortcuts get three flows: a new session answered in one call (`POST /api/sessions` with `reply_for`,
|
|
16
|
+
`timeout` or `request_id`; set `web.ask_dir` and the Shortcut can leave out the folder), `POST
|
|
17
|
+
/api/sessions/last/ask` for the session you last asked from your phone (following continues), and a recent-sessions
|
|
18
|
+
list without delegates (`GET /api/sessions/summaries?delegates=0`). docs/thin-clients.md has an iOS Shortcut recipe
|
|
19
|
+
with a New / Last / Pick menu.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Each session keeps its own draft in the web composer: text typed in one session no longer shows in another, a pick or
|
|
24
|
+
quote goes into the open session's draft, and + new has its own. The draft's text survives a reload in this browser;
|
|
25
|
+
attached images don't.
|
|
26
|
+
- Continuing a session moves its draft to the new link, even if you are in another session when it finishes; the new
|
|
27
|
+
link gets the opener only when there was no draft. The "Restore draft" button is gone.
|
|
28
|
+
- Stopping a session that is being continued, deleted or archived is refused right away and says what to do
|
|
29
|
+
("session ab12cd34 is being continued as 7b2d41aa-…: stop that one") instead of waiting 10 seconds; in the web the
|
|
30
|
+
toast offers Open on the new link. A refused stop no longer ends the running turn.
|
|
31
|
+
- A participant's client id from chi 0.171 and before (`review:<id>`) is no longer read as a participant's; such turns in
|
|
32
|
+
old sessions show as automatic.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- `chi send --new --continues last:<id>` (or a chain schedule's firing) racing another continue of the same chain no
|
|
37
|
+
longer fails with "was continued as …"; it follows to the new link.
|
|
38
|
+
- chi web no longer shows a session as stopped while a one-turn `chi -p` run or a delete holds it, and a worker being
|
|
39
|
+
stopped no longer shows as connected (its worker badge, open card and question go as the stop lands).
|
|
40
|
+
- `chi schedule cancel` (and the `cancel_schedule` tool) says when the schedule it removes was what kept a pruned chain
|
|
41
|
+
reachable from its first session, and names the newest link to send to; before, later sends to the first session
|
|
42
|
+
landed there silently.
|
|
43
|
+
- A block fixed in an answer that a hook's display replaced is redrawn right away, not on the next reload; a live
|
|
44
|
+
answer's bubble shows its time on hover like a reloaded one.
|
|
45
|
+
- A failed block whose fix couldn't be shown no longer stays at "asking for a fix…": it offers Ask in chat.
|
|
46
|
+
|
|
47
|
+
Update with `chi update` (mcp 0.9.3).
|
|
48
|
+
|
|
11
49
|
## [0.191.0] - 2026-11-27
|
|
12
50
|
|
|
13
51
|
### Changed
|
|
@@ -6986,7 +7024,8 @@ and long-lived sessions.
|
|
|
6986
7024
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6987
7025
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6988
7026
|
|
|
6989
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
7027
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.192.0...HEAD
|
|
7028
|
+
[0.192.0]: https://github.com/dm1try/samagotchi/compare/v0.191.0...v0.192.0
|
|
6990
7029
|
[0.191.0]: https://github.com/dm1try/samagotchi/compare/v0.190.1...v0.191.0
|
|
6991
7030
|
[0.190.1]: https://github.com/dm1try/samagotchi/compare/v0.190.0...v0.190.1
|
|
6992
7031
|
[0.190.0]: https://github.com/dm1try/samagotchi/compare/v0.189.0...v0.190.0
|
data/docs/architecture.md
CHANGED
|
@@ -247,7 +247,7 @@ agent logic and can be used without any terminal rendering; the UI is a thin lay
|
|
|
247
247
|
| UI | `Samagotchi::TerminalUI`, `TerminalUI::AttachLauncher` / `AttachedLoop` | The attached TUI: rendering (ANSI, spinner, status line) and the terminal's own commands over the worker's Bridge. `TerminalUI`: the `--non-interactive` one-shot host, which delegates all core work to its `Engine`. |
|
|
248
248
|
| Model loops and adapters | `KernelLoop`, `LLM::ChatLoop`, `Samagotchi::Client`, `LLM::OpenAIChat`, `LLM::AnthropicMessages`, `LLM::HTTP` | The model↔tool loops and the HTTP adapters they talk through (see "Model loops and adapters"). |
|
|
249
249
|
| Bridge (SSE/HTTP) ([internals/bridge.md](internals/bridge.md)) | `Samagotchi::Bridge`, `SessionManager` | The **single live client transport**: an SSE read stream + HTTP POST turn/cancel/answer surface that attaches to a worker's existing `Engine` through its event log, turn state, question desk and steer cut (`Engine#event_log`, `#turn_state`, `#question_desk`, `#steer_cut`, which the Worker hands it). Every session worker starts it (bound `127.0.0.1`, localhost-only), and it answers only a request that names its secret (`X-Chi-Bridge`, from the worker's 0600 `bridge.json`). |
|
|
250
|
-
| Web (Rack) | `Samagotchi::Web::App`, `SessionManager` | Single-port `127.0.0.1:4567` control plane via `rack`+`webrick` (serve `index.html` + `/api/*`). With `web.host: lan` (or one of this machine's IPv4 addresses) the server also listens on that address, where every request needs the access token, this machine's on loopback too (`App#token_gate`: the `chi_token` cookie, on loopback a value derived from the token (`Token.loopback_cookie`), or `Authorization: Bearer`; chi web prints a `Local:` link with a one-time code; [CLI](cli.md#chi-web-on-your-phone)). Experimental: behind an auth proxy (`web.public_url`, `Web::ProxyGate`) every request needs the token, this machine's too, and one that came through the proxy also the configured identity header for the owner ([configuration.md](configuration.md#behind-an-auth-proxy)). A request goes through, in order: the Host check (`local_host_header?`: loopback names, the LAN address, the public host), the cross-site check (`cross_site?`: Origin this server's or the public origin, no `Sec-Fetch-Site` cross-site/same-site on a POST or `/api`), the frame check (`framed?`: a frame/embed/object load from another origin, 403 `framed`; every HTML answer carries `X-Frame-Options: DENY` and `frame-ancestors 'none'; frame-src 'none'`, so a page's own frames can't navigate either), the token gate (`token_gate` → `principal_for`, `proxied_principal` for a proxied request; the `?token=` / `POST /api/token` trade sets the cookie, `__Host-chi_token` through the proxy; with `web.public_url` a direct request takes Bearer only, and with it or LAN mode chi's token-less `/api/info` probe gets `probe_info`), then the route's permission (`Principal#permits?`). It talks to each worker's Bridge (`App#relay`, `bridge_get`; `/stream` proxies it) and reads the session files; no `Engine` of its own. Markdown (`web.markdown`) is rendered here only (`Web::MarkdownRenderer`): the answers it serves, card bodies, and `POST /api/render` for a text the page already shows. `App` keeps the gate, `ROUTES` and the helpers the handlers share; its handlers live in mixins it includes, each a `Web::` module with private methods: `SessionAccessRoutes` (`web/session_access_routes.rb`), `ParticipantAccess` (`web/participant_access.rb`), `ParticipantsAdmin` (`web/participants_admin.rb`), `ParticipantReview` (`web/participant_review.rb`), `MessageDisplay` (`web/message_display.rb`), `SessionShow` (`web/session_show.rb`), `SessionCreate` (`web/session_create.rb`), `SessionControl` (`web/session_control.rb`), `PushRoutes` (`web/push_routes.rb`) and `ProxyGate` (`web/proxy_gate.rb`). Exact paths in `GATE_FREE_PATHS` are served before the token gate (the fragment trade's script, and the Home Screen app's manifest, service worker and icons). `bin/chi web` entrypoint. |
|
|
250
|
+
| Web (Rack) | `Samagotchi::Web::App`, `SessionManager` | Single-port `127.0.0.1:4567` control plane via `rack`+`webrick` (serve `index.html` + `/api/*`). With `web.host: lan` (or one of this machine's IPv4 addresses) the server also listens on that address, where every request needs the access token, this machine's on loopback too (`App#token_gate`: the `chi_token` cookie, on loopback a value derived from the token (`Token.loopback_cookie`), or `Authorization: Bearer`; chi web prints a `Local:` link with a one-time code; [CLI](cli.md#chi-web-on-your-phone)). Experimental: behind an auth proxy (`web.public_url`, `Web::ProxyGate`) every request needs the token, this machine's too, and one that came through the proxy also the configured identity header for the owner ([configuration.md](configuration.md#behind-an-auth-proxy)). A request goes through, in order: the Host check (`local_host_header?`: loopback names, the LAN address, the public host), the cross-site check (`cross_site?`: Origin this server's or the public origin, no `Sec-Fetch-Site` cross-site/same-site on a POST or `/api`), the frame check (`framed?`: a frame/embed/object load from another origin, 403 `framed`; every HTML answer carries `X-Frame-Options: DENY` and `frame-ancestors 'none'; frame-src 'none'`, so a page's own frames can't navigate either), the token gate (`token_gate` → `principal_for`, `proxied_principal` for a proxied request; the `?token=` / `POST /api/token` trade sets the cookie, `__Host-chi_token` through the proxy; with `web.public_url` a direct request takes Bearer only, and with it or LAN mode chi's token-less `/api/info` probe gets `probe_info`), then the route's permission (`Principal#permits?`). It talks to each worker's Bridge (`App#relay`, `bridge_get`; `/stream` proxies it) and reads the session files; no `Engine` of its own. Markdown (`web.markdown`) is rendered here only (`Web::MarkdownRenderer`): the answers it serves, card bodies, and `POST /api/render` for a text the page already shows. `App` keeps the gate, `ROUTES` and the helpers the handlers share; its handlers live in mixins it includes, each a `Web::` module with private methods: `SessionAccessRoutes` (`web/session_access_routes.rb`), `ParticipantAccess` (`web/participant_access.rb`), `ParticipantsAdmin` (`web/participants_admin.rb`), `ParticipantReview` (`web/participant_review.rb`), `MessageDisplay` (`web/message_display.rb`), `SessionShow` (`web/session_show.rb`), `SessionCreate` (`web/session_create.rb`), `AskCreate` (`web/ask_create.rb`: a create that answers its first turn), `SessionControl` (`web/session_control.rb`), `PushRoutes` (`web/push_routes.rb`) and `ProxyGate` (`web/proxy_gate.rb`). Exact paths in `GATE_FREE_PATHS` are served before the token gate (the fragment trade's script, and the Home Screen app's manifest, service worker and icons). `bin/chi web` entrypoint. |
|
|
251
251
|
| Sessions | `Samagotchi::Session`, `SessionManager` | File-based `~/.local/state/samagotchi/sessions/<uuid>.json` + sidecar `input/`/`output/`; retention (14d/500) + ordering (`updated_at desc`). |
|
|
252
252
|
|
|
253
253
|
- `bin/chi` in one-shot mode (`--non-interactive`, see `LaunchMode` above) builds `TerminalUI`.
|
|
@@ -504,14 +504,15 @@ model: [internals/remote-sessions.md](internals/remote-sessions.md).
|
|
|
504
504
|
| Route | Permission | Body / params | Answer | Refusals |
|
|
505
505
|
|---|---|---|---|---|
|
|
506
506
|
| `GET /api/sessions/resolve?id=` | owner | an id or a unique prefix | 200 `{id}` | 404 `not_found`; 400 `ambiguous_id` with `ids` |
|
|
507
|
-
| `GET /api/sessions/summaries` | owner | `dir` (a folder: its project; none: every project), `cwd`, `live=1`, `archived=1`, `tests=0`, `sort`, `order`, `limit` | 200: the rows `chi sessions list` prints (`SessionRow#to_summary_h`, 28 keys in a fixed order: `status`, `live`, `busy`, `owner`, `recap`, `ctx_pct`, `waiting`, `waiting_id`, `title`, `preview`, …) | 400 `invalid_dir`, `invalid_cwd` |
|
|
507
|
+
| `GET /api/sessions/summaries` | owner | `dir` (a folder: its project; none: every project), `cwd`, `live=1`, `archived=1`, `tests=0`, `delegates=0` (no delegates or `chi scratch` sessions, counted before `limit`), `sort`, `order`, `limit` | 200: the rows `chi sessions list` prints (`SessionRow#to_summary_h`, 28 keys in a fixed order: `status`, `live`, `busy`, `owner`, `recap`, `ctx_pct`, `waiting`, `waiting_id`, `title`, `preview`, …) | 400 `invalid_dir`, `invalid_cwd` |
|
|
508
508
|
| `GET /api/projects?dir=` | owner | optional page-scope folder | 200: project rows (`Web::ProjectList`: the hub's projects plus the start project and current project, even without sessions) with counts, roots, default/current marks; no `dir`: no current project | 400 `invalid_dir`; 503 `no_hub` |
|
|
509
509
|
| `POST /api/projects` | owner | `{dir}` (absolute folder; `~` and `~/` expand against the server's home) | 200 `{outcome, root, dir}` (`created`, `already_marked`, or `git`) | 400 `invalid_json`, `invalid_dir`; 422 `above_home`, `write_failed` |
|
|
510
510
|
| `POST /api/sessions` (more fields) | owner | `toolkit`, `tools`, `no_tools`, `parent_answers`; `driver` (`agent:<name>`, the new session's driver); `client_id` (`cli:send`/`cli:answer`/`agent:<name>`: the first line is checked as chi send checks it); `check_vision: true` (images follow) | 201 adds `model_warning`, `parent_answers_warning` (a level looser than config.yml's, capped) and `first_turn_id` (the id the prompt it starts with gets for its turn; null for an `idle` create); with a `first_turn_id`, a wait `token` for that turn (none for an `idle` create) | 400 `invalid_toolkit`, `invalid_parent_answers`, `invalid_continues` (beside `continues`); 403 `parent_answers_refused`, `parent_continue_refused`; 422 `no_vision` |
|
|
511
|
+
| `POST /api/sessions` (answered: any of `reply_for`, `timeout`, `request_id`) | owner | the ask's fields (`prompt`, `timeout`, `client_id`, `request_id`, `reply_for`) and the create's; `dir` optional: else `web.ask_dir` (`Config.get` per create, `StartDir.resolve(from: :ask_config)`), else the start folder. A `request_id` names the session (`SessionInbox.enqueued_id_for("create:" + key)`, `AskCreate::LOCKS` per id): a retry spawns nothing | 201: the ask's answer (as `POST …/ask`'s 200) + `session_id`, `created` (false: a retry's), `model_warning`, `parent_answers_warning`; the session spawns idle with the prompt as its preview, then `AskRoutes#run_ask`; records `last` (`Web::LastAsk`) unless a parent's line ([thin-clients.md](thin-clients.md#a-new-session-in-one-call)) | 400 `invalid_ask` (also beside `idle` or `continues`), `invalid_dir` (`web.ask_dir` not a folder), the ask's and the create's 400s, nothing spawned; after the spawn the ask's refusals keep their code and carry `session_id`, `created` |
|
|
511
512
|
| `POST /api/sessions/:id/turn` (more fields) | owner | `client_id` as above; `check_vision: true` with `images` | as before | 403 `parent_answers_refused`, `parent_continue_refused`; 422 `no_vision`; 409 `link_continued` (`successor_id`) or `transition_busy` while a transition holds the session's lock (every sender: `SessionInbox::Hold`, internals/session-lifecycle.md) |
|
|
512
513
|
| `POST /api/sessions/:id/wait/prepare` | owner | `question_id` (absent: the pending one; `null`: none), `turn`, `created`, `busy` (+ `queue`) | 200 `{session_id, cursor, baseline: {messages, question_id, last_turn}, own_turn, known_turn, running, live, settled, last_turn_id}` (`WaitStart`) | 409 `busy`, `waiting` (`SendCommand::Busy`'s words, and its fields: `question`, `parent_strategy`) |
|
|
513
514
|
| `POST /api/sessions/:id/wait` | owner | `cursor`, `baseline`, `turn`, `queued`, `ended_before`, `owner_grace`, `timeout` (capped at 30 s); or `{token, timeout}` (a wait token, `SessionAccess::Exchange::Token`: the answer adds `session_id`, and `token` again while the status is `timeout`; a token beside the other fields, another session's, one that isn't one or a participant's: 400 `invalid_wait`) | 200: `ReplyWait::Result`'s fields (`status`: `done`, `waiting_for_answer`, `no_reply`, `error`, `stopped`, `worker_gone`, or `timeout`: ask again; `text`, `file`, `question` as `PendingQuestion#to_file`, `outcome`, `limit`, `error_kind`, `retryable`, `cancel_reason`, `stopped_by`, `kept_steps`, `turn_id`, `origin`; never the session) and `parent_strategy` `{name, allowed, origin}` (`ParentReport.strategy_for`, this server's config.yml) | 400 `invalid_wait`; 503 `server_stopping` |
|
|
514
|
-
| `POST /api/sessions/:id/ask` | owner | `prompt` (16 KiB), `timeout` (default and most 30 s), `queue` (default `true`: a running session queues it as its own turn; `false` refuses it), `client_id` (absent: `web:unnamed`; `cli:send`'s `/continue yes` goes in as `cli:answer` and is parent-gated as on `…/turn`), `request_id` (optional, 1-128 printable ASCII, messages only: a retry with it answers the first ask's turn, `SessionInbox.enqueued_id_for`) | 200: the wait's fields + `session_id` (where it ran), `asked` (the id given, when another link ran it), `token` when the status is `timeout`, `request_id` echoed when given; 200 `{status: command, session_id}` for a session command (`/continue yes` with an offer standing answers the continued turn's fields instead). The whole call answers within `AskRoutes::ASK_MAX_SECONDS` (35) (`Web::AskRoutes`, `SessionAccess::Ask`, [thin-clients.md](thin-clients.md)) | 404 `not_found`; 400 `ambiguous_id`, `missing_fields`, `invalid_prompt`, `local_command`, `invalid_ask` (also a `request_id` on a session command); 403 `parent_continue_refused`, `parent_answers_refused`; 409 `busy`, `waiting` (neutral words, Busy's fields), `continuing`, `owned_by_tui`, `enqueued_id_conflict` (the same `request_id`, another prompt, a turn the session no longer names but the worker remembers), the turn route's delivery refusals (`queue_unavailable`, …); 504 `worker_timeout`; 503 `server_stopping` |
|
|
515
|
+
| `POST /api/sessions/:id/ask` | owner | `:id` may be `last` (`Web::LastAsk.target`: the session the owner's last answered ask or answered create went to, kept in `last_ask.json` beside the sessions folder, following continues; gone or archived with no successor: the newest not scratch, delegate, `driver`, test run or archived; none: 404 `not_found`; a participant's: 404 at the gate; no `…/last/wait`); `prompt` (16 KiB), `timeout` (default and most 30 s), `queue` (default `true`: a running session queues it as its own turn; `false` refuses it), `client_id` (absent: `web:unnamed`; `cli:send`'s `/continue yes` goes in as `cli:answer` and is parent-gated as on `…/turn`), `request_id` (optional, 1-128 printable ASCII, messages only: a retry with it answers the first ask's turn, `SessionInbox.enqueued_id_for`) | 200: the wait's fields + `session_id` (where it ran), `asked` (the id given, when another link ran it), `token` when the status is `timeout`, `request_id` echoed when given; 200 `{status: command, session_id}` for a session command (`/continue yes` with an offer standing answers the continued turn's fields instead). The whole call answers within `AskRoutes::ASK_MAX_SECONDS` (35) (`Web::AskRoutes`, `SessionAccess::Ask`, [thin-clients.md](thin-clients.md)) | 404 `not_found`; 400 `ambiguous_id`, `missing_fields`, `invalid_prompt`, `local_command`, `invalid_ask` (also a `request_id` on a session command); 403 `parent_continue_refused`, `parent_answers_refused`; 409 `busy`, `waiting` (neutral words, Busy's fields), `continuing`, `owned_by_tui`, `enqueued_id_conflict` (the same `request_id`, another prompt, a turn the session no longer names but the worker remembers), the turn route's delivery refusals (`queue_unavailable`, …); 504 `worker_timeout`; 503 `server_stopping` |
|
|
515
516
|
| `POST /api/mcp` (`GET`, `DELETE`) | owner | one JSON-RPC message of MCP (112 KiB: a 16 KiB prompt JSON-escaped), either revision: the current one with `MCP-Protocol-Version`, `Mcp-Method` and `Mcp-Name` headers matching the body, the earlier one with the `Mcp-Session-Id` its `initialize` handed out (and an `MCP-Protocol-Version`, if any, that chi serves) | 200 the JSON-RPC answer (a tool's refusal is a result with `isError`), 202 for a notification; `GET` 405 (`Allow: POST, DELETE`, no stream), `DELETE` 200. Each call within `McpServer::Tools::SLICE` (25 s) (`Web::McpRoute`, `McpServer::Http`, [mcp-server.md](mcp-server.md)) | 400 `-32020` (headers unlike the body), `-32022` (an unsupported revision), `-32700` (not JSON or not UTF-8; with the request's id when one can be read)/`-32600` (not an object: a batch is one), `Missing session ID`, an unsupported legacy `MCP-Protocol-Version`; 404 `-32601`; the gate's 401 adds `WWW-Authenticate: Bearer` here |
|
|
516
517
|
| `POST /api/sessions/:id/answer` (`wait`) | owner | `wait: N` (seconds, at most 30) beside `id`, `selected`, `freeform` | 200 `{status: answered, session_id, id, reply: {the wait's fields, token while it is timeout}}`; a question answered elsewhere first: 200 `{status: not_pending, answered_here: false, …, reply}` (as `chi answer` still waits); a wait that fails after the answer went in: 200 with that `status` and `wait_error` `{error: server_stopping \| not_found \| wait_failed, detail}` in place of `reply`; without `wait` every answer is as before | 400 `invalid_wait`; 404 |
|
|
517
518
|
| `POST /api/sessions/:id/notes` | owner | `text`, `source` (default `cli`, never `broadcast`) | 200 `{status: queued \| waits, session_id, queued}` (`NoteDelivery`) | 409 `owned_by_tui` (`status: refused`); 400 `note_rejected`, `missing_fields`, `invalid_source` |
|
|
@@ -696,7 +697,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
696
697
|
| LLM context strategies | `llm_context_strategy.rb`, `llm_context_view.rb`, `llm_context_stale.rb`, `llm_context_forget.rb` | What a request sends of the history (none, stale, forget) ([internals/llm-context-forget.md](internals/llm-context-forget.md)). |
|
|
697
698
|
| Session chains | `session_continue.rb` (`SessionContinue`), `session_chain.rb` (`SessionChain`), `session_chain/links.rb` (`SessionChain::Links`), `session_chain/delete.rb` (`SessionChain::Delete`), `session_chain/delete_preview.rb` (`SessionChain::Delete::Preview`), `continued_from.rb` (`ContinuedFrom`) | A session that continues an earlier one. `SessionChain::Links` is the one chain walker (one listing; `latest`, `first_live`, `root`, `next_of`): `SessionChain.latest`/`.next_of`, `SessionInbox::Head` and the schedule tick all ask it. `SessionChain.opener_for` gives the text web `continue →` prefills in the new link: the previous link's own first typed message when that link continues one itself, else nil (the 201's `opener`; not saved). `SessionChain::Delete` plans and deletes a link or its chain; `Delete::Preview` supplies the web delete sheet, and `ContinuedFrom` records what a continue must undo ([sessions.md](sessions.md)). |
|
|
698
699
|
| MCP server | `mcp_server/protocol.rb` (`McpServer::Protocol`: JSON-RPC in both revisions, no transport, no chi), `mcp_server/tools.rb` (`McpServer::Tools`: `chi_sessions`, `chi_ask`, `chi_wait`, `chi_answer` over a SessionAccess backend through `SessionAccess::Ask` and `Exchange`), `mcp_server/text.rb` (`McpServer::Text`: the results' words), `mcp_server/stdio.rb` (`McpServer::Stdio`), `mcp_server/http.rb` (`McpServer::Http`), `mcp_command.rb` (`chi mcp serve`), `web/mcp_route.rb` (`Web::McpRoute`: `POST /api/mcp`, included through SessionAccessRoutes) | chi as an MCP server ([mcp-server.md](mcp-server.md)); not the `mcp` bundle (chi as a client). Only `tools.rb` names `SessionAccess`: another front builds `Protocol.new(tools: Tools.new(access))`. The caller is a parent agent (`cli:send` / `cli:answer`, `SessionAccess::Ask#agent_line`). |
|
|
699
|
-
| chi web's routes | `web/app.rb` (`Web::App`: the gate, `ROUTES`, the shared helpers), `web/request_body.rb` (`Web::RequestBody`: bounded body reads), `web/message_display.rb` (`Web::MessageDisplay`: saved messages and cards as display items, the owner show's stamped with their turns' drawings and carrying no parts (a step's ✂ marks only), the participant show's with their parts, `POST /api/render`), `web/session_show.rb` (`Web::SessionShow`: `GET /api/sessions/:id` with its `cards`, `tail` and `timing` re-reads, `GET …/output`, the timing payload), `web/session_create.rb` (`Web::SessionCreate`: `POST /api/sessions`, a continue), `web/session_control.rb` (`Web::SessionControl`: answer, command, turn and images, cancel, stop, restart, archive, delete), `web/session_access_routes.rb` (`Web::SessionAccessRoutes`: the session-command routes), `web/ask_routes.rb` (`Web::AskRoutes`: ask, wait tokens, the answer's wait, included through SessionAccessRoutes), `web/verify_fresh_routes.rb` (`Web::VerifyFreshRoutes`: Verify fresh children), `web/working_set_routes.rb` (`Web::WorkingSetRoutes`: the working set routes), `web/viewer.rb` (`Web::Viewer`: page capabilities), `web/push_routes.rb` (`Web::PushRoutes`: `/api/push`, its subscriptions, prefs, test and presence), `web/block_renderer_routes.rb` (`Web::BlockRendererRoutes`: `GET /api/block_renderers` and one renderer's file, [internals/block-renderers.md](internals/block-renderers.md)), `web/reload_check_route.rb` (`Web::ReloadCheckRoute`: `POST /api/sessions/:id/reload_check`, the opt-in `web.reload_check`'s counts from the page's `reload_check.js`, 204 and one `reload_checked` log line, with `reload_mismatch`, its `kinds`, `excused` (ACCEPTED ids) and `explained` when the turn read otherwise after a reload; the worker's version is chi web's own view, its sidecar) | The handlers `App`'s `ROUTES` name, in the file that holds their kind; each mixin is included in `App` and reads its helpers and ivars, so `app.send(:handle_show, …)` and the specs that stub `App` methods work as before. The shared body reader caps incoming requests. |
|
|
700
|
+
| chi web's routes | `web/app.rb` (`Web::App`: the gate, `ROUTES`, the shared helpers), `web/request_body.rb` (`Web::RequestBody`: bounded body reads), `web/message_display.rb` (`Web::MessageDisplay`: saved messages and cards as display items, the owner show's stamped with their turns' drawings and carrying no parts (a step's ✂ marks only), the participant show's with their parts, `POST /api/render`), `web/session_show.rb` (`Web::SessionShow`: `GET /api/sessions/:id` with its `cards`, `tail` and `timing` re-reads, `GET …/output`, the timing payload), `web/session_create.rb` (`Web::SessionCreate`: `POST /api/sessions`, a continue), `web/session_control.rb` (`Web::SessionControl`: answer, command, turn and images, cancel, stop, restart, archive, delete), `web/session_access_routes.rb` (`Web::SessionAccessRoutes`: the session-command routes), `web/ask_routes.rb` (`Web::AskRoutes`: ask, wait tokens, the answer's wait, included through SessionAccessRoutes), `web/ask_create.rb` (`Web::AskCreate`: a create that answers its first turn), `web/last_ask.rb` (`Web::LastAsk`: the owner's `last`, `last_ask.json`), `web/verify_fresh_routes.rb` (`Web::VerifyFreshRoutes`: Verify fresh children), `web/working_set_routes.rb` (`Web::WorkingSetRoutes`: the working set routes), `web/viewer.rb` (`Web::Viewer`: page capabilities), `web/push_routes.rb` (`Web::PushRoutes`: `/api/push`, its subscriptions, prefs, test and presence), `web/block_renderer_routes.rb` (`Web::BlockRendererRoutes`: `GET /api/block_renderers` and one renderer's file, [internals/block-renderers.md](internals/block-renderers.md)), `web/reload_check_route.rb` (`Web::ReloadCheckRoute`: `POST /api/sessions/:id/reload_check`, the opt-in `web.reload_check`'s counts from the page's `reload_check.js`, 204 and one `reload_checked` log line, with `reload_mismatch`, its `kinds`, `excused` (ACCEPTED ids) and `explained` when the turn read otherwise after a reload; the worker's version is chi web's own view, its sidecar) | The handlers `App`'s `ROUTES` name, in the file that holds their kind; each mixin is included in `App` and reads its helpers and ivars, so `app.send(:handle_show, …)` and the specs that stub `App` methods work as before. The shared body reader caps incoming requests. |
|
|
700
701
|
| Web Push | `web/push.rb` (`Web::Push`: `Runtime`, `preflight!`, the `web.push.*` settings), `web/push/crypto.rb` (`Push::Crypto`: RFC 8291 aes128gcm, RFC 8292 VAPID), `web/push/store.rb` (`Push::Store`, `Store::Sub`: `web-push/vapid.pem`, `subscriptions.json`), `web/push/client.rb` (`Push::Client`, `Client::Result`), `web/push/attention.rb` (`Push::Attention`: notify.js's rules in Ruby, shared cases in `spec/fixtures/attention_cases.json`), `web/push/presence.rb` (`Push::Presence`: the pages' "in front" reports), `web/push/notifier.rb` (`Push::Notifier`, a hub subscriber with a sender thread), `web/push_routes.rb` (`Web::PushRoutes`), `private_files.rb` (`PrivateFiles`, shared with the grants), `public/sw.js`, `public/push.js`, `public/manifest.webmanifest` | chi web pushes what the tab notifies for (approvals, questions, step-limit questions, cards, failed turns; done turns to a device that asks) to the owner's Home Screen app over an https public URL: the Notifier turns the hub's new attentions into show pushes after a hold, unless a chi web page is in front, at most 30 an hour, with one retry and a restart catch-up (`sent.json`) (each carries the keys still open, and the badge; no close push: every push shows a notification); the bell (`notifications.js`) subscribes the device, and the service worker and the page close the answered ones. See [internals/web-push.md](internals/web-push.md). |
|
|
701
702
|
| chi web's updates | `web/update_check.rb` (`Web::UpdateCheck`), `web/update_ops.rb` (`Web::UpdateOps`), `web/auto_update.rb` (`Web::AutoUpdate`) | The RubyGems checker and its `update_check.json`; the install, worker-restart and chi-web-restart operations (one at a time) the owner's routes and AutoUpdate share; `update.auto: install`'s thread (install when no turn runs, then idle workers and chi web). See [configuration](configuration.md#unattended-updates-updateauto). |
|
|
702
703
|
| Behind an auth proxy | `web/public_url.rb` (`Web::PublicUrl`: `web.public_url`, `web.proxy.identity_header`, `web.proxy.owner`), `web/proxy_gate.rb` (`Web::ProxyGate`, mixed into App; `RawHeaderNames`, prepended to WEBrick's request by `Web::Server`), `web/link_codes.rb` (`Web::LinkCodes`: the links' one-time codes), `proxy_trace.rb` (`ProxyTrace`), `web/public/token_fragment.js`, `web/public/auth_lost.js`, `web/tunnel.rb` + `web/tunnel/tailscale.rb` (`Web::Tunnel`, `Web::Tunnel::Tailscale`: `chi web --tunnel tailscale`, Tailscale Serve set for one run and the PublicUrl it makes) | Experimental: chi web behind an auth proxy. Every request needs the token; a proxied one's owner also needs the identity header (one clean value under one name); the `__Host-` cookie, an absolute `Location` from the public URL, https links with a one-time code in the fragment; the page's lost-sign-in banner. Bridges refuse proxy traces ([configuration.md](configuration.md#behind-an-auth-proxy)). |
|
data/docs/bundles.md
CHANGED
|
@@ -41,7 +41,7 @@ only against this API (`lib/samagotchi/bundles/btw/plugin.rb`).
|
|
|
41
41
|
server](mcp-server.md).)
|
|
42
42
|
|
|
43
43
|
`chi bundle install mcp` (or the `dev` profile) installs the bundle shipped with chi. It is written
|
|
44
|
-
only against this API (`lib/samagotchi/bundles/mcp/`: `plugin.rb` and its parts `client.rb`, `http_client.rb`, `oauth.rb`, `tools.rb`, `content.rb`), and gives
|
|
44
|
+
only against this API (`lib/samagotchi/bundles/mcp/`: `plugin.rb` and its parts `client.rb`, `http_client.rb`, `oauth.rb`, `sign_in.rb`, `server_config.rb`, `tools.rb`, `content.rb`), and gives
|
|
45
45
|
the model the tools of [MCP](https://modelcontextprotocol.io) servers. It
|
|
46
46
|
has no memory file, and the servers' tools aren't declared to the model one
|
|
47
47
|
by one: the bundle publishes them into chi's tool index
|
data/docs/cli.md
CHANGED
|
@@ -470,6 +470,10 @@ chi schedule add --session 3f9a1c2e --every 5m -m "Check in" --if "$HOME/.local/
|
|
|
470
470
|
chi schedule edit 4b7e9a --no-if # fire at every occurrence again
|
|
471
471
|
```
|
|
472
472
|
|
|
473
|
+
When the schedule a cancel removes was what kept a pruned chain reachable from its first
|
|
474
|
+
session, `cancel` prints one more line on stdout naming the chain's newest link to send to
|
|
475
|
+
from then on, and still exits 0 ([scheduling.md](scheduling.md#keeping-the-chain-short)).
|
|
476
|
+
|
|
473
477
|
Every `list` row names its schedule: the `--title` it was given, or, when it has
|
|
474
478
|
none, the first 30 characters of its prompt in quotes with `…` where it is cut
|
|
475
479
|
(newlines and runs of spaces become one space). The name column is padded to the
|
|
@@ -764,10 +768,11 @@ note or image) is deleted as its worker exits, and `/exit` says so; set
|
|
|
764
768
|
[Sessions](sessions.md).
|
|
765
769
|
|
|
766
770
|
`chi sessions stop ID...` stops each session's worker and waits for it to exit, so
|
|
767
|
-
a `chi --resume ID` after it starts a fresh one.
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
+
a `chi --resume ID` after it starts a fresh one. A session being continued,
|
|
772
|
+
deleted or archived refuses the stop at once, saying so ("session ab12cd34 is
|
|
773
|
+
being deleted", "session ab12cd34 is being continued as 7b2d41aa-…: stop that
|
|
774
|
+
one"); a short hold (a send) is waited for up to 10 s, then refused ("…; try
|
|
775
|
+
again in a moment"). Either way the running turn goes on and that id exits 1. A worker still running an
|
|
771
776
|
older chi (from before an upgrade) takes turns, but not commands, or not the
|
|
772
777
|
ones newer than it (`/llm-context`, `--llm-context` on `--attach`); the attached
|
|
773
778
|
terminal and the Web UI say so, with that restart line.
|
|
@@ -1185,9 +1190,12 @@ The prompt stays open while a turn runs in an attached terminal:
|
|
|
1185
1190
|
running turn's card with the commands queued for its end, until its turn
|
|
1186
1191
|
starts; its **×** (`Remove from queue`, once the worker acked it) takes it
|
|
1187
1192
|
back before it runs, in every tab (a toast says why when it can't: it
|
|
1188
|
-
already started, it is gone, no live worker), and puts its text back into
|
|
1189
|
-
empty
|
|
1190
|
-
the
|
|
1193
|
+
already started, it is gone, no live worker), and puts its text back into
|
|
1194
|
+
the session's draft when that is empty, to change and send again (a draft
|
|
1195
|
+
stays: the text is then in the toast; after a switch to another session
|
|
1196
|
+
meanwhile it goes into the left session's empty draft, a toast says
|
|
1197
|
+
`Removed: back in <id>'s draft`, else a sticky toast with Copy; images don't
|
|
1198
|
+
come back); `cut in now` cuts, like `/cut TEXT` (by click only: it throws the
|
|
1191
1199
|
thinking away). Cut is enabled only while the step has streamed nothing but
|
|
1192
1200
|
thinking and cutting is on for the model (the line says `cuts at about 0:25
|
|
1193
1201
|
if you choose cut in now` until the thinking passes `steer_cut_after`, and
|
data/docs/configuration.md
CHANGED
|
@@ -163,6 +163,7 @@ or `chi web` restart.
|
|
|
163
163
|
| `memories` | Worker start | The running engine holds its preload list. The config list is not saved in the session file, so a respawn reads the current list. |
|
|
164
164
|
| `append_system_prompt` | Worker start for the file list | The config list is not saved in the session file. File text is read when the prompt is built; `/model` rebuilds it, while an already-built prompt is cached. CLI `--append-system-prompt` files are saved in the session. |
|
|
165
165
|
| `toolkit.default`, `toolkit.child` | Session creation | The chosen toolkit is saved; changing the defaults does not move existing sessions. |
|
|
166
|
+
| `web.ask_dir` | Session creation | Read at each thin-client create that names no folder; existing sessions keep their folder. |
|
|
166
167
|
| `toolkit.kits`, `execute.description`, `llm_context.policy` | Worker start | These are held by the engine's toolkit or tool registry. |
|
|
167
168
|
| `toolkit.suggest.mode`, `toolkit.suggest.threshold`, `toolkit.suggest.defer_turns`, `toolkit.suggest.defer_tokens` | Worker start | Suggestion settings are config-only and are resolved when the worker runs its audit or on-mode ask. |
|
|
168
169
|
| `skip_agents_md` | Prompt rebuild | A running engine caches its built prompt; a new worker or `/model` rebuild uses the changed value. |
|
|
@@ -175,7 +176,7 @@ or `chi web` restart.
|
|
|
175
176
|
| `session.idle_exit_minutes`, `session.project_env`, `session.carry_last_answer`, `session.keep_empty`, `session.max_children`, `session.delegate_reports`, `session.task_wakes`, `session.max_wakes` | Worker start or next matching lifecycle decision | Existing workers keep their idle-exit timer and project env; the other values are read for the next corresponding decision. |
|
|
176
177
|
| `session.retention_*`, `session.max_count`, `session.keep_status`, `session.sweep_interval_hours` | Next retention sweep | `chi web` sweeps on its configured schedule and on `GET /api/sessions`; `chi sessions prune` uses the values for that invocation. The sweep interval is checked on the next hub tick. |
|
|
177
178
|
| `schedule.*` | Next CLI run | `chi schedule add` and `chi schedule tick` read them for that run; with `schedule.auto_tick` on, `chi web`'s hub ticks on `schedule.tick_interval_minutes`. |
|
|
178
|
-
| `web.*` except `web.participants.*` | `chi web` start | Restart `chi web` to change its bind address, port or page settings. |
|
|
179
|
+
| `web.*` except `web.participants.*` and except `web.ask_dir` | `chi web` start | Restart `chi web` to change its bind address, port or page settings. |
|
|
179
180
|
| `log.*` | Process start | Each process holds its configured log sink and level after first use; restart that process. |
|
|
180
181
|
| `history.file` | Next history access | The TUI and web composer resolve its path when they read or append history. |
|
|
181
182
|
| `broadcast.*` | Next `chi broadcast` | Each broadcast invocation reads its targeting and triage settings. |
|
|
@@ -2063,6 +2064,9 @@ name doesn't load. By hand, on the Mac that runs chi web (or steps 1–2, then
|
|
|
2063
2064
|
AirDrop or type it). The code works once, within 10 minutes (`chi web` again prints a new one); the phone then
|
|
2064
2065
|
keeps the `__Host-chi_token` cookie.
|
|
2065
2066
|
|
|
2067
|
+
A phone Shortcut talks to the same address with the token ([thin clients](thin-clients.md)); set `web.ask_dir` so its
|
|
2068
|
+
new sessions need no folder ([A new session in one call](thin-clients.md#a-new-session-in-one-call)).
|
|
2069
|
+
|
|
2066
2070
|
#### `chi web --tunnel tailscale`
|
|
2067
2071
|
|
|
2068
2072
|
Steps 3–5 in one command, after steps 1–2 (Tailscale signed in, HTTPS certificates on):
|
|
@@ -2430,6 +2434,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
|
|
|
2430
2434
|
| `web.annotate_presets` | `Agreed\|Could you please elaborate?` | yes | Quick replies next to Annotate in `chi web`, `\|`-separated (a YAML list works too); `""` in the file or on the CLI leaves only Annotate (an empty env value means the default). See [CLI](cli.md#web-annotate-presets). |
|
|
2431
2435
|
| `web.editor` | `vscode` | yes | What a file ref in `chi web` (a file tool row's title, a diff line) opens, for a viewer on this machine: a preset (`vscode`, `vscode-insiders`, `cursor`, `zed`) or a URL template with `{path}` and an optional `{line}`; `none` turns refs off. See [Opening files from chi web](#opening-files-from-chi-web). |
|
|
2432
2436
|
| `web.start_dir` | the folder `chi web` runs in | | The folder `chi web` starts in (`chi web --start-dir DIR` for one run): its page (the printed link, a bare `/`, the LAN link and QR code, the Home Screen app) opens on that folder's project, outside a project (no repository or marked folder) on every session, and a new session from the all view starts there; the header's project picker switches projects. `~` and a relative path (resolved from your home folder) work; one that isn't a folder stops `chi web` from starting. `chi web` never changes its own folder. See [CLI](cli.md). |
|
|
2437
|
+
| `web.ask_dir` | the `web.start_dir` folder | | The folder a thin client's one-call create (`POST /api/sessions` with `reply_for`, `timeout` or `request_id`, such as a phone Shortcut's) starts in when it names no `dir`, so the Shortcut can leave the folder out. `~` and a relative path (resolved from your home folder) work; one that isn't a folder refuses that create (400 `invalid_dir`), nothing started. Read at each create; a plain create without those fields never uses it. Only the owner's token creates sessions. See [A new session in one call](thin-clients.md#a-new-session-in-one-call). |
|
|
2433
2438
|
| `web.participants.expires` | `7d` | | How long a participant's link lasts unless `chi share --expires` says otherwise: `Nh` or `Nd`, 1h to 30d. See [participants](internals/participants.md). |
|
|
2434
2439
|
| `web.participants.cap` | `2.0` | | What a participant's turns, and the side calls they cause, may cost you in dollars unless `chi share --cap` says otherwise ($0 to $1000); at the cap their next comment is refused (429 `cap_reached`) and you get a notice. `chi share cap ID P DOLLARS` changes one grant's. |
|
|
2435
2440
|
| `web.participants.queue` | `3` | | How many of a participant's turns may wait behind their running one (0 to 20); one more is refused (429 `too_many_turns`). |
|
|
@@ -149,7 +149,8 @@ session switch, a turn's end, Revise's clones, the stage's hand-off to `#history
|
|
|
149
149
|
|
|
150
150
|
**The only way out is composer text.** Fill reply builds `id: option (note) · …` from the picked rows (a row with no
|
|
151
151
|
pick is left out) and hands it to app.js's `fillComposer`, after a typed draft on a new line (`withDraft`; the draft
|
|
152
|
-
is kept).
|
|
152
|
+
is kept). Both act on the open session's draft (`drafts.js`, [web-frontend.md](web-frontend.md#the-drafts)): a pick in
|
|
153
|
+
one session never lands in another's text. It never sends: the owner reads the text and sends it or not. `replyText` drops a leading `!` or `/` from
|
|
153
154
|
an id too (an id of only those is its row's number), so the filled text never starts a shell line or a session command
|
|
154
155
|
even from data the normaliser didn't mend; the draft before it is the owner's own. The row's `wp-id` chip shows that
|
|
155
156
|
same cleaned id (`rowId`, one rule for both), so what is drawn is what fills. A walk has no way out at all. The model's
|
|
@@ -264,11 +264,7 @@ of its own after it.
|
|
|
264
264
|
|
|
265
265
|
**chi web.** The author is the grant's (`p:<id>`) and the client id `participant:<id>` (`ClientId.participant`, its
|
|
266
266
|
`ClientId::Sender` row: a human's input, never the owner's, origin `participant`, source `participant`, labelled
|
|
267
|
-
`invited`; not the author, which says who wrote it).
|
|
268
|
-
`turn_drawings.jsonl`, input files, an older chi web still running) reads the same (`ClientId::LEGACY_REVIEW_PREFIX`,
|
|
269
|
-
compat shim `review_client_id`, until 0.173), and a live worker that doesn't name `participant_client_id`
|
|
270
|
-
(`Delivery::PARTICIPANT_ID_FEATURE`) is sent `review:<id>` (`SessionManager` delivery; a dequeue's id, only echoed
|
|
271
|
-
back, is left as it is); the body's `client_id`, `author` and
|
|
267
|
+
`invited`; not the author, which says who wrote it). The body's `client_id`, `author` and
|
|
272
268
|
`no_interrupt` never count, its `images` only as refs to their own uploads, and its `delivery` only as `queue` or
|
|
273
269
|
next step (none: next step).
|
|
274
270
|
Refused before delivery, each audited:
|
|
@@ -102,6 +102,9 @@ command, on an idle session with its offer standing and a live worker, is bound
|
|
|
102
102
|
instead, the offer's turn id from `ReplyWait.own_turn`, as chi answer follows it; the worker's ack is not read): chi web's `POST …/ask`
|
|
103
103
|
builds one per request over a `Local` that delivers through chi web's own manager and Bridge (`Web::AskRoutes::
|
|
104
104
|
AskAccess`), and `McpServer::Tools` reuses `SessionAccess::Ask` / `Exchange` through the MCP server without chi web.
|
|
105
|
+
chi web's create that answers its first turn (`Web::AskCreate`) spawns the session idle, its prompt as the preview,
|
|
106
|
+
then runs the same `SessionAccess::Ask` through `AskRoutes#run_ask`; a `request_id` names the session itself
|
|
107
|
+
(`SessionInbox.enqueued_id_for("create:" + key)`), so a retry finds it and the Ask rebinds to the first turn.
|
|
105
108
|
The ask chain carries a turn's anchors (`Ask#call` → `Exchange#attempt` → `Local#deliver_turn` → the manager's
|
|
106
109
|
`deliver_turn`, `anchors:` passed only when given): chi web's `/ask` puts a message's `reply_for` there
|
|
107
110
|
(`TurnAnchors`). `SessionAccess::Remote#deliver_turn` refuses a non-empty one (local only, exit 2), and neither
|
|
@@ -14,14 +14,14 @@ SessionManager boundaries are in [Architecture](../architecture.md) and [Engine
|
|
|
14
14
|
|
|
15
15
|
| Fact | Writer and removal | Cross-process readers and how they see change |
|
|
16
16
|
|---|---|---|
|
|
17
|
-
| `<id>.json` `status` | `Session#save` writes the session snapshot; the owner is the normal writer. `Session#load` overlays `stopped` as `stopped` without rewriting the file. | `SessionRow` and `SessionAccess::Local` read saved turn status; stop cancellation, restart fallback, and archive refusal also use it as a busy hint. Readers reload the file; the hub refreshes rows on its tick. It is turn state, not proof of liveness. |
|
|
17
|
+
| `<id>.json` `status` | `Session#save` writes the session snapshot; the owner is the normal writer. `Session#load` (and `summary_from_file`) overlays `stopped` as `stopped` without rewriting the file; the file's status is kept in `Session#loaded_status` (not saved, nil for a session built in memory). | `SessionRow` and `SessionAccess::Local` read saved turn status; stop cancellation, restart fallback, and archive refusal also use it as a busy hint. Readers reload the file; the hub refreshes rows on its tick. It is turn state, not proof of liveness. The session hub shows `stopped` only in a stopped state (`STOPPED_STATES`): `Web::SessionSummary.shown` derives the state from the facts, and a restored file whose own status says `stopped` stays stopped everywhere. |
|
|
18
18
|
| `starting` (`{pid, at}`) | `SpawnPart#spawn_session` marks before the first session file; `#spawn_worker_for_session` marks around `Process.spawn`; `#claim_start` claims with `StartingMarker.claim`. Failures clear it; `Worker#start` clears it after acquiring `owner.lock`. A stale/dead marker is taken over after 60 seconds or when its pid is gone. | `WorkerPresence`, resume, archive, delete, and retention read it directly; `WorkerPresence` checks age and pid. The session hub also refreshes presence. The atomic hard-link claim arbitrates competing starters; there is no event notification. |
|
|
19
19
|
| `owner.lock` and `leaving_at` | `OwnerLock.acquire` creates the file, takes its exclusive flock, and writes `{pid, kind, started_at}`; `OwnerLock#mark_leaving` adds `leaving_at` and `leave_wait`; `#release` unlocks and closes but leaves the file. Deletion removes it with the session directory. | `OwnerLock.owner` probes the kernel flock, then reads the record. The kernel releases the lock on process death; the record alone does not establish ownership. Presence and `WorkerLink` decisions probe it; hub presence refreshes poll it. `leaving_at` marks a worker that closed its Bridge but still holds the lock for leave work. |
|
|
20
20
|
| `bridge.json` | `Bridge#write_sidecar` publishes the worker endpoint; `Bridge#remove_sidecar` removes its own sidecar when stopping. A crash can leave it behind. | `WorkerLink.resolve` combines the sidecar with `owner.lock` and pid; a sidecar alone is stale. Readers waiting for a worker poll `WorkerLink.resolve`; a stale unlink rechecks the owner and removes only the unchanged file. Live clients see worker events over Bridge SSE. |
|
|
21
21
|
| In-memory exit claim | `Worker#exit_request` uses `WorkerExitClaim#claim`, `#accept`, `#release` and `#forget`; `#stopped!` records the last stop-all. It dies with that Worker. | Only that worker's threads read it; the Bridge's `/exit` and the loop coordinate through the Engine event lock, not a cross-process file. |
|
|
22
22
|
| `stopped` | `SessionManager#stop_session` calls `Session.mark_stopped` under the session's transition lock (kind `stop`, "Stops, archives and the ring wake"); `SpawnPart#resume` and delivery's `#start_for_send` clear it with `Session.clear_stopped` when starting for a person. Session-directory deletion removes it. | `WorkerPresence`, the worker startup/signal paths, and `Session#load` check the marker. It is read from disk on a decision (and on the hub refresh); no worker event is required. Its timestamp is compared with `starting.at` so a stop cancels an older start, not a later resume. |
|
|
23
23
|
| `archived` | `ArchiveStore.archive` is called by `SessionManager#archive_session`; `ArchiveStore.unarchive` is called by `#unarchive_session`, `SessionContinue#undo_failed_continue`, and the chain-delete undo/revival paths. Session-directory deletion removes it. | Lists, chain resolution, delivery, schedules, retention, and `WorkerPresence` call `ArchiveStore.archived?` against the file; changes are seen by the next read or list refresh. |
|
|
24
|
-
| `continue.lock` and `continue.json` | `SessionTransition` is the only code that flocks `continue.lock`: a continue takes it exclusively after its recap, for the previous link and the new link's reserved id at once (`SessionContinue#with_lock`: `exclusive`, `LOCK_WAIT` 10 s a try, then `Refused :transition_busy`), a user's link or chain delete takes it exclusively for its whole run (`SessionChain::Delete`, kind `delete`, `LOCK_WAIT` 10 s), the schedule prune, the retention sweep and a leaving worker's empty or scratch delete try it once (kind `delete`), a stop takes it for its mark and TERM (kind `stop`, `STOP_LOCK_WAIT` 10 s; a worker stopping its delegates tries once), an archive for its task stop and markers (kind `archive`, `ARCHIVE_LOCK_WAIT` 10 s), a ring's wake holds it shared across its check and resume, crash repair tries it once (`try_exclusive`), an exclusive holder records its kind in the file while it holds it (`holder`, which `Busy.held` reads), arrivals and readers that must exclude a continue take a nonblocking shared hold (`shared`: each `WakePolicy` row's `hold`, taken in the seats), and previews probe it (`held?`). `ContinueIntent#write` records the successor before archive and updates the archived ids after; failed-continue cleanup removes the intent. The lock file remains until session-directory deletion; a continue that ends before its new link is saved removes that link's reserved folder, and the previous link's lock when the link was deleted meanwhile (`SessionTransition.forget`). | Every `:shared` delivery (sends, every turn sender, pushes, peer says), peer pairs, context adds/removes/pushes, invites, schedules, the delete preview, `SessionLifecycle.read` (`transitioning`) and `ContinueIntent.in_flight` (through `SessionChain::Successor`) inspect the lock and intent. flock coordinates the live transition; readers reload the JSON. An intent without a held lock is a crashed continue, not an active one; so is one whose successor is neither saved nor held (a continue holds both), and one under another kind's hold (a delete, a stop, an archive: `SessionTransition.other_than_continue?`). |
|
|
24
|
+
| `continue.lock` and `continue.json` | `SessionTransition` is the only code that flocks `continue.lock`: a continue takes it exclusively after its recap, for the previous link and the new link's reserved id at once (`SessionContinue#with_lock`: `exclusive`, `LOCK_WAIT` 10 s a try, then `Refused :transition_busy`), a user's link or chain delete takes it exclusively for its whole run (`SessionChain::Delete`, kind `delete`, `LOCK_WAIT` 10 s), the schedule prune, the retention sweep and a leaving worker's empty or scratch delete try it once (kind `delete`), a stop takes it for its turn cancel, mark and TERM (kind `stop`, `STOP_LOCK_WAIT` 10 s for a short hold, a continue naming its new link, a delete or an archive refused at once; a worker stopping its delegates tries once), an archive for its task stop and markers (kind `archive`, `ARCHIVE_LOCK_WAIT` 10 s), a ring's wake holds it shared across its check and resume, crash repair tries it once (`try_exclusive`), an exclusive holder records its kind in the file while it holds it (`holder`, which `Busy.held` reads), arrivals and readers that must exclude a continue take a nonblocking shared hold (`shared`: each `WakePolicy` row's `hold`, taken in the seats), and previews probe it (`held?`). `ContinueIntent#write` records the successor before archive and updates the archived ids after; failed-continue cleanup removes the intent. The lock file remains until session-directory deletion; a continue that ends before its new link is saved removes that link's reserved folder, and the previous link's lock when the link was deleted meanwhile (`SessionTransition.forget`). | Every `:shared` delivery (sends, every turn sender, pushes, peer says), peer pairs, context adds/removes/pushes, invites, schedules, the delete preview, `SessionLifecycle.read` (`transitioning`) and `ContinueIntent.in_flight` (through `SessionChain::Successor`) inspect the lock and intent. flock coordinates the live transition; readers reload the JSON. An intent without a held lock is a crashed continue, not an active one; so is one whose successor is neither saved nor held (a continue holds both), and one under another kind's hold (a delete, a stop, an archive: `SessionTransition.other_than_continue?`). |
|
|
25
25
|
| `parent.json` | `Session#reparent` writes the override when `ChildMove` moves a child. Session-directory deletion removes it. | `ChildReports` resolves the current parent when routing a ring; the worker reads the override when loading its parent. Readers reload the file; it is not an event stream. |
|
|
26
26
|
| `reminders.json` | `Worker::LeavePart#carry_reminders` writes it for an asked restart, or removes it when stopped/no successor; stop, archive, and a stopped restart also remove it. `ReminderCarry#take` reads and removes it at worker start. | Only the next worker restores it into its Engine. It is a one-shot hand-off, not polled state; the session id, 120-second window, and stop marker are checked before restore. |
|
|
27
27
|
| Pending `input/`, `children/`, and `notes/` | `SessionInbox.write_input`, `#write_ring`, and `#write_note` write the files. A worker claims input and notes by atomic rename to `.processing`, then removes or settles them; rings are consumed by `ChildReports`. Session-directory deletion removes all three. | The worker checks input around turns and on its idle loop; rings and notes are checked by worker wake/absorption paths. The file is the durable queue; Bridge SSE can announce a live turn, but the worker's file scan is the fallback and recovery path. |
|
|
@@ -146,15 +146,15 @@ operation (one driver each, every private reach in that one file) and projects i
|
|
|
146
146
|
code can't make (a one-turn run's lock with a stop) is marked `reachable: false` with its note and still asserted.
|
|
147
147
|
|
|
148
148
|
Every answer must equal `ALLOWED[op][state]` (for the session hub, `SHOWN[state]`: `Web::SessionSummary.build`'s
|
|
149
|
-
status and bridge_up, its `
|
|
149
|
+
status and bridge_up, the live its summary gates the open question on (`SessionSummary.shown`)), or be named by exactly one `KNOWN_DIFFERENCES` entry (op, a `when`
|
|
150
150
|
over the row, a plain reason); an entry that names no mismatch fails as stale. The entries are the findings for the
|
|
151
151
|
owner, not fixed: stop-first schedule checks under a one-turn run's or an unknown owner's lock (`#busy_cell`'s stop override), and attach's under a
|
|
152
152
|
one-turn run's, a deleter's or an unknown owner's; chain mode's starting check before any one-turn-run check (`#busy_cell`'s F1b override); a start
|
|
153
153
|
marked after the stop holding a resume off;
|
|
154
|
-
`wake_for_report` reporting a worker's `:live` as `:owned
|
|
155
|
-
never reading the stop, the restart and schedule reading a deleter as starting, the schedule's Skew words,
|
|
156
|
-
`busy_reason`'s live branch falling through to the starting check
|
|
157
|
-
removed.) The delivery columns are
|
|
154
|
+
`wake_for_report` reporting a worker's `:live` as `:owned`. (Restart
|
|
155
|
+
never reading the stop, the restart and schedule reading a deleter as starting, the schedule's Skew words,
|
|
156
|
+
`busy_reason`'s live branch falling through to the starting check, and the hub's bridge_up, live and status overlay (F3/(c))
|
|
157
|
+
were fixed: their entries went stale and were removed.) The delivery columns are
|
|
158
158
|
generated from `WakePolicy::ROWS`, so for deliveries the matrix proves the states are drawn right (decide is a function
|
|
159
159
|
of the state), not what WakePolicy does; the literal columns and `SHOWN` are goldens.
|
|
160
160
|
|
|
@@ -180,10 +180,15 @@ continue (`SessionContinue.repair_interrupted`), not by worker startup.
|
|
|
180
180
|
in lib that flocks or probes it (`spec/session_transition_lock_spec.rb`). The file keeps its name: an older chi's
|
|
181
181
|
continue, followed send and delete honour it.
|
|
182
182
|
|
|
183
|
-
- `exclusive(ids, kind:, state_dir:, deadline:)` takes each id's lock in sorted order,
|
|
184
|
-
`deadline: nil` blocks (no caller since the continue took a deadline), seconds retry
|
|
185
|
-
and raise `SessionTransition::Busy`, which owns its refusal text and names the id.
|
|
186
|
-
|
|
183
|
+
- `exclusive(ids, kind:, state_dir:, deadline:, refuse_transitions: false)` takes each id's lock in sorted order,
|
|
184
|
+
creating a missing folder; `deadline: nil` blocks (no caller since the continue took a deadline), seconds retry
|
|
185
|
+
until then (`0`: one try) and raise `SessionTransition::Busy`, which owns its refusal text and names the id. With
|
|
186
|
+
`refuse_transitions` (a stop's; a deadline required, else `ArgumentError`) each failed try reads the holder again
|
|
187
|
+
(`Busy.held(id, taker: kind)`) and raises at once when it is a transition (`Busy#transition?`: a delete, an
|
|
188
|
+
archive, a continue whose intent names its new link); a stop, a repair, a holder that names nothing (an older
|
|
189
|
+
chi's, a continue before its intent, the new link's own hold) and every shared hold are waited out to the
|
|
190
|
+
deadline. Re-reading each try catches a delete that takes the lock while the stop waits behind a send. Ids taken
|
|
191
|
+
before a busy one are let go. While it holds a lock it writes its `kind` into the file (cleared on release, never from a lock another
|
|
187
192
|
holds; `try_exclusive` too).
|
|
188
193
|
- `holder(id, state_dir:)` is that kind (`:continue`, `:delete`), read only behind a failed shared try: a shared
|
|
189
194
|
holder (a send), an older chi's continue, a raw flock and a crash's leftover name none. `Busy.held(id, state_dir:)`
|
|
@@ -196,7 +201,10 @@ continue, followed send and delete honour it.
|
|
|
196
201
|
(its detail, which `--remote` reads back), `ContextSources.changing`, `Participants.invite`, the delete's refusal
|
|
197
202
|
(`DeleteRefused.held`) and the delete preview take their words from it; a delete holding the lock makes the seats
|
|
198
203
|
name no successor (`Hold.under`). The peer say/pair and the context push answer a status, `:busy`, whose words
|
|
199
|
-
are the plain ones.
|
|
204
|
+
are the plain ones. Those are `Busy#retry_message`, `#message` for every taker but a stop: a stop's Busy
|
|
205
|
+
(`taker: :stop`) that met a transition says what to do instead ("session ab12cd34 is being deleted", "… being
|
|
206
|
+
archived", "… being continued as <new id>: stop that one"). `DeleteRefused.held` and `ArchiveRefused.held` keep
|
|
207
|
+
the retry words (`retry_message`) for a stop they wrap.
|
|
200
208
|
- `try_exclusive(id, …)` is one try that creates no folder, crash repair's (`repair_intent`): a lock this thread
|
|
201
209
|
holds counts as taken, so a repair reached inside a continue never undoes it.
|
|
202
210
|
- `shared(id, state_dir:)` is a non-blocking shared hold (an invalid id is `false`; the lock file is created, the
|
|
@@ -281,15 +289,20 @@ archive.
|
|
|
281
289
|
|
|
282
290
|
### Stops, archives and the ring wake
|
|
283
291
|
|
|
284
|
-
- **A stop** (`SessionManager.stop_session`) takes `exclusive([id], kind: :stop, deadline: lock_wait
|
|
285
|
-
(`STOP_LOCK_WAIT` 10 s
|
|
286
|
-
|
|
292
|
+
- **A stop** (`SessionManager.stop_session`) takes `exclusive([id], kind: :stop, deadline: lock_wait,
|
|
293
|
+
refuse_transitions: true)` (`STOP_LOCK_WAIT` 10 s for a short hold; a continue naming its new link, a delete or an
|
|
294
|
+
archive refused at once) for the turn cancel, the owner read, the stop marker, the reminders hand-off and the
|
|
295
|
+
TERM/CONT; the owner wait after it (`wait:`) runs unheld. The turn cancel (a Bridge call whose read timeout is
|
|
296
|
+
`STOP_CANCEL_WAIT`, then up to `STOP_CANCEL_WAIT` for the worker's save) is the one deliberate, bounded exception
|
|
297
|
+
to "never a Bridge wait under a hold": a refused stop leaves the turn running, and no deadlock follows, because
|
|
298
|
+
every shared taker refuses at once on a held lock, a worker's own exclusive takes are one try, and the canceled
|
|
299
|
+
worker saves its turn without the transition lock. Only
|
|
287
300
|
a saved session's lock is taken (a gone one's folder is never made again; `Session.mark_stopped`'s not found
|
|
288
301
|
follows). A hold this thread has passes through: a continue's archive (`archive_session` → `stop_session`), its
|
|
289
302
|
`discard_failed_link`, a delete's `release_for_delete!`; a plain delete with a stop (no chain keywords, a scratch's
|
|
290
303
|
end: `delete_resolved` takes no transition lock) turns a held one into its own refusal (`stop_held` →
|
|
291
|
-
`DeleteRefused.held`). Not taken in time → `SessionTransition::Busy
|
|
292
|
-
nothing marked: chi web's 409 `stop_held` (`kind`, `successor_id`: `--remote` builds the same Busy), `chi sessions
|
|
304
|
+
`DeleteRefused.held`). Not taken in time, or held by a transition → `SessionTransition::Busy` (`taker: :stop`),
|
|
305
|
+
nothing canceled or marked: chi web's 409 `stop_held` (`kind`, `successor_id`: `--remote` builds the same Busy), `chi sessions
|
|
293
306
|
stop` prints it and exits 1. A worker stopping its delegates (the exit ask's stop-all, a plugin's
|
|
294
307
|
`ctx.sessions.stop`) tries once (`lock_wait: 0`): it holds its own `owner.lock`; a held child is left running
|
|
295
308
|
(logged / the plugin's `Error`, Busy's words).
|
|
@@ -348,7 +361,7 @@ These are documented race boundaries, not promises of an atomic lifecycle transi
|
|
|
348
361
|
| A ring wake decides to start, then a stop lands before resume (closed). | Before: `SpawnPart#wake_for_report` (`session_manager/spawn.rb`) checked, then `resume_session` cleared a stop that landed meanwhile and started the worker. Now the wake holds the session's transition lock shared across the check and the resume and the stop takes it exclusively for its mark and TERM: the stop comes after the start, whole (its marker stays), or the wake meets the stop's hold and leaves the ring on disk (`:busy`). | `spec/session_manager/spawn_spec.rb` ".wake_for_report" (a stop from another thread in the start callback is held off and its marker stays; a held lock answers `:busy`, nothing started). |
|
|
349
362
|
| A ring's own delivery wakes the parent while a stop lands. | `ChildReports.ring` → `SessionInbox.deliver(:ring)` (a `:none` row: its write must never be refused) decides, then starts the parent on another thread (`ChildReports#starter`, `start_for_inbox`): the hold of `wake_for_report` does not cover it, so a stop between the decide and the start can be cleared by it as before. | No pin (declared); a shared hold around the start alone, on the starter's thread, would close it. |
|
|
350
363
|
| A restart outside the transition lock. | `restart_session` asks the worker to leave and its successor to start (or the fallback TERMs and resumes); it spans two processes, so it takes no transition lock (D3): a continue, a delete, a stop or an archive may interleave with it, each with its own checks (the restart precheck reads `SessionLifecycle`). | No pin (declared). |
|
|
351
|
-
| A stop's
|
|
364
|
+
| A stop's owner wait is unheld (its turn cancel: closed). | `stop_session` waits for the owner after it lets go of the lock: a send in that wait may go in (and a new worker start after the wait, as before). The turn cancel now runs under the stop's hold (its Bridge read bounded by `STOP_CANCEL_WAIT`), so a stop refused busy no longer ends the turn. | `spec/session_manager/lifecycle_spec.rb` "under the transition lock" (held for the mark and TERM, not the owner wait) and "mid-turn" (the cancel under the stop's hold, its read timeout; a refused stop cancels nothing). |
|
|
352
365
|
| Empty-session discard races a delivery (closed for turns and notes). | `WorkerBoot#discard_left_session` (`worker_boot.rb`) checks emptiness after releasing the worker lock and again under the deletion lock (`delete_session`'s `still:`): a send or note that went in before the lock keeps the session. One that reads the session during the lock is refused (`DeliverResult::DELETING`, a note as gone); one that read it before the lock and wrote after it reads it again after its write and takes its file back (`SessionInbox.withdraw`), so no turn or note is reported delivered and then removed. No new lock for that: the write-then-reread and the recheck under the existing deletion lock close it (the discard also tries the session's transition lock once, kind `delete`: a send or a transition holding it keeps the session). What remains: a ring or fresh verdict that read the session before the lock and wrote after it is not taken back: it goes with the directory, or stays for the next worker if the delete gives up; neither is reported to a person. | `run_session_loop_spec.rb`: a send at deletion-lock acquisition is refused; one just before the lock keeps the session. `delivery_spec.rb` / `note_delivery_spec.rb`: the lock (or the removal) between the check and the write, deterministic through the bridge / writer seam. |
|
|
353
366
|
| Stop reads an owner pid, then sends TERM. | `LifecyclePart#stop_session` (`session_manager/lifecycle.rb`): the pid can be reused between the owner read and `Process.kill`; protecting that requires a real pid-reuse scenario. | No unit pin: pid reuse/process signaling is not reliably representable without real processes. |
|
|
354
367
|
| Saved `status` is used as a lifecycle hint. | `LifecyclePart#restart_fallback_holds` and `RemovalPart#archive_refusal` (`session_manager/lifecycle.rb`, `session_manager/removal.rb`) use saved `running` status as a busy hint; status is not a lock or proof that a worker is alive. | Unit spec: pin fallback refusal from saved status without a live Bridge. |
|
|
@@ -382,7 +395,8 @@ These are documented race boundaries, not promises of an atomic lifecycle transi
|
|
|
382
395
|
`ALLOWED` cells (the literal ones by hand; the delivery ones follow `WakePolicy::ROWS`) and the matrix's rows; a
|
|
383
396
|
decider that answers otherwise is a `KNOWN_DIFFERENCES` entry with its reason, never a silent cell change.
|
|
384
397
|
7. A new multi-step transition takes `SessionTransition.exclusive` with its own `kind` (add its words to
|
|
385
|
-
`Busy::WORDS` so `Busy.held` names it; any kind but `continue` names no new link
|
|
398
|
+
`Busy::WORDS` so `Busy.held` names it; any kind but `continue` names no new link; a long one a stop should not
|
|
399
|
+
wait for goes in `Busy::TRANSITIONS`, and a stop meeting it is refused at once), with a deadline, before any
|
|
386
400
|
`owner.lock`; an automatic one tries once (`deadline: 0`) and leaves the session for later, and so does one a
|
|
387
401
|
worker runs (it holds an `owner.lock`). A literal operation that takes the lock gets its `TAKES_LOCK` cell.
|
|
388
402
|
8. Recheck lock order, crash cleanup, and the existing file-format/compatibility specs before changing runtime behavior.
|