Repository navigation
Holistic implementation planner - #61
Conversation
One planner run sees every scope and issue and orders steps by dependency across scopes. Steps stay grouped per scope with global numbers and a Depends on line. Budget scales with scopes that have issues (at most x8).
mcp 2.2 treats any non-ToolError exception as a crash: full traceback at ERROR and the reason hidden from the agent. Missing paths, file vs directory, permission and root-escape errors now reach the agent with their message.
- Implementation plan has Goal, Decisions, Tasks, Risks and Validation sections - Large reviews post issues and plan as separate comments when body is too big - Breaking JSON change: implementation_plan is now an object or null
… fix planner docs
peaks-admin
left a comment
There was a problem hiding this comment.
🔍 CodeSpy Review v2.4.4
Issues Found: 2 | Critical: 0 | High: 0 | Medium: 1
🧠 memories
Briefing: khezen/codespy/codespy-ai
Overview
The khezen/codespy/codespy-ai codebase centers around a holistic implementation planner that processes all scopes and issues in a single run, replacing the previous per-scope planning approach. Key structural elements include repository-root-relative file paths, globally numbered steps with explicit scope and dependency tracking, and a filesystem tool that returns ToolError exceptions instead of crashing the agent. Important constants like PLAN_BUDGET_SCOPE_CAP = 8 govern planner behavior. Several documentation files remain outdated regarding the holistic planner changes, and certain coding practices (like using assert for runtime preconditions) have been identified as problematic.
The repository uses a multi-stage Dockerfile with Poetry-managed dependencies (pyproject.toml, poetry.lock). Key directories include src/codespy (source), tests, docs, assets, and Formula. A non-root user 'codespy' with uid 1000 is created in the final Dockerfile stage. The coding agent (review.implement) executes the plan generated by the holistic implementation planner.
Structure and Where Things Live
The implementation planner now operates holistically: a single run processes all scopes and issues, ordering steps by cross-scope dependency then severity.
Steps are grouped by scope with global numbering and explicit 'Depends on' lines.
Each step lists its title, scope, files, the change, how to verify it, the steps it depends on, and the issues it addresses.
File paths in the planner are now repository-root-relative (not scope-relative). Steps include a
scopefield indicating which subroot they affect, andfileslists use repo-root paths.Key files changed in the holistic planner PR: CHANGELOG.md (docs change), action.yml (inputs updated), docs/architecture.md (pipeline diagram updated), docs/configuration.md (planner behavior docs), docs/usage.md (usage docs), src/codespy/agents/review/plan/models.py (Step model with scope/depends_on/number), src/codespy/workflows/review/models.py (markdown rendering with dependencies).
Issues are structured as dictionaries with keys: severity, category, filename, line_start, title, description.
Issue severity levels: high, medium, low; issue categories include smell, documentation.
Key directories in the repository: src/codespy (source), tests, docs, assets, Formula.
Conventions
Steps are grouped by scope with global numbering and explicit Depends on lines (repeated across multiple sources as a key convention).
The print statement in the trajectory outputs issue fields space-separated followed by '|' and the description.
To assess code quality, list all issues with their attributes to orient, then formulate a holistic QA and recommendation based on severity and category distribution.
Boolean flag parameters is_local and is_fork in pipeline.py should be replaced with a review-target object or checked at call site to avoid flag proliferation and improve clarity.
Invariants and Constants
PLAN_BUDGET_SCOPE_CAP = 8: the planner caps the number of scopes considered in budget calculation at 8, regardless of total scopes with issues.
Dependencies and Integrations
The implementation planner now runs once across all scopes, ordering steps by dependency and severity instead of planning per scope in isolation.
Steps are globally numbered, each tied to one scope, with explicit depends_on references for cross-scope dependencies.
Filesystem tool errors are returned as ToolError rather than crashing the agent; filesystem tool errors (missing paths, file vs directory, permission, root-escape) are returned as ToolError to the agent, not as unhandled exceptions that crash the agent.
Filesystem tool errors now return ToolError exceptions (not crashes) for missing paths, file/directory mismatches, permission denied, and path escaping root; real crashes remain unchanged.
Filesystem tool errors (e.g., missing path, permission denied) are now caught by the
_agent_errorsdecorator and re-raised asToolErrorto the agent, preserving error messages without crashing.Poetry lockfile is a TOML-like format wrapped in JSON with a 'content' field, where dependencies are listed under [[package]] sections with name and version fields.
Pitfalls and Recurring Problems
Assert statements are inappropriate for runtime preconditions as they are stripped under -O; plan/agent.py:194 uses assert on review_context.metadata as a runtime precondition; asserts are stripped under -O; should raise ValueError instead.
Assert on review_context.metadata should be replaced with explicit check raising ValueError; asserts are stripped under -O.
filesystem/server.py _EXPECTED_ERRORS includes bare ValueError, which hides genuine server bugs as agent errors; should use a dedicated root-escape exception.
Broad ValueError in _EXPECTED_ERRORS should be narrowed to a dedicated root-escape exception to avoid hiding genuine server bugs as agent errors.
Pre-existing untracked files are incorrectly published as agent changes because collect_changes ignores the
beforesnapshot, allowing leftover cache files to reach the fix PR.Unused
reserveparameter in _build_review_body function; all callers pass 0 after body_suffix removal, making the parameter redundant.Assert is used for runtime precondition in fix_pull_request.py, which is unsafe because asserts are stripped under Python's -O optimization flag.
Code smells identified: assert used as runtime precondition in fix_pull_request.py:46 (same pattern previously accepted in plan/agent.py), unused
reserveparameter in git.py:402, private _planner_scope imported across modules, private fs._resolve_path called from MCP server, is_local/is_fork boolean flags in pipeline.py:612.Cross-module import of private helper function _planner_scope from plan-agent module in review/implement/agent.py, violating encapsulation.
Dockerfile final stage copies root-owned files (lines 42-43), posing a security risk; recommendation is to use --chown flag in COPY commands or adjust ownership after copy.
Dockerfile build stage runs as root (lines 9-23), posing a security risk; recommendation is to add USER instruction or use --chown with COPY commands.
Dockerfile apt-get install commands (lines 9-22) do not pin exact package versions, creating a security risk; recommendation is to pin exact versions for apt-get install packages.
Dockerfile pip install command (line 14) lacks --no-cache-dir optimization, presenting a low security risk; recommendation is to add --no-cache-dir to pip install command.
Facts Shown to Be Wrong (Outdated Documentation)
docs/architecture.md:108 still describes the old per-scope ImplementationPlanSignature and needs updating for the single run over all scopes, repo-root tools, and scope/depends_on step fields.
docs/configuration.md:262 step field list omits scope and Depends on fields.
docs/architecture.md:108 still describes the old per-scope ImplementationPlanSignature and needs updating for the single run over all scopes, repo-root tools, and scope/depends_on step fields.
docs/configuration.md:262 step field list omits scope and Depends on fields.
Around this work
Holistic Implementation Planner in khezen/codespy
Overview
The khezen/codespy codebase has transitioned from per-scope planning to a holistic implementation planner that processes all scopes and issues in a single run. Previously, each scope was planned independently in separate runs, which prevented plans from expressing cross-scope dependencies (e.g., fixing a shared library before its consumers). Now, a single execution sees every scope and every issue, with file tools rooted at the repository root, enabling comprehensive dependency-aware planning.
Key Changes
- Single-run planning: The implementation planner (
review.plan) now operates once across all scopes instead of making isolated plans per scope- Global step numbering: Steps are numbered globally across all scopes
- Explicit dependency tracking: Each step includes a
depends_onfield to express cross-scope dependencies- Repository-root file paths: File paths in plans are now repository-root-relative rather than scope-relative
- Scope indication: Each step includes a
scopefield indicating which subroot it affectsStep Structure
Each implementation step contains:
- title: Description of the change
- scope: Indicates which subroot the step affects
- files: Lists repository-root-relative paths of files to modify
- change: The specific modification to make
- verify: How to verify the change works correctly
- depends_on: Explicit references to steps this step depends on (enabling cross-scope dependencies)
- number: Global step number
- addresses: Issues that this step resolves
Files Changed in the Holistic Planner PR
The following files were modified to implement the holistic planner:
src/codespy/agents/review/plan/__init__.pysrc/codespy/tools/storage/filesystem/protected.pysrc/codespy/__init__.pysrc/codespy/agents/review/implement/agent.pytests/test_implementation_plan.pyREADME.mdaction.ymldocs/memory.mdAdditional documentation files updated in the PR include:
CHANGELOG.md(documentation change)action.yml(inputs updated)docs/architecture.md(pipeline diagram updated)docs/configuration.md(planner behavior documentation)docs/usage.md(usage documentation)src/codespy/agents/review/plan/models.py(Step model with scope/depends_on/number fields)src/codespy/workflows/review/models.py(markdown rendering with dependencies)Issues Structure
Issues processed by the planner are structured as dictionaries with these keys:
severity: Levels include high, medium, lowcategory: Includes smell, documentation, and other typesfilename: Path to file with the issueline_start: Starting line number of the issuetitle: Brief description of the issuedescription: Detailed explanation of the issueTechnical Implementation Details
Filesystem Tool Improvements
The filesystem tool now returns
ToolErrorexceptions instead of crashing the agent when encountering:
- Missing paths
- File vs directory mismatches
- Permission denied errors
- Path escaping root attempts
These errors are caught by the
_agent_errorsdecorator and re-raised asToolErrorto preserve error messages without crashing the agent. Only genuine crashes remain unhandled.Planning Constants
PLAN_BUDGET_SCOPE_CAP = 8: The planner caps the number of scopes considered in budget calculation at 8, regardless of the total number of scopes with issuesAgent Integration
The coding agent (
review.implement) executes the plan generated by the holistic implementation planner, performing the actual code modifications based on the planner's output.Documentation Updates Needed
Several documentation files remain outdated regarding the holistic planner changes:
docs/architecture.mdline 108: Still describes the old per-scopeImplementationPlanSignatureand needs updating for:
- Single run over all scopes
- Repository-root tools
- Scope and
depends_onstep fieldsdocs/configuration.mdline 262: Step field list omits thescopeandDepends onfieldsIdentified Code Quality Issues
Several code smells and potential issues were identified in the codebase:
Assert Statements for Runtime Preconditions
- Using
assertfor runtime preconditions is inappropriate as they are stripped under Python's-Ooptimization flag- Specific instances:
plan/agent.py:194: Assert onreview_context.metadatashould be replaced with explicit check raisingValueErrorfix_pull_request.py:46: Same pattern - assert used as runtime preconditionException Handling Issues
filesystem/server.py _EXPECTED_ERRORSincludes bareValueError, which hides genuine server bugs as agent errors- Should narrow to a dedicated root-escape exception instead of broad
ValueErrorOther Code Smells
- Pre-existing untracked files incorrectly published as agent changes because
collect_changesignores thebeforesnapshot- Unused
reserveparameter ingit.py:402(all callers pass 0 afterbody_suffixremoval)- Private
_planner_scopeimported across modules inreview/implement/agent.py, violating encapsulation- Private
fs._resolve_pathcalled from MCP server- Boolean flag parameters
is_localandis_forkinpipeline.py:612should be replaced with a review-target object or checked at call siteDockerfile Security Concerns
- Dockerfile final stage copies root-owned files (lines 42-43) posing security risk
- Dockerfile build stage runs as root (lines 9-23) posing security risk
- Dockerfile
apt-get installcommands (lines 9-22) lack exact package version pinning- Dockerfile
pip installcommand (line 14) lacks--no-cache-diroptimizationWorkflow Benefits
The holistic approach enables:
- Proper ordering of fixes across scopes (e.g., shared libraries before consumers)
- Global step numbering for clear progression
- Explicit dependency expression between steps
- Repository-root perspective for file operations
- Coordinated planning across the entire repository
This represents a significant improvement over the previous isolated per-scope planning approach, allowing for more sophisticated and accurate implementation planning that respects cross-cutting concerns and dependencies.
Seen before
- [observation] Changes span planner agent, models, workflows, filesystem server, tests, and documentation.
- [observation] Filesystem MCP server now raises ToolError (not logged as crash) for: missing path, file vs directory, permission denied, path escaping root; real crashes (e.g., segfault, OOM) still log tracebacks; agent sees errors like 'Directory not found: deploy' instead of internal tracebacks
- [observation] Non-root user 'codespy' with uid 1000 is created in the final stage of the Dockerfile.
- [2026-11-23 · audit] In plan/agent.py:194, assert is used as a runtime precondition, which is stripped under -O optimization flag. | When: 2026-11-23 | Low severity issue identified during audit; accepted by reviewer but not yet fixed
- [observation] Filesystem tool error handling improved to return ToolError exceptions instead of crashing.
- [2026-11-23 · audit] Holistic implementation planner processes all scopes and issues in a single run with global step numbering, includes review.implement coding agent, improved filesystem error handling returning ToolError exceptions, documentation updates, and version bump to 2.4.4. | When: Monday, November 23, 2026
- [observation] Implementation planner now operates holistically across all scopes in a single run, ordering steps by cross-scope dependency and severity, with global step numbering and per-scope grouping. Filesystem tool errors (missing paths, permissions, etc.) are returned as ToolError instead of crashing the agent.
- [observation] ImplementationPlanSignature row in docs/architecture.md:108 should be updated to reflect one run over all scopes and issues, repo-root tools, with steps carrying scope and depends_on.
- [observation] Repository contains a Dockerfile using multi-stage build and Python dependencies managed by Poetry (pyproject.toml, poetry.lock).
- [observation] Added coding agent (review.implement) that carries out the plan
- [observation] Coding agent (review.implement) added to carry out the implementation plan.
- [observation] Key directories in the repository: src/codespy (source), tests, docs, assets, Formula.
- [2026-11-23 · summary] Includes related documentation and version updates | When: 2026-11-23
- [observation] Cross-module import of private helper function _planner_scope from plan-agent module in review/implement/agent.py, violating encapsulation.
- [observation] Assert on review_context.metadata in src/codespy/agents/review/plan/agent.py:194 should be replaced with explicit ValueError check to avoid being stripped under -O optimization flag.
- [observation] Review pipeline updated to a 6-step flow with Implementation Agent as step 6.
- [observation] Recommendation: Approve pull request with minor changes; fix assert in plan/agent.py and docs field list in docs/configuration.md before merge (both accepted as low-severity).
- [observation] Holistic planner processes all scopes/issues in one run with global step numbering, explicit 'depends_on' (1-based indices), and per-step 'scope' field; post-run, steps are grouped by scope; file paths are repository-root-relative; budget is per-scope settings × scopes with issues (capped at 8).
- [observation] Documentation is stale: architecture.md still describes 5-step flow (now 6), README describes per-scope plan and omits Implementation Agent, memory.md lacks the implement agent.
- [observation] Implementation Agent added to pipeline flow in memory docs as read-only with no episode.
- [observation] filesystem/server.py _EXPECTED_ERRORS includes bare ValueError, which hides genuine server bugs as agent errors; should use a dedicated root-escape exception.
- [observation] Code smells identified: assert used as runtime precondition in fix_pull_request.py:46 (same pattern previously accepted in plan/agent.py), unused
reserveparameter in git.py:402, private _planner_scope imported across modules, private fs._resolve_path called from MCP server, is_local/is_fork boolean flags in pipeline.py:612.- [observation] Implementation Agent added to run-level load list and recall_memory tool list in memory docs.
- [observation] Dockerfile hardening issues: root user in build stage, root-owned COPY in final stage without --chown, unpinned apt packages, pip install without --no-cache-dir; assessed as low risk and likely outside PR intent. Additionally, Dockerfile build stage runs as root (lines 9-23), posing a security risk; recommendation is to add USER instruction or use --chown with COPY commands. Dockerfile apt-get install commands (lines 9-22) do not pin exact package versions, creating a security risk; recommendation is to pin exact versions for apt-get install packages.
- [observation] Bare ValueError in src/codespy/tools/storage/filesystem/server.py:22-23 should be narrowed to a dedicated PathEscapesRootError exception to avoid masking server bugs as agent errors.
- [observation] Private FileSystem method _resolve_path is called from MCP server in filesystem/server.py, which should be replaced with a public resolve method for proper encapsulation.
- [observation] In docs/configuration.md:262, the Step field list omits scope and depends_on fields.
- [observation] Improved filesystem tool error handling to return ToolError exceptions instead of crashing
- [observation] The holistic planner's budget caps at ×8: max_iters and max_llm_calls are multiplied by the number of scopes with issues, but never exceed 8× the per-scope setting.
- [2026-11-23 · doc] Holistic implementation planner processes all scopes and issues in a single run with cross-scope dependency-aware planning and global step numbering. | When: 2026-11-23 | Enables comprehensive planning across all scopes in one execution.
- [observation] Audit found 3 low-severity findings: (1) plan/agent.py:194 uses assert as runtime precondition (stripped under -O; should raise ValueError), (2) filesystem/server.py:22-23 has bare ValueError in _EXPECTED_ERRORS turning server bugs into agent-facing errors (should use PathEscapesRootError subclass), (3) docs/configuration.md:262 omits global number, scope, and depends_on from step field list.
- [observation] Opt-in Implementation Agent feature added to README with link to docs/configuration.md#implementation-agent.
- [2026-11-23 · audit] In docs/architecture.md:108, ImplementationPlanSignature row still describes per-scope planning, which is outdated due to holistic implementation. | When: 2026-11-23 | Medium severity issue identified during audit
Decisions
- [2026-11-23 · summary] Added coding agent (review.implement) that carries out the plan | When: 2026-11-23
- [observation] Steps are grouped by scope with global numbering and explicit Depends on lines.
- [observation] Issue severity levels: high, medium, low; issue categories include smell, documentation.
- [observation] Includes related documentation and version updates
- [observation] Issues are structured as dictionaries with keys: severity, category, filename, line_start, title, description.
- [2026-11-23 · doc] Each step should list its global number, title, scope, files, the change, how to verify it, the steps it depends on, and the issues it addresses. | When: 2026-11-23
- [observation] README documentation updated to describe one cross-scope plan (Goal/Decisions/Tasks/Risks/Validation) grouped per scope.
- [observation] Assert used for runtime precondition in review agent code should be replaced with explicit ValueError check | When: 2026-11-23 | Asserts are stripped under -O optimization flag, making runtime checks unreliable
- [2026-11-23 · audit] Audit found 3 low-severity findings: (1) plan/agent.py:194 uses assert as runtime precondition (stripped under -O; should raise ValueError), (2) filesystem/server.py:22-23 has bare ValueError in _EXPECTED_ERRORS turning server bugs into agent-facing errors (should use PathEscapesRootError subclass), (3) docs/configuration.md:262 omits global number, scope, and depends_on from step field list. | When: 2026-11-23
- [observation] PlanStep files are repository-root-relative paths; each step's 'scope' field indicates the affected subroot (e.g., 'src', 'docs'); paths are normalized: leading './' stripped, empty/'.' treated as repo root.
- [observation] Dockerfile final stage copies root-owned files (lines 42-43), posing a security risk; recommendation is to use --chown flag in COPY commands or adjust ownership after copy
Recurring patterns
- [observation] Pre-existing untracked files are incorrectly published as agent changes because collect_changes ignores the
beforesnapshot, allowing leftover cache files to reach the fix PR- [observation] To assess code quality, list all issues with their attributes to orient, then formulate a holistic QA and recommendation based on severity and category distribution.
- [observation] Recommendation: REQUEST CHANGES. Fix untracked-file leak by passing untracked_before to collect_changes and skipping '??' entries present before run. Update stale docs (architecture step count, README, memory.md) in same PR. Address smells and Dockerfile hardening in follow-ups.
- [observation] High severity bug in implement/agent.py lines 121-150: collect_changes ignores the
beforesnapshot, causing pre-existing untracked files (e.g. caches) to be published in the fix PR.- [observation] Misplaced comment and vague variable name in review workflow models reduce code clarity
- [observation] Holistic implementation planner processes all scopes and issues in a single run with cross-scope dependency-aware planning and global step numbering
- [observation] When verifying documentation updates, the agent checked for planner-related keywords (plan, per scope, subroot, max_concurrent, scope-relative, ToolError) in specific files to detect stale references.
- [observation] Assert on review_context.metadata should be replaced with explicit check raising ValueError; asserts are stripped under -O.
- [observation] The print statement in the trajectory outputs issue fields space-separated followed by '|' and the description.
- [observation] Boolean flag parameters is_local and is_fork in pipeline.py should be replaced with a review-target object or checked at call site to avoid flag proliferation and improve clarity
- [observation] Assert is used for runtime precondition in fix_pull_request.py, which is unsafe because asserts are stripped under Python's -O optimization flag
What changed
- Changes span planner agent, models, workflows, filesystem server, tests, and documentation. (was: Changes span planner agent, models, workflows, filesystem server, tests, and documentation., changed 2026-11-23)
- Filesystem MCP server now raises ToolError (not logged as crash) for: missing path, file vs directory, permission denied, path escaping root; real crashes (e.g., segfault, OOM) still log tracebacks; agent sees errors like 'Directory not found: deploy' instead of internal tracebacks (was: Filesystem tool errors are returned as ToolError rather than crashing the agent; filesystem tool errors (missing paths, file vs directory, permission, root-escape) are returned as ToolError to the agent, not as unhandled exceptions that crash the agent; filesystem tool errors now return ToolError exceptions (not crashes) for missing paths, file/directory mismatches, permission denied, and path escaping root; real crashes remain unchanged., changed 2026-11-23)
📋 Summary
The implementation planner now creates one holistic plan for the entire review instead of isolated per-scope plans, enabling cross-scope dependency ordering and global step numbering. A new implementation agent carries out the plan using write-enabled filesystem tools, and filesystem errors are returned as ToolError exceptions instead of crashing the agent.
🎯 Quality Assessment
Solid. Holistic planner adds cross-scope dependency ordering and global step numbering. Filesystem errors map to ToolError; only invalid paths are mapped, and missing metadata still raises. Implementer skips dirty clones. Earlier accepted findings (assert precondition, step field docs) addressed in a1d7fd8. No bugs or security issues found. Remaining: (1) medium smell: is_local/is_fork boolean flags in _run_implementer (pipeline.py:612-638); (2) low doc: docs/development.md source tree omits agents/review/implement. Note: breaking JSON change (implementation_plan is now an object or null) shipped as patch bump 2.4.4.
📊 Statistics
| Severity | Security | Bugs | Documentation | Smells | SEO | Total |
|---|---|---|---|---|---|---|
| Critical | 0 | 0 | 0 | 0 | 0 | 0 |
| High | 0 | 0 | 0 | 0 | 0 | 0 |
| Medium | 0 | 0 | 0 | 1 | 0 | 1 |
| Low | 0 | 0 | 1 | 0 | 0 | 1 |
| Info | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 1 | 1 | 0 | 2 |
💰 Cost Summary
Total: $2.7936 | LLM Calls: 132
- Memory: pending (retain, consolidation, mental models)
Review
| Signature | In Tokens | Out Tokens | In Cost | Out Cost | Calls | Duration |
|---|---|---|---|---|---|---|
| doc | 339,360 | 4,276 | $1.2145 | $0.0855 | 13 | 89.4s |
| code_review | 284,593 | 3,975 | $0.8641 | $0.0795 | 12 | 79.0s |
| supply_chain | 1,724,339 | 56,594 | $0.2567 | $0.0307 | 75 | 424.6s |
| plan | 63,034 | 2,542 | $0.1606 | $0.0508 | 6 | 38.2s |
| audit | 7,965 | 637 | $0.0274 | $0.0127 | 2 | 11.1s |
| summary | 42,257 | 2,597 | $0.0061 | $0.0012 | 16 | 26.9s |
Subtotal: $2.7898 | LLM Calls: 124
Memory
| Signature | In Tokens | Out Tokens | In Cost | Out Cost | Calls | Duration |
|---|---|---|---|---|---|---|
| memory_recall | 17,884 | 1,622 | $0.0027 | $0.0011 | 3 | 9.6s |
| memory_recall_embeddings | 285 | 0 | $0.0000 | $0.0000 | 5 | 1.4s |
Subtotal: $0.0038 | LLM Calls: 8
⚠️ Issues without line reference or could not post inline
🔵 [Low] Source tree omits implementation agent
File: docs/development.md:72
Category: documentation | Confidence: 60%
Add the new implementation agent (agents/review/implement) to the development.md source tree; the pipeline stages list ends at planner.
Suggestion:
Append 'implementer' to the modules list, or add an agents/review/implement entry.
💡 Recommendation
Approve. Non-blocking: replace the boolean flags with a review-target object or gate the call at the call site; add the implement agent to the development.md tree; consider a minor version bump for the breaking JSON change.
🛠️ Implementation Plan (2 steps)
Goal
_run_implementer no longer takes is_local/is_fork boolean flags; the caller in review() decides whether local or fork reviews skip the implementer. docs/development.md lists the implement agent in the source tree.
Decisions
- Check local/fork at the call site (pipeline.py:531), not in a review-target object. is_local comes from the config type (line 399) and is_fork from the PR, so no single existing object holds both.
- Keep the skip log messages, but emit them from the caller, so operators still see why the implementer did not run.
- Make the doc fix only add the implement agent; do not restructure the rest of the tree in this change.
Tasks
1. Check local/fork before calling _run_implementer
Files:
src/codespy/workflows/review/pipeline.py,tests/test_implementer.pyRemove the is_local and is_fork parameters and their checks from _run_implementer. At line 531, skip the call when is_local or pr.is_fork, logging the same info/warning messages and leaving implementation_result as None. Update the docstring.
Verify: Remove the local/fork cases from test_skips. Change the calls at test_implementer.py:370 and :381 to the new signature. Add a review()-level test that the implementer is not called for a local config or for pr.is_fork=True. Run pytest tests/test_implementer.py.
Addresses: Boolean flag parameters in _run_implementer
2. Add implement agent to development.md tree
Files:
docs/development.mdIn the docs/development.md source tree (line 71), add 'implementer' to the pipeline stages list after planner, or add an agents/review/implement entry, matching src/codespy/agents/review/implement/.
Verify: Check that the tree shows the implement agent and that it exists at src/codespy/agents/review/implement/.
Addresses: Source tree omits implementation agent
Risks
- The local/fork skip tests are written against _run_implementer. Moving the checks to review() needs a test of the call site, or that coverage is silently lost.
- The docs tree is already stale: it shows agents/reviewer/ and modules/, but the code is agents/review//. An entry added in the old style stays inaccurate.
- _run_implementer must keep its other guards: implement enabled, plan enabled, and plan is not None.
Validation
- Run pytest across the whole suite.
- Run a local review with review.implement and review.plan enabled. Check the log says 'Skipping implement: local reviews edit nothing' and the implementer is not called.
- Run the fork-PR path. Check the fork skip warning is logged and the JSON has implementation null.
- grep for is_fork and is_local in pipeline.py and check that _run_implementer no longer references them.
| def _run_implementer( | ||
| self, | ||
| scopes: list[ScopeResult], | ||
| issues: list[Issue], | ||
| review_ctx: ReviewContext, | ||
| plan: ImplementationPlan | None, | ||
| is_local: bool, | ||
| is_fork: bool, | ||
| ) -> ImplementationResult | None: | ||
| """Run the opt-in implementation agent. Never raises: a failure yields none. | ||
|
|
||
| Skipped when disabled, without a plan, for local reviews (the user's | ||
| working tree) and for fork PRs (no branch can be pushed next to the head). | ||
| """ | ||
| if not self.settings.is_signature_enabled("implement"): | ||
| return None | ||
| if not self.settings.is_signature_enabled("plan"): | ||
| logger.warning("review.implement needs review.plan.enabled; skipping implement") | ||
| return None | ||
| if plan is None: | ||
| return None | ||
| if is_local: | ||
| logger.info("Skipping implement: local reviews edit nothing") | ||
| return None | ||
| if is_fork: | ||
| logger.warning("Skipping implement: fork PR (codespy cannot push next to its head)") | ||
| return None |
There was a problem hiding this comment.
🟡 [Medium] Boolean flag parameters in _run_implementer
Category: smell | Confidence: 85%
Replace is_local/is_fork boolean flags with a review-target object, or check them at the call site.
💡 Suggestion
Pass the PR/review target, or gate the call in the caller at line 532.
What
The implementation planner (
review.plan) now makes one plan for the whole review instead of one isolated plan per scope.Before, each scope was planned in its own run, so a plan could not say that a fix in one scope needs a change in another scope first (e.g. a shared library before its consumers). Now one run sees every scope and every issue, with file tools rooted at the repo root, and orders steps by dependency across scopes, then severity.
The output is still detailed per scope:
depends_on.number,scopeanddepends_on.implementation_plankeeps its[{subroot, steps}]shape.Budget
review.plan.max_iters/max_llm_callsstay per scope (defaults 5 / 16). The single run gets them multiplied by the number of scopes with issues, at most ×8. Example: 3 scopes with issues gives 15 iterations / 48 LLM calls.review.max_concurrent_scopesno longer applies to the planner.Behaviour change
A planner failure now drops the whole plan; the review is still posted. Before, only the scope that failed was left out.
Tests
tests/test_implementation_plan.pypasses (33 tests): it covers the scope check, numbering and grouping, dependency cleanup, the budget, the single run (one call, repo-rooted tools, inputs not mutated, cleanup on failure) and rendering.test_cerebral*,test_config*,test_doc_extractor,test_review_memories,test_review_statistics).Docs (
configuration.md,usage.md,architecture.md),action.ymlinput descriptions and the CHANGELOG ([Unreleased], no version bump) are updated.Also: filesystem tool errors reach the agent
With mcp 2.2, a tool that raises anything other than
ToolErroris treated as a crash. It's logged at ERROR with a full traceback, and the agent only getsError executing tool list_directory. An agent probingdeploy/orinfra/in a scope without them filled the log with tracebacks and couldn't tell a missing folder from a broken tool.The filesystem MCP server now raises these failures as
ToolError, keeping their message: missing path, file vs directory, permission denied, path escaping the root. The agent getsDirectory not found: deployand nothing is logged as a crash. Real crashes are unchanged. Covered bytests/test_filesystem_server.py(6 tests).