Files
last30days-skill/tests/test_planner_quiet_mode.py
T
Matt Van Horn 00d01933e0 fix: per-entity Step 0.55, LAW 7 sub-run quiet, default 2, canonical SKILL.md (#311)
Four fixes based on 2026-04-22 test-window feedback on v3.0.11 --competitors:

- Each competitor sub-run now runs Step 0.55 (X handle / subreddits /
  GitHub) via resolve.auto_resolve inside the fanout closure. Deep-copied
  config per entity prevents _auto_resolve_context leak across sub-runs.
  Resolved data stored on report.artifacts["resolved"] for the renderer.
- New internal_subrun keyword on planner.plan_query and pipeline.run
  suppresses the LAW 7 "No --plan passed" stderr for engine-internal
  fan-out only. Default path unchanged.
- Default --competitors count is now 2 (3-way total). --competitors=N
  still customizes; range 1..6.
- SKILL.md STEP 0 canonical-path self-check forces readers who loaded
  from marketplaces/ (auto-restored to origin/main, stale) to re-read
  from plugins/cache/last30days-skill/last30days/{VERSION}/SKILL.md.
  Two of three 2026-04-22 test windows hit this stale-path trap.
- New ## Resolved Entities block in render_comparison_multi shows
  per-entity handles/subs/github for debug visibility.

Bumps plugin.json to 3.0.12. 12 new tests; 1,175 total passing.

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:30:08 -07:00

56 lines
1.8 KiB
Python

# ruff: noqa: E402
"""Tests for planner.plan_query internal_subrun quiet mode."""
from __future__ import annotations
import io
import sys
import unittest
from contextlib import redirect_stderr
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from lib import planner
class PlannerQuietModeTests(unittest.TestCase):
def _call(self, *, internal_subrun: bool):
err = io.StringIO()
with redirect_stderr(err):
plan = planner.plan_query(
topic="Acme Corp",
available_sources=["grounding", "reddit"],
requested_sources=None,
depth="default",
provider=None,
model=None,
internal_subrun=internal_subrun,
)
return plan, err.getvalue()
def test_default_emits_law7_warning(self):
plan, stderr = self._call(internal_subrun=False)
self.assertIn("No --plan passed", stderr)
self.assertIn("YOU ARE the planner", stderr)
self.assertTrue(plan.subqueries)
def test_internal_subrun_suppresses_warning(self):
plan, stderr = self._call(internal_subrun=True)
self.assertNotIn("No --plan passed", stderr)
self.assertNotIn("YOU ARE the planner", stderr)
# Still returns a valid fallback plan
self.assertTrue(plan.subqueries)
def test_internal_subrun_still_allows_other_warnings(self):
"""Quiet mode only silences the LAW 7 block, not all planner output."""
plan, _stderr = self._call(internal_subrun=True)
# The plan itself is deterministic fallback; verify note carries
# no planner-error indication.
self.assertGreater(len(plan.subqueries), 0)
if __name__ == "__main__":
unittest.main()