From e610e253efc4bb279f223143378a17949934e621 Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Fri, 17 Apr 2026 20:38:38 +0200 Subject: [PATCH] fix(brain): pass type and domain fields to ingestion write endpoint The write handler was building a hand-rolled map that dropped the type and domain fields from writeArgs. Pass the struct directly so all fields reach the ingestion server. Strengthen the test to assert the request body contains the type field. Co-Authored-By: Claude Sonnet 4.6 --- internal/skills/brain/handlers.go | 5 +---- internal/skills/brain/handlers_test.go | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/skills/brain/handlers.go b/internal/skills/brain/handlers.go index f92a99a..fb7584e 100644 --- a/internal/skills/brain/handlers.go +++ b/internal/skills/brain/handlers.go @@ -56,10 +56,7 @@ func (s *Skill) write(ctx context.Context, args json.RawMessage) (json.RawMessag if a.Content == "" { return nil, fmt.Errorf("content is required") } - return s.post(ctx, "/write", map[string]string{ - "content": a.Content, - "filename": a.Filename, - }) + return s.post(ctx, "/write", a) } func (s *Skill) post(ctx context.Context, path string, body any) (json.RawMessage, error) { diff --git a/internal/skills/brain/handlers_test.go b/internal/skills/brain/handlers_test.go index 7d87d54..7df6028 100644 --- a/internal/skills/brain/handlers_test.go +++ b/internal/skills/brain/handlers_test.go @@ -41,6 +41,10 @@ func TestHandle_BrainQuery_CallsIngestServer(t *testing.T) { func TestHandle_BrainWrite_CallsIngestServer(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/write", r.URL.Path) + var body map[string]string + require.NoError(t, json.NewDecoder(r.Body).Decode(&body)) + assert.Equal(t, "concept", body["type"]) + assert.Equal(t, "# Test\n\nSome learning.", body["content"]) json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"}) })) defer srv.Close()