Files
agentic-resources/tests/test_retro_publish.py
tegwick 0d05dfcc5d session-memory: weekly retro entrypoint + hub publish (AGENTIC-WP-0010)
The analysis half of the weekly coding retrospection. retro/build.py: windowed
detect+measure -> top-3 improvement suggestions per repo (cross-flavor first,
recommendations pulled from the Pattern Catalog) + fleet snapshot. retro/publish.py:
publishes the report to the hub as the coding_retro read model (event_type=
coding_retro progress event) + local JSON/md, graceful degrade. retro entrypoint
with --window-days/--publish/--json. Live verify over real sessions surfaced
per-repo suggestions with catalog recommendations. 13 new tests; suite 152/152.

Consumed by activity-core ACTIVITY-WP-0008 (Weekly Coding Retrospection, Sat 19:00).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 19:17:24 +02:00

63 lines
2.0 KiB
Python

"""Retro publish tests (AGENTIC-WP-0010 T02)."""
import json
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from session_memory.retro.publish import ( # noqa: E402
publish_to_hub,
render_markdown,
write_local,
)
def _report():
return {
"window": {"since": "2026-06-01T00:00:00Z", "until": "2026-06-08T00:00:00Z", "days": 7},
"generated_at": "2026-06-08T19:00:00Z", "n_sessions": 12,
"suggestions": [
{"repo": "state-hub", "title": "schema thrash", "recommendation": "front-load schemas",
"priority": "high", "score": 632.0, "cross_flavor": False, "signal_type": "schema_thrash"},
],
"measure": {"infra_overhead_share_median": 0.117, "error_rate": 0.96,
"schema_thrash_sessions": 8, "success_rate": 1.0, "tokens_p50": 250725},
}
def test_render_markdown():
md = render_markdown(_report())
assert "Weekly Coding Retro" in md
assert "**state-hub**" in md and "front-load schemas" in md
assert "infra-overhead median: 0.117" in md
def test_write_local_json_and_md(tmp_path):
jp = str(tmp_path / "out" / "retro.json")
mp = str(tmp_path / "out" / "retro.md")
write_local(_report(), jp, mp)
assert json.load(open(jp))["n_sessions"] == 12
assert "Weekly Coding Retro" in open(mp).read()
def test_publish_calls_poster_with_coding_retro_event():
captured = {}
def poster(url, payload):
captured["url"] = url
captured["payload"] = payload
ok = publish_to_hub(_report(), base_url="http://hub", poster=poster)
assert ok is True
assert captured["url"] == "http://hub/progress/"
assert captured["payload"]["event_type"] == "coding_retro"
assert captured["payload"]["detail"]["n_sessions"] == 12
def test_publish_degrades_gracefully_on_failure():
def boom(url, payload):
raise OSError("hub down")
assert publish_to_hub(_report(), poster=boom) is False