Class: Textus::Read::Pulse

Inherits:
Object
  • Object
show all
Extended by:
Contract::DSL
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

Methods included from Contract::DSL

arg, contract, contract?, response, summary, surfaces, verb

Constructor Details

#initialize(container:, call:) ⇒ Pulse

Returns a new instance of Pulse.



17
18
19
20
21
22
23
24
25
# File 'lib/textus/read/pulse.rb', line 17

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



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/textus/read/pulse.rb', line 27

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