samagotchi 0.141.0 → 0.143.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 +111 -7
- data/README.md +2 -1
- data/bin/chi +2 -0
- data/docs/architecture.md +25 -289
- data/docs/bundle-authoring.md +7 -6
- data/docs/bundles.md +1232 -0
- data/docs/cli.md +51 -13
- data/docs/configuration.md +68 -30
- data/docs/context.md +12 -12
- data/docs/guardrails.md +27 -20
- data/docs/hooks.md +28 -9
- data/docs/internals/attached-context.md +225 -0
- data/docs/internals/background-tasks.md +1 -1
- data/docs/internals/bridge.md +380 -0
- data/docs/internals/bundles.md +6 -3
- data/docs/internals/context-telemetry.md +1 -1
- data/docs/internals/engine.md +31 -19
- data/docs/internals/participants.md +13 -12
- data/docs/internals/prompt-caching.md +12 -12
- data/docs/internals/remote-sessions.md +1 -1
- data/docs/internals/{tool-guardrails.md → tool-output-limits.md} +21 -2
- data/docs/internals/web-push.md +1 -1
- data/docs/memory.md +33 -3
- data/docs/plugins.md +127 -1231
- data/docs/sessions.md +51 -27
- data/docs/sub-agent.md +6 -6
- data/docs/system-one.md +122 -0
- data/docs/testing.md +3 -1
- data/lib/samagotchi/bridge.rb +2 -0
- data/lib/samagotchi/bundle_command/api_calls.rb +132 -0
- data/lib/samagotchi/bundle_command/check.rb +50 -34
- data/lib/samagotchi/bundle_command/installed_check.rb +86 -0
- data/lib/samagotchi/bundle_command/scaffold.rb +1 -0
- data/lib/samagotchi/bundle_settings_check.rb +58 -0
- data/lib/samagotchi/bundles/agents-md/manifest.yml +4 -2
- data/lib/samagotchi/bundles/agents-md/plugin.rb +1 -1
- data/lib/samagotchi/bundles/btw/manifest.yml +4 -2
- data/lib/samagotchi/bundles/btw/plugin.rb +1 -1
- data/lib/samagotchi/bundles/check-in/manifest.yml +7 -3
- data/lib/samagotchi/bundles/check-in/plugin.rb +101 -11
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +3 -3
- data/lib/samagotchi/bundles/claude-peer/plugin.rb +1 -1
- data/lib/samagotchi/bundles/claude-peer/scripts/pair +1 -1
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/codex-peer/plugin.rb +1 -1
- data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
- data/lib/samagotchi/bundles/coordinator/plugin.rb +1 -1
- data/lib/samagotchi/bundles/core/manifest.yml +2 -2
- data/lib/samagotchi/bundles/cost-cap/manifest.yml +6 -3
- data/lib/samagotchi/bundles/cost-cap/plugin.rb +5 -7
- data/lib/samagotchi/bundles/github-pr/manifest.yml +3 -1
- data/lib/samagotchi/bundles/known-names/manifest.yml +3 -1
- data/lib/samagotchi/bundles/loop-guard/manifest.yml +4 -2
- data/lib/samagotchi/bundles/loop-guard/plugin.rb +1 -1
- data/lib/samagotchi/bundles/mcp/manifest.yml +4 -2
- data/lib/samagotchi/bundles/mcp/plugin.rb +2 -2
- data/lib/samagotchi/bundles/ruby/manifest.yml +2 -2
- data/lib/samagotchi/bundles/ruby/plugin.rb +1 -1
- data/lib/samagotchi/bundles/skills/manifest.yml +4 -2
- data/lib/samagotchi/bundles/skills/plugin.rb +1 -1
- data/lib/samagotchi/bundles/slow-commands/manifest.yml +4 -2
- data/lib/samagotchi/bundles/slow-commands/plugin.rb +1 -1
- data/lib/samagotchi/bundles/source-links/manifest.yml +3 -1
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +3 -3
- data/lib/samagotchi/bundles/system/manifest.yml +4 -4
- data/lib/samagotchi/bundles/system/memory_guide.md +1 -1
- data/lib/samagotchi/bundles/system/self_map.md +3 -3
- data/lib/samagotchi/bundles/work-cap/manifest.yml +6 -3
- data/lib/samagotchi/bundles/work-cap/plugin.rb +11 -13
- data/lib/samagotchi/config.rb +74 -14
- data/lib/samagotchi/context_candidate_choice.rb +20 -3
- data/lib/samagotchi/context_candidates.rb +4 -1
- data/lib/samagotchi/context_candidates_log.rb +36 -1
- data/lib/samagotchi/context_judge.rb +6 -2
- data/lib/samagotchi/context_status.rb +1 -2
- data/lib/samagotchi/engine.rb +96 -70
- data/lib/samagotchi/extension_load.rb +11 -4
- data/lib/samagotchi/guardrail_wiring.rb +36 -31
- data/lib/samagotchi/guardrails/chi_dirs.rb +7 -4
- data/lib/samagotchi/guardrails/path_resolve.rb +1 -1
- data/lib/samagotchi/guardrails/protected_paths.rb +7 -4
- data/lib/samagotchi/guardrails_command.rb +3 -3
- data/lib/samagotchi/hook_routes.rb +37 -2
- data/lib/samagotchi/hooks/bundle_loader.rb +20 -4
- data/lib/samagotchi/hooks/registry.rb +23 -5
- data/lib/samagotchi/host_model.rb +3 -3
- data/lib/samagotchi/host_registry.rb +14 -7
- data/lib/samagotchi/judgments_command.rb +155 -0
- data/lib/samagotchi/kernel_loop.rb +20 -3
- data/lib/samagotchi/llm/chat_loop.rb +79 -10
- data/lib/samagotchi/llm/errors.rb +7 -5
- data/lib/samagotchi/llm/stray_tool_call.rb +68 -0
- data/lib/samagotchi/log_line.rb +1 -1
- data/lib/samagotchi/memory_bundle/builder.rb +4 -2
- data/lib/samagotchi/memory_bundle/entry_size.rb +100 -0
- data/lib/samagotchi/memory_bundle/installed_bundle.rb +9 -2
- data/lib/samagotchi/memory_bundle/installed_copy.rb +92 -0
- data/lib/samagotchi/memory_bundle/installer.rb +2 -0
- data/lib/samagotchi/memory_bundle/manifest.rb +23 -13
- data/lib/samagotchi/memory_bundle/provenance.rb +4 -1
- data/lib/samagotchi/memory_bundle/shipped_update.rb +13 -1
- data/lib/samagotchi/model_catalog.rb +3 -2
- data/lib/samagotchi/models_command.rb +1 -1
- data/lib/samagotchi/plugin/api.rb +41 -7
- data/lib/samagotchi/plugin/context.rb +59 -1
- data/lib/samagotchi/plugin/judgments.rb +72 -0
- data/lib/samagotchi/plugin/loader.rb +6 -3
- data/lib/samagotchi/plugin/peer.rb +17 -22
- data/lib/samagotchi/plugin_session_state.rb +32 -5
- data/lib/samagotchi/prompt_warmup.rb +1 -9
- data/lib/samagotchi/run_options.rb +1 -0
- data/lib/samagotchi/self_report.rb +36 -0
- data/lib/samagotchi/session_access/contract.rb +1 -1
- data/lib/samagotchi/session_access/local.rb +1 -1
- data/lib/samagotchi/session_access/remote.rb +3 -3
- data/lib/samagotchi/session_archive_command.rb +3 -3
- data/lib/samagotchi/session_commands.rb +7 -4
- data/lib/samagotchi/session_config.rb +9 -3
- data/lib/samagotchi/session_continue.rb +1 -1
- data/lib/samagotchi/session_manager.rb +25 -5
- data/lib/samagotchi/session_retention.rb +10 -0
- data/lib/samagotchi/side_judgments.rb +12 -1
- data/lib/samagotchi/system_one/answer.rb +63 -11
- data/lib/samagotchi/system_one/approval_label.rb +56 -0
- data/lib/samagotchi/system_one/approval_question.rb +2 -0
- data/lib/samagotchi/system_one/client.rb +43 -17
- data/lib/samagotchi/system_one/fake_backend.rb +1 -1
- data/lib/samagotchi/system_one/http_backend.rb +12 -4
- data/lib/samagotchi/system_one/judgment_settings.rb +61 -0
- data/lib/samagotchi/system_one/judgments.rb +243 -0
- data/lib/samagotchi/system_one/log.rb +25 -2
- data/lib/samagotchi/system_one/recording.rb +117 -0
- data/lib/samagotchi/system_one/runs.rb +179 -0
- data/lib/samagotchi/system_one/runs_store.rb +230 -0
- data/lib/samagotchi/system_one.rb +9 -0
- data/lib/samagotchi/terminal_ui/attach_link.rb +2 -2
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -1
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
- data/lib/samagotchi/terminal_ui/local_link.rb +1 -1
- data/lib/samagotchi/terminal_ui/remote_link.rb +1 -2
- data/lib/samagotchi/testing/bundle.rb +9 -2
- data/lib/samagotchi/testing/host.rb +2 -1
- data/lib/samagotchi/testing/judgments.rb +176 -0
- data/lib/samagotchi/testing/recorder.rb +5 -0
- data/lib/samagotchi/testing/recording_api.rb +1 -1
- data/lib/samagotchi/tool_output_cut.rb +26 -6
- data/lib/samagotchi/tool_response.rb +1 -1
- data/lib/samagotchi/tool_runner.rb +63 -4
- data/lib/samagotchi/toolkit_suggest.rb +11 -2
- data/lib/samagotchi/tools/memory.rb +28 -0
- data/lib/samagotchi/turn_note.rb +9 -0
- data/lib/samagotchi/update_command.rb +49 -16
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +1 -0
- data/lib/samagotchi/web/auto_update.rb +79 -49
- data/lib/samagotchi/web/auto_update_record.rb +59 -0
- data/lib/samagotchi/web/public/app.js +8 -4
- data/lib/samagotchi/web/public/hash_intent.js +24 -0
- data/lib/samagotchi/web/public/index.html +3 -1
- data/lib/samagotchi/web/public/revise_stack.js +14 -5
- data/lib/samagotchi/web/session_control.rb +3 -3
- data/lib/samagotchi/web/update_check.rb +7 -6
- data/lib/samagotchi/web/update_ops.rb +80 -25
- metadata +23 -2
|
@@ -6,16 +6,20 @@ module Samagotchi
|
|
|
6
6
|
module SystemOne
|
|
7
7
|
# One judgment the System One API answered: for an :noul question,
|
|
8
8
|
# `noul` is the probability of "yes"; a :choice answer carries `choice`
|
|
9
|
-
# (the criterion chosen) and `confidence`; a :score answer carries
|
|
10
|
-
# `
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
# (the criterion chosen) and `confidence`; a :score answer carries `score`
|
|
10
|
+
# and `level`. The server's `score` is the probability-weighted level index
|
|
11
|
+
# (Σ index × its probability), not a level number: with levels 0..n-1 it
|
|
12
|
+
# sits between 0 and n-1, and for a two-level question it is exactly the
|
|
13
|
+
# probability of level 1. `level` is the name of the level with the most
|
|
14
|
+
# probability, from the response's `legend`. `probabilities` is what the
|
|
15
|
+
# model put on each option, when it says (for a score, keyed by level index).
|
|
16
|
+
Answer = Data.define(:id, :type, :noul, :choice, :score, :level, :confidence, :probabilities) do
|
|
17
|
+
def initialize(id:, type:, noul: nil, choice: nil, score: nil, level: nil, confidence: nil, probabilities: nil) = super
|
|
14
18
|
|
|
15
19
|
# The response's answers entry as the wire sends it, or nil when it is
|
|
16
|
-
# not usable: no type, a type the contract doesn't have, a noul
|
|
17
|
-
#
|
|
18
|
-
# judgment for this question", never a guess.
|
|
20
|
+
# not usable: no type, a type the contract doesn't have, a noul outside
|
|
21
|
+
# 0..1, a score that isn't a number or past the last level, … A nil means
|
|
22
|
+
# "no judgment for this question", never a guess.
|
|
19
23
|
def self.from_wire(id, raw)
|
|
20
24
|
return nil unless raw.is_a?(Hash)
|
|
21
25
|
|
|
@@ -37,9 +41,13 @@ module Samagotchi
|
|
|
37
41
|
choice = raw["choice"].to_s.strip
|
|
38
42
|
choice.empty? ? nil : new(**answer, choice: choice)
|
|
39
43
|
else
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
# The legend names the levels; without it there is no name for the
|
|
45
|
+
# answer, but the weighted score still stands.
|
|
46
|
+
legend = levels(raw["legend"])
|
|
47
|
+
return nil if bad_field(raw, "legend", legend)
|
|
48
|
+
|
|
49
|
+
score = level_score(raw["score"], legend, odds)
|
|
50
|
+
score.nil? ? nil : new(**answer, score: score, level: top_level(legend, odds))
|
|
43
51
|
end
|
|
44
52
|
end
|
|
45
53
|
|
|
@@ -73,6 +81,50 @@ module Samagotchi
|
|
|
73
81
|
weights
|
|
74
82
|
end
|
|
75
83
|
end
|
|
84
|
+
|
|
85
|
+
# The legend as the server writes it: a map of level index => name, or
|
|
86
|
+
# the level names in order. nil when absent or unreadable.
|
|
87
|
+
private_class_method def self.levels(value)
|
|
88
|
+
case value
|
|
89
|
+
when Hash
|
|
90
|
+
pairs = value.map { |index, name| [index.to_s.strip, name.to_s.strip] }
|
|
91
|
+
return nil if pairs.empty? || pairs.any? { |index, name| !index.match?(/\A\d+\z/) || name.empty? }
|
|
92
|
+
|
|
93
|
+
pairs.to_h { |index, name| [index.to_i, name] }
|
|
94
|
+
when Array
|
|
95
|
+
names = value.map { |name| name.to_s.strip }
|
|
96
|
+
return nil if names.empty? || names.any?(&:empty?)
|
|
97
|
+
|
|
98
|
+
names.each_with_index.to_h { |name, index| [index, name] }
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# The score as sent: the weighted level index, a whole number kept whole.
|
|
103
|
+
# Not a number, or past the last level the response names, is no answer.
|
|
104
|
+
private_class_method def self.level_score(value, legend, odds)
|
|
105
|
+
return nil unless value.is_a?(Numeric)
|
|
106
|
+
|
|
107
|
+
score = value.to_f
|
|
108
|
+
return nil if score.nan? || score.infinite? || score.negative?
|
|
109
|
+
|
|
110
|
+
count = legend&.size || (odds.is_a?(Array) ? odds.size : odds&.size)
|
|
111
|
+
# A hair past the last level is the probabilities' own rounding, not a
|
|
112
|
+
# level out of range.
|
|
113
|
+
return nil if count && score > count - 1 + 1e-9
|
|
114
|
+
|
|
115
|
+
score == score.to_i ? score.to_i : score
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# The level with the most probability, named by the legend; nil when
|
|
119
|
+
# there are no probabilities, or no legend to name it with.
|
|
120
|
+
private_class_method def self.top_level(legend, odds)
|
|
121
|
+
return nil if legend.nil? || legend.empty? || odds.nil? || odds.empty?
|
|
122
|
+
|
|
123
|
+
weights = legend.keys.map { |index| odds.is_a?(Array) ? odds[index] : odds[index.to_s] }
|
|
124
|
+
return nil if weights.any?(&:nil?)
|
|
125
|
+
|
|
126
|
+
legend[legend.keys[weights.index(weights.max)]]
|
|
127
|
+
end
|
|
76
128
|
end
|
|
77
129
|
end
|
|
78
130
|
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../question_answer"
|
|
4
|
+
require_relative "approval_question"
|
|
5
|
+
require_relative "runs"
|
|
6
|
+
|
|
7
|
+
module Samagotchi
|
|
8
|
+
module SystemOne
|
|
9
|
+
# What an answer to an approval says about the ask, for the judgments log
|
|
10
|
+
# (its value) and the saved run (all of it). The scope they took, a
|
|
11
|
+
# denial, or none for an ask that was cancelled, which is not an answer.
|
|
12
|
+
# A parent agent's answer is not the user's: its allow labels nothing, and
|
|
13
|
+
# its deny is a weak label only where the parent could have allowed — a
|
|
14
|
+
# parent that was not allowed to permit says nothing about what the user
|
|
15
|
+
# would have done (docs/guardrails.md, "System 1").
|
|
16
|
+
module ApprovalLabel
|
|
17
|
+
Label = Data.define(:value, :by, :strength)
|
|
18
|
+
|
|
19
|
+
# `/guardrails wrong`, the web's "should have asked".
|
|
20
|
+
WRONG = Label.new(value: "should_have_asked", by: "user", strength: "strong")
|
|
21
|
+
NONE = Label.new(value: "none", by: "none", strength: nil)
|
|
22
|
+
|
|
23
|
+
module_function
|
|
24
|
+
|
|
25
|
+
# @param answer [QuestionAnswer, Object] anything else: the ask was cancelled
|
|
26
|
+
# @param scopes [Array<String>] the scopes the ask offered
|
|
27
|
+
# @param parent_may_permit [#call] whether the session's parent may
|
|
28
|
+
# allow this ask (read only for a parent's deny)
|
|
29
|
+
# @return [Label, nil] nil: this answer is no label
|
|
30
|
+
def of(answer, scopes:, parent_may_permit:)
|
|
31
|
+
return NONE unless answer.is_a?(Samagotchi::QuestionAnswer)
|
|
32
|
+
|
|
33
|
+
index = answer.selected_indices.first
|
|
34
|
+
allowed = !index.nil? && index < scopes.size
|
|
35
|
+
if answer.parent_agent?
|
|
36
|
+
return nil if allowed || !parent_may_permit.call
|
|
37
|
+
|
|
38
|
+
return Label.new(value: "deny", by: "parent", strength: "weak")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
value = if allowed
|
|
42
|
+
scopes[index] == "once" ? "allow_once" : "allow_wide"
|
|
43
|
+
else
|
|
44
|
+
"deny"
|
|
45
|
+
end
|
|
46
|
+
Label.new(value: value, by: "user", strength: "strong")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# On the saved run +id+ names; an id from before runs has none.
|
|
50
|
+
# @param runs [Runs, nil]
|
|
51
|
+
def save(runs, id, label)
|
|
52
|
+
runs&.label(id, label.value, by: label.by, strength: label.strength, question: ApprovalQuestion::ID)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -15,6 +15,8 @@ module Samagotchi
|
|
|
15
15
|
# the memory an ask names and the earlier asks it resembles.
|
|
16
16
|
module ApprovalQuestion
|
|
17
17
|
ID = "allow"
|
|
18
|
+
# Its saved asks' name (Runs).
|
|
19
|
+
JUDGMENT = "approvals.allow"
|
|
18
20
|
# What the judgment is asked, in the model's terms. Frozen: a change
|
|
19
21
|
# here is a change in behaviour, not a wording tweak.
|
|
20
22
|
INSTRUCTIONS = "A coding agent wants to run this tool call, and a guardrail rule asked its user to approve it. " \
|
|
@@ -17,7 +17,7 @@ module Samagotchi
|
|
|
17
17
|
# while the judge is asked is not a failed judgment: its
|
|
18
18
|
# LLM::RequestCancelled goes on to the caller, which asks no one.
|
|
19
19
|
#
|
|
20
|
-
# client = SystemOne::Client.from_config(host_registry: registry)
|
|
20
|
+
# client = SystemOne::Client.from_config(host_registry: registry, mode: "audit")
|
|
21
21
|
# client&.ask(state: "git push origin main", questions: {"allow" => question})
|
|
22
22
|
class Client
|
|
23
23
|
MODES = %w[off audit on].freeze
|
|
@@ -33,19 +33,26 @@ module Samagotchi
|
|
|
33
33
|
@tag = tag.to_sym
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
# nil when
|
|
37
|
-
#
|
|
38
|
-
#
|
|
36
|
+
# nil when +mode+ is off or no host is named, so the caller needs no
|
|
37
|
+
# other check. The settings are read every call: a config.yml change
|
|
38
|
+
# takes effect on the next ask.
|
|
39
|
+
# @param mode [String, Symbol] the caller's own: there is no default,
|
|
40
|
+
# so nothing gets "on" by leaving it out, and no use reads another's
|
|
41
|
+
# mode key (approvals pass guardrails.system_one.mode); host, model and
|
|
42
|
+
# timeout are system_one.*, every use's
|
|
39
43
|
# @param model [String, nil] a model for this call only (chi guardrails
|
|
40
|
-
# replay --model), else the configured one
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
# replay --model, a bundle's judgment's own), else the configured one
|
|
45
|
+
# @param host [String, nil] a host for this call only (a bundle's
|
|
46
|
+
# judgment's own, never core's: JudgmentSettings), else the configured one
|
|
47
|
+
def self.from_config(host_registry:, mode:, env: ENV, model: nil, host: nil, tag: :guardrails)
|
|
48
|
+
mode = mode.to_s.strip.downcase
|
|
43
49
|
return nil unless MODES.include?(mode) && mode != "off"
|
|
50
|
+
return nil if moved_keys_left?
|
|
44
51
|
|
|
45
|
-
host = Config.get("
|
|
52
|
+
host = (host.nil? ? Config.get("system_one.host") : host).to_s.strip
|
|
46
53
|
return nil if host.empty?
|
|
47
54
|
|
|
48
|
-
model = (model.nil? ? Config.get("
|
|
55
|
+
model = (model.nil? ? Config.get("system_one.model") : model).to_s.strip
|
|
49
56
|
timeout_ms = configured_timeout_ms
|
|
50
57
|
|
|
51
58
|
new(backend: HttpBackend.new(host_registry: host_registry, host: host, model: model.empty? ? nil : model,
|
|
@@ -53,39 +60,57 @@ module Samagotchi
|
|
|
53
60
|
mode: mode, host: host, model: model.empty? ? nil : model, tag: tag)
|
|
54
61
|
end
|
|
55
62
|
|
|
56
|
-
#
|
|
63
|
+
# system_one.timeout_ms, else the default: the whole
|
|
57
64
|
# request's limit, and how long a turn waits for an answer (toolkit
|
|
58
65
|
# suggestion's on mode).
|
|
59
66
|
# @return [Integer]
|
|
60
67
|
def self.configured_timeout_ms
|
|
61
|
-
timeout_ms = Config.get("
|
|
68
|
+
timeout_ms = Config.get("system_one.timeout_ms").to_i
|
|
62
69
|
timeout_ms.positive? ? timeout_ms : DEFAULT_TIMEOUT_MS
|
|
63
70
|
end
|
|
64
71
|
|
|
72
|
+
# Whether config.yml still sets a key that moved to system_one (the
|
|
73
|
+
# warning names it). A file half moved is no judgment: with the host
|
|
74
|
+
# moved and the model not, the host's first model would answer under
|
|
75
|
+
# approvals' clean record (Record is model-blind) and could auto-allow.
|
|
76
|
+
def self.moved_keys_left?
|
|
77
|
+
section = ConfigFile.section("guardrails")
|
|
78
|
+
own = section.is_a?(Hash) ? section["system_one"] || section["system-one"] : nil
|
|
79
|
+
own.is_a?(Hash) && own.keys.map { |key| key.to_s.tr("-", "_") }.intersect?(Config::SYSTEM_ONE_MOVED_KEYS)
|
|
80
|
+
end
|
|
81
|
+
private_class_method :moved_keys_left?
|
|
82
|
+
|
|
65
83
|
# @param state [String, Hash, Array] what the question is about, as the
|
|
66
84
|
# contract takes it
|
|
67
85
|
# @param questions [Hash{String => Question|Hash}] the questions, by id
|
|
86
|
+
# @param observer [#call, nil] told (**facts) what the return value
|
|
87
|
+
# hides: why it is nil (failure:, failure_text:) and what the backend
|
|
88
|
+
# said (model:, served_model:, raw:, usage:), on this thread, before
|
|
89
|
+
# #ask returns (Recording)
|
|
90
|
+
# @param run_id [String, nil] Recording's: a bare client saves no run,
|
|
91
|
+
# and a caller holding a bare client asks the same way
|
|
68
92
|
# @return [Hash{String => Answer}, nil] one Answer per question, or nil
|
|
69
93
|
# when there is no judgment at all
|
|
70
|
-
def ask(state:, questions:, cancel_controller: nil)
|
|
94
|
+
def ask(state:, questions:, cancel_controller: nil, observer: nil, run_id: nil)
|
|
71
95
|
questions = SystemOne.normalize_questions(questions)
|
|
72
96
|
return nil if questions.empty?
|
|
73
97
|
|
|
74
98
|
answers = begin
|
|
75
|
-
@backend.ask(state: state, questions: questions, cancel_controller: cancel_controller
|
|
99
|
+
@backend.ask(state: state, questions: questions, cancel_controller: cancel_controller,
|
|
100
|
+
**(observer ? { observer: observer } : {}))
|
|
76
101
|
rescue LLM::RequestCancelled
|
|
77
102
|
raise
|
|
78
103
|
rescue StandardError => e
|
|
79
|
-
return no_judgment("#{e.class}: #{e.message}", error: e.class.name)
|
|
104
|
+
return no_judgment("#{e.class}: #{e.message}", failure: e.class.name, observer: observer, error: e.class.name)
|
|
80
105
|
end
|
|
81
106
|
|
|
82
107
|
unless answers.is_a?(Hash)
|
|
83
|
-
return no_judgment("the backend returned #{answers.inspect}")
|
|
108
|
+
return no_judgment("the backend returned #{answers.inspect}", failure: "bad_response", observer: observer)
|
|
84
109
|
end
|
|
85
110
|
|
|
86
111
|
answers = questions.to_h { |question| [question.id, answers[question.id]] }
|
|
87
112
|
missing = questions.reject { |question| answers[question.id].is_a?(Answer) }
|
|
88
|
-
return no_judgment("no answer for #{missing.map(&:id).join(", ")}") unless missing.empty?
|
|
113
|
+
return no_judgment("no answer for #{missing.map(&:id).join(", ")}", failure: "no_answer", observer: observer) unless missing.empty?
|
|
89
114
|
|
|
90
115
|
answers
|
|
91
116
|
end
|
|
@@ -93,7 +118,8 @@ module Samagotchi
|
|
|
93
118
|
private
|
|
94
119
|
|
|
95
120
|
# One warn, one nil: the ask goes to the user.
|
|
96
|
-
def no_judgment(reason, **fields)
|
|
121
|
+
def no_judgment(reason, failure:, observer:, **fields)
|
|
122
|
+
observer&.call(failure: failure, failure_text: reason)
|
|
97
123
|
# Qualified: inside SystemOne, the bare Log is now SystemOne::Log.
|
|
98
124
|
Samagotchi::Log.warn(@tag, "system_one_failed", echo: "[samagotchi:#{@tag}] system one: #{reason}", host: @host, **fields)
|
|
99
125
|
nil
|
|
@@ -36,13 +36,17 @@ module Samagotchi
|
|
|
36
36
|
@env = env
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
# @param observer [#call, nil] told (**facts) the model it resolved,
|
|
40
|
+
# before the request, then what the response said beside the parsed
|
|
41
|
+
# answers: served_model:, raw: (each answer as sent, score legends
|
|
42
|
+
# and all) and usage: (Splash's input_tokens, output_tokens)
|
|
39
43
|
# @return [Hash{String => Answer}] one Answer per question, nil for a
|
|
40
44
|
# question the response answered badly
|
|
41
45
|
# @raise [UnsupportedHost] the host is unknown, not an openai host, or
|
|
42
46
|
# names no model
|
|
43
47
|
# @raise [BackendError] the request failed, the status isn't 200, or
|
|
44
48
|
# the body isn't a usable response
|
|
45
|
-
def ask(state:, questions:, cancel_controller: nil)
|
|
49
|
+
def ask(state:, questions:, cancel_controller: nil, observer: nil)
|
|
46
50
|
entry = @host_registry.find_entry(@host)
|
|
47
51
|
raise UnsupportedHost, "host #{@host.inspect} is not in hosts:" unless entry
|
|
48
52
|
unless entry.api&.to_sym == :openai
|
|
@@ -52,6 +56,7 @@ module Samagotchi
|
|
|
52
56
|
model = @model || host_model(entry)
|
|
53
57
|
raise UnsupportedHost, "host #{@host} names no model for System One" if model.nil? || model.empty?
|
|
54
58
|
|
|
59
|
+
observer&.call(model: model)
|
|
55
60
|
url = "#{entry.openai_base_url.to_s.chomp("/")}/systemone"
|
|
56
61
|
questions = SystemOne.normalize_questions(questions)
|
|
57
62
|
body = { model: model, state: state, questions: questions.to_h { |question| [question.id, question.to_wire] } }
|
|
@@ -64,7 +69,9 @@ module Samagotchi
|
|
|
64
69
|
raise BackendError, "#{@host}: #{status} #{error_detail(response.body)}"
|
|
65
70
|
end
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
data = reply_of(response.body)
|
|
73
|
+
answers = data["answers"]
|
|
74
|
+
observer&.call(served_model: data["model"], raw: answers, usage: data["usage"])
|
|
68
75
|
questions.to_h { |question| [question.id, Answer.from_wire(question.id, answers[question.id])] }
|
|
69
76
|
end
|
|
70
77
|
|
|
@@ -99,14 +106,15 @@ module Samagotchi
|
|
|
99
106
|
end
|
|
100
107
|
end
|
|
101
108
|
|
|
102
|
-
|
|
109
|
+
# The response's JSON, its answers map checked.
|
|
110
|
+
def reply_of(body)
|
|
103
111
|
data = JSON.parse(body.to_s)
|
|
104
112
|
raise BackendError, "the response is not JSON: #{body.to_s[0, 200]}" unless data.is_a?(Hash)
|
|
105
113
|
|
|
106
114
|
answers = data["answers"]
|
|
107
115
|
raise BackendError, "the response has no answers map" unless answers.is_a?(Hash)
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
data
|
|
110
118
|
rescue JSON::ParserError => e
|
|
111
119
|
raise BackendError, "the response is not JSON: #{e.message[0, 200]}"
|
|
112
120
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../config"
|
|
4
|
+
|
|
5
|
+
module Samagotchi
|
|
6
|
+
module SystemOne
|
|
7
|
+
# A bundle's judgment's settings: its entry in config.yml's
|
|
8
|
+
# system_one.judgments, read at each ask, as Client's are. Off until the
|
|
9
|
+
# user sets a mode. +host+ and +model+ are nil for the shared
|
|
10
|
+
# system_one.host and .model.
|
|
11
|
+
#
|
|
12
|
+
# Core's judgments have none, whatever the file says (Config::
|
|
13
|
+
# RESERVED_JUDGMENTS): Record and Similar are model-blind, so a model
|
|
14
|
+
# swapped for approvals alone would inherit a clean record and could
|
|
15
|
+
# auto-allow.
|
|
16
|
+
JudgmentSettings = Data.define(:mode, :host, :model) do
|
|
17
|
+
def initialize(mode: "off", host: nil, model: nil) = super
|
|
18
|
+
|
|
19
|
+
def off? = mode == "off"
|
|
20
|
+
|
|
21
|
+
# The model for Client.from_config: its own; else, on a host of its own,
|
|
22
|
+
# that host's first ("": the shared model belongs to the shared host);
|
|
23
|
+
# else nil, the shared one.
|
|
24
|
+
def client_model = model || (host ? "" : nil)
|
|
25
|
+
|
|
26
|
+
# @param name [String] the judgment's full name
|
|
27
|
+
# @param section [Hash, nil] config.yml's system_one section
|
|
28
|
+
# @return [JudgmentSettings]
|
|
29
|
+
def self.of(name, section: ConfigFile.section("system_one"))
|
|
30
|
+
return new if Config::RESERVED_JUDGMENTS.include?(name.to_s.split(".").first)
|
|
31
|
+
|
|
32
|
+
entry = entries(section)[name.to_s]
|
|
33
|
+
return new unless entry.is_a?(Hash)
|
|
34
|
+
|
|
35
|
+
new(mode: Config.judgment_mode(entry["mode"]) || "off", host: text(entry["host"]), model: text(entry["model"]))
|
|
36
|
+
rescue StandardError
|
|
37
|
+
new
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The names system_one.judgments sets.
|
|
41
|
+
# @return [Array<String>]
|
|
42
|
+
def self.names(section: ConfigFile.section("system_one"))
|
|
43
|
+
entries(section).keys
|
|
44
|
+
rescue StandardError
|
|
45
|
+
[]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.entries(section)
|
|
49
|
+
judgments = section["judgments"] if section.is_a?(Hash)
|
|
50
|
+
judgments.is_a?(Hash) ? judgments.transform_keys(&:to_s) : {}
|
|
51
|
+
end
|
|
52
|
+
private_class_method :entries
|
|
53
|
+
|
|
54
|
+
def self.text(value)
|
|
55
|
+
word = value.to_s.strip
|
|
56
|
+
word.empty? ? nil : word
|
|
57
|
+
end
|
|
58
|
+
private_class_method :text
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../config"
|
|
4
|
+
require_relative "../log"
|
|
5
|
+
require_relative "../llm/errors"
|
|
6
|
+
require_relative "../side_judgments"
|
|
7
|
+
require_relative "judgment_settings"
|
|
8
|
+
require_relative "question"
|
|
9
|
+
require_relative "recording"
|
|
10
|
+
require_relative "runs"
|
|
11
|
+
|
|
12
|
+
module Samagotchi
|
|
13
|
+
module SystemOne
|
|
14
|
+
# Bundles' judgments (chi.judgment, ctx.judge, ctx.judge_later): what the
|
|
15
|
+
# user set for each, then the same Client and Recording core's uses ask
|
|
16
|
+
# through. It adds no power: a bundle's run is scoped to its name, and off
|
|
17
|
+
# until the user sets a mode. Core's uses stay outside (their threads,
|
|
18
|
+
# gates and contention are their own) and can't be set here (D2,
|
|
19
|
+
# JudgmentSettings).
|
|
20
|
+
class Judgments
|
|
21
|
+
# What chi.judgment declared. +questions+ is an Array of Question, or a
|
|
22
|
+
# callable given the ctx, returning what normalize_questions takes.
|
|
23
|
+
Declaration = Data.define(:name, :questions, :positive, :negative) do
|
|
24
|
+
# @raise [ArgumentError] anything the declaration can't be
|
|
25
|
+
def self.build(bundle:, name:, questions:, positive: nil, negative: nil)
|
|
26
|
+
full = "#{bundle}.#{name}"
|
|
27
|
+
# The first word is the bundle: "a.b" + "x" and "a" + "b.x" must not meet.
|
|
28
|
+
raise ArgumentError, "judgment #{full.inspect}: a bundle with a dot in its name can't declare one" if bundle.to_s.include?(".")
|
|
29
|
+
|
|
30
|
+
unless Runs.declarable?(full)
|
|
31
|
+
raise ArgumentError, "judgment #{full.inspect}: a full name is dot-separated words of a-z, 0-9, _ and -, " \
|
|
32
|
+
"with no first word of #{Runs::RESERVED.join(", ")} and no #{Runs::RESERVED_SUFFIX} at its end"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
new(name: full, questions: questions.respond_to?(:call) ? questions : checked(full, questions),
|
|
36
|
+
positive: Array(positive).map(&:to_s).freeze, negative: Array(negative).map(&:to_s).freeze)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# The questions of an ask now.
|
|
40
|
+
# @return [Array<Question>]
|
|
41
|
+
def questions_for(context)
|
|
42
|
+
questions.respond_to?(:call) ? self.class.checked(name, questions.call(context)) : questions
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.checked(full, questions)
|
|
46
|
+
list = SystemOne.normalize_questions(questions)
|
|
47
|
+
raise ArgumentError, "judgment #{full} has no questions" if list.empty?
|
|
48
|
+
|
|
49
|
+
list.freeze
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# What each of its runs says of the label values, if anything.
|
|
53
|
+
def run_fields = { positive: positive, negative: negative }.reject { |_key, values| values.empty? }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# What an ask came to. +reason+ says why there's no answer: :off,
|
|
57
|
+
# :no_host, :no_session, :failed, :cancelled or :busy; nil
|
|
58
|
+
# with answers. +mode+ is the judgment's ("off", "audit", "on"): in audit
|
|
59
|
+
# the bundle looks and doesn't act. +run_id+ is nil when no run is saved.
|
|
60
|
+
Result = Data.define(:answers, :run_id, :mode, :reason) do
|
|
61
|
+
def self.none(reason, mode: "off", run_id: nil) = new(answers: {}.freeze, run_id: run_id, mode: mode, reason: reason)
|
|
62
|
+
|
|
63
|
+
def no_judgment? = answers.empty?
|
|
64
|
+
def audit? = mode == "audit"
|
|
65
|
+
|
|
66
|
+
# An :noul question's probability of yes; nil with no answer, or for
|
|
67
|
+
# another type (its answer is #answers[id]).
|
|
68
|
+
# @param id [String, Symbol, nil] nil: the only question's
|
|
69
|
+
# @return [Float, nil]
|
|
70
|
+
def p(id = nil)
|
|
71
|
+
answer = id.nil? ? (answers.values.first if answers.size == 1) : answers[id.to_s]
|
|
72
|
+
answer&.noul
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# One ask, made ready on the caller's thread.
|
|
77
|
+
Ask = Data.define(:client, :questions, :state, :run_id, :mode)
|
|
78
|
+
|
|
79
|
+
# The seams are what the Engine knows, read at each ask. They default to
|
|
80
|
+
# nothing, for a chi with no Engine (a bundle's install check): nothing
|
|
81
|
+
# is ever answered there.
|
|
82
|
+
# @param settings [#call] (name) → JudgmentSettings
|
|
83
|
+
# @param client_for [#call] (name, settings) → a Client, nil with no host
|
|
84
|
+
# @param runs [#call] → the Runs to save in
|
|
85
|
+
# @param where [#call] → Recording::Context, nil with no session
|
|
86
|
+
# @param side [SideJudgments]
|
|
87
|
+
# @param participant [#call] → whether a participant's turn runs: its
|
|
88
|
+
# text is never saved
|
|
89
|
+
def initialize(settings: JudgmentSettings.method(:of), client_for: ->(_name, _settings) {}, runs: -> { Runs.new }, where: -> {},
|
|
90
|
+
side: SideJudgments.new, participant: -> { false })
|
|
91
|
+
@settings = settings
|
|
92
|
+
@client_for = client_for
|
|
93
|
+
@runs = runs
|
|
94
|
+
@where = where
|
|
95
|
+
@side = side
|
|
96
|
+
@participant = participant
|
|
97
|
+
@declarations = {}
|
|
98
|
+
@mutex = Mutex.new
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# @param declaration [Declaration]
|
|
102
|
+
def declare(declaration)
|
|
103
|
+
@mutex.synchronize { @declarations[declaration.name] = declaration }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def declared?(name) = @mutex.synchronize { @declarations.key?(name.to_s) }
|
|
107
|
+
|
|
108
|
+
# Ask now, on this thread.
|
|
109
|
+
# @param context [Object] what a questions builder gets (the ctx)
|
|
110
|
+
# @return [Result]
|
|
111
|
+
# @raise [ArgumentError] +name+ isn't declared, or +state+ can't be one
|
|
112
|
+
def judge(name, state:, context: nil, cancel_controller: nil)
|
|
113
|
+
ask = prepare(name, state, context)
|
|
114
|
+
return ask if ask.is_a?(Result)
|
|
115
|
+
|
|
116
|
+
asked(ask, cancel_controller)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Ask on +name+'s side thread, one at a time; the block gets the Result
|
|
120
|
+
# on another thread, always once.
|
|
121
|
+
# @return [String, nil] the run's id, nil when no run will be saved
|
|
122
|
+
# @raise [ArgumentError] as #judge
|
|
123
|
+
def later(name, state:, context: nil, &block)
|
|
124
|
+
ask = prepare(name, state, context)
|
|
125
|
+
return tell(name, block, ask).run_id if ask.is_a?(Result)
|
|
126
|
+
|
|
127
|
+
started = @side.start(name, warn: warner(name, "judge_later_failed"),
|
|
128
|
+
finish: ->(result) { deliver(name, block, result || Result.none(:failed, mode: ask.mode, run_id: ask.run_id)) }) do
|
|
129
|
+
asked(ask, nil)
|
|
130
|
+
end
|
|
131
|
+
tell(name, block, skipped(ask, :busy)) unless started
|
|
132
|
+
ask.run_id
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# A later line on a run (Runs#label, #acted); false when it isn't saved.
|
|
136
|
+
# Nothing is saved in a participant's turn, as an ask there saves no run.
|
|
137
|
+
def label(run_id, value, by:, strength: nil, question: nil)
|
|
138
|
+
return false if @participant.call
|
|
139
|
+
|
|
140
|
+
@runs.call.label(run_id, value, by: by, strength: strength, question: question)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def acted(run_id, what)
|
|
144
|
+
return false if @participant.call
|
|
145
|
+
|
|
146
|
+
@runs.call.acted(run_id, what)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# The system_one.judgments names no plugin declared, once the plugins
|
|
150
|
+
# have loaded: a typo there is a judgment that stays off. Core's names
|
|
151
|
+
# have their own warning (Config.validate_yaml_sections).
|
|
152
|
+
# @return [Array<String>]
|
|
153
|
+
def undeclared
|
|
154
|
+
known = @mutex.synchronize { @declarations.keys }
|
|
155
|
+
(JudgmentSettings.names - known).reject { |name| Config::RESERVED_JUDGMENTS.include?(name.split(".").first) }
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
private
|
|
159
|
+
|
|
160
|
+
# The Ask, or the Result that says why there is none.
|
|
161
|
+
def prepare(name, state, context)
|
|
162
|
+
declaration = @mutex.synchronize { @declarations[name.to_s] }
|
|
163
|
+
raise ArgumentError, "no judgment #{name} declared (chi.judgment)" unless declaration
|
|
164
|
+
unless state.is_a?(String) || state.is_a?(Hash) || state.is_a?(Array)
|
|
165
|
+
raise ArgumentError, "judgment #{name}: state: is a String, a Hash or an Array, not #{state.class}"
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
settings = @settings.call(declaration.name)
|
|
169
|
+
return Result.none(:off) if settings.off?
|
|
170
|
+
|
|
171
|
+
client = client_for(declaration, settings)
|
|
172
|
+
return Result.none(:no_host, mode: settings.mode) if client.nil?
|
|
173
|
+
|
|
174
|
+
where = where_now(declaration)
|
|
175
|
+
return Result.none(:no_session, mode: settings.mode) if where.nil?
|
|
176
|
+
|
|
177
|
+
ready(declaration, settings, client, where, state, context)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def where_now(declaration)
|
|
181
|
+
@where.call
|
|
182
|
+
rescue StandardError => e
|
|
183
|
+
warner(declaration.name, "judgment_session_unread").call(e)
|
|
184
|
+
nil
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def ready(declaration, settings, client, where, state, context)
|
|
188
|
+
runs = @participant.call ? Runs.new : @runs.call
|
|
189
|
+
Ask.new(client: Recording.new(client, judgment: declaration.name, runs: runs, context: where, fields: declaration.run_fields),
|
|
190
|
+
questions: declaration.questions_for(context), state: copy_of(declaration, state),
|
|
191
|
+
run_id: runs.on? ? Runs.new_id(declaration.name) : nil, mode: settings.mode)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# A state nested too deep to copy (a cycle) is a bad state: a
|
|
195
|
+
# SystemStackError would go past a hook's rescue and end the turn.
|
|
196
|
+
def copy_of(declaration, state)
|
|
197
|
+
Runs.scrubbed(state)
|
|
198
|
+
rescue SystemStackError
|
|
199
|
+
raise ArgumentError, "judgment #{declaration.name}: state: is nested too deep"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def client_for(declaration, settings)
|
|
203
|
+
@client_for.call(declaration.name, settings)
|
|
204
|
+
rescue StandardError => e
|
|
205
|
+
warner(declaration.name, "judgment_client_failed").call(e)
|
|
206
|
+
nil
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def skipped(ask, reason)
|
|
210
|
+
ask.client.skip(state: ask.state, questions: ask.questions, reason: reason.to_s, run_id: ask.run_id)
|
|
211
|
+
Result.none(reason, mode: ask.mode, run_id: ask.run_id)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def asked(ask, cancel_controller)
|
|
215
|
+
answers = ask.client.ask(state: ask.state, questions: ask.questions, cancel_controller: cancel_controller, run_id: ask.run_id)
|
|
216
|
+
return Result.none(:failed, mode: ask.mode, run_id: ask.run_id) if answers.nil?
|
|
217
|
+
|
|
218
|
+
Result.new(answers: answers.freeze, run_id: ask.run_id, mode: ask.mode, reason: nil)
|
|
219
|
+
rescue LLM::RequestCancelled
|
|
220
|
+
Result.none(:cancelled, mode: ask.mode, run_id: ask.run_id)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# The block gets +result+ on another thread, as an asked one does.
|
|
224
|
+
# @return [Result] +result+
|
|
225
|
+
def tell(name, block, result)
|
|
226
|
+
@side.aside(warn: warner(name, "judge_later_failed")) { deliver(name, block, result) } if block
|
|
227
|
+
result
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def deliver(name, block, result)
|
|
231
|
+
block&.call(result)
|
|
232
|
+
rescue StandardError => e
|
|
233
|
+
warner(name, "judge_later_block_failed").call(e)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def warner(name, event)
|
|
237
|
+
lambda { |error|
|
|
238
|
+
Samagotchi::Log.warn(:plugins, event, judgment: name, error: "#{error.class}: #{error.message}"[0, 300])
|
|
239
|
+
}
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|