{# Shared solution presentation used by opportunity detail and admin solutions pages. Expects: sol (solution view model) create_pr_route_prefix (optional, defaults to /app) #} {% set create_pr_prefix = create_pr_route_prefix | default('/app') %}
{% with trust_tier=sol.trust_tier, template_name=sol.template_name, summary=None %} {% include "components/trust_badge.html" %} {% endwith %} {% if sol.local_build_execution_mode %} {{ sol.local_build_execution_mode.title }} {% endif %}
{% if sol.template_name in downstream_patch_guardrail_template_ids %} {# Spec 127: breaking-change guardrail. Always visible above the diff so the user cannot miss it. Final status line reflects the shadow-validation state for this solution (FR-006/FR-007). #}

⚠ Breaking change — partition filter will become mandatory

Applying this change tells BigQuery to reject any future query on this table that does not filter on the partition column. This is a guardrail, not a silent optimization.

{% if not sol.shadow_run %}

Downstream safety not yet verified. Run shadow validation below before applying.

{% elif sol.shadow_run.status in ['queued', 'running'] %}

Shadow validation is in progress — downstream safety will be verified once the run completes.

{% elif sol.shadow_run.status == 'succeeded' %}

✓ Shadow-verified: no downstream model in this project fails with the change applied.

{% elif sol.shadow_run.status == 'failed' %}

✗ Shadow validation failed. {% if sol.shadow_run.failure_reason %} Downstream impact: {{ sol.shadow_run.failure_reason }}. {% endif %} Review the dbt build logs below to identify affected models before applying.

{% elif sol.shadow_run.status == 'skipped' %}

Shadow validation was skipped — downstream safety is not verified.

{% else %}

Downstream safety not yet verified.

{% endif %}
{% endif %} {% if sol.resolution_category == 'dbt_project_change' and sol.diff_lines %} {% if sol.explanation %}

Solution: {{ sol.explanation }}

{% endif %} {% if sol.file_path %}

Target File

{{ sol.file_path }}

{% endif %} {% if sol.repository %}

{{ sol.repository }} {% if sol.commit_sha %} · {{ sol.commit_sha[:8] }}{% endif %}

{% endif %} {% with solution_id=sol.id, diff_lines=sol.diff_lines, compiled_original=sol.compiled_original, compiled_original_label=sol.compiled_original_label, compiled_modified=sol.compiled_modified, dry_run_original=sol.dry_run_original, dry_run_modified=sol.dry_run_modified, verification_sql=sol.verification_sql, verification_profile=sol.verification_profile, verification_output_mode=sol.verification_output_mode, verification_source_label=sol.verification_source_label, verification_warnings=sol.verification_warnings, verification_unavailable_reason=sol.verification_unavailable_reason, file_path=None %} {% include "components/code_viewer.html" %} {% endwith %} {% if sol.file_diffs and sol.file_diffs | length > 1 %} {# Additional files in this multi-file solution (primary already rendered above). #}

{% if sol.template_name in downstream_patch_guardrail_template_ids %} Downstream patches (spec 128) {% else %} Additional files in this fix {% endif %}

{% for fd in sol.file_diffs[1:] %} {% set pm = fd.proposal_meta or {} %} {% set patch_status = pm.get('status') if pm else None %} {% set is_spec128 = sol.template_name in downstream_patch_guardrail_template_ids and pm.get('change_type') == 'downstream_partition_filter_patch' %}

{{ fd.file_path }}

{% if is_spec128 %} {{ (patch_status or 'proposed') | replace('_', ' ') | title }} {% endif %}
{% if is_spec128 and patch_status == 'manual_required' %}

Unable to propose an automatic patch

{% if pm.get('abstain_reason') %}

{{ pm.get('abstain_reason') }}

{% endif %}

Hand-edit this file to add a partition filter, then re-run shadow validation on the bundle.

{% else %} {% with solution_id=sol.id ~ '-' ~ loop.index, diff_lines=fd.diff_lines, compiled_original=None, compiled_original_label=None, compiled_modified=None, dry_run_original=None, dry_run_modified=None, verification_sql=None, verification_profile=None, verification_output_mode=None, verification_source_label=None, verification_warnings=[], verification_unavailable_reason=None, file_path=None %} {% include "components/code_viewer.html" %} {% endwith %} {% endif %} {% if is_spec128 and patch_status in ('proposed', 'edited') %}
{% endif %}
{% endfor %} {% if sol.template_name in downstream_patch_guardrail_template_ids %}
{% endif %}
{% endif %} {% if sol.file_path and sol.config_id and sol.opp_id %} {% if sol.local_apply_enabled and sol.opp_status == 'active' %} {# --- Shadow comparison results block (shown once a shadow run exists) --- #} {% if sol.shadow_run %}

Empirical comparison (shadow validation)

{% if sol.shadow_run.triggered_by == 'auto' %} Auto {% endif %} {{ sol.shadow_run.status | replace('_', ' ') | title }}
{% if sol.shadow_run.status == 'succeeded' %}
Bytes Cost (USD)
Baseline (current) {{ "{:,}".format(sol.shadow_run.total_baseline_bytes or 0) }} ${{ "%.4f"|format(sol.shadow_run.total_baseline_cost_usd or 0) }}
Shadow (proposed) {{ "{:,}".format(sol.shadow_run.total_shadow_bytes or 0) }} ${{ "%.4f"|format(sol.shadow_run.total_shadow_cost_usd or 0) }}
Delta {% if sol.shadow_run.bytes_delta_pct is not none %}{{ "%+.1f"|format(sol.shadow_run.bytes_delta_pct) }}%{% else %}—{% endif %} {% if sol.shadow_run.cost_delta_usd is not none %}{{ "%+.4f"|format(sol.shadow_run.cost_delta_usd) }}{% else %}—{% endif %}

Cascade of {{ sol.shadow_run.cascade_size }} model(s). Empirical numbers from dbt run_results, not estimates.

{% elif sol.shadow_run.status == 'skipped' %}

Skipped: {{ sol.shadow_run.skipped_reason }}. Falling back to dry-run evidence above.

{% elif sol.shadow_run.status in ['queued', 'running'] %}

{% if sol.shadow_run.status == 'queued' %}Queued{% else %}Running{% endif %} — executing the dbt cascade twice against BigQuery.

{% if sol.shadow_run.cascade_size %}Cascade of {{ sol.shadow_run.cascade_size }} model(s). {% endif %} Terminal below updates every ~3 s while the cascade runs; the page will refresh itself only when it finishes. {% if sol.shadow_run.triggered_by == 'auto' %}Triggered automatically — "Auto-validate Safe solutions" is enabled.{% endif %}

{# Live terminal. The
 content is updated in place by a
           small JS polling loop hitting /app/shadow-runs//tail.
           We deliberately do NOT reload the whole page — that was the
           old behaviour and it was disruptive (lost scroll, reran
           template, flashed UI). Only when the run reaches a terminal
           status do we reload once to render the final comparison view. #}
        
Shadow validation — live output {{ (sol.shadow_run.build_logs | length) // 1024 + 1 if sol.shadow_run.build_logs else 0 }} KB
{{ sol.shadow_run.build_logs or '' }}
{% else %}

Failed: {{ sol.shadow_run.failure_reason or sol.shadow_run.status }}.

{% endif %} {% if sol.shadow_run.build_logs %}
Show dbt build logs ({{ (sol.shadow_run.build_logs | length) // 1024 + 1 }} KB)
{{ sol.shadow_run.build_logs }}
{% endif %}
{% endif %}
{# --- Run Comparison (primary) — streams dbt output live via SSE --- #} {% if not sol.shadow_run or sol.shadow_run.status not in ['succeeded', 'running'] %} {% endif %} {# --- Apply & Commit Locally — always available; after comparison it becomes the "accept" button --- #} {# Spec 128: disable Apply when any downstream patch is still manual_required. #} {% set has_manual_required = false %} {% if sol.file_diffs %} {% for fd in sol.file_diffs %} {% if (fd.proposal_meta or {}).get('status') == 'manual_required' %} {% set has_manual_required = true %} {% endif %} {% endfor %} {% endif %}
{# --- Live terminal pane, populated by the SSE stream --- #}

{% if not sol.shadow_run or sol.shadow_run.status not in ['succeeded', 'running'] %} Run Comparison executes the cascade twice (baseline + shadow) against your local BigQuery dataset and reports real bytes/cost deltas. Live dbt output streams below. Skip writes the change directly to {{ sol.file_path }} with no empirical check. {% else %} Writes the generated change to {{ sol.file_path }} inside {{ sol.local_project_path }}. {% endif %} {% if sol.local_build_execution_mode and sol.local_build_execution_mode.description %} {{ sol.local_build_execution_mode.description }} {% endif %}

{% elif sol.local_apply_enabled and sol.opp_status == 'pr_pending' %}
Applied to local project

Change written to {{ sol.file_path }}. Run dbt build then sync to verify.

{% elif sol.local_execution_mode %}

Local working tree not connected yet

Set the dbt project folder on this project configuration to enable Apply to Working Tree for {{ sol.file_path }}.

{% elif sol.repository %}
{% endif %} {% endif %} {% endif %} {% if sol.explanation and not (sol.resolution_category == 'dbt_project_change' and sol.diff_lines) %}

Notes

{{ sol.explanation }}

{% endif %} {% if sol.resolution_category == 'bigquery_infrastructure' %} {% if sol.current_setting and sol.recommended_setting %} {% with current_setting=sol.current_setting, recommended_setting=sol.recommended_setting, affected_resource=sol.affected_resource %} {% include "components/setting_comparison.html" %} {% endwith %} {% endif %} {% endif %} {% if sol.risk_justification or sol.validation_report %}
Risk & Validation Details
{% if sol.risk_justification %}

{{ sol.risk_justification }}

{% endif %} {% if sol.validation_report %} {% set report_tier = sol.validation_report.tier or sol.validation_report.overall_tier %} {% if report_tier %}

Tier: {{ report_tier | replace('_', ' ') | title }}

{% endif %} {% if sol.validation_report.error %}

{{ sol.validation_report.error }}

{% endif %} {% if sol.validation_report.steps %}
{% for step in sol.validation_report.steps %}
{% if step.result in ('pass', 'success', 'matched') or step.status == 'matched' %} {% elif step.result in ('fail', 'failure') %} {% else %} {% endif %} {{ step.name | default(step.type, true) | replace('_', ' ') | title }} {{ step.result | default(step.status, true) }}
{% if step.details and step.details is string %}

{{ step.details }}

{% endif %} {% if step.classification %}

Classification: {{ step.classification }}

{% endif %}
{% endfor %}
{% endif %} {% if sol.validation_report.dbt_compile %}

dbt Compile

{% if sol.validation_report.dbt_compile.success %}Success{% else %}Not successful{% endif %} {% if sol.validation_report.dbt_compile.reason %} · {{ sol.validation_report.dbt_compile.reason | replace('_', ' ') }}{% endif %} {% if sol.validation_report.dbt_compile.exit_code is not none %} · Exit {{ sol.validation_report.dbt_compile.exit_code }}{% endif %} {% if sol.validation_report.dbt_compile.duration_ms is not none %} · {{ sol.validation_report.dbt_compile.duration_ms }}ms{% endif %}

{% if sol.validation_report.dbt_compile.stderr %}
{{ sol.validation_report.dbt_compile.stderr }}
{% endif %}
{% endif %} {% if sol.validation_report.dbt_parse %}

dbt Parse

{% if sol.validation_report.dbt_parse.success %}Success{% else %}Not successful{% endif %} {% if sol.validation_report.dbt_parse.exit_code is not none %} · Exit {{ sol.validation_report.dbt_parse.exit_code }}{% endif %} {% if sol.validation_report.dbt_parse.duration_ms is not none %} · {{ sol.validation_report.dbt_parse.duration_ms }}ms{% endif %} {% if sol.validation_report.dbt_parse.manifest_available %} · Manifest available{% endif %} {% if sol.validation_report.dbt_parse.optimized_sql_source == 'manifest_diff' %} · Optimized SQL via synced manifest diff{% endif %}

{% if sol.validation_report.dbt_parse.stderr %}
{{ sol.validation_report.dbt_parse.stderr }}
{% endif %}
{% endif %} {% if sol.validation_report.warnings %}
{% for warning in sol.validation_report.warnings %}

⚠ {{ warning }}

{% endfor %}
{% endif %} {% if sol.validation_report.timestamp %}

Validated: {{ sol.validation_report.timestamp }}

{% endif %} {% endif %}
{% endif %}