feat: add session_id field to issue close/update mutations (bd-tksk)
Adds closed_by_session tracking for entity CV building per Gas Town decision 009-session-events-architecture.md. Changes: - Add ClosedBySession field to Issue struct - Add closed_by_session column to issues table (migration 034) - Add --session flag to bd close command - Support CLAUDE_SESSION_ID env var as fallback - Add --session flag to bd update for status=closed - Display closed_by_session in bd show output - Update Storage interface to include session parameter in CloseIssue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Executed-By: beads/crew/dave Rig: beads Role: crew
This commit is contained in:
committed by
Steve Yegge
parent
7c9b975436
commit
b362b36824
@@ -443,6 +443,14 @@ func (m *MemoryStorage) UpdateIssue(ctx context.Context, id string, updates map[
|
||||
}
|
||||
issue.ExternalRef = nil
|
||||
}
|
||||
case "close_reason":
|
||||
if v, ok := value.(string); ok {
|
||||
issue.CloseReason = v
|
||||
}
|
||||
case "closed_by_session":
|
||||
if v, ok := value.(string); ok {
|
||||
issue.ClosedBySession = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,11 +475,17 @@ func (m *MemoryStorage) UpdateIssue(ctx context.Context, id string, updates map[
|
||||
return nil
|
||||
}
|
||||
|
||||
// CloseIssue closes an issue with a reason
|
||||
func (m *MemoryStorage) CloseIssue(ctx context.Context, id string, reason string, actor string) error {
|
||||
return m.UpdateIssue(ctx, id, map[string]interface{}{
|
||||
"status": string(types.StatusClosed),
|
||||
}, actor)
|
||||
// CloseIssue closes an issue with a reason.
|
||||
// The session parameter tracks which Claude Code session closed the issue (can be empty).
|
||||
func (m *MemoryStorage) CloseIssue(ctx context.Context, id string, reason string, actor string, session string) error {
|
||||
updates := map[string]interface{}{
|
||||
"status": string(types.StatusClosed),
|
||||
"close_reason": reason,
|
||||
}
|
||||
if session != "" {
|
||||
updates["closed_by_session"] = session
|
||||
}
|
||||
return m.UpdateIssue(ctx, id, updates, actor)
|
||||
}
|
||||
|
||||
// CreateTombstone converts an existing issue to a tombstone record.
|
||||
|
||||
@@ -515,7 +515,7 @@ func TestMemoryStorage_GetStaleIssues_FilteringAndLimit(t *testing.T) {
|
||||
t.Fatalf("CreateIssue %s: %v", iss.ID, err)
|
||||
}
|
||||
}
|
||||
if err := store.CloseIssue(ctx, closed.ID, "done", "actor"); err != nil {
|
||||
if err := store.CloseIssue(ctx, closed.ID, "done", "actor", ""); err != nil {
|
||||
t.Fatalf("CloseIssue: %v", err)
|
||||
}
|
||||
|
||||
@@ -555,10 +555,10 @@ func TestMemoryStorage_Statistics_EpicsEligibleForClosure_Counting(t *testing.T)
|
||||
t.Fatalf("CreateIssue %s: %v", iss.ID, err)
|
||||
}
|
||||
}
|
||||
if err := store.CloseIssue(ctx, c1.ID, "done", "actor"); err != nil {
|
||||
if err := store.CloseIssue(ctx, c1.ID, "done", "actor", ""); err != nil {
|
||||
t.Fatalf("CloseIssue c1: %v", err)
|
||||
}
|
||||
if err := store.CloseIssue(ctx, c2.ID, "done", "actor"); err != nil {
|
||||
if err := store.CloseIssue(ctx, c2.ID, "done", "actor", ""); err != nil {
|
||||
t.Fatalf("CloseIssue c2: %v", err)
|
||||
}
|
||||
// Parent-child deps: child -> epic.
|
||||
@@ -851,7 +851,7 @@ func TestMemoryStorage_UpdateIssue_CoversMoreFields(t *testing.T) {
|
||||
}
|
||||
|
||||
// Status closed when already closed should not clear ClosedAt.
|
||||
if err := store.CloseIssue(ctx, iss.ID, "done", "actor"); err != nil {
|
||||
if err := store.CloseIssue(ctx, iss.ID, "done", "actor", ""); err != nil {
|
||||
t.Fatalf("CloseIssue: %v", err)
|
||||
}
|
||||
closedOnce, _ := store.GetIssue(ctx, iss.ID)
|
||||
@@ -881,7 +881,7 @@ func TestMemoryStorage_CountEpicsEligibleForClosure_CoversBranches(t *testing.T)
|
||||
t.Fatalf("CreateIssue %s: %v", iss.ID, err)
|
||||
}
|
||||
}
|
||||
if err := store.CloseIssue(ctx, epClosed.ID, "done", "actor"); err != nil {
|
||||
if err := store.CloseIssue(ctx, epClosed.ID, "done", "actor", ""); err != nil {
|
||||
t.Fatalf("CloseIssue: %v", err)
|
||||
}
|
||||
// Child -> ep1 (eligible once child is closed).
|
||||
@@ -898,7 +898,7 @@ func TestMemoryStorage_CountEpicsEligibleForClosure_CoversBranches(t *testing.T)
|
||||
store.mu.Unlock()
|
||||
|
||||
// Close child to make ep1 eligible.
|
||||
if err := store.CloseIssue(ctx, c.ID, "done", "actor"); err != nil {
|
||||
if err := store.CloseIssue(ctx, c.ID, "done", "actor", ""); err != nil {
|
||||
t.Fatalf("CloseIssue child: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ func TestCloseIssue(t *testing.T) {
|
||||
}
|
||||
|
||||
// Close it
|
||||
if err := store.CloseIssue(ctx, issue.ID, "Completed", "test-user"); err != nil {
|
||||
if err := store.CloseIssue(ctx, issue.ID, "Completed", "test-user", ""); err != nil {
|
||||
t.Fatalf("CloseIssue failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ func TestStatistics(t *testing.T) {
|
||||
}
|
||||
// Close the one marked as closed
|
||||
if issue.Status == types.StatusClosed {
|
||||
if err := store.CloseIssue(ctx, issue.ID, "Done", "test-user"); err != nil {
|
||||
if err := store.CloseIssue(ctx, issue.ID, "Done", "test-user", ""); err != nil {
|
||||
t.Fatalf("CloseIssue failed: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -786,7 +786,7 @@ func TestStatistics_BlockedAndReadyCounts(t *testing.T) {
|
||||
}
|
||||
|
||||
// Close the closedBlocker properly
|
||||
if err := store.CloseIssue(ctx, closedBlocker.ID, "Done", "test"); err != nil {
|
||||
if err := store.CloseIssue(ctx, closedBlocker.ID, "Done", "test", ""); err != nil {
|
||||
t.Fatalf("CloseIssue failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -878,7 +878,7 @@ func TestStatistics_EpicsEligibleForClosure(t *testing.T) {
|
||||
|
||||
// Close the children properly
|
||||
for _, child := range []*types.Issue{child1, child2} {
|
||||
if err := store.CloseIssue(ctx, child.ID, "Done", "test"); err != nil {
|
||||
if err := store.CloseIssue(ctx, child.ID, "Done", "test", ""); err != nil {
|
||||
t.Fatalf("CloseIssue failed: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -926,7 +926,7 @@ func TestStatistics_TombstonesExcludedFromTotal(t *testing.T) {
|
||||
}
|
||||
|
||||
// Close the closed issue properly
|
||||
if err := store.CloseIssue(ctx, issues[1].ID, "Done", "test"); err != nil {
|
||||
if err := store.CloseIssue(ctx, issues[1].ID, "Done", "test", ""); err != nil {
|
||||
t.Fatalf("CloseIssue failed: %v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user