samagotchi 0.188.0 → 0.189.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -1
  3. data/docs/architecture.md +5 -3
  4. data/docs/bundle-authoring.md +1 -1
  5. data/docs/bundles.md +15 -0
  6. data/docs/cli.md +23 -5
  7. data/docs/guardrails.md +3 -2
  8. data/docs/internals/bundles.md +3 -3
  9. data/docs/internals/pages.md +65 -18
  10. data/docs/internals/session-lifecycle.md +19 -6
  11. data/docs/internals/web-frontend.md +3 -3
  12. data/docs/internals/web-push.md +11 -5
  13. data/docs/pages.md +68 -15
  14. data/docs/peers.md +3 -0
  15. data/docs/plugins.md +25 -1
  16. data/docs/releasing.md +1 -1
  17. data/docs/scheduling.md +71 -8
  18. data/docs/sessions.md +4 -4
  19. data/docs/testing.md +1 -1
  20. data/lib/samagotchi/bundle_manifest.rb +34 -5
  21. data/lib/samagotchi/bundles/schedules/manifest.yml +11 -0
  22. data/lib/samagotchi/bundles/schedules/scripts/schedules.rb +159 -0
  23. data/lib/samagotchi/bundles/system/manifest.yml +3 -3
  24. data/lib/samagotchi/bundles/system/self_map.md +2 -2
  25. data/lib/samagotchi/bundles/system/skill_pages.md +9 -4
  26. data/lib/samagotchi/installed_bundles/manifest.rb +8 -1
  27. data/lib/samagotchi/memory_bundle/asset_installer.rb +3 -2
  28. data/lib/samagotchi/memory_bundle/builder.rb +1 -0
  29. data/lib/samagotchi/memory_bundle/installed_copy.rb +1 -1
  30. data/lib/samagotchi/page_command.rb +9 -6
  31. data/lib/samagotchi/pages/bundled.rb +83 -0
  32. data/lib/samagotchi/pages/launch.rb +14 -2
  33. data/lib/samagotchi/pages/runner.rb +7 -2
  34. data/lib/samagotchi/pages/runtime.rb +83 -0
  35. data/lib/samagotchi/pages/store.rb +18 -5
  36. data/lib/samagotchi/pages.rb +47 -3
  37. data/lib/samagotchi/peer_continue.rb +14 -8
  38. data/lib/samagotchi/run_options.rb +1 -1
  39. data/lib/samagotchi/schedule_command.rb +79 -37
  40. data/lib/samagotchi/schedule_display.rb +69 -0
  41. data/lib/samagotchi/schedules/busy_part.rb +146 -0
  42. data/lib/samagotchi/schedules/edit_part.rb +120 -0
  43. data/lib/samagotchi/schedules/history_part.rb +51 -0
  44. data/lib/samagotchi/schedules/listing_part.rb +52 -0
  45. data/lib/samagotchi/schedules/notices_part.rb +116 -0
  46. data/lib/samagotchi/schedules/protection_part.rb +103 -0
  47. data/lib/samagotchi/schedules/recurrence.rb +103 -0
  48. data/lib/samagotchi/schedules.rb +134 -330
  49. data/lib/samagotchi/session_access/local.rb +9 -1
  50. data/lib/samagotchi/session_access/remote.rb +2 -1
  51. data/lib/samagotchi/session_chain/delete.rb +7 -5
  52. data/lib/samagotchi/session_lifecycle/allowed.rb +2 -1
  53. data/lib/samagotchi/session_lifecycle.rb +3 -2
  54. data/lib/samagotchi/session_manager/removal.rb +16 -9
  55. data/lib/samagotchi/session_protection.rb +99 -0
  56. data/lib/samagotchi/session_retention.rb +21 -6
  57. data/lib/samagotchi/sessions_command.rb +4 -0
  58. data/lib/samagotchi/testing/boundary.rb +13 -0
  59. data/lib/samagotchi/tools/cancel_schedule.rb +5 -2
  60. data/lib/samagotchi/turn_outcome.rb +41 -0
  61. data/lib/samagotchi/version.rb +1 -1
  62. data/lib/samagotchi/web/page_routes.rb +13 -8
  63. data/lib/samagotchi/web/public/app.js +12 -18
  64. data/lib/samagotchi/web/public/index.html +11 -2
  65. data/lib/samagotchi/web/public/owner_claim.js +7 -5
  66. data/lib/samagotchi/web/public/page_links.js +1 -1
  67. data/lib/samagotchi/web/public/page_view.js +8 -5
  68. data/lib/samagotchi/web/public/pages.css +9 -2
  69. data/lib/samagotchi/web/public/pages_group.js +21 -19
  70. data/lib/samagotchi/web/public/pages_list.js +73 -0
  71. data/lib/samagotchi/web/public/pages_model.js +54 -0
  72. data/lib/samagotchi/web/public/pages_wiring.js +66 -0
  73. data/lib/samagotchi/web/public/views.js +77 -23
  74. data/lib/samagotchi/web/push/notifier.rb +4 -3
  75. data/lib/samagotchi/web/server.rb +3 -1
  76. data/lib/samagotchi/web/session_hub.rb +64 -19
  77. metadata +17 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b9e5ec4891e42a2a7c38c7f3adb595d8738e2a7cabc471bcf6b440298d98164
4
- data.tar.gz: e5a2a8d96a359921935b05fb9952e892c8611b14837193b79750f3a88bdcd880
3
+ metadata.gz: c8e7fa5a6ecf59f94f137ab4b95a76d129a6e2edab94204aab625747a7ffc3d4
4
+ data.tar.gz: 61480eb9e2af49ec87cd51eafaf1a4bd4b3fe0202ff464c126fb971203bd68bf
5
5
  SHA512:
