Add curated daily triage digest

This commit is contained in:
2026-05-19 19:09:21 +02:00
parent 3110399b11
commit 6cb0718e90
2 changed files with 294 additions and 0 deletions

View File

@@ -115,3 +115,118 @@ def test_resolver_failure_returns_empty(monkeypatch) -> None:
def test_unknown_query_returns_empty() -> None:
assert StateHubContextResolver().resolve("unknown", None, {}) == {}
def test_daily_triage_digest_is_curated_scalar_json(monkeypatch) -> None:
payloads = {
"/state/summary": {
"generated_at": "2026-05-19T05:20:00Z",
"totals": {"tasks": {"todo": 4, "blocked": 1}},
"topics": [
{
"slug": "custodian",
"domain_slug": "custodian",
"workstreams": [
{
"id": "ws-1",
"slug": "cust-wp-0045",
"title": "Activity-Core Daily Triage Runner Cutover",
"status": "ready",
"owner": "custodian",
},
{
"id": "ws-closed",
"slug": "closed",
"title": "Closed",
"status": "finished",
"owner": "custodian",
},
],
}
],
},
"/workstreams/workplan-index": {
"workstreams": {
"ws-1": {
"repo_slug": "the-custodian",
"relative_path": "workplans/CUST-WP-0045.md",
"needs_review": True,
"health_labels": ["needs_review"],
}
}
},
"/state/next_steps": [
{
"type": "resolved_decision",
"domain": "custodian",
"workstream_id": "ws-1",
"workstream_slug": "cust-wp-0045",
"workstream_title": "Activity-Core Daily Triage Runner Cutover",
"task_id": "task-1",
"task_title": "T05 - Update ActivityDefinition",
"message": "free text should not be included",
}
],
"/messages/": [
{
"id": "msg-1",
"from_agent": "hub",
"subject": "Please review",
"body": "free text should not be included",
"created_at": "2026-05-19T05:00:00Z",
}
],
"/workstreams/ws-1": {
"planning_priority": "high",
"planning_order": 45,
},
"/tasks/": [
{
"id": "task-1",
"title": "T05 - Update ActivityDefinition",
"status": "todo",
"priority": "high",
"needs_human": False,
"description": "free text should not be included",
},
{
"id": "task-2",
"title": "T06 - Canary Cutover",
"status": "blocked",
"priority": "medium",
"needs_human": True,
},
],
}
def fake_get(url: str, **kwargs: Any) -> DummyResponse:
path = url.removeprefix("http://state-hub.test")
return DummyResponse(payloads[path])
monkeypatch.setenv("STATE_HUB_URL", "http://state-hub.test")
monkeypatch.setattr(httpx, "get", fake_get)
raw_digest = StateHubContextResolver().resolve(
"daily_triage_digest",
None,
{"max_workstreams": 4, "max_next_steps": 4},
)
assert isinstance(raw_digest, str)
assert "free text should not be included" not in raw_digest
import json
digest = json.loads(raw_digest)
assert digest["totals"] == {"tasks": {"todo": 4, "blocked": 1}}
assert digest["open_workstreams"][0]["slug"] == "cust-wp-0045"
assert digest["open_workstreams"][0]["planning_priority"] == "high"
assert digest["open_workstreams"][0]["open_task_counts"] == {
"todo": 1,
"in_progress": 0,
"blocked": 1,
"needs_human": 1,
"open_total": 2,
}
assert digest["deterministic_scoring"]["future_mode"] == (
"code_score_high_gain_high_effort_candidates"
)