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, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view

Constructor Details

#initialize(container:, call:) ⇒ Pulse

Returns a new instance of Pulse.



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

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



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

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,
    "contract_etag" => contract_etag,
    "next_due_at" => soonest_due(freshness_rows),
    "hook_errors" => hook_errors_since(since),
  }
end