samagotchi 0.166.0 → 0.167.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -1
  3. data/docs/architecture.md +1 -0
  4. data/docs/cli.md +10 -5
  5. data/docs/configuration.md +1 -0
  6. data/docs/guardrails.md +6 -5
  7. data/docs/hooks.md +4 -6
  8. data/docs/internals/bundles.md +2 -4
  9. data/docs/internals/engine.md +4 -5
  10. data/docs/internals/objectives.md +141 -9
  11. data/docs/internals/remote-sessions.md +5 -6
  12. data/docs/internals/web-frontend.md +30 -25
  13. data/docs/memory.md +1 -2
  14. data/docs/sessions.md +20 -2
  15. data/docs/testing.md +4 -3
  16. data/lib/samagotchi/bridge.rb +1 -1
  17. data/lib/samagotchi/bundle_command/installed_check.rb +2 -14
  18. data/lib/samagotchi/bundle_command.rb +19 -11
  19. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  20. data/lib/samagotchi/cli/command.rb +10 -0
  21. data/lib/samagotchi/compat.rb +3 -11
  22. data/lib/samagotchi/config.rb +3 -0
  23. data/lib/samagotchi/context_command.rb +2 -1
  24. data/lib/samagotchi/engine/objectives.rb +20 -1
  25. data/lib/samagotchi/engine/side_requests.rb +3 -2
  26. data/lib/samagotchi/engine/turn_end.rb +4 -1
  27. data/lib/samagotchi/engine.rb +3 -0
  28. data/lib/samagotchi/extension_load.rb +2 -26
  29. data/lib/samagotchi/guardrails/approvals.rb +36 -13
  30. data/lib/samagotchi/jsonl_store.rb +61 -0
  31. data/lib/samagotchi/memory_bundle/status.rb +3 -15
  32. data/lib/samagotchi/memory_bundle/system_bundle.rb +16 -10
  33. data/lib/samagotchi/memory_command.rb +4 -2
  34. data/lib/samagotchi/objectives.rb +43 -14
  35. data/lib/samagotchi/objectives_backing.rb +124 -0
  36. data/lib/samagotchi/objectives_check.rb +19 -126
  37. data/lib/samagotchi/objectives_command.rb +14 -7
  38. data/lib/samagotchi/objectives_record.rb +104 -0
  39. data/lib/samagotchi/objectives_track.rb +353 -0
  40. data/lib/samagotchi/push_command.rb +2 -1
  41. data/lib/samagotchi/remote_command.rb +2 -1
  42. data/lib/samagotchi/reply_wait/poll.rb +6 -6
  43. data/lib/samagotchi/reply_wait.rb +4 -24
  44. data/lib/samagotchi/schedule_command.rb +6 -0
  45. data/lib/samagotchi/schedules.rb +1 -1
  46. data/lib/samagotchi/session_access/remote.rb +3 -5
  47. data/lib/samagotchi/session_commands.rb +1 -1
  48. data/lib/samagotchi/sessions_command.rb +12 -6
  49. data/lib/samagotchi/share_command.rb +2 -1
  50. data/lib/samagotchi/tool_activity.rb +11 -1
  51. data/lib/samagotchi/tool_declarations.rb +5 -1
  52. data/lib/samagotchi/tools/objectives_tool.rb +19 -2
  53. data/lib/samagotchi/turn_stages/objectives.rb +46 -3
  54. data/lib/samagotchi/version.rb +1 -1
  55. data/lib/samagotchi/web/participant_access.rb +1 -1
  56. data/lib/samagotchi/web/public/app.js +52 -424
  57. data/lib/samagotchi/web/public/copy.js +2 -1
  58. data/lib/samagotchi/web/public/index.html +35 -9
  59. data/lib/samagotchi/web/public/info_bar_model.js +3 -1
  60. data/lib/samagotchi/web/public/no_contact_fill.js +29 -0
  61. data/lib/samagotchi/web/public/objectives.css +14 -0
  62. data/lib/samagotchi/web/public/objectives_moves.js +82 -9
  63. data/lib/samagotchi/web/public/objectives_state.js +42 -0
  64. data/lib/samagotchi/web/public/objectives_strip.js +33 -9
  65. data/lib/samagotchi/web/public/objectives_track.js +52 -0
  66. data/lib/samagotchi/web/public/objectives_wiring.js +16 -1
  67. data/lib/samagotchi/web/public/participant.html +1 -1
  68. data/lib/samagotchi/web/public/participants_panel.js +14 -7
  69. data/lib/samagotchi/web/public/question_cards.js +7 -12
  70. data/lib/samagotchi/web/public/resync_reach.js +10 -6
  71. data/lib/samagotchi/web/public/scope.js +3 -3
  72. data/lib/samagotchi/web/public/session_rename.js +6 -2
  73. data/lib/samagotchi/web/public/session_state.js +1 -1
  74. data/lib/samagotchi/web/public/session_sync.js +249 -0
  75. data/lib/samagotchi/web/public/session_view.js +279 -0
  76. data/lib/samagotchi/web/public/stream_handlers.js +1 -1
  77. data/lib/samagotchi/web/public/tokens.css +2 -2
  78. data/lib/samagotchi/web/public/turn_block.js +8 -0
  79. data/lib/samagotchi/web/public/turn_html.js +1 -1
  80. data/lib/samagotchi/web/public/widget_picks.js +3 -0
  81. data/lib/samagotchi/web/public/working_set_view.js +1 -1
  82. data/lib/samagotchi/web/session_access_routes.rb +4 -15
  83. metadata +10 -1
