Fix auto-import collision detection and enforce status/closed_at invariant (bd-226)
Code review and fixes: - Increased scanner buffer to 2MB for large JSON lines - Added line numbers and snippets to parse error messages - Made non-SQLite fallback conservative (skip import to prevent data loss) - Improved collision warnings (concise, show first 10 IDs) - Removed unused autoImportWithoutCollisionDetection function Status/closed_at invariant enforcement: - Auto-import now enforces invariant on all creates/updates - Fixed CreateIssue to respect closed_at field (was ignoring it) - Closed issues without closed_at get timestamp set automatically Integration tests: - TestAutoImportWithCollision: verifies local changes preserved - TestAutoImportNoCollision: happy path with new issues - TestAutoImportClosedAtInvariant: enforces invariant Closes bd-226, bd-230, bd-231
This commit is contained in:
@@ -406,14 +406,14 @@ func (s *SQLiteStorage) CreateIssue(ctx context.Context, issue *types.Issue, act
|
||||
INSERT INTO issues (
|
||||
id, title, description, design, acceptance_criteria, notes,
|
||||
status, priority, issue_type, assignee, estimated_minutes,
|
||||
created_at, updated_at, external_ref
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
created_at, updated_at, closed_at, external_ref
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`,
|
||||
issue.ID, issue.Title, issue.Description, issue.Design,
|
||||
issue.AcceptanceCriteria, issue.Notes, issue.Status,
|
||||
issue.Priority, issue.IssueType, issue.Assignee,
|
||||
issue.EstimatedMinutes, issue.CreatedAt, issue.UpdatedAt,
|
||||
issue.ExternalRef,
|
||||
issue.ClosedAt, issue.ExternalRef,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to insert issue: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user