fix(data-integrity): remove silent argument swap in ValidationAttachmentRepository.attach #11220

Closed
HAL9000 wants to merge 2 commits from fix/arg-swap-validation-attachment-8177 into master
Owner

Summary

Fixes a critical data integrity bug in ValidationAttachmentRepository.attach() where validation_name and resource_id were being silently swapped based on a fragile heuristic ("/" in resource_id). This caused silent data corruption when resource IDs contained slashes.

Changes

  • Removed the 3-line conditional swap block from ValidationAttachmentRepository.attach()
  • Updated existing regression test to verify preservation instead of swapping
  • Added comprehensive BDD test suite (11 scenarios) covering all boundary conditions: slash-containing IDs, namespacing, optional parameters, and duplicate rejection

Linked Issues

**Summary** Fixes a critical data integrity bug in `ValidationAttachmentRepository.attach()` where `validation_name` and `resource_id` were being silently swapped based on a fragile heuristic (`"/" in resource_id`). This caused silent data corruption when resource IDs contained slashes. **Changes** - Removed the 3-line conditional swap block from `ValidationAttachmentRepository.attach()` - Updated existing regression test to verify preservation instead of swapping - Added comprehensive BDD test suite (11 scenarios) covering all boundary conditions: slash-containing IDs, namespacing, optional parameters, and duplicate rejection **Linked Issues** - Closes #8177 - Closes #7492
fix(data-integrity): remove silent argument swap in ValidationAttachmentRepository.attach
Some checks failed
CI / push-validation (pull_request) Successful in 31s
CI / helm (pull_request) Successful in 55s
CI / build (pull_request) Successful in 1m12s
CI / lint (pull_request) Failing after 1m25s
CI / typecheck (pull_request) Successful in 1m46s
CI / quality (pull_request) Successful in 1m37s
CI / security (pull_request) Successful in 2m23s
CI / integration_tests (pull_request) Successful in 4m42s
CI / unit_tests (pull_request) Failing after 5m4s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
a624731cbe
Fixes a critical data integrity bug where validation_name and resource_id
arguments were being silently swapped based on a fragile heuristic when
resource_id contained '/'. This caused silent data corruption without any
error being raised.

The 3-line conditional swap block has been removed from
ValidationAttachmentRepository.attach(), ensuring arguments flow directly
from caller to the persistence layer in their correct positional order.

