fix(graph): model the edge read routes' actual hydrated shape - #22
Merged
Conversation
`listEdges`, `traverse`, and `getEntity().edges` do not return the raw `memory_edge` row. They return the server's `GraphTraversalEdge`: `subject` and `object` are fully hydrated entities rather than ids, plus a `hop` counter — and there is no `subjectId`, `objectId`, or `brainId` on the wire at all. Caught by running the Rust port against production, where strict decoding failed with `missing field 'subjectId'`. TypeScript's structural typing hid it — the call compiled and then handed back objects whose declared fields were all undefined at runtime. Drops the raw-row `MemoryEdge` type rather than keeping it alongside. No read route returns that shape, and a type nothing returns is a trap. `hop` is 0 from `listEdges` (no seed) and 1-indexed from `traverse`. Verified live: NVIDIA CORP -[reported_metric]-> Cost of Revenue, decoded through the corrected type.
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.
Follow-up to #21. The squash-merge of that PR did not include this fix, so
maincurrently ships aMemoryEdgetype that does not match anything the APIreturns.
The bug
listEdges(),traverse(), andgetEntity().edgesdo not return the rawmemory_edgerow. They return the server'sGraphTraversalEdge:{ "id": "g1", "subject": { "id": "e1", "canonicalName": "NVIDIA CORP", ... }, "predicate": "reported_metric", "object": { "id": "e2", "canonicalName": "Cost of Revenue", ... }, "objectLiteral": null, "weight": 0.85, "hop": 0 }subjectandobjectare fully hydrated entities, not ids. There is nosubjectId,objectId, orbrainIdon the wire at all — which is exactly whatthe shipped
MemoryEdgedeclares.How it was found
By running the Rust port of the same surface against production, where strict
decoding failed outright:
TypeScript's structural typing hid it completely — the call compiles, the
request succeeds, and you get back objects whose every declared field is
undefinedat runtime. Anyone readingedge.subjectIdgetsundefinedand noerror.
The change
Replaces
MemoryEdgewithGraphTraversalEdge, matching the server type name.The raw row shape is dropped rather than kept alongside: no read route returns
it, and a type nothing returns is a trap.
hopis documented for what it actually does — 0 fromlistEdges(no seed),1-indexed from
traverse.Verification
Typecheck and build clean, and verified against
app.memmesh.ai— the correctedtype decodes real edges:
The Python (#5), Rust (#5), .NET (#5), and Go (#5) PRs all carry the corrected
shape already, so merging this brings TypeScript back in line with the other
four.