Class: Textus::Session

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/textus/session.rb

Overview

The agent session: per-connection (MCP), per-process (CLI), or per-loop (Ruby) orientation state — the audit cursor plus the contract etag and propose_lane captured at boot. Immutable Dry::Struct::Value; advance_cursor and with return new instances. ADR 0036; contract_etag widened in ADR 0074.

Instance Method Summary collapse

Instance Method Details

#advance_cursor(new_cursor) ⇒ Object



18
# File 'lib/textus/session.rb', line 18

def advance_cursor(new_cursor) = with(cursor: new_cursor)

#check_etag!(observed_etag) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/textus/session.rb', line 20

def check_etag!(observed_etag)
  return if observed_etag == contract_etag

  raise Textus::ContractDrift.new(
    "contract changed (manifest/hooks/schemas were #{short_etag(contract_etag)}, " \
    "now #{short_etag(observed_etag)}); re-run boot",
  )
end

#with(**attrs) ⇒ Object



16
# File 'lib/textus/session.rb', line 16

def with(**attrs) = self.class.new(to_h.merge(attrs))