generated from coulomb/repo-seed
Implement weekly coding retro schedule
This commit is contained in:
@@ -25,6 +25,7 @@ from activity_core.rules.models import TaskRef, TaskSpec
|
||||
|
||||
_DEFINITIONS_DIR = Path(__file__).parent.parent / "activity-definitions"
|
||||
_SBOM_DEF_PATH = _DEFINITIONS_DIR / "weekly-sbom-staleness.md"
|
||||
_CODING_RETRO_DEF_PATH = _DEFINITIONS_DIR / "weekly-coding-retro.md"
|
||||
|
||||
|
||||
# ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
@@ -95,6 +96,69 @@ def test_sbom_definition_parses_correctly():
|
||||
assert defn.rules[0]["id"] == "flag-stale-sbom"
|
||||
|
||||
|
||||
def test_coding_retro_definition_parses_disabled_until_verified():
|
||||
defn = parse_file(_CODING_RETRO_DEF_PATH)
|
||||
|
||||
assert defn.id == "weekly-coding-retro"
|
||||
assert defn.enabled is False
|
||||
assert defn.trigger_config["trigger_type"] == "cron"
|
||||
assert defn.trigger_config["cron_expression"] == "0 19 * * 6"
|
||||
assert defn.trigger_config["timezone"] == "Europe/Berlin"
|
||||
assert defn.context_sources == [
|
||||
{
|
||||
"type": "state-hub",
|
||||
"query": "coding_retro",
|
||||
"params": {"window_days": 7, "limit": 100},
|
||||
"bind_to": "context.retro",
|
||||
}
|
||||
]
|
||||
assert len(defn.rules) == 1
|
||||
assert defn.rules[0]["id"] == "propose-weekly-improvements"
|
||||
|
||||
|
||||
def test_coding_retro_rule_emits_one_task_per_positive_suggestion():
|
||||
defn = parse_file(_CODING_RETRO_DEF_PATH)
|
||||
rule = defn.rules[0]
|
||||
context = {
|
||||
"retro": {
|
||||
"suggestions": [
|
||||
{
|
||||
"repo": "activity-core",
|
||||
"title": "Harden coding retro smoke gates",
|
||||
"recommendation": "Dry-run with fixture and live hub evidence.",
|
||||
"priority": "high",
|
||||
"score": 8.5,
|
||||
},
|
||||
{
|
||||
"repo": "quiet-repo",
|
||||
"title": "Do not emit zero-score suggestion",
|
||||
"recommendation": "This should stay quiet.",
|
||||
"priority": "low",
|
||||
"score": 0,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
specs = expand_rule_actions([rule], _EmptyEvent(), context)
|
||||
|
||||
assert specs == [
|
||||
{
|
||||
"title": "Harden coding retro smoke gates",
|
||||
"description": "Dry-run with fixture and live hub evidence.",
|
||||
"target_repo": "activity-core",
|
||||
"priority": "high",
|
||||
"labels": ["coding-retro", "improvement", "automated"],
|
||||
"due_in_days": None,
|
||||
"source_type": "rule",
|
||||
"source_id": "propose-weekly-improvements",
|
||||
"triggering_event_id": "",
|
||||
"activity_definition_id": "",
|
||||
"condition": "context.s.score > 0",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_pipeline_emits_one_task_for_stale_repo_only():
|
||||
"""Stale repo (45 days) matches; fresh repo (10 days) does not."""
|
||||
defn = parse_file(_SBOM_DEF_PATH)
|
||||
|
||||
Reference in New Issue
Block a user