Remove obsolete collision remapping code and tests
- Deleted collision remapping tests (obsolete with hash IDs bd-8e05) - Simplified collision.go from 704 to 138 lines - Removed RemapCollisions, ScoreCollisions, and reference update code - Removed issue_counters table dependencies (bd-807b) - Added COLLISION_MATH.md documentation - Fixed RenameCounterPrefix and ResetCounter to be no-ops - Closed bd-a58f, bd-3d65, bd-807b Hash-based IDs make collision remapping unnecessary since collisions are extremely rare (same ID = same content). Amp-Thread-ID: https://ampcode.com/threads/T-cbb0f111-6a95-4598-b03e-c137112f9875 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -1571,44 +1571,17 @@ func (s *SQLiteStorage) RenameDependencyPrefix(ctx context.Context, oldPrefix, n
|
||||
return nil
|
||||
}
|
||||
|
||||
// RenameCounterPrefix updates the prefix in the issue_counters table
|
||||
// RenameCounterPrefix is a no-op with hash-based IDs (bd-8e05)
|
||||
// Kept for backward compatibility with rename-prefix command
|
||||
func (s *SQLiteStorage) RenameCounterPrefix(ctx context.Context, oldPrefix, newPrefix string) error {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to begin transaction: %w", err)
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var lastID int
|
||||
err = tx.QueryRowContext(ctx, `SELECT last_id FROM issue_counters WHERE prefix = ?`, oldPrefix).Scan(&lastID)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return fmt.Errorf("failed to get old counter: %w", err)
|
||||
}
|
||||
|
||||
_, err = tx.ExecContext(ctx, `DELETE FROM issue_counters WHERE prefix = ?`, oldPrefix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete old counter: %w", err)
|
||||
}
|
||||
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO issue_counters (prefix, last_id)
|
||||
VALUES (?, ?)
|
||||
ON CONFLICT(prefix) DO UPDATE SET last_id = MAX(last_id, excluded.last_id)
|
||||
`, newPrefix, lastID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create new counter: %w", err)
|
||||
}
|
||||
|
||||
return tx.Commit()
|
||||
// Hash-based IDs don't use counters, so nothing to update
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetCounter deletes the counter for a prefix, forcing it to be recalculated from max ID
|
||||
// This is used by renumber to ensure the counter matches the actual max ID after renumbering
|
||||
// ResetCounter is a no-op with hash-based IDs (bd-8e05)
|
||||
// Kept for backward compatibility
|
||||
func (s *SQLiteStorage) ResetCounter(ctx context.Context, prefix string) error {
|
||||
_, err := s.db.ExecContext(ctx, `DELETE FROM issue_counters WHERE prefix = ?`, prefix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete counter: %w", err)
|
||||
}
|
||||
// Hash-based IDs don't use counters, so nothing to reset
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user