Add async pipeline with progress monitoring, resumability, and result transparency

Pipeline engine rewritten with combo-first loop: each combination is processed
through all requested passes before moving to the next, with incremental DB
saves after every step (crash-safe). Blocked combos now get result rows so they
appear in the results page with constraint violation reasons.

New pipeline_runs table tracks run lifecycle (pending/running/completed/failed/
cancelled). Web route launches pipeline in a background thread with its own DB
connection. HTMX polling partial shows live progress with per-pass breakdown.

Also: status guard prevents reviewed->scored downgrade, save_combination loads
existing status on dedup for correct resume, per-metric scores show domain
bounds + units + position bars, ensure_metric backfills units on existing rows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Simonson, Andrew
2026-02-18 15:30:52 -06:00
parent 8118a62242
commit d2028a642b
17 changed files with 1263 additions and 217 deletions

View File

@@ -8,6 +8,7 @@
<form method="post" action="{{ url_for('pipeline.pipeline_run') }}">
<div class="form-group">
<label for="domain">Domain</label>
<p class="form-hint">The evaluation context that defines which metrics matter and how they're weighted.</p>
<select name="domain" id="domain" required>
<option value="">— select —</option>
{% for d in domains %}
@@ -18,30 +19,45 @@
<fieldset>
<legend>Passes</legend>
<div class="checkbox-row">
{% for p in [1, 2, 3, 4, 5] %}
<p class="form-hint">Each pass progressively filters and enriches combinations. Later passes depend on earlier ones.</p>
<div class="checkbox-col">
<label>
<input type="checkbox" name="passes" value="{{ p }}"
{{ 'checked' if p <= 3 }}>
Pass {{ p }}
{% if p == 1 %}(Constraints)
{% elif p == 2 %}(Estimation)
{% elif p == 3 %}(Scoring)
{% elif p == 4 %}(LLM Review)
{% elif p == 5 %}(Human Review)
{% endif %}
<input type="checkbox" name="passes" value="1" checked>
<strong>Pass 1 — Constraint Resolution</strong>
<span class="form-hint">Checks requires/provides/excludes compatibility between entities. Blocks impossible combinations.</span>
</label>
<label>
<input type="checkbox" name="passes" value="2" checked>
<strong>Pass 2 — Physics Estimation</strong>
<span class="form-hint">Estimates raw metric values (speed, cost, etc.) using heuristics or an LLM. Without an LLM provider, uses a force/mass stub.</span>
</label>
<label>
<input type="checkbox" name="passes" value="3" checked>
<strong>Pass 3 — Scoring &amp; Ranking</strong>
<span class="form-hint">Normalizes estimates against domain bounds and computes a weighted geometric mean composite score.</span>
</label>
<label>
<input type="checkbox" name="passes" value="4">
<strong>Pass 4 — LLM Review</strong>
<span class="form-hint">Sends top combinations to an LLM for a plausibility and novelty assessment. Requires an LLM provider to be configured.</span>
</label>
<label>
<input type="checkbox" name="passes" value="5">
<strong>Pass 5 — Human Review</strong>
<span class="form-hint">Marks results as ready for human review on the Results page.</span>
</label>
{% endfor %}
</div>
</fieldset>
<div class="form-group">
<label for="threshold">Score Threshold</label>
<p class="form-hint">Minimum composite score (01) for a combination to pass scoring. Lower values keep more results; higher values are more selective.</p>
<input type="number" name="threshold" id="threshold" value="0.1" step="0.01" min="0" max="1">
</div>
<fieldset>
<legend>Dimensions</legend>
<p class="form-hint">Which entity dimensions to combine. The pipeline generates the Cartesian product of all entities in the selected dimensions.</p>
<div class="checkbox-row">
{% for d in dimensions %}
<label>
@@ -57,4 +73,76 @@
</div>
</form>
</div>
{% set active_runs = runs | selectattr('status', 'in', ['pending', 'running']) | list %}
{% if active_runs %}
<h2>Active Runs</h2>
{% for run in active_runs %}
<div class="card"
hx-get="{{ url_for('pipeline.run_status', run_id=run.id) }}"
hx-trigger="every 2s"
hx-swap="innerHTML">
{% include "pipeline/_run_status.html" %}
</div>
{% endfor %}
{% endif %}
{% if runs %}
<h2>Run History</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Domain</th>
<th>Status</th>
<th>Total</th>
<th>P1 Checked</th>
<th>P1 Blocked</th>
<th>P2 Estimated</th>
<th>P3 Scored</th>
<th>P4 Reviewed</th>
<th>Started</th>
</tr>
</thead>
<tbody>
{% for run in runs %}
{% set blocked = (run.combos_pass1 or 0) - (run.combos_pass2 or 0) if (run.combos_pass2 or 0) > 0 and (run.combos_pass1 or 0) > (run.combos_pass2 or 0) else 0 %}
<tr>
<td>{{ run.id }}</td>
<td>{{ run.domain_name }}</td>
<td><span class="badge badge-{{ run.status }}">{{ run.status }}</span></td>
<td>{{ run.total_combos or '—' }}</td>
<td>{{ run.combos_pass1 or '—' }}</td>
<td>{% if blocked %}<span class="badge badge-blocked">{{ blocked }}</span>{% else %}—{% endif %}</td>
<td>{{ run.combos_pass2 or '—' }}</td>
<td>{{ run.combos_pass3 or '—' }}</td>
<td>{{ run.combos_pass4 or '—' }}</td>
<td>{{ run.started_at or run.created_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if summaries.values()|select|list %}
<h2>Domain Summaries</h2>
{% for d in domains %}
{% set s = summaries[d.name] %}
{% if s %}
<div class="card">
<h3>{{ d.name }} <span class="subtitle">{{ d.description }}</span></h3>
<dl class="summary-dl">
<dt>Results</dt><dd>{{ s.total_results }} scored combinations</dd>
<dt>Blocked</dt><dd>{{ s.blocked }} combinations</dd>
<dt>Score range</dt><dd class="score-cell">{{ "%.4f"|format(s.min_score) }} — {{ "%.4f"|format(s.max_score) }}</dd>
<dt>Avg score</dt><dd class="score-cell">{{ "%.4f"|format(s.avg_score) }}</dd>
<dt>Last pass</dt><dd>{{ s.last_pass }}</dd>
</dl>
<div style="margin-top:0.5rem">
<a href="{{ url_for('results.results_domain', domain_name=d.name) }}" class="btn btn-sm">View results</a>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}