fix(decomposition): address review feedback for PR #9437
CI / push-validation (pull_request) Successful in 34s
CI / helm (pull_request) Successful in 36s
CI / lint (pull_request) Successful in 3m55s
CI / typecheck (pull_request) Successful in 4m35s
CI / security (pull_request) Successful in 4m43s
CI / build (pull_request) Successful in 3m57s
CI / quality (pull_request) Successful in 4m26s
CI / e2e_tests (pull_request) Successful in 8m57s
CI / integration_tests (pull_request) Successful in 10m49s
CI / unit_tests (pull_request) Successful in 11m56s
CI / docker (pull_request) Failing after 46s
CI / coverage (pull_request) Successful in 14m47s
CI / status-check (pull_request) Failing after 3s

- Remove committed test_reports/ CI artifacts (summary.txt, test_results.json)
- Add test_reports/ to .gitignore to prevent future commits
- Update CHANGELOG.md with Fixed entry for #9401 under [Unreleased]
- Update CONTRIBUTORS.md with credit for directory clustering fix (#9401)
- Add BDD test scenarios for absolute path clustering in
  features/large_project_decomposition.feature:
  * Directory clustering works correctly with absolute file paths
  * _directory_key returns correct key for absolute path with root
  * Directory clustering does not collapse all absolute paths into one bucket
- Add corresponding step implementations in
  features/steps/large_project_decomposition_coverage_steps.py

All 38 scenarios pass (including 3 new absolute path scenarios).
Lint and typecheck pass.

ISSUES CLOSED: #9401
This commit is contained in:
2026-04-16 07:43:02 +00:00
committed by Forgejo
parent 81a584b999
commit e261ea5abe
7 changed files with 85 additions and 78 deletions
+3
View File
@@ -180,3 +180,6 @@ output.xml
report.html
.agent-orchestration
agents-test
# Generated test reports (CI artifacts)
test_reports/
+1
View File
@@ -45,6 +45,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
failure output significantly easier to spot in CI and local runs. A worker
crash (unhandled exception) is detected via an all-zero summary and the
captured traceback is always surfaced.
- **Directory Clustering Absolute Path Fix** (#9401): Fixed `DecompositionService._directory_key` to correctly handle absolute file paths by computing relative paths before extracting directory keys. Previously, the function used a fixed depth of 2 path components, causing all absolute paths to collapse into a single bucket (e.g., `/home` for every file on the system), making directory-based clustering completely ineffective. The fix adds an optional `root` parameter to `_directory_key()` and `ClusteringStrategy.cluster_by_directory()`, and updates `DecompositionService._build_hierarchy()` to compute the common root and pass it through, ensuring directory clustering groups paths by their actual directory hierarchy in production use.
- **Automation Profile Silent Fallback** (#8232): `_resolve_profile_for_plan` in
`PlanLifecycleService` now raises a clear `ValidationError` when a plan's
+2 -1
View File
@@ -7,7 +7,6 @@
* Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
* Luis Mendes <luis.p.mendes@gmail.com>
* Rui Hu <rui.hu@cleverthis.com>
* HAL 9000 <hal9000@cleverthis.com>
# Details
@@ -22,4 +21,6 @@ Below are some of the specific details of various contributions.
* Rui Hu has contributed the v3 actor YAML schema validation fix (#5869): added `ActorConfigSchema` validation to the `agents actor add --config` CLI command, covering cycle detection, required field validation, and enum validation for v3 YAML actor definitions.
* HAL 9000 has contributed automated bug fixes, including fix #7488 (store sandbox_path in checkpoint metadata to enable rollback).
* This project was made possible thanks to considerable donation of time, money, and resources by CleverThis, Inc.
* HAL 9000 has contributed the directory clustering absolute path fix (#9401): updated `_directory_key()` to accept an optional `root` parameter for relative path computation, enabling effective directory-based clustering for projects with absolute file paths.
* HAL 9000 has contributed automated bug fixes, CLI output formatting improvements, and ongoing maintenance as part of the CleverAgents automation system.
* This project was made possible thanks to considerable donation of time, money, and resources by CleverThis, Inc.
@@ -232,3 +232,19 @@ Feature: Large-project hierarchical decomposition
Scenario: Directory key handles short paths
When I compute directory key for a single-component path
Then the directory key should be empty string
# --- absolute path clustering ------------------------------------------
Scenario: Directory clustering works correctly with absolute file paths
Given a project with absolute paths in distinct subdirectories
When I decompose with directory clustering
Then at least two clusters should have different directory prefixes
Scenario: _directory_key returns correct key for absolute path with root
When I compute directory key for an absolute path with a root
Then the directory key should reflect the relative path structure
Scenario: Directory clustering does not collapse all absolute paths into one bucket
Given a project with absolute paths spanning multiple top-level directories
When I decompose with max_files_per_subplan 50
Then the decomposition result should have max_depth_reached >= 1
@@ -240,3 +240,66 @@ def step_when_dir_key_short(context: Any) -> None:
@then("the directory key should be empty string")
def step_then_dir_key_empty(context: Any) -> None:
assert context.dir_key == ""
# ---------------------------------------------------------------------------
# absolute path clustering scenarios
# ---------------------------------------------------------------------------
@given("a project with absolute paths in distinct subdirectories")
def step_given_abs_path_project(context):
import os
import tempfile
tmpdir = tempfile.mkdtemp(prefix="decompose-abs-")
context.tmpdir = tmpdir
paths = []
for sub in ("src/api", "src/web"):
dirpath = os.path.join(tmpdir, sub)
os.makedirs(dirpath, exist_ok=True)
for i in range(50):
fpath = os.path.join(dirpath, f"f_{i:03d}.py")
with open(fpath, "w") as fh:
fh.write("x" * 200)
paths.append(fpath)
context.files = sorted(paths)
@given("a project with absolute paths spanning multiple top-level directories")
def step_given_abs_path_multi_top(context):
import os
import tempfile
tmpdir = tempfile.mkdtemp(prefix="decompose-multi-")
context.tmpdir = tmpdir
paths = []
for top in ("alpha", "beta", "gamma", "delta"):
for sub in ("core", "utils"):
dirpath = os.path.join(tmpdir, top, sub)
os.makedirs(dirpath, exist_ok=True)
for i in range(30):
fpath = os.path.join(dirpath, f"f_{i:03d}.py")
with open(fpath, "w") as fh:
fh.write("x" * 200)
paths.append(fpath)
context.files = sorted(paths)
@when("I compute directory key for an absolute path with a root")
def step_when_dir_key_abs_with_root(context):
from cleveragents.application.services.decomposition_clustering import (
_directory_key,
)
root = "/home/user/project"
path = "/home/user/project/src/api/handler.py"
context.dir_key = _directory_key(path, depth=2, root=root)
context.expected_dir_key = "src/api"
@then("the directory key should reflect the relative path structure")
def step_then_dir_key_relative(context):
assert context.dir_key == context.expected_dir_key, (
f"expected {context.expected_dir_key!r}, got {context.dir_key!r}"
)
-27
View File
@@ -1,27 +0,0 @@
Test Framework: generic
Total Tests: 3
Passed: 1
Failed: 2
--- Test Results ---
✗ Output Block 1
✓ nox > Running session typecheck
✗ Error Output
--- Failed Tests ---
✗ Output Block 1
/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py
/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:529:18 - warning: Import "langchain_groq" could not be resolved from source (reportMissingModuleSource)
/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:537:18 - warning: Import "langchain_together" could not be resolved from source (reportMissingModuleSource)
/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:545:18 - warning: Import "langchain_cohere" could not be resolved from source (reportMissingModuleSource)
0 errors, 3 warnings, 0 informations
✗ Error Output
nox > Running session typecheck
nox > Creating virtual environment (uv) using python3.13 in .nox/typecheck
nox > uv pip install pyright
nox > uv pip install -e .
nox > pyright
nox > Session typecheck was successful in 35 seconds.
-50
View File
@@ -1,50 +0,0 @@
{
"framework": "generic",
"tests": [
{
"name": "Output Block 1",
"passed": false,
"output": [
"/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py",
" /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:529:18 - warning: Import \"langchain_groq\" could not be resolved from source (reportMissingModuleSource)",
" /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:537:18 - warning: Import \"langchain_together\" could not be resolved from source (reportMissingModuleSource)",
" /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:545:18 - warning: Import \"langchain_cohere\" could not be resolved from source (reportMissingModuleSource)",
"0 errors, 3 warnings, 0 informations"
],
"rawOutput": "/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py\n /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:529:18 - warning: Import \"langchain_groq\" could not be resolved from source (reportMissingModuleSource)\n /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:537:18 - warning: Import \"langchain_together\" could not be resolved from source (reportMissingModuleSource)\n /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:545:18 - warning: Import \"langchain_cohere\" could not be resolved from source (reportMissingModuleSource)\n0 errors, 3 warnings, 0 informations"
},
{
"name": "nox > Running session typecheck",
"passed": true,
"output": [
"nox > Running session typecheck",
"nox > Creating virtual environment (uv) using python3.13 in .nox/typecheck",
"nox > uv pip install pyright",
"nox > uv pip install -e .",
"nox > pyright ",
"nox > Session typecheck was successful in 35 seconds."
],
"rawOutput": "nox > Running session typecheck\nnox > Creating virtual environment (uv) using python3.13 in .nox/typecheck\nnox > uv pip install pyright\nnox > uv pip install -e .\nnox > pyright \nnox > Session typecheck was successful in 35 seconds."
},
{
"name": "Error Output",
"passed": false,
"output": [
"nox > Running session typecheck",
"nox > Creating virtual environment (uv) using python3.13 in .nox/typecheck",
"nox > uv pip install pyright",
"nox > uv pip install -e .",
"nox > pyright ",
"nox > Session typecheck was successful in 35 seconds.",
""
],
"rawOutput": "nox > Running session typecheck\nnox > Creating virtual environment (uv) using python3.13 in .nox/typecheck\nnox > uv pip install pyright\nnox > uv pip install -e .\nnox > pyright \nnox > Session typecheck was successful in 35 seconds.\n"
}
],
"summary": {
"total": 3,
"passed": 1,
"failed": 2
},
"rawOutput": "/tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py\n /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:529:18 - warning: Import \"langchain_groq\" could not be resolved from source (reportMissingModuleSource)\n /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:537:18 - warning: Import \"langchain_together\" could not be resolved from source (reportMissingModuleSource)\n /tmp/gpt5codex-isolator-20260414-0023456789/repo/src/cleveragents/providers/registry.py:545:18 - warning: Import \"langchain_cohere\" could not be resolved from source (reportMissingModuleSource)\n0 errors, 3 warnings, 0 informations\n\nnox > Running session typecheck\nnox > Creating virtual environment (uv) using python3.13 in .nox/typecheck\nnox > uv pip install pyright\nnox > uv pip install -e .\nnox > pyright \nnox > Session typecheck was successful in 35 seconds."
}