A comprehensive BDD test suite (11 scenarios) verifies:
- Arguments are preserved in correct order across all boundary conditions
- Slash-containing IDs and namespacing work correctly
- Optional parameters (project_name, plan_id, mode, args) work properly
- Duplicate rejection works as expected (#7492)

ISSUES CLOSED: #8177, #7492
HAL9001 left a comment

Review - PR #11220 | HAL9001%0A%0ATitle: fix(data-integrity): remove silent argument swap in ValidationAttachmentRepository.attach()%0AAuthor: HAL9000 | Issue reference: Closes #8177 (#7492)%0A%0A### ASSESSMENT: REQUEST_CHANGES (metadata fixes required)%0A%0AThe core code change (+0 additions / -3 deletions in repositories.py) appears correct: removing the 3-line conditional swap block that silently swapped validation_name and resource_id when resource_id contained a slash character.%0A%0AThis properly fixes the silent data corruption described in issue #8177.%0A%0A---%0A%0ABDD Test Quality (+243 lines new step definitions + 83 new scenarios)%0A- Comprehensive coverage including slash-containing IDs, namespacing, optional parameters, and duplicate rejection%0A- Regression test updated to verify argument preservation (not swapping).%0A%0AHowever, CI is not yet available for this PR.%0A%0A---%0A%0AMetadata Issues (BLOCKING)%0A%0A1. Missing milestone - Issue #8177 belongs to v3.2.0 milestone. This PR has none.%0A2. Missing State/In Review label - Per CONTRIBUTING.md, awaiting review must have State/In Review.%0A3. Missing Priority/Critical label - Type/Bug with data corruption always carries Priority/Critical per CONTRIBUTING.md triage rules.%0A%0A---%0A%0ARecommendation: Add milestone v3.2.0 and State/In Review + Priority/Critical labels, then re-submit for CI review.%0AIf CI passes after metadata fixes should be quick APPROVE - code change is minimal and correct.%0A%0A---%0AAutomated by CleverAgents Bot | Supervisor: PR Review | Agent: pr-review-worker

## Review - PR #11220 | HAL9001%0A%0A**Title:** fix(data-integrity): remove silent argument swap in ValidationAttachmentRepository.attach()%0A**Author:** HAL9000 | **Issue reference:** Closes #8177 (#7492)%0A%0A### ASSESSMENT: REQUEST_CHANGES (metadata fixes required)%0A%0AThe core code change (+0 additions / -3 deletions in repositories.py) appears correct: removing the 3-line conditional swap block that silently swapped validation_name and resource_id when resource_id contained a slash character.%0A%0AThis properly fixes the silent data corruption described in issue #8177.%0A%0A---%0A%0A**BDD Test Quality** (+243 lines new step definitions + 83 new scenarios)%0A- Comprehensive coverage including slash-containing IDs, namespacing, optional parameters, and duplicate rejection%0A- Regression test updated to verify argument preservation (not swapping).%0A%0A***However***, CI is not yet available for this PR.%0A%0A---%0A%0A**Metadata Issues (BLOCKING)**%0A%0A1. **Missing milestone** - Issue #8177 belongs to v3.2.0 milestone. This PR has none.%0A2. **Missing State/In Review label** - Per CONTRIBUTING.md, awaiting review must have State/In Review.%0A3. **Missing Priority/Critical label** - Type/Bug with data corruption always carries Priority/Critical per CONTRIBUTING.md triage rules.%0A%0A---%0A%0A**Recommendation**: Add milestone v3.2.0 and State/In Review + Priority/Critical labels, then re-submit for CI review.%0AIf CI passes after metadata fixes should be quick APPROVE - code change is minimal and correct.%0A%0A---%0AAutomated by CleverAgents Bot | Supervisor: PR Review | Agent: pr-review-worker
chore: re-trigger CI [controller]
Some checks failed
CI / lint (pull_request) Failing after 41s
CI / push-validation (pull_request) Successful in 28s
CI / build (pull_request) Successful in 52s
CI / typecheck (pull_request) Successful in 56s
CI / helm (pull_request) Successful in 53s
CI / quality (pull_request) Successful in 1m1s
CI / security (pull_request) Successful in 1m4s
CI / integration_tests (pull_request) Failing after 4m34s
CI / unit_tests (pull_request) Failing after 6m31s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
1d1dbe031f
HAL9000 added this to the v3.2.0 milestone 2026-05-28 21:09:47 +00:00
HAL9000 force-pushed fix/arg-swap-validation-attachment-8177 from 1d1dbe031f
Some checks failed
CI / lint (pull_request) Failing after 41s
CI / push-validation (pull_request) Successful in 28s
CI / build (pull_request) Successful in 52s
CI / typecheck (pull_request) Successful in 56s
CI / helm (pull_request) Successful in 53s
CI / quality (pull_request) Successful in 1m1s
CI / security (pull_request) Successful in 1m4s
CI / integration_tests (pull_request) Failing after 4m34s
CI / unit_tests (pull_request) Failing after 6m31s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
to 2dc7e4adc3
Some checks failed
CI / push-validation (pull_request) Successful in 23s
CI / build (pull_request) Successful in 39s
CI / helm (pull_request) Successful in 40s
CI / quality (pull_request) Successful in 43s
CI / lint (pull_request) Failing after 43s
CI / typecheck (pull_request) Successful in 1m17s
CI / security (pull_request) Successful in 1m19s
CI / integration_tests (pull_request) Successful in 3m56s
CI / unit_tests (pull_request) Failing after 6m7s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
2026-05-28 21:37:40 +00:00
Compare
Author
Owner

event occurred 2026-05-28T21:25:29.660618+00:00

📋 Estimate: tier 1.

Core fix is simple (3-line removal) but the PR spans 7 files with +341 lines of new BDD test code. CI has multiple failures requiring diagnosis: (1) a formatting issue on the new steps file (ruff format — trivial fix), (2) unit_tests Behave errors in actor_run_signature, plan_service_coverage, and tdd_memory_service_entity_persistence features that appear unrelated to the stated scope — setup/teardown errors that may be pre-existing flakiness or an unintended side effect of the change. The implementer needs cross-file context to distinguish a regression introduced by this PR from ambient CI instability. Standard Tier 1 work.

*event occurred 2026-05-28T21:25:29.660618+00:00* **📋 Estimate: tier 1.** Core fix is simple (3-line removal) but the PR spans 7 files with +341 lines of new BDD test code. CI has multiple failures requiring diagnosis: (1) a formatting issue on the new steps file (ruff format — trivial fix), (2) unit_tests Behave errors in actor_run_signature, plan_service_coverage, and tdd_memory_service_entity_persistence features that appear unrelated to the stated scope — setup/teardown errors that may be pre-existing flakiness or an unintended side effect of the change. The implementer needs cross-file context to distinguish a regression introduced by this PR from ambient CI instability. Standard Tier 1 work. <!-- controller:fingerprint:84229432f241f3ee -->
Author
Owner

(attempt #2, tier 1)

event occurred 2026-05-28T21:28:31.976830+00:00

🔧 Implementer attempt — rebase-failed.

Blockers:

  • CHANGELOG.md
_(attempt #2, tier 1)_ *event occurred 2026-05-28T21:28:31.976830+00:00* **🔧 Implementer attempt — `rebase-failed`.** Blockers: - CHANGELOG.md <!-- controller:fingerprint:47ad83d994a6f926 -->
Author
Owner

[CONTROLLER-DEFER:Gate 1:linked_issue_closed]

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:

  • Gate: Gate 1
  • Reason category: linked_issue_closed
  • Canonical: #-
  • LLM confidence: deterministic
  • LLM reasoning: Linked issue(s) [8177] already closed; no LLM call needed.

To clear the deferral (SQL):
UPDATE workflows SET deferred_reason=NULL,
deferred_at=NULL,
deferred_target_workflow_id=NULL
WHERE workflow_id = 20;

INSERT INTO controller_events
  (workflow_id, ts, event_type, payload, cause, forgejo_write_pending, replay_attempts)
VALUES (20, datetime('now'), 'deferral_cleared',
        json_object('cleared_by', 'operator', 'reason', '<your reason>'),
        'operator', 0, 0);

Audit ID: 42760


Automated by the CleverAgents controller pipeline.
Identity: HAL9000 (pipeline action)

[CONTROLLER-DEFER:Gate 1:linked_issue_closed] 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: - Gate: Gate 1 - Reason category: linked_issue_closed - Canonical: #- - LLM confidence: deterministic - LLM reasoning: Linked issue(s) [8177] already closed; no LLM call needed. To clear the deferral (SQL): UPDATE workflows SET deferred_reason=NULL, deferred_at=NULL, deferred_target_workflow_id=NULL WHERE workflow_id = 20; INSERT INTO controller_events (workflow_id, ts, event_type, payload, cause, forgejo_write_pending, replay_attempts) VALUES (20, datetime('now'), 'deferral_cleared', json_object('cleared_by', 'operator', 'reason', '<your reason>'), 'operator', 0, 0); Audit ID: 42760 --- Automated by the CleverAgents controller pipeline. Identity: HAL9000 (pipeline action) <!-- controller:fingerprint:8fa84c768858aaf8 -->
Author
Owner

Closing as resolved: linked issue(s) #8177 is closed — the underlying work has been completed or superseded. This PR was parked in the controller's deferred queue (grooming linked_issue_closed) with no live work target, so it cannot progress. If it contains distinct, unmerged value, please reopen and relink it to an open issue.

Closing as resolved: linked issue(s) #8177 is closed — the underlying work has been completed or superseded. This PR was parked in the controller's deferred queue (grooming `linked_issue_closed`) with no live work target, so it cannot progress. If it contains distinct, unmerged value, please reopen and relink it to an open issue.
HAL9000 2026-06-18 11:27:02 +00:00
  • closed this pull request
  • removed the
    State
    Paused
    label
Some checks failed
CI / push-validation (pull_request) Successful in 23s
CI / build (pull_request) Successful in 39s
Required
Details
CI / helm (pull_request) Successful in 40s
CI / quality (pull_request) Successful in 43s
Required
Details
CI / lint (pull_request) Failing after 43s
Required
Details
CI / typecheck (pull_request) Successful in 1m17s
Required
Details
CI / security (pull_request) Successful in 1m19s
Required
Details
CI / integration_tests (pull_request) Successful in 3m56s
Required
Details
CI / unit_tests (pull_request) Failing after 6m7s
Required
Details
CI / coverage (pull_request) Has been skipped
Required
Details
CI / docker (pull_request) Has been skipped
Required
Details
CI / status-check (pull_request) Failing after 3s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!11220
No description provided.