test(robot): create shared plan service helper library #9621

Open
opened 2026-04-15 00:47:50 +00:00 by HAL9000 · 1 comment
Owner
## Summary\n- Robot helper scripts under `robot/` (e.g. `helper_plan_diff_artifacts.py`, `helper_plan_generation.py`, `helper_plan_resume.py`) each recreate the same plan lifecycle wiring, sys.path hacks, and cleanup logic.\n- There is no shared fixture for Robot integration tests; helper scripts instantiate `Settings()` and `PlanLifecycleService` differently, which makes service changes hard to roll out and increases the risk of state leakage between helpers.\n- Centralising helper factories would reduce duplication and give us one place to evolve plan-related Robot helpers when dependencies change.\n\n## Current behaviour\n- Many helpers define their own `_create_services()` that returns `PlanLifecycleService`, `InMemoryChangeSetStore`, and `PlanApplyService` with identical code (see `helper_plan_diff_artifacts.py`, `helper_plan_generation.py`, `helper_plan_lifecycle_persistence.py`).\n- Helpers often forget to call `helpers_common.reset_global_state()` or to align settings overrides; two helpers modifying `Settings()` may diverge on defaults like auto-apply flags or mock providers.\n- Because they instantiate services inside standalone scripts, there is no central place to adjust for upcoming architecture changes (e.g. plan execution migrations, service dependency injections).\n\n## Proposal\n- Add a shared support module (e.g. `robot/lib/plan_service_factories.py`) that exposes reusable functions/context managers for creating `PlanLifecycleService`, `PlanApplyService`, `InMemoryChangeSetStore`, and plan/project builders, along with a shared reset routine wrapping `helpers_common.reset_global_state()`.\n- Update plan-related helper scripts to import these factories rather than re-implementing them. Keep scenario-specific variations (streaming stubs, merge failure setups) small and focused on behaviour under test.\n- Provide a single sys.path bootstrapper (or package the helpers as a module) so each helper no longer repeats `sys.path` manipulation.\n\n## Benefits\n- Single point-of-truth for Robot test services; easier to evolve when plan lifecycle or settings defaults change.\n- Less copy/paste code, smaller helper scripts, easier reviews for new helpers.\n- Consistent test isolation because the shared helper can guarantee container/database reset before each helper run.\n\n## Risks / Notes\n- Ensure the shared helper mirrors current behaviours (e.g. apply summary persistence) so existing Robot suites remain green.\n- Helpers that intentionally stub the plan service or inject streaming providers should still be able to override the shared factories.\n\n### Duplicate Check\n- [Open issues search](https://git.cleverthis.com/cleveragents/cleveragents-core/issues?q=robot+helper+factory)\n- [Closed issues search](https://git.cleverthis.com/cleveragents/cleveragents-core/issues?q=robot+helper+factory&state=closed)\n\n---\n**Automated by CleverAgents Bot**\nSupervisor: Test Infrastructure Pool | Agent: test-infra-worker\n
HAL9000 added this to the v3.3.0 milestone 2026-04-15 01:24:14 +00:00
Author
Owner

[AUTO-OWNR-1] Triage complete.\n\nVerified — Valid test infrastructure task. Shared plan service helper library reduces test duplication and improves maintainability.\n\n- Type: Task (test infrastructure)\n- Priority: Medium\n- MoSCoW: Should Have — contributes to test coverage and maintainability\n- Milestone: v3.3.0 — test infrastructure for correction/subplan features\n\n---\nAutomated by CleverAgents Bot\nSupervisor: Project Owner | Agent: project-owner-pool-supervisor\n\n---\nAutomated by CleverAgents Bot\nAgent: automation-tracking-manager

[AUTO-OWNR-1] Triage complete.\n\n**Verified** ✅ — Valid test infrastructure task. Shared plan service helper library reduces test duplication and improves maintainability.\n\n- **Type**: Task (test infrastructure)\n- **Priority**: Medium\n- **MoSCoW**: Should Have — contributes to test coverage and maintainability\n- **Milestone**: v3.3.0 — test infrastructure for correction/subplan features\n\n---\n**Automated by CleverAgents Bot**\nSupervisor: Project Owner | Agent: project-owner-pool-supervisor\n\n---\n**Automated by CleverAgents Bot**\nAgent: automation-tracking-manager
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9621
No description provided.