Files
roboco/tests/unit/config/test_x_engine_flag.py
T
0450ec9e89 feat(x-engine): smart spotlight cadence — daily when there's news, quiet when there isn't (#374)
CEO verdict on the blind 3-day timer: 'It should default to 1 day and
be more like... smart.' Now: interval defaults to 1 day; the cycle
skips (with logged reasons) while a spotlight draft is still awaiting
the CEO, and stretches to 3x the interval when nothing has shipped
(CHANGELOG sections via the read clone) since the last spotlight
activity — where activity is a materialized draft's seen_at or a
completed exploration's updated_at, deliberately excluding the stale-
cycle janitor's cancels. The HoM gains an explicit skip exit
(propose_feature_spotlight skip=true + reason: completes the
exploration, no draft, no seen-slug, still counts as activity), and
its spawn prompt now carries the seen ledger WITH dates, what shipped
since the last spotlight, and recently rejected drafts with the CEO's
reasons — fresh-but-unspotlighted first. Fail-open on changelog read
errors so a signal outage never starves the engine.

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
2026-07-09 20:59:53 +02:00

60 lines
1.9 KiB
Python

"""The X engine is gated by default-off config flags (mirrors release manager)."""
from __future__ import annotations
import os
from unittest import mock
from roboco.config import Settings
from roboco.services.settings import FEATURE_FLAGS, validate_setting
_DEFAULT_INTERVAL = 1800
_DEFAULT_MAX_OPEN = 10
_DEFAULT_SPOTLIGHT_INTERVAL_SECONDS = 86400 # 1 day
def test_x_engine_disabled_by_default() -> None:
s = Settings()
assert s.x_engine_enabled is False
assert s.x_mentions_interval_seconds == _DEFAULT_INTERVAL
assert s.x_max_open_posts == _DEFAULT_MAX_OPEN
def test_x_engine_reads_env_var() -> None:
with mock.patch.dict(os.environ, {"ROBOCO_X_ENGINE_ENABLED": "true"}):
assert Settings().x_engine_enabled is True
def test_x_mentions_interval_reads_env_var() -> None:
override = 900
with mock.patch.dict(
os.environ, {"ROBOCO_X_MENTIONS_INTERVAL_SECONDS": str(override)}
):
assert Settings().x_mentions_interval_seconds == override
def test_x_engine_flag_registered_in_feature_flags() -> None:
assert "x_engine_enabled" in [key for key, _ in FEATURE_FLAGS]
def test_x_engine_flag_validates_as_bool() -> None:
validate_setting("x_engine_enabled", "true")
def test_x_feature_spotlight_disabled_by_default() -> None:
assert Settings().x_feature_spotlight_enabled is False
def test_x_feature_spotlight_flag_registered_in_feature_flags() -> None:
assert "x_feature_spotlight_enabled" in [key for key, _ in FEATURE_FLAGS]
def test_x_feature_spotlight_interval_defaults_to_one_day() -> None:
"""CEO directive: default cadence is 1 day (was 3 days) — the engine's
own smart-cadence guard stretches this to 3x when quiet instead of the
interval itself defaulting slower."""
assert (
Settings().x_feature_spotlight_interval_seconds
== _DEFAULT_SPOTLIGHT_INTERVAL_SECONDS
)