feat(actor): add plan_subplan tool and decision emission #463
Labels
Clear labels
auto/needs-reevaluation
controller-managed
overdue
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Needs Feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
Controller deferred this PR; awaiting Phase 6+ scope-evaluator or operator re-enablement.
Auto-agents controller manages this PR/issue (see tools/controller/deploy/RUNBOOK.md). Remove this label to abandon controller management.
PR blocked by an open issue dependency. Operator must close the dep (or remove the dependency link) before the merge driver can act. Auto-cleared by merge_drive when no open deps remain.
Most recent merge cycle hit CI timeout. Driver excludes this PR while last merge_cycle row is < 30 min old; label persists thereafter as visible history.
Currently being processed by an implementer worker.
Currently being processed by the merge driver.
Currently being processed by a reviewer worker.
Merge driver heartbeat stale; pipeline halted. Closed automatically on next clean tick.
Detected master commit violating the strict merge invariant. Tracked as an issue (not a PR label); kept here for label completeness.
In-cycle escalation: most recent attempt ran at the Tier 0 slot (`tier-0`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 1 slot (`tier-1`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 2 slot (`tier-2`). Slot's model defined in .opencode/models/tiers.yaml. Gated behind IMPLEMENTER_ESCALATION_TIER2_ENABLED.
In-cycle escalation: most recent attempt ran at the Tier -1 slot (`tier-min`). Slot's model defined in .opencode/models/tiers.yaml. Suffix is ``-min`` (not ``--1``) so the Forgejo UI reads naturally.
Tracking issues used by the AI Automation system for agents to communicate and report.
Rebase conflict needs LLM conflict-resolver.
Failing CI needs implementer attention.
Documenting a driver incident or rollback.
Reviewer has APPROVED this PR and no later REQUEST_CHANGES is outstanding. The merge driver requires this label to even consider a PR for merging. Set by the reviewer worker on APPROVE; cleared on REQUEST_CHANGES.
Train repeatedly lost master-tempo races. Driver excludes via merge_cycle until cooldown elapses; label persists as visible history.
Revert PR backing out an invariant violation. Fast-tracked through the merge driver.
Sentinel PR duplicated from upstream into a personal fork by tools/duplicate_prs_to_fork.py for pipeline testing. Lives only in the fork; the canonical pipeline never sees it.
No implementer activity for N days. Flagged for human review. Auto-cleared on next push to head branch.
Repeatedly fails on current master (>= 3 ci-fail-on-rebased-sha releases in 12 h). Excluded from driver until human triage.
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
CI Blocker
Critical priority issue that blocks CI/CD pipeline and prevents PR merges
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Automation
Any edits or discussion about the AI automated coding system.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Refactor
A code change that restructures existing code without changing its external behavior.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
Projects
Clear projects
No project
Assignees
aditya (Aditya Chhabra)
aleenaumair (Aleena Umair)
brent.edwards (Brent Edwards)
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
HAL9000 (HAL 9000)
HAL9001 (HAL9001)
hamza.khyari (Hamza Khyari)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
org.cleveragents
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cleveragents/cleveragents-core#463
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "feature/m5-subplan-actor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Implements the
builtin/plan-subplantool that strategy actors call to emitSUBPLAN_SPAWNorSUBPLAN_PARALLEL_SPAWNdecisions when decomposing a largeplan into coordinated child plans. Validates the subplan payload, applies
sensible defaults, generates human-readable rationale text, and optionally
persists the emitted
Decisionvia an injectedDecisionService.Type of Change
Quality Checklist
Anyunless justified)nox -s typecheckpasses with no errorsnox -s lintpasses with no errorsfeatures/)robot/) if applicablenox -s coverage_report)nox -s security_scan)nox -s dead_code)Testing
All tests written before implementation (TDD). Tests cover validation,
defaults, serial vs parallel decision types, rationale generation, decision
service injection, registry registration, and ToolRunner execution.
Test Commands Run
Related Issues
ISSUES CLOSED #198
Implementation Notes
New files
src/cleveragents/tool/builtins/subplan_tool.pySubplanPayload,make_plan_subplan_spec,PLAN_SUBPLAN_SPECfeatures/plan_subplan_tool.featurefeatures/steps/plan_subplan_tool_steps.py_StubDecisionServicerobot/plan_subplan_tool.robotrobot/helper_plan_subplan_tool.pybenchmarks/subplan_actor_tool_bench.pyexamples/actors/strategy_with_subplan.yamlModified files
src/cleveragents/tool/builtins/__init__.py— addedregister_subplan_tool,SubplanPayload,make_plan_subplan_spec,ALL_SUBPLAN_TOOLSexportsCHANGELOG.md— added#198entryArchitecture decisions
Optional
DecisionServiceinjection via factory: The tool itself is apure function.
make_plan_subplan_spec(decision_service=None)creates aToolSpecwhose handler is a closure bound to the service. In production theruntime injects the real
DecisionService; in tests a list-based stub is used,keeping 100% of tool logic testable without a database.
SubplanPayloadas the single validation layer: All input constraints(non-empty goal, at least one of
resource_scopes/project_ref,max_parallel1–50, valid
merge_strategyenum, validcontext_viewvalue) are enforced by afrozen Pydantic model. Any validation failure returns
{"success": False, "error": ...}rather than raising, so the ToolRunner never sees an unhandled exception.Decision type driven by
parallelflag:parallel=FalseemitsSUBPLAN_SPAWN;parallel=TrueemitsSUBPLAN_PARALLEL_SPAWN. Thedependencieslist (sibling subplan ULIDs) is only meaningful for parallelspawns but is accepted and stored in both cases for forward compatibility.
Rationale auto-generation:
_build_rationale()constructs a multi-linehuman-readable string from the payload (goal, targeted resources, execution
mode, dependencies, context view override). This text is stored on the
Decision.rationalefield and surfaced inplan explainoutput.131be21e80to4c4bd74d944c4bd74d94to131be21e80Code Review — Bugs & Security Findings
Reviewed commits
b888afab(feat) and131be21e(fix) onfeature/m5-subplan-actoragainst issue #198 acceptance criteria anddocs/specification.md.BUGS
B1 [High]
parent_decision_idaccepted but never returned to callerFile:
src/cleveragents/tool/builtins/subplan_tool.py:268-281The
parent_decision_idfield is accepted inSubplanPayload(line 149), stored in theDecisionobject (line 255), but the handler's return dict (lines 268-281) omits it entirely. The calling actor has no way to confirm the parent linkage was recorded.The corresponding Behave scenario ("parent_decision_id is included in the decision when provided" at
features/plan_subplan_tool.feature:112-116) only assertssuccess=Trueanddecision_type— it never verifiesparent_decision_idis present in the result, making the test name misleading and the assertion vacuous.Fix: Add
"parent_decision_id": payload.parent_decision_idto the return dict at line 281, and update the test to assert its value.B2 [Medium] "Verify all examples are documented" scenario not updated
File:
features/actor_examples.feature:665-677The fix commit (
131be21e) correctly updated the "Verify all example files exist" scenario (line 654) to expect 7 files includingstrategy_with_subplan.yaml. However, the adjacent "Verify all examples are documented" scenario (line 665) was not updated to check thatstrategy_with_subplan.yamlis referenced indocs/reference/actors_examples.md. Additionally,docs/reference/actors_examples.mddoes not appear to have been updated to reference the new example.B3 [Medium] Specification naming discrepancy
Spec:
docs/specification.md§Child Plan Spawning Mechanism:Implementation:
builtin/plan-subplan(subplan_tool.py:76)These differ in both namespace (
local/vsbuiltin/) and name (create-subplanvsplan-subplan). Either the specification or the implementation should be updated for consistency.SECURITY
S1 [High] No ULID format validation on
plan_id,dependencies,parent_decision_idFile:
src/cleveragents/tool/builtins/subplan_tool.py:115,141-143,149-151SubplanPayloadaccepts arbitrary strings forplan_id(onlymin_length=1),dependencies(no validation), andparent_decision_id(no validation). These fields semantically represent ULIDs.The
Decisionmodel in the same codebase (domain/models/core/decision.py) rigorously validates ULID fields with a regex pattern (^[0-9A-HJKMNP-TV-Z]{26}$) and dedicated@field_validatormethods. This inconsistency means:plan_idvalues pass the tool handler, then fail insideDecision(**decision_kwargs), producing a confusing error message about the Decision model rather than about the tool input.dependenciesentries flow into the rationale text completely unchecked.Fix: Add
@field_validatormethods onplan_id,dependencies, andparent_decision_idinSubplanPayloadenforcing the same ULID regex pattern used by theDecisionmodel.S2 [Medium] No path validation on
resource_scopesFile:
src/cleveragents/tool/builtins/subplan_tool.py:119-121resource_scopesaccepts arbitrary strings with no format or sanitization checks. Values like[""],["../../etc/passwd"], or extremely long strings are accepted and flow into the Decision rationale and downstream processing. Early validation (non-empty strings, no path traversal sequences) would prevent garbage from entering the decision tree.S3 [Low] Overly broad exception handling masks programming errors
File:
src/cleveragents/tool/builtins/subplan_tool.py:226This catches
ValidationError(intended) but alsoTypeError,AttributeError,KeyError, and any other exception that might indicate a bug in the validation code itself. These bugs would silently become user-facing error messages instead of surfacing as real failures.Fix: Catch
pydantic.ValidationErrorandValueErrorexplicitly.cc72ec0936toeb4e6f59d9P1 — Must Fix
P1-1: Sham rationale test — asserts non-empty, not goal presence
features/steps/plan_subplan_tool_steps.py:302-305The feature scenario "Rationale is auto-generated for serial subplan" claims to verify the goal is mentioned in the rationale, but the step
step_then_rationale_goalonly assertsassert rationale(truthy / non-empty). Any non-empty string passes.Fix: Assert the actual goal text appears in the rationale. The
Whenstep for this scenario passesgoal="Refactor models", so:P1-2:
source="builtin"silently discarded —ToolSpechas nosourcefieldsrc/cleveragents/tool/builtins/subplan_tool.py:427ToolSpec(defined intool/runtime.py:39) has nosourcefield. Pydantic v2 defaults toextra="ignore", so this kwarg is silently dropped. Any downstream code that tries to inspectspec.sourcewill getAttributeError. If the intent is to tag built-in tools by origin,sourcemust be added toToolSpec, or this parameter should be removed.Fix: Either add
source: str = Field(default="custom")toToolSpec, or remove thesource="builtin"kwarg.P2 — Should Fix
P2-1:
side_effectsvalue diverges from specsrc/cleveragents/tool/builtins/subplan_tool.py:424The spec (
specification.md:18101) definesside_effects: [spawn_subplan]for the create-subplan tool. The implementation uses["emit_decision"]. While the field is free-form, using a consistent vocabulary with the spec aids auditability and tool-capability queries.Fix: Use
["spawn_subplan"]or["spawn_subplan", "emit_decision"]to align with the spec vocabulary.P2-2: Dead
TYPE_CHECKINGimport guardsrc/cleveragents/tool/builtins/subplan_tool.py:81-82The block was set up but contains only
pass. Either add the intended type-only imports or remove the dead guard.P2-3: Non-deterministic
context_viewenum order in JSON schemasrc/cleveragents/tool/builtins/subplan_tool.py:92-94, 396_VALID_CONTEXT_VIEWSis afrozenset, whose iteration order is non-deterministic. The JSON schemaenumat line 396 unpacks it via[*list(_VALID_CONTEXT_VIEWS), None], producing a different enum order on each Python process restart. This can cause spurious schema-diff noise in CI.Fix: Use a
tupleorsorted()to produce a deterministic order:P3 — Nit
P3-1: Weak assertion on parallel rationale scenario
features/plan_subplan_tool.feature:98-101The scenario "Rationale for parallel subplan mentions parallel execution" only asserts that the rationale contains
"parallel". It doesn't verifysuccess=Trueordecision_type="subplan_parallel_spawn". Other parallel scenarios do check these, so this isn't a gap in coverage, but the scenario itself is under-asserted for its title.P3-2: Subplan payload fields not structurally persisted on Decision
src/cleveragents/tool/builtins/subplan_tool.py:298-309The
Decisionobject does not carryresource_scopes,merge_strategy,max_parallel,dependencies, orcontext_viewin structured fields — they only appear in the free-textrationale. This means theplan explaintree can display them (via rationale text) but they're not queryable for programmatic use. Worth a follow-up ticket if structured querying is needed.Summary
Closing as duplicate of #198 (same title, same scope). #198 is assigned to @aditya with active branch
feature/m5-subplan-actor.New commits pushed, approval review dismissed automatically according to repository settings
Not duplicate. This is THE #198 PR. I'm assigned @aditya, on
feature/m5-subplan-actorAlready approved.