@@ -10,10 +10,14 @@ only library. Pure modules (`*_model.js`, `session_state.js`, `sessions_list.js`
10
10
  and have `node --test` specs under `spec/web/public/` (happy-dom for the DOM ones); the pages as a whole are covered
11
11
  by `npm run e2e` (`spec/e2e/`). `app.js` has no unit spec.
12
12
 
13
- **`app.js` has a size cap**: `npm run lint` fails past `max-lines` in `eslint.config.js` (counted as `wc -l` counts:
14
- 2000, ratcheted down from 2250 when the versions, the owner's claim links and Verify, the composer's mode and the
15
- strip's hide went into modules of their own, which left room for a few features' wiring). A new feature goes into a module of its own, wired from `app.js` in a few lines; a
16
- refactor that shrinks `app.js` ratchets the cap down with it. Never raise it: extract instead.
13
+ **Every module has a size cap, `app.js` its own**: `npm run lint` fails past `max-lines` in `eslint.config.js`
14
+ (counted as `wc -l` counts, comments and blank lines too). Every `public/*.js` module: 1200 (`samagotchi/module-size`,
15
+ about 10% over the largest, `turn_block.js`), so a module near it splits rather than becoming the next `app.js`.
16
+ `app.js` (`samagotchi/app-size`): 1649, its size plus 50 once the session-open flow went into `session_sync.js` and
17
+ `session_view.js`; ratcheted down from 2000, itself down from 2250 when the versions, the owner's claim links and
18
+ Verify, the composer's mode and the strip's hide went into modules of their own. A new feature goes into a module of
19
+ its own, wired from `app.js` in a few lines; a refactor that shrinks `app.js` ratchets its cap down with it. Never
20
+ raise either: extract instead.
17
21
 
18
22
  **New exports go in new modules.** The static JS is served at unversioned URLs. Today every load revalidates
19
23
  (app.rb `serve_static` sends `Cache-Control: no-cache` with a content ETag, and `sw.js` has no fetch handler), but an
@@ -24,13 +28,13 @@ page. A factory dep a new version stops passing is the same hazard the other way
24
28
  out of `send_turn.js`, `session_actions.js` and `lists_view.js`); a page loaded before keeps all its old modules
25
29
  until a reload, so the risk is a mixed cache, not an open tab. `answer_fold.js`, `details_motion.js`,
26
30
  `turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
27
- `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says reconnecting / can't reach chi web) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
31
+ `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says 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), `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).
28
32
 
29
33
  ## Two pages, two models
30
34
 
31
35
  | Page | Entry | Model |
32
36
  |---|---|---|
33
- | **Owner page**: the start page and a session page | `index.html` → `app.js` | **Render once, then patch.** A session's open (`select` → `resync` → `renderSessionView`) draws the history from `GET /api/sessions/:id`; from then on each stream event changes the DOM in place (`stream_handlers.js`). The DOM *is* the log. The start page is the same app with `store.selected` null. |
37
+ | **Owner page**: the start page and a session page | `index.html` → `app.js` | **Render once, then patch.** A session's open (`session_sync.js` `select` → `resync` → `session_view.js` `renderSessionView`) draws the history from `GET /api/sessions/:id`; from then on each stream event changes the DOM in place (`stream_handlers.js`). The DOM *is* the log. The start page is the same app with `store.selected` null. |
34
38
  | **Participant page**: a review or pair link | `participant.html` → `participant.js` | **Re-read at a turn boundary, then a keyed redraw.** It reads `GET …/review`, draws it, and streams; an event that ends or changes a turn (`reloads`) marks the data stale and the page reads it again. `drawnMessages` keeps a message's node while its signature is unchanged; a small `live` overlay (`participant_model.js applyLive`) draws the running turn on top. |
35
39
 
