feat(governance): trace km stale ratio rechecks
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
Type Sync Check / check-type-sync (push) Successful in 26s
CD Pipeline / tests (push) Successful in 3m34s
CD Pipeline / build-and-deploy (push) Successful in 4m2s
CD Pipeline / post-deploy-checks (push) Successful in 1m48s

This commit is contained in:
Your Name
2026-05-20 00:52:14 +08:00
parent 5ac315c119
commit d283e65340
8 changed files with 416 additions and 7 deletions

View File

@@ -290,6 +290,19 @@ type KnowledgeReviewDraftArchiveResponse = {
writes_km: boolean;
writes_governance_audit: boolean;
audit_dispatch_id?: string | null;
stale_ratio_snapshot?: {
stale_count: number;
total_count: number;
stale_ratio: number;
threshold: number;
stale_days: number;
} | null;
stale_ratio_recheck_status:
| "dry_run"
| "completed"
| "already_active"
| "not_requested";
stale_ratio_recheck_dispatch_id?: string | null;
next_action: string;
generated_at?: string | null;
};
@@ -666,6 +679,10 @@ function governanceKmStageKey(stage?: string | null) {
stage === "waiting_owner_review" ||
stage === "km_writeback_after_approval" ||
stage === "stale_ratio_recheck" ||
stage === "owner_approved_duplicate_archive" ||
stage === "km_duplicate_archive_after_owner_approval" ||
stage === "km_governance_rechecked" ||
stage === "km_governance_close_or_continue" ||
stage === "needs_manual_km_triage" ||
stage === "cancelled" ||
stage === "queued_for_review" ||
@@ -771,6 +788,18 @@ function groupArchiveStatusKey(status?: string | null) {
return "unknown";
}
function staleRatioRecheckStatusKey(status?: string | null) {
if (
status === "dry_run" ||
status === "completed" ||
status === "already_active" ||
status === "not_requested"
) {
return status;
}
return "unknown";
}
function buildWorkItems(
telemetry: Telemetry,
t: ReturnType<typeof useTranslations>
@@ -1717,6 +1746,26 @@ function KnowledgeGovernancePanel({
audit: archiveAction.result.audit_dispatch_id ?? "--",
})}
</p>
<p className="mt-1 text-[#5f5b52]">
{t("archiveActions.recheck", {
status: t(
`archiveActions.recheckStatuses.${staleRatioRecheckStatusKey(
archiveAction.result.stale_ratio_recheck_status
)}` as never
),
dispatch: archiveAction.result.stale_ratio_recheck_dispatch_id ?? "--",
})}
</p>
{archiveAction.result.stale_ratio_snapshot ? (
<p className="mt-1 text-[#5f5b52]">
{t("archiveActions.snapshot", {
stale: archiveAction.result.stale_ratio_snapshot.stale_count,
total: archiveAction.result.stale_ratio_snapshot.total_count,
ratio: archiveAction.result.stale_ratio_snapshot.stale_ratio,
threshold: archiveAction.result.stale_ratio_snapshot.threshold,
})}
</p>
) : null}
</div>
) : null}
</div>