samagotchi 0.192.0 → 0.194.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 +128 -1
- data/docs/architecture.md +3 -3
- data/docs/bundle-authoring.md +1 -1
- data/docs/bundles.md +82 -40
- data/docs/cli.md +47 -17
- data/docs/configuration.md +75 -8
- data/docs/context.md +8 -5
- data/docs/desktop.md +3 -0
- data/docs/guardrails.md +20 -5
- data/docs/hooks.md +1 -0
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/bundles.md +2 -2
- data/docs/internals/engine.md +46 -3
- data/docs/internals/pages.md +4 -4
- data/docs/internals/panes.md +66 -0
- data/docs/internals/participants.md +5 -3
- data/docs/internals/peers.md +176 -27
- data/docs/internals/prompt-caching.md +6 -1
- data/docs/internals/remote-sessions.md +6 -0
- data/docs/internals/session-lifecycle.md +12 -4
- data/docs/internals/web-frontend.md +106 -22
- data/docs/internals/working-set.md +5 -1
- data/docs/peers.md +150 -27
- data/docs/plugins.md +48 -7
- data/docs/releasing.md +30 -2
- data/docs/scheduling.md +3 -2
- data/docs/sessions.md +16 -7
- data/docs/sub-agent.md +6 -4
- data/docs/system-one.md +4 -0
- data/docs/testing.md +38 -3
- data/docs/thin-clients.md +27 -11
- data/lib/samagotchi/bridge/card_store.rb +1 -1
- data/lib/samagotchi/broadcast/triage_model.rb +17 -0
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +8 -5
- data/lib/samagotchi/bundles/claude-peer/plugin.rb +24 -5
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +61 -24
- data/lib/samagotchi/bundles/claude-peer/scripts/pair +31 -8
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +8 -5
- data/lib/samagotchi/bundles/codex-peer/plugin.rb +62 -6
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +57 -19
- data/lib/samagotchi/bundles/codex-peer/scripts/pair +28 -7
- data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
- data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
- data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
- data/lib/samagotchi/bundles/mcp/plugin.rb +0 -7
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/chi_invocation.rb +7 -0
- data/lib/samagotchi/client.rb +18 -0
- data/lib/samagotchi/codex_rollout.rb +93 -0
- data/lib/samagotchi/compat.rb +8 -1
- data/lib/samagotchi/config.rb +19 -6
- data/lib/samagotchi/continue_offer.rb +13 -1
- data/lib/samagotchi/delivery.rb +2 -2
- data/lib/samagotchi/effective_model.rb +28 -2
- data/lib/samagotchi/engine/cards.rb +9 -4
- data/lib/samagotchi/engine/hooks.rb +8 -0
- data/lib/samagotchi/engine/models.rb +197 -7
- data/lib/samagotchi/engine/plugins.rb +2 -0
- data/lib/samagotchi/engine/side_requests.rb +72 -13
- data/lib/samagotchi/engine/toolkit.rb +1 -1
- data/lib/samagotchi/engine/turn_helpers.rb +1 -1
- data/lib/samagotchi/engine.rb +11 -8
- data/lib/samagotchi/engine_snapshots.rb +16 -3
- data/lib/samagotchi/events.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
- data/lib/samagotchi/hooks.rb +3 -1
- data/lib/samagotchi/host_registry.rb +146 -16
- data/lib/samagotchi/idle_client.rb +13 -2
- data/lib/samagotchi/idle_recap.rb +33 -3
- data/lib/samagotchi/idle_target.rb +27 -7
- data/lib/samagotchi/jsonl_store.rb +13 -2
- data/lib/samagotchi/llm/adapter_common.rb +4 -2
- data/lib/samagotchi/llm/anthropic_messages.rb +14 -2
- data/lib/samagotchi/llm/errors.rb +35 -4
- data/lib/samagotchi/llm/model_listing.rb +19 -0
- data/lib/samagotchi/llm/openai_chat.rb +8 -2
- data/lib/samagotchi/llm/prompt_cache.rb +5 -0
- data/lib/samagotchi/model_binding.rb +46 -4
- data/lib/samagotchi/model_catalog.rb +68 -8
- data/lib/samagotchi/model_profile.rb +35 -0
- data/lib/samagotchi/models_command.rb +8 -4
- data/lib/samagotchi/pages/launch.rb +1 -1
- data/lib/samagotchi/panes/kitty.rb +122 -0
- data/lib/samagotchi/panes.rb +185 -0
- data/lib/samagotchi/peer_announce.rb +245 -0
- data/lib/samagotchi/peer_cold.rb +92 -0
- data/lib/samagotchi/peer_command.rb +121 -20
- data/lib/samagotchi/peer_continue.rb +42 -16
- data/lib/samagotchi/peer_exchanges.rb +7 -0
- data/lib/samagotchi/peer_mailbox.rb +50 -10
- data/lib/samagotchi/peer_pair_here.rb +149 -0
- data/lib/samagotchi/peer_presence.rb +434 -0
- data/lib/samagotchi/peer_receipts.rb +33 -6
- data/lib/samagotchi/peer_say.rb +46 -21
- data/lib/samagotchi/peer_wait_expiry.rb +47 -0
- data/lib/samagotchi/plugin/api.rb +13 -1
- data/lib/samagotchi/plugin/card.rb +68 -11
- data/lib/samagotchi/plugin/context.rb +33 -2
- data/lib/samagotchi/plugin/panes.rb +54 -0
- data/lib/samagotchi/plugin/peer.rb +170 -63
- data/lib/samagotchi/plugin/peer_pairing.rb +290 -0
- data/lib/samagotchi/plugin/peer_start.rb +301 -0
- data/lib/samagotchi/plugin/peer_start_hook.rb +207 -0
- data/lib/samagotchi/plugin/peers.rb +89 -9
- data/lib/samagotchi/recap_setup.rb +40 -3
- data/lib/samagotchi/self_report.rb +25 -6
- data/lib/samagotchi/send_command.rb +6 -6
- data/lib/samagotchi/served_lookup.rb +225 -0
- data/lib/samagotchi/served_ref.rb +41 -0
- data/lib/samagotchi/session_access/contract.rb +6 -0
- data/lib/samagotchi/session_access/local.rb +149 -40
- data/lib/samagotchi/session_access/remote.rb +4 -4
- data/lib/samagotchi/session_access/remote_peers.rb +8 -5
- data/lib/samagotchi/session_chain/links.rb +8 -3
- data/lib/samagotchi/session_commands.rb +40 -8
- data/lib/samagotchi/session_continue.rb +11 -6
- data/lib/samagotchi/session_lifecycle/allowed.rb +4 -2
- data/lib/samagotchi/session_manager/delivery.rb +5 -0
- data/lib/samagotchi/session_manager/lifecycle.rb +58 -7
- data/lib/samagotchi/session_manager/removal.rb +3 -0
- data/lib/samagotchi/session_manager/spawn.rb +6 -1
- data/lib/samagotchi/session_model_settings.rb +7 -3
- data/lib/samagotchi/session_stores.rb +25 -11
- data/lib/samagotchi/sessions_command.rb +16 -3
- data/lib/samagotchi/system_one/http_backend.rb +111 -10
- data/lib/samagotchi/system_one/runs.rb +5 -2
- data/lib/samagotchi/system_prompt.rb +11 -4
- data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -1
- data/lib/samagotchi/terminal_ui/formatting.rb +26 -12
- data/lib/samagotchi/terminal_ui/status_row.rb +20 -3
- data/lib/samagotchi/terminal_ui.rb +1 -1
- data/lib/samagotchi/testing/boundary.rb +0 -1
- data/lib/samagotchi/testing/bundle.rb +6 -2
- data/lib/samagotchi/testing/host.rb +1 -0
- data/lib/samagotchi/testing/recorder.rb +3 -0
- data/lib/samagotchi/turn_endings.rb +6 -2
- data/lib/samagotchi/user_typed.rb +29 -0
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +8 -20
- data/lib/samagotchi/web/participant_review.rb +1 -1
- data/lib/samagotchi/web/participant_view.rb +1 -1
- data/lib/samagotchi/web/peer_routes.rb +40 -15
- data/lib/samagotchi/web/public/agent_rows.js +206 -0
- data/lib/samagotchi/web/public/agent_runs.js +595 -0
- data/lib/samagotchi/web/public/answer_fold.js +41 -44
- data/lib/samagotchi/web/public/app.js +4 -4
- data/lib/samagotchi/web/public/block_fix.js +1 -1
- data/lib/samagotchi/web/public/card.js +26 -10
- data/lib/samagotchi/web/public/cards_place.js +6 -4
- data/lib/samagotchi/web/public/context_chips.js +24 -2
- data/lib/samagotchi/web/public/copy.js +8 -2
- data/lib/samagotchi/web/public/data.js +2 -1
- data/lib/samagotchi/web/public/format.js +9 -1
- data/lib/samagotchi/web/public/history_reveal.js +5 -2
- data/lib/samagotchi/web/public/index.html +56 -2
- data/lib/samagotchi/web/public/info_bar_model.js +1 -1
- data/lib/samagotchi/web/public/model_pick.js +18 -5
- data/lib/samagotchi/web/public/model_picker.js +1 -1
- data/lib/samagotchi/web/public/page_view.js +1 -1
- data/lib/samagotchi/web/public/pages.css +1 -7
- data/lib/samagotchi/web/public/peer_chip.js +15 -5
- data/lib/samagotchi/web/public/peer_data.js +4 -2
- data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
- data/lib/samagotchi/web/public/peer_note.js +4 -2
- data/lib/samagotchi/web/public/peer_row.js +37 -0
- data/lib/samagotchi/web/public/peer_wait.js +36 -0
- data/lib/samagotchi/web/public/quiet_notes.js +12 -1
- data/lib/samagotchi/web/public/revise_stack.js +5 -2
- data/lib/samagotchi/web/public/send_turn.js +11 -3
- data/lib/samagotchi/web/public/served_ref.js +9 -0
- data/lib/samagotchi/web/public/session_fields.js +1 -0
- data/lib/samagotchi/web/public/session_state.js +4 -0
- data/lib/samagotchi/web/public/stage_missing.js +23 -6
- data/lib/samagotchi/web/public/stream_handlers.js +16 -0
- data/lib/samagotchi/web/public/turn_block.js +4 -0
- data/lib/samagotchi/web/public/version_notices.js +7 -1
- data/lib/samagotchi/web/session_control.rb +19 -10
- data/lib/samagotchi/web/session_show.rb +20 -0
- data/lib/samagotchi/web/update_ops.rb +2 -2
- data/lib/samagotchi/worker/command_queue.rb +3 -0
- data/lib/samagotchi/worker/mail.rb +24 -1
- data/lib/samagotchi/worker.rb +8 -5
- data/lib/samagotchi/worker_inbound/mail.rb +34 -6
- data/lib/samagotchi/worker_inbound.rb +11 -3
- data/lib/samagotchi/worker_link.rb +13 -1
- data/lib/samagotchi/worker_wakes.rb +33 -5
- metadata +22 -2
- data/lib/samagotchi/web/public/pages_group.js +0 -67
data/docs/internals/peers.md
CHANGED
|
@@ -10,8 +10,10 @@ and `RE_RE` (a send ref).
|
|
|
10
10
|
**The peer's side, `<state>/samagotchi/mailbox/<session id>/<peer>/`** (`PeerMailbox`): the only folder a
|
|
11
11
|
sandboxed peer writes, beside the sessions folder and apart from it.
|
|
12
12
|
|
|
13
|
-
- `link.json`: `PeerLink(peer, address, paired_at, from)`; `address` nil: answers only
|
|
14
|
-
|
|
13
|
+
- `link.json`: `PeerLink(peer, address, paired_at, from, peer_session)`; `address` nil: answers only;
|
|
14
|
+
`peer_session` (written only when set, read by `from_h`, so a continue's copy keeps it) the peer's own session id.
|
|
15
|
+
`chi peer pair` writes it whole; `unpair` removes only it (and, `Local#peer_unpair`, the session's wait and
|
|
16
|
+
pairing files below). An older chi drops `peer_session` on its continue and its re-pair.
|
|
15
17
|
- `in/<serial>.json`: `PeerMessage(serial, text, summary, wake, re, at)`, one file per message, written whole
|
|
16
18
|
(`AtomicFile`; its temp name never matches `FILE_RE`).
|
|
17
19
|
- `lock`: the say's, while it picks a serial and writes (`flock`, opened `NOFOLLOW`).
|
|
@@ -27,13 +29,108 @@ A bad file is a `BadFile` with its reason. A directory link is never followed: a
|
|
|
27
29
|
listed, `serials` reads a linked folder as empty and `post` refuses one.
|
|
28
30
|
|
|
29
31
|
**chi's side, `sessions/<id>/peer_receipts.json`** (`PeerReceipts`), written only by the session's worker, on
|
|
30
|
-
its loop thread: `{peers: {<peer>: {box, taken, receipts}}}`, `Receipt(serial, state, reason, turn,
|
|
31
|
-
at)`. `
|
|
32
|
+
its loop thread: `{peers: {<peer>: {box, taken, receipts}}, peer_wakes}`, `Receipt(serial, state, reason, turn,
|
|
33
|
+
outcome, at)`. `peer_wakes` is `WorkerWakes#peer_in_a_row` (the `peer.turns` count), saved at each change
|
|
34
|
+
(`Worker::MailPart#save_peer_wakes`, given to `WorkerWakes` as `on_peer_count`: each `count!(peer: true)` and the
|
|
35
|
+
reset in `human_input!(interactive: true)`, all on the loop thread) and read at the worker's start; absent is 0 (a
|
|
36
|
+
0.192.0 file; an older worker's write drops it: a reset). `box` is 6 random hex the worker mints (and writes at once) with a peer's first message; `taken` is the
|
|
32
37
|
newest serial it took. The CLI and chi web only read it.
|
|
33
38
|
|
|
34
39
|
`SessionStores` rows: `link.json`, `in/`, `lock` (removal `:peer_mailbox`: a delete removes the session's
|
|
35
|
-
mailbox folder) and `peer_receipts.json` (`:session_files`); a continue
|
|
36
|
-
|
|
40
|
+
mailbox folder) and `peer_receipts.json` (`:session_files`); a continue copies `link.json` to the new link and
|
|
41
|
+
leaves the rest with the previous one (below).
|
|
42
|
+
|
|
43
|
+
## Who is here: `PeerPresence`
|
|
44
|
+
|
|
45
|
+
`<state>/samagotchi/mailbox/.here/<peer>/`, inside the mailbox root on purpose (the one folder a sandboxed peer may
|
|
46
|
+
write; the `chi-mailbox` guardrail denies chi's own tools any write there; `SessionPaths.valid_id?` rejects `.here`,
|
|
47
|
+
so nothing reads it as a session):
|
|
48
|
+
|
|
49
|
+
- `<peer session>.json`: `PeerHere(peer, session, address, cwd, project, pid, at)`, written whole by `chi peer
|
|
50
|
+
announce` only. `project` is `MemoryPaths.project_key` of the cwd, computed once; `pid` is `CLAUDE_PID` (the
|
|
51
|
+
socket's file-name number as fallback). Live: the pid alive and the address a socket, and a socket named
|
|
52
|
+
`<n>.sock` (Claude Code's) `n == pid` (a forged entry can't borrow a real Claude's pid, its title and its Show).
|
|
53
|
+
A dead one is removed by whoever reads the folder. A live one on the same address under another session id is superseded by the announce
|
|
54
|
+
(a `/clear` gives Claude a new session id on the same socket): removed, its pairing files moved, its links'
|
|
55
|
+
`peer_session` renamed (`Local#peer_retag`).
|
|
56
|
+
- `waiting/<chi session>.json`: `PeerWaiting(session, project, at)`, a 10-minute wait (`WAIT_SECONDS`); an `at` in
|
|
57
|
+
the future or unparsable is stale, and `marks` (what an announce and `--here` pair against) skips an archived
|
|
58
|
+
session's (stale on read: archiving leaves the file). **A stale wait is removed only by its session's worker** (`PeerWaitExpiry`, from
|
|
59
|
+
`Worker::MailPart#expire_peer_waits` in `idle_pass`: removed, and once per wait `:peer_wait_ended`, the bundle's
|
|
60
|
+
`ctx.notify` line; a session paired meanwhile, or a peer no bundle declares, gets no line), its unpair and its
|
|
61
|
+
delete; every other reader treats it as absent, so the line isn't lost. A continue moves it to the new link
|
|
62
|
+
(`PeerContinue#carry_waits`, keeping `at`).
|
|
63
|
+
- `paired/<peer session>/<chi session>`: one empty file per pairing made with a `peer_session`
|
|
64
|
+
(`Local#pair_on`), never rewritten, removed by unpair and delete (the peer session's folder too once it is
|
|
65
|
+
empty: `rmdir`, so a pairing written meanwhile keeps it). A resume's announce lists it and re-pairs each
|
|
66
|
+
through `Local#peer_refresh` (its busy, continue and worker-age rules), only while the chain's live link is still
|
|
67
|
+
that peer session's; else the file is dropped (an unpair, another Claude paired since).
|
|
68
|
+
- **`claim`**: an atomic rename of the wait's file (`<id>.json.claimed-<hex>`). The announce, `--here` and a row's
|
|
69
|
+
Pair claim before they pair; anything but `:paired` renames it back; a pairing that paired ends the link's wait
|
|
70
|
+
(and any claimed leftover of a crash). While a claim is held the mark is only its claimed file, which `waiting`
|
|
71
|
+
and `marks` don't read: `claimed?` (a claimed file with a fresh `at`) is what the other paths ask, and they write
|
|
72
|
+
nothing while it is true (`/claude pair`, a row's Pair, `--here`).
|
|
73
|
+
|
|
74
|
+
`SessionStores` rows: `waiting/<id>.json` (`continue: :peers`) and `paired/<peer session>/<id>`, both removal
|
|
75
|
+
`:peer_presence` (`RemovalPart#remove_files`), not cross-version.
|
|
76
|
+
|
|
77
|
+
**`chi peer announce NAME`** (`PeerAnnounce`): Claude Code's `SessionStart` hook. Nothing unless
|
|
78
|
+
`CLAUDE_CODE_SESSION_ATTENDED` is 1 (a headless or nested `claude -p` is 0; subagents fire no `SessionStart`).
|
|
79
|
+
It writes the `PeerHere` (superseding), refreshes its pairings (`chi <id8>: pairing refreshed`), and when it has
|
|
80
|
+
none takes the one fresh wait of its project (`paired with chi <id8> (<title>): …`; two or more: names them, pairs
|
|
81
|
+
none). Its stdout enters Claude's start context; any failure prints nothing and exits 0. Measured 0.13 s on the
|
|
82
|
+
Studio. Who the peer is comes from a reader returning one `PeerAnnounce::Announcer` (session, address, cwd, project,
|
|
83
|
+
pid, `lists_itself`, `from`, `app`): Claude's above, and Codex's for `announce codex`:
|
|
84
|
+
|
|
85
|
+
- **Codex's** (codex-peer's start hook, appended to `$CODEX_HOME/hooks.json`): stdin only. It needs
|
|
86
|
+
`hook_event_name: SessionStart`, `source: startup` (never `resume`, `clear`, `compact`, `fork`), a `session_id`
|
|
87
|
+
`PeerPresence.peer_session?` takes and an absolute `cwd`; then `CodexRollout.interactive_start?` on
|
|
88
|
+
`transcript_path`. The address and the peer session are the thread id; it writes no `PeerHere` (no pid, no socket:
|
|
89
|
+
`PeerPresence.live?` can't hold, and the TUI's hook runs in Codex's app-server daemon, which outlives every window),
|
|
90
|
+
so a thread with a pairing (`paired_sessions` + `peer_refresh` `:same`) takes nothing, else the mark as above
|
|
91
|
+
(`from: "Codex in <cwd>"`). Under the daemon's `CHI_REMOTE` bin/chi exits 2 first; the line's `|| true` hides it.
|
|
92
|
+
An older chi with this line exits at the `CLAUDE_CODE_SESSION_ATTENDED` gate (silent).
|
|
93
|
+
- **`CodexRollout`** (checked on Codex 0.172.0, undocumented): line 1 of the rollout (`type: session_meta`) passes
|
|
94
|
+
only with `payload.originator == "codex-tui"`, `payload.thread_source == "user"`, a string `payload.source` and
|
|
95
|
+
`payload.id == session_id` (an allowlist: `codex_exec`, a subagent, anything missing fail closed). The file is
|
|
96
|
+
lstat'ed (a regular file, no link followed, opened `NOFOLLOW`) and its real path must be under the real
|
|
97
|
+
`<codex home>/sessions`, the codex home being the hook env's `CODEX_HOME` (the daemon's), else `~/.codex`. Line 1
|
|
98
|
+
is ~19 KB (`base_instructions`), so it is read to the first newline within `LINE_MAX_BYTES` (1 MiB), never
|
|
99
|
+
`PeerPresence::FILE_MAX_BYTES`. The hook fires 1–2 s after the file is born, so a missing file, a 0-byte one or a
|
|
100
|
+
line with no newline yet is tried `TRIES` (10) × `TRY_SECONDS` (0.1 s), then given up silently. A headless `exec`
|
|
101
|
+
boots chi and exits at this gate (~0.4 s wall, 0.16 s CPU, on the Studio).
|
|
102
|
+
|
|
103
|
+
**`chi peer pair NAME --here`** (`PeerPairHere`): the fresh wait of this folder's project (claimed), else the one
|
|
104
|
+
session of that project (by `project_key`, not a path prefix) a worker runs now, else exit 1 with the candidates.
|
|
105
|
+
A mark or live session another pairing holds (`claimed?`, or the one mark's claim lost) exits 1 rather than falling
|
|
106
|
+
back; a chosen session whose chain's live link is paired with another peer (another address, and another peer
|
|
107
|
+
session when both are named: the same socket after a `/clear` is the same Claude) exits 1 too, "unpair there
|
|
108
|
+
first" (owner: `--here` never replaces a live one; a pair with an id does). One whose peer is gone
|
|
109
|
+
(`PeerLink#socket_gone?`: an absolute socket path that is no socket now; claude-peer's `link_gone?` is the same
|
|
110
|
+
rule) is replaced, as `/claude pair` ends it: its pairing file dropped and a stderr line (the pair script reads
|
|
111
|
+
stdout's first word). A Codex thread id is never gone, so Codex keeps the refusal.
|
|
112
|
+
Before the live fallback (a fresh mark still pairs first), a live session of the project whose chain's link is
|
|
113
|
+
paired with this peer already, by this peer session or at this address (codex-peer's start hook paired it; an older
|
|
114
|
+
pair script passes no `--peer-session`), wins: `PeerPairHere::Found#same`, and `PeerCommand` says it paired
|
|
115
|
+
(`PeerPaired` `:same`, nothing written) or, when the address or peer session changed, pairs it again (keeping its
|
|
116
|
+
peer session when none was given). A stopped session's pairing never wins (a resumed Codex keeps its thread).
|
|
117
|
+
The pair scripts run it with no id (refused over a remote by the script itself); codex-peer's passes
|
|
118
|
+
`--peer-session "$thread"`.
|
|
119
|
+
|
|
120
|
+
**From chi's side** (`Plugin::PeerPairing`, `ctx.peers.here/pair/wait/claim`): `/claude pair` (one here: pairs;
|
|
121
|
+
none: waits; several: waits and draws the card, rows by `ctx.card(rows:)`), a row's `pair <id8>` (claims first:
|
|
122
|
+
a pairing made meanwhile is named, nothing written; a wait that ended pairs anyway), `show <id8>` (the window found
|
|
123
|
+
live by its pid, `ctx.panes`, only under `ctx.user_typed?`), `unpair`. A bundle whose peer doesn't announce
|
|
124
|
+
(`announces?` false: codex-peer) only waits. The start hook (`Plugin::PeerStartHook`, `/<peer> install-hook
|
|
125
|
+
[--yes]`) is merged only under `ctx.user_typed?`: claude-peer's into Claude Code's settings.json, codex-peer's into
|
|
126
|
+
Codex's hooks.json (the bundle's `#hook_file`, `#start_hook_line`, `#hook_paragraph`, `#hook_written_line`,
|
|
127
|
+
`#hook_stale_tail`); `#with_hook` replaces an announce line in place, else appends a group, never reorders (Codex's
|
|
128
|
+
trust is `[hooks.state."<file>:session_start:<group>:<hook>"]` in config.toml, index-keyed, which chi never writes). `/<peer> start`
|
|
129
|
+
(`Plugin::PeerStart`) writes the wait and opens a kitty tab running the peer: it has no path of its own to pair (the
|
|
130
|
+
started Claude's announce takes the wait; codex-peer's first prompt runs the skill's `--here`, or its start hook
|
|
131
|
+
takes the wait at that prompt; `#start_needs_hook?`: claude true, codex false, and codex's opened line adds
|
|
132
|
+
`#start_review_hint` while its hook is current); its `PaneRef` lives
|
|
133
|
+
in the bundle's `state.json`, never here ([panes.md](panes.md)).
|
|
37
134
|
|
|
38
135
|
## Who is a peer
|
|
39
136
|
|
|
@@ -53,16 +150,30 @@ starts without it.
|
|
|
53
150
|
`chi peer say` (`PeerCommand`) → `SessionAccess::Local#peer_say` (`RemotePeers#peer_say` through `--remote`,
|
|
54
151
|
which posts `…/peers/NAME/say` with its `wait`: chi web waits, and its read timeout is the wait plus 30 s).
|
|
55
152
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
153
|
+
0. **The link it runs on** (`Local#peer_head`): the id said to, or, when it is archived, its chain's first live
|
|
154
|
+
link (`SessionChain::Links#first_live`, `SessionInbox::Head`'s walk; only an archived id lists the sessions).
|
|
155
|
+
Every step below is keyed on that link, never on the id asked (its `taken`, its receipts, its worker, its hold),
|
|
156
|
+
and a received say's `PeerSay#forwarded_to` names it (on the wire; the line ends `· session continued as <id8>:
|
|
157
|
+
answer there`; an older client drops it and prints the old line). One hop: a link continued again meanwhile is
|
|
158
|
+
refused as continued. `peer_pair` (`PeerPaired#forwarded_to`), `peer_unpair` (the asked link's pairing and the
|
|
159
|
+
live link's, `PeerUnpaired`) and `peer_list` walk the same way; `chi peer ls` resolves with the access's `head`
|
|
160
|
+
(chi send's, also through `--remote`) and names the link. chi web's `GET …/peers`, the chip's feed, stays on
|
|
161
|
+
its page's session.
|
|
162
|
+
|
|
163
|
+
1. Refused before anything is written: no session, continued (with the next id), no `link.json` (on a link
|
|
164
|
+
reached from a continued id: `:continued` naming that link, the words the 0.192.0 skills pair again on), a live
|
|
165
|
+
worker without the `peer_mail` Bridge feature (`WorkerLink.live_features`, read only), `UNTAKEN_MAX` (200)
|
|
166
|
+
untaken messages or noted receipts.
|
|
59
167
|
2. Under a shared hold of the session's transition lock (`SessionTransition.shared`, `Local#moved_on`), the
|
|
60
168
|
continued check again, then the delivery (step 3): a continue holding the lock (from after its recap through
|
|
61
169
|
`PeerContinue`'s carry) refuses the say `:continued` naming its new link (`SessionChain::Successor.of` with
|
|
62
|
-
`in_flight: true`; the line `this session is being continued as <id>: say it
|
|
170
|
+
`in_flight: true`; the line `this session is being continued as <id>: say it again in a moment`, `in_flight`
|
|
63
171
|
on the wire), or `:busy` (`SessionTransition::Busy`'s words) when the holder names none. So a say never lands
|
|
64
|
-
in a mailbox the carry already read (N1). The
|
|
65
|
-
|
|
172
|
+
in a mailbox the carry already read (N1). The pairing is read again inside the hold: a continue saves its new
|
|
173
|
+
link, then copies the pairing in its `before_spawn` holding the link's lock, so a say meanwhile is busy, never a
|
|
174
|
+
refusal that sends the peer to pair again. The feature probe before and the receipt wait after stay outside the
|
|
175
|
+
hold; the delivery's worker start (`resume_session`, a spawn) is inside it. A delivery the row's own hold
|
|
176
|
+
refused (`Hold.under`) reads as `:continued` (its successor named) or `:busy`, not as no such session.
|
|
66
177
|
3. `SessionInbox.deliver(:peer)` (`WakePolicy::ROWS[:peer]`, the push row; `START_EVENTS[:peer] =
|
|
67
178
|
:peer_woke_session`): a session gone or being deleted refuses before its block writes. Inside the block:
|
|
68
179
|
the lock, the serial, the write, the trim. The block's "asks for a worker" is the message's own `wake`: no
|
|
@@ -70,8 +181,8 @@ which posts `…/peers/NAME/say` with its `wait`: chi web waits, and its read ti
|
|
|
70
181
|
4. The line (`PeerSay`): what the say saw at once (a running turn, a stopped or archived session, a one-turn run,
|
|
71
182
|
a failed start), else a receipt read every 250 ms within the wait, then the peer's other held receipts.
|
|
72
183
|
|
|
73
|
-
`chi peer pair` makes the old-worker and continued checks too,
|
|
74
|
-
`link.json` under the same shared hold (`:continued` in flight, `:busy`). A context push into the session's own
|
|
184
|
+
`chi peer pair` makes the old-worker and continued checks too, on the link step 0 reached, with the same sentences
|
|
185
|
+
(`PeerPaired`), and writes `link.json` under the same shared hold (`:continued` in flight, `:busy`). A context push into the session's own
|
|
75
186
|
source does too (`Local#context_push`: 410 `context_continued` with `in_flight`, 423 `context_busy`). The continued
|
|
76
187
|
words are `SessionChain::Continued`'s, one wording for every refusal of a continued link ("this session" in a
|
|
77
188
|
peer's line: the installed skills look for `this session was continued as <id>`). Wire: an older chi `--remote`
|
|
@@ -90,7 +201,7 @@ why a wake can't run: `:queued`, `:exit`, `:leaving`, `:before_turn` (nil: it ma
|
|
|
90
201
|
plus `box`), its text by `PeerNote.body` (a wake note up to the tool output cap, a plain one up to
|
|
91
202
|
`PeerNote::HELD_CHARS`; over it, `PeerNote.message_text` points at `<peer>_read(serial: N)`).
|
|
92
203
|
- **Wake:** the batch wakes when a message in it asked, `peer.turns` is above 0 (else `held: off`), the caller
|
|
93
|
-
gave no `hold
|
|
204
|
+
gave no `hold:`, the cache isn't cold (else `held: cold`, below) and `WorkerWakes#wake_hold(peer: !agreed)` is nil. The turn starts at the batch's last note;
|
|
94
205
|
its wake line, its origin (`peer:<name>`, `ClientId::PEER_PREFIX`) and the count come from the newest message
|
|
95
206
|
that asked; an agreeing one (`VERDICT OK`) counts toward `session.max_wakes` only. In the start grace nothing
|
|
96
207
|
is taken and `mail_wake_waiting?` joins `idle_wait`'s check.
|
|
@@ -100,6 +211,20 @@ why a wake can't run: `:queued`, `:exit`, `:leaving`, `:before_turn` (nil: it ma
|
|
|
100
211
|
note already in the conversation doesn't wake.
|
|
101
212
|
- **An unreadable file** (a transient read error) raises and the batch retries on the next pass; a bad file's
|
|
102
213
|
contents are refused as `invalid` and move `taken`.
|
|
214
|
+
- **The cold hold** (`MailPart#cold_hold?`, `PeerCold`): none of the batch's asking messages is an answer chi asked
|
|
215
|
+
for that doesn't agree (`PeerCold.asked_for?`: its `re` is a `sent` row of `peer_exchanges.jsonl` for that peer,
|
|
216
|
+
in this session or `Session#continues`, that no earlier message of the peer's claimed, as `PeerExchanges.joined`
|
|
217
|
+
pairs them: one answer claims a send, so an old or repeated `re` is held; a log that is there and can't be read,
|
|
218
|
+
`PeerExchanges.read!`, counts as asked), and `PeerCold.cold?`: the host keeps a
|
|
219
|
+
TTL'd cache (`Engine#remote_cache_ttl`: the chat adapter's `cache_breakpoints?`, a remote Claude model's chat
|
|
220
|
+
requests, through `OpenAIChat`, or `AnthropicMessages` with a dialect whose breakpoints weren't refused; `PromptCache.ttl_seconds`;
|
|
221
|
+
nil on a local model), `Session#last_turn`'s `ended_at` is older than it (a `ContinueOffer` stamp or a failed
|
|
222
|
+
turn's taken as it is: never earlier than the last request), and `analytics.json`'s `context.used_tokens` is above
|
|
223
|
+
`PeerCold::FLOOR_TOKENS` (20,000). No `ended_at`, no count or an unparsable time: warm. Side requests (recap,
|
|
224
|
+
`ctx.ask_model`) go through `IdleClient` with no breakpoints, so they neither read nor refresh the cache: the
|
|
225
|
+
turn's end is the cache's last refresh. Its one-time notice is its own (`WorkerWakes#notice_peer_cold!`, reset by
|
|
226
|
+
interactive input), apart from the budget's. The notices' once-flags are the worker's, not saved: a new worker
|
|
227
|
+
(an idle exit, a restart) can say a held message once more, though the count it reads (`peer_wakes`) is saved.
|
|
103
228
|
- **The wake turn:** `MailWake(peer, turn_id, plain_note, agreed)`, run by `WakeTurnsPart#run_mail_wake_turn`
|
|
104
229
|
through `run_wake`. The one-time hook notice for a held message (`WorkerInbound#peer_held`) is the TUI's and
|
|
105
230
|
the web's.
|
|
@@ -134,28 +259,52 @@ wake line. The wording is model-visible and eval-tuned (0017).
|
|
|
134
259
|
The peer bundles' base: `ctx.peers.link(PEER)` (`Plugin::Peers`, read only) is the pairing whose address the
|
|
135
260
|
transport sends to; `<peer>_read` reads a message (`ctx.peers.message`) paged by lines, in the peer block; the
|
|
136
261
|
status card reads the link and the newest message, and says "paired the old way: pair again" when an older
|
|
137
|
-
bundle's context source (`LEGACY_INBOX`, `LEGACY_OUTBOX`) is attached.
|
|
138
|
-
|
|
139
|
-
|
|
262
|
+
bundle's context source (`LEGACY_INBOX`, `LEGACY_OUTBOX`) is attached. A continue tells the peer nothing: the
|
|
263
|
+
pairing is copied (below), and the next send's header names the new id. (An older chi's init task posted a
|
|
264
|
+
`moved` message; the skills still name it as chi's, and don't reply to it.) `ctx.peers.left_behind` reads the
|
|
265
|
+
previous link's pairing, the one the copy came from.
|
|
266
|
+
|
|
267
|
+
A model's send to a dormant pairing (`Peer#quiet_check!`, `by: "model"` only): the newest of the link's `paired_at`,
|
|
268
|
+
`last-send.json`, the `sent` rows of `peer_exchanges.jsonl` and the peer's newest message, over this session and
|
|
269
|
+
`ctx.continues` (one hop: the copied pairing keeps its `paired_at` and the new link's logs start empty), is older than
|
|
270
|
+
`peer.quiet_minutes`. In a turn with `ctx.turn_interactive?` (the turn's origin `ClientId.interactive?`; a person's first prompt
|
|
271
|
+
from a web tab or a TUI keeps that screen's id, `Session#first_turn_client_id`, and a Continue tap on a step-limit
|
|
272
|
+
offer continues an interactive offer turn as its screen's, `ContinueOffer#continue_client`) it asks
|
|
273
|
+
through `ctx.ask_user` (Send tagged `:spend`); in any other turn `ask_user` would block with nobody to answer
|
|
274
|
+
(`QuestionDesk` waits with no timeout), so it raises `SendError` at once. A Don't send (or no answer) is remembered
|
|
275
|
+
until the next `before_turn`. The tools' descriptions don't change (no prompt rebuild).
|
|
276
|
+
|
|
277
|
+
The skills (`scripts/chi-peer-SKILL.md`) say an answer from a file (`$TMPDIR/chi-peer/answer-<ref>.md`, `chi peer
|
|
278
|
+
say … < file`): a say refused with "try again" is run again as it is; after a `#N received` line or a failure with
|
|
279
|
+
no line it is not (a say has no idempotency key, so a second run writes a second message).
|
|
140
280
|
|
|
141
281
|
## A continue: `PeerContinue`
|
|
142
282
|
|
|
143
|
-
`SessionContinue::CARRY` step `:peers
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
283
|
+
`SessionContinue::CARRY` step `:peers` (its store `:peer_mailbox`, its file `link.json`), in the new link's
|
|
284
|
+
`before_spawn` (both workers down): first each pairing of the previous link is copied to the new one as it is
|
|
285
|
+
(`PeerMailbox.carry_links`: `address`, `from` and `paired_at` kept), whether or not anything is unread; then the
|
|
286
|
+
previous link's messages never taken and those whose receipts are still `held` or `noted`, in the worker's order,
|
|
287
|
+
become one note in the new link (`NOTE_SOURCE` "peer messages"), each text in its peer block and cut past 4 KiB,
|
|
288
|
+
within the inbox's note limit; a cut text ends pointing at `<peer>_read(serial: N, box: "<previous id8>")`, which
|
|
289
|
+
`Plugin::Peers#message` reads from the link this session continues (that id's first 8 as the box; one hop, this
|
|
290
|
+
session's own chain only). Each part is best effort (logged, the link starts
|
|
291
|
+
without it). The previous link's mailbox, `taken` and receipts are only read, so there is no undo: the copies are
|
|
292
|
+
in the new link's mailbox folder, which a failed continue's delete removes (`discard_failed_link` →
|
|
293
|
+
`delete_session` → `:peer_mailbox`). The previous link keeps its own `link.json`. Forwarded answers that name a
|
|
294
|
+
send of the previous link (`re`) show in the new link's chip as an answer with no send (its `peer_exchanges.jsonl`
|
|
295
|
+
starts empty).
|
|
149
296
|
|
|
150
297
|
## chi web
|
|
151
298
|
|
|
152
299
|
`Web::PeerRoutes` (all `:owner`, a participant gets 403):
|
|
153
300
|
|
|
154
|
-
- `GET …/peers` → `{peers: [{name, label, paired_at, from, address, can_send, messages, exchanges}]}`: one
|
|
155
|
-
mailbox folder (`PeerRoster`),
|
|
301
|
+
- `GET …/peers` → `{peers: [{name, label, paired_at, from, address, can_send, messages, exchanges, waiting}]}`: one
|
|
302
|
+
row per mailbox folder (`PeerRoster`), and one per peer this session waits for, with `waiting: {until}` (a fresh
|
|
303
|
+
wait only: `#waiting_rows`; the page's waiting chip, `peer_wait.js`), its newest 20 messages with their receipts and `words`
|
|
156
304
|
(`PeerRoster.state_words`), and `exchanges` (`PeerExchanges.joined` over chi's sends and the messages as answer
|
|
157
305
|
lines). No text.
|
|
158
|
-
- `GET …/peers/NAME/messages/SERIAL` (the text and its receipt); `DELETE …/peers/NAME` (Unpair
|
|
306
|
+
- `GET …/peers/NAME/messages/SERIAL` (the text and its receipt); `DELETE …/peers/NAME` (Unpair, and the waiting
|
|
307
|
+
chip's Cancel: `Local#peer_unpair` ends the wait too; `waited: true` says one ended); `POST
|
|
159
308
|
…/peers/NAME/pair` and `…/say` (the remote's; the say waits here).
|
|
160
309
|
|
|
161
310
|
The page's peer chip is fed by `GET …/peers` alone ([web-frontend.md](web-frontend.md), The peer exchange).
|
|
@@ -238,7 +238,8 @@ is prefilled once. The native and the chat loop use the same plan.
|
|
|
238
238
|
- **TTL.** Anthropic keeps a breakpoint 5 minutes after its last read; a session the user comes back to later
|
|
239
239
|
writes its prompt again. `cache.ttl: 1h` sends `cache_control: {type: "ephemeral", ttl: "1h"}` on both
|
|
240
240
|
breakpoints (the log line shows `cache=1h`). Off by default: a 1h write costs 2× the input price, a 5m write
|
|
241
|
-
1.25×, a read 0.1× either way, so 1h pays off only when pauses of 5–60 minutes are common.
|
|
241
|
+
1.25×, a read 0.1× either way, so 1h pays off only when pauses of 5–60 minutes are common. The peer mail's cold hold
|
|
242
|
+
reads the same TTL (`PromptCache.ttl_seconds`, `Engine#remote_cache_ttl`: [peers.md](peers.md), The worker's mail path).
|
|
242
243
|
- **Routing.** Every chat request carries a `Session-Id` header, which OpenRouter uses to keep a conversation on
|
|
243
244
|
one provider. `cache.key: session` also sends the session id as `prompt_cache_key` in the body, the field
|
|
244
245
|
OpenAI's API routes and caches by (OpenRouter honours it too); the log line shows `cache_by=session`. Only
|
|
@@ -309,6 +310,10 @@ is prefilled once. The native and the chat loop use the same plan.
|
|
|
309
310
|
send their line with `--yes`: typing the flag, or the Set, is the choice. A plugin command asks
|
|
310
311
|
through `ctx.cache_confirm(line, changed:)` (cost `:full`: its prompt section is in the stable part), with the
|
|
311
312
|
sender's flag `SessionCommands#run` gives it (`CacheConfirm.asking`), and returns `[text, confirm]`.
|
|
313
|
+
A `served` model (`main:served`) whose host now serves another model restarts the prompt as a `/model` does
|
|
314
|
+
(`Engine#follow_served!` at the turn's start: the system prompt rebuilt), without asking: nobody chose it, and
|
|
315
|
+
the server's KV cache is the old model's anyway. Its per-turn check is one `GET /v1/models` before the prompt is
|
|
316
|
+
built; an unchanged answer changes no byte.
|
|
312
317
|
7. **No wall-clock time rendered at wire time.** A history entry's `at` (`MessageTime::KEY`, when it happened) is
|
|
313
318
|
display-only: no wire format reads it, and a guard spec checks that `ChatLoop#wire_messages` and
|
|
314
319
|
`Prompt.format_with_images` give the same bytes with and without it (`spec/message_time_history_spec.rb`). A
|
|
@@ -227,6 +227,12 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
|
|
|
227
227
|
only when its detail starts with `not found: /` (the 404 from `serve_static`, for a path no route takes). A route's
|
|
228
228
|
own 404 (no such session or source) stays a refusal. **Keep that rule:** a new route's 404 must never use the
|
|
229
229
|
`not found: /…` wording.
|
|
230
|
+
- **Answers across versions.** The corpus's `wire/remote/` (`CompatRemote`, recorded at each release) pins the shape
|
|
231
|
+
of chi web's answers to `Remote`: `spec/compat/remote_readers_spec.rb` reads the previous release's answers with
|
|
232
|
+
today's `Remote` (exact values, so `head`'s `:same` fallback or a nil `SessionView` field fails) and sends its
|
|
233
|
+
requests to today's chi web (same status, every old key path kept with its JSON type). Canned replies check
|
|
234
|
+
parsing only: a new request field an older chi web ignores still needs a feature of its own (below). Ask, last-ask
|
|
235
|
+
and MCP (`ask_routes.rb`, `last_ask.rb`, `mcp_route.rb`) have no in-repo reader and aren't recorded.
|
|
230
236
|
- **A field an older chi web would ignore.** A body field whose meaning is a restriction (`share --identity`'s
|
|
231
237
|
`identity`: an older chi web drops it and issues a link anyone could open) gets a feature of its own
|
|
232
238
|
(`bound_grants`, `App::BOUND_FEATURE`), and `Remote` requires it before sending the field (`require_feature!`):
|
|
@@ -96,7 +96,8 @@ state. A cell is `:go`, `:wait` or the decider's own refusal reason; `SessionLif
|
|
|
96
96
|
write, a `:none` row, still goes in). The other literal operations read none (archive's column is `archivable!`,
|
|
97
97
|
its checks; `archive_session` takes the lock after them).
|
|
98
98
|
- **Literal columns** (`LITERAL`): resume (`resume_session`), restart (`restart_session`: `stop_marked` in every
|
|
99
|
-
state with the stop marked: stopping, stopped, stopped_starting
|
|
99
|
+
state with the stop marked: stopping, stopped, stopped_starting; refused for an agent's restart and an update's,
|
|
100
|
+
started again for a person's, the op-local `start_stopped:` branch below), stop (`stop_session`),
|
|
100
101
|
archive (`archivable!`), delete (`release_for_delete!`, without a stop), sched_chain and sched_same
|
|
101
102
|
(`Schedules#busy_reason`; `worker_busy` is "its worker is starting or leaving", `deleting` the delivery's "the
|
|
102
103
|
session is being deleted", `worker_newer` `WorkerLink::Skew#short_message`) and attach
|
|
@@ -115,7 +116,13 @@ owner read through `session_owner`) and `ALLOWED[:restart]`: `owned_by_tui` rais
|
|
|
115
116
|
raises `RestartRefused` with it as the reason (`starting`, `not_running`, `stop_marked`, `deleting`), `fallback` goes to
|
|
116
117
|
`restart_fallback` (skew, a stuck start) and `go` asks the live worker. Its op-local checks stay where they were: the
|
|
117
118
|
SIGSTOP check (`:stopped`, the worker's pid: a different condition with its own words, before the table's refusal),
|
|
118
|
-
the worker's `restart` feature, the Bridge's reply and the fallback's holds. The
|
|
119
|
+
the worker's `restart` feature, the Bridge's reply and the fallback's holds. The `start_stopped:` branch is op-local
|
|
120
|
+
too (the table's `stop_marked` cell names the state; the caller picks the answer): a person's restart (the CLI when
|
|
121
|
+
`AgentCaller` finds no agent, the web's `POST …/restart` unless its body says `"start_stopped": false`) on a
|
|
122
|
+
`stop_marked` cell, after the SIGSTOP check, calls `resume_session` (the stop cleared, a worker spawned) and awaits
|
|
123
|
+
any live Bridge (`Restarted#was_stopped`); a stopping one first waits `wait_for_owner_release` (`STOP_WAIT`), else
|
|
124
|
+
`RestartRefused :still_stopping`. A scratch session keeps the refusal; `Web::UpdateOps#restart_one` passes none (an
|
|
125
|
+
update never undoes a stop). The matrix still drives it, so its
|
|
119
126
|
column is pinned against the precheck and the op-local paths together.
|
|
120
127
|
|
|
121
128
|
A schedule's busy check (`Schedules#busy_reason`, `schedules/busy_part.rb`) is the second: it reads `WorkerPresence`
|
|
@@ -344,7 +351,7 @@ firing counts it a skip; the web composer, a delegate follow-up, a plugin's send
|
|
|
344
351
|
| context add / remove (`Local#context_add`/`#context_remove`, chi web's URL add and detach) | shared | `ContextSources.changing`: a continue copies the session's own sources. Refused `ContextSources::Held` (423 `context_busy`). |
|
|
345
352
|
| context push, peer say, peer pair | shared | Phase 1 (`Local#moved_on`); the say's delivery seat holds again (shared beside shared). |
|
|
346
353
|
| invite (`Participants.invite`) | shared | A continue archives the link and ends its grants; refused `Grants::Invalid` with Busy's words. |
|
|
347
|
-
| revoke, peer unpair | none | Removals: a continue ends every grant at the archive, and
|
|
354
|
+
| revoke, peer unpair | none | Removals: a continue ends every grant at the archive, and an unpair of a continued id ends the live link's pairing too (`Local#peer_unpair`); refusing them would only make the owner retry. |
|
|
348
355
|
| `Local#answer` / `#dismiss`, cancel (cut), the attached TUI's `post_turn`, `Bridge#enqueue_turn` (the input fallback) | worker-side | Bridge-only: the live worker's own session (a continue's archive stops that worker and `archivable!` refuses it busy or queued). Over `--remote` the TUI's turn is chi web's turn route, `deliver_turn`'s seat. |
|
|
349
356
|
| The new link's boot (`ChildMove.adopt`, `NoteMove.adoption`, its objectives notes) | worker-side, none | Runs inside its creator's exclusive hold of the new link: a hold there would be refused until the continue ends. |
|
|
350
357
|
|
|
@@ -372,8 +379,9 @@ These are documented race boundaries, not promises of an atomic lifecycle transi
|
|
|
372
379
|
| A send between a continue's exclusive hold and its archive marker (closed). | Before: `follow_guard` held only for a followed send to an archived link, so a send (any sender) to a link a continue held but had not archived yet went in, and the archive then refused the continue as busy or queued. Now every `:shared` row's delivery takes the hold in its seat: refused naming the new link (`link_continued`), else `transition_busy`. | `spec/session_inbox/hold_spec.rb` (each sender busy under a really held lock; a send to a link not archived yet refused naming the new link); the matrix's transitioning rows. |
|
|
373
380
|
| A frozen worker's Bridge post under a send's hold. | `deliver_turn` holds the session's lock shared across the Bridge's post (up to `BridgeClient::READ_TIMEOUT` 30 s for a worker that doesn't answer); a continue of that session waits `LOCK_WAIT` per try and is refused `transition_busy`, and a stop or an archive waits its 10 s and is refused (`stop_held` / `transition_held`, "busy with another change"): stopping that frozen worker can take a second try. | No unit pin: a frozen worker's post is a timing case. |
|
|
374
381
|
| A delete or a send during a continue's recap. | `SessionContinue.continue_once` waits for the recap before it takes the transition lock: in that window a link delete and the delete preview no longer see a continue (`:continuing`): the delete may take the link's lock exclusively, and the continue's lock wait then ends busy ("being deleted"); a followed send to the link goes in. Under the lock the continue checks the link again: deleted → not found (its folder not brought back), continued by another → `Refused :continued`, a turn queued → the archive's refusal. | `session_continue_spec.rb` "the transition lock": the lock not held during the recap, a send then accepted, a link deleted or continued during the recap refused under the lock. |
|
|
382
|
+
| A stop is refused during a live continue. | `ContinueIntent#write` records the new link before archive; if the live continue names it, a stop refusal can name that successor up to a few seconds before it is saved while the archive waits up to 5 s and then spawns it. Opening the named link at once can show gone until it appears, and a failed spawn means it never appears. | `continue_intent.rb` (`in_flight`) and `session_continue.rb`. |
|
|
375
383
|
| The new link's worker boots inside the continue's hold. | `SessionContinue.spawn_continuation` spawns it while the continue holds the new link's transition lock exclusively; its boot writes (`Worker#start` → `ChildMove.adopt`, `WorkerInbound` → `NoteMove.adoption`, its objectives notes through the note row, `:none`) take no transition hold. A hold added on that path would be refused until the continue ends (drop the new link's hold before the spawn instead). A send or a peer pair to the new link from outside is `transition_busy` until the continue lets go (milliseconds after the spawn): the senders retry. | `session_continue_spec.rb`: the boot's adoption on another thread makes no `SessionTransition` call, adopts the note, and a note through `NoteDelivery` goes in. |
|
|
376
|
-
| An unpair or a revoke during a continue. | `:none` (above):
|
|
384
|
+
| An unpair or a revoke during a continue. | `:none` (above): the continue archives the old link, saves the new one, then copies the pairing in the new link's `before_spawn` (`PeerMailbox.carry_links`, reading `link.json` at that moment, so an unpair before it wins). An unpair that lands between the copy's read of the old `link.json` and its write of the new one removes the old link's only; the copy keeps the peer paired with the new link (unpair again). | No pin (declared). |
|
|
377
385
|
| Sends to a session a delete holds (open, by design). | `SessionChain::Delete` holds the transition locks from before its stop to the end: a send, a push, a peer say or a context change to the link, its previous link or a delegate that goes is refused `transition_busy` "being deleted" for the stop (up to the delete's wait, 10 s from the CLI), the task stop (about 4 s a link) and the removal; a chain delete holds every link's for the whole chain (N links × stop + tasks: minutes for a long chain with `--stop-tasks`). chi send and an ask retry within their wait; the web composer, a delegate, a plugin and a participant report it. Before, those sends went in and the delete stopped or removed them. | `session_chain/delete_spec.rb` "under the transition locks" (a send during the stop refused as being deleted, both locks the delete's). |
|
|
378
386
|
| A delete meets a send's or another change's hold (closed). | Before: `Delete.link`, `hold_all` took `SH\|NB`, so a continue was refused but another delete, a prune or the retention sweep could run beside it, and a send held nothing off. Now a user's delete waits up to `LOCK_WAIT` for the locks exclusively, then refuses (`continuing` / `transition_held`, the holder named); the prune, the sweep and a leaving worker's delete try once and keep the session. | `session_chain/delete_spec.rb` (a short shared hold waited out, a long one refused, a held delegate refuses), `session_retention_spec.rb`, `session_discardable_spec.rb` (held → kept). |
|
|
379
387
|
| A prune at a link it can't delete (closed: visible, never skipped). | Before: a link another enabled schedule protects (its anchor inside the chain, a stale head) was refused `prune_stopped` at every firing, after the link's delegates were already deleted, and the chain grew silently. Now the hold is checked before anything in the subtree goes and the prune stops there with a record (`prune_waiting`, list/show) and one log line; a held transition lock on the link or the next does the same, and every tick retries. Still open: the chain grows behind such a link until the other schedule is cancelled (re-linking the chain around it is held, D6). | `schedules_spec.rb` "a prune held at a link" (held link: kept with every later link, resumed next tick; next link held; the mid-chain schedule: one log, list/show lines, nothing deleted around it, gone after cancel). |
|