Update ~20 stale comments across the Dolt storage layer that still
referenced SQLite after the migration to Dolt-only storage. Rename
LargeSQLite/XLargeSQLite fixture functions to LargeDolt/XLargeDolt.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Run make fmt to fix all gofmt issues. Add nolint directives for:
- G204 (gosec) in cmd/bd/stubs.go: git args are internal, not user-supplied
- unparam in internal/syncbranch/worktree.go: error return kept for callers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
Add comprehensive unit tests for New constructor, CompactTier1 error
paths, CompactTier1Single, CompactTier2, and SummarizeTier1 with audit.
Fix nil pointer dereference in New when API key is missing (typed nil
*HaikuClient assigned to summarizer interface caused panic in type
assertion).
Closes bd-thgk
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Commit cb1e3555 ("refactor(rpc): fix leaky abstraction") accidentally
rewrote CompactTier1() and removed critical safety features:
Restored:
- CheckEligibility() call before GetIssue() (fail fast on ineligible)
- DryRun returns error with details, not silent nil
- Size check: skip compaction if summary >= original size
- Git commit hash capture via GetCurrentCommitHash()
- Proper warning comment when compaction is skipped
Also fixed data race in test:
- Add mutex to stubSummarizer.calls for thread-safe access in batch test
The tests were correct - they defined the original intended behavior
that was working before the accidental regression.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The RPC layer was directly importing storage/sqlite and doing type
assertions to *sqlite.SQLiteStorage, which broke abstraction and
prevented Dolt backend from using certain features.
Changes:
- Add CompactableStorage and BatchDeleter interfaces to storage package
- Move CompactionCandidate and DeleteIssuesResult types to internal/types
- Update RPC handlers to use interface type assertions instead of concrete types
- Update compact package to accept interface instead of concrete type
- Remove unnecessary type assertions where methods exist on Storage interface
This enables Dolt (and future backends) to implement optional features
like compaction and batch delete through proper interface extension.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/opal
Rig: beads
Role: polecat
The compact.New constructor was tightly coupled to *sqlite.SQLiteStorage,
preventing other storage backends (like Dolt) from using the compaction
feature even if they implemented the required methods.
Changes:
- Export issueStore as CompactableStore interface
- Change New() to accept CompactableStore instead of *sqlite.SQLiteStorage
- Remove unused sqlite import
The struct already used the interface internally; this change simply
fixes the constructor signature to accept any compliant implementation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/onyx
Rig: beads
Role: polecat
- Add compacted_at_commit field to Issue type (bd-405)
- Add database schema and migration for new field
- Create GetCurrentCommitHash() helper function
- Update ApplyCompaction to store git commit hash (bd-395)
- Update compaction calls to capture current commit
- Update tests to verify commit hash storage
- All tests passing
Amp-Thread-ID: https://ampcode.com/threads/T-5518cccb-7fc9-4dcd-ba5a-e22cd10e45d7
Co-authored-by: Amp <amp@ampcode.com>
- Add EventCompacted event type constant
- Add compaction fields to Issue struct (CompactionLevel, CompactedAt, OriginalSize)
- Update ApplyCompaction to record compaction events with JSON metadata
- Update bd show to display compaction status with emoji indicators
- Update GetIssue query to load compaction fields
- All tests passing
Amp-Thread-ID: https://ampcode.com/threads/T-3f7946c6-8f5e-4a81-9527-1217041c7b39
Co-authored-by: Amp <amp@ampcode.com>
Snapshots defeated the entire purpose of compaction - if we're keeping
the original content, we're not actually saving any space. Compaction
is about graceful memory decay for agentic databases, not reversible
compression.
Removed:
- CreateSnapshot/GetSnapshots/RestoreFromSnapshot from storage
- --restore flag and functionality from bd compact command
- All snapshot-related tests
- Snapshot struct and related code
The database is ephemeral and meant to decay over time. Compaction
actually reduces database size now.
Closes bd-260 (won't fix - conceptually wrong)
Closes bd-261 (already done in bd-259)
- 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