# Graph compatibility notes Checked against the original at `../orly` (`pkg/database/graph-*.go`, `pkg/database/save-event.go`, `pkg/database/delete-event.go` and `pkg/database/indexes/keys.go`), and morly's `pkg/store/index/keys.mx`. ## Matches - `pks`, `spk`, `epg`, `peg`, `eeg`, `gee`, `ppg`, `gpp` key prefixes, field order, widths and direction bytes. - Author edge `0`; outbound p-tag edge `1`; inbound reverse `2`. - E-tag out `0`, in `1`; pubkey-pubkey out `0`, in `1`. - Author and p-tag event→pubkey edges, the reverse pubkey→event edges, and the direct pubkey→pubkey edges written from every p-tag. - E-tag event→event edges only when the target event is stored, written in both directions. - `pp` traversal is a BFS over kind-3 `ppg`/`gpp` edges. - `pe` traversal is the original one-hop authored / p-tag-mention query. - `ee` is seeded from the events authored by the supplied pubkey. ## Intentional corrections - **Reverse p-tag deletion.** orly's `deleteGraphIndexes` copies the forward direction byte when constructing the reverse `peg` key, so a p-tag edge with direction 1 constructs another `peg` direction 1 instead of direction 2. torly constructs the actual reverse (`DirPTagIn`). - **`pe` result shape.** orly's executor puts event IDs into `pubkeys_by_depth` for outbound `pe`. torly always reports event IDs in `events_by_depth`. - **`ee` direction.** orly's executor passes `out`, `in` or `both` to `TraverseThread`, which only recognizes `outbound`, `inbound` or `both`; consequently its `out` and `in` return nothing. torly maps `out` to `eeg`, `in` to `gee`, and `both` to the union. - **Complete kind coverage.** orly's `GetEventsByAuthor` and `GetEventsReferencingPubkey` use a short common-kind list when no kinds are requested. torly scans all kinds. ## Deliberate differences - Events with more than **256** `p`/`e` tags are not graph-indexed at all. Truncating them would silently change the graph, so they contribute no author, p-tag or e-tag edges. They remain stored and queryable through the normal NIP-01 indexes. - `ee` treats every event authored by the seed as a root and excludes all of them from the response. orly excludes only the current root, so an authored event referenced by another root can appear in its result. - torly backfills an e-tag edge when a reply is stored before its root. orly only creates the edge if the target already exists. - A graph response is sorted per depth for deterministic output; orly emits discovery order. The deployed orly relay currently reports `graph queries not supported on this relay` because its graph executor is not initialized, so runtime comparison of `_graph` was not possible against that instance; the comparison above is against the source implementation.