Class: Textus::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/store.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Store

Returns a new instance of Store.



45
46
47
48
49
# File 'lib/textus/store.rb', line 45

def initialize(root)
  @container = build_container(File.expand_path(root))
  bootstrap_hooks
  events.publish(:store_loaded, ctx: Hooks::Context.new(scope: as(Role::DEFAULT)))
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



5
6
7
# File 'lib/textus/store.rb', line 5

def container
  @container
end

Class Method Details

.discover(start_dir = Dir.pwd, root: nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/textus/store.rb', line 14

def self.discover(start_dir = Dir.pwd, root: nil)
  explicit = root || ENV.fetch("TEXTUS_ROOT", nil)
  return discover_explicit(explicit) if explicit

  ascend_for_store(File.expand_path(start_dir)) ||
    raise(IoError.new("no .textus directory found from #{start_dir}"))
end

Instance Method Details

#as(role, dry_run: false, correlation_id: nil) ⇒ Object



62
63
64
# File 'lib/textus/store.rb', line 62

def as(role, dry_run: false, correlation_id: nil)
  RoleScope.new(container: container, role: role, dry_run: dry_run, correlation_id: correlation_id)
end

#session(role:) ⇒ Object

Build an agent Session oriented at the current cursor/manifest — the Ruby equivalent of an MCP ‘initialize`. ADR 0036.



53
54
55
56
57
58
59
60
# File 'lib/textus/store.rb', line 53

def session(role:)
  Textus::Session.new(
    role: role,
    cursor: audit_log.latest_seq,
    propose_zone: manifest.policy.propose_zone_for(role),
    manifest_etag: file_store.etag(File.join(root, "manifest.yaml")),
  )
end