From 0f6ecd25b03e60eea07e725cc534a2c2cb71893b Mon Sep 17 00:00:00 2001 From: Jer Miller Date: Tue, 14 Apr 2026 21:56:46 -0600 Subject: [PATCH] decisionalizer: add pre-hook gate to skip days with no decision outputs When no decisions.md activity files exist for the target day, the pre-hook returns a skip_reason so the orchestrator bypasses the LLM call entirely. Modeled on the documents.py pre-hook pattern. --- talent/decisionalizer.md | 3 ++- talent/decisionalizer.py | 16 +++++++++++++ tests/test_decisionalizer_hook.py | 39 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 talent/decisionalizer.py create mode 100644 tests/test_decisionalizer_hook.py diff --git a/talent/decisionalizer.md b/talent/decisionalizer.md index 3e2b45ee2..7634ca9aa 100644 --- a/talent/decisionalizer.md +++ b/talent/decisionalizer.md @@ -6,7 +6,8 @@ "color": "#c62828", "schedule": "daily", "priority": 60, - "output": "md" + "output": "md", + "hook": {"pre": "decisionalizer"} } $sol_identity diff --git a/talent/decisionalizer.py b/talent/decisionalizer.py new file mode 100644 index 000000000..b79b1ad09 --- /dev/null +++ b/talent/decisionalizer.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright (c) 2026 sol pbc + +"""Pre-hook for decisionalizer talent — skips days with no decision outputs.""" + +from pathlib import Path + +from think.utils import get_journal + + +def pre_process(context: dict) -> dict | None: + """Skip days that have no decision activity outputs.""" + day = context["day"] + if not any(Path(get_journal()).glob(f"facets/*/activities/{day}/*/decisions.md")): + return {"skip_reason": "no decision outputs for day"} + return {} diff --git a/tests/test_decisionalizer_hook.py b/tests/test_decisionalizer_hook.py new file mode 100644 index 000000000..e4b255d26 --- /dev/null +++ b/tests/test_decisionalizer_hook.py @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: AGPL-3.0-only +# Copyright (c) 2026 sol pbc + +"""Tests for decisionalizer pre-hook.""" + +from unittest.mock import patch + +from talent.decisionalizer import pre_process + + +def test_skip_when_no_decisions(tmp_path): + """Skip when no decisions.md files exist for the day.""" + activities = tmp_path / "facets" / "somefacet" / "activities" / "20260410" + activities.mkdir(parents=True) + + with patch("talent.decisionalizer.get_journal", return_value=str(tmp_path)): + result = pre_process({"day": "20260410"}) + + assert result == {"skip_reason": "no decision outputs for day"} + + +def test_proceed_when_decisions_exist(tmp_path): + """Proceed when decisions.md files exist for the day.""" + decisions = ( + tmp_path + / "facets" + / "testfacet" + / "activities" + / "20260410" + / "meeting_100000_300" + / "decisions.md" + ) + decisions.parent.mkdir(parents=True) + decisions.write_text("") + + with patch("talent.decisionalizer.get_journal", return_value=str(tmp_path)): + result = pre_process({"day": "20260410"}) + + assert result == {} -- 2.51.2