samagotchi 0.188.0 → 0.190.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +76 -1
  3. data/docs/architecture.md +9 -4
  4. data/docs/bundle-authoring.md +1 -1
  5. data/docs/bundles.md +15 -0
  6. data/docs/cli.md +38 -9
  7. data/docs/configuration.md +1 -0
  8. data/docs/guardrails.md +22 -9
  9. data/docs/internals/attached-context.md +4 -1
  10. data/docs/internals/bundles.md +3 -3
  11. data/docs/internals/engine.md +18 -2
  12. data/docs/internals/pages.md +65 -18
  13. data/docs/internals/session-lifecycle.md +19 -6
  14. data/docs/internals/web-frontend.md +3 -3
  15. data/docs/internals/web-push.md +11 -5
  16. data/docs/pages.md +69 -15
  17. data/docs/peers.md +3 -0
  18. data/docs/plugins.md +25 -1
  19. data/docs/releasing.md +1 -1
  20. data/docs/scheduling.md +168 -11
  21. data/docs/sessions.md +4 -4
  22. data/docs/sub-agent.md +1 -1
  23. data/docs/testing.md +1 -1
  24. data/lib/samagotchi/bundle_manifest.rb +34 -5
  25. data/lib/samagotchi/bundles/guardrails/guardrails/rules.yml +15 -0
  26. data/lib/samagotchi/bundles/guardrails/manifest.yml +2 -2
  27. data/lib/samagotchi/bundles/schedules/manifest.yml +11 -0
  28. data/lib/samagotchi/bundles/schedules/scripts/schedules.rb +169 -0
  29. data/lib/samagotchi/bundles/system/manifest.yml +3 -3
  30. data/lib/samagotchi/bundles/system/self_map.md +2 -2
  31. data/lib/samagotchi/bundles/system/skill_pages.md +9 -4
  32. data/lib/samagotchi/config.rb +2 -0
  33. data/lib/samagotchi/context_fetch.rb +9 -3
  34. data/lib/samagotchi/engine/models.rb +6 -4
  35. data/lib/samagotchi/engine/turn_end.rb +20 -2
  36. data/lib/samagotchi/engine.rb +5 -1
  37. data/lib/samagotchi/failure_line.rb +43 -0
  38. data/lib/samagotchi/guardrail_wiring.rb +3 -1
  39. data/lib/samagotchi/guardrails/chi_dirs.rb +20 -5
  40. data/lib/samagotchi/guardrails/parent_approvals.rb +1 -1
  41. data/lib/samagotchi/guardrails/protected_paths.rb +8 -4
  42. data/lib/samagotchi/guardrails/shell_paths.rb +16 -2
  43. data/lib/samagotchi/guardrails/targets.rb +1 -1
  44. data/lib/samagotchi/guardrails/verdict.rb +5 -3
  45. data/lib/samagotchi/image_store.rb +4 -0
  46. data/lib/samagotchi/installed_bundles/manifest.rb +8 -1
  47. data/lib/samagotchi/last_turn.rb +2 -1
  48. data/lib/samagotchi/llm/utf8_scrub.rb +26 -0
  49. data/lib/samagotchi/llm_context_view.rb +6 -0
  50. data/lib/samagotchi/memory_bundle/asset_installer.rb +3 -2
  51. data/lib/samagotchi/memory_bundle/builder.rb +1 -0
  52. data/lib/samagotchi/memory_bundle/installed_copy.rb +1 -1
  53. data/lib/samagotchi/model_profile.rb +4 -1
  54. data/lib/samagotchi/page_command.rb +9 -6
  55. data/lib/samagotchi/pages/bundled.rb +83 -0
  56. data/lib/samagotchi/pages/launch.rb +14 -2
  57. data/lib/samagotchi/pages/runner.rb +7 -2
  58. data/lib/samagotchi/pages/runtime.rb +84 -0
  59. data/lib/samagotchi/pages/store.rb +18 -5
  60. data/lib/samagotchi/pages.rb +47 -3
  61. data/lib/samagotchi/peer_continue.rb +14 -8
  62. data/lib/samagotchi/reply_wait.rb +1 -1
  63. data/lib/samagotchi/run_options.rb +1 -1
  64. data/lib/samagotchi/schedule_command.rb +175 -39
  65. data/lib/samagotchi/schedule_display.rb +85 -0
  66. data/lib/samagotchi/schedules/busy_part.rb +146 -0
  67. data/lib/samagotchi/schedules/condition_part.rb +312 -0
  68. data/lib/samagotchi/schedules/edit_part.rb +144 -0
  69. data/lib/samagotchi/schedules/history_part.rb +51 -0
  70. data/lib/samagotchi/schedules/listing_part.rb +52 -0
  71. data/lib/samagotchi/schedules/notices_part.rb +122 -0
  72. data/lib/samagotchi/schedules/protection_part.rb +113 -0
  73. data/lib/samagotchi/schedules/prune_part.rb +79 -0
  74. data/lib/samagotchi/schedules/recurrence.rb +103 -0
  75. data/lib/samagotchi/schedules.rb +188 -409
  76. data/lib/samagotchi/session_access/local.rb +9 -1
  77. data/lib/samagotchi/session_access/remote.rb +2 -1
  78. data/lib/samagotchi/session_chain/delete.rb +7 -5
  79. data/lib/samagotchi/session_lifecycle/allowed.rb +2 -1
  80. data/lib/samagotchi/session_lifecycle.rb +3 -2
  81. data/lib/samagotchi/session_manager/removal.rb +16 -9
  82. data/lib/samagotchi/session_protection.rb +99 -0
  83. data/lib/samagotchi/session_retention.rb +21 -6
  84. data/lib/samagotchi/sessions_command.rb +4 -0
  85. data/lib/samagotchi/system_one/self_protect.rb +4 -2
  86. data/lib/samagotchi/testing/boundary.rb +13 -0
  87. data/lib/samagotchi/tools/cancel_schedule.rb +32 -4
  88. data/lib/samagotchi/tools/execute.rb +5 -1
  89. data/lib/samagotchi/tools/list_schedules.rb +1 -0
  90. data/lib/samagotchi/tools/task_runtime.rb +6 -0
  91. data/lib/samagotchi/turn_endings.rb +14 -2
  92. data/lib/samagotchi/turn_flow.rb +2 -1
  93. data/lib/samagotchi/turn_outcome.rb +41 -0
  94. data/lib/samagotchi/version.rb +1 -1
  95. data/lib/samagotchi/web/page_routes.rb +13 -8
  96. data/lib/samagotchi/web/public/app.js +12 -18
  97. data/lib/samagotchi/web/public/index.html +11 -2
  98. data/lib/samagotchi/web/public/owner_claim.js +7 -5
  99. data/lib/samagotchi/web/public/page_links.js +1 -1
  100. data/lib/samagotchi/web/public/page_view.js +8 -5
  101. data/lib/samagotchi/web/public/pages.css +9 -2
  102. data/lib/samagotchi/web/public/pages_group.js +21 -19
  103. data/lib/samagotchi/web/public/pages_list.js +73 -0
  104. data/lib/samagotchi/web/public/pages_model.js +54 -0
  105. data/lib/samagotchi/web/public/pages_wiring.js +66 -0
  106. data/lib/samagotchi/web/public/stream_handlers.js +8 -0
  107. data/lib/samagotchi/web/public/views.js +77 -23
  108. data/lib/samagotchi/web/push/notifier.rb +4 -3
  109. data/lib/samagotchi/web/server.rb +3 -1
  110. data/lib/samagotchi/web/session_hub.rb +75 -19
  111. data/lib/samagotchi/worker.rb +6 -4
  112. metadata +20 -1
