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

@@ -1925,11 +1925,20 @@
"failed": "Archive action failed; refresh and verify the latest dedupe plan.",
"requiresOwner": "Owner review required; backend rechecks the latest plan.",
"result": "Archived {archived}; audit dispatch: {audit}",
"recheck": "Stale-ratio recheck: {status}; dispatch: {dispatch}",
"snapshot": "Current stale {stale} / total {total}; ratio {ratio}; threshold {threshold}",
"statuses": {
"dry_run": "Dry run complete",
"archived": "Archived",
"noop_already_archived": "Already archived",
"unknown": "Status pending"
},
"recheckStatuses": {
"dry_run": "Dry run only",
"completed": "Completed",
"already_active": "Already active",
"not_requested": "Not requested",
"unknown": "Status pending"
}
},
"statuses": {
@@ -1950,6 +1959,10 @@
"waiting_owner_review": "Waiting owner review",
"km_writeback_after_approval": "KM writeback after approval",
"stale_ratio_recheck": "Stale-ratio recheck",
"owner_approved_duplicate_archive": "Owner approved duplicate archive",
"km_duplicate_archive_after_owner_approval": "Duplicate archive after owner review",
"km_governance_rechecked": "KM governance rechecked",
"km_governance_close_or_continue": "Close or continue governance",
"needs_manual_km_triage": "Manual KM triage needed",
"cancelled": "Cancelled",
"queued_for_review": "Queued for governance review",

View File

@@ -1926,11 +1926,20 @@
"failed": "封存動作失敗;請重新整理後確認最新 dedupe plan。",
"requiresOwner": "需要 owner 審核;後端會重新比對最新 plan。",
"result": "已封存 {archived} 份;稽核 dispatch{audit}",
"recheck": "Stale ratio 回測:{status}dispatch{dispatch}",
"snapshot": "目前 stale {stale} / total {total}ratio {ratio};門檻 {threshold}",
"statuses": {
"dry_run": "乾跑完成",
"archived": "封存完成",
"noop_already_archived": "已封存,無需重複處理",
"unknown": "狀態待確認"
},
"recheckStatuses": {
"dry_run": "乾跑未排程",
"completed": "已完成回測",
"already_active": "已有活躍回測",
"not_requested": "尚未建立",
"unknown": "狀態待確認"
}
},
"statuses": {
@@ -1951,6 +1960,10 @@
"waiting_owner_review": "等待 owner 審核",
"km_writeback_after_approval": "審核後寫回 KM",
"stale_ratio_recheck": "回測 stale ratio",
"owner_approved_duplicate_archive": "Owner 已批准封存重複草稿",
"km_duplicate_archive_after_owner_approval": "Owner 審核後封存重複草稿",
"km_governance_rechecked": "KM 治理已回測",
"km_governance_close_or_continue": "關閉或繼續治理",
"needs_manual_km_triage": "需要人工整理 KM",
"cancelled": "已取消",
"queued_for_review": "等待治理審核",

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>