fix(cli): wrap plan apply --format json output in spec-required JSON envelope #11018
Merged
HAL9000
merged 5 commits from 2026-06-15 01:23:46 +00:00
pr-9817-plan-apply-json into master
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#11018
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 "pr-9817-plan-apply-json"
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?
Summary
Fix the
agents plan apply --format jsoncommand to return a spec-compliant JSON envelope instead of a raw plan dictionary. The command now properly wraps the plan data in the required envelope structure withcommand,status,exit_code, anddatafields containing artifacts, changes, validation, sandbox cleanup, and lifecycle information.Changes
lifecycle_apply_planfunction insrc/cleveragents/cli/commands/plan.pyto wrap non-rich format output in spec-required JSON envelope_apply_output_dicthelper function exclusively forplan applycall sitescommand: "plan apply",status: "ok",exit_code: 0, andtimingfieldsdatafield contains:artifacts: count of files changedchanges: insertions and deletions from git diffproject: project identifierapplied_at: timestamp of applicationvalidation: test, lint, and type_check results with durationsandbox_cleanup: worktree, branch, and checkpoint statuslifecycle: phase, state, total_duration, total_cost, decisions_made, child_plansmessages: ["Changes applied"]to response envelopePlan as LifecyclePlanimport to module top-levelTesting
features/plan_apply_json_envelope.featurecovering:_plan_spec_dict, not apply envelope)robot/plan_apply_json_envelope.robotwith helper scriptIssue Reference
Closes #9449
Epic: M3 Decisions + Validations + Invariants (v3.2.0)
8d586dd714toda048a826dda048a826dto312932fdfcCode Review — PR #11018:
fix(cli): wrap plan apply --format json output in spec-required JSON envelopeVerdict: REQUEST_CHANGES — There are multiple blocking issues across correctness, spec alignment, CI, test quality, and PR process compliance.
CI Status
CI is failing on 5 of the 5 required-for-merge checks:
lint— failing after 1m21sunit_tests— failing after 4m56sintegration_tests— failing after 5m1se2e_tests— failing after 4m20sstatus-check— failing (aggregates all above)All CI gates must be green before a PR can be merged. Please fix all CI failures before re-requesting review.
Blocking Issues Found
1. Spec Deviation —
timingField StructureThe spec (§agents plan apply, line ~13465) requires:
The PR produces:
This is a structural deviation from the spec. The
applied_attimestamp belongs indata.applied_at(which is correctly present), not intiming. Thetimingblock must containstartedandduration_ms. Fix_apply_output_dictto accept astarted_attimestamp andduration_msfrom the call site, and pass them intotiming.2. Spec Deviation —
data.validationField StructureThe spec defines:
The PR produces:
Multiple deviations: key is
test(singular) instead oftests, values are flat strings instead of structured objects, andduration_sis a numeric field (not string"0s"). Both the implementation and the Behave scenarios (which test against the"test"key) need to be corrected to match the spec.3. Spec Deviation — Missing
data.plan_idFieldThe spec's plan apply JSON output includes
"plan_id"in thedatablock:The PR omits
plan_idfrom thedatadict. This field is required by spec and must be added (plan.identity.plan_id).4. Robot Integration Tests Use Undefined Keyword
The
.robotfile callsRun Plan Apply Json Envelope Test <scenario>but this keyword is never defined — it is not incommon.resource, not in the robot file's own*** Keywords ***section (which doesn't exist), and not in any imported resource. This is the root cause of theintegration_testsCI failure.All other robot files in this project use the pattern:
The
.robotfile must be rewritten to useRun Process ${PYTHON} ${HELPER} <scenario> cwd=${WORKSPACE}consistently with project conventions.5. Robot Helper Uses Plain Dicts Instead of LifecyclePlan Domain Objects
The
helper_plan_apply_json_envelope.pyconstructs a plaindictand sets it asservice.apply_plan.return_value. Whenlifecycle_apply_plancalls_apply_output_dict(plan), the plan is a dict, not aLifecyclePlaninstance. Theisinstance(plan, LifecyclePlan)guard in_apply_output_dictwill beFalse, so all robot tests exercise the legacy fallback path only — they never test the real implementation.The robot helper must construct a real
LifecyclePlandomain object (as the Behave steps correctly do). Import and use the actual domain model classes, or the tests are effectively testing dead code.6. Commit Message Type Is Invalid (
bugis not a Conventional Changelog type)bug(cli): ...is not a valid Conventional Changelog type. Valid types are:feat,fix,docs,style,refactor,test,chore,perf,ci,build,revert. A bug fix must usefix. This appears to be an error in the issue's Metadata section that was carried through verbatim. The issue's Metadata should be corrected to prescribefix(cli): ..., and the commit message must be amended to usefix.7. PR Missing Milestone
Linked issue #9449 is assigned to milestone
v3.2.0. Per CONTRIBUTING.md §12, PRs must be assigned the same milestone as their linked issue(s). The PR has no milestone assigned — please set it tov3.2.0.8. PR Missing
Type/LabelThe PR has no
Type/label. Exactly oneType/label is required. This is a bug fix, soType/Bugmust be applied.9. Forgejo Dependency Direction Not Set
Per CONTRIBUTING.md §2 (CRITICAL), the PR must block the linked issue — not the other way around. Set the dependency: PR #11018 → blocks → Issue #9449. Verify that issue #9449 shows this PR under "depends on". Currently no dependency relationship is set at all.
10. Branch Name Does Not Match Issue Metadata
Issue #9449's
## Metadatasection specifiesBranch: fix/plan-apply-json-envelope. The actual PR branch ispr-9817-plan-apply-json. Per CONTRIBUTING.md, the branch used must match theBranchfield in the issue Metadata exactly. This is a policy violation.Minor (Non-Blocking) Observations
_execute_output_dict: The diff changesReturns:toReturns:(adds 2-space indent), which is invalid Google-style docstring format and is likely the root cause of thelintCI failure. Revert this unintended change.changeshardcoded to zeros:data.changesalways reports{"insertions": 0, "deletions": 0}. The spec shows real diff data here. This is an acceptable incremental limitation but should be tracked in a follow-up issue.sandbox_refsas proxy forartifacts: Usinglen(plan.sandbox_refs)as a proxy for files changed is a reasonable fallback, but the relationship between sandbox refs and files changed may not be 1:1. Consider tracking in a follow-up.Summary
The core implementation concept is correct — wrapping
lifecycle_apply_plannon-rich output in a dedicated_apply_output_dicthelper is the right approach. However, the PR has multiple blocking issues that must be resolved:timingstructure,validationstructure, missingdata.plan_id)bug→fix)v3.2.0and labelType/Bugto the PR_execute_output_dictOnce CI is green and all blocking issues are resolved, re-request review.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
@@ -0,0 +3,4 @@from __future__ import annotationsimport jsonimport sysBLOCKING — Robot helper uses plain dicts; all tests exercise the legacy fallback path, not the real implementation
_make_plan()builds a plain Pythondictand sets it assvc.apply_plan.return_value. Whenlifecycle_apply_plancalls_apply_output_dict(plan), theisinstance(plan, LifecyclePlan)check returnsFalse(dict is not a LifecyclePlan). The function falls into the legacy fallback:This means every robot test is asserting against the legacy minimal envelope, not the spec-required structured envelope. The tests appear to pass (or would pass) even if the real implementation is completely broken.
Fix: construct a real
LifecyclePlanobject in_make_plan(), exactly as_make_plan()does in the Behave step definitions (plan_apply_json_envelope_steps.py):Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
@@ -0,0 +10,4 @@Envelope Has All Required Top-Level Fields[Documentation] Verify that the plan apply JSON envelope contains all required top-level keys.${result}= Run Plan Apply Json Envelope Test verify_top_level_fieldsShould Be Equal As Integers ${result.rc} 0BLOCKING — Undefined Robot keyword causes integration_tests CI failure
Run Plan Apply Json Envelope Testis not defined anywhere in the project. The robot file has no*** Keywords ***section, and the keyword is absent fromcommon.resourceand all imported resources. Every test case in this file will fail withNo keyword with name 'Run Plan Apply Json Envelope Test' found.All other robot files in this project follow this established convention:
Rewrite all test cases to use
Run Process ${PYTHON} ${HELPER} <scenario_name> cwd=${WORKSPACE}, matching howhelper_cli_formats.py,helper_apply_pipeline.py, and other helpers are invoked.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
BLOCKING — Docstring indent regression causes lint failure
This diff changes
Returns:(4-space indent, correct Google-style docstring) toReturns:(6-space indent, incorrect). This appears to be an unintended edit and is likely the root cause of theCI / lintfailure. Please revert this specific change in_execute_output_dict.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
BLOCKING — Spec Deviation:
validationkey names and value structure are wrongThe spec (§agents plan apply) defines the validation sub-object as:
This implementation has three deviations:
"test"(singular) — must be"tests"(plural)"passed") — must be structured objects per spec"duration"as a string"0s"— must be"duration_s"as a numeric floatThe Behave feature file also checks against
"test"— both the implementation and the test assertions must be updated to match the spec.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
BLOCKING — Spec Deviation:
timingfield structure is wrongThe spec (§agents plan apply, line ~13465) requires:
This implementation produces:
applied_atis already present indata.applied_at. Thetimingblock must containstarted(ISO timestamp of when the command began) andduration_ms(elapsed milliseconds). Update_apply_output_dictto accept these as parameters fromlifecycle_apply_plan, which should measure wall-clock time around the service call.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Review complete. REQUEST_CHANGES submitted (Review ID: 8301).
10 blocking issues identified — see the review for full details. Summary of required changes:
timingmust have{started, duration_ms},validationmust usetestskey with structured objects,data.plan_idmust be included.robotfile to useRun Process ${PYTHON} ${HELPER}pattern; fix helper to use realLifecyclePlanobjectsbug(cli)→fix(cli)v3.2.0and labelType/Bug_execute_output_dictAutomated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
[CONTROLLER-DEFER:Gate 1:full_duplicate]
This PR has been deferred for re-evaluation. The controller has stepped back
from processing it. To resume, a human or scope-evaluator must clear the
deferral flag AND re-add the auto/sentinel label.
Decision:
To clear the deferral (SQL):
UPDATE workflows SET deferred_reason=NULL,
deferred_at=NULL,
deferred_target_workflow_id=NULL
WHERE workflow_id = 420;
Audit ID: 155571
Automated by the CleverAgents controller pipeline.
Identity: HAL9000 (pipeline action)
📋 Estimate: tier 1.
8-file PR (+1134/-10) adding a JSON envelope wrapper to plan apply CLI output plus 31 new tests (16 Behave + 15 Robot). Core logic change is bounded to one function in plan.py, but CI has 5 failing gates requiring diagnosis: lint (ruff format on one steps file — trivial), unit_tests (12 failed/8 errored spanning both new and apparently pre-existing feature files), e2e/integration (truncated logs), security (bandit nosec warnings). The unrelated feature file failures (actor_run_signature, plan_service_coverage, tdd_memory_service_entity_persistence) require cross-file investigation to determine if caused by this PR or pre-existing. Multi-file scope with new test infrastructure and multiple CI failures to triage and fix is standard Tier 1 work.
📋 Estimate: tier 1.
Focused CLI change (one function + helper in plan.py) but implementation is demonstrably incomplete: all new plan_apply_json_envelope Behave scenarios fail, existing plan_cli_coverage_boost tests regress, all new Robot integration tests fail, and an E2E test (M6 Full Autonomy) fails suggesting a downstream contract regression. Fix requires debugging the envelope construction logic, reconciling existing test expectations, and investigating the E2E regression — multi-file test context required. Lint failure (ruff format on one step file) is trivial. Actor/plan_service/memory-service failures appear pre-existing. Standard tier-1 debugging and test-fix work.
9260b962a5toff2b627772📋 Estimate: tier 1.
Multi-file change (8 files, +1019/-512) with three active CI failures: 4 Pyright errors accessing a nonexistent private method
_commit_planonPlanLifecycleServiceat 4 call sites in plan.py, 29 failing Behave unit test scenarios across multiple feature files, and 1 failing Robot integration test. The implementer must locate the correct PlanLifecycleService API surface, fix all 4 type errors, repair the failing test scenarios, and pass the integration test — standard cross-file, test-heavy tier-1 work with clear but non-trivial debugging scope.5e25a20de9to23057589652305758965to208988cdde✅ Approved
Reviewed at commit
208988c.Confidence: high.
Claimed by
merge_drive.py(pid 2329255) until2026-06-15T02:37:18.190690+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
208988cddeto372ef09153Approved by the controller reviewer stage (workflow 420).