feat(engram): use POST /v1/engrams/search for semantic search#5
Merged
vthunder merged 5 commits intoengram-phase3-4from Feb 23, 2026
Merged
feat(engram): use POST /v1/engrams/search for semantic search#5vthunder merged 5 commits intoengram-phase3-4from
vthunder merged 5 commits intoengram-phase3-4from
Conversation
- Add GetTraceSummariesAll to graph/compression.go — returns all available pyramid levels for a trace (no fallback, exact match per level) - Add LocalTraceInfo struct + GetTraceInfo callback to MCP tools deps - Wire GetTraceInfo in main.go via graphDB (read-only, no LLM needed) - query_trace now augments Engram response with local done status and all available pyramid levels when GetTraceInfo callback is configured - Also commit entities.go valid_at fix: AddEntityRelationWithSource now uses COALESCE subquery to populate valid_at from source episode timestamp Completes Phase 4 query_trace item from trace-completion-pyramid-design.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When Claude inference detects "contradicts" relationships between episodes, those edges were previously fed into the clustering algorithm and caused contradicting episodes to merge into a single trace — silently discarding the conflict. This commit implements the conflict resolution pipeline: - Migration v22: adds has_conflict, conflict_with, conflict_with_at columns to traces table with idx_traces_has_conflict index - Trace struct: adds HasConflict, ConflictWith, ConflictResolvedAt fields (populated by all standard scanTrace/scanTraceRows queries) - graph.MarkTraceConflict: marks a trace as conflicting with another by short_id, builds CSV of conflict_with, idempotent re-marks - graph.GetTraceShortID: lightweight short_id lookup by trace ID - consolidate.Run: separates "contradicts" edges from regular edges before Phase 2 clustering — contradiction edges are still stored to DB for audit but excluded from the adjacency list, so contradicting episodes form separate traces - consolidate.markContradictionConflicts: after trace creation, looks up which traces the contradicting episodes landed in and marks both with has_conflict + conflict_with, deduplicating trace pairs - Tests: TestMarkTraceConflict covers marking, idempotency, and GetTraceShortID Phase 4 (retrieval: surface conflicting traces together in context) is a follow-up step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a conflicted trace is retrieved, its conflict partner(s) are now automatically included in the RetrievalResult at the same activation level. This ensures the executive sees both sides of a contradiction in context rather than silently surfacing only one claim. - Added injectConflictPartners() helper in activation.go - Called from both Retrieve() and RetrieveWithContext() after assembly, before the final activation-based sort - TestInjectConflictPartners: verifies injection, activation parity, and idempotency (no duplicate injection on second call) Step 4 of conflict-resolution-design.md. Steps 1-3 were in 90cbb15. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a conflicted trace is retrieved, context now shows both sides of the contradiction grouped together with a [CONFLICT] label so the executive can notice and ask for clarification. - focus.MemorySummary: add ShortID, HasConflict, ConflictWith fields - engram.Trace (HTTP client): add ShortID, HasConflict, ConflictWith for JSON deserialization - buildPrompt(): conflict-aware memory formatting — groups pairs, marks the later trace as "contradicts above", falls back to plain format if partner is absent from result set - buildprompt_test.go: 3 tests (conflict pair, normal trace, orphaned conflict) All 21 packages pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switch Client.Search() from GET /v1/engrams?query=... to POST /v1/engrams/search with a JSON body. This matches the updated Engram API design where query params are avoided for search requests that can carry arbitrarily large payloads. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Client.Search()to usePOST /v1/engrams/searchwith a JSON body instead ofGET /v1/engrams?query=...Depends on
Test plan
go test ./internal/engram/...passesTestSearchvalidates POST method, path/v1/engrams/search, and JSON body🤖 Generated with Claude Code