"""A-2's actual validation (U-004) + U-005's real-call coverage: a REAL `trigger_org_node("planner", ...)` call against a deployed target project, using the same production code path U-005 built rather than a one-off subprocess call. Gated behind RUN_REAL_AGENT_E2E=1 (CLAUDE.md Testing constraint) -- costs real API usage, skipped by default in normal `python3 -m unittest` runs, matching graphloop's RUN_REAL_AGENT_E2E precedent. Run: RUN_REAL_AGENT_E2E=1 python3 -m unittest src.test_agent_e2e -v """ import subprocess import tempfile import unittest from src import agent_profile, org_node_trigger, project_scaffold, schema from src.test_support import skip_unless_env @skip_unless_env("RUN_REAL_AGENT_E2E") class RealPlannerInvocationTest(unittest.TestCase): def test_claude_agent_planner_starts_with_correct_identity(self): with tempfile.TemporaryDirectory() as tmp: subprocess.run(["git", "init"], cwd=tmp, check=True, capture_output=True) conn = schema.connect(":memory:") schema.create_schema(conn) project_scaffold.create_project(conn, tmp, init_git_if_missing=False) agent_profile.deploy_agent_definitions(tmp) answer = org_node_trigger.trigger_org_node( "planner", "In one short sentence: what is your job, and what do you never do? " "Answer only, take no other action.", tmp, timeout=120, ) self.assertTrue(answer, "planner returned an empty result") # A-2's actual question: did the identity come through, not the default # assistant persona? "不写业务代码" / "不实现" is the Planner's own red line. self.assertTrue( any(kw in answer for kw in ("规划", "需求", "Planning", "planning", "PRD", "SDD", "BRD")), "planner's answer doesn't look like the migrated planning identity: " + answer, ) if __name__ == "__main__": unittest.main()