@@ -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
 
@@ -186,16 +186,22 @@ from saying it twice across restarts). The key's `chi:` prefix keeps sw.js from
186
186
  | `updated` | `chi:updated:<X>` | "chi updated to X" / "chi web and 3 sessions restarted; 1 restarts when idle." + the edited files |
187
187
  | `restart_failed` | `chi:restart_failed:<X>` | "chi X is installed; chi web didn't restart" / why (a failed `--version` preflight, no wrapper), "Restart chi web in its terminal." |
188
188
 
189
- **A disabled schedule's show.** `SessionHub#run_schedule_tick` emits one `schedule_disabled` hub event per
190
- `Schedules::Outcome#disabled` of its tick (`#publish_disabled`, under `@monitor` like `publish_notice`): `{id, title,
191
- kind: skipped|failed, count, reason, session_id, at}`, `session_id` being `Schedules#session_of` (the resolved
192
- target, else the head) and `at` the tick's wall time. The page's event stream passes it to the tabs, which have no
189
+ **A disabled schedule's show.** Any ticker (chi web's, a cron `chi schedule tick`, a `run-now`) that turns a
190
+ recurring schedule off by its budget leaves a `disabled_notice` on its entry (`Schedules#skipped` / `#failed`,
191
+ under the rule `#mark_disabled` shares). The hub claims them with `Schedules#claim_disabled_notices` (a lock-free
192
+ read, then a non-blocking lock that clears each notice before it is emitted: at most once, and once across two chi
193
+ webs, since `@updates_seen` is per process) right after its own tick in `#run_schedule_tick` and once per
194
+ `schedule.tick_interval_minutes` from `#schedule_tick`, auto_tick off too, but never from the seeding
195
+ `scan(tick: false)`, which runs before the Notifier subscribes. `#publish_disabled` emits one `schedule_disabled`
196
+ hub event per claimed notice (under `@monitor` like `publish_notice`): `{id, title, kind: skipped|failed, count,
197
+ reason, session_id, at}`, `session_id` being the resolved target at claim time, else the head, and `at` the
198
+ disabling tick's time. A notice older than a day or whose entry is on again is cleared unpushed. The page's event stream passes it to the tabs, which have no
193
199
  listener. The Notifier shows it with reason `schedule`, key and tag `chi:schedule_disabled:<id>:<at>` (`chi:`: not
194
200
  a waiting key; `<at>`: a later disable shows again; the same event twice shows once, `@updates_seen`), title
