{#- The role templates' one-line fact row, the kit's "Facts" pattern. -#}
{%- macro row(label, value, note="", name="facts") -%}
{{ label }}
{{ value }}{% if note %} {{ note }}{% endif %}
…
{{ label }}
{{ label }}
{{ value }}
{% if note %}
{{ note }}
{% endif %}
{%- endmacro -%}
{#- A "not set up yet" state: its title, what to do, and where, a link the
frame opens as one of core's tabs (`data-om-opens`, kit 0.12.0). -#}
{%- macro next_step(title, text, opens="", where="") -%}
{%- endmacro -%}
{#- An act whose second pair of eyes is on for this person (contract v20,
W6.29): `tool`, the act's tool name; `person`, the request's caller;
`prepared`, the prepared change the page was opened from, if any. Says a
second person makes the change, and to its preparer that it is not
theirs to make. -#}
{%- macro second_pair_of_eyes(tool, person, prepared=none) -%}
{%- if tool in person.second_pair_of_eyes -%}
{%- if prepared and prepared.prepared_by_subject == person.subject -%}
Needs a second person: you prepared this change, so someone other than you makes it.
{%- else -%}
Needs a second person: prepare this change, and someone other than you makes it.
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
{#- The Sessions section's rows (contract v27; spec/sessions-and-data-
report-their-latency-and-quality, "Session latency fields"): one line per
open session, a `meridian.roles.SessionLatency` -- its round trip at p99
over the last minute, the rest a tap away. -#}
{%- macro ms(ns) -%}{{ "%.1f"|format(ns / 1000000) }} ms{%- endmacro -%}
{%- macro session_rows(sessions) -%}
{%- if not sessions -%}
{{ row("Sessions", "None measured yet") }}
{%- endif -%}
{%- for s in sessions -%}
{%- set value -%}{% if s.rtt.p99_ns %}RTT p99 {{ ms(s.rtt.p99_ns) }}{% else %}RTT not measured{% endif %}{%- endset -%}
{%- set note -%}{{ s.transport }}{% if s.order_ack.p99_ns %} · order ack p99 {{ ms(s.order_ack.p99_ns) }}{% endif %}{% if s.fill_delay.p99_ns %} · fill delay p99 {{ ms(s.fill_delay.p99_ns) }}{% endif %}{% for f in s.feed_delay %} · {{ f.dataset }} feed delay p99 {{ ms(f.p99_ns) }}{% endfor %} · gaps {{ s.gaps }}, reconnects {{ s.reconnects }}, rate-limited {{ s.rate_limited }} in the last hour{% if s.backlog_peak %} · backlog peak {{ s.backlog_peak }}{% endif %}{% if s.ceiling and s.ceiling.rtt_p99_ns %} · ceiling {{ ms(s.ceiling.rtt_p99_ns) }}{% endif %}{%- endset -%}
{{ row(s.session, value, note, name="sessions") }}
{%- endfor -%}
{%- endmacro -%}