Evidence with supportive metadata

This commit is contained in:
2026-04-29 15:52:37 +02:00
parent 6c0a7db5e4
commit eb1513e463
10 changed files with 194 additions and 9 deletions

View File

@@ -592,8 +592,12 @@ def repository_detail(
<form class="stack" method="post" action="/ui/repos/{repository_id}/evidence">
<h3>Add Capability Support</h3>
<label>Supported capability ID <input name="capability_id" type="number" min="1" required></label>
<label>Supported characteristic kind <input name="target_kind" value="capability" required></label>
<label>Supported characteristic ID <input name="target_id" type="number" min="1" placeholder="Defaults to supported capability ID"></label>
<label>Support type <input name="type" placeholder="fact, documentation, test, example, feature" required></label>
<label>Reference <input name="reference" placeholder="Observed fact, file, or lower-level characteristic" required></label>
<label>Reference kind <input name="reference_kind" value="source" placeholder="source, fact, feature, capability"></label>
<label>Reference ID <input name="reference_id" type="number" min="1" placeholder="Optional fact or characteristic ID"></label>
<label>Strength <input name="strength" value="medium" required></label>
<button type="submit">Add Support</button>
</form>
@@ -724,6 +728,10 @@ def create_evidence_from_form(
type: str = Form(...),
reference: str = Form(...),
strength: str = Form("medium"),
target_kind: str = Form("capability"),
target_id: int | None = Form(default=None),
reference_kind: str = Form("source"),
reference_id: int | None = Form(default=None),
service: RegistryService = Depends(get_service),
) -> RedirectResponse:
service.add_evidence(
@@ -732,6 +740,10 @@ def create_evidence_from_form(
type=type,
reference=reference,
strength=strength,
target_kind=target_kind,
target_id=target_id,
reference_kind=reference_kind,
reference_id=reference_id,
)
return RedirectResponse(f"/ui/repos/{repository_id}", status_code=303)
@@ -836,6 +848,10 @@ def edit_evidence_from_form(
type: str = Form(...),
reference: str = Form(...),
strength: str = Form("medium"),
target_kind: str = Form("capability"),
target_id: int | None = Form(default=None),
reference_kind: str = Form("source"),
reference_id: int | None = Form(default=None),
service: RegistryService = Depends(get_service),
) -> RedirectResponse:
service.update_evidence(
@@ -844,6 +860,10 @@ def edit_evidence_from_form(
type=type,
reference=reference,
strength=strength,
target_kind=target_kind,
target_id=target_id,
reference_kind=reference_kind,
reference_id=reference_id,
)
return RedirectResponse(f"/ui/repos/{repository_id}", status_code=303)
@@ -2795,15 +2815,25 @@ def render_approved_feature(feature: dict, repository_id: int) -> str:
def render_approved_evidence(evidence: dict, repository_id: int) -> str:
target_kind = escape(str(evidence.get("target_kind") or "capability"))
target_id = evidence.get("target_id")
reference_kind = escape(str(evidence.get("reference_kind") or "source"))
reference_id = evidence.get("reference_id")
return f"""
<li>
<strong>{escape(evidence["type"])}</strong>
<span class="pill">{escape(evidence["strength"])}</span>
<span class="pill">supports {target_kind}{f' #{target_id}' if target_id else ''}</span>
<span class="pill">references {reference_kind}{f' #{reference_id}' if reference_id else ''}</span>
<span class="source">{escape(evidence["reference"])}</span>
{render_sources(evidence.get("source_refs", []))}
<form class="stack" method="post" action="/ui/repos/{repository_id}/evidence/{evidence['id']}/edit">
<label>Supported characteristic kind <input name="target_kind" value="{target_kind}" required></label>
<label>Supported characteristic ID <input name="target_id" type="number" min="1" value="{target_id or ''}"></label>
<label>Support type <input name="type" value="{escape(evidence['type'])}" required></label>
<label>Reference <input name="reference" value="{escape(evidence['reference'])}" required></label>
<label>Reference kind <input name="reference_kind" value="{reference_kind}" required></label>
<label>Reference ID <input name="reference_id" type="number" min="1" value="{reference_id or ''}"></label>
<label>Strength <input name="strength" value="{escape(evidence['strength'])}" required></label>
<button class="secondary" type="submit">Save Support</button>
</form>