UAT: CorrectionService.analyze_impact() returns synthetic placeholder file/artifact paths — real resource tracking not implemented #3752

Open
opened 2026-04-05 22:28:33 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/correction-service-real-artifact-tracking
  • Commit Message: fix(services): replace synthetic placeholder paths in CorrectionService.analyze_impact() with real file/artifact tracking
  • Milestone: (none — backlog)
  • Parent Epic: #394

Background

CorrectionService.analyze_impact() in src/cleveragents/application/services/correction_service.py populates affected_files and artifacts_to_archive with synthetic placeholder paths derived from decision IDs rather than real file/artifact data. The code itself contains a TODO comment acknowledging this:

# TODO: affected_files and artifacts_to_archive use synthetic
# placeholders derived from decision IDs.  Replace with real
# file / artifact tracking once the resource-rollback layer
# is integrated (see spec § Mid-Execute Correction).
affected_files=[f"{d}.py" for d in affected],
...
artifacts_to_archive=artifacts,  # where artifacts = [f"{d}.artifact" for d in affected]

This means the CorrectionImpact returned by analyze_impact() contains fabricated file paths like "01HXYZ123.py" and artifact paths like "01HXYZ123.artifact" — paths that do not correspond to any real files in the workspace. Callers (including the CLI agents plan correct --dry-run) will display these fabricated paths to users, which is misleading and incorrect.

Affected File

  • src/cleveragents/application/services/correction_service.py

Code Location

CorrectionService.analyze_impact() (lines ~200-260):

impact = CorrectionImpact(
    affected_decisions=affected,
    excluded_decisions=excluded,
    # TODO: affected_files and artifacts_to_archive use synthetic
    # placeholders derived from decision IDs.  Replace with real
    # file / artifact tracking once the resource-rollback layer
    # is integrated (see spec § Mid-Execute Correction).
    affected_files=[f"{d}.py" for d in affected],
    affected_child_plans=[],
    estimated_cost=float(len(affected)) * _COST_PER_DECISION,
    risk_level=risk,
    rollback_tier="full"
    if request.mode == CorrectionMode.REVERT
    else "append_only",
    rollback_tier_depth=tier_depth,
    artifacts_to_archive=artifacts,  # [f"{d}.artifact" for d in affected]
)

Steps to Reproduce

  1. Create a CorrectionService and record some decisions
  2. Call service.analyze_impact(correction_id, decision_tree={"d1": ["d2", "d3"]})
  3. Inspect impact.affected_files — contains ["d1.py", "d2.py", "d3.py"] (fabricated)
  4. Inspect impact.artifacts_to_archive — contains ["d1.artifact", "d2.artifact", "d3.artifact"] (fabricated)

Expected Behaviour

affected_files should contain the actual workspace file paths that were modified by the affected decisions (derived from ArtifactRef entries in each Decision.artifacts_produced).

artifacts_to_archive should contain the actual artifact paths from Decision.artifacts_produced for all affected decisions.

Actual Behaviour

Both fields contain fabricated paths derived from decision IDs (e.g., "01HXYZ123.py", "01HXYZ123.artifact"). These paths do not exist in the workspace and mislead users and downstream consumers.

Subtasks

  • Implement real file/artifact tracking in analyze_impact() by extracting artifact_path values from Decision.artifacts_produced for all affected decisions
  • Pass the decisions mapping (decision_id → Decision) to analyze_impact() so it can look up actual artifact paths
  • Update the CorrectionService.analyze_impact() signature to accept an optional decisions parameter
  • Update callers of analyze_impact() to pass the decisions mapping
  • Add Behave scenario verifying that affected_files contains real artifact paths from decision records
  • Verify nox -e unit_tests passes

Definition of Done

  • analyze_impact() returns real file/artifact paths from Decision.artifacts_produced
  • Synthetic placeholder generation is removed
  • Behave test verifies real artifact path extraction
  • nox -e unit_tests passes
  • PR merged

