Use HashSet for gateway term service sets

This commit is contained in:
elpresidank 2026-06-04 05:34:15 -05:00
parent 0862250dab
commit 3a256096f8
2 changed files with 22 additions and 8 deletions

View file

@ -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<string>`. 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.

View file

@ -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;