samagotchi 0.171.0 → 0.172.1
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 +46 -1
- data/bin/chi +6 -4
- data/docs/architecture.md +24 -7
- data/docs/bundles.md +4 -21
- data/docs/cli.md +50 -80
- data/docs/configuration.md +11 -13
- data/docs/context.md +5 -6
- data/docs/guardrails.md +57 -96
- data/docs/hooks.md +3 -4
- data/docs/internals/attached-context.md +6 -7
- data/docs/internals/background-tasks.md +4 -3
- data/docs/internals/bridge.md +29 -3
- data/docs/internals/engine.md +21 -9
- data/docs/internals/objectives.md +3 -5
- data/docs/internals/participants.md +118 -143
- data/docs/internals/prompt-caching.md +4 -5
- data/docs/internals/web-frontend.md +70 -27
- data/docs/internals/working-set.md +7 -5
- data/docs/memory.md +1 -1
- data/docs/plugins.md +2 -16
- data/docs/scheduling.md +1 -1
- data/docs/sessions.md +15 -49
- data/docs/sub-agent.md +2 -2
- data/docs/system-one.md +2 -2
- data/docs/testing.md +81 -8
- data/lib/samagotchi/bridge/card_store.rb +1 -0
- data/lib/samagotchi/bridge/sse_writer.rb +1 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +0 -1
- data/lib/samagotchi/bridge.rb +26 -9
- data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
- data/lib/samagotchi/bundle_command/test_run.rb +1 -0
- data/lib/samagotchi/bundle_command/try/run.rb +1 -0
- data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
- data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
- data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
- data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
- data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +126 -67
- data/lib/samagotchi/command_intake.rb +15 -3
- data/lib/samagotchi/compat.rb +6 -1
- data/lib/samagotchi/context_candidate_choice.rb +1 -3
- data/lib/samagotchi/context_candidates.rb +3 -4
- data/lib/samagotchi/continue_offer.rb +9 -2
- data/lib/samagotchi/delivery.rb +23 -12
- data/lib/samagotchi/empty_answer_error.rb +5 -0
- data/lib/samagotchi/engine/cards.rb +3 -0
- data/lib/samagotchi/engine/context_judge.rb +5 -3
- data/lib/samagotchi/engine/events.rb +4 -0
- data/lib/samagotchi/engine/hooks.rb +3 -0
- data/lib/samagotchi/engine/messages.rb +5 -0
- data/lib/samagotchi/engine/model_settings.rb +2 -0
- data/lib/samagotchi/engine/models.rb +10 -0
- data/lib/samagotchi/engine/objectives.rb +6 -0
- data/lib/samagotchi/engine/participants.rb +18 -14
- data/lib/samagotchi/engine/plugins.rb +8 -0
- data/lib/samagotchi/engine/questions.rb +3 -0
- data/lib/samagotchi/engine/recap.rb +1 -0
- data/lib/samagotchi/engine/session.rb +4 -0
- data/lib/samagotchi/engine/side_requests.rb +9 -0
- data/lib/samagotchi/engine/steering.rb +2 -0
- data/lib/samagotchi/engine/toolkit.rb +5 -0
- data/lib/samagotchi/engine/turn_end.rb +7 -0
- data/lib/samagotchi/engine/turn_helpers.rb +8 -0
- data/lib/samagotchi/engine/verify.rb +2 -0
- data/lib/samagotchi/engine.rb +3 -2
- data/lib/samagotchi/grants.rb +28 -22
- data/lib/samagotchi/guardrail_wiring.rb +23 -18
- data/lib/samagotchi/guardrails/approval_use.rb +59 -0
- data/lib/samagotchi/guardrails/approvals.rb +9 -11
- data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
- data/lib/samagotchi/guardrails/gate.rb +10 -5
- data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
- data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
- data/lib/samagotchi/guardrails/review_paths.rb +2 -3
- data/lib/samagotchi/guardrails.rb +1 -1
- data/lib/samagotchi/llm_context_strategy.rb +2 -0
- data/lib/samagotchi/objectives.rb +1 -4
- data/lib/samagotchi/objectives_audit.rb +1 -1
- data/lib/samagotchi/objectives_track.rb +1 -1
- data/lib/samagotchi/owner_prompt.rb +3 -6
- data/lib/samagotchi/parent_report.rb +1 -0
- data/lib/samagotchi/participant_messages.rb +9 -4
- data/lib/samagotchi/participant_turn_mode.rb +50 -0
- data/lib/samagotchi/participants.rb +21 -12
- data/lib/samagotchi/participants_watch.rb +2 -2
- data/lib/samagotchi/plugin/api.rb +2 -2
- data/lib/samagotchi/plugin/attached_context.rb +1 -1
- data/lib/samagotchi/plugin/context.rb +0 -4
- data/lib/samagotchi/plugin/sessions.rb +1 -25
- data/lib/samagotchi/run_options.rb +2 -3
- data/lib/samagotchi/send_command.rb +10 -10
- data/lib/samagotchi/session.rb +0 -3
- data/lib/samagotchi/session_access/contract.rb +1 -10
- data/lib/samagotchi/session_access/local.rb +10 -23
- data/lib/samagotchi/session_access/remote.rb +9 -20
- data/lib/samagotchi/session_access.rb +12 -16
- data/lib/samagotchi/session_chain.rb +4 -6
- data/lib/samagotchi/session_commands.rb +6 -3
- data/lib/samagotchi/session_continue.rb +1 -2
- data/lib/samagotchi/session_manager/delivery.rb +25 -5
- data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
- data/lib/samagotchi/session_manager/listing.rb +5 -0
- data/lib/samagotchi/session_manager/spawn.rb +2 -2
- data/lib/samagotchi/session_manager/worker_command.rb +9 -0
- data/lib/samagotchi/session_participants.rb +12 -8
- data/lib/samagotchi/session_review.rb +5 -7
- data/lib/samagotchi/session_stores.rb +3 -3
- data/lib/samagotchi/share_command.rb +10 -12
- data/lib/samagotchi/share_terms.rb +41 -0
- data/lib/samagotchi/steer.rb +8 -14
- data/lib/samagotchi/system_prompt.rb +16 -25
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
- data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
- data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
- data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
- data/lib/samagotchi/terminal_ui.rb +1 -2
- data/lib/samagotchi/testing/sessions.rb +2 -10
- data/lib/samagotchi/tool_runner.rb +8 -9
- data/lib/samagotchi/toolkit.rb +4 -22
- data/lib/samagotchi/toolkit_suggest.rb +3 -3
- data/lib/samagotchi/tools/deferred_tools.rb +1 -0
- data/lib/samagotchi/tools/execute.rb +11 -45
- data/lib/samagotchi/tools/leftovers.rb +126 -0
- data/lib/samagotchi/tools/memory.rb +70 -26
- data/lib/samagotchi/tools/task_get.rb +1 -0
- data/lib/samagotchi/tools/task_list.rb +3 -2
- data/lib/samagotchi/tools/task_record.rb +6 -4
- data/lib/samagotchi/tools/task_runtime.rb +199 -20
- data/lib/samagotchi/tools/task_wait.rb +4 -3
- data/lib/samagotchi/turn_context.rb +1 -1
- data/lib/samagotchi/turn_origin.rb +1 -1
- data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
- data/lib/samagotchi/turn_stages/objectives.rb +2 -2
- data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
- data/lib/samagotchi/update_hint.rb +3 -1
- data/lib/samagotchi/verify_fresh.rb +1 -1
- data/lib/samagotchi/verify_fresh_origin.rb +13 -11
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -5
- data/lib/samagotchi/web/participant_access.rb +14 -18
- data/lib/samagotchi/web/participant_review.rb +3 -4
- data/lib/samagotchi/web/participant_show.rb +4 -3
- data/lib/samagotchi/web/participant_view.rb +3 -3
- data/lib/samagotchi/web/participants_admin.rb +21 -40
- data/lib/samagotchi/web/public/app.js +7 -48
- data/lib/samagotchi/web/public/card_kinds.js +51 -0
- data/lib/samagotchi/web/public/cards_place.js +13 -2
- data/lib/samagotchi/web/public/data.js +2 -10
- data/lib/samagotchi/web/public/delivery_line.js +17 -60
- data/lib/samagotchi/web/public/index.html +10 -30
- data/lib/samagotchi/web/public/live_turn.js +1 -1
- data/lib/samagotchi/web/public/owner_claim.js +2 -2
- data/lib/samagotchi/web/public/participant_bar.js +4 -5
- data/lib/samagotchi/web/public/participant_names.js +14 -10
- data/lib/samagotchi/web/public/participants_panel.js +29 -62
- data/lib/samagotchi/web/public/question_cards.js +29 -14
- data/lib/samagotchi/web/public/reload_check.js +2 -3
- data/lib/samagotchi/web/public/send_turn.js +4 -23
- data/lib/samagotchi/web/public/session_actions.js +4 -45
- data/lib/samagotchi/web/public/session_fields.js +0 -1
- data/lib/samagotchi/web/public/session_state.js +0 -3
- data/lib/samagotchi/web/public/session_sync.js +4 -2
- data/lib/samagotchi/web/public/session_view.js +2 -3
- data/lib/samagotchi/web/public/settings_panel.js +4 -18
- data/lib/samagotchi/web/public/stage_answer.js +56 -0
- data/lib/samagotchi/web/public/stage_asking.js +30 -11
- data/lib/samagotchi/web/public/stage_cloud.js +93 -0
- data/lib/samagotchi/web/public/stage_dom.js +100 -0
- data/lib/samagotchi/web/public/stage_handoff.js +154 -0
- data/lib/samagotchi/web/public/stage_pager.js +59 -0
- data/lib/samagotchi/web/public/stage_place.js +144 -0
- data/lib/samagotchi/web/public/stage_probe.js +64 -0
- data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
- data/lib/samagotchi/web/public/stage_view.js +133 -506
- data/lib/samagotchi/web/public/stage_waiting.js +30 -13
- data/lib/samagotchi/web/public/start_page.js +12 -33
- data/lib/samagotchi/web/public/start_settings.js +24 -78
- data/lib/samagotchi/web/public/start_toolkit.js +6 -10
- data/lib/samagotchi/web/public/stream_handlers.js +1 -9
- data/lib/samagotchi/web/public/turn_block.js +3 -7
- data/lib/samagotchi/web/public/turn_events.js +15 -6
- data/lib/samagotchi/web/public/turn_pieces.js +3 -4
- data/lib/samagotchi/web/public/viewer_self.js +8 -2
- data/lib/samagotchi/web/qr.rb +1 -1
- data/lib/samagotchi/web/session_control.rb +3 -1
- data/lib/samagotchi/web/session_create.rb +5 -71
- data/lib/samagotchi/web/session_summary.rb +1 -4
- data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
- data/lib/samagotchi/web/viewer.rb +3 -3
- data/lib/samagotchi/worker.rb +16 -14
- data/lib/samagotchi/worker_inbound.rb +4 -3
- data/lib/samagotchi/worker_link.rb +17 -0
- data/lib/samagotchi/working_set.rb +87 -28
- metadata +16 -8
- data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
- data/lib/samagotchi/participant_mode.rb +0 -86
- data/lib/samagotchi/review_apply.rb +0 -131
- data/lib/samagotchi/review_command.rb +0 -123
- data/lib/samagotchi/review_start.rb +0 -196
- data/lib/samagotchi/web/public/review_apply.js +0 -34
- data/lib/samagotchi/web/public/review_start.js +0 -55
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../idle_client"
|
|
4
|
+
require_relative "../idle_target"
|
|
5
|
+
require_relative "../log"
|
|
6
|
+
require_relative "../objectives_check"
|
|
7
|
+
require_relative "../objectives_track"
|
|
8
|
+
require_relative "../session"
|
|
9
|
+
require_relative "../system_one/recorder"
|
|
10
|
+
require_relative "../system_one/runs"
|
|
11
|
+
|
|
3
12
|
module Samagotchi
|
|
4
13
|
class Engine
|
|
5
14
|
# Side requests: a plugin's ctx.ask_model and Check this on their own
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../log"
|
|
4
|
+
require_relative "../tool_loads"
|
|
5
|
+
require_relative "../tools/tool_surface"
|
|
6
|
+
require_relative "../turn_stages/toolkit_suggestion"
|
|
7
|
+
|
|
3
8
|
module Samagotchi
|
|
4
9
|
class Engine
|
|
5
10
|
# The session's toolkit: the kits and what a turn declares
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../answer_display"
|
|
4
|
+
require_relative "../answer_refs"
|
|
5
|
+
require_relative "../client"
|
|
6
|
+
require_relative "../last_turn"
|
|
7
|
+
require_relative "../llm/model_result"
|
|
8
|
+
require_relative "../log"
|
|
9
|
+
|
|
3
10
|
module Samagotchi
|
|
4
11
|
class Engine
|
|
5
12
|
# How a turn ends after #end_turn's step: the normal ending and its
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../image_store"
|
|
4
|
+
require_relative "../llm/errors"
|
|
5
|
+
require_relative "../llm/turn_settings"
|
|
6
|
+
require_relative "../log"
|
|
7
|
+
require_relative "../session"
|
|
8
|
+
require_relative "../turn_stages/warmup"
|
|
9
|
+
require_relative "../vision_context"
|
|
10
|
+
|
|
3
11
|
module Samagotchi
|
|
4
12
|
class Engine
|
|
5
13
|
# What a turn's steps use before and around the model: its settings,
|
data/lib/samagotchi/engine.rb
CHANGED
|
@@ -48,7 +48,6 @@ require_relative "llm/openai_chat"
|
|
|
48
48
|
require_relative "llm/turn_settings"
|
|
49
49
|
require_relative "session"
|
|
50
50
|
require_relative "toolkit_binding"
|
|
51
|
-
require_relative "participant_mode"
|
|
52
51
|
require_relative "context_candidates"
|
|
53
52
|
require_relative "context_candidates_log"
|
|
54
53
|
require_relative "context_candidate_choice"
|
|
@@ -504,7 +503,9 @@ module Samagotchi
|
|
|
504
503
|
cancel_controller: -> { active_cancel_controller },
|
|
505
504
|
# A participant's turn: their name on the owner's card, their
|
|
506
505
|
# grant's mode for the turn's (GuardrailWiring#begin_turn).
|
|
507
|
-
participant: ->(author) { @participants.entry_for(author, session: @session) }
|
|
506
|
+
participant: ->(author) { @participants.entry_for(author, session: @session) },
|
|
507
|
+
# The same clock the participants line measures "active" at.
|
|
508
|
+
clock: -> { @participants.now }
|
|
508
509
|
)
|
|
509
510
|
end
|
|
510
511
|
private :build_guardrail_wiring
|
data/lib/samagotchi/grants.rb
CHANGED
|
@@ -5,7 +5,6 @@ require "fileutils"
|
|
|
5
5
|
require "json"
|
|
6
6
|
require "openssl"
|
|
7
7
|
require_relative "steer"
|
|
8
|
-
require_relative "participant_mode"
|
|
9
8
|
require "securerandom"
|
|
10
9
|
require "time"
|
|
11
10
|
require_relative "atomic_file"
|
|
@@ -16,6 +15,7 @@ require_relative "session"
|
|
|
16
15
|
require_relative "redacted_inspect"
|
|
17
16
|
require_relative "private_files"
|
|
18
17
|
require_relative "participant_exposure"
|
|
18
|
+
require_relative "participant_turn_mode"
|
|
19
19
|
|
|
20
20
|
module Samagotchi
|
|
21
21
|
# Participants' access to one session each (the shared-sessions plan,
|
|
@@ -53,14 +53,13 @@ module Samagotchi
|
|
|
53
53
|
KEEP_ENDED = 30 * DAY
|
|
54
54
|
# last_used_at is written at most this often per grant.
|
|
55
55
|
TOUCH_INTERVAL = 60
|
|
56
|
-
|
|
57
|
-
# The only role in v1: a reviewer reads and (P3) comments.
|
|
56
|
+
# Grants retain the stored "reviewer" role; its user-facing label is participant.
|
|
58
57
|
ROLES = %w[reviewer].freeze
|
|
59
|
-
# The
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
PAIR_MODE =
|
|
58
|
+
# The mark of a grant this chi honours: every grant is issued with it
|
|
59
|
+
# (a participant's turns act under the owner's rules). A grant without
|
|
60
|
+
# it was issued by an older chi for read-only turns, which this chi
|
|
61
|
+
# doesn't run: it reads as ended (Grant#state :outdated).
|
|
62
|
+
PAIR_MODE = ParticipantTurnMode::PAIR_MODE
|
|
64
63
|
NAME_MAX = ParticipantName::MAX
|
|
65
64
|
ID_RE = /\Ap_[0-9a-f]{8}\z/
|
|
66
65
|
# D7: what a participant's turns (and the side calls they cause) may
|
|
@@ -142,17 +141,18 @@ module Samagotchi
|
|
|
142
141
|
# +cap+ (dollars) and +queue+ (turns waiting) as issued; nil in a
|
|
143
142
|
# grant from before them, which takes the config's (#spend_cap,
|
|
144
143
|
# #queue_limit).
|
|
145
|
-
# +exposure+: what the participant learns of the
|
|
144
|
+
# +exposure+: what the participant learns of the session's usage
|
|
146
145
|
# (ParticipantExposure; "own" for every grant today, and for one from
|
|
147
146
|
# before it). Kept as stored: a level this chi doesn't know reads as
|
|
148
147
|
# the narrowest, and is written back as it was.
|
|
149
148
|
# +extra+: the stored keys this chi doesn't know (a newer chi's,
|
|
150
149
|
# such as a field added to a grant without a version bump), written
|
|
151
150
|
# back as they were, so a rewrite here never drops them.
|
|
152
|
-
# +mode+: PAIR_MODE
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
-
|
|
151
|
+
# +mode+: PAIR_MODE for every grant this chi issues; nil in a grant an
|
|
152
|
+
# older chi issued for read-only turns, which reads as ended
|
|
153
|
+
# (#state :outdated). Stored only when set; a chi that doesn't know it
|
|
154
|
+
# keeps it in +extra+.
|
|
155
|
+
Grant = Data.define(:id, :session_id, :digest, :name, :role, :created_at, :expires_at, :revoked_at,
|
|
156
156
|
:revoked_by, :last_used_at, :cap, :queue, :identity, :exposure, :mode, :extra) do
|
|
157
157
|
# identity: the proxy identity (an email, lower case) the grant is
|
|
158
158
|
# bound to, nil for any (Web::ProxyGate; issued from shared-sessions P6).
|
|
@@ -163,7 +163,7 @@ module Samagotchi
|
|
|
163
163
|
|
|
164
164
|
def self.from_h(hash)
|
|
165
165
|
known = members - [:extra]
|
|
166
|
-
extra = hash.reject { |key, _| known.include?(key.to_s.to_sym) }
|
|
166
|
+
extra = hash.reject { |key, _| known.include?(key.to_s.to_sym) || self::RETIRED.include?(key.to_s) }
|
|
167
167
|
new(**known.to_h { |key| [key, hash[key.to_s]] }, extra: extra)
|
|
168
168
|
end
|
|
169
169
|
|
|
@@ -176,10 +176,13 @@ module Samagotchi
|
|
|
176
176
|
# The author a participant's turn carries (Principal#author).
|
|
177
177
|
def author = Steer.author_for(id)
|
|
178
178
|
|
|
179
|
-
# :active, :revoked
|
|
179
|
+
# :active, :revoked, :expired or :outdated (an older chi's grant
|
|
180
|
+
# for read-only turns: no PAIR_MODE) at +now+ (a Time). Derived, never
|
|
181
|
+
# written: an outdated grant is swept as any other once it expires.
|
|
180
182
|
def state(now)
|
|
181
183
|
return :revoked if revoked_at
|
|
182
184
|
return :expired if Time.iso8601(expires_at) <= now
|
|
185
|
+
return :outdated unless ParticipantTurnMode.invite_mode?(mode)
|
|
183
186
|
|
|
184
187
|
:active
|
|
185
188
|
end
|
|
@@ -196,7 +199,7 @@ module Samagotchi
|
|
|
196
199
|
|
|
197
200
|
# Never the digest: what chi share ls and the owner's routes show.
|
|
198
201
|
def public_h(now)
|
|
199
|
-
{ id: id, session_id: session_id,
|
|
202
|
+
{ id: id, session_id: session_id, name: name, role: role, created_at: created_at,
|
|
200
203
|
expires_at: expires_at, revoked_at: revoked_at, revoked_by: revoked_by, last_used_at: last_used_at,
|
|
201
204
|
state: state(now).to_s, cap: spend_cap, queue: queue_limit, identity: identity }
|
|
202
205
|
end
|
|
@@ -222,6 +225,12 @@ module Samagotchi
|
|
|
222
225
|
alias_method :to_s, :inspect
|
|
223
226
|
end
|
|
224
227
|
|
|
228
|
+
# Keys an older chi stored that this one reads as known and drops:
|
|
229
|
+
# "kind" (human / agent, retired with the agent label). Not kept in
|
|
230
|
+
# #extra, so a newer store's check for unknown fields (#reload) doesn't
|
|
231
|
+
# leave an older pair grant out for it.
|
|
232
|
+
Grant::RETIRED = %w[kind].freeze
|
|
233
|
+
|
|
225
234
|
# A new grant and its token: the only time the token exists outside
|
|
226
235
|
# the participant's hands.
|
|
227
236
|
Issued = Data.define(:grant, :token) do
|
|
@@ -331,16 +340,13 @@ module Samagotchi
|
|
|
331
340
|
# @param on_write [#call, nil] see #update
|
|
332
341
|
# @return [Issued]
|
|
333
342
|
# @raise [Invalid]
|
|
334
|
-
def issue(session_id:, name:,
|
|
335
|
-
on_write: nil)
|
|
343
|
+
def issue(session_id:, name:, role: "reviewer", ttl: nil, cap: nil, identity: nil, on_write: nil)
|
|
336
344
|
Session.check_id!(session_id)
|
|
337
345
|
ttl ||= Grants.default_ttl
|
|
338
346
|
cap = Grants.default_cap if cap.nil?
|
|
339
|
-
raise Invalid, "kind is human or agent, not #{kind}" unless KINDS.include?(kind)
|
|
340
347
|
raise Invalid, "role is reviewer, not #{role}" unless ROLES.include?(role)
|
|
341
348
|
raise Invalid, "a grant lasts 1 hour to 30 days" unless ttl.is_a?(Integer) && ttl.between?(3600, MAX_TTL)
|
|
342
349
|
raise Invalid, CAP_RANGE unless Grants.cap?(cap)
|
|
343
|
-
raise Invalid, "mode is #{PAIR_MODE} or none, not #{mode}" unless mode.nil? || mode == PAIR_MODE
|
|
344
350
|
|
|
345
351
|
clean = Grants.clean_name(name)
|
|
346
352
|
identity = Grants.clean_identity(identity) unless identity.nil?
|
|
@@ -348,10 +354,10 @@ module Samagotchi
|
|
|
348
354
|
issued = now
|
|
349
355
|
update(on_write) do |grants|
|
|
350
356
|
id = fresh_id(grants)
|
|
351
|
-
grant = Grant.new(id: id, session_id: session_id, digest: Grants.digest(token),
|
|
357
|
+
grant = Grant.new(id: id, session_id: session_id, digest: Grants.digest(token), name: clean,
|
|
352
358
|
role: role, created_at: stamp(issued), expires_at: stamp(issued + ttl), revoked_at: nil,
|
|
353
359
|
revoked_by: nil, last_used_at: nil, cap: cap.to_f, queue: Grants.default_queue,
|
|
354
|
-
identity: identity, mode:
|
|
360
|
+
identity: identity, mode: PAIR_MODE)
|
|
355
361
|
[grants + [grant], Issued.new(grant: grant, token: token)]
|
|
356
362
|
end
|
|
357
363
|
end
|
|
@@ -15,7 +15,8 @@ require_relative "edit_preview"
|
|
|
15
15
|
require_relative "system_one"
|
|
16
16
|
require_relative "tool_activity"
|
|
17
17
|
require_relative "turn_origin"
|
|
18
|
-
require_relative "
|
|
18
|
+
require_relative "grants"
|
|
19
|
+
require_relative "participant_turn_mode"
|
|
19
20
|
|
|
20
21
|
module Samagotchi
|
|
21
22
|
# An Engine's tool guardrails: who can approve (the interface), the YAML
|
|
@@ -58,8 +59,10 @@ module Samagotchi
|
|
|
58
59
|
# @param participant [#call] (author) → the participant's
|
|
59
60
|
# Participants::Entry (participants.json: their name, their grant's
|
|
60
61
|
# mode), nil for none
|
|
62
|
+
# @param clock [#call] → Time a participant's invite is checked at
|
|
63
|
+
# (ParticipantTurnMode), the Engine's SessionParticipants#now
|
|
61
64
|
def initialize(scratch:, tools:, session:, cancelled:, ask:, notify: ->(_message) {}, system_one: -> {},
|
|
62
|
-
system_one_runs: -> {}, cancel_controller: -> {}, participant: ->(_author) {})
|
|
65
|
+
system_one_runs: -> {}, cancel_controller: -> {}, participant: ->(_author) {}, clock: -> { Time.now })
|
|
63
66
|
@scratch = scratch
|
|
64
67
|
@tools_lookup = tools
|
|
65
68
|
@session_lookup = session
|
|
@@ -70,6 +73,9 @@ module Samagotchi
|
|
|
70
73
|
@system_one_runs = system_one_runs
|
|
71
74
|
@cancel_controller = cancel_controller
|
|
72
75
|
@participant = participant
|
|
76
|
+
# → Time: what a participant's invite is current at (the Engine's
|
|
77
|
+
# SessionParticipants clock).
|
|
78
|
+
@clock = clock
|
|
73
79
|
# Bundle name → the rules last loaded from it whole, kept while the
|
|
74
80
|
# installed version needs a newer chi; [name, version] said so once.
|
|
75
81
|
@loaded_bundle_rules = {}
|
|
@@ -118,14 +124,18 @@ module Samagotchi
|
|
|
118
124
|
mode: author && participant_turn_mode(session, entry))
|
|
119
125
|
end
|
|
120
126
|
|
|
121
|
-
# A participant's turn's mode:
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
127
|
+
# A participant's turn's mode: PAIR (it acts under the owner's
|
|
128
|
+
# guardrails, PairBoundary) when ParticipantTurnMode says :pair, else
|
|
129
|
+
# REFUSED (no current invite, an older chi's read-only one, no session,
|
|
130
|
+
# the owner's own Verify fresh child: ParticipantRefusal). Never nil
|
|
131
|
+
# for a participant's turn: the tools scrub the owner's env on any mode.
|
|
125
132
|
def participant_turn_mode(session, entry)
|
|
126
|
-
|
|
127
|
-
fresh ? fresh.turn_mode : ParticipantMode.for_turn(session, entry)
|
|
133
|
+
ParticipantTurnMode.of(entry: entry, session: session, now: @clock.call) == :pair ? PAIR : REFUSED
|
|
128
134
|
end
|
|
135
|
+
|
|
136
|
+
# A participant's turn's modes (TurnContext#participant_mode).
|
|
137
|
+
PAIR = :pair
|
|
138
|
+
REFUSED = :refused
|
|
129
139
|
private :participant_turn_mode
|
|
130
140
|
|
|
131
141
|
# The gate every tool call asks first, given the call's TurnContext
|
|
@@ -149,10 +159,9 @@ module Samagotchi
|
|
|
149
159
|
# The gate's core checks, in order. A delegate child's boundary comes
|
|
150
160
|
# before the rules, so its ask keeps the child-boundary rule id (and
|
|
151
161
|
# its once/session scopes) when a strict rule asks too. The
|
|
152
|
-
# participant's boundary comes before both, by the
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
-
# never asks about it; both are no-ops for the owner's turns.
|
|
162
|
+
# participant's boundary comes before both, by the turn's mode: a pair
|
|
163
|
+
# turn's (PairBoundary), else every call denied (ParticipantRefusal).
|
|
164
|
+
# Either is a no-op for the owner's turns.
|
|
156
165
|
# @param turn [TurnContext] the call's turn
|
|
157
166
|
def checks(turn)
|
|
158
167
|
rules = self.rules
|
|
@@ -163,13 +172,9 @@ module Samagotchi
|
|
|
163
172
|
# The boundary for a participant's turn in this session (#checks), by
|
|
164
173
|
# the turn's mode.
|
|
165
174
|
def participant_boundary(turn)
|
|
166
|
-
|
|
167
|
-
end
|
|
175
|
+
return pair_boundary(turn) if turn.participant_mode == PAIR
|
|
168
176
|
|
|
169
|
-
|
|
170
|
-
# no-op unless +turn+'s author is a participant's.
|
|
171
|
-
def review_boundary(turn)
|
|
172
|
-
Guardrails::ReviewBoundary.new(author: -> { turn.author }, root: -> { boundary_root(turn.git) })
|
|
177
|
+
Guardrails::ParticipantRefusal.new(author: -> { turn.author })
|
|
173
178
|
end
|
|
174
179
|
|
|
175
180
|
# A participant's pair turn's boundary (Guardrails::PairBoundary): a
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "approvals"
|
|
4
|
+
require_relative "../turn_origin"
|
|
5
|
+
|
|
6
|
+
module Samagotchi
|
|
7
|
+
module Guardrails
|
|
8
|
+
# Which stored approvals an ask may use: the one place that says so
|
|
9
|
+
# (Gate#settle_ask asks it before it looks in the store).
|
|
10
|
+
# all — any stored entry: session, repo or rule (an owner's turn);
|
|
11
|
+
# session — only this session's own "Allow for this session" entries:
|
|
12
|
+
# a participant's turn (the owner's repo or rule approvals
|
|
13
|
+
# are the owner's, for the owner's turns), and an ask of a
|
|
14
|
+
# rule in SESSION_ONLY_RULES (a delegate child's boundary: a
|
|
15
|
+
# repo entry would hold in every worktree, for every child);
|
|
16
|
+
# none — no stored entry: a fresh ask (Verdict#fresh_ask, the pair
|
|
17
|
+
# boundary's own asks).
|
|
18
|
+
# A later policy (say a softer one for participants) is one more
|
|
19
|
+
# POLICIES key and one branch in .policy.
|
|
20
|
+
module ApprovalUse
|
|
21
|
+
POLICIES = { all: Approvals::STORED_SCOPES, session: %w[session].freeze, none: [].freeze }.freeze
|
|
22
|
+
# Rules a stored answer allows only for its session: their asks offer
|
|
23
|
+
# once/session, and a repo entry for the same call (from another
|
|
24
|
+
# rule) would hold in every worktree, for every child. The id is
|
|
25
|
+
# ChildBoundary::RULE (spelled here so the store needs no shell lexer;
|
|
26
|
+
# approval_use_spec checks they agree).
|
|
27
|
+
SESSION_ONLY_RULES = %w[child-boundary].freeze
|
|
28
|
+
|
|
29
|
+
module_function
|
|
30
|
+
|
|
31
|
+
# Fail closed: only a turn known to be the owner's gets :all. A call
|
|
32
|
+
# with no TurnContext (nil, or anything that can't say whose turn it
|
|
33
|
+
# is) gets :session, and so does one whose judged context names a
|
|
34
|
+
# participant's author (verdict.context's origin), whatever the turn
|
|
35
|
+
# says: a wider approval is the owner's, and an unknown caller is no
|
|
36
|
+
# owner.
|
|
37
|
+
# @param verdict [Verdict] the ask
|
|
38
|
+
# @param turn [TurnContext, nil] the call's turn
|
|
39
|
+
# @return [Symbol] a POLICIES key
|
|
40
|
+
def policy(verdict, turn)
|
|
41
|
+
return :none if verdict.fresh_ask?
|
|
42
|
+
return :session unless turn.respond_to?(:participant?)
|
|
43
|
+
return :session if turn.participant? || participant_call?(verdict) || SESSION_ONLY_RULES.include?(verdict.rule.to_s)
|
|
44
|
+
|
|
45
|
+
:all
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# @return [Array<String>] the stored scopes +verdict+ may match (empty: none)
|
|
49
|
+
def scopes(verdict, turn) = POLICIES.fetch(policy(verdict, turn))
|
|
50
|
+
|
|
51
|
+
# Whether the call's judged context (Gate#evaluate's) names a
|
|
52
|
+
# participant's author.
|
|
53
|
+
def participant_call?(verdict)
|
|
54
|
+
origin = verdict.context.respond_to?(:origin) ? verdict.context.origin : nil
|
|
55
|
+
!!TurnOrigin.from(origin)&.participant?
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -37,10 +37,6 @@ module Samagotchi
|
|
|
37
37
|
COLLECTION = "approvals"
|
|
38
38
|
FORMAT = StateFormat.new(version: 1, members: [StateFormat.required(:scope), StateFormat.extra(:extra, in_version: 1)])
|
|
39
39
|
STORED_SCOPES = %w[session repo rule].freeze
|
|
40
|
-
# Rules a stored answer allows only for its session: their asks offer
|
|
41
|
-
# once/session, and a repo entry for the same call (from another
|
|
42
|
-
# rule) would hold in every worktree, for every child.
|
|
43
|
-
SESSION_ONLY_RULES = %w[child-boundary].freeze
|
|
44
40
|
|
|
45
41
|
# @param sessions_dir [String] Session's state dir
|
|
46
42
|
# ($XDG_STATE_HOME/samagotchi/sessions): the store sits beside it,
|
|
@@ -62,9 +58,11 @@ module Samagotchi
|
|
|
62
58
|
end
|
|
63
59
|
|
|
64
60
|
# @param verdict [Verdict] an ask with its targets and context
|
|
61
|
+
# @param scopes [Array<String>] the entries' scopes it may use
|
|
62
|
+
# (ApprovalUse.scopes: which ones an ask may use is decided there)
|
|
65
63
|
# @return [Hash, nil] the first entry that allows it
|
|
66
|
-
def match(verdict)
|
|
67
|
-
self.class.find_in(read.first, verdict)
|
|
64
|
+
def match(verdict, scopes: STORED_SCOPES)
|
|
65
|
+
self.class.find_in(read.first, verdict, scopes: scopes)
|
|
68
66
|
end
|
|
69
67
|
|
|
70
68
|
# Store the verdict's allowed scope (not "once").
|
|
@@ -77,17 +75,17 @@ module Samagotchi
|
|
|
77
75
|
end
|
|
78
76
|
|
|
79
77
|
# @param list [Array<Hash>] entries
|
|
78
|
+
# @param scopes [Array<String>] the scopes of the entries it may use
|
|
80
79
|
# @return [Hash, nil] the first of +list+ that allows +verdict+
|
|
81
|
-
def self.find_in(list, verdict)
|
|
80
|
+
def self.find_in(list, verdict, scopes: STORED_SCOPES)
|
|
82
81
|
key = key_for(verdict)
|
|
83
82
|
place = place_for(verdict)
|
|
84
83
|
repo = verdict.targets&.repo
|
|
85
84
|
here = ->(e) { e["repo"] ? e["repo"] == repo : e["repo_root"] == place }
|
|
86
85
|
session_id = verdict.context&.session_id
|
|
87
|
-
session_only = SESSION_ONLY_RULES.include?(verdict.rule.to_s)
|
|
88
86
|
command_place = session_place(verdict)
|
|
89
87
|
list.find do |e|
|
|
90
|
-
next false
|
|
88
|
+
next false unless scopes.include?(e["scope"])
|
|
91
89
|
|
|
92
90
|
case e["scope"]
|
|
93
91
|
when "session"
|
|
@@ -269,8 +267,8 @@ module Samagotchi
|
|
|
269
267
|
# The store's entries, then this session's own.
|
|
270
268
|
def entries = @store.entries + @mutex.synchronize { @own.dup }
|
|
271
269
|
|
|
272
|
-
def match(verdict)
|
|
273
|
-
@mutex.synchronize { Approvals.find_in(@own, verdict) } || @store.match(verdict)
|
|
270
|
+
def match(verdict, scopes: STORED_SCOPES)
|
|
271
|
+
@mutex.synchronize { Approvals.find_in(@own, verdict, scopes: scopes) } || @store.match(verdict, scopes: scopes)
|
|
274
272
|
end
|
|
275
273
|
|
|
276
274
|
def add(verdict, scope)
|
|
@@ -4,6 +4,7 @@ require_relative "verdict"
|
|
|
4
4
|
require_relative "context"
|
|
5
5
|
require_relative "targets"
|
|
6
6
|
require_relative "approvals"
|
|
7
|
+
require_relative "approval_use"
|
|
7
8
|
require_relative "protected_paths"
|
|
8
9
|
require_relative "../log"
|
|
9
10
|
|
|
@@ -81,12 +82,14 @@ module Samagotchi
|
|
|
81
82
|
# Settle an ask: the approver asks the user; with none, or one that
|
|
82
83
|
# fails, it is denied.
|
|
83
84
|
# @return [Verdict]
|
|
84
|
-
# A stored approval that covers the call allows it without asking
|
|
85
|
-
#
|
|
85
|
+
# A stored approval that covers the call allows it without asking
|
|
86
|
+
# (only the scopes ApprovalUse lets this ask use: none for a fresh
|
|
87
|
+
# ask, this session's own for a participant's turn); an answer that
|
|
88
|
+
# allows it beyond this once is stored.
|
|
86
89
|
# @param context [TurnContext] the call's turn (the approver's)
|
|
87
90
|
def settle_ask(verdict, context:)
|
|
88
91
|
approvals = @approvals_lookup.call
|
|
89
|
-
if
|
|
92
|
+
if (entry = stored(approvals, verdict, ApprovalUse.scopes(verdict, context)))
|
|
90
93
|
verdict.settle!(:allow, decided_by: "approval")
|
|
91
94
|
verdict.scope = entry["scope"]
|
|
92
95
|
return verdict
|
|
@@ -104,8 +107,10 @@ module Samagotchi
|
|
|
104
107
|
|
|
105
108
|
private
|
|
106
109
|
|
|
107
|
-
def stored(approvals, verdict)
|
|
108
|
-
|
|
110
|
+
def stored(approvals, verdict, scopes)
|
|
111
|
+
return nil if scopes.empty?
|
|
112
|
+
|
|
113
|
+
approvals&.match(verdict, scopes: scopes)
|
|
109
114
|
rescue StandardError
|
|
110
115
|
nil
|
|
111
116
|
end
|
|
@@ -9,10 +9,10 @@ require_relative "../steer"
|
|
|
9
9
|
|
|
10
10
|
module Samagotchi
|
|
11
11
|
module Guardrails
|
|
12
|
-
# A participant's
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
12
|
+
# A participant's turn (GuardrailWiring::PAIR): it acts with the
|
|
13
|
+
# session's tools under the owner's guardrails, and their asks go to the
|
|
14
|
+
# owner (GuardrailWiring#request_approval). This check sits in the
|
|
15
|
+
# participant boundary's seat (GuardrailWiring#checks), on in
|
|
16
16
|
# every guardrails mode and with guardrails.enabled: false, active only
|
|
17
17
|
# while the running turn's author is a participant. An accident guard
|
|
18
18
|
# for a trusted team, not containment. It denies, never asks (the
|
|
@@ -146,8 +146,8 @@ module Samagotchi
|
|
|
146
146
|
)
|
|
147
147
|
|
|
148
148
|
# @param author [#call] → String, nil: the running turn's author
|
|
149
|
-
# (the call's TurnContext#author, GuardrailWiring#
|
|
150
|
-
#
|
|
149
|
+
# (the call's TurnContext#author, GuardrailWiring#pair_boundary);
|
|
150
|
+
# the check is off unless it is a
|
|
151
151
|
# participant's (Steer.participant_author?)
|
|
152
152
|
# @param denied_dirs [#call] → Array<String>: chi's own dirs
|
|
153
153
|
# @param home [#call] → String, nil
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../steer"
|
|
4
|
+
|
|
5
|
+
module Samagotchi
|
|
6
|
+
module Guardrails
|
|
7
|
+
# The participant boundary's seat (GuardrailWiring#checks) for a
|
|
8
|
+
# participant's turn this chi doesn't run under the owner's rules: no
|
|
9
|
+
# current invite (an older chi's read-only one, no grant at all), a
|
|
10
|
+
# Verify fresh child saved for a read-only turn, or no session. The
|
|
11
|
+
# worker refuses such a turn before it starts (Worker#participant_refusal);
|
|
12
|
+
# this is the fail-closed fallback should one start anyway: every call is
|
|
13
|
+
# denied, nobody is asked. A no-op for the owner's turns.
|
|
14
|
+
class ParticipantRefusal
|
|
15
|
+
RULE = "participant-refused"
|
|
16
|
+
SOURCE = "core"
|
|
17
|
+
REASON = "this participant's turn runs no tools: their invite is from an older chi or has ended"
|
|
18
|
+
ADVICE = "Answer in text only; the session's owner can invite them again."
|
|
19
|
+
|
|
20
|
+
# @param author [#call] → String, nil: the running turn's author
|
|
21
|
+
def initialize(author:)
|
|
22
|
+
@author = author
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Vote on +verdict+.
|
|
26
|
+
def check(verdict)
|
|
27
|
+
return verdict unless Steer.participant_author?(@author.call)
|
|
28
|
+
|
|
29
|
+
verdict.deny!(REASON, rule: RULE, source: SOURCE, decided_by: "core", advice: ADVICE)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -14,9 +14,8 @@ module Samagotchi
|
|
|
14
14
|
# checked on the path as given and as it resolves (a symlink in the
|
|
15
15
|
# project to ~/.ssh is ~/.ssh; a `..` after a symlinked dir climbs out
|
|
16
16
|
# of its target, as the kernel opens it: PathResolve.reals).
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
# check.
|
|
17
|
+
# PairBoundary asks it for every path a participant's turn reads or
|
|
18
|
+
# writes.
|
|
20
19
|
class ReviewPaths
|
|
21
20
|
# Home folders that hold keys and tokens, never read in a review turn
|
|
22
21
|
# (nor read or written in a pair turn).
|
|
@@ -13,7 +13,7 @@ require_relative "guardrails/approvals"
|
|
|
13
13
|
require_relative "guardrails/protected_paths"
|
|
14
14
|
require_relative "guardrails/scratch_writes"
|
|
15
15
|
require_relative "guardrails/child_boundary"
|
|
16
|
-
require_relative "guardrails/
|
|
16
|
+
require_relative "guardrails/participant_refusal"
|
|
17
17
|
require_relative "guardrails/pair_boundary"
|
|
18
18
|
require_relative "guardrails/load_failures"
|
|
19
19
|
require_relative "guardrails/rules"
|
|
@@ -404,12 +404,9 @@ module Samagotchi
|
|
|
404
404
|
# A continue's copy: +previous+'s list as a note file in the new link,
|
|
405
405
|
# read fresh, its unabsorbed newest file included. It runs inside the
|
|
406
406
|
# continue's rollback, and a link without the list is still a good link:
|
|
407
|
-
# a failure is logged.
|
|
408
|
-
# participants could differ (as SessionChain.carried_answer).
|
|
407
|
+
# a failure is logged.
|
|
409
408
|
# @return [String, nil] the note file's path
|
|
410
409
|
def carry(previous, to:, state_dir:)
|
|
411
|
-
return nil if previous.review?
|
|
412
|
-
|
|
413
410
|
list = current(previous.id, Session.load(previous.id, state_dir: state_dir).messages, state_dir: state_dir)
|
|
414
411
|
return nil if list.empty?
|
|
415
412
|
|
|
@@ -81,7 +81,7 @@ module Samagotchi
|
|
|
81
81
|
private
|
|
82
82
|
|
|
83
83
|
def ask(judgment, session, message)
|
|
84
|
-
return if session.nil? || session.id.nil? || session.scratch
|
|
84
|
+
return if session.nil? || session.id.nil? || session.scratch
|
|
85
85
|
|
|
86
86
|
items = Objectives.current(session.id, session.messages, state_dir: @state_dir).items
|
|
87
87
|
.select { |item| item.status == Objectives::ACTIVE }.first(MAX_OBJECTIVES)
|
|
@@ -107,7 +107,7 @@ module Samagotchi
|
|
|
107
107
|
session = turn.session
|
|
108
108
|
return false unless active?(Objectives.current(session.id, session.messages, state_dir: engine.session_state_dir))
|
|
109
109
|
return false if engine.interface == :non_interactive
|
|
110
|
-
return false unless OwnerPrompt.turn?(
|
|
110
|
+
return false unless OwnerPrompt.turn?(author: turn.origin.author)
|
|
111
111
|
|
|
112
112
|
worked_without_move?(session.messages)
|
|
113
113
|
end
|
|
@@ -6,7 +6,7 @@ require_relative "steer"
|
|
|
6
6
|
module Samagotchi
|
|
7
7
|
# The session owner's own words: the one rule for what may act on a
|
|
8
8
|
# session's conversation by itself (toolkit suggest, attached context's
|
|
9
|
-
# candidates). A participant's turn
|
|
9
|
+
# candidates). A participant's turn never does.
|
|
10
10
|
module OwnerPrompt
|
|
11
11
|
module_function
|
|
12
12
|
|
|
@@ -23,11 +23,8 @@ module Samagotchi
|
|
|
23
23
|
!(field(message, :turn_id) || field(message, MessageTime::KEY)).nil?
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
# Whether a turn by +author+
|
|
27
|
-
|
|
28
|
-
def turn?(session:, author:)
|
|
29
|
-
!session&.review? && !Steer.participant_author?(author)
|
|
30
|
-
end
|
|
26
|
+
# Whether a turn by +author+ is the owner's own: not a participant's.
|
|
27
|
+
def turn?(author:) = !Steer.participant_author?(author)
|
|
31
28
|
|
|
32
29
|
def field(hash, key)
|
|
33
30
|
return nil unless hash.is_a?(Hash)
|