samagotchi 0.145.0 → 0.147.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -1
- data/docs/architecture.md +14 -5
- data/docs/cli.md +6 -3
- data/docs/configuration.md +16 -3
- data/docs/guardrails.md +7 -2
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/engine.md +1 -1
- data/docs/internals/web-frontend.md +3 -2
- data/docs/memory.md +45 -0
- data/docs/sessions.md +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/child_reports.rb +13 -6
- data/lib/samagotchi/guardrails/approval.rb +17 -4
- data/lib/samagotchi/guardrails/parent_approvals.rb +5 -1
- data/lib/samagotchi/guardrails/verdict.rb +5 -3
- data/lib/samagotchi/memory_command.rb +135 -7
- data/lib/samagotchi/memory_paths.rb +9 -0
- data/lib/samagotchi/memory_usage.rb +368 -0
- data/lib/samagotchi/relay.rb +2 -2
- data/lib/samagotchi/tool_activity.rb +3 -3
- data/lib/samagotchi/tool_output_cut.rb +12 -1
- data/lib/samagotchi/toolkit_suggest.rb +7 -4
- data/lib/samagotchi/tools/delegate.rb +88 -13
- data/lib/samagotchi/tools/memory.rb +12 -2
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +2 -2
- data/lib/samagotchi/web/auto_update.rb +60 -5
- data/lib/samagotchi/web/public/app.js +11 -18
- data/lib/samagotchi/web/public/participant_annotate.js +2 -1
- data/lib/samagotchi/web/public/question_cards.js +33 -9
- data/lib/samagotchi/web/public/revise_stack.js +6 -5
- data/lib/samagotchi/web/public/update_notice.js +22 -11
- data/lib/samagotchi/web/public/update_sheet.js +4 -1
- data/lib/samagotchi/web/public/verify_preset.js +5 -1
- data/lib/samagotchi/web/public/worker_features.js +14 -0
- data/lib/samagotchi/web/session_access_routes.rb +1 -1
- data/lib/samagotchi/web/session_hub.rb +17 -4
- data/lib/samagotchi/working_set.rb +3 -2
- metadata +3 -1
|
@@ -45,9 +45,10 @@ function statusText(model) {
|
|
|
45
45
|
|
|
46
46
|
// Both restarts, once a newer chi is installed (an install done here, or the
|
|
47
47
|
// installed notice's toast) and nothing runs: either result keeps the other in reach.
|
|
48
|
+
// Not on an automatic run: it restarts them by itself.
|
|
48
49
|
function restartActions(model) {
|
|
49
50
|
const busy = ["starting", "running", "restarting"].includes(model.state);
|
|
50
|
-
if (!model.restartable || busy) return nothing;
|
|
51
|
+
if (!model.restartable || model.auto || busy) return nothing;
|
|
51
52
|
return html`<button type="button" class="ghost" data-act="restart-workers">Restart workers</button>
|
|
52
53
|
<button type="button" class="ghost" data-act="restart-web">Restart chi web</button>`;
|
|
53
54
|
}
|
|
@@ -125,6 +126,8 @@ export function createUpdateSheet({ dialog, update, restartWorkers, restartWeb }
|
|
|
125
126
|
model = {
|
|
126
127
|
...model,
|
|
127
128
|
...data,
|
|
129
|
+
// A frame names auto only when it is true: this run's word, not the last one's.
|
|
130
|
+
auto: data.auto === true,
|
|
128
131
|
rows: Array.isArray(data.rows) ? data.rows : [],
|
|
129
132
|
};
|
|
130
133
|
if (data.operation === "install" && data.state === "done") restartable = true;
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// module of its own: static JS is cached at unversioned URLs, and a new
|
|
7
7
|
// export on an old module would blank the page.
|
|
8
8
|
|
|
9
|
+
import { workerPredates } from "./worker_features.js";
|
|
10
|
+
|
|
9
11
|
export const VERIFY_PRESET = Object.freeze({
|
|
10
12
|
label: "Verify",
|
|
11
13
|
text: "Verify this claim against the code. If this session's context doesn't settle it, say so. "
|
|
@@ -14,8 +16,10 @@ export const VERIFY_PRESET = Object.freeze({
|
|
|
14
16
|
|
|
15
17
|
export const VERIFY_UNAVAILABLE = "restart this session to use Verify";
|
|
16
18
|
|
|
19
|
+
// The Verify gate (app.js featureGates): a live worker without "verify"
|
|
20
|
+
// predates Verify turns (worker_features.js's rule).
|
|
17
21
|
export function verifyWorkerUnavailable(workerFeatures, bridgeUp) {
|
|
18
|
-
return
|
|
22
|
+
return workerPredates(workerFeatures, bridgeUp, "verify");
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
// +presets+ (annotate_presets.js parsePresets) with Verify after them.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// One rule for the worker-side feature gates: a worker that is up and whose
|
|
2
|
+
// features lack +feature+ predates it (chi web would answer 409
|
|
3
|
+
// <feature>_unavailable), so the page says so instead of offering the action.
|
|
4
|
+
// A worker that isn't up isn't asked: the send wakes a new one that has it.
|
|
5
|
+
// Used by Verify's gate (verify_preset.js) and Revise's (revise_stack.js).
|
|
6
|
+
//
|
|
7
|
+
// A new module: the page's modules are cached at unversioned URLs, and a new
|
|
8
|
+
// export of an old one (docs/internals/web-frontend.md) leaves a cached copy
|
|
9
|
+
// without it.
|
|
10
|
+
|
|
11
|
+
// @return [bool] true only for a live worker without the feature.
|
|
12
|
+
export function workerPredates(workerFeatures, bridgeUp, feature) {
|
|
13
|
+
return bridgeUp === true && Array.isArray(workerFeatures) && !workerFeatures.includes(feature);
|
|
14
|
+
}
|
|
@@ -274,7 +274,7 @@ module Samagotchi
|
|
|
274
274
|
model_name: session_access.show(id).model_name,
|
|
275
275
|
default_model: ModelProfile.default_model_name,
|
|
276
276
|
parent_strategy: strategy_json(session_access.parent_strategy(id)),
|
|
277
|
-
**(@hub&.chi_state || { version: VERSION, installed: nil, available: nil, update_blocked: nil, auto: "off", restart: "idle" }) })
|
|
277
|
+
**(@hub&.chi_state || { version: VERSION, installed: nil, available: nil, update_blocked: nil, auto: "off", restart: "idle", auto_offers: nil }) })
|
|
278
278
|
rescue SessionManager::OwnedByTUI => e
|
|
279
279
|
owned_by_tui(e)
|
|
280
280
|
rescue SessionAccess::Refused => e
|
|
@@ -41,8 +41,7 @@ module Samagotchi
|
|
|
41
41
|
|
|
42
42
|
# What a subscriber gets: `session` with {session: summary} for an
|
|
43
43
|
# upsert, `session_gone` with {id:} for a removal, `chi` with
|
|
44
|
-
#
|
|
45
|
-
# state changes. seq is monotonic per
|
|
44
|
+
# the #chi_state fields when chi version state changes. seq is monotonic per
|
|
46
45
|
# hub, for the log's sake: there is no replay.
|
|
47
46
|
Event = Struct.new(:type, :seq, :data, keyword_init: true)
|
|
48
47
|
|
|
@@ -76,7 +75,7 @@ module Samagotchi
|
|
|
76
75
|
# @param installed_versions [#newest] what is installed (InstalledVersions)
|
|
77
76
|
# @param update_auto [String] update.auto, said in the chi state (the page's wording)
|
|
78
77
|
# @param update_restart [String] update.restart, said beside it (whether
|
|
79
|
-
#
|
|
78
|
+
# a newer installed chi restarts by itself: no Restart toast)
|
|
80
79
|
def initialize(state_dir:, manager: SessionManager, now: nil, scan_interval: SCAN_INTERVAL,
|
|
81
80
|
full_probe_interval: FULL_PROBE_INTERVAL, installed_versions: InstalledVersions.new,
|
|
82
81
|
update_auto: Config.get("update.auto"), update_restart: Config.get("update.restart"))
|
|
@@ -87,6 +86,7 @@ module Samagotchi
|
|
|
87
86
|
@installed = nil
|
|
88
87
|
@available = nil
|
|
89
88
|
@update_blocked = nil
|
|
89
|
+
@auto_offers = nil
|
|
90
90
|
@update_state = nil
|
|
91
91
|
@manager = manager
|
|
92
92
|
@now = now || -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }
|
|
@@ -164,7 +164,7 @@ module Samagotchi
|
|
|
164
164
|
def chi_state
|
|
165
165
|
@monitor.synchronize do
|
|
166
166
|
{ version: VERSION, installed: @installed, available: @available, update_blocked: @update_blocked,
|
|
167
|
-
auto: @update_auto, restart: @update_restart }
|
|
167
|
+
auto: @update_auto, restart: @update_restart, auto_offers: @auto_offers }
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
|
|
@@ -180,6 +180,19 @@ module Samagotchi
|
|
|
180
180
|
nil
|
|
181
181
|
end
|
|
182
182
|
|
|
183
|
+
# AutoUpdate won't (or hasn't, for long) restart onto +version+ by itself:
|
|
184
|
+
# the page offers the restarts for it, in spite of update.auto. In memory:
|
|
185
|
+
# AutoUpdate says it again after a chi web restart.
|
|
186
|
+
def auto_offer_restart(version)
|
|
187
|
+
@monitor.synchronize do
|
|
188
|
+
next if @auto_offers == version
|
|
189
|
+
|
|
190
|
+
@auto_offers = version
|
|
191
|
+
emit("chi", chi_state)
|
|
192
|
+
end
|
|
193
|
+
nil
|
|
194
|
+
end
|
|
195
|
+
|
|
183
196
|
# Publish the owner-triggered update's progress or result for current
|
|
184
197
|
# tabs, and retain the latest state for a reconnect's snapshot.
|
|
185
198
|
def publish_update(state:, rows:, progress: nil, operation: nil, version: nil, auto: false)
|
|
@@ -235,7 +235,8 @@ module Samagotchi
|
|
|
235
235
|
def shared_with(touch, key) = touch.share > 1 ? found_names(touch.run) - [key] : []
|
|
236
236
|
|
|
237
237
|
# A memory_read's names (Tools::MemoryRead.parse_names: none for the
|
|
238
|
-
# index listing), less the ones its output says weren't found.
|
|
238
|
+
# index listing), less the ones its output says weren't found. Public:
|
|
239
|
+
# `chi memory usage` counts reads the same way (MemoryUsage).
|
|
239
240
|
def found_names(run)
|
|
240
241
|
names = Tools::MemoryRead.parse_names(run.call[:content].to_s)
|
|
241
242
|
last = run.text.split(ToolResponse::SEPARATOR).last.to_s
|
|
@@ -308,6 +309,6 @@ module Samagotchi
|
|
|
308
309
|
|
|
309
310
|
def field(hash, key) = hash.key?(key) ? hash[key] : hash[key.to_s]
|
|
310
311
|
|
|
311
|
-
private_class_method :all_touches, :touches, :failed?, :
|
|
312
|
+
private_class_method :all_touches, :touches, :failed?, :shared_with, :item, :still_sent?, :dropped?, :with_id, :changed?, :stamp_of, :field
|
|
312
313
|
end
|
|
313
314
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: samagotchi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.147.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -487,6 +487,7 @@ files:
|
|
|
487
487
|
- lib/samagotchi/memory_command.rb
|
|
488
488
|
- lib/samagotchi/memory_orphans.rb
|
|
489
489
|
- lib/samagotchi/memory_paths.rb
|
|
490
|
+
- lib/samagotchi/memory_usage.rb
|
|
490
491
|
- lib/samagotchi/message_parts.rb
|
|
491
492
|
- lib/samagotchi/message_time.rb
|
|
492
493
|
- lib/samagotchi/model_binding.rb
|
|
@@ -958,6 +959,7 @@ files:
|
|
|
958
959
|
- lib/samagotchi/web/public/verify_card.css
|
|
959
960
|
- lib/samagotchi/web/public/verify_preset.js
|
|
960
961
|
- lib/samagotchi/web/public/verify_target.js
|
|
962
|
+
- lib/samagotchi/web/public/worker_features.js
|
|
961
963
|
- lib/samagotchi/web/public/working_set.js
|
|
962
964
|
- lib/samagotchi/web/public/working_set_rail.js
|
|
963
965
|
- lib/samagotchi/web/public/working_set_view.js
|