36
40
  The participant page is **deliberately separate**: it shares leaf modules with the owner page (the annotate bar,
@@ -47,8 +51,8 @@ change.
47
51
  | Holder | What | Who writes | How a change reaches the screen |
48
52
  |---|---|---|---|
49
53
  | **The session store** (`session_store.js`; app.js `store`) | `store.selected` (the open session's id), `store.current` and `store.sessions` (below) | through the store only (see The session store); other modules get getters (`selected: () => store.selected`, `state: () => store.current`) or the store itself (`stream_handlers.js`, `send_turn.js`, `session_actions.js`) | the store runs the redraws that read what changed (below); nobody calls them by hand |
50
- | **app.js module scope**: about 20 top-level `let`s (`streamControl`, `eventsControl`, `pageCapabilities`/`pageEditorUrl`, `resyncsInFlight`/`resyncAgain`, `resyncAttempts`, `scopeError`…) | the page's mode and its streams | app.js only; other modules get getters and hooks | the writer touches the redraw that reads it (`store.touch("infoBar")`: the stream; `version_notices.js` does it for the versions and its `restarting` set), or calls a redraw only it feeds |
51
- | **`store.current`** (`session_state.js`: `emptySessionState` / `sessionStateFrom`; per field: `session_fields.js FIELDS`) | the open session's fields, about 40 (info bar, chips, verdicts, timing, worker, stream cursor) | `store.update` / `setStatus` from app.js, `stream_handlers.js`, `send_turn.js` (`firstPreview`, `owner`), `session_actions.js` (`status`), `owner_verify.js` (`verdicts`, `verifyFresh`); `forgetSession`'s `replaceCurrent`. Two writers in place, on purpose (D8 in `FIELDS`): live_timing.js's `activeTurn`, verdict_fresh.js's running list | the store runs the field's redraws (`FIELDS[key].redraws`) |
54
+ | **app.js module scope**: about a dozen top-level `let`s (`eventsControl`, `pageCapabilities`/`pageEditorUrl`, `scopeError`…); the open session's stream handle and re-read bookkeeping (`streamControl`, `resyncsInFlight`/`resyncAgain`, `resyncAttempts`) are `session_sync.js`'s, in its closure | the page's mode and its streams | their module only; other modules get getters and hooks (`sessionSync.hasStream()`: a stream object, also while it connects, the bar's streaming; `streamLive()`: it delivers) | the writer touches the redraw that reads it (`store.touch("infoBar")`: the stream; `version_notices.js` does it for the versions and its `restarting` set), or calls a redraw only it feeds |
55
+ | **`store.current`** (`session_state.js`: `emptySessionState` / `sessionStateFrom`; per field: `session_fields.js FIELDS`) | the open session's fields, about 40 (info bar, chips, verdicts, timing, worker, stream cursor) | `store.update` / `setStatus` from app.js, `stream_handlers.js`, `session_sync.js`, `session_view.js`, `send_turn.js` (`firstPreview`, `owner`), `session_actions.js` (`status`), `owner_verify.js` (`verdicts`, `verifyFresh`); `forgetSession`'s `replaceCurrent` (`session_view.js`). Two writers in place, on purpose (D8 in `FIELDS`): live_timing.js's `activeTurn`, verdict_fresh.js's running list | the store runs the field's redraws (`FIELDS[key].redraws`) |
52
56
  | **`store.sessions`** (the hub's projection) | every card | `store.update({sessions})` from app.js: `openSessionEvents` (`applySessionEvent`), `refresh` (the list fallback), `addCreatedSession`, `applyView` (re-sorted), `replaceSelectedCard` (`setLiveStatus` through `setStatus`, `readTurnEnd`, `setUsedMemories`), the stream's close (`withoutWorker`); `session_actions.js` (`setSessions`) | the store: `lists` and `infoBar`. **Always a new array**; an entry is replaced, never changed in place. `followSelectedSession` copies the open one's owner and worker (`fieldsFromCard`) and, when not streaming, its status (`setStatus(…, "hub")`) into `store.current` |
53
57
  | **Factory closures**: the `create*` factories (popovers, panels, views) | each component's own state: open-for, busy, error, its own fetched list | the factory | an `onChange` hook back into app.js, or a getter the factory reads at draw time |
54
58
  | **The history DOM** | the conversation as drawn: which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers and long prompts (`.folded`), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
@@ -75,16 +79,16 @@ through the store**, never `current.X = …`:
75
79
  old one writes there alone.
76
80
  - `store.batch(fn)`, `store.touch(name)`, `store.on(name, fn)`: the redraws (below).
77
81
 
78
- The ESLint block `samagotchi/session-writes` (eslint.config.js) enforces it in the seven modules that hold the state
82
+ The ESLint block `samagotchi/session-writes` (eslint.config.js) enforces it in the nine modules that hold the state
79
83
  (app.js, `stream_handlers.js`, `send_turn.js`, `session_actions.js`, `start_page.js`, `working_set_view.js`,
80
- `owner_verify.js`): an
84
+ `owner_verify.js`, `session_sync.js`, `session_view.js`): an
81
85
  assignment, `++`, `delete` or `Object.assign` into `current`, `store.current` or `state()` is an error
82
86
  (`spec/web/public/lint_session_writes.test.js` runs it on a sample). An alias (`const st = state(); st.x = …`) isn't
83
87
  caught: don't write through one.
84
88
 
85
89
  **Read `store.current` fresh after every await.** A `const cur = store.current` held across an await pins the object
86
- from before it, which a session switch (`forgetSession`) may have replaced: app.js's `readTurnEnd`,
87
- `mergeTurnTiming`, `resync` and `refreshTimingFromSession` read it again after each await. Keep `store.sessions`
90
+ from before it, which a session switch (`forgetSession`) may have replaced: app.js's `mergeTurnTiming` and
91
+ `refreshTimingFromSession`, `session_view.js`'s `readTurnEnd` and `session_sync.js`'s `resync` read it again after each await. Keep `store.sessions`
88
92
  reads fresh too.
89
93
 
90
94
  ### Fields and their redraws
@@ -112,13 +116,13 @@ piece a redraw calls exists): `lists` → `lists.render()`, `paintActive` → `l
112
116
  a store write. A value written unchanged redraws nothing (a chunk with the same ctx %).
113
117
 
114
118
  An input the store doesn't hold calls `store.touch(name)` where it changes: `infoBar` for the clock (liveTurn's
115
- `onTick`), the versions and the sessions restarting (`version_notices.js` `notice`, `restart`), the stream (`startStream`, `workerGone`), the working
119
+ `onTick`), the versions and the sessions restarting (`version_notices.js` `notice`, `restart`), the stream (`session_sync.js` `startStream`, `workerGone`), the working
116
120
  set's and the participants' `onChange`, the continue and review in-flight sets
117
121
  (`session_actions.js`); `composer` and `infoBar` for `liveTurn.running` (`setTurnRunning`, with `settingsPanel`:
118
122
  the open ⚙ panel's running-turn note) and at the end of `renderSessionView` (a whole view drawn). Left as they are,
119
123
  on purpose: `composer_mode.js`'s phone-width listener calls its `update()` (the bar doesn't read it),
120
- `strip_hidden.js`'s apply and `applyView` call `updateSessionTitle()`, and `closeStream`/`stream.restart` set
121
- `streamControl = null` without a redraw (a resync or a workerGone follows).
124
+ `strip_hidden.js`'s apply and `applyView` call `updateSessionTitle()`, and `session_sync.js`'s `closeStream`/`restart`
125
+ (the stream handlers' `stream.restart`) drop the stream handle without a redraw (a resync or a workerGone follows).
122
126
 
123
127
  A function that writes more than once batches its synchronous part, so each redraw runs once: `select` (before its
124
128
  `await resync()`), `clearSelection`, the hub's `snapshot` and `session` events, `workerGone`, `setTurnRunning`,
@@ -156,9 +160,10 @@ A page action the open session's worker must support (its sidecar features and a
156
160
  when a field it reads changes (`workerFeatures`, `bridgeUp`), and a gate's `redraw` only when its answer flipped: a
157
161
  restart's hub event that brings the feature enables it, the worker going (`workerGone`'s `bridgeUp = false`) says
158
162
  it's unavailable. `forgetSession` and `renderSessionView` draw the history with the answer already, so they `prime()`
159
- the gates in the batch of their write, and nothing fires. Today two gates: `verify` (Verify fresh on a verdict's
160
- card, `redrawFresh`) and `revise` (the answers' Revise buttons and the composer's Revising chip, `redrawRevise`).
161
- Both refuse only a live worker without the feature — `workerPredates(features, up, feature)` in
163
+ the gates in the batch of their write, and nothing fires. Today three gates: `verify` (Verify fresh on a verdict's
164
+ card, `redrawFresh`), `revise` (the answers' Revise buttons and the composer's Revising chip, `redrawRevise`) and
165
+ `objectivesTrack` (the objectives' Where are we?, in the list and on the no-move line, `objectives.redraw`).
166
+ All refuse only a live worker without the feature — `workerPredates(features, up, feature)` in
162
167
  `worker_features.js`, the rule both gates share: a worker that isn't up is woken by the send as a new one, which
163
168
  has it. A new action that needs a worker feature is one more entry.
164
169
 
@@ -190,7 +195,7 @@ The redraws, by their store names:
190
195
  `store.sessions`.
191
196
  - `featureGates`: the gates above.
192
197
 
193
- `forgetSession()` is the one reset: `select` and `clearSelection` both call it, so anything per-session that isn't
198
+ `forgetSession()` (`session_view.js`) is the one reset: `select` and `clearSelection` both call it, so anything per-session that isn't
194
199
  in `store.current` (capabilities, the markdown warning and tip, the init row, the Verify claim, the armed Revise,
195
200
  the running turn's DOM) is cleared there, and the feature gates are primed for the empty session. A new per-session holder
196
201
  (an armed composer anchor like the Verify claim or the Revise) goes into it. The armed Verify claim is
@@ -268,7 +273,7 @@ sheet's offset (`chip_popover.js place`: 8px above the indicator, or a keyboard'
268
273
  toast's fallback place (in a session `--toast-bottom` already sits it above the card), the lightbox's padding and the
269
274
  signed-out banner (`auth_lost.js`, `env()` itself: the participant page has no `--safe-*`). A new fixed or bottom-anchored
270
275
  piece reads `--safe-*`, never `env()`: the e2e set the names by hand (`web.spec.js`, a portrait phone and a landscape one),
271
- as Chromium has no insets. The theme-color metas are tokens.css's `--bg` per theme (`theme.test.js` pins them).
276
+ as Chromium has no insets. The theme-color metas are tokens.css's `--bg-top` per theme up to 600px wide (a phone's page starts from that colour at its top edge, so the status bar meets the top bar with no seam), else its `--bg` (`theme.test.js` pins them). An iOS 26 Home Screen app ignores them for the status bar strip: it paints the strip in the body's `background-color`, so a phone's body gradient keeps a `--bg-top` colour layer under it (black strip without one).
272
277
 
273
278
  ## The stage's height
274
279
 
@@ -328,7 +333,7 @@ generation age, `delivery_line.js genAge`) reads "thinking quietly 0:50 · no to
328
333
  A phone shows the short text. Nothing is said while a tool runs (its own clock, `.ts-tool-clock`, from 10 s instead),
329
334
  a blocking card waits, the live timing line has a note (a retry, plugins' setup: `live_timing.js note`), the turn has
330
335
  ended, or for 5 s after the page shows again (`visibilitychange`). The open session's stream not live for a second
331
- (`streamControl` gone: `workerGone` until the resync streams again) reads "reconnecting… · events paused" and wins.
336
+ (`session_sync.js`'s stream handle gone: `workerGone` until the resync streams again) reads "reconnecting… · events paused" and wins.
332
337
  It ticks on the live timing line's clock (app.js `createLiveTurn`'s `onTick` → `turnDom.tick`; 200 ms, then 1 s) and
333
338
  writes only when its text changes. Expanded, it is a right-aligned span in the now row, its tint by level
334
339
  (`.ts-now[data-stall]`); where the now row doesn't show (a collapsed stage, a plain turn's), its short text follows
@@ -346,9 +351,9 @@ dropped. **`latest.js`** is the guard:
346
351
  ask out stale (a close, a reset). For a list that is re-read.
347
352
 
348
353
  On it: `context_chips.js`, `project_picker.js`, `participants_panel.js` (`load`), `cards_place.js`
349
- (`refreshCardBodies`), `stream_handlers.js` (`answer_display`), `working_set_view.js` (`fetchServer`) and app.js's
350
- turn-end re-reads (`readTurnEnd`, `refreshTimingFromSession`, `mergeTurnTiming`) and init-row timers. Still by hand
351
- (the id decides more than "drop it"): app.js `resync`/`retryResync` (the re-read budget, `resyncAgain`), the stream's
354
+ (`refreshCardBodies`), `stream_handlers.js` (`answer_display`), `working_set_view.js` (`fetchServer`), the
355
+ turn-end re-reads (`session_view.js` `readTurnEnd`, app.js's `refreshTimingFromSession`, `mergeTurnTiming`) and app.js's init-row timers. Still by hand
356
+ (the id decides more than "drop it"): `session_sync.js` `resync`/`retryResync` (the re-read budget, `resyncAgain`), the stream's
352
357
  close, `session_actions.js` (continue/review open another session on purpose), `send_turn.js` (a failure for another
353
358
  session becomes a toast), and `participant.js` (its own `loadSeq`, the separate page). A new await in a component
354
359
  uses `latest.js`.
@@ -368,7 +373,7 @@ uses `latest.js`.
368
373
  |---|---|---|
369
374
  | 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` |
