feat: knowledge-graph service + observe identity provenance (and a buildable main) - #5
Merged
Merged
Conversation
…ests Lands the staged SDK parity work that has been sitting uncommitted. This is not optional cleanup: `main` does not currently compile. MemMeshClient and MemoryService reference RequestOptions, MemMeshException, SeekPage<>, RequestInterceptor/ResponseInterceptor, and six service classes that exist only in these files — 25 CS0246 errors on a clean checkout. Splits the monolithic Services.cs into per-service files (Alerts, Brains, Consent, Events, Financial, Lattice, Typed), adds Errors.cs, Pagination.cs, and RequestOptions.cs, plus an xunit suite with a stubbed HttpMessageHandler. 103 tests pass.
Parity with @memmesh/sdk v0.9.0 (thinkfleet-memory-sdk#21). New `mm.Graph` — StatsAsync, ListEntitiesAsync, GetEntityAsync, ListEdgesAsync, TraverseAsync. There was no graph surface before, so the structural half of memory was unreachable from .NET. Edges deserialize as GraphTraversalEdge, the shape the read routes actually return: Subject and Object are hydrated entities, not ids, plus a Hop counter. The raw memory_edge row is not modelled — no read route returns it. Modelling it that way failed outright in the Rust port. Query values are percent-encoded via a small QueryString builder. An unescaped `&` in a search filter would truncate it server-side and quietly return the wrong page. ObserveAsync gains userId / agentId / sessionId. The server route has always accepted them; the SDK was dropping them, so provenance never arrived. Added only when set, so existing call sites send identical bodies. They are provenance, NOT a tenancy boundary. Verified live against app.memmesh.ai — 12142 entities / 287698 edges, decoding NVIDIA CORP -[reported_metric]-> Cost of Revenue. 113 tests pass.
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.
.NET parity with
@memmesh/sdkv0.9.0 — seethinkfleet-memory-sdk#21.
Commit 1 —
mainis broken; this restores itA clean checkout of
mainfails with 25CS0246errors.MemMeshClientand
MemoryServicereferenceRequestOptions,MemMeshException,SeekPage<>,RequestInterceptor/ResponseInterceptor, and six service classes that existonly as untracked files on a developer machine — 3,069 lines of staged parity
work that had never been committed.
That commit lands it as-is: Services.cs split into per-service files (Alerts,
Brains, Consent, Events, Financial, Lattice, Typed), plus Errors.cs,
Pagination.cs, RequestOptions.cs, an xunit suite with a stubbed
HttpMessageHandler, and the publish workflow. 103 tests pass.I did not author this and have not reviewed it line by line — I verified only
that it builds and that its tests pass. If it was being held back
deliberately, drop commit 1 and this PR needs rebasing onto whatever does fix
the build.
Commit 2 — the actual feature
New:
mm.GraphStatsAsync()GET /admin/memory/graph/statsListEntitiesAsync(..)GET /admin/memory/entitiesGetEntityAsync(id, ..)GET /admin/memory/entities/:idListEdgesAsync(..)GET /admin/memory/graph/edgesTraverseAsync(id, ..)POST /admin/memory/graph/traverseUse
StatsAsync(), not(await ListEntitiesAsync()).Countfor any "how bigis it" question. The list routes page, so their length is the page size —
against a real project, 1,000 vs the actual 12,142.
Edges come back hydrated
ListEdgesAsync,TraverseAsync, andGetEntityAsync().Edgesreturn theserver's
GraphTraversalEdge:SubjectandObjectare full entities, notids, plus a
Hopcounter. NosubjectId/objectIdon the wire. The rawmemory_edgerow is deliberately not modelled — no read route returns it.This bit for real in the Rust port (
missing field 'subjectId') and wassilently wrong in the TypeScript PR before being fixed there.
Hopis 0 fromListEdgesAsync(no seed) and 1-indexed fromTraverseAsync.ObserveAsyncforwards identityuserId/agentId/sessionIdnow reach the server. The route has alwaysaccepted them; the SDK was dropping them. Added only when set, so existing
call sites send identical bodies (
Observe_text_omits_identity_when_unset).Provenance, not a tenancy boundary — search filters
chatIdentityId IS NULL OR = $1, permissive by design.Query encoding
Filter values go through
Uri.EscapeDataString. An unescaped&in asearchstring would truncate the query server-side and quietly return the wrong page.
Verification
app.memmesh.ai: 12,142 entities / 287,698 edges,decoding
NVIDIA CORP -[reported_metric]-> Cost of Revenueand theliteral-object case
NVIDIA CORP -[ticker_symbol]-> NVDA.