Platform upgrade: semantic search, citations, readiness, tests, Docker

Major features added by 5 parallel agent teams:
- Semantic "Ask" (NL queries via FTS5 + embeddings + Claude synthesis)
- Global search across drafts, ideas, authors, gaps
- REST API expansion (14 endpoints, up from 3) with CSV/JSON export
- Citation graph visualization (D3.js, 440 nodes, 2422 edges)
- Standards readiness scoring (0-100 composite from 6 factors)
- Side-by-side draft comparison view with shared/unique analysis
- Annotation system (notes + tags per draft, DB-persisted)
- Docker deployment (Dockerfile + docker-compose with Ollama)
- Scheduled updates (cron script with log rotation)
- Pipeline health dashboard (stage progress bars, cost tracking)
- Test suite foundation (54 pytest tests covering DB, models, web data)

Fixes: compare_drafts() stubbed→working, get_authors_for_draft() bug,
source-aware analysis prompts, config env var overrides + validation,
resilient batch error handling with --retry-failed, observatory --dry-run

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 20:52:56 +01:00
parent da2a989744
commit 757b781c67
33 changed files with 4253 additions and 170 deletions

View File

@@ -156,6 +156,14 @@
{{ idea.type }}
</span>
{% endif %}
{% if idea.novelty_score is not none and idea.novelty_score %}
<span class="flex-shrink-0 px-1.5 py-0.5 rounded text-[10px] font-mono
{% if idea.novelty_score >= 4 %}bg-green-500/20 text-green-400
{% elif idea.novelty_score >= 3 %}bg-amber-500/20 text-amber-400
{% elif idea.novelty_score >= 2 %}bg-orange-500/20 text-orange-400
{% else %}bg-red-500/20 text-red-400{% endif %}"
title="Novelty score">N:{{ idea.novelty_score }}</span>
{% endif %}
</div>
{% if idea.description %}
<p class="text-xs text-slate-500 leading-relaxed mt-1">{{ idea.description }}</p>
@@ -165,6 +173,40 @@
</div>
</div>
{% endif %}
<!-- Annotation (notes & tags) -->
<div class="detail-card rounded-xl border border-slate-800 p-6" id="annotationSection">
<h2 class="text-sm font-semibold text-slate-300 mb-3 flex items-center gap-2">
<svg class="w-4 h-4 text-slate-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
Notes & Tags
</h2>
<div class="mb-3">
<textarea id="annotNote" rows="3" placeholder="Add a private note about this draft..."
class="w-full bg-slate-800/60 border border-slate-700 rounded-lg px-3 py-2 text-sm text-slate-200 placeholder-slate-500 focus:outline-none focus:border-blue-500 resize-y">{{ draft.annotation.note if draft.annotation else '' }}</textarea>
</div>
<div class="mb-3">
<div class="flex flex-wrap gap-1.5 mb-2" id="tagContainer">
{% if draft.annotation and draft.annotation.tags %}
{% for tag in draft.annotation.tags %}
<span class="tag-chip inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-blue-500/20 text-blue-400 border border-blue-500/30">
{{ tag }}
<button onclick="removeTag('{{ tag }}')" class="hover:text-red-400 transition ml-0.5">&times;</button>
</span>
{% endfor %}
{% endif %}
</div>
<div class="flex gap-2">
<input type="text" id="newTag" placeholder="Add tag..." maxlength="30"
class="flex-1 bg-slate-800/60 border border-slate-700 rounded-lg px-3 py-1.5 text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-blue-500"
onkeydown="if(event.key==='Enter'){event.preventDefault();addTag();}">
<button onclick="addTag()" class="px-3 py-1.5 bg-blue-600 text-white rounded-lg text-xs font-medium hover:bg-blue-500 transition">Add</button>
</div>
</div>
<button onclick="saveAnnotation()" class="w-full px-3 py-2 bg-slate-800 border border-slate-700 text-slate-300 rounded-lg text-xs font-medium hover:border-blue-500 hover:text-blue-400 transition" id="saveBtn">
Save Note
</button>
<div id="saveStatus" class="text-xs text-center mt-2 text-slate-600"></div>
</div>
</div>
<!-- Right column: Sidebar -->
@@ -193,6 +235,42 @@
</div>
{% endif %}
<!-- Readiness Score -->
{% if draft.readiness and draft.readiness.score > 0 %}
<div class="detail-card rounded-xl border border-slate-800 p-5">
<h2 class="text-sm font-semibold text-slate-300 mb-3 flex items-center gap-2">
<svg class="w-4 h-4 text-slate-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/></svg>
Standards Readiness
</h2>
<!-- Gauge -->
<div class="relative w-full h-6 bg-slate-800 rounded-full overflow-hidden mb-2">
<div class="h-full rounded-full transition-all duration-700
{% if draft.readiness.score >= 60 %}bg-gradient-to-r from-green-600 to-green-400
{% elif draft.readiness.score >= 35 %}bg-gradient-to-r from-amber-600 to-amber-400
{% else %}bg-gradient-to-r from-red-600 to-red-400{% endif %}"
style="width: {{ draft.readiness.score }}%"></div>
<div class="absolute inset-0 flex items-center justify-center text-xs font-bold text-white">
{{ draft.readiness.score }}/100
</div>
</div>
<!-- Factor breakdown -->
<div class="space-y-1.5 mt-3">
{% for key, f in draft.readiness.factors.items() %}
<div class="flex items-center justify-between text-xs">
<span class="text-slate-500">{{ f.label }}</span>
<div class="flex items-center gap-2">
<span class="text-slate-600 font-mono text-[10px]">{{ f.detail }}</span>
<span class="font-mono font-medium
{% if f.value >= 0.7 %}text-green-400
{% elif f.value >= 0.4 %}text-amber-400
{% else %}text-red-400{% endif %}">+{{ f.contribution }}</span>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<!-- Metadata -->
<div class="detail-card rounded-xl border border-slate-800 p-5">
<h2 class="text-sm font-semibold text-slate-300 mb-3 flex items-center gap-2">
@@ -308,3 +386,76 @@
</div>
</div>
{% endblock %}
{% block extra_scripts %}
<script>
const draftName = {{ draft.name | tojson }};
function addTag() {
const input = document.getElementById('newTag');
const tag = input.value.trim();
if (!tag) return;
input.value = '';
fetch(`/api/drafts/${encodeURIComponent(draftName)}/annotate`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({add_tag: tag}),
})
.then(r => r.json())
.then(data => {
if (data.success) renderTags(data.annotation.tags);
});
}
function removeTag(tag) {
fetch(`/api/drafts/${encodeURIComponent(draftName)}/annotate`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({remove_tag: tag}),
})
.then(r => r.json())
.then(data => {
if (data.success) renderTags(data.annotation.tags);
});
}
function renderTags(tags) {
const container = document.getElementById('tagContainer');
container.innerHTML = tags.map(t =>
`<span class="tag-chip inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-blue-500/20 text-blue-400 border border-blue-500/30">
${t}
<button onclick="removeTag('${t}')" class="hover:text-red-400 transition ml-0.5">&times;</button>
</span>`
).join('');
}
function saveAnnotation() {
const note = document.getElementById('annotNote').value;
const btn = document.getElementById('saveBtn');
const status = document.getElementById('saveStatus');
btn.disabled = true;
btn.textContent = 'Saving...';
fetch(`/api/drafts/${encodeURIComponent(draftName)}/annotate`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({note: note}),
})
.then(r => r.json())
.then(data => {
btn.disabled = false;
btn.textContent = 'Save Note';
if (data.success) {
status.textContent = 'Saved';
status.className = 'text-xs text-center mt-2 text-green-400';
setTimeout(() => { status.textContent = ''; status.className = 'text-xs text-center mt-2 text-slate-600'; }, 2000);
}
})
.catch(() => {
btn.disabled = false;
btn.textContent = 'Save Note';
status.textContent = 'Error saving';
status.className = 'text-xs text-center mt-2 text-red-400';
});
}
</script>
{% endblock %}