Backlog note: This issue was discovered during autonomous operation
on milestone . It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/correction-service-real-artifact-tracking` - **Commit Message**: `fix(services): replace synthetic placeholder paths in CorrectionService.analyze_impact() with real file/artifact tracking` - **Milestone**: *(none — backlog)* - **Parent Epic**: #394 ## Background `CorrectionService.analyze_impact()` in `src/cleveragents/application/services/correction_service.py` populates `affected_files` and `artifacts_to_archive` with **synthetic placeholder paths** derived from decision IDs rather than real file/artifact data. The code itself contains a TODO comment acknowledging this: ```python # TODO: affected_files and artifacts_to_archive use synthetic # placeholders derived from decision IDs. Replace with real # file / artifact tracking once the resource-rollback layer # is integrated (see spec § Mid-Execute Correction). affected_files=[f"{d}.py" for d in affected], ... artifacts_to_archive=artifacts, # where artifacts = [f"{d}.artifact" for d in affected] ``` This means the `CorrectionImpact` returned by `analyze_impact()` contains fabricated file paths like `"01HXYZ123.py"` and artifact paths like `"01HXYZ123.artifact"` — paths that do not correspond to any real files in the workspace. Callers (including the CLI `agents plan correct --dry-run`) will display these fabricated paths to users, which is misleading and incorrect. ## Affected File - `src/cleveragents/application/services/correction_service.py` ## Code Location `CorrectionService.analyze_impact()` (lines ~200-260): ```python impact = CorrectionImpact( affected_decisions=affected, excluded_decisions=excluded, # TODO: affected_files and artifacts_to_archive use synthetic # placeholders derived from decision IDs. Replace with real # file / artifact tracking once the resource-rollback layer # is integrated (see spec § Mid-Execute Correction). affected_files=[f"{d}.py" for d in affected], affected_child_plans=[], estimated_cost=float(len(affected)) * _COST_PER_DECISION, risk_level=risk, rollback_tier="full" if request.mode == CorrectionMode.REVERT else "append_only", rollback_tier_depth=tier_depth, artifacts_to_archive=artifacts, # [f"{d}.artifact" for d in affected] ) ``` ## Steps to Reproduce 1. Create a `CorrectionService` and record some decisions 2. Call `service.analyze_impact(correction_id, decision_tree={"d1": ["d2", "d3"]})` 3. Inspect `impact.affected_files` — contains `["d1.py", "d2.py", "d3.py"]` (fabricated) 4. Inspect `impact.artifacts_to_archive` — contains `["d1.artifact", "d2.artifact", "d3.artifact"]` (fabricated) ## Expected Behaviour `affected_files` should contain the actual workspace file paths that were modified by the affected decisions (derived from `ArtifactRef` entries in each `Decision.artifacts_produced`). `artifacts_to_archive` should contain the actual artifact paths from `Decision.artifacts_produced` for all affected decisions. ## Actual Behaviour Both fields contain fabricated paths derived from decision IDs (e.g., `"01HXYZ123.py"`, `"01HXYZ123.artifact"`). These paths do not exist in the workspace and mislead users and downstream consumers. ## Subtasks - [ ] Implement real file/artifact tracking in `analyze_impact()` by extracting `artifact_path` values from `Decision.artifacts_produced` for all affected decisions - [ ] Pass the `decisions` mapping (decision_id → Decision) to `analyze_impact()` so it can look up actual artifact paths - [ ] Update the `CorrectionService.analyze_impact()` signature to accept an optional `decisions` parameter - [ ] Update callers of `analyze_impact()` to pass the decisions mapping - [ ] Add Behave scenario verifying that `affected_files` contains real artifact paths from decision records - [ ] Verify `nox -e unit_tests` passes ## Definition of Done - `analyze_impact()` returns real file/artifact paths from `Decision.artifacts_produced` - Synthetic placeholder generation is removed - Behave test verifies real artifact path extraction - `nox -e unit_tests` passes - PR merged > **Backlog note:** This issue was discovered during autonomous operation > on milestone <M>. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
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.

Blocks
#394 Epic: Decision Framework
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3752
No description provided.