Module: Ace::Hitl::Lifecycle::Duty

Defined in:
lib/ace/hitl/lifecycle/duty.rb

Overview

The standing-duty projection (spec 8wm.t.y21 §7; contract of the deployed hitl_status/duty surface): pending answerable requests with their effect declaration visibility, plus everything the effect layer has escalated. Root-only, like the store reads it projects from.

Class Method Summary collapse

Class Method Details

.pending_entry(value) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ace/hitl/lifecycle/duty.rb', line 26

def pending_entry(value)
  {
    "id" => value["id"],
    "work" => value["work"],
    "attempt" => value["attempt"],
    "project" => value["project"],
    "harness" => value["harness"],
    "kind" => value["kind"],
    "state" => "created",
    "requester" => value["requester"],
    "created_at" => value["created_at"],
    "has_effect" => value["effect"].is_a?(Hash) && Array(value["effect"]["argv"]).any?
  }
end

.project(store) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/ace/hitl/lifecycle/duty.rb', line 16

def project(store)
  store.require_root!("duty")
  {
    "pending" => store.pending.map { |value| pending_entry(value) },
    "escalated" => store.states.select do |record|
      record["effect_state"] == Effects::OUTCOME_ESCALATED
    end
  }
end