370
375
  | A second hub stream, unscoped | `notifications.js` (`allEvents`) on a project's page | the Home Screen app's device tidy-up across projects |
371
- | The open session, `GET /api/sessions/:id/stream?from_seq=` (`data.js openStream`) | app.js `startStream` from `store.current.streamSeq` | events → `stream_handlers.js`. It closes itself on an error; the page resyncs (`resync`: a fresh render and a new stream from its cursor), once at once when it had opened, else after `STREAM_RETRY_MS`. Meanwhile a turn the stage holds reads "reconnecting…" (Quiet, under Frames), and the Bridge's `: ping` is invisible to the page. A re-read that can't reach chi web keeps the history it drew (`resync_reach.js`): the session bar's status chip says "reconnecting…" while `retryResync` tries, "can't reach chi web" once the tries ran out (`store.current.reach`), and any hub event for the session then re-reads it (`followSelectedSession`); the next drawn re-read clears it. Only a first load (select's "Loading…") shows the error in the history |
376
+ | 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 |
372
377
  | The participant stream | `participant.js connect` | listens for `STREAM_EVENTS`, which is `Web::ParticipantView::EVENTS` (checked by `spec/web/participant_view_spec.rb`); reopened from fresh data when CLOSED |
373
378
 
374
379
  A new event type for the owner page is a handler in `stream_handlers.js` (the participant view spec makes it decide
data/docs/memory.md CHANGED
@@ -631,8 +631,7 @@ memory still marked as behind an earlier upgrade keeps its mark either way.
631
631
  - **`chi bundle status`** says per file what is `modified` (the uninstall's
632
632
  rule above: edited, or with nothing recorded to tell), `missing` or
633
633
  `unreadable`, and that a file stays behind and why. Its `issues=` counts files
634
- behind, missing or unreadable (and a plugin that won't load, or class-file hooks an older chi installed, which no
635
- longer load: `Hooks (N): not loaded`), not edits. `chi bundle status NAME`
634
+ behind, missing or unreadable (and a plugin that won't load), not edits. `chi bundle status NAME`
636
635
  lists the bundle's guardrail rules and scripts too (`Rules (N):`, `Scripts (N):`),
637
636
  each `[ok]`, `[missing]` or `[modified]`: edited, so the next install or upgrade
638
637
  replaces it, its copy kept in the trash. An edited or missing rule doesn't load
data/docs/sessions.md CHANGED
@@ -213,7 +213,11 @@ refuses a note. See [cli.md](cli.md#session-objectives) for the commands and
213
213
  [internals/objectives.md](internals/objectives.md) for the mechanism.
214
214
 
215
215
  The model can record a **move** with the `objectives` tool: a line on what it did or found for an objective, with
216
- optional evidence. A move shows as the tool's row in the turn, and `/objectives` shows each objective's latest one under
216
+ optional evidence and a state: `progress` (the default), `blocked` or `done`. `done` is the agent's claim, not a status:
217
+ the page and `/objectives` say "claims done" (or "blocked") beside the move, and you still mark it done yourself. chi
218
+ reads what the move's own turn ran before it: a done move whose last command failed, or that edited files again after a
219
+ command checked its edits, is marked `not backed: …` (muted, information only). A turn with no command marks nothing. A move
220
+ shows as the tool's row in the turn, and `/objectives` shows each objective's latest one under
217
221
  it. It is information only: only you change the list or a status, and it never approves anything. A move costs one
218
222
  generation when it's the step's only call. On a kit that doesn't declare the tool, `/toolkit add objectives` declares it
219
223
  (the model can also reach it with `call_tool`). A participant's turn is denied it.
@@ -232,13 +236,27 @@ A second tap while one runs asks nothing. Its cost is in the session's side line
232
236
  local server it answers after the running request. A participant can't reach it. See
233
237
  [internals/objectives.md](internals/objectives.md#check-this).
234
238
 
239
+ **The tracker** (`/objectives track`, or **Where are we?** in the web) is Check this for the whole list: one side request
240
+ reads the same record and answers one line per active objective, `done`, `progress`, `blocked` or `no sign`, with what in
241
+ the record shows it. It reads at most 8 active objectives (it says how many it left out), on the same model as Check
242
+ this. The lines come as a card and as `track: …` under each objective, beside the agent's own moves: where they disagree
243
+ (the agent claims done, the tracker sees no sign) is the thing to look at. A reading goes stale once the objective is
244
+ reworded or the conversation moves on. With `objectives.tracker: on` it also runs by itself after a turn of yours (a
245
+ prompt or a wake, not a participant's, not a `--non-interactive` run) that edited, wrote or ran a command and recorded no
246
+ move, while an objective is active; your next turn cancels a read still out. **With a hosted `objectives.check_model`
247
+ that sends up to 24,000 characters of the session's record off the machine after such a turn, without a tap.** It is
248
+ information only, as Check this is, can't open a file or run anything, and is refused during a participant's turn. See
249
+ [internals/objectives.md](internals/objectives.md#the-tracker).
250
+
235
251
  **In the web** a session with a list has a strip above the conversation: its objectives and how many are done (a phone
236
252
  shows one line, the one being worked on). A tap opens the list, where you add, mark done, drop, undo and tap a text to
237
253
  reword it, with no message and no turn. Mid-turn the strip has the change and says it applies after this turn. Each list
238
254
  in the conversation shows as pills, or as one line of what you changed. A turn's moves show as chips above its answer;
239
255
  Not yet on one (or in the list, for an objective with a move) sends `Not yet on O2 (…).` as a normal message. With the
240
256
  [decision-card](bundles.md#the-decision-card-bundle) bundle, the newest long answer offers its Short version in a card,
241
- which enters no history. A session with no list shows none of this. A participant doesn't see the list.
257
+ which enters no history. The newest turn that edited, wrote or ran a command and recorded no move says `no move
258
+ recorded` under its steps while an objective is active (information only; nothing asks the model for one). A session
259
+ with no list shows none of this. A participant doesn't see the list.
242
260
 
243
261
  ## Notes a turn leaves for the model
244
262
 
data/docs/testing.md CHANGED
@@ -22,7 +22,7 @@ with two rules only, `no-undef` (a name used but never imported or declared: a d
22
22
  style pass: add a rule only for a bug class it would have caught. It runs in about 2 s, in CI's `npm test` job and in
23
23
  `rake release:check`; `rake lint` stays RuboCop alone (CI's rubocop job has no node). A name that is also a browser
24
24
  global (`name`, `status`, `open`…) passes even when its import is gone: give an export such a name only with care.
25
- It also caps `app.js`'s size (`max-lines`; see docs/internals/web-frontend.md).
25
+ It also caps every web module's size and `app.js`'s own, lower (`max-lines`; see docs/internals/web-frontend.md).
26
26
  It also checks `spec/e2e/` for two things: `no-unused-vars`, and the Playwright twin of `Samagotchi/SpecSleep`: no `page.waitForTimeout`.
27
27
  Wait for the state (a locator's `expect`, `data-phase`, an animation's end through `waitForFunction`); time the page
28
28
  keeps (a pointer's dwell, a hold) runs on Playwright's `page.clock` (`install`, then `pauseAt` and `runFor`: the
@@ -158,8 +158,9 @@ continue's `context/sessions/<id>/left.json`, stored approvals
158
158
  (`guardrails/approvals.json`), and a participant's grant
159
159
  (`web-grants/grants.json`) with its `participants.json` sidecar, and the chi
160
160
  home (`home.json`). A corpus from
161
- 0.164.0 or before has none of those and skips them; a later one must hold them. 0.165.0's approvals (a list) are
162
- also read as recorded and wrapped in a versioned store, the shape a later chi writes.
161
+ 0.164.0 or before has none of those and skips them; a later one must hold them. 0.165.0's and 0.166.0's approvals (a list)
162
+ are also read from a copy as recorded (the read rewrites it versioned) and wrapped in a versioned store, the shape a
163
+ later chi writes; the corpus is always read from a copy, since a reader may rewrite what it reads.
163
164
  A corpus recorded after 0.165.0 also holds `wire/`: a worker's replies to `GET state`, `snapshot` (after a turn, and
164
165
  mid-turn with a prompt queued behind it) and `tail`, each `{route, status, body}`, and the session file it saved,
165
166
  recorded from a real Engine and Bridge (`script/release/compat_wire.rb`, `CompatWire`: a scripted kernel, read over the
@@ -761,7 +761,7 @@ module Samagotchi
761
761
  FEATURES = ["restart", "task_stop", "reparent", Delivery::QUEUE_FEATURE, ReplyWait::TURN_IDS_FEATURE,
762
762
  VerifyAnchor::FEATURE, ReviseAnchor::FEATURE,
763
763
  SessionInbox::UNQUEUE_FEATURE, Delivery::REVIEW_FEATURE, Delivery::PAIR_FEATURE, TurnDrawings::FEATURE,
764
- WorkerLink::ACTIVITY_FEATURE].freeze
764
+ WorkerLink::ACTIVITY_FEATURE, ObjectivesTrack::FEATURE].freeze
765
765
 
766
766
  # The routes, by method and what follows /session/:id/: a handler takes
767
767
  # the session id and the request body and returns [headers, status, body].
@@ -59,9 +59,8 @@ module Samagotchi
59
59
 
60
60
  # What the child sends: an edited file, which the copy's own shas can't
61
61
  # tell, a manifest key that doesn't parse (the copy holds the mirror's
62
- # value or none: InstalledManifest#key_problems), the class-file hooks
63
- # the record still has (they don't load), and Check's warnings and
64
- # errors, naming the installed bundle's folder rather than the copy's.
62
+ # value or none: InstalledManifest#key_problems), and Check's warnings
63
+ # and errors, naming the installed bundle's folder rather than the copy's.
65
64
  def answer_of(bundle)
66
65
  edited = MemoryBundle::ShippedUpdate.edited_executables(bundle.name, bundle).map do |file|
67
66
  Check::Finding.new(level: :warn, code: :edited, file: file, line: nil, fix: "chi bundle upgrade #{bundle.name}, or reinstall it",
@@ -70,7 +69,6 @@ module Samagotchi
70
69
  edited += bundle.manifest.key_problems.values.map do |message|
71
70
  Check::Finding.new(level: :error, code: :manifest, file: "manifest.yml", line: nil, message: message, fix: nil)
72
71
  end
73
- edited << retired_hooks(bundle) unless bundle.hooks.empty?
74
72
  edited = edited.map { |finding| { level: finding.level, text: finding.to_s } }
75
73
  installed_dir = MemoryBundle::Provenance.new(name: bundle.name).bundle_dir
76
74
  edited + MemoryBundle::InstalledCopy.with(bundle) do |dir|
@@ -82,16 +80,6 @@ module Samagotchi
82
80
  end
83
81
  private_class_method :answer_of
84
82
 
85
- # A 0.157 record's class-file hooks: they no longer load, and only an
86
- # upgrade from a source that has moved them (or an uninstall) clears it
87
- # (compat shim retired_class_file_hooks: Compat::SHIMS).
88
- def retired_hooks(bundle)
89
- Check::Finding.new(level: :warn, code: :"hooks-retired", file: "hooks/", line: nil,
90
- message: MemoryBundle::Manifest::HooksRetired::WORDS,
91
- fix: "chi bundle upgrade #{bundle.name} once its source hooks from plugin.rb, or chi bundle uninstall #{bundle.name}")
92
- end
93
- private_class_method :retired_hooks
94
-
95
83
  def died(why, prefix: true) = Found.new(level: "error", text: check_line(prefix ? "the check died: #{why}" : why))
96
84
  private_class_method :died
97
85
 
@@ -106,6 +106,9 @@ module Samagotchi
106
106
  chi bundle build --scope system --out ./my-bundle/ identity.md work.md
107
107
  TEXT
108
108
  TRASH_HELP = "Usage: chi bundle trash [--empty] [--dry-run] [--older-than DAYS]"
109
+ STATUS_HELP = "Usage: chi bundle status [<bundle>]"
110
+ DIFF_HELP = "Usage: chi bundle diff <bundle> [file]"
111
+ LIST_HELP = "Usage: chi bundle list"
109
112
 
110
113
  # The subcommands' flags: --help only; a word not starting with -- is
111
114
  # a positional (install's source, -h included). --scope takes whatever
@@ -134,6 +137,8 @@ module Samagotchi
134
137
  f.switch "--dry-run"
135
138
  f.value "--older-than"
136
139
  end
140
+ # status, diff and list take no flag: --help, else an unknown one.
141
+ NO_FLAGS = CLI::Flags.new(help: %w[--help], flag_pattern: /\A--/)
137
142
 
138
143
  # @param argv [Array<String>] the arguments after "bundle"
139
144
  def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr)
@@ -157,7 +162,7 @@ module Samagotchi
157
162
  when "uninstall" then uninstall(@argv[1..])
158
163
  when "status" then status(@argv[1..])
159
164
  when "diff" then diff(@argv[1..])
160
- when "list" then list
165
+ when "list" then list(@argv[1..])
161
166
  when "build" then build(@argv[1..])
162
167
  when "trash" then trash(@argv[1..])
163
168
  when "new" then new_bundle(@argv[1..])
@@ -536,7 +541,10 @@ module Samagotchi
536
541
  end
537
542
 
538
543
  def status(rest)
539
- name = rest.find { |a| !a.start_with?("--") }
544
+ parsed = parse_flags(NO_FLAGS, rest, "status", help: STATUS_HELP)
545
+ return parsed if parsed.is_a?(Integer)
546
+
547
+ name = parsed.args.first
540
548
  require "json"
541
549
  if name
542
550
  st = Samagotchi::MemoryBundle::Status.bundle_status(name)
@@ -573,10 +581,6 @@ module Samagotchi
573
581
  commit = st.provenance.source_commit
574
582
  @stdout.puts " trust_level: #{trust}"
575
583
  @stdout.puts " source_commit: #{commit}" if commit
576
- unless st.retired_hooks.empty?
577
- @stdout.puts " Hooks (#{st.retired_hooks.size}): not loaded: #{Samagotchi::MemoryBundle::Manifest::HooksRetired::WORDS}"
578
- st.retired_hooks.each { |file, state| @stdout.puts " #{file} [#{state}]" }
579
- end
580
584
  print_assets("Rules", st.rules, " (edited after install: not loaded; reinstall the bundle)")
581
585
  print_assets("Scripts", st.scripts, " (edited after install: the next install replaces it, a copy kept in the trash)")
582
586
  if (plugin = st.plugin)
@@ -598,17 +602,15 @@ module Samagotchi
598
602
 
599
603
  st = Samagotchi::MemoryBundle::Status.bundle_status(bname)
600
604
  mods = st.files.values.count { |v| v[:behind] || v[:missing] || v[:unreadable] }
601
- hook_info = st.retired_hooks.empty? ? "" : " hooks=#{st.retired_hooks.size}"
602
605
  plugin = st.plugin
603
606
  mods += 1 if plugin && (plugin[:state] != "ok" || plugin[:requires_failure])
604
- mods += 1 unless st.retired_hooks.empty?
605
607
  # A rule that is missing or edited doesn't load; a script runs edited.
606
608
  mods += st.rules.values.count { |state| state != "ok" } + st.scripts.values.count("missing")
607
609
  mods += 1 if st.scope_error
608
610
  plugin_info = plugin ? " plugin=#{plugin[:file]}" : ""
609
611
  includes = st.provenance.includes
610
612
  includes_info = includes ? " includes=#{includes.join(",")}" : ""
611
- @stdout.puts " #{bname} v#{st.provenance.version}#{dev_label(st.provenance)} scope=#{status_scope(st)} files=#{st.files.size}#{hook_info}#{plugin_info}#{includes_info} issues=#{mods}"
613
+ @stdout.puts " #{bname} v#{st.provenance.version}#{dev_label(st.provenance)} scope=#{status_scope(st)} files=#{st.files.size}#{plugin_info}#{includes_info} issues=#{mods}"
612
614
  end
613
615
  end
614
616
  0
@@ -642,7 +644,10 @@ module Samagotchi
642
644
  def status_scope(st) = st.scope_error ? "#{st.scope} (unknown)" : st.scope
643
645
 
644
646
  def diff(rest)
645
- args = rest.reject { |a| a.start_with?("--") }
647
+ parsed = parse_flags(NO_FLAGS, rest, "diff", help: DIFF_HELP)
648
+ return parsed if parsed.is_a?(Integer)
649
+
650
+ args = parsed.args
646
651
  bname = args[0]
647
652
  file_arg = args[1]
648
653
  if bname.nil? || bname.empty?
@@ -750,7 +755,10 @@ module Samagotchi
750
755
  @stdout.puts File.exist?(current) ? File.read(current) : "(missing)"
751
756
  end
752
757
 
753
- def list
758
+ def list(rest)
759
+ parsed = parse_flags(NO_FLAGS, rest, "list", help: LIST_HELP)
760
+ return parsed if parsed.is_a?(Integer)
761
+
754
762
  listing = Samagotchi::MemoryBundle::Listing
755
763
  shipped = listing.shipped
756
764
  installed = listing.installed(shipped: shipped)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: samagotchi-system
3
- version: 0.166.0
3
+ version: 0.167.0
4
4
  scope: system
5
5
  description: Default system memories — identity, self map, config modification protocol, memory guide and the delegated-session rules
6
6
  files:
@@ -35,6 +35,16 @@ module Samagotchi
35
35
  Exit::USAGE
36
36
  end
37
37
 
38
+ # The one refusal of a --format value the command doesn't print
39
+ # (nil, no --format, is the text). The caller returns what it gives.
40
+ # @param formats [Array<String>] the values the command takes
41
+ # @return [Integer, nil] the usage exit status, or nil for a format it takes
42
+ def format_refusal(format, formats = %w[text json])
43
+ return nil if format.nil? || formats.include?(format)
44
+
45
+ usage_error("unknown format #{format.inspect}: use --format #{formats.join("|")}")
46
+ end
47
+
38
48
  # +argv+ through +flags+ (a Flags), help and usage errors done.
39
49
  # @return [Flags::Result, Integer] the result, or the exit status
40
50
  # after the help (0) or a usage error (2)
@@ -19,18 +19,10 @@ module Samagotchi
19
19
  files: ["lib/samagotchi/bridge/card_store.rb"],
20
20
  what: "CardStore#seed_v1 reads a cards.json from before the turn log; its comment says a retention " \
21
21
  "period after the release that wrote version 2 (0.151.0, 2026-11-05)"),
22
- Shim.new(id: :retired_class_file_hooks, added_in: "0.158.0", remove_after: "0.166.0",
23
- files: ["lib/samagotchi/extension_load.rb", "lib/samagotchi/memory_bundle/status.rb",
24
- "lib/samagotchi/bundle_command/installed_check.rb"],
25
- what: "a 0.157 install record's class-file hooks: announced as not loading, shown and checked until " \
26
- "an upgrade or uninstall clears them (installed state, not protocol)"),
27
- Shim.new(id: :approvals_array_read, added_in: "0.166.0", remove_after: nil,
22
+ Shim.new(id: :approvals_array_read, added_in: "0.166.0", remove_after: "0.167.0",
28
23
  files: ["lib/samagotchi/guardrails/approvals.rb"],
29
- what: "Approvals#parse reads approvals.json as the list 0.165 and before write, beside the versioned store"),
30
- Shim.new(id: :approvals_array_write, added_in: "0.166.0", remove_after: "0.166.0",
31
- files: ["lib/samagotchi/guardrails/approvals.rb"],
32
- what: "Approvals#update writes a list (or no file) back as a list, since a 0.165 reader sets a " \
33
- "versioned store aside; from 0.167 a write is versioned (and the corpus records that)")
24
+ what: "Approvals#parse reads approvals.json as the list 0.165 and before write, beside the versioned " \
25
+ "store, and #version_list rewrites it versioned on that first read")
34
26
  ].freeze
35
27
 
36
28
  module_function
@@ -262,6 +262,9 @@ module Samagotchi
262
262
 
263
263
  # Check this (ObjectivesCheck): a cheap configured model for its one side request; nil is the session's.
264
264
  Entry.new(key: "objectives.check_model", yaml_path: %w[objectives check_model], type: :string, default: nil, expose: %i[config], lifecycle: :next_matching_turn_display_poll_write),
265
+ # The tracker (ObjectivesTrack): on, it also reads the list by itself after an owner's turn that did work and
266
+ # recorded no move (on objectives.check_model); off, only /objectives track and Where are we? do.
267
+ Entry.new(key: "objectives.tracker", yaml_path: %w[objectives tracker], type: :enum, default: "off", expose: %i[config], enum_values: %w[off on], lifecycle: :next_matching_turn_display_poll_write),
265
268
  # System 1 on the objectives (ObjectivesAudit): audit saves a yes/no per active objective on what comes in and goes
266
269
  # out, acted on by nothing; off (no conversation text goes to a System 1 host for it). Host and model: system_one.*.
267
270
  Entry.new(key: "objectives.system_one", yaml_path: %w[objectives system_one], type: :enum, default: "off", expose: %i[config], enum_values: %w[off audit], lifecycle: :next_matching_turn_display_poll_write),
@@ -249,7 +249,8 @@ module Samagotchi
249
249
 
250
250
  def run_ls(options, args)
251
251
  format = options[:format]
252
- return usage_error("unknown format #{format.inspect}: use --format text|json") unless [nil, "text", "json"].include?(format)
252
+ refused = format_refusal(format)
253
+ return refused if refused
253
254
 
254
255
  targets = targets(options, args) or return CLI::Exit::FAILED
255
256
  rows = targets.flat_map { |target| @access.context_entries(target).map { |entry| row(target, entry) } }
@@ -5,7 +5,7 @@ module Samagotchi
5
5
  # The session's objectives (TurnStages::Objectives, forwarded): the view
6
6
  # announced when it changed, the model's proposals kept as cards until
7
7
  # the turn is over, System 1's audit of them (ObjectivesAudit); and
8
- # Check this's side request. Reads @objectives_stage, @side_judgments,
8
+ # Check this's and the tracker's side requests. Reads @objectives_stage, @side_judgments,
9
9
  # @host_registry, @session.
10
10
  module ObjectivesPart
11
11
  # The session's objectives as the page draws them, when that differs
@@ -36,6 +36,15 @@ module Samagotchi
36
36
  cancel_controller: nil, model: model, source: ObjectivesCheck::SOURCE)
37
37
  end
38
38
 
39
+ # The tracker (ObjectivesTrack)'s one side request, under its own kind so
40
+ # /stats counts it apart. +cancel_controller+: the automatic read's, which
41
+ # the owner's next turn cancels (raises LLM::RequestCancelled then).
42
+ # @return [String] the answer
43
+ def ask_objective_track(request, model:, cancel_controller: nil)
44
+ ask_side_model(request, timeout: ObjectivesTrack::TIMEOUT_SECONDS, max_tokens: ObjectivesTrack::MAX_TOKENS,
45
+ cancel_controller: cancel_controller, model: model, source: ObjectivesTrack::SOURCE)
46
+ end
47
+
39
48
  # A change the model proposes (the objectives tool), kept until the turn
40
49
  # is over (TurnStages::Objectives#propose).
41
50
  # @return [Boolean] false past Objectives::PROPOSALS_PER_TURN
@@ -55,6 +64,16 @@ module Samagotchi
55
64
  Log.warn(:turn, "objectives_proposal_failed", error: e.class.name, msg: e.message)
56
65
  end
57
66
 
67
+ # After a completed turn (#complete_turn, beside the stage's outgoing):
68
+ # with objectives.tracker on, the tracker by itself, when the turn did
69
+ # work and recorded no move (TurnStages::Objectives#track). It only
70
+ # informs: a failure is logged.
71
+ def track_objectives_after(turn)
72
+ @objectives_stage.track(turn, engine: self)
73
+ rescue StandardError => e
74
+ Log.warn(:turn, "objectives_track_start_failed", error: e.class.name, msg: e.message)
75
+ end
76
+
58
77
  # The stage over this Engine's side asks (built in #initialize, once
59
78
  # the host registry is). Each call takes its values: the recorder,
60
79
  # the sessions dir, the running conversation.
@@ -41,8 +41,9 @@ module Samagotchi
41
41
  # command's ask_model between turns).
42
42
  # @return [String, nil]
43
43
  def side_author(kind)
44
- # Check this is only ever the owner's, whichever turn runs as it ends.
45
- return nil if kind.to_s == ObjectivesCheck::SOURCE
44
+ # Check this and the tracker are only ever the owner's, whichever turn
45
+ # runs as they end.
46
+ return nil if [ObjectivesCheck::SOURCE, ObjectivesTrack::SOURCE].include?(kind.to_s)
46
47
 
47
48
  # One read each of the published contexts (TurnState): any thread.
48
49
  running = turn_context
@@ -117,7 +117,10 @@ module Samagotchi
117
117
  # a display version of the answer (AnswerDisplay) and event[:refs]
118
118
  # for refs on it (AnswerRefs).
119
119
  session = turn.session
120
- @objectives_stage.outgoing(turn, result, recorder: system_one_recorder) unless canceled || result.exhausted?
120
+ unless canceled || result.exhausted?
121
+ @objectives_stage.outgoing(turn, result, recorder: system_one_recorder)
122
+ track_objectives_after(turn)
123
+ end
121
124
  display = AnswerDisplay.new(session.messages)
122
125
  refs = AnswerRefs.new(session.messages, cwd: session.working_directory)
123
126
  after_turn = { type: :after_turn, status: canceled ? "canceled" : "completed",
@@ -974,6 +974,9 @@ module Samagotchi
974
974
  # cross-thread state is set here and cleared in #release_turn only.
975
975
  def begin_turn(session, prompt, on_event:, cancel_controller:, origin:, continue:, id: nil, verify: nil, revises: nil,
976
976
  input_waiting: nil)
977
+ # The tracker's automatic read still out: any turn's start frees its
978
+ # request first, before this turn's own probes and waits.
979
+ @objectives_stage.cancel_track
977
980
  origin = TurnOrigin.of(origin)
978
981
  # A participant's Verify fresh child: every turn is theirs (their
979
982
  # author, boundary and cap), whoever started it.
@@ -33,15 +33,9 @@ module Samagotchi
33
33
  end
34
34
 
35
35
  # The hooks: config.yml's (Hooks::Loader; an empty Registry without a
36
- # hooks config). An installed record that still has class-file hooks (a
37
- # 0.157 install) adds a not-required failure each, which the Engine
38
- # announces at the first turn: they don't load (#tell_retired_hooks;
39
- # compat shim retired_class_file_hooks: Compat::SHIMS).
36
+ # hooks config).
40
37
  # @return [Hooks::Registry]
41
- def hooks
42
- tell_retired_hooks
43
- hooks_from_config
44
- end
38
+ def hooks = hooks_from_config
45
39
 
46
40
  # Load the installed bundles' plugins into +registries+; one that fails
47
41
  # goes to +failures+, a required one (a guardrail plugin) to the hook
@@ -71,23 +65,5 @@ module Samagotchi
71
65
 
72
66
  Hooks::Registry.new
73
67
  end
74
-
75
- # One failure per record whose hooks: map isn't empty; an empty
76
- # hooks/ dir is not one, nor a manifest.json that doesn't read (the
77
- # plugin loader and the rules report that: a record holding only hooks/
78
- # with an unreadable manifest.json is silent at start, as its hooks
79
- # wouldn't load anyway; `chi bundle status` lists it unreadable).
80
- def tell_retired_hooks
81
- require_relative "memory_bundle/provenance"
82
- MemoryBundle::Provenance.each_installed(holding: :hooks) do |bundle_name, bundle|
83
- next if bundle.error?
84
-
85
- Log.warn(:hooks, "bundle_hooks_retired", bundle: bundle_name, hooks: bundle.hooks.size)
86
- @hook_failures.add("hooks (bundle #{bundle_name})", MemoryBundle::Manifest::HooksRetired::WORDS, required: false)
87
- end
88
- rescue StandardError => e
89
- Log.error(:hooks, "bundles_load_failed", echo: "[samagotchi:hooks] failed to read the installed bundles: #{e.class}: #{e.message}",
90
- error: e.class.name)
91
- end
92
68
  end
93
69
  end