From 09120b1012b5ab7dc50b597c6044fc39c3c2d0c1 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Tue, 30 Dec 2025 16:24:08 -0800 Subject: [PATCH] Add BD_ACTOR env var default for created_by field enforcement (gt-6r18e.6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create() function now defaults Actor from BD_ACTOR env var when not provided - CreateAgentBead() now passes --actor flag from BD_ACTOR for provenance tracking - This ensures created_by is populated on all issue creation paths Affects: merge requests, escalations, digests, agent beads, molecule steps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/beads/beads.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/beads/beads.go b/internal/beads/beads.go index cf42168b..139f8ce9 100644 --- a/internal/beads/beads.go +++ b/internal/beads/beads.go @@ -404,6 +404,8 @@ func (b *Beads) Blocked() ([]*Issue, error) { } // Create creates a new issue and returns it. +// If opts.Actor is empty, it defaults to the BD_ACTOR environment variable. +// This ensures created_by is populated for issue provenance tracking. func (b *Beads) Create(opts CreateOptions) (*Issue, error) { args := []string{"create", "--json"} @@ -422,8 +424,13 @@ func (b *Beads) Create(opts CreateOptions) (*Issue, error) { if opts.Parent != "" { args = append(args, "--parent="+opts.Parent) } - if opts.Actor != "" { - args = append(args, "--actor="+opts.Actor) + // Default Actor from BD_ACTOR env var if not specified + actor := opts.Actor + if actor == "" { + actor = os.Getenv("BD_ACTOR") + } + if actor != "" { + args = append(args, "--actor="+actor) } out, err := b.run(args...) @@ -784,6 +791,7 @@ func ParseAgentFields(description string) *AgentFields { // CreateAgentBead creates an agent bead for tracking agent lifecycle. // The ID format is: --- (e.g., gt-gastown-polecat-Toast) // Use AgentBeadID() helper to generate correct IDs. +// The created_by field is populated from BD_ACTOR env var for provenance tracking. func (b *Beads) CreateAgentBead(id, title string, fields *AgentFields) (*Issue, error) { description := FormatAgentDescription(title, fields) @@ -794,6 +802,11 @@ func (b *Beads) CreateAgentBead(id, title string, fields *AgentFields) (*Issue, "--description=" + description, } + // Default actor from BD_ACTOR env var for provenance tracking + if actor := os.Getenv("BD_ACTOR"); actor != "" { + args = append(args, "--actor="+actor) + } + out, err := b.run(args...) if err != nil { return nil, err