Class: Textus::Read::Freshness
- Inherits:
-
Object
- Object
- Textus::Read::Freshness
- Extended by:
- Contract::DSL
- Defined in:
- lib/textus/read/freshness.rb
Overview
Per-entry lifecycle scan (ADR 0079, 0085). Walks every entry declared in the manifest, consults ‘rules.for(key)` for a `lifecycle:` policy, and reports the unified verdict. Status is one of :fresh, :expired, or :no_policy; the row also carries the policy’s :action (on_expire).
ADR 0085 removed the public ‘freshness` verb: there is no `:cli`/`:mcp` surface. This is now a Ruby-only internal scan (empty `surfaces`, the honest home reserved by ADR 0073) consumed by `pulse` (which derives `stale` + `next_due_at` from it) and the hook `Context`. Humans drill into per-entry lifecycle detail via `get` (last_fetched_at) + `rule_explain` (the ttl / on_expire policy) instead of a dedicated verb.
Instance Method Summary collapse
- #call(prefix: nil, zone: nil) ⇒ Object
-
#initialize(container:, call:) ⇒ Freshness
constructor
A new instance of Freshness.
-
#soonest_due(prefix: nil, zone: nil) ⇒ Object
Returns the soonest ‘next_due_at` across all entries with a fetch policy, as an ISO-8601 string, or nil if none.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Constructor Details
#initialize(container:, call:) ⇒ Freshness
Returns a new instance of Freshness.
24 25 26 27 28 29 |
# File 'lib/textus/read/freshness.rb', line 24 def initialize(container:, call:) @container = container @call = call @manifest = container.manifest @file_store = container.file_store end |
Instance Method Details
#call(prefix: nil, zone: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/textus/read/freshness.rb', line 43 def call(prefix: nil, zone: nil) rows = [] @manifest.data.entries.each do |mentry| next if prefix && !mentry.key.start_with?(prefix) next if zone && mentry.zone != zone rows << row_for(mentry) end rows end |
#soonest_due(prefix: nil, zone: nil) ⇒ Object
Returns the soonest ‘next_due_at` across all entries with a fetch policy, as an ISO-8601 string, or nil if none.
33 34 35 36 37 38 39 40 41 |
# File 'lib/textus/read/freshness.rb', line 33 def soonest_due(prefix: nil, zone: nil) times = call(prefix: prefix, zone: zone) .map { |r| r[:next_due_at] } .compact .map { |t| Time.parse(t) } return nil if times.empty? times.min.utc.iso8601 end |