caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
Builds PaperTrail from the base skeleton into a full evidence-verification platform
for the "Built with Claude: Life Sciences" hackathon (Builder Track).

New named-user features (Build Beyond the Bench):
- Lab Notebook Companion — rough bench notes -> structured, searchable, grounded
  experiment records (lib/labNotebook, /console/lab-notebook, migration 0059)
- Clinical Trial Matcher — de-identified patient notes -> ranked eligible
  ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning
  (lib/trialMatcher, /console/trial-matcher, migrations 0060)

Platform:
- Deterministic verification moat (biostats recompute, exact-span grounding)
- 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar,
  PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier)
- Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise
  governance (RBAC, /api/v1 gateway, metering, audit chain, retention)
- 17 OSS projects assimilated into native TypeScript on our stack (backend/engines
  retained + credited in NOTICE)
- Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site
- Next.js 16 upgrade, benchmark harness (honest smoke-test caveat)

Licensing: Apache-2.0 (LICENSE + NOTICE).
2026-07-10 16:23:13 +03:00

298 lines
13 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block content %}
<section class="panel">
<div class="panel-header">
<div>
<h2 class="panel-title">Reference IDs</h2>
<p class="panel-subtitle">Use these IDs when looking up files, traces, or batch exports.</p>
</div>
<a href="{{ url_for('api.guidebook_page') }}#progress" class="help-link" title="Guidebook: Progress">?</a>
</div>
<div class="summary-strip" id="referenceList"></div>
</section>
<section class="panel">
<div class="panel-header">
<div>
<h2 class="panel-title"><span id="liveDot" class="pulse-dot"></span> Progress</h2>
<p class="panel-subtitle">Live view of this batch as the processor works through it.</p>
</div>
<div class="refresh-meta">
<span id="refreshLabel">Refreshing…</span>
<span class="countdown-track"><span id="refreshCountdown" class="countdown-fill"></span></span>
</div>
</div>
<div id="processorAlert" class="status-card error-card hidden"></div>
<div id="progressStatus" class="status-card info-card hidden"></div>
<div class="stack">
<div class="summary-strip">
<div class="summary-cell">
<span class="label">Completed</span>
<span class="value" id="completedValue">–</span>
</div>
<div class="summary-cell">
<span class="label">Progress</span>
<span class="value" id="percentValue">–</span>
</div>
<div class="summary-cell">
<span class="label">Status</span>
<span class="value" id="statusValue">connecting…</span>
</div>
<div class="summary-cell">
<span class="label">Elapsed</span>
<span class="value" id="elapsedValue">0:00</span>
</div>
</div>
<div class="live-progress-track" id="progressTrack" role="progressbar" aria-label="Batch progress" aria-valuemin="0" aria-valuemax="100">
<div class="live-progress-fill" id="progressFill"></div>
</div>
<div class="stage-flow" id="stageFlow"></div>
<div id="currentClaim"></div>
</div>
</section>
<script>
window.progressPageConfig = {
batchId: {{ batch_id|tojson }},
claimId: {{ claim_id|tojson }},
};
</script>
{% endblock %}
{% block scripts %}
<script>
const { escapeHtml, fetchJson, setStatus, hideStatus } = window.ValsciUI;
const config = window.progressPageConfig || {};
const batchId = config.batchId;
const claimId = config.claimId;
const POLL_MS = 5000;
const byId = (id) => document.getElementById(id);
const pageOpenedAt = Date.now();
let nextRefreshAt = null;
let refreshing = false;
let redirecting = false;
const STAGES = [
{ key: "queued", label: "Queued" },
{ key: "ready_for_search", label: "Searching literature" },
{ key: "ready_for_analysis", label: "Analyzing evidence" },
{ key: "processed", label: "Done" },
];
const STAGE_KEYS = new Set([...STAGES.map(s => s.key), "error", "unknown"]);
let currentModelsText = '';
function modelsToText(models) {
if (!Array.isArray(models) || !models.length) return '';
// One entry per distinct provider/model combination; usually just one.
return models.map(entry => entry.display || (entry.models || []).join(', ')).filter(Boolean).join(' · ');
}
function renderReferences() {
const references = [];
if (batchId) references.push({ label: 'Batch ID', value: batchId });
if (claimId) references.push({ label: 'Claim ID', value: claimId });
references.push({ label: 'Model', value: currentModelsText || '…', id: 'modelValue' });
byId('referenceList').innerHTML = references.length
? references.map(item => `
<div class="summary-cell">
<span class="label">${escapeHtml(item.label)}</span>
<span class="value"${item.id ? ` id="${item.id}"` : ''}>${escapeHtml(item.value)}</span>
</div>
`).join('')
: `<div class="empty-state"><strong>No reference IDs were provided.</strong><span>Open this page from a batch or claim run.</span></div>`;
}
function renderModels(models) {
const text = modelsToText(models);
if (text === currentModelsText) return;
currentModelsText = text;
const cell = byId('modelValue');
if (cell) cell.textContent = text || '…';
}
function formatElapsed(ms) {
const totalSeconds = Math.floor(ms / 1000);
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return `${minutes}:${String(seconds).padStart(2, "0")}`;
}
let processorDownShown = false;
function renderProcessorAlert(processor) {
const alert = byId('processorAlert');
if (!processor || processor.alive) {
processorDownShown = false;
alert.classList.add('hidden');
return;
}
const lastSeen = processor.age_seconds != null
? `It was last seen ${Math.round(processor.age_seconds)}s ago.`
: 'It has not reported in since this server started.';
const message = `${lastSeen} Claims will stay queued until it starts — run "python processor.py", or check "docker compose logs processor" if you deployed with Docker.`;
if (processorDownShown) {
// Refresh the "last seen" text without restarting the pulse animation.
const span = alert.querySelector('span');
if (span) span.textContent = message;
return;
}
processorDownShown = true;
setStatus(alert, {
title: 'The claim processor is not running',
message,
tone: 'error',
});
}
function renderStages(counts, total) {
const known = STAGES.map((stage, index) => {
const count = Number(counts[stage.key] || 0);
let cls = '';
if (stage.key === 'processed' && count > 0) cls = 'done';
else if (stage.key !== 'processed' && count > 0) cls = 'active';
return `
<span class="stage-chip ${cls}">
${stage.key !== 'processed' && count > 0 ? '<span class="pulse-dot"></span>' : ''}
${escapeHtml(stage.label)} <span class="stage-count">${count}</span>
</span>
${index < STAGES.length - 1 ? '<span class="stage-arrow">→</span>' : ''}
`;
}).join('');
const errorCount = Number(counts.error || 0) + Number(counts.unknown || 0);
const errors = errorCount > 0
? `<span class="stage-chip error">✕ Errors <span class="stage-count">${errorCount}</span></span>`
: '';
const extras = Object.entries(counts)
.filter(([key, count]) => !STAGE_KEYS.has(key) && Number(count) > 0)
.map(([key, count]) => `
<span class="stage-chip active">
<span class="pulse-dot"></span>
${escapeHtml(key.replace(/_/g, ' '))} <span class="stage-count">${Number(count)}</span>
</span>
`).join('');
byId('stageFlow').innerHTML = known + extras + errors;
}
function renderProgress(data) {
const total = Number(data.total_claims || 0);
const processed = Number(data.processed_claims || 0);
const counts = data.detailed_counts || {};
const errorCount = Number(counts.error || 0);
const settled = total > 0 && processed + errorCount >= total;
const percent = total > 0 ? (processed / total) * 100 : 0;
const working = total > 0 && !settled;
byId('completedValue').textContent = total > 0 ? `${processed} / ${total}` : '–';
byId('percentValue').textContent = total > 0 ? `${percent.toFixed(0)}%` : '–';
byId('statusValue').textContent = (data.status || 'initializing').replace(/_/g, ' ');
byId('liveDot').classList.toggle('idle', !working);
const track = byId('progressTrack');
const fill = byId('progressFill');
track.classList.toggle('indeterminate', total === 0);
track.setAttribute('aria-valuenow', String(Math.round(percent)));
fill.style.width = `${total > 0 ? Math.max(percent, 2) : 0}%`;
fill.classList.toggle('working', working);
renderStages(counts, total);
renderProcessorAlert(data.processor);
renderModels(data.models);
byId('currentClaim').innerHTML = data.current_claim_id ? `
<div class="status-card info-card">
<strong>Currently processing</strong>
<span>Claim ID ${escapeHtml(data.current_claim_id)}</span>
</div>
` : '';
if (settled && errorCount > 0 && data.status !== 'completed') {
setStatusOnce(`settled-${errorCount}`, {
title: `Batch finished with ${errorCount} failed claim${errorCount === 1 ? '' : 's'}`,
message: 'Open the batch results to inspect the failures or retry them from the claim pages.',
tone: 'warning',
});
} else if (data.status === 'error') {
setStatusOnce('batch-error', {
title: 'Batch error',
message: 'The batch reported an error. Open the batch results or trace details for diagnostics.',
tone: 'error',
});
} else {
statusCardKey = '';
hideStatus(byId('progressStatus'));
}
}
let statusCardKey = '';
function setStatusOnce(key, payload) {
if (statusCardKey === key) return;
statusCardKey = key;
setStatus(byId('progressStatus'), payload);
}
function completedDestination() {
if (claimId) {
return `/progress?batch_id=${encodeURIComponent(batchId)}&claim_id=${encodeURIComponent(claimId)}`;
}
return `/batch_results?batch_id=${encodeURIComponent(batchId)}`;
}
async function refresh() {
if (redirecting) return;
refreshing = true;
try {
const data = await fetchJson(`/api/v1/batch/${encodeURIComponent(batchId)}/progress`);
renderProgress(data);
if (data.status === 'completed') {
redirecting = true;
byId('refreshLabel').textContent = 'Done — opening results…';
byId('progressFill').style.width = '100%';
window.setTimeout(() => { window.location.href = completedDestination(); }, 700);
return;
}
} catch (error) {
setStatusOnce('fetch-error', {
title: 'Progress refresh failed',
message: error.message || 'Unable to refresh progress.',
tone: 'warning',
});
} finally {
refreshing = false;
}
nextRefreshAt = Date.now() + POLL_MS;
window.setTimeout(refresh, POLL_MS);
}
function tick() {
byId('elapsedValue').textContent = formatElapsed(Date.now() - pageOpenedAt);
if (redirecting) return;
const label = byId('refreshLabel');
const countdown = byId('refreshCountdown');
if (refreshing || nextRefreshAt === null) {
label.textContent = 'Refreshing…';
countdown.style.width = '100%';
return;
}
const remaining = Math.max(0, nextRefreshAt - Date.now());
label.textContent = `Next refresh in ${Math.ceil(remaining / 1000)}s`;
countdown.style.width = `${(remaining / POLL_MS) * 100}%`;
}
renderReferences();
if (!batchId) {
setStatus(byId('progressStatus'), {
title: 'Missing batch ID',
message: 'Open progress from a batch or claim run so this page can poll the right status.',
tone: 'warning',
});
byId('refreshLabel').textContent = 'Not polling';
byId('liveDot').classList.add('idle');
} else {
refresh();
window.setInterval(tick, 200);
}
</script>
{% endblock %}