From 2b40d0a3b03a35dbc19eb19ec91dedb7a4c473d9 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 05:11:48 +0000 Subject: [PATCH] feat(brain): surface deleted_at in memory outputs Co-Authored-By: Virgil --- pkg/agentic/commands.go | 6 ++++++ pkg/agentic/commands_test.go | 2 ++ pkg/brain/direct.go | 1 + pkg/brain/direct_test.go | 2 ++ pkg/brain/tools.go | 1 + pkg/brain/tools_test.go | 6 ++++++ 6 files changed, 18 insertions(+) diff --git a/pkg/agentic/commands.go b/pkg/agentic/commands.go index 43747b2..4710e05 100644 --- a/pkg/agentic/commands.go +++ b/pkg/agentic/commands.go @@ -547,6 +547,9 @@ func (s *PrepSubsystem) cmdBrainList(options core.Options) core.Result { if memory.SupersedesCount > 0 { core.Print(nil, " supersedes: %d", memory.SupersedesCount) } + if memory.DeletedAt != "" { + core.Print(nil, " deleted_at: %s", memory.DeletedAt) + } if memory.Content != "" { core.Print(nil, " %s", memory.Content) } @@ -698,6 +701,7 @@ type brainRecallMemory struct { Project string `json:"project"` AgentID string `json:"agent_id"` Confidence float64 `json:"confidence"` + DeletedAt string `json:"deleted_at,omitempty"` Tags []string `json:"tags"` } @@ -1134,6 +1138,7 @@ type brainListOutputEntry struct { AgentID string `json:"agent_id"` Confidence float64 `json:"confidence"` SupersedesCount int `json:"supersedes_count,omitempty"` + DeletedAt string `json:"deleted_at,omitempty"` Tags []string `json:"tags"` } @@ -1178,6 +1183,7 @@ func brainListOutputFromPayload(payload map[string]any) brainListOutput { case int: entry.SupersedesCount = supersedesCount } + entry.DeletedAt = brainListStringValue(entryMap["deleted_at"]) if tags, ok := entryMap["tags"].([]any); ok { for _, tag := range tags { entry.Tags = append(entry.Tags, brainListStringValue(tag)) diff --git a/pkg/agentic/commands_test.go b/pkg/agentic/commands_test.go index fed2fa8..1ae2433 100644 --- a/pkg/agentic/commands_test.go +++ b/pkg/agentic/commands_test.go @@ -254,6 +254,7 @@ func TestCommands_CmdBrainList_Good(t *testing.T) { "agent_id": "virgil", "confidence": 0.9, "supersedes_count": 3, + "deleted_at": "2026-03-31T12:30:00Z", "tags": []any{"architecture", "convention"}, }, }, @@ -272,6 +273,7 @@ func TestCommands_CmdBrainList_Good(t *testing.T) { assert.Contains(t, output, "count: 1") assert.Contains(t, output, "mem-1 architecture") assert.Contains(t, output, "supersedes: 3") + assert.Contains(t, output, "deleted_at: 2026-03-31T12:30:00Z") assert.Contains(t, output, "Use named actions.") } diff --git a/pkg/brain/direct.go b/pkg/brain/direct.go index f4628b5..b9c9e1c 100644 --- a/pkg/brain/direct.go +++ b/pkg/brain/direct.go @@ -258,6 +258,7 @@ func memoriesFromPayload(payload map[string]any) []Memory { CreatedAt: stringField(memoryMap, "created_at"), UpdatedAt: stringField(memoryMap, "updated_at"), ExpiresAt: stringField(memoryMap, "expires_at"), + DeletedAt: stringField(memoryMap, "deleted_at"), } if id, ok := memoryMap["id"].(string); ok { memory.ID = id diff --git a/pkg/brain/direct_test.go b/pkg/brain/direct_test.go index 796f63d..f130b73 100644 --- a/pkg/brain/direct_test.go +++ b/pkg/brain/direct_test.go @@ -429,6 +429,7 @@ func TestDirect_List_Good_WithMemories(t *testing.T) { "agent_id": "codex", "confidence": 0.73, "supersedes_count": 2, + "deleted_at": "2026-03-31T12:30:00Z", "tags": []any{"queue", "review"}, "updated_at": "2026-03-30T10:00:00Z", "created_at": "2026-03-30T09:00:00Z", @@ -469,6 +470,7 @@ func TestDirect_List_Good_WithMemories(t *testing.T) { assert.Equal(t, "manual", out.Memories[0].Source) assert.Equal(t, "2026-03-30T10:00:00Z", out.Memories[0].UpdatedAt) assert.Equal(t, "2026-04-01T00:00:00Z", out.Memories[0].ExpiresAt) + assert.Equal(t, "2026-03-31T12:30:00Z", out.Memories[0].DeletedAt) assert.Contains(t, out.Memories[0].Tags, "queue") assert.Contains(t, out.Memories[0].Tags, "source:manual") diff --git a/pkg/brain/tools.go b/pkg/brain/tools.go index 307622f..38c6bc0 100644 --- a/pkg/brain/tools.go +++ b/pkg/brain/tools.go @@ -83,6 +83,7 @@ type Memory struct { SupersedesID string `json:"supersedes_id,omitempty"` SupersedesCount int `json:"supersedes_count,omitempty"` ExpiresAt string `json:"expires_at,omitempty"` + DeletedAt string `json:"deleted_at,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` } diff --git a/pkg/brain/tools_test.go b/pkg/brain/tools_test.go index ed2d53f..a3911c9 100644 --- a/pkg/brain/tools_test.go +++ b/pkg/brain/tools_test.go @@ -23,3 +23,9 @@ func TestTools_RecallInput_Good(t *testing.T) { input := RecallInput{Query: "error handling", TopK: 10} assert.Equal(t, 10, input.TopK) } + +func TestTools_Memory_Good(t *testing.T) { + memory := Memory{DeletedAt: "2026-04-01T00:00:00Z"} + + assert.Equal(t, "2026-04-01T00:00:00Z", memory.DeletedAt) +}