Problem
During ring:dev-cycle execution (Gates 0 RED-GREEN for sort mappers), 3 backend-engineer-golang agents running in parallel overwrote existing test files, deleting 3,743 lines of pre-existing tests unrelated to the migration.
Root Cause
Gate 0 (Implementation) dispatches agents per execution unit. When multiple tasks run in parallel and touch test files in the same package, each agent uses Write/Create which overwrites the entire file. There is no file locking, merge strategy, or baseline snapshot.
Invariant (from @Garzão)
Tests may ONLY be removed if the code being tested was removed. In all other scenarios, tests MUST be preserved — only modified to reflect changes in the code under test.
This invariant is not currently enforced anywhere in the dev-cycle or agent prompts.
Proposed Fix (3 layers)
Layer 1: Agent-level protection (minimal fix)
Add explicit instructions to backend-engineer-golang agent prompt:
- NEVER delete or overwrite existing
_test.go files entirely. Use Edit tool to modify specific test functions, never Write/Create on existing test files.
- NEVER remove test functions unless the code under test was deleted in the same task.
- When adding tests, create task-scoped test files (e.g.,
sort_mapper_migration_test.go) rather than modifying shared test files.
- Before writing any test file, read the existing file first and preserve all existing test functions.
Layer 2: Pre/post-execution snapshot (defense in depth)
Before dispatching parallel agents in Gate 0, the orchestrator should:
- Snapshot all
_test.go files in affected packages (git stash or file copy)
- After all agents complete, diff against baseline
- If any test file lost lines vs baseline → revert that file and re-dispatch the offending agent sequentially
Layer 3: Parallel execution conflict detection
During Step 1 (initialization), the orchestrator should:
- Analyze which files each task/subtask will likely touch (based on requirements + codebase structure)
- If multiple tasks target the same package → force sequential execution for those tasks
- Allow parallel execution only for tasks with non-overlapping file scopes
Affected Components
dev-team/skills/dev-cycle/SKILL.md — orchestrator needs snapshot + conflict detection
dev-team/agents/backend-engineer-golang.md — agent needs test preservation rules
dev-team/skills/dev-implementation/SKILL.md — skill dispatching agents needs parallel safety
- Potentially all
backend-engineer-* agents (same pattern applies to TypeScript)
Priority
High — data loss (test deletion) undermines the entire quality gate system. The dev-cycle has 5 testing gates (3-7) that become meaningless if tests are silently deleted during implementation.
Reported by
@Carlao-LERIAN in #the-ring-feedbacks
Problem
During
ring:dev-cycleexecution (Gates 0 RED-GREEN for sort mappers), 3backend-engineer-golangagents running in parallel overwrote existing test files, deleting 3,743 lines of pre-existing tests unrelated to the migration.Root Cause
Gate 0 (Implementation) dispatches agents per execution unit. When multiple tasks run in parallel and touch test files in the same package, each agent uses
Write/Createwhich overwrites the entire file. There is no file locking, merge strategy, or baseline snapshot.Invariant (from @Garzão)
This invariant is not currently enforced anywhere in the dev-cycle or agent prompts.
Proposed Fix (3 layers)
Layer 1: Agent-level protection (minimal fix)
Add explicit instructions to
backend-engineer-golangagent prompt:_test.gofiles entirely. UseEdittool to modify specific test functions, neverWrite/Createon existing test files.sort_mapper_migration_test.go) rather than modifying shared test files.Layer 2: Pre/post-execution snapshot (defense in depth)
Before dispatching parallel agents in Gate 0, the orchestrator should:
_test.gofiles in affected packages (git stashor file copy)Layer 3: Parallel execution conflict detection
During Step 1 (initialization), the orchestrator should:
Affected Components
dev-team/skills/dev-cycle/SKILL.md— orchestrator needs snapshot + conflict detectiondev-team/agents/backend-engineer-golang.md— agent needs test preservation rulesdev-team/skills/dev-implementation/SKILL.md— skill dispatching agents needs parallel safetybackend-engineer-*agents (same pattern applies to TypeScript)Priority
High — data loss (test deletion) undermines the entire quality gate system. The dev-cycle has 5 testing gates (3-7) that become meaningless if tests are silently deleted during implementation.
Reported by
@Carlao-LERIAN in #the-ring-feedbacks