generated from coulomb/repo-seed
Expand rule actions for per-repo tasks
Add safe action interpolation and for_each binding for rule fan-out, update the weekly SBOM definition, cover the new evaluation path, and reconcile activity-core scope/workplans for the State Hub sync.
This commit is contained in:
@@ -20,7 +20,7 @@ import pytest
|
||||
from activity_core.definition_parser import parse_file
|
||||
from activity_core.issue_sink import NullSink
|
||||
from activity_core.models import EventEnvelope
|
||||
from activity_core.rules.evaluator import evaluate_condition
|
||||
from activity_core.rules.actions import expand_rule_actions
|
||||
from activity_core.rules.models import TaskRef, TaskSpec
|
||||
|
||||
_DEFINITIONS_DIR = Path(__file__).parent.parent / "activity-definitions"
|
||||
@@ -59,27 +59,24 @@ def _run_rule_pipeline(
|
||||
spawn_log: list[dict] = []
|
||||
triggering_event_id = str(uuid.uuid4())
|
||||
|
||||
for repo in repos:
|
||||
context = {"repos": repo}
|
||||
if not evaluate_condition(rule["condition"], event, context):
|
||||
continue
|
||||
|
||||
action = rule.get("action", {})
|
||||
context = {"repos": {"repos": repos}}
|
||||
for spec_dict in expand_rule_actions([rule], event, context):
|
||||
spec = TaskSpec(
|
||||
title=f"Run SBOM rescan — {repo['repo_slug']}",
|
||||
description="SBOM rescan needed — age threshold exceeded.",
|
||||
target_repo=repo["repo_slug"],
|
||||
priority=action.get("priority", "medium"),
|
||||
labels=action.get("labels", []),
|
||||
title=spec_dict["title"],
|
||||
description=spec_dict["description"],
|
||||
target_repo=spec_dict["target_repo"],
|
||||
priority=spec_dict["priority"],
|
||||
labels=spec_dict["labels"],
|
||||
due_in_days=spec_dict["due_in_days"],
|
||||
source_type="rule",
|
||||
source_id=rule["id"],
|
||||
source_id=spec_dict["source_id"],
|
||||
triggering_event_id=triggering_event_id,
|
||||
)
|
||||
ref = sink.emit(spec)
|
||||
task_refs.append(ref)
|
||||
spawn_log.append({
|
||||
"source_id": rule["id"],
|
||||
"condition_matched": rule["condition"],
|
||||
"source_id": spec_dict["source_id"],
|
||||
"condition_matched": spec_dict["condition"],
|
||||
"triggering_event_id": triggering_event_id,
|
||||
"task_ref": ref.external_id,
|
||||
})
|
||||
@@ -121,7 +118,7 @@ def test_pipeline_emits_one_task_for_stale_repo_only():
|
||||
assert len(spawn_log) == 1
|
||||
entry = spawn_log[0]
|
||||
assert entry["source_id"] == "flag-stale-sbom"
|
||||
assert entry["condition_matched"] == "context.repos.sbom_age_days > 30"
|
||||
assert entry["condition_matched"] == "context.repo.sbom_age_days > 30"
|
||||
assert entry["triggering_event_id"] == spawn_log[0]["triggering_event_id"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user