Class: Textus::Read::Pulse

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

Overview

Aggregator over audit + freshness + review + doctor. One round-trip for an agent’s per-turn heartbeat. All component reads are existing APIs; pulse is sugar with a stable envelope shape and a monotonic cursor (seq).

Instance Method Summary collapse

Constructor Details

#initialize(container:, call:) ⇒ Pulse

Returns a new instance of Pulse.



10
11
12
13
14
15
16
17
18
# File 'lib/textus/read/pulse.rb', line 10

def initialize(container:, call:)
  @container  = container
  @call       = call
  @manifest   = container.manifest
  @file_store = container.file_store
  @audit_log  = container.audit_log
  @root       = container.root
  @events     = container.events
end

Instance Method Details

#call(since: 0) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/textus/read/pulse.rb', line 20

def call(since: 0)
  freshness_rows = freshness.call
  {
    "cursor" => @audit_log.latest_seq,
    "changed" => audit_changes_since(since),
    "stale" => freshness_rows.select { |r| r[:status] == :stale }.map { |r| r[:key] },
    "pending_review" => review_keys,
    "doctor" => doctor_summary,
    "manifest_etag" => manifest_etag,
    "next_due_at" => soonest_due(freshness_rows),
    "hook_errors" => hook_errors_since(since),
  }
end