195
201
  "Schedule disabled: <title or the id's first 8>", body "skipped 12 times: <reason>" + a line `chi schedule enable
196
202
  <short id>`, url `Notifier.session_url` of the session's summary, `/` when it has none. Two exceptions to the rules
197
203
  above: it is pushed with a page in front (`UNSEEN_ON_PAGE`: the page has no schedules view), and it gets
198
- `UPDATE_TTL` (24 h) like an update. A cron tick or `chi schedule run-now` emits nothing (no hub).
204
+ `UPDATE_TTL` (24 h) like an update. With no chi web running, a cron tick's notice waits in `schedules.json`.
199
205
 
200
206
  `updated` is sent by the **restarted** chi web (its AutoUpdate finds the run at `phase: web`): the exec ends the
201
207
  old process, and `Notifier#stop` does not flush the shows still in their hold, so a push queued just before it would
data/docs/pages.md CHANGED
@@ -14,7 +14,7 @@ Say what you want to see and that you want it kept: "make me a page of …", "I'
14
14
  "keep this as a page". chi follows its shipped pages skill (`skill_pages`, [docs/memory.md](memory.md#skills)): it
15
15
  finds the pages folder with `chi self`, writes `NAME.rb` there, runs `chi page run NAME`, compares the stored rows
16
16
  with where they came from, fixes what failed, and answers in a line or two with the link `[Title](#/p/NAME)` (with
17
- Markdown off, the link is plain text: the page is in All sessions, under Pages). "Change the page …" edits the script
17
+ Markdown off, the link is plain text: the page is under the `pages` pill in chi web's top bar). "Change the page …" edits the script
18
18
  and runs it again; "remove the page …" is `chi page rm NAME`.
19
19
 
20
20
  - It uses `chi page list`, the read tool, `chi page run` and `chi page rm`, never a shell command that names the pages
@@ -77,6 +77,51 @@ the script adds them, at most 20.
77
77
  A rule broken fails the run with a message naming the block and the limit: `table 2: column "cost" has format
78
78
  :percent (use :money or :count)`, `table 1 has 13 columns (at most 12)`.
79
79
 
80
+ ## Reading chi's data: `runtime`
81
+
82
+ From chi 0.189.0 a script has **`runtime`** next to `page`: what chi itself knows, read in the page's own process
83
+ from this chi's code (no `chi` on `PATH`, no second boot, nothing changed). A page that never calls it loads none of
84
+ it. On an older chi `runtime` is a `NameError`, and the run fails with it (the last good result kept).
85
+
86
+ - **`runtime.schedules`**: every durable schedule ([scheduling.md](scheduling.md)), the earliest due first. Each has
87
+ the keys `chi schedule list --all --format json` gives a schedule as methods: `id`, `name` (its title, or the start
88
+ of its prompt in quotes), `title`, `mode`, `prompt`, `recurrence_words`, `next_due`, `last_fired`, `last_result`,
89
+ `enabled`, `state` (`on`, `firing` or `off`), `off_reason` (`owner`, `skips`, `failures`, `done`, `missed` or
90
+ `off`; nil unless off), `skips`, `max_skips`, `failures`, `max_failures`, `skip_window`, `anchor`, `head`,
91
+ `created_at`, `history`: its runs, oldest first, each with `at`, `status`, `detail` and `session_id`, and
92
+ `condition`: its `--if CMD` as `{"cmd", "by", "set_at"}`, nil for none ([Conditions](scheduling.md#conditions---if)).
93
+ Times are ISO 8601 UTC strings, nil when there is none.
94
+ - `runtime.schedules.rows`: every schedule as a table row (all but `history`): `ui.table runtime.schedules.rows,
95
+ columns: { "name" => "Name", "state" => "State" }`.
96
+ - `.warning`: `chi schedule list`'s warning when nothing ticks the schedules, else nil; `.unreadable_ids`: the id of
97
+ each entry of `schedules.json` that doesn't read (nil for one with no id).
98
+ - A `schedules.json` that isn't JSON fails the run with the store's own words (`… is not readable JSON …: fix or
99
+ remove it before changing schedules`). The read takes no lock and writes nothing, though chi's debug log may get a
100
+ line for an entry that doesn't read.
101
+
102
+ `runtime`, like the rest of the page script DSL, is stable for bundles ([plugins.md](plugins.md#stable-for-bundles)).
103
+
104
+ ## Pages from a bundle
105
+
106
+ A bundle can ship pages: its manifest's `pages:` names scripts in its `scripts/` ([plugins.md](plugins.md)), each
107
+ `NAME.rb` the page `NAME`. The shipped **schedules** bundle is one: `chi bundle install schedules` adds a
108
+ **Schedules** page ([scheduling.md](scheduling.md#the-schedules-page)).
109
+
110
+ - A bundle's page is listed and runs as yours does (`chi page list` says `schedules bundle`; its JSON carries
111
+ `bundle` and `script`, the path of the script it runs). It shows in chi web after the next list read (a reload, or
112
+ opening the Pages list): an install isn't watched.
113
+ - **Your own `NAME.rb` replaces it**: with `~/.config/samagotchi/pages/schedules.rb` there, that script runs. That is
114
+ how a bundle's page is made your own: copy its script (`script` in `chi page list --format json`) there and change
115
+ it. Removing your copy brings the bundle's page back, as never ran.
116
+ - **It can't be removed**: `chi page rm schedules` exits 1 with `page schedules comes with the schedules bundle:
117
+ uninstall the bundle or write your own ~/.config/samagotchi/pages/schedules.rb`, and chi web has no Delete for it.
118
+ Uninstalling the bundle takes the page away (its stored result stays on disk, unused).
119
+ - A bundle's page lasts as its installed `manifest.yml` does: one edited since lists no page (chi's debug log says
120
+ `bundle_pages_unread`; `chi bundle status NAME` says the file is edited): reinstall the bundle.
121
+ - A bundle's script runs only as installed: one edited since (or missing) runs nothing, and the run fails with
122
+ `bundle schedules's scripts/schedules.rb differs from the installed one (reinstall the bundle)`.
123
+ - When a chi upgrade changes a bundle's script, the page says "The script changed" until a Refresh.
124
+
80
125
  ## Running
81
126
 
82
127
  - `chi page run NAME` runs the script in a Ruby process of its own and prints a summary of each block: a text's first
@@ -91,21 +136,26 @@ A rule broken fails the run with a message naming the block and the limit: `tabl
91
136
  good result is kept).
92
137
  - One run of a page at a time: a second `chi page run usage` meanwhile exits 1 with `page usage is already running`.
93
138
  - `chi page list` shows each page's title and `ran 2 min ago`, `failed 1 h ago (line 9)` or `(never ran)`, with
94
- `changed` when the script changed since its result was made (the result came from an older script; nothing ran). `chi page rm NAME` removes the script and its result.
139
+ `changed` when the script changed since its result was made (the result came from an older script; nothing ran),
140
+ and the bundle a page comes with. `chi page rm NAME` removes the script and its result (a bundle's page can't be
141
+ removed: [Pages from a bundle](#pages-from-a-bundle)).
95
142
 
96
143
  Exit codes: 0 ran, 1 failed (or no such page, or already running), 2 the command line itself (an unknown flag, a name
97
144
  that breaks the rule). See [the CLI](cli.md#commands).
98
145
 
99
146
  ## In chi web
100
147
 
101
- - **Finding a page.** All sessions has a **Pages** group at its top, in every project scope (pages are global): one row
102
- of cards that scrolls sideways, each with the page's title and `ran 2 min ago`, `failed 1 h ago` or `never ran`. The
103
- search field filters it too, by name and title. With no page (or none the search matches) there is no group. A
104
- `#/p/usage` link in chi's answer opens the page in the same tab; a reload or a copied `…/#/p/usage` link opens it
105
- too.
106
- - **The page** shows in place of the session area: Back (to where it was opened from, else All sessions), the title,
148
+ - **Finding a page.** The top bar has a **`pages`** pill as soon as there is a page, in every view and project scope
149
+ (pages are global), on a desktop and a phone alike; with no page it isn't there. It opens the **Pages list**
150
+ (`#/pages`), in place of the session area: a card per page, each with the page's title and `ran 2 min ago`,
151
+ `failed 1 h ago` or `never ran`; a tap opens the page. The pill appears without a reload when chi makes the first
152
+ page (chi web watches the pages folder), and goes when the last one is removed. A `#/p/usage` link in chi's answer
153
+ opens the page in the same tab; a reload or a copied `…/#/p/usage` link opens it too.
154
+ - **The page** shows in place of the session area: Back (to where it was opened from: "Pages" from the list, "Back"
155
+ from an answer's link; with nowhere to go back to, the Pages list), the title,
107
156
  when it ran and how long it took, **Refresh** and `⋯` with Delete (it asks once, then removes the script and its
108
- result). Opening it shows the stored result at once and runs nothing.
157
+ result, then shows the Pages list; a bundle's page has no `⋯`). Opening it shows the stored result at once and runs
158
+ nothing.
109
159
  - **Refresh** runs the script as `chi page run` does and redraws when the run ends; the button reads "Running…" and
110
160
  can't be pressed twice. A run already going (from a terminal, another tab) says "already running". Stopping chi web
111
161
  stops a Refresh. A Refresh holds its request until the run ends, up to about 32 s (the 30 s cut and its grace): behind
@@ -119,12 +169,15 @@ that breaks the rule). See [the CLI](cli.md#commands).
119
169
  a tap opens the rest as label and value lines; rows keep the script's order there.
120
170
  - **A walk** is drawn by the same widget as in an answer; its lanes scroll sideways inside it.
121
171
  - **Markdown off** (`web.markdown`, the default): a text block shows as plain text, and a link in chi's answer is plain
122
- text too, so the Pages group is the way in. A fenced block inside a text block (a `chi-ui` or a mermaid one) stays
172
+ text too, so the `pages` pill is the way in. A fenced block inside a text block (a `chi-ui` or a mermaid one) stays
123
173
  source on a page.
124
- - **Not live**: the group is read when All sessions opens, a page when it opens and after its own Refresh or Delete.
125
- A run from a terminal shows after the next open or a reload.
126
- - Pages are the owner's: a participant ([chi share](cli.md)) sees no Pages group, no page, and no page route answers
127
- their link.
174
+ - **What is live**: the list (and with it the pill) is read when chi web opens, when the Pages list, All sessions or a
175
+ page opens, after a Delete, and when a page script is made or removed (a script that writes a file into the pages
176
+ folder, which is its working folder, counts too: each of its runs refreshes the open lists). A page itself is read when it opens and
177
+ after its own Refresh; a run from a terminal shows after the next open or a reload (a first run's "ran" time on the
178
+ list too).
179
+ - Pages are the owner's: a participant ([chi share](cli.md)) sees no `pages` pill, no Pages list, no page, and no page
180
+ route answers their link.
128
181
 
129
182
  ## Where a run happens
130
183
 
@@ -145,7 +198,8 @@ that breaks the rule). See [the CLI](cli.md#commands).
145
198
 
146
199
  ## Where things are stored
147
200
 
148
- - The script: `~/.config/samagotchi/pages/NAME.rb`.
201
+ - The script: `~/.config/samagotchi/pages/NAME.rb`; a bundle's in the bundle's own `scripts/` folder under the system
202
+ memories (`.bundles/NAME/scripts/`).
149
203
  - The result: `~/.local/state/samagotchi/pages/NAME/output.json` (`$XDG_STATE_HOME`): the title, the blocks of the last
150
204
  good run, when it ran, how long it took, the sha256 of the script that made it, and the last failure since, if any.
151
205
  Its shape is in [internals/pages.md](internals/pages.md).
data/docs/peers.md CHANGED
@@ -93,6 +93,9 @@ run it. `peer.turns: 0` means a peer's message never wakes chi. `context.wake` i
93
93
  (`serial`, `offset`, `limit`), which pages it.
94
94
  - 200 messages chi hasn't read: further says are refused until it reads them.
95
95
  - The mailbox keeps every message chi hasn't taken, and the newest 50 it has.
96
+ - A continued message is cut at 4 KiB in the new link; run `chi peer ls <previous id>` to read the rest.
97
+ - A `chi peer say` sent at the very moment of a continue may stay with the previous session; run
98
+ `chi peer ls <previous id>` to read it there.
96
99
 
97
100
  ## Continuing a session
98
101
 
data/docs/plugins.md CHANGED
@@ -1737,6 +1737,26 @@ block_renderers:
1737
1737
  side and 100M px. Over that, or if the image doesn't decode, the block stays source. The
1738
1738
  layers and the residual risk are in [internals/block-renderers.md](internals/block-renderers.md).
1739
1739
 
1740
+ ## Pages
1741
+
1742
+ A bundle can ship [pages](pages.md): Ruby scripts the page runner runs, listed under `pages:` (from chi 0.189.0).
1743
+
1744
+ ```yaml
1745
+ # manifest.yml
1746
+ scripts:
1747
+ schedules.rb: sha256:… # scripts/schedules.rb in the bundle
1748
+ pages: [schedules.rb] # scripts: keys named NAME.rb: the page NAME
1749
+ ```
1750
+
1751
+ - Each is a `scripts:` file, so it installs and checks as any script does, and one changed after the install runs
1752
+ nothing until the bundle is reinstalled (a `--dev` install's links aren't checked).
1753
+ - chi web lists them from the install records, running no plugin. The first installed bundle (by name) with a page
1754
+ name has it; a bundle whose `requires_chi` this chi doesn't meet has none.
1755
+ - The owner's own `NAME.rb` in the pages folder replaces a bundle's page, and a bundle's page can't be removed but
1756
+ by uninstalling the bundle ([Pages from a bundle](pages.md#pages-from-a-bundle)).
1757
+ - The script is a page script like any other: `page`, `ui` and `runtime` ([pages.md](pages.md)). The shipped
1758
+ schedules bundle is the example (`lib/samagotchi/bundles/schedules/`).
1759
+
1740
1760
  ## Stable for bundles
1741
1761
 
1742
1762
  Bundles normally use only `chi.*` and `ctx`; the constants, helpers and manifest
@@ -1789,7 +1809,7 @@ that calls it, or for a real external bundle that does. No method on the chance
1789
1809
  7. **The manifest schema**: the manifest's keys and shapes, as [A bundle with a plugin](#a-bundle-with-a-plugin)
1790
1810
  and [bundles.md](bundles.md) document them — `name`, `version`, `scope`, `description`, `files`, `hooks`,
1791
1811
  `trust_level`, `plugin`, `requires_chi`, `requires_chi_next` (shipped bundles only: the release tooling
1792
- reads it, chi doesn't), `needs`, `scripts`, `context_providers`, `block_renderers`, `includes`,
1812
+ reads it, chi doesn't), `needs`, `scripts`, `context_providers`, `block_renderers`, `pages`, `includes`,
1793
1813
  `session_settings`, `settings`. Those are `BundleManifest::KEYS`; `BundleManifest::SINCE` is the chi release each
1794
1814
  key or shape first worked in, and the docs don't copy it — the code is its truth.
1795
1815
  - A key keeps its meaning. A new key gets a `SINCE` entry and a CHANGELOG line, and an older chi says
@@ -1801,6 +1821,10 @@ that calls it, or for a real external bundle that does. No method on the chance
1801
1821
  There is no `api_version:`.
1802
1822
  - `block_renderers:`, the frame's `chi.defineRenderer` and `chi.features` (`regions`: `render` may return
1803
1823
  `{ svg, regions }`) ([Block renderers](#block-renderers)) are part of it. Neither is Ruby, so the scan below doesn't see them.
1824
+ - `pages:` and the page script DSL a bundle's page (or anyone's) is written in: `page`, `ui.text` / `ui.table` /
1825
+ `ui.walk`, and `runtime` with what it returns (`runtime.schedules`: its members, `rows`, `warning`,
1826
+ `unreadable_ids`, `Pages::Runtime::Unreadable`) ([pages.md](pages.md)). A page runs in the page runner, not as a
1827
+ plugin, so the scan below doesn't see it either.
1804
1828
 
1805
1829
  `Samagotchi::Testing::Boundary::ALLOWED` is the checked copy of items 1-6,
1806
1830
  and `Boundary::EXCEPTIONS` the per-bundle list of what each shipped bundle
data/docs/releasing.md CHANGED
@@ -13,7 +13,7 @@ can run the whole release; the user approves the notes before the tag and the
13
13
  and `rake release:check` enforce it). The system bundle upgrades itself when
14
14
  chi starts.
15
15
  - **Every other shipped bundle** (btw, check-in, guardrails, known-names,
16
- loop-guard, mcp, skills, slow-commands, agents-md, cost-cap, work-cap, source-links, github-pr, coordinator, claude-peer, codex-peer, ruby, model-notes, decision-card, inline-widgets, web-search, and the profiles core and dev) has its own semver in its
16
+ loop-guard, mcp, skills, slow-commands, agents-md, cost-cap, work-cap, source-links, github-pr, coordinator, claude-peer, codex-peer, ruby, model-notes, decision-card, inline-widgets, web-search, schedules, and the profiles core and dev) has its own semver in its
17
17
  `manifest.yml` and, when it needs a newer chi, a `requires_chi:` line. They never upgrade by themselves: users run
18
18
  `chi update` (all of them, with the gem) or `chi bundle upgrade NAME`. So:
19
19
  - a change to a bundle's files bumps that bundle's `version:`