Class: Insika::Context::Providers::Briefing

Inherits:
Insika::ContextProvider show all
Defined in:
lib/insika/context/providers/briefing.rb

Overview

Read path for the session briefing: the per-session working-state the agent keeps and asks for. Thin adapter over the SessionStore, same pattern as Memory: one :system fragment, deterministic. The MISSING list is rendered, never implied — that list is what stops the model re-asking for a field already given.

Instance Method Summary collapse

Methods inherited from Insika::ContextProvider

#layer, #required?

Constructor Details

#initialize(session_store:) ⇒ Briefing

Returns a new instance of Briefing.



12
13
14
# File 'lib/insika/context/providers/briefing.rb', line 12

def initialize(session_store:)
  @session_store = session_store
end

Instance Method Details

#call(request) ⇒ Object

required? == false (default): a store failure degrades via the Builder's warning path, never aborts the turn.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/insika/context/providers/briefing.rb', line 28

def call(request)
  session = request.respond_to?(:session) ? request.session : nil
  return [] if session.nil? # one-shot turns have no briefing

  briefing = briefing_for(session)
  fields = briefing["fields"] || {}
  declared = Array(request.profile.briefing_fields)
  return [] if declared.empty? # defensive; enabled_for? already gates

  block = format_block(declared, fields, briefing["next_step"])
  return [] if block.nil?

  [ContextFragment.build(content: block, placement: :system,
                         priority: Context::Priority::BRIEFING,
                         source: id)]
end

#enabled_for?(profile) ⇒ Boolean

Pack-declared: no briefing_fields -> no provider (the Builder still applies the context_providers allowlist on top — two gates, like Memory).

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/insika/context/providers/briefing.rb', line 21

def enabled_for?(profile)
  fields = profile.respond_to?(:briefing_fields) ? profile.briefing_fields : nil
  !Array(fields).empty?
end

#idObject

Stable id -> the context-trace category "briefing".



17
# File 'lib/insika/context/providers/briefing.rb', line 17

def id = "briefing"