From f6eeb170ef893c9c8c6f9a1ea9ae9a9f217a3a28 Mon Sep 17 00:00:00 2001 From: Zachary Rosen Date: Fri, 26 Dec 2025 20:38:14 -0500 Subject: [PATCH] fix: add missing CreatedBy in RPC path created_by was recently added in https://github.com/steveyegge/beads/commit/c3ef1c3f382ac2485a9b793051a291937b4ed37c but was missing support for passing in the CreatedBy through the RPC path so a create that was using the daemon was never having the created_by field set. --- cmd/bd/create.go | 1 + internal/rpc/protocol.go | 3 +- internal/rpc/server_issues_epics.go | 3 +- internal/rpc/server_mutations_test.go | 44 +++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/cmd/bd/create.go b/cmd/bd/create.go index e097b065..359923b6 100644 --- a/cmd/bd/create.go +++ b/cmd/bd/create.go @@ -223,6 +223,7 @@ var createCmd = &cobra.Command{ WaitsFor: waitsFor, WaitsForGate: waitsForGate, Wisp: wisp, + CreatedBy: getActorWithGit(), } resp, err := daemonClient.Create(createArgs) diff --git a/internal/rpc/protocol.go b/internal/rpc/protocol.go index 00d12907..9e228716 100644 --- a/internal/rpc/protocol.go +++ b/internal/rpc/protocol.go @@ -93,7 +93,8 @@ type CreateArgs struct { Wisp bool `json:"wisp,omitempty"` // Wisp = ephemeral vapor from the Steam Engine; bulk-deleted when closed RepliesTo string `json:"replies_to,omitempty"` // Issue ID for conversation threading // ID generation (bd-hobo) - IDPrefix string `json:"id_prefix,omitempty"` // Override prefix for ID generation (mol, wisp, etc.) + IDPrefix string `json:"id_prefix,omitempty"` // Override prefix for ID generation (mol, wisp, etc.) + CreatedBy string `json:"created_by,omitempty"` // Who created the issue } // UpdateArgs represents arguments for the update operation diff --git a/internal/rpc/server_issues_epics.go b/internal/rpc/server_issues_epics.go index 918d19ed..d9d55f43 100644 --- a/internal/rpc/server_issues_epics.go +++ b/internal/rpc/server_issues_epics.go @@ -180,7 +180,8 @@ func (s *Server) handleCreate(req *Request) Response { Wisp: createArgs.Wisp, // NOTE: RepliesTo now handled via replies-to dependency (Decision 004) // ID generation (bd-hobo) - IDPrefix: createArgs.IDPrefix, + IDPrefix: createArgs.IDPrefix, + CreatedBy: createArgs.CreatedBy, } // Check if any dependencies are discovered-from type diff --git a/internal/rpc/server_mutations_test.go b/internal/rpc/server_mutations_test.go index 83f5d2b4..61631389 100644 --- a/internal/rpc/server_mutations_test.go +++ b/internal/rpc/server_mutations_test.go @@ -1,6 +1,7 @@ package rpc import ( + "context" "encoding/json" "testing" "time" @@ -9,6 +10,49 @@ import ( "github.com/steveyegge/beads/internal/types" ) +// TestHandleCreate_SetsCreatedBy verifies that CreatedBy is passed through RPC and stored (GH#748) +func TestHandleCreate_SetsCreatedBy(t *testing.T) { + store := memory.New("/tmp/test.jsonl") + server := NewServer("/tmp/test.sock", store, "/tmp", "/tmp/test.db") + + createArgs := CreateArgs{ + Title: "Test CreatedBy Field", + IssueType: "task", + Priority: 2, + CreatedBy: "test-actor", + } + createJSON, _ := json.Marshal(createArgs) + createReq := &Request{ + Operation: OpCreate, + Args: createJSON, + Actor: "test-actor", + } + + resp := server.handleCreate(createReq) + if !resp.Success { + t.Fatalf("create failed: %s", resp.Error) + } + + var createdIssue types.Issue + if err := json.Unmarshal(resp.Data, &createdIssue); err != nil { + t.Fatalf("failed to parse response: %v", err) + } + + // Verify CreatedBy was set in the response + if createdIssue.CreatedBy != "test-actor" { + t.Errorf("expected CreatedBy 'test-actor' in response, got %q", createdIssue.CreatedBy) + } + + // Verify CreatedBy was persisted to storage + storedIssue, err := store.GetIssue(context.Background(), createdIssue.ID) + if err != nil { + t.Fatalf("failed to get issue from storage: %v", err) + } + if storedIssue.CreatedBy != "test-actor" { + t.Errorf("expected CreatedBy 'test-actor' in storage, got %q", storedIssue.CreatedBy) + } +} + func TestEmitMutation(t *testing.T) { store := memory.New("/tmp/test.jsonl") server := NewServer("/tmp/test.sock", store, "/tmp", "/tmp/test.db")