Skip to content

Apply hardening: artifact-contamination guard #401

Description

@jamesrochabrun

Parent: #398

Goal

Reject pending edit previews when replacement content appears contaminated by repeated tool-call echoes or apply markers before the user can approve corrupted output.

Implementation Notes

Target area: PendingChangesPreviewService and its new apply utility layer from the fuzzy apply issue.

Add a pure artifact guard that scans replacement/preview text for known hallucinated tool markers, using thresholds to avoid false positives in legitimate source files.

Candidate markers:

  • to=functions
  • functions.
  • <|tool|>
  • repeated tool_use
  • repeated apply_edits
  • repeated JSON snippets like "name":"Edit" or "name":"MultiEdit"

Use hard rejection for very strong markers and repeated-marker thresholds for weaker markers. Return a clear rejected outcome with offending markers.

Acceptance Criteria

  • Replacement content with repeated tool-call echoes is rejected before preview approval.
  • A single legitimate mention of a marker string in source code is not rejected.
  • Rejected edits include enough reason text for the UI to display what was detected.
  • Nothing is written or accepted when an edit is rejected.

Tests

Add focused tests in PendingChangesPreviewServiceTests or a new pure utility test suite for marker thresholds and false-positive cases.

Run the targeted AgentHubCore test for the affected suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions