feat(governance): attach km archive history to dedupe groups
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 6m56s
Type Sync Check / check-type-sync (push) Successful in 6m51s
CD Pipeline / build-and-deploy (push) Successful in 4m43s
CD Pipeline / post-deploy-checks (push) Successful in 1m47s
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 6m56s
Type Sync Check / check-type-sync (push) Successful in 6m51s
CD Pipeline / build-and-deploy (push) Successful in 4m43s
CD Pipeline / post-deploy-checks (push) Successful in 1m47s
This commit is contained in:
@@ -471,6 +471,20 @@ class TestKmReviewDraftDedupe:
|
||||
owner_action="review_canonical_and_archive_duplicate_drafts",
|
||||
writes_on_read=False,
|
||||
can_archive_without_owner_approval=False,
|
||||
archive_history=[
|
||||
DispatchItem(
|
||||
id="dispatch-archive-001",
|
||||
governance_event_id="event-001",
|
||||
event_type="knowledge_degradation",
|
||||
dispatch_status="succeeded",
|
||||
executor_type="hermes_km_review_dedupe_owner_archive",
|
||||
proposed_action="Owner archived duplicate KM drafts",
|
||||
created_at=NOW,
|
||||
workflow_stage="km_duplicate_archive_after_owner_approval",
|
||||
dry_run_plan_fingerprint="sha256:" + "a" * 64,
|
||||
archived_count=2,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
@@ -490,6 +504,10 @@ class TestKmReviewDraftDedupe:
|
||||
assert data["groups"][0]["canonical_entry_id"] == "km-canonical"
|
||||
assert data["groups"][0]["writes_on_read"] is False
|
||||
assert data["groups"][0]["can_archive_without_owner_approval"] is False
|
||||
assert data["groups"][0]["archive_history"][0]["executor_type"] == (
|
||||
"hermes_km_review_dedupe_owner_archive"
|
||||
)
|
||||
assert data["groups"][0]["archive_history"][0]["archived_count"] == 2
|
||||
|
||||
def test_governance_event_tag_extraction(self):
|
||||
assert _extract_governance_event_id_from_tags([
|
||||
@@ -524,6 +542,27 @@ class TestKmReviewDraftDedupe:
|
||||
groups = _build_km_review_draft_dedupe_groups(
|
||||
rows,
|
||||
{"event-001": "km-canonical"},
|
||||
{
|
||||
"event-001": [
|
||||
DispatchItem(
|
||||
id="dispatch-recheck-001",
|
||||
governance_event_id="event-001",
|
||||
event_type="knowledge_degradation",
|
||||
dispatch_status="succeeded",
|
||||
executor_type="hermes_km_stale_ratio_recheck",
|
||||
proposed_action="Rechecked stale ratio",
|
||||
created_at=NOW,
|
||||
workflow_stage="stale_ratio_recheck",
|
||||
stale_ratio_snapshot={
|
||||
"stale_count": 10,
|
||||
"total_count": 100,
|
||||
"stale_ratio": 0.1,
|
||||
"threshold": 0.2,
|
||||
"stale_days": 7,
|
||||
},
|
||||
)
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
first = groups[0]
|
||||
@@ -532,6 +571,8 @@ class TestKmReviewDraftDedupe:
|
||||
assert first.preferred_source == "dispatch_context"
|
||||
assert first.duplicate_entry_ids == ["km-latest"]
|
||||
assert first.writes_on_read is False
|
||||
assert first.archive_history[0].executor_type == "hermes_km_stale_ratio_recheck"
|
||||
assert first.archive_history[0].stale_ratio_snapshot["stale_ratio"] == pytest.approx(0.1)
|
||||
|
||||
def test_archive_endpoint_requires_owner_shape_and_returns_audit_result(self, client):
|
||||
"""Owner 批准後的 archive endpoint 應回傳 KM write 與 audit write 結果。"""
|
||||
|
||||
Reference in New Issue
Block a user