From 3a256096f8e81ff0e9cfeef25fb1a5e4306d336f Mon Sep 17 00:00:00 2001 From: elpresidank Date: Thu, 4 Jun 2026 05:34:15 -0500 Subject: [PATCH] Use HashSet for gateway term service sets --- ts/EFFECT_NATIVE_REWRITE_AUDIT.md | 16 +++++++++++++++- .../flow/src/gateway/dispatch/serialize.ts | 14 +++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ts/EFFECT_NATIVE_REWRITE_AUDIT.md b/ts/EFFECT_NATIVE_REWRITE_AUDIT.md index c721ba46..29647fa2 100644 --- a/ts/EFFECT_NATIVE_REWRITE_AUDIT.md +++ b/ts/EFFECT_NATIVE_REWRITE_AUDIT.md @@ -420,6 +420,19 @@ Notes: - `bun run --cwd ts/packages/client test -- src/__tests__/rpc-timeout.test.ts` - `cd ts && bun run check:tsgo` +### 2026-06-04: Gateway Term Service HashSet Slice + +- Status: migrated and package-verified. +- Completed: + - `ts/packages/flow/src/gateway/dispatch/serialize.ts` now uses + `effect/HashSet` for static term-bearing request/response service + membership instead of native `Set`. + - Request and response translators preserve the same deep client/internal + term conversion behavior via `HashSet.has` membership checks. +- Verification: + - `bun run --cwd ts/packages/flow test -- src/__tests__/gateway-dispatcher.test.ts` + - `cd ts && bun run check:tsgo` + ### 2026-06-02: RAG And Agent Requestor Bridge Slice - Status: migrated, root-verified, committed, and pushed. @@ -1862,7 +1875,8 @@ Notes: - Qdrant graph/doc known-collection caches now use `MutableHashSet`. Short-lived local traversal sets remain no-ops. - Gateway dispatcher static service registries, streaming membership, and - scoped requestor cache now use Effect `HashMap`/`HashSet`. + scoped requestor cache now use Effect `HashMap`/`HashSet`; gateway + term-bearing service membership sets now use Effect `HashSet` too. - FlowManager `() => Effect.gen(...)` factories are normalized to `Effect.fn` / `Effect.fnUntraced`. Sibling service factories still need a focused scan before treating them as valid migration targets. diff --git a/ts/packages/flow/src/gateway/dispatch/serialize.ts b/ts/packages/flow/src/gateway/dispatch/serialize.ts index 2b756988..1ff6b239 100644 --- a/ts/packages/flow/src/gateway/dispatch/serialize.ts +++ b/ts/packages/flow/src/gateway/dispatch/serialize.ts @@ -29,7 +29,7 @@ import { type Term, type Triple, } from "@trustgraph/base"; -import { Effect, Match } from "effect"; +import { Effect, HashSet, Match } from "effect"; import * as O from "effect/Option"; import * as S from "effect/Schema"; @@ -251,23 +251,23 @@ function deepInternalToClient(value: unknown): unknown { * Services whose requests contain Term/Triple fields that need translation. * All other services pass through without term translation. */ -const TERM_BEARING_REQUEST_SERVICES = new Set([ +const TERM_BEARING_REQUEST_SERVICES = HashSet.make( "triples", "knowledge", "librarian", -]); +); /** * Services whose responses contain Term/Triple fields that need translation. */ -const TERM_BEARING_RESPONSE_SERVICES = new Set([ +const TERM_BEARING_RESPONSE_SERVICES = HashSet.make( "triples", "graph-embeddings", "knowledge", "librarian", "graph-rag", "agent", -]); +); // ---------- Top-level request / response translators ---------- @@ -280,7 +280,7 @@ const TERM_BEARING_RESPONSE_SERVICES = new Set([ * scalar fields (query strings, limits, etc.). */ export function translateRequest(service: string, body: unknown): unknown { - if (TERM_BEARING_REQUEST_SERVICES.has(service)) { + if (HashSet.has(TERM_BEARING_REQUEST_SERVICES, service)) { return deepClientToInternal(body); } return body; @@ -309,7 +309,7 @@ export const translateRequestEffect = ( * All other services pass through unchanged. */ export function translateResponse(service: string, response: unknown): unknown { - if (TERM_BEARING_RESPONSE_SERVICES.has(service)) { + if (HashSet.has(TERM_BEARING_RESPONSE_SERVICES, service)) { return deepInternalToClient(response); } return response;