Implement adaptive ID length scaling (bd-ea2a13)
- Start with 4-char IDs for small databases (0-500 issues) - Scale to 5-char at 500-1500 issues, 6-char at 1500+ - Configurable via max_collision_prob, min/max_hash_length - Birthday paradox math ensures collision probability stays under threshold - Comprehensive tests and documentation - Collision calculator tool for analysis Also filed bd-aa744b to remove sequential ID code path.
This commit is contained in:
@@ -38,9 +38,10 @@ func TestHashIDGeneration(t *testing.T) {
|
||||
t.Fatalf("Failed to create issue: %v", err)
|
||||
}
|
||||
|
||||
// Verify hash ID format: bd-<6 hex chars> (or 7/8 on collision)
|
||||
if len(issue.ID) < 9 || len(issue.ID) > 11 { // "bd-" (3) + 6-8 hex chars = 9-11
|
||||
t.Errorf("Expected ID length 9-11, got %d: %s", len(issue.ID), issue.ID)
|
||||
// Verify hash ID format: bd-<4-8 hex chars> with adaptive length (bd-ea2a13)
|
||||
// For empty/small database, should use 4 chars
|
||||
if len(issue.ID) < 7 || len(issue.ID) > 11 { // "bd-" (3) + 4-8 hex chars = 7-11
|
||||
t.Errorf("Expected ID length 7-11, got %d: %s", len(issue.ID), issue.ID)
|
||||
}
|
||||
|
||||
if issue.ID[:3] != "bd-" {
|
||||
@@ -187,9 +188,9 @@ func TestHashIDBatchCreation(t *testing.T) {
|
||||
}
|
||||
ids[issue.ID] = true
|
||||
|
||||
// Verify hash ID format (6-8 chars)
|
||||
if len(issue.ID) < 9 || len(issue.ID) > 11 {
|
||||
t.Errorf("Expected ID length 9-11, got %d: %s", len(issue.ID), issue.ID)
|
||||
// Verify hash ID format (4-8 chars with adaptive length)
|
||||
if len(issue.ID) < 7 || len(issue.ID) > 11 {
|
||||
t.Errorf("Expected ID length 7-11, got %d: %s", len(issue.ID), issue.ID)
|
||||
}
|
||||
if issue.ID[:3] != "bd-" {
|
||||
t.Errorf("Expected ID to start with 'bd-', got: %s", issue.ID)
|
||||
|
||||
Reference in New Issue
Block a user