6
- metadata.gz: d4af9fec473330c198f0aa57991eb7447cedf18a37cc3bb45b66980490f527bcf1bcac96bf329e38996540b5e8315ac9ab40262580523a607a964e747a1b7895
7
- data.tar.gz: 58a8c06f5d6e8093c07c5f53c5268d3566bb8a3c4afa06fd2868ef06670be4e3da07cc8489981347a891f64589e20375a0b9c0fc58161c3374e025a3abcc3243
6
+ metadata.gz: ddd533fc0c541fe9be37a437180bfbdaa62322b9de85b028da971dc2d7a69b6440cf8548110705eb9d91ce9d176544e348fb5d559fe538343eb907c3f7dbd47f
7
+ data.tar.gz: df7ea7ed667b4e5784fc0def947532666374ccf1f8d502a5eaf7d3975f76d4bda79f6b6a4f7b9267436b8dea6096cb44335062bdba285def2623f675f82acb79
data/CHANGELOG.md CHANGED
@@ -8,6 +8,46 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.189.0] - 2026-11-25
12
+
13
+ ### Added
14
+
15
+ - `chi schedule show ID` lists the schedule's last 20 outcomes, newest first (fired, skipped, failed, missed, your
16
+ enable and disable), each with its reason and session; `list --format json` has them as `history`.
17
+ - `chi schedule edit ID` changes a schedule in place: its title, prompt, recurrence, catch-up or budgets (only the
18
+ flags given), keeping its id, session, mode and counters ([docs/cli.md](docs/cli.md#durable-schedules-chi-schedule)).
19
+ - The schedules bundle (`chi bundle install schedules`): a Schedules page in chi web (`#/p/schedules`): every
20
+ schedule, why one is off and the `chi schedule enable ID` that turns it on, and the recent runs; read-only
21
+ ([docs/scheduling.md](docs/scheduling.md#the-schedules-page)).
22
+ - Page scripts get `runtime.schedules`: the schedules read in chi itself, no `chi` command
23
+ ([docs/pages.md](docs/pages.md#reading-chis-data-runtime)). A bundle can ship pages (the manifest's `pages:`); your
24
+ own `NAME.rb` replaces a bundle's page, and `chi page rm` refuses one ([docs/pages.md](docs/pages.md#pages-from-a-bundle)).
25
+ - `chi schedule list --format json` gives each schedule's `name`, `state` (on, firing, off) and `off_reason`.
26
+
27
+ ### Changed
28
+
29
+ - A schedule turned off by its skip or failure budget notifies the phone whatever ran the tick: a cron
30
+ `chi schedule tick` or a `run-now` too, not only chi web's own tick (chi web pushes it, with `schedule.auto_tick`
31
+ off as well).
32
+ - chi web: pages have their own `pages` pill in the top bar (when there is at least one page, in every view, on a
33
+ desktop and a phone); it opens the Pages list, and appears without a reload when chi makes the first page. All
34
+ sessions no longer shows a Pages group ([docs/pages.md](docs/pages.md#in-chi-web)).
35
+
36
+ ### Fixed
37
+
38
+ - `chi schedule cancel|enable|disable` (and the `cancel_schedule` tool) say "no schedule" instead of ok when another
39
+ cancel removed the schedule in between.
40
+ - Pairing claude-peer or codex-peer again removes that peer's old inbox/outbox context sources (their chips).
41
+ - A `schedules.json` that can't be read (not JSON, not a schedules document, a file chi can't open, or a schedule in
42
+ it that doesn't read) no longer leaves its sessions unprotected: the retention sweep deletes nothing that round (it
43
+ tries again at the next sweep interval) and a delete (`chi sessions delete`, `prune`, the web's, `--remote`) is
44
+ refused with "schedules.json is unreadable (…): fix or remove it before deleting sessions". For one schedule that
45
+ doesn't read, the refusal names it and `chi schedule cancel <id>` removes it. A missing file is still no schedules.
46
+ - chi web: when a claim is shown while the Pages list or a page is open, the address bar no longer jumps to the
47
+ session's hash: Back or a Reload now returns you to the page instead of to the session.
48
+
49
+ Update with `chi update` (the new schedules bundle: `chi bundle install schedules`).
50
+
11
51
  ## [0.188.0] - 2026-11-24
12
52
 
13
53
  ### Added
@@ -6878,7 +6918,8 @@ and long-lived sessions.
6878
6918
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
6879
6919
  hotkey panel that send selected text or the clipboard to your sessions.
6880
6920
 
6881
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.188.0...HEAD
6921
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.189.0...HEAD
6922
+ [0.189.0]: https://github.com/dm1try/samagotchi/compare/v0.188.0...v0.189.0
6882
6923
  [0.188.0]: https://github.com/dm1try/samagotchi/compare/v0.187.0...v0.188.0
6883
6924
  [0.187.0]: https://github.com/dm1try/samagotchi/compare/v0.186.0...v0.187.0
6884
6925
  [0.186.0]: https://github.com/dm1try/samagotchi/compare/v0.185.0...v0.186.0
data/docs/architecture.md CHANGED
@@ -229,8 +229,8 @@ catalogue, never to the class.
229
229
  - **Single owner:** the process running a session's Engine (its worker, or a `--non-interactive` one-shot) holds a flock on `owner.lock` (`OwnerLock`); a second owner backs off, and the web answers 409 for a session a one-shot owns. That owner is also the one writer of the session's `turn_drawings.jsonl` (a worker's Bridge, a one-shot's own accumulator); a fork's copy of its parent's lines is written before the child's worker spawns.
230
230
  - **Status:** `status` is turn state (`idle`/`running`); liveness is the lock. A stop is the `<uuid>/stopped` marker (`Session.mark_stopped`; a resume removes it), which `Session.load` and `.summary_from_file` read as status `stopped`, so no other process rewrites a worker's session file. A resume writes nothing else: the worker, holding the lock, turns a status from before it idle (`Worker#settle_stale_status`: `stopped` with no marker, `error`, a `running` no turn is behind; not a new session's `running` whose first prompt waits), and saves at start whatever the status, which stamps `updated_at` as the resume's save did (a session woken with no turn stays young for the sweep). N-1: a newer spawner starting an older worker (a checkout's chi spawning the installed one) loses that reset; a restart covers it.
231
231
  - **Starting:** every spawn marks the session starting (`<uuid>/starting`, `{pid, at}`, `StartingMarker`) until its worker holds the lock: `spawn_worker_for_session` writes it with its own pid before `Process.spawn` and the starter's after (the starter lives until the worker holds the lock, at most `WORKER_START_GRACE`; a spawn that raises or whose starter is gone leaves none), `spawn_session` before the new file is saved, and `Worker#start` removes it. It holds for 60 s at most, and only while the pid it names runs. A resume claims it (`StartingMarker.claim`, a link(2): of resumes racing from any processes one wins), then reads the owner again. A stop marker cancels the hold-off (`start_pending?` = starting and not stop-marked) for a start marked before the stop only: of two sends after a stop, the claim lets one spawn. The stop marker carries its own `at` (`{"at"}`, on the starting marker's clock; `Session.stopped_at`), an older chi's empty one its mtime. The sweep, archive (`:starting`) and delete (refused as an owned session) honour it. N-1: an older spawner writes none for a resume (the owner checks stay); an older worker never leaves one it was given (every worker clears it at start); a leftover one is stale by age or pid (a claim's temp files a kill left, `starting.*`, count as skeleton); a 0.160 spawner or chi web still holds off on a fresh marker under a stop (it reads `starting?` before the stop), until the start ends or 60 s. `SessionManager` keeps only its starters' pids, for chi web's restart to adopt (`live_spawn_pids`), and decides nothing from them.
232
- - **Deleting:** `delete_session`, the retention sweep and a failed continue's cleanup use `remove_files` for the session JSON, sidecar dir, plugin state, attached context, participant grants, System 1 runs and context-candidate records. `SessionStores` registers the sidecar filenames and the removal categories; `remove_session_files` deletes the whole sidecar directory, so those files need no individual removal path. The JSON and dir go through `remove_session_files`, holding the owner lock (kind `deleting`, which `stop_session` never signals; not waited for: a worker that took it since the check keeps the session) and reading the starting marker again under it (a resume that claimed the start just before keeps the session; one after it sees the lock held). N-1: an older chi's stop reading the owner then would TERM the deleter (chi web, the CLI) in that moment; an older reader shows the kind as unknown. `Session#save` of a session read from its file (or saved once) skips a file that is gone (log `save_skipped_deleted`) rather than recreate it; only a new session's first save creates one.
233
- - **Worker presence:** whether a worker is up, coming or held off is read once per decision as a `WorkerPresence` (`worker_presence.rb`, a `Data.define`), the deciders' one reader of those facts (display and list rows still read `session_owner` / `WorkerLink` themselves): the owner lock's holder, the stop marker (`stop_marked?`: the only "stopped" a decider reads, never the session file's status), the `starting` marker (`StartingMarker`, `starting?`, `start_pending?`: every spawn writes it, see Starting), the archive marker, the session file's existence, and the `WorkerLink` outcome when asked (never the file itself: a scratch session's flag is read by `WakePolicy`, last). The deciders read it: `resume_session` (tui, owned, `resume_held_off?`), the session inbox's `WakePolicy` (a ring, a push's wake, a note, a fresh verdict, `wake_for_report`, `deliver_turn`'s two liveness checks, `WorkerBoot`'s leave: below), `Local#wake`/`#worker`, `AttachLauncher`, `Schedules#busy_reason`, archive, delete and the retention sweep. Each keeps its own subset of the facts and their order.
232
+ - **Deleting:** `delete_session`, the retention sweep and a failed continue's cleanup use `remove_files` for the session JSON, sidecar dir, plugin state, attached context, participant grants, System 1 runs and context-candidate records. `SessionStores` registers the sidecar filenames and the removal categories (what a delete removes), `SessionProtection` its protectors (what refuses one: an enabled schedule's anchor, head and target; fail-closed); `remove_session_files` deletes the whole sidecar directory, so those files need no individual removal path. The JSON and dir go through `remove_session_files`, holding the owner lock (kind `deleting`, which `stop_session` never signals; not waited for: a worker that took it since the check keeps the session) and reading the starting marker again under it (a resume that claimed the start just before keeps the session; one after it sees the lock held). N-1: an older chi's stop reading the owner then would TERM the deleter (chi web, the CLI) in that moment; an older reader shows the kind as unknown. `Session#save` of a session read from its file (or saved once) skips a file that is gone (log `save_skipped_deleted`) rather than recreate it; only a new session's first save creates one.
233
+ - **Worker presence:** whether a worker is up, coming or held off is read once per decision as a `WorkerPresence` (`worker_presence.rb`, a `Data.define`), the deciders' one reader of those facts (display and list rows still read `session_owner` / `WorkerLink` themselves): the owner lock's holder, the stop marker (`stop_marked?`: the only "stopped" a decider reads, never the session file's status), the `starting` marker (`StartingMarker`, `starting?`, `start_pending?`: every spawn writes it, see Starting), the archive marker, the session file's existence, and the `WorkerLink` outcome when asked (never the file itself: a scratch session's flag is read by `WakePolicy`, last). The deciders read it: `resume_session` (tui, owned, `resume_held_off?`), the session inbox's `WakePolicy` (a ring, a push's wake, a note, a fresh verdict, `wake_for_report`, `deliver_turn`'s two liveness checks, `WorkerBoot`'s leave: below), `Local#wake`/`#worker`, `AttachLauncher`, `Schedules#busy_reason` (its state's answer through `SessionLifecycle`: `Reading.derive` and `ALLOWED`), archive, delete and the retention sweep. Each keeps its own subset of the facts and their order.
234
234
  - **Session inbox:** a delivery into a session (`SessionInbox.deliver(kind, id) { |at| write }`, `session_inbox_delivery.rb`) runs one path: resolve the link (`SessionInbox::Head.resolve`: push and a fresh verdict are pinned to the id named; a send and a note go to the chain's newest link, and for a send (a kind that starts an archived link) a continue of the reached link in flight (`ContinueIntent.in_flight`: `continue.json` written, `continue.lock` held, the successor not saved yet) gives `:continuing` with the successor's id, which chi send asks again for a moment and then refuses; a note needs no such check (`NoteMove` moves or adopts it); a ring's file stays with the parent `parent.json` names and its wake goes one hop, to the link whose `ChildReports` reads that file; only an archived id is walked, with one `Session.list`: `SessionChain::Links#first_live`), refuse before any write (a gone session; a one-turn run's or a scratch session for send and a note), write with the kind's own writer (formats unchanged), read `WorkerPresence` once, and apply the kind's `WakePolicy` row. `decide` reads in one order for every kind: gone, one-turn run (`:owned`), owned (`:live`), the stop marker (`:stopped`: the only "stopped", the file's status never decides; send un-stops), archived (send alone starts one), starting (`:starting`, never a second spawn), the kind never starts (`:none`: a note, a fresh verdict) or wasn't asked to (`:off`), scratch (the session file is read only here), else `:start` through `SessionManager.start_for_inbox` (`resume_session`, its claim on the starting marker; it answers `:woken` only when it spawned the worker, `:starting` when another start won the claim, `:live` when a worker took the lock since). N-1 gap: a session file that says `stopped` with no stop marker (stopped before the marker existed, or a resume whose spawn failed after it cleared the marker) is woken, and an older worker, which has no `Worker#settle_stale_status`, exits on its first pass; the wake still reads `:woken`, and each later ring or push spawns another such worker (bounded by the rings and pushes). Restarting chi on the new version (`chi web`, the workers) closes it. `SessionInbox.wake` is the wake half alone (`wake_for_report`, a failed continue's rings). On it: `ChildRing.ring` (its start on a thread), `Local#context_push`'s wake (its outcome is `ContextPush#wake`, the push line's ending), `NoteDelivery.deliver` (every note writer a person or another session drives: `chi note`, `send_note`, `chi broadcast`, chi web's notes route; `NoteDelivery::Result#id` is the link that has it, `#asked` the one named; `/objectives` passes `pin: true`: its list is its own session's) and `VerifyFresh.forward` (`:fresh_verdict`: the child's parent, pinned, no worker). Send keeps its Bridge/file flow in `SessionManager.deliver_turn`, which resolves nothing (it acts on the id it is given: an archived link gets the message and comes back); chi send resolves the head first (`SessionAccess#head`, remotely `GET /api/sessions/resolve?head=1`), while the web composer, a participant's turn, `delegate` follow-ups, `Plugin::Sessions` and `Schedules` stay on the id they name; its two liveness checks (before the post, after a file's write) read the sender's row (`WakePolicy.for_sender(client_id)`, `ClientId.wake_kind`: a person's — chi send, a web tab, a TUI — is `:send`; a schedule, a plugin, a delegate follow-up and a participant have rows of their own, any other id `:automatic`, which start an idle session but neither un-stop nor start an archived link: refused before the write, `DeliverResult::STOPPED` / `ARCHIVED`) and leave the other refusals to `resume_session`'s wording. One row is not a delivery: `:leave`, `WorkerBoot.run_session_loop`'s successor as a worker leaves (input left after a signal, an idle exit's or `/exit`'s input or rings, a restart), read on a fresh presence once the lock is free: a stop that landed as it left starts none for any way out (`resume_session` would clear the stop; logged `respawn_dropped`, `restart_dropped` for a restart, whose reminders go with it), the input and rings stay for the next start. The notes a spawn writes into the session it starts stay direct `SessionInbox.write_note` calls, pinned by construction: spawn_session's chain note, `ContextMove`'s notes, `Objectives.carry`, `ChildMove`'s note to a moved child. A continue moves the previous link's waiting notes to the new link last in its `before_spawn` (`NoteMove.move`), a failed one gives them back before the link goes (`NoteMove.give_back`), and the new link's worker adopts what the archived links before it get after their continue (`NoteMove.adoption`, from `WorkerInbound#absorb_notes` and `Worker#start`: back along the chain through up to 8 archived links, from each only notes from the creation of the link that continued it, never an objectives list). `write_note` refuses a session with no file and no folder (`Session::NotFound`), so a late writer can't bring back a deleted link's folder.
235
235
  - **Retention:** 14 days / 500 cap (env `SAMAGOTCHI_SESSION_RETENTION_DAYS`/`MAX_COUNT`, optional `KEEP_STATUS`), live-owner and starting guard (looked at again right before a session's files go), only when `*.json` present; lazy sweep at most once per `session.sweep_interval_hours` (default 24) from the session hub's full-probe tick (and on `GET /api/sessions`, which the page no longer calls), manual via `bin/chi sessions prune --dry-run`.
236
236
  - **Ordering:** `Session.list(sort:,order:,limit:,offset:)` and `GET /api/sessions?sort=&order=&limit=&offset=` default `updated_at desc`; Web UI sort/filter/pagination.
@@ -371,7 +371,9 @@ proxies the stream and relays the writes. The routes, wire shapes, replay rules,
371
371
  never pulls from the page: `chi web` runs one `Samagotchi::Web::SessionHub` (a thread inside
372
372
  the server, no daemon) that keeps an in-memory projection of the session list and pushes
373
373
  changes to every open tab over `GET /api/events` (SSE: a `snapshot` frame on every connect,
374
- then `session` for an upsert and `session_gone` for a removal, `: ping` while idle, no replay).
374
+ then `session` for an upsert and `session_gone` for a removal, `: ping` while idle, no replay;
375
+ and `pages`, no data, when the pages' scripts folder changed: one `File.stat` of `Pages.scripts_dir` a tick, which
376
+ Server.start passes as `pages_dir:`, never on the first look; the page reads `GET /api/pages` again on it).
375
377
  The snapshot names chi's version: a tab served by another one (its `<body data-version>`) offers a
376
378
  reload in a toast, since an open tab keeps its old JS across a `chi web` upgrade. It also names
377
379
  `installed`, the newest chi on this machine (`InstalledVersions`: the highest `samagotchi-<v>.gemspec`
@@ -58,7 +58,7 @@ plugin:
58
58
  `bundles: my-bundle:` as a Hash with string keys, once, when the plugin loads. A value a session may set
59
59
  (`chi --set my-bundle.KEY=V`, listed in the manifest's `session_settings:`, typed with `{KEY: number}` so a
60
60
  value of another type is refused) is read from `ctx.settings` at call time. List what config.yml may set in `settings:`
61
- (`[greeting]`, or `{greeting: string}`): a typo there then warns. `chi bundle check --set KEY=VALUE` gives the sandboxed load a setting. A bundle can also draw a fenced block in chi web's answers, with no plugin code: `block_renderers:` and a script calling `chi.defineRenderer` ([plugins.md](plugins.md#block-renderers)). A plugin that outgrows one file lists its other top-level `.rb` files under `plugin: parts:` (`client.rb: sha256:`, at most 16; `check --fix` fills the shas, and warns of a top-level `.rb` they don't list): chi loads them in that order, then `plugin.rb`, into one namespace, so a part reopens `class Plugin` and a class body uses only what an earlier part defines; never `require_relative` one ([plugins.md](plugins.md#a-plugin-in-several-files)).
61
+ (`[greeting]`, or `{greeting: string}`): a typo there then warns. `chi bundle check --set KEY=VALUE` gives the sandboxed load a setting. A bundle can also draw a fenced block in chi web's answers, with no plugin code: `block_renderers:` and a script calling `chi.defineRenderer` ([plugins.md](plugins.md#block-renderers)); and ship a page: `pages:` naming a page script in `scripts:` ([plugins.md](plugins.md#pages)). A plugin that outgrows one file lists its other top-level `.rb` files under `plugin: parts:` (`client.rb: sha256:`, at most 16; `check --fix` fills the shas, and warns of a top-level `.rb` they don't list): chi loads them in that order, then `plugin.rb`, into one namespace, so a part reopens `class Plugin` and a class body uses only what an earlier part defines; never `require_relative` one ([plugins.md](plugins.md#a-plugin-in-several-files)).
62
62
 
63
63
  ## What a hook sees
64
64
 
data/docs/bundles.md CHANGED
@@ -411,6 +411,21 @@ The port is bound to loopback, not the LAN. Under colima, run it from a folder i
411
411
  shares only that with its VM by default, and elsewhere SearXNG starts on its own default settings (JSON off).
412
412
  `curl 'http://127.0.0.1:8888/search?q=ruby&format=json'` should answer JSON.
413
413
 
414
+ ## The schedules bundle
415
+
416
+ `chi bundle install schedules` installs a **Schedules** page (`lib/samagotchi/bundles/schedules/scripts/schedules.rb`):
417
+ in chi web it is under the `pages` pill (`#/p/schedules`), and `chi page run schedules` runs it from a terminal. No
418
+ profile includes it, so `chi update` lists it as not installed until you install it. What it shows is in
419
+ [scheduling.md](scheduling.md#the-schedules-page). It has no plugin, tools or settings: the manifest's `pages:` names
420
+ its one script ([plugins.md](plugins.md#pages)), and the script reads the schedules with `runtime.schedules`
421
+ ([pages.md](pages.md#reading-chis-data-runtime)).
422
+
423
+ - **Read-only.** It changes nothing; for each schedule that is off it prints the `chi schedule enable ID` that turns it
424
+ on (a spent one-off gets a new moment first: `chi schedule edit ID --date …`).
425
+ - **Your own version.** Copy the script (`chi page list --format json` gives its path as `script`) to
426
+ `~/.config/samagotchi/pages/schedules.rb` and change it: yours runs instead. Remove your copy to get the bundle's back.
427
+ - **Removing it.** `chi page rm schedules` refuses (the page comes with the bundle); uninstall the bundle instead.
428
+
414
429
  ## The loop-guard bundle
415
430
 
416
431
  `chi bundle install loop-guard` installs the bundle shipped with chi (`chi
data/docs/cli.md CHANGED
@@ -26,7 +26,7 @@
26
26
  - `chi context report [--days N]` — the candidate judge's counts from `context_candidates.jsonl`: candidates proposed, mentioned, attached or declined by you; the judge's asks; what it would attach per threshold, and how that agrees with what you did (this machine only; see [The log and the report](context.md#the-log-and-the-report))
27
27
  - `chi send [-m TEXT] [--image PATH]... [--cut | --queue] [--as NAME] (ID|PREFIX)...` — send a message to sessions as if typed there (from an agent, as that agent: `--as NAME` or its marker, see [An agent's messages](sub-agent.md#an-agents-messages-driver-and-visitor); `--new --driver NAME` names a new session's driver): a turn starts (or a running one takes it at its next step; `--cut` asks it to cut long thinking for it; `--queue` runs it as a turn of its own after the running one, and `--queue --wait` waits for that turn's own answer); piped stdin goes above `-m` as quoted context, and `--image` attaches images (see [Sessions: Sending a message](sessions.md#sending-a-message)); to a session that was continued it goes to its chain's newest link (`3f9a1c2e → 7b2d41aa (continued) sent`; the old link stays archived; one being continued right now waits up to 10 s for its new link, then `refused: being continued as 7b2d41aa; send again in a moment`), so a chain's first id is a stable address; `--new` starts a session with it instead (`--new --continues ID|last:ID` the next link of that session's chain, see [Session chains](sessions.md#session-chains)), and `--wait` prints the answer (`--wait ID` with no message waits for the next reply without sending — to an idle session whose last turn already ended, that ended turn's reply or end comes back; `--wait --turn T ID` with no message waits for exactly turn T, whether running, queued or last ended; `--format json` includes its `turn_id` when known, for waiting again after exit 3 or 4; exit 3 a question waits, its options on stderr; exit 4 `--timeout` passed with the turn still running; see [Starting a session](sessions.md#starting-a-session))
28
28
  - `chi answer ID --question QID (--option N|LABEL)... [--text T] [--timeout S] [--format json]` (or `--dismiss`) — answer the question a session waits on (the one `chi send --wait` exited 3 with), then wait and print what comes next as `chi send --wait` does: the reply (0), the next question (3), still running after `--timeout` (4). `--option` is 1-based or the label, repeated on a multi-select question; `--text` is free text, or a Deny's reason; `--dismiss` leaves it unanswered and the model finishes its reply. A question no longer open (the web answered first) isn't answered again: it waits for that turn's reply. An option the question doesn't offer exits 2; a worker that is gone exits 1 (`send the task again: chi send --wait -m "…" ID`). What a parent may pick follows `guardrails.parent_answers`, or the session's own `parent_answers` when stricter (`soft`, the default: a deny, a plain answer, Continue and "Allow once"; `standard`: no allow; `hard`: no Continue either), never a wider scope or an allow on chi's own config; a refused pick exits 1 with what to answer instead (a convention, not a security boundary; see [Guardrails](guardrails.md#answers-from-a-parent-agent))
29
- - `chi schedule <add|list|show|tick|run-now|enable|disable|cancel>` — durable schedules on this machine: a prompt with a clock that fires out of no worker (cron, systemd, or chi web's hub with `schedule.auto_tick`), as the next link of a session's chain or as a turn in the session itself (see [Scheduling](scheduling.md) and [Durable schedules](#durable-schedules-chi-schedule)). A usage error exits 2, an unknown session or schedule 1; `chi --remote X schedule list` exits 2
29
+ - `chi schedule <add|edit|list|show|tick|run-now|enable|disable|cancel>` — durable schedules on this machine: a prompt with a clock that fires out of no worker (cron, systemd, or chi web's hub with `schedule.auto_tick`), as the next link of a session's chain or as a turn in the session itself (see [Scheduling](scheduling.md) and [Durable schedules](#durable-schedules-chi-schedule)). A usage error exits 2, an unknown session or schedule 1; `chi --remote X schedule list` exits 2
30
30
  - `chi remote add NAME URL [--token-file F | --token-stdin]`, `chi remote ls`, `chi remote rm NAME` — the other machines whose chi web the session commands reach with `--remote NAME` (see [Remote sessions](#remote-sessions))
31
31
  - `chi share ID --name NAME [--identity EMAIL] [--expires 3d] [--cap 2]`, `chi share ls [ID]`, `chi share cap ID P DOLLARS`, `chi share revoke ID [P] | --all` — invite a participant into a session through chi web on the LAN, whose turns act under your guardrails (a link of their own, 7 days, a $2 spending cap), list them, change one's cap, revoke them (see [Participants](#participants))
32
32
  - `chi mcp serve` — chi as an MCP server on stdio: an MCP host (Claude Code, Codex) drives the sessions with four tools (`chi_sessions`, `chi_ask`, `chi_wait`, `chi_answer`); `claude mcp add chi -- chi mcp serve`. chi web serves the same at `POST /api/mcp` (see [chi as an MCP server](mcp-server.md))
@@ -41,7 +41,7 @@
41
41
  - `chi project`, `chi project init [--new-id | --merge-subfolders] [DIR]` — this folder's project, and making a folder in no git repository one. `chi project` prints how its project was found (`kind` `git`, `marker` or `none`), its `root`, its `top` (where the AGENTS.md chain starts), a marked project's `id` (what its memories and project context are keyed on; else the root's path is) and its project `memories` folder, with a `note` for a marker a repository makes ignored, or a `$HOME` that is a git repository. `init` writes `DIR/.chi/project.yml` with a new `id:` (DIR defaults to this folder and is created when missing), so DIR and every subfolder share one memories folder (kept when DIR moves or is renamed), group their sessions and take `chi context --project`; it writes nothing in a git repository (the repository already is the project, exit 0), says so (with the id) for a folder already marked, refuses `$HOME`, a folder above it and `/` (exit 1), and marks a folder inside another marked project as its own, nested one. On a folder marked without an id (an older chi's marker) it adopts one: the folders keyed by its path move to the id, each leaving a link by its old name, and it says what moved and names memories an earlier path left (refused, exit 1, while a session of the project runs). `--new-id` gives a marked folder a fresh id with a copy of its memories and project context (a copied folder going its own way; refused elsewhere, exit 1). Memories a session on this machine saved in a subfolder before init (keyed by that subfolder's path) are named by `init` and by `chi project` (a `note`); `--merge-subfolders` moves them into the project's memories folder (marking DIR first when it isn't yet): a memory the project has by that name, or a bundle's, stays and is named, an emptied folder is removed; refused, exit 1, while a session in DIR runs; not with `--new-id` (exit 2). It prints the root, the id and the memories folder (with the memories already there: a folder chi ran in at its top keeps them, moved to the id), the running sessions in DIR to restart (`chi sessions restart ID`: their prompt keeps the old project) and, when DIR has saved sessions, that a running chi web groups them after its restart. This machine only. See [Projects without git](memory.md#projects-without-git)
42
42
  - `chi bundle install|upgrade|uninstall|status|diff|list|build|trash|new|test|check` — manage memory bundles (see [Plugins](plugins.md) and [Bundle hooks](hooks.md#bundle-hooks)); `list` shows the installed ones and the ones shipped with chi, which `install <name>` installs; `upgrade <name>` upgrades an installed bundle by name from the source it came from (its folder, archive or git URL), `upgrade <source>` from a new one; `core` and `dev` are profiles that install a set of them (see [Bundle profiles](memory.md#bundle-profiles-core-and-dev), [Guardrails](guardrails.md), [Bundles](bundles.md#the-btw-bundle), [the mcp bundle](bundles.md#the-mcp-bundle) [the loop-guard bundle](bundles.md#the-loop-guard-bundle), [the check-in bundle](bundles.md#the-check-in-bundle) and [the skills bundle](bundles.md#the-skills-bundle)). `trash` lists and empties the bundle trash (moved files from uninstalls/upgrades). `install`/`upgrade` `--force` overwrites existing entries and also installs a bundle whose `requires_chi` this chi doesn't meet and a memory, plugin or script whose bytes disagree with its manifest `sha256`; without it such a bundle or file is refused (exit 1), nothing written. `install` and `upgrade` (`--dry-run` too) start with the bundle and its version: `NAME OLD → NEW` when it changes, `NAME VERSION` when it doesn't (or for a new install), and `NAME VERSION (already current)` when the run writes nothing, in place of the `Up to date: …` line. A plain `install` of a bundle that is already installed from the same source rewrites its rules, plugin, scripts and record: the summary lists a file that already holds the bundle's bytes as `Up to date: …`, one you wrote as `Skipped: …`, and ends with `NAME was already installed from SOURCE: its rules, plugin and scripts now match it and its record was rewritten` (plus, when a memory was kept, `your own copies of its memories were kept (chi bundle upgrade NAME merges the bundle's changes into them)`). A source with class-file hooks (`hooks/*.rb` or a manifest `hooks:` entry) is refused, `--dry-run` too; an older install's hooks are removed by the next install or upgrade (`Removed (chi no longer loads class-file bundle hooks): …`, an edited one copied to the trash first; see [Class-file hooks are retired](hooks.md#class-file-hooks-are-retired)). `status NAME` lists the bundle's guardrail rules and scripts beside its plugin, each `[ok]`, `[missing]` or `[modified]` (edited: the next install replaces it, its copy kept in the trash; an edited rule doesn't load, so it counts in `issues=`), and `diff NAME` names an edited rule or script with its recorded and current sha256 (chi keeps no base text for them). A usage error (an unknown subcommand or flag, a missing argument, a bad `build --scope`) exits 2, as for the other subcommands. Plain `chi` and `chi web` exit 1 on an unknown flag, a flag missing its value or a stray argument. `new`, `test` and `check` are for writing one: see [Writing a bundle](#writing-a-bundle-new-test-check)
43
43
 
44
- - `chi page run NAME [--format text|json]` — run the page script `~/.config/samagotchi/pages/NAME.rb` in a Ruby process of its own (in the pages folder, cut at 30 s with what it started) and store what it built; it prints a summary per block (a text's first lines, a table's labels, first rows and total, a walk's steps), or `error: line N: …` with the script's stderr and "the result of … is kept". `--format json` prints the stored page. `chi page list [--format text|json]` — each page's title and `ran … ago`, `failed … ago (line N)` or `(never ran)`, `changed` when the script changed since. `chi page rm NAME` removes the script and its result. Exit 1 when the script raised, was stopped or broke a limit, when there is no such page or it is already running; 2 for the command line (an unknown flag, a name that isn't lowercase letters, digits and hyphens) — see [Pages](pages.md)
44
+ - `chi page run NAME [--format text|json]` — run the page script `~/.config/samagotchi/pages/NAME.rb` (else an installed bundle's page NAME: [Pages from a bundle](pages.md#pages-from-a-bundle)) in a Ruby process of its own (in the pages folder, cut at 30 s with what it started) and store what it built; it prints a summary per block (a text's first lines, a table's labels, first rows and total, a walk's steps), or `error: line N: …` with the script's stderr and "the result of … is kept". `--format json` prints the stored page. `chi page list [--format text|json]` — each page's title and `ran … ago`, `failed … ago (line N)` or `(never ran)`, `changed` when the script changed since, and the bundle a page comes with (`--format json`: `bundle`, and `script`, the path of the script it runs). `chi page rm NAME` removes the script and its result; a bundle's page is refused, exit 1 ("page NAME comes with the X bundle: uninstall the bundle or write your own …/NAME.rb"). Exit 1 when the script raised, was stopped or broke a limit, when there is no such page or it is already running; 2 for the command line (an unknown flag, a name that isn't lowercase letters, digits and hyphens) — see [Pages](pages.md)
45
45
  - `chi guardrails replay [--dry-run] [--threshold T] [--model M]` — seed System 1's record from the approvals this machine's sessions already answered: each ask is judged by the configured model and written to `guardrails/judgments.jsonl` with the answer the user gave, then a per-rule table prints (asks, allowed, denied, would-be auto-allows, false allows, asks with no judgment). A parent agent's answer is not the user's: only its deny is replayed, and only where the parent could have allowed. `--dry-run` judges without writing, `--threshold` overrides `guardrails.system_one.threshold` for the table, `--model` the configured model for this run. Exit 2 when `guardrails.system_one.mode` is off or no `host` is set; a usage error exits 2 (see [System 1](guardrails.md#system-1-experimental))
46
46
  - `chi guardrails rule <id>` — print exactly `asks` when that rule is loaded, not disabled and votes `ask` in this `guardrails.mode` for every model; any other line says why not (no such rule, disabled, another mode, it denies, for some models only, rules that failed to load, `guardrails.enabled: false`). Exit 0 either way, 2 for a usage error. It reads config.yml and the installed bundles as a worker does (`GuardrailWiring#rules`) and takes the rule's id, never a command; the [coordinator skill](bundles.md#the-coordinator-bundle) reads it before it merges without asking
47
47
  - `chi judgments ls` / `chi judgments report NAME [--days N]` — what [System 1's saved runs](system-one.md) hold: each judgment's digests, runs, labels, failures, models and size; one judgment's counts, p histogram and labels by value. Reads only; local only; `--days` must be a positive whole number.
@@ -457,21 +457,25 @@ chi schedule add --continues 3f9a1c2e --every 30m --mode same -m "Check the buil
457
457
 
458
458
  chi schedule list # id name mode recurrence next due target [skips 3 of 12 (≈1 h at a 5 min tick)]
459
459
  chi schedule list --all --format json # the disabled ones and the fired one-offs too
460
- chi schedule show 4b7e9a # the entry in full: anchor, head, prompt, counters
460
+ chi schedule show 4b7e9a # the entry in full: anchor, head, prompt, counters, its last 20 outcomes
461
461
  chi schedule tick # fire everything due; quiet when nothing is
462
462
  chi schedule tick --dry-run # print what would fire, change nothing
463
463
  chi schedule run-now 4b7e9a # fire it now, whatever its next_due says
464
464
  chi schedule disable 4b7e9a # stop it, keep it in the file
465
465
  chi schedule enable 4b7e9a
466
466
  chi schedule cancel 4b7e9a # delete it (by id, a unique prefix, or its title)
467
+ chi schedule edit 4b7e9a --weekday 2 --time 08:30 # change it in place: only the flags given
468
+ chi schedule edit "Monday audit" -m "Audit the open PRs and the queue" --max-skips 24
467
469
  ```
468
470
 
469
471
  Every `list` row names its schedule: the `--title` it was given, or, when it has
470
472
  none, the first 30 characters of its prompt in quotes with `…` where it is cut
471
473
  (newlines and runs of spaces become one space). The name column is padded to the
472
474
  widest name among the rows printed, so the columns after it line up. `--format json`
473
- carries `title` as it is stored (`null` with no title) and the whole `prompt`, never
474
- the quoted stand-in; the `list_schedules` tool names a schedule the same way.
475
+ carries `title` as it is stored (`null` with no title) and the whole `prompt`, and the
476
+ quoted stand-in only as `name`; with it `state` (`on`, `firing`, `off`) and `off_reason`
477
+ ([scheduling.md](scheduling.md#skip-not-failure)). The `list_schedules` tool names a
478
+ schedule the same way.
475
479
 
476
480
  `add` needs a target (`--session ID`, or `--continues ID` for the same session)
477
481
  and exactly one recurrence kind — `--every 45m|2h|1d`, `--weekday 1..7` with
@@ -483,6 +487,20 @@ how many consecutive failures or busy targets disable it. A blank or over-16-KiB
483
487
  prompt, two recurrence kinds, a `scratch` target and a `--weekday` without
484
488
  `--time` are all refused with exit 2.
485
489
 
490
+ `edit ID` changes a schedule in place and prints its updated `list` row: `--title`,
491
+ `-m|--prompt`, one whole recurrence (as `add`'s: `--time` alone is refused),
492
+ `--catch-up` and the three budgets, checked as `add` checks them; only the flags given
493
+ change, and the skip and failure counters, `enabled` and the history stay (it adds one
494
+ `edited` row naming the fields). The session and the mode don't change: `--session`,
495
+ `--continues` and `--mode` are refused ("cancel it and add a new one"). A new
496
+ recurrence starts its clock now, as `add`'s does, and is refused while a firing is in
497
+ flight ("a run is in progress; edit the time after it settles", exit 1); a prompt,
498
+ title or budget edit then applies to the next firing. A spent `--date` one-off stays
499
+ disabled after an edit: `chi schedule enable` it. No flag to change, or only values the
500
+ schedule already has, exits 2 ("nothing to change"), as does an edit that would make it
501
+ say what another schedule of the chain says (its new title, or its new prompt and
502
+ recurrence); a missing id exits 1.
503
+
486
504
  `tick` prints one line per entry it touched (`fired`, `skipped`, `missed`,
487
505
  `failed`, or `would fire` under `--dry-run`), with the reason; nothing due prints
488
506
  `no schedules due`, and a tick that finds the lock held by another prints `no
data/docs/guardrails.md CHANGED
@@ -5,8 +5,9 @@ loops (native and chat hosts). The verdict is **allow**, **ask** or
5
5
  **deny**; the strictest vote wins, and a deny can't be undone by a later
6
6
  voter. Of two asks the first one names the rule, except a rule only the
7
7
  user may allow (`chi-config`, `chi-home`, `chi-shim`, `chi-hooks`, `shell-touches-chi`,
8
- `chi-context-cmd`, `chi-broadcast`): it takes over, and only the scopes both asks offer
9
- are offered. When a second YAML rule with another id asks about the same call (`git merge y && git push`), no
8
+ `chi-context-cmd`, `chi-broadcast`, `prompt-memory-write`, `model-overlay-write`,
9
+ `chi-answer-piped`, `chi-answer-http`, `bundle-secrets-shell`): it takes over, and only the
10
+ scopes both asks offer are offered. When a second YAML rule with another id asks about the same call (`git merge y && git push`), no
10
11
  [rule grant](#approvals) answers it and none is offered.
11
12
 
12
13
  Who votes, in order:
@@ -68,7 +68,7 @@ read side, never the reverse.
68
68
  | `InstalledBundles::FileStanding` (installed_bundles/file_standing.rb) | the one owner of what chi says of an edited bundle file, used by every surface: `Behind` (`#state`, `#line`: `x.md stays behind 0.8.0: no merge possible (why); missed ## A, ## B, ## C and 2 more`, `would stay` in a dry run), `MergeNote`, `.merged_line`, `.no_merge` (for `LEGACY_BASE` it says chi can't tell whether the file holds edits), `.clauses` (a report's clauses for one bundle), `.behind_count`, `.stay_behind`, `.counts_sentence` (the push), `.still_behind`, `.text` (UTF-8, whatever a name or heading was tagged), `FORCE_TAKES`, `FORCE_MOVES`, `IN_THE_TRASH`. Behind means marked and bytes other than the mark's `incoming_sha` (`.behind?`, read by `InstalledBundles::Record#behind_files` and `Remerge` alike): a file brought level by hand isn't, a missing one is a missing file, and one that can't be read is. An older mark no retry has looked at reads `may be behind` (`Behind#unsure`, and the counts say so), and isn't behind at all when level with its recorded source on disk (`InstalledBundles::Record#behind_file?`). A new surface reads these and adds no wording |
69
69
  | `Remerge` | the retry at the same version, memory files only, for a file marked `conflict` (its `FileState` and `REMERGE` row; a `:decide` cell through `Merger::Upgrade#decision`): `#run(dry_run:)` → a `Result` (`merged`, `settled`, `stamped`, `behind`, `warnings`, `trash_copy`). It merges what merges and settles those entries (`Provenance#resolve_conflicts`, the index line refreshed), checking a merged incoming file against the manifest's sha256, in a dry run too. It leaves `version`, `installed_at` and the assets alone: the Installer would `rm_rf` guardrails, plugin and scripts under live sessions. Every file it leaves is in `behind`, with why: one not shipped now (`MemoryFiles.select`) keeps its mark, base and text; one whose `incoming_sha` isn't the shipped text (a checkout at one VERSION) is left alone, no git runs, and it reads as its mark says; a mark with no digest (older chi) is tried as well, and a real conflict then records it (`Provenance#refresh_marks`, which writes only when the mark would read differently, so a conflict at each start writes nothing). A mark whose digest matches is tried on every run, since the file or git may have changed. `noop` and `keep` settle quietly; `fast_forward` waits for the next upgrade, reading as behind until then; `install` is a missing file, which isn't behind, and a warning says so. A file it can't read or replace stays as it is, saying why. Called from `ShippedUpdate.plan_row`/`apply` (`chi update`) and `SystemBundle.sync`'s equal-version branch, under its lock (each chi start and `chi update`); a bundle chi doesn't ship retries through `chi bundle upgrade`. No marks: nothing is read beyond the record. One marked file costs one git run per Engine start, about 12 ms on the Studio (0.1 ms with none) |
70
70
  | `Provenance` | the `.bundles/<name>/` dir's write side (an `InstalledBundles::Dir`): `#write` the record + bases (its `files:` is the full list: a key left out is dropped, a nil value keeps the entry with no base; `marks:` are the files left behind, each a `FileStanding::Behind`, and `incoming_dir:` the bundle text each speaks of, recorded as `incoming_sha` and saved at `#incoming_path`; an older mark that stays keeps `legacy_base`), `#resolve_conflicts` (base to the incoming file, mark and its fields (`MARK_FIELDS`) and saved text gone; a file whose incoming copy is gone keeps both), `#refresh_marks` (what a retry found: why, missed, the digest and `legacy_base`, the saved text), `#note_merged` and `#clear_merge_notes(notes)` (`MERGE_NOTE_FIELDS`, kept through `#write`; the saved text is best effort, after the manifest, so it can't leave a plugin under the old record's sha; any other failure writing the record still can, until a retry), `#record` → `InstalledBundles::Record` (the Dir's). `#write(manifest_from: DIR)` keeps `DIR/manifest.yml` at `#kept_manifest_path` (written aside and renamed; for `dev:` a link to its realpath) and records `manifest_sha` (`FileDigest.sha256`, `DEV_SHA` for dev) and `installed_by` (this chi's VERSION); the Installer and `Profile.install` pass their source dir, and a write without it carries the existing record's two fields, the kept file left alone. The in-place edits (`#resolve_conflicts`, `#record_restored`, `#refresh_marks`, `#note_merged`, `#clear_merge_notes`) keep them. The record's mirror of the manifest keys (`requires_chi` … `setting_types`) is still written from the kwargs, exactly as before: an older chi sharing the memories dir (an old worker, chi web, gem or worktree) reads only the record, and without the mirror's `requires_chi` it would load a too-new bundle's plugin. A key a later manifest gains is never mirrored. Any chi without the kept manifest that rewrites a record drops `manifest_sha` and `installed_by` (it rebuilds the record from its own kwargs). `#adopt_manifest(dir, dry_run:)` heals such a record (`InstalledBundles::Record#manifest_unkept?`: no `manifest_sha`, or its file gone): when `dir` is the source of what's installed (its manifest names the bundle at the recorded version; each mirrored key, normalised as `#mirror_fields` records it (the one shape `#write` uses too), equals the record's, a key the record lacks being fine only when `BundleManifest::SINCE` has it, since an older chi couldn't have recorded it (a recorded hook doesn't count: retired); and every recorded plugin, hook, script, rule and unmarked memory sha is that of `dir`'s file; else the why names the key or file) it keeps `dir/manifest.yml` and records `manifest_sha`, nothing else (not `installed_at`, the mirror or `installed_by`); otherwise it returns why and writes nothing. Never for a dev record (its next `install --dev` links the file) |
71
- | `InstalledBundles::Manifest` (installed_bundles/manifest.rb) | the one answer to "this installed bundle's manifest" (`InstalledBundles::Record#manifest`): requires_chi, trust_level, needs, the scripts' names, context providers, block renderers, session settings and settings with their types, file descriptions, a profile's includes. Read from the kept `manifest.yml` (`origin: :kept`) when the record's `manifest_sha` is set and the file still has it (`InstalledBundles::Sha.matches?`, so a dev link is never checked), else from the record's `mirror` (`origin: :record`), in these cases: no kept file and no `manifest_sha` (a record from before chi kept it; no problem); no kept file, or something other than a file in its place, while `manifest_sha` is set (`:missing`); a kept file and no `manifest_sha` (a chi without the kept manifest rewrote the record: `problems["manifest.yml"] = :stale`); a kept file with another sha, or one that isn't a YAML mapping (`:edited`); the sha matches (`:kept`). `#standing` is that symbol, `#key_problems` the rest. The kept file is read by `BundleManifest.tolerant` key by key in a fixed order (its comment): a key that doesn't parse under this chi takes the mirror's value if that parses, else empty, with its message in `problems` (a reader that logged it logs that); `block_renderers` is checked against the record's scripts when the kept `scripts:` fails, and an older install's `hooks:` is ignored (no problem row). `description` and `unknown_keys` come only from a kept file; a profile's `includes` is always the record's (its members, identity). The value is deep-frozen, since callers share it. One process-wide cache (a Hash under a Mutex, cleared at `CACHE_LIMIT`) keyed by the record value and the kept file's stat (mtime, size, inode, device; a dev link's target): chi web asks per request, a worker at start and per `ContextProviders.resolve`. `#requires_chi_failure(version = VERSION)` is the one requires_chi gate; `#experimental?`, `#needs?`, `#context_providers?`, `#block_renderers?` |
71
+ | `InstalledBundles::Manifest` (installed_bundles/manifest.rb) | the one answer to "this installed bundle's manifest" (`InstalledBundles::Record#manifest`): requires_chi, trust_level, needs, the scripts' names, context providers, block renderers, pages (`pages:`, kept file only: never mirrored, so `[]` from the record), session settings and settings with their types, file descriptions, a profile's includes. Read from the kept `manifest.yml` (`origin: :kept`) when the record's `manifest_sha` is set and the file still has it (`InstalledBundles::Sha.matches?`, so a dev link is never checked), else from the record's `mirror` (`origin: :record`), in these cases: no kept file and no `manifest_sha` (a record from before chi kept it; no problem); no kept file, or something other than a file in its place, while `manifest_sha` is set (`:missing`); a kept file and no `manifest_sha` (a chi without the kept manifest rewrote the record: `problems["manifest.yml"] = :stale`); a kept file with another sha, or one that isn't a YAML mapping (`:edited`); the sha matches (`:kept`). `#standing` is that symbol, `#key_problems` the rest. The kept file is read by `BundleManifest.tolerant` key by key in a fixed order (its comment): a key that doesn't parse under this chi takes the mirror's value if that parses, else empty, with its message in `problems` (a reader that logged it logs that); `block_renderers` is checked against the record's scripts when the kept `scripts:` fails, and an older install's `hooks:` is ignored (no problem row). `description` and `unknown_keys` come only from a kept file; a profile's `includes` is always the record's (its members, identity). The value is deep-frozen, since callers share it. One process-wide cache (a Hash under a Mutex, cleared at `CACHE_LIMIT`) keyed by the record value and the kept file's stat (mtime, size, inode, device; a dev link's target): chi web asks per request, a worker at start and per `ContextProviders.resolve`. `#requires_chi_failure(version = VERSION)` is the one requires_chi gate; `#experimental?`, `#needs?`, `#context_providers?`, `#block_renderers?`, `#pages?` |
72
72
  | `ManifestStanding` (manifest_standing.rb) | the one owner of the words for an installed bundle's `manifest.yml` as `InstalledBundles::Manifest` read it: `.state` (`:kept`, `:legacy`, `:stale`, `:missing`, `:edited`), `.label` (`[kept]` / `[from the install record]`), `.line(bundle, refused:)` (the case and the command: `chi bundle upgrade NAME` (reads it again from a git URL, or a source that didn't match, with why), `chi update keeps it` while untried, the source is gone (`Installer.source_gone_line`), `chi bundle install --dev SOURCE` for a dev record; for a kept one, only the keys whose `BundleManifest::SINCE` floor is above the record's `installed_by`: newer than its installer), `.keep(bundle, source_dir:, dry_run:)` → `Outcome` (the record after, the line, `kept`): `Provenance#adopt_manifest` from `source_dir`, else from the recorded source (a dir; a zip/tar through `PreparedSource`, cleaned up; never a git clone). Read by `ShippedUpdate` (`Row#manifest`, the plan's dry `keep` and apply's), `UpdateCommand#external_rows` (a `kept its manifest` row, else a warn row, before the bundle's re-check, which then sees the kept file) and `chi bundle status NAME` (`BundleCommand#manifest_line`: `Manifest:`, the label, `.status_line`: for a record with a folder source (a bundle chi ships: this chi's shipped copy at the recorded version, which `chi update` reads), a dry `adopt_manifest` first, so the line says whether `chi update` keeps it or why not; an archive isn't extracted there, its line says `chi update tries to keep it`; a profile chi doesn't ship is never kept by `chi update`, so its line names `chi bundle upgrade NAME`) |
73
73
  | `InstalledBundles::Record`, `BundleHook`, `PluginRef` (installed_bundles/record.rb, bundle_hook.rb, plugin_ref.rb) | value objects for the record; tolerant of older records (missing keys read as empty). `InstalledBundles::Record`'s members are identity and state (name, version, scope, source, `installed_at`, `source_commit`, files and their marks, hooks, guardrails, scripts and the plugin with their shas, a profile's `includes`, `dev`, `dir`, the kept manifest's `manifest_sha` and `installed_by`, nil on a record from before it was kept); the manifest keys it records sit in one `mirror` Hash (`MIRROR_KEYS`, frozen: a key a later manifest gains is never mirrored) that only `InstalledBundles::Manifest` reads, so manifest data is read through `#manifest`. `BundleHook` is an older record's hook entry: `.parse` and `#sha256` (what the retire, uninstall and the trash selection read) |
74
74
  | `BlockRenderers` (`lib/samagotchi/block_renderers.rb`) | a manifest's `block_renderers:`: `.parse_list`, and what chi web asks without loading plugins: `.for_installed` (first bundle by name wins a language; a record with an error, an unmet `requires_chi` or a list that doesn't parse is skipped) and `.script_path` (`load` membership first, then `InstalledBundles::Sha.matches?`). `BundleManifest` checks each `load` is a `scripts:` key; the files are ordinary scripts everywhere else ([block-renderers.md](block-renderers.md)) |
@@ -115,8 +115,8 @@ check reads no manifest. Each skip is also logged once per process: an unreadabl
115
115
  (`bundle_unreadable`), a too-new bundle by the reader that skips it; every once-per-process log is a Set under a Mutex,
116
116
  like `GuardrailWiring`'s kept-rules notice.
117
117
  They read shas and state off the record, and
118
- manifest data (requires_chi, needs, providers, renderers, settings) through `InstalledBundles::Record#manifest`
119
- (`InstalledBundles::Manifest`: the kept `manifest.yml` when its sha holds, else the record's mirror), as do `SessionConfig`, `BundleSettingsCheck`, `BlockRenderers`, `Status`, `BundleCommand`'s
118
+ manifest data (requires_chi, needs, providers, renderers, pages, settings) through `InstalledBundles::Record#manifest`
119
+ (`InstalledBundles::Manifest`: the kept `manifest.yml` when its sha holds, else the record's mirror), as do `SessionConfig`, `BundleSettingsCheck`, `BlockRenderers`, `Pages::Bundled`, `Status`, `BundleCommand`'s
120
120
  status and diff, `Builder` and `InstalledCopy`. The one requires_chi gate is `InstalledBundles::Manifest#requires_chi_failure`, which the runtime readers reach through `Standing` (`:too_new`). `GuardrailWiring#rules_stamp` stats each bundle's
121
121
  `manifest.yml` with its `manifest.json` and `guardrails/*`, so a changed requires_chi re-reads the rules. No reader
122
122
  calls `BundleManifest.new` on a kept file: `BundleManifest.tolerant` through `InstalledBundles::Manifest` is the one read.
@@ -6,16 +6,44 @@ The user side is [pages.md](../pages.md). This is how a run happens and what it
6
6
 
7
7
  | File | What |
8
8
  |---|---|
9
- | `lib/samagotchi/pages.rb` | `Pages`: the limits, the name rule (`check_name!`, the one check before any path), the folders, the errors (`Refused`, `BadName`, `Missing`, `Busy`, each owning its message), the values `Stored` and `Failure` |
9
+ | `lib/samagotchi/pages.rb` | `Pages`: the limits, the name rule (`check_name!`, the one check before any path), the folders, the resolver (`script_path`, `user_script_path`, `bundled`), the errors (`Refused`, `BadName`, `Missing`, `FromBundle`, `Busy`, each owning its message), the values `Stored` and `Failure` |
10
10
  | `pages/builder.rb` | `Builder` (the script's `ui`: `text`, `table`, `walk`) and `TableBlock` (columns, formats, key columns, cells, the total) |
11
11
  | `pages/store.rb` | `Store`: read, list, `record_run`, `record_failure`, `locked`, `remove`, `file_id`, `remove_temporary_outputs` |
12
12
  | `pages/runner.rb` | `Runner.run(argv)`: the runner process's whole job |
13
+ | `pages/runtime.rb` | `Runtime`, a script's `runtime`: `#schedules` (`ScheduleList`, `Schedule`, `Run`, `Unreadable`) |
14
+ | `pages/bundled.rb` | `Bundled`: the pages installed bundles ship (a manifest's `pages:`), `Page#refusal` |
13
15
  | `pages/launch.rb` | `Launch.run(name, timeout:, cancelled:)`: the one launch path |
14
16
  | `page_command.rb` | `chi page run | list | rm` |
15
17
 
16
18
  `pages.rb` requires json, digest, time, `inline_widgets`, `paths` and `atomic_file`, and autoloads its parts. Nothing
17
- it reaches requires the engine, the config, the web, the plugins, `ChildEnv` or `ProcessGroup`: the runner loads it
18
- alone. `launch.rb` is the only file that needs `ChildEnv` and `ProcessGroup`, and nothing in `pages.rb` requires it.
19
+ it reaches at load requires the engine, the config, the web, the plugins, `ChildEnv` or `ProcessGroup`: the runner
20
+ loads it alone. `launch.rb` is the only file that needs `ChildEnv` and `ProcessGroup`, and nothing in `pages.rb`
21
+ requires it. Two parts load more, and only when used: `Runtime#schedules` requires `schedules.rb` (which reaches the
22
+ config, `SessionManager` and `ProcessGroup`; about 70 ms) when a script calls it, and `Bundled` requires
23
+ `installed_bundles.rb` (the config) when a name has no script of the user's. `spec/pages_runtime_spec.rb` pins it: a
24
+ real runner process running a user's page that never calls `runtime` has loaded no `runtime.rb`, `schedules.rb` or
25
+ `config.rb`.
26
+
27
+ **The resolver.** `Pages.script_path(name)` is the script a name runs: the user's `NAME.rb` when it exists, else the
28
+ page of that name an installed bundle ships (`Bundled.find`), else the user's path (no such page). Every read and run
29
+ goes through it (`Store.read`/`script_sha`, `Launch`, `Runner`, `PageRoutes`). `Store.remove` never does: it deletes
30
+ only `Pages.user_script_path(name)`, and with no user script a bundle's page raises `FromBundle` before anything is
31
+ touched (`pages_bundled_spec` checks the bundle's file is still there). `Store.list` is the user's names (the pages
32
+ folder) and `Bundled.all`'s, one per name. `Stored#bundle` is the bundle whose script runs (nil when the user's runs,
33
+ so a shadowing copy reads as the user's) and `Stored#script` its path.
34
+
35
+ **Bundle pages** (`Bundled`, from the install records like `BlockRenderers.for_installed`, so chi web loads no plugin):
36
+ each usable `InstalledBundles.standings` record's `manifest.pages` (`InstalledBundles::Manifest#pages`: the kept
37
+ `manifest.yml` only, never the record's mirror, since a key a later manifest gains is never mirrored), the first
38
+ bundle by name winning a name; an unreadable or too-new bundle ships none. Since `pages:` isn't mirrored, a kept
39
+ `manifest.yml` that is edited, stale or missing (`InstalledBundles::Manifest#standing`), or a `pages:` that doesn't
40
+ parse, ships no page either: `Bundled.unread` logs `bundle_pages_unread` (bundle, why) once per process when the kept
41
+ file names `pages:` (or the key failed), and `chi bundle status NAME` says the file is edited. `Page#refusal` is
42
+ `InstalledBundles::Dir#file_refusal(:scripts, …)` against the recorded sha: `Launch.run` checks it under the lock and,
43
+ on one, records it as the run's failure and starts nothing. A bundle page whose installed script is gone is still
44
+ a page (`Pages.exists?`, which `Launch.run` and `GET /api/pages/NAME` ask): its run fails with the `file_missing`
45
+ refusal, not "no page". A bundle page's run loads `installed_bundles.rb` in the
46
+ runner too (its `Pages.script_path`), accepted: the shipped one loads the schedules anyway.
19
47
 
20
48
  ## The one launch path
21
49
 
@@ -79,8 +107,8 @@ limit). It arms the deadline when argv carries one (a write of the result and th
79
107
  and the write sets a done flag under it, so a result written before the deadline fires is never overwritten), checks
80
108
  the
81
109
  name and the script, then
82
- `load(path, dsl)`: the wrap module is a fresh `Module` defining only `page`, so the script's own `def`s land in it, not
83
- on `Object`. `page(title) { |ui| … }` makes a `Builder`; a second call raises `Refused`. After the load, no `page` call
110
+ `load(path, dsl)`: the wrap module is a fresh `Module` defining only `page` and `runtime` (the Collector's
111
+ `Runtime`, made on the first call), so the script's own `def`s land in it, not on `Object`. `page(title) { |ui| … }` makes a `Builder`; a second call raises `Refused`. After the load, no `page` call
84
112
  fails the run too.
85
113
 
86
114
  It rescues `StandardError`, `ScriptError`, `SystemExit`, `SystemStackError` (endless recursion) and `NoMemoryError` (never a `SignalException`: a TERM is the launcher's cut,
@@ -131,32 +159,48 @@ all `:owner`: a participant's token gets 403 `not_permitted` (`participant_gate_
131
159
 
132
160
  | Route | Answers |
133
161
  |---|---|
134
- | `GET /api/pages` | `{pages: [{name, title, state, ran_at, failed_at, changed, error_line}]}`, by name (`Store.list`) |
162
+ | `GET /api/pages` | `{pages: [{name, title, state, ran_at, failed_at, changed, error_line, bundle}]}`, by name (`Store.list`) |
135
163
  | `GET /api/pages/NAME` | the page (below); 404 `page_missing` with no script. Runs nothing |
136
164
  | `POST /api/pages/NAME/run` | `Launch.run(name, timeout: 30, cancelled: -> { !@server_running.call })` inside the request; the page as after the run, with `stderr` (its last 2 KB) when it failed; 409 `page_busy`, 404 `page_missing`, 503 `server_stopping` (chi web's stop ended it: "the run was stopped") |
137
- | `DELETE /api/pages/NAME` | `Store.remove`: `{removed: NAME}`; 409 `page_busy`, 404 `page_missing` |
165
+ | `DELETE /api/pages/NAME` | `Store.remove`: `{removed: NAME}`; 409 `page_busy`, 409 `page_bundled` (a bundle's page, `FromBundle`), 404 `page_missing` |
138
166
 
139
- The page: `{name, title, state, ran_at, duration_ms, changed, changed_after_failure, script_changed_at, error:
140
- {message, line, at} | null, blocks}`. `changed` is `Stored#changed?`; `changed_after_failure` says the script differs
167
+ The page: `{name, title, state, ran_at, duration_ms, changed, bundle, changed_after_failure, script_changed_at, error:
168
+ {message, line, at} | null, blocks}`. `bundle` (`Stored#bundle`) makes `page_view.js` leave out `⋯` and its Delete;
169
+ an older cached app.js still offers it, and the 409's message shows in its toast. `changed` is `Stored#changed?`; `changed_after_failure` says the script differs
141
170
  from the one that failed (so the page needs no sha); `script_changed_at` is the script's mtime. A text block carries
142
171
  `html`, the `MarkdownRenderer`'s sanitised render, when rendering is available (`web.markdown`), else `text` only.
143
172
  The error codes' `detail` is the exception's own message.
144
173
 
145
- **The capability** `pages` (`Web::Viewer::CAPABILITIES`, never a participant's) makes the view, the group and the link
146
- handler; without it none is made and no page call goes out (`viewer_boot.test.js`).
174
+ **The capability** `pages` (`Web::Viewer::CAPABILITIES`, never a participant's) makes the pill, the list, the view and
175
+ the link handler (`pages_wiring.js`, one call in app.js; the pill is `viewer.control(#pagesBtn, "pages")`); without it
176
+ none is made and no page call goes out (`viewer_boot.test.js`).
147
177
 
148
178
  **The page's modules** (`lib/samagotchi/web/public/`): `page_route.js` (`pageHash`, `pageNameFromHash`, the open rule:
149
- never a participant's, never without `pages`), `views.js` (reads the page hash before the session intent:
150
- `body.page-view`, `openPage` / `closePage` / `leavePage`, the session hash not written while a page is open, a session
151
- picked leaving the page), `page_view.js` (the header, the states, the calls; an answer for a page no longer open is
179
+ never a participant's, never without `pages`), `views.js` (reads the page hash and the list's `#/pages` before the
180
+ session intent: `body.page-view` / `body.pages-list`, `openPage` / `closePage` / `leavePage`, `openPagesList` /
181
+ `closePagesList`, where a page or the list was opened from kept in its history entry (`history.pushState({from})`:
182
+ `pages`, `sessions`, `back`, `pill`; Back and its label read `history.state.from`, so Back and Forward keep them;
183
+ an entry with no state was typed or replaced and leaves for the list, or the session), the pill's `aria-pressed`, the session hash not written while either is open, a session picked
184
+ leaving it; a page with nowhere to go back to, or gone, lands on the list), `pages_model.js` (the page's one list of
185
+ pages: `load` shares a read that is out, `reload` asks again, a failed read keeps the last list; DOM-free),
186
+ `pages_wiring.js` (the model, the pill, the list, the view and the links; when the list is read),
187
+ `pages_list.js` (the Pages list, `#/pages`: its hash, its cards in `/api/pages`'s order), `page_view.js` (the header, the states, the calls; an answer for a page no longer open is
152
188
  dropped, `latest.js`), `page_model.js` (the words: meta, the failed and changed lines, Copy the error), `page_blocks.js`
153
189
  (text, walk in a widget host with `drawWalk`, an unknown type as one muted line), `page_table.js` and
154
- `page_table_model.js` (cells, sort, the phone's rows), `pages_group.js` (All sessions' group), `page_links.js` (the
190
+ `page_table_model.js` (cells, sort, the phone's rows), `pages_group.js` (All sessions' former group, kept for an
191
+ older cached app.js until after 0.189.0; nothing new imports it), `page_links.js` (the
155
192
  delegated click on the turn roots and the page view for `#/p/` anchors), `pages.css`. What a script wrote reaches the
156
193
  page as text or attributes, never as markup, except the server's sanitised `html`.
157
194
 
158
- **Not live**: no stream event and no polling. A run from a terminal shows on the next open; two tabs are not kept in
159
- step.
195
+ **The list is live, a page isn't.** chi web's session hub stats the scripts folder (`Pages.scripts_dir`) once a tick
196
+ and sends a `pages` event (no data) on `GET /api/events` when its mtime moved: a script made, renamed in or removed
197
+ (an editor's temp file or a data file beside the scripts counts too: one extra `GET /api/pages` per open tab). Never on
198
+ the first look; a folder that appears or goes is a change. A run changes nothing there (its output is under the state
199
+ dir), unless the script writes a file beside itself (it runs with the pages folder as its working folder): then each
200
+ run refreshes every open tab's list. The page reads the list again on that event and on every snapshot (the first one
201
+ shares the boot read while that is out; a later one is a reconnect: the hub has no replay); with no hub stream (no `EventSource`, the list's fetch fallback) the list is read only when a view opens. A
202
+ page's own result has no stream event and no polling: a run from a terminal shows on the next open; two tabs are not
203
+ kept in step.
160
204
 
161
205
  ## chi's side: the skill
162
206
 
@@ -172,4 +216,7 @@ owner's `~/.claude/plans/evals/0016-pages-skill/`.
172
216
 
173
217
  ## Later builds
174
218
 
175
- - Not planned yet: picks on a page, a data API (`runtime`), a bundle's pages, parameters.
219
+ - `runtime` has one method, `schedules`, with its first page (the schedules bundle). A method comes with its first
220
+ caller: sessions, a session's stats, a config value are the candidates.
221
+ - Not planned yet: picks on a page, parameters, a live install (the hub watches the pages folder only, so a bundle's
222
+ page shows on the next list read).
@@ -3,8 +3,9 @@
3
3
  There is no persisted lifecycle enum. A state is derived from the session file, sidecar files, locks, and the worker
4
4
  link: `SessionLifecycle.read(id)` (`session_lifecycle.rb`) reads them once (`WorkerPresence` with its link looked at,
5
5
  never unlinked, and `ContinueIntent.in_flight`) and names the first of its 15 states whose facts hold (Derived states).
6
- The same session can satisfy more than one fact (archived while its worker is leaving); the precedence picks one. One
7
- decider reads `SessionLifecycle`: `restart_session`'s precheck (Allowed operations). The others still read their own
6
+ The same session can satisfy more than one fact (archived while its worker is leaving); the precedence picks one. Two
7
+ deciders read `SessionLifecycle`: `restart_session`'s precheck and a schedule's busy check (`Schedules#busy_cell`;
8
+ Allowed operations). The others still read their own
8
9
  subset of the facts in their own order, and what each answers per state is `ALLOWED` (Allowed operations), pinned by
9
10
  the characterization matrix. The session file layout and user-facing session behavior are in [Sessions](../sessions.md); the Worker and
10
11
  SessionManager boundaries are in [Architecture](../architecture.md) and [Engine internals](engine.md).
@@ -98,7 +99,7 @@ Link resolution (`SessionInbox::Head.resolve`, `Schedules#target_of`) stays outs
98
99
 
99
100
  The running-tasks check of a user's delete and archive (`SessionManager::RunningTasks`, `tasks_running`) is op-local,
100
101
  not an `ALLOWED` cell: it reads the transcript and each `task.json`, not the lifecycle's facts, and runs after the
101
- lifecycle refusals (`refuse_scheduled!`, `archivable!`), before the worker is stopped.
102
+ lifecycle refusals (`refuse_protected!`, `archivable!`), before the worker is stopped.
102
103
 
103
104
  `restart_session` is the first decider migrated to the table: its lifecycle precheck is `SessionLifecycle.read` (the
104
105
  owner read through `session_owner`) and `ALLOWED[:restart]`: `owned_by_tui` raises `OwnedByTUI`, a refusal cell
@@ -106,7 +107,19 @@ raises `RestartRefused` with it as the reason (`starting`, `not_running`, `stop_
106
107
  `restart_fallback` (skew, a stuck start) and `go` asks the live worker. Its op-local checks stay where they were: the
107
108
  SIGSTOP check (`:stopped`, the worker's pid: a different condition with its own words, before the table's refusal),
108
109
  the worker's `restart` feature, the Bridge's reply and the fallback's holds. The matrix still drives it, so its
109
- column is pinned against the precheck and the op-local paths together. The other deciders don't read `ALLOWED` yet.
110
+ column is pinned against the precheck and the op-local paths together.
111
+
112
+ A schedule's busy check (`Schedules#busy_reason`, `schedules/busy_part.rb`) is the second: it reads `WorkerPresence`
113
+ as before (the owner through `session_owner`, the link looked at), derives the state with `Reading.derive` on that
114
+ presence with `exists: true` (the target resolved already, and a delete mid-way, its JSON gone under the deleting
115
+ lock, must read `deleting`, not `absent`; no `ContinueIntent` read), and `#busy_cell` takes `ALLOWED[:sched_chain]`
116
+ or `[:sched_same]` for it. Two op-local overrides keep today's order, each named by its `KNOWN_DIFFERENCES` entries: the
117
+ stop marker before the owner (any cell but `deleting` becomes `stopped`: F1, and an unknown owner's stop), and chain
118
+ mode's starting check with no one-turn-run check (a fresh starting marker without a worker's lock makes `go`
119
+ `worker_busy`: F1b). A skip cell's words are `BUSY_WORDS` (`worker_newer` is Skew's own). On `go`, a live worker
120
+ is asked through its Bridge (`#live_busy_reason`: `/activity`, an old chi, the three activity signals, chain mode's
121
+ open streams) and any other session goes to the file checks (`#file_busy_reason`): those stay op-local, as restart's
122
+ SIGSTOP, features and Bridge reply do. The other deciders don't read `ALLOWED` yet.
110
123
 
111
124
  ## Characterization matrix
112
125
 
@@ -123,8 +136,8 @@ code can't make (a one-turn run's lock with a stop) is marked `reachable: false`
123
136
  Every answer must equal `ALLOWED[op][state]` (for the session hub, `SHOWN[state]`: `Web::SessionSummary.build`'s
124
137
  status and bridge_up, its `SessionRow`'s live), or be named by exactly one `KNOWN_DIFFERENCES` entry (op, a `when`
125
138
  over the row, a plain reason); an entry that names no mismatch fails as stale. The entries are the findings for the
126
- owner, not fixed: stop-first schedule checks under a one-turn run's or an unknown owner's lock, and attach's under a
127
- one-turn run's, a deleter's or an unknown owner's; chain mode's starting check before any one-turn-run check; a start
139
+ 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
140
+ 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
128
141
  marked after the stop holding a resume off;
129
142
  `wake_for_report` reporting a worker's `:live` as `:owned`; the hub's bridge_up, live and status overlay. (Restart
130
143
  never reading the stop, the restart and schedule reading a deleter as starting, the schedule's Skew words, and
@@ -37,7 +37,7 @@ sheet still keeps `isChained` and `format.js deleteConfirmText` that way; and `w
37
37
  with 0.183.0's `ws_reader.js` and `ws_peek.js`, and 0.183.0's view with this `ws_reader.js`, from
38
38
  `spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `quiet_notes.js`, `details_motion.js`,
39
39
  `turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
40
- `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from, the session's hash not written while it is open, a session picked leaving it; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_group.js` and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
40
+ `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while it is open, a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js), `pages_group.js` (All sessions' former group, kept for an older cached app.js until after 0.189.0) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
41
41
 
42
42
  ## One page, every viewer
43
43
 
@@ -278,7 +278,7 @@ gates are boot-time: a show's narrower `viewer` changes what `viewer.can` answer
278
278
  | `block_renderers` | a bundle's drawn blocks (the core `chi-ui` drawer stays) | `/api/block_renderers*` |
279
279
  | `stop_any_turn` | the stage's Stop turn (`onCancel`) | `POST …/cancel` |
280
280
  | `steer_any_turn` | none: the delivery line reads a participant's own `steer_own_turn` instead (`viewerTurn`) | |
281
- | `pages` | the page view (`#pageView`, `page_view.js`), All sessions' Pages group (`#pagesGroup`), the `#/p/` link handler (`page_links.js`); without it a `#/p/…` hash is no page | `GET /api/pages` (when All sessions opens), `GET /api/pages/:name` (a page opened), `POST …/run` (Refresh), `DELETE /api/pages/:name` |
281
+ | `pages` | the pages pill (`#pagesBtn`), the Pages list (`#pagesList`, `pages_list.js`), the page view (`#pageView`, `page_view.js`), the `#/p/` link handler (`page_links.js`), all made by `pages_wiring.js`; without it `#/pages` and a `#/p/…` hash are no view | `GET /api/pages` (once at boot, then when the list, All sessions or a page opens, after a Delete, on the hub's `pages` event and a reconnect's snapshot), `GET /api/pages/:name` (a page opened), `POST …/run` (Refresh), `DELETE /api/pages/:name` |
282
282
 
283
283
  A participant's `can` (`Viewer::PARTICIPANT_CAPABILITIES`, in their show's `viewer` and on `<body>`) names
284
284
  capabilities of their own, not the owner's: `send` (the composer), `stop_own_turn` (Stop turn on a turn they
@@ -965,7 +965,7 @@ uses `latest.js`.
965
965
 
966
966
  | Stream | Opened by | Lifecycle |
967
967
  |---|---|---|
968
- | The hub, `GET /api/events` (`data.js openEvents`) | app.js `openSessionEvents` (scoped by `?dir`) | `snapshot` then `session` / `session_gone` → `applySessionEvent` → `allSessions`; EventSource reconnects itself (a fresh snapshot); `onClosed` (a proxy sign-in on reconnect): probe, reopen after `EVENTS_REOPEN_MS` |
968
+ | The hub, `GET /api/events` (`data.js openEvents`) | app.js `openSessionEvents` (scoped by `?dir`) | `snapshot` then `session` / `session_gone` → `applySessionEvent` → `allSessions`; `pages` (and every snapshot after the first) → `pages_wiring.js` reads the list of pages again; EventSource reconnects itself (a fresh snapshot); `onClosed` (a proxy sign-in on reconnect): probe, reopen after `EVENTS_REOPEN_MS` |
969
969
  | A second hub stream, unscoped | `notifications.js` (`allEvents`) on a project's page | the Home Screen app's device tidy-up across projects |
970
970
  | The open session, `GET /api/sessions/:id/stream?from_seq=` (`data.js openStream`) | `session_sync.js` `startStream` from `store.current.streamSeq` | events → `stream_handlers.js`. It closes itself on an error; the page resyncs (`resync`: a fresh render and a new stream from its cursor), once at once when it had opened, else after `STREAM_RETRY_MS`. Meanwhile a turn the stage holds reads "reconnecting…" (Quiet, under Frames), and the Bridge's `: ping` is invisible to the page. A re-read that can't reach chi web keeps the history it drew (`resync_reach.js`): the session bar's status chip says "retrying" while `retryResync` tries, "offline" once the tries ran out (`store.current.reach`; short words that fit the chip's reserved width, the full words in its tooltip), but only while no turn runs: during a turn the stage's "reconnecting…" is the one signal (on a phone the bar can hide its status) and the chip keeps the turn's word, and any hub event for the session then re-reads it (`followSelectedSession`); the next drawn re-read clears it. Only a first load (select's "Loading…") shows the error in the history |
971
971