Skip to content

feat(engram): use POST /v1/engrams/search for semantic search#5

Merged
vthunder merged 5 commits intoengram-phase3-4from
api/search-post
Feb 23, 2026
Merged

feat(engram): use POST /v1/engrams/search for semantic search#5
vthunder merged 5 commits intoengram-phase3-4from
api/search-post

Conversation

@vthunder
Copy link
Owner

Summary

  • Updates Client.Search() to use POST /v1/engrams/search with a JSON body instead of GET /v1/engrams?query=...
  • Removes query string handling from the GET path
  • All tests updated and passing

Depends on

Test plan

  • go test ./internal/engram/... passes
  • TestSearch validates POST method, path /v1/engrams/search, and JSON body

🤖 Generated with Claude Code

Dan Mills and others added 5 commits February 22, 2026 21:25
- 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>
@vthunder vthunder merged commit 9138cc4 into engram-phase3-4 Feb 23, 2026
@vthunder vthunder deleted the api/search-post branch February 23, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant