{% from 'components/page-heading.html' import page_heading %} {% from 'components/artifact-type.html' import artifact_type %} {{ page_heading(t['context-diagnostic-detail']) }}
{% set diagnostic = context_diagnostic %} {% set prepared = diagnostic.prepared %} {% set receipt = diagnostic.receipt %} {% from 'components/context-stage-texts.html' import candidate_text, candidate_text_drawer with context %} {% macro phase_duration(phase) -%} {%- set duration = context_phase_durations.get(phase) if context_phase_durations is defined else none -%} {%- if duration and duration.duration_ms -%}{{ '%.2f'|format(duration.duration_ms) }} ms · {{ duration.count }}{%- endif -%} {%- endmacro %}

1{{ t.context_query }}

{% if diagnostic.record.query_text is not none %}
{{ diagnostic.record.query_text if diagnostic.record.query_text else t.context_query_empty }}
{% else %}
{{ t.context_query_not_recorded }}
{% endif %}
{% if diagnostic.record.diagnostics_payload.get('text_capture_complete') == false %}
{{ t.context_text_incomplete }}
{% endif %}

2{{ t.context_flow_search }}{{ phase_duration('context_searches') }}

{% for group in context_search_rows %}{% else %}{% endfor %}
{{ t.context_round }}{{ t.auto_family }}{{ t.context_mode }}{{ t.context_outcome }}{{ t.context_retrieved }}{{ t.context_total_duration }}{{ t.context_reason }}{{ t.context_calls }}{{ t.context_original_text }}
{{ group.round }}{{ artifact_type(group.family) }}{{ t.get('context_mode_' ~ group.mode, t.unknown_value) if group.mode else t.unknown_value }} {{ t['context_outcome_' ~ group.outcome] }}{{ group.result_count if group.result_count|default(none) is not none else t.unknown_value }}{{ '%.2f'|format(group.duration_ms) ~ ' ms' if group.duration_ms|default(none) is not none else t.unknown_value }} {% if group.error_code|default(none) %}{{ t.get('context_error_' ~ group.error_code, group.error_code) }}{% elif group.configured|default(none) == false %}{{ t.context_not_configured }}{% else %}{{ t['context_fallback_' ~ group.fallback_reason] }}{% endif %}{% if group.error_code|default(none) and group.fallback_reason != 'none' %}
{{ t['context_fallback_' ~ group.fallback_reason] }}
{% endif %}
{{ group.count if group.count is not none else t.unknown_value }}{% call candidate_text_drawer('context-drawer-search-' ~ loop.index) %}{{ candidate_text(group.text_snapshot) }}{% endcall %}
{{ t.context_no_path }}

3{{ t.context_flow_rerank }}{{ phase_duration('context_reranks') }}

{% for group in context_rerank_rows %}{% else %}{% endfor %}
{{ t.context_round }}{{ t.context_rerank_input }}{{ t.context_text_stage_rerank_input }}{{ t.context_rerank_output }}{{ t.context_text_stage_rerank_output }}{{ t.context_outcome }}{{ t.context_reason }}{{ t.context_calls }}
{{ group.round }}{{ group.input_count if group.input_count|default(none) is not none else t.unknown_value }}{% call candidate_text_drawer('context-drawer-rerank-input-' ~ loop.index) %}{{ candidate_text(group.input_text) }}{% endcall %}{{ group.output_count if group.output_count|default(none) is not none else t.unknown_value }}{% call candidate_text_drawer('context-drawer-rerank-output-' ~ loop.index) %}{{ candidate_text(group.output_text) }}{% endcall %}{{ t['context_outcome_' ~ group.outcome] if group.outcome else t.unknown_value }}{{ t['context_fallback_' ~ group.fallback_reason] if group.fallback_reason else t.unknown_value }}{{ group.count if group.count is not none else t.unknown_value }}
{{ t.context_no_path }}

4{{ t.context_flow_assembly }}{{ phase_duration('context_assembly_evidence') }}

{% for row in context_assembly_rows %}{% else %}{% endfor %}
{{ t.auto_family }}{{ t.context_assembly_candidates }}{{ t.context_selected }}{{ t.context_omitted }}{{ t.context_original_text }}
{{ artifact_type(row.family) }}{{ row.candidates if row.candidates is not none else t.unknown_value }}{{ row.selected if row.selected is not none else t.unknown_value }}{% for group in row.omitted %}
{{ t['context_omit_' ~ group.reason] }}{% if group.reason != 'not_retrieved' %} · {{ group.count }}{% endif %}
{% else %}{{ t.context_no_omissions if row.omissions_known else t.unknown_value }}{% endfor %}
{% call candidate_text_drawer('context-drawer-assembly-' ~ loop.index) %}{% for snapshot in row.text_snapshots %}{% if snapshot.scope_id and snapshot.scope_id != scope %}
{{ snapshot.scope_id }}
{% endif %}{{ candidate_text(snapshot) }}{% else %}{{ candidate_text(none) }}{% endfor %}{% endcall %}
{{ t.unknown_value }}

5{{ t.context_text_stage_final }}

{{ t.context_result }}
{{ t['context_' ~ prepared.status] }}{% if diagnostic.record.error_code and prepared.status in ['ready', 'empty'] %} · {{ t.context_degraded }}{% endif %}
{{ t.context_selected }}
{{ diagnostic.record.selected_count if diagnostic.record.selected_count is not none else receipt.selected|length if receipt else t.unknown_value }}
{{ t.context_budget }}
{{ prepared.content_bytes if prepared.content_bytes is not none else t.unknown_value }} / {{ diagnostic.record.requested_max_bytes }} B
{{ t.context_budget_bytes_hint }}
{{ t.context_fallbacks }}
{{ diagnostic.fallbacks if receipt else t.unknown_value }}
{{ t.context_reason }}
{% if diagnostic.record.diagnostics_payload.failed_stage %}{{ diagnostic.record.diagnostics_payload.failed_stage }} · {% endif %}{{ t.get('context_error_' ~ diagnostic.record.error_code, diagnostic.record.error_code) or t.context_fallback_none }}
{% if diagnostic.error %}
{{ t.context_partial }} · {{ t['context_' ~ diagnostic.error] }}
{% endif %}
{% if prepared.content %}
{{ prepared.content }}
{% else %}{{ t.context_empty if prepared.status == 'empty' else t.context_text_not_recorded }}{% endif %}
{% if receipt %}

{{ t.context_references }}

{% for item in diagnostic.selected %}{% if item.available %} {% else %}{% endif %} {% else %}{% endfor %}
{{ t.auto_family }}{{ t.context_revision }}{{ t.context_bytes }}{{ t.context_outcome }}{{ t.context_original_text }}
{{ artifact_type(item.family) }}{{ item.ref.artifact_id }} @{{ item.ref.revision }}{% if item.scope_id != scope %}
{{ item.scope_id }}
{% endif %}
{{ item.bytes }}{{ t.context_truncated if item.truncated else t.context_full }}{% call candidate_text_drawer('context-drawer-selected-' ~ loop.index) %}{% if item.text is not none %}
{{ item.text }}
{% else %}{{ t.context_text_not_recorded }}{% endif %}{% endcall %}
{{ t.context_reference_unavailable }}
{{ t.context_no_selected }}
{% endif %}
{{ t.context_evidence }}
{{ t.context_request_id }}
{{ diagnostic.record.request_id or t.unknown_value }}

{{ t.context_boundary }}