Implement Tier 1 compaction logic (bd-257)
- Add Compactor with CompactTier1 and CompactTier1Batch methods - Single issue and batch compaction with 5 concurrent workers - Dry-run mode for testing without API calls - Smart size checking: keeps original if summary is longer - Improved Haiku prompts to emphasize compression - Add ApplyCompaction method for setting compaction metadata - Comprehensive tests including API integration tests - All tests passing
This commit is contained in:
@@ -450,3 +450,24 @@ func (s *SQLiteStorage) GetSnapshots(ctx context.Context, issueID string) ([]*Sn
|
||||
|
||||
return snapshots, nil
|
||||
}
|
||||
|
||||
// ApplyCompaction updates the compaction metadata for an issue after successfully compacting it.
|
||||
// This sets compaction_level, compacted_at, and original_size fields.
|
||||
func (s *SQLiteStorage) ApplyCompaction(ctx context.Context, issueID string, level int, originalSize int) error {
|
||||
now := time.Now().UTC()
|
||||
|
||||
_, err := s.db.ExecContext(ctx, `
|
||||
UPDATE issues
|
||||
SET compaction_level = ?,
|
||||
compacted_at = ?,
|
||||
original_size = ?,
|
||||
updated_at = ?
|
||||
WHERE id = ?
|
||||
`, level, now, originalSize, now, issueID)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to apply compaction metadata: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user