Files
beads/internal/storage/sqlite/migrations/036_owner_column.go
beads/crew/dave ceb5769c75 feat: add owner field for human attribution in HOP CV chains
Add 'owner' field to Issue struct for tracking the human responsible
for the issue, distinct from 'created_by' which tracks the executor.
Owner is populated from git author email (GIT_AUTHOR_EMAIL or git
config user.email), per Decision 008 for CV accumulation.

Changes:
- Add Owner field to types.Issue with omitempty JSON tag
- Include Owner in content hash computation
- Add owner column migration (036_owner_column.go)
- Update all SQL queries to include owner field
- Add getOwner() helper using git author email fallback chain
- Populate owner in bd create command
- Add owner to RPC CreateArgs protocol

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/dave
Rig: beads
Role: crew
2026-01-10 19:28:08 -08:00

35 lines
810 B
Go

package migrations
import (
"database/sql"
"fmt"
)
// MigrateOwnerColumn adds the owner column to the issues table.
// This tracks the human owner responsible for the issue, using git author email
// for HOP CV (curriculum vitae) attribution chains. See Decision 008.
func MigrateOwnerColumn(db *sql.DB) error {
// Check if column already exists
var columnExists bool
err := db.QueryRow(`
SELECT COUNT(*) > 0
FROM pragma_table_info('issues')
WHERE name = 'owner'
`).Scan(&columnExists)
if err != nil {
return fmt.Errorf("failed to check owner column: %w", err)
}
if columnExists {
return nil
}
// Add the owner column
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN owner TEXT DEFAULT ''`)
if err != nil {
return fmt.Errorf("failed to add owner column: %w", err)
}
return nil
}