From 9eaa1a2c1e995a93c960415d8ef93c0e884c380c Mon Sep 17 00:00:00 2001 From: elpresidank Date: Thu, 4 Jun 2026 06:44:34 -0500 Subject: [PATCH] Use Effect fn for FalkorDB helpers --- ts/EFFECT_NATIVE_REWRITE_AUDIT.md | 21 ++++++++ .../flow/src/query/triples/falkordb.ts | 50 ++++++++----------- .../flow/src/storage/triples/falkordb.ts | 5 +- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/ts/EFFECT_NATIVE_REWRITE_AUDIT.md b/ts/EFFECT_NATIVE_REWRITE_AUDIT.md index 9af0c5db..bf0d8486 100644 --- a/ts/EFFECT_NATIVE_REWRITE_AUDIT.md +++ b/ts/EFFECT_NATIVE_REWRITE_AUDIT.md @@ -2028,6 +2028,27 @@ Notes: - `cd ts && bun run lint` - `git diff --check` +### 2026-06-04: FalkorDB Effect.fn Helper Slice + +- Status: migrated and package-verified. +- Completed: + - `ts/packages/flow/src/query/triples/falkordb.ts` now defines reusable + connection, pattern-match, and query helper programs with `Effect.fn` or + `Effect.fnUntraced` instead of arrow functions returning `Effect.gen`. + - `ts/packages/flow/src/storage/triples/falkordb.ts` now uses a named + `Effect.fn` for its connection helper, matching the existing scoped + acquisition/finalizer boundary. + - The public Promise facades and scoped layer acquisition behavior are + unchanged; this slice only removes repeated helper generator construction. + - The focused scan for FalkorDB helper `=> Effect.gen` patterns is clean. +- Verification: + - `cd ts/packages/flow && bunx --bun vitest run src/__tests__/falkordb-lifecycle.test.ts` + - `cd ts && bun run check:tsgo` + - `cd ts && bun run build` + - `cd ts && bun run test` + - `cd ts && bun run lint` + - `git diff --check` + ## Subagent Findings To Preserve - MCP/workbench: diff --git a/ts/packages/flow/src/query/triples/falkordb.ts b/ts/packages/flow/src/query/triples/falkordb.ts index 0ea23ca3..6ad9ba1c 100644 --- a/ts/packages/flow/src/query/triples/falkordb.ts +++ b/ts/packages/flow/src/query/triples/falkordb.ts @@ -126,10 +126,9 @@ const resolveFalkorDBQueryConfig = Effect.fn("FalkorDBTriplesQuery.resolveConfig }; }); -const connectFalkorDBTriplesQuery = ( +const connectFalkorDBTriplesQuery = Effect.fn("FalkorDBTriplesQuery.connect")(function* ( config: FalkorDBQueryConfig, -): Effect.Effect => - Effect.gen(function* () { +) { const { url, database } = yield* resolveFalkorDBQueryConfig(config); const clientFactory = config.clientFactory; const graphFactory = config.graphFactory; @@ -209,15 +208,14 @@ const queryRows = ( Effect.map((result) => result.data ?? []), ); -const matchPattern = ( +const matchPattern = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], sv: string, pv: string, ov: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { for (const destType of ["Literal", "Node"] as const) { const destKey = destType === "Literal" ? "value" : "uri"; const rows = yield* queryRows( @@ -233,14 +231,13 @@ const matchPattern = ( } }); -const matchSP = ( +const matchSP = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], sv: string, pv: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { const litRows = yield* queryRows( graph, "match-sp-literal", @@ -264,14 +261,13 @@ const matchSP = ( } }); -const matchSO = ( +const matchSO = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], sv: string, ov: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { for (const [destType, destKey] of [["Literal", "value"], ["Node", "uri"]] as const) { const rows = yield* queryRows( graph, @@ -286,14 +282,13 @@ const matchSO = ( } }); -const matchPO = ( +const matchPO = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], pv: string, ov: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { for (const [destType, destKey] of [["Literal", "value"], ["Node", "uri"]] as const) { const rows = yield* queryRows( graph, @@ -308,13 +303,12 @@ const matchPO = ( } }); -const matchS = ( +const matchS = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], sv: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { const litRows = yield* queryRows( graph, "match-s-literal", @@ -338,13 +332,12 @@ const matchS = ( } }); -const matchP = ( +const matchP = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], pv: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { const litRows = yield* queryRows( graph, "match-p-literal", @@ -368,13 +361,12 @@ const matchP = ( } }); -const matchO = ( +const matchO = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], ov: string, limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { for (const [destType, destKey] of [["Literal", "value"], ["Node", "uri"]] as const) { const rows = yield* queryRows( graph, @@ -389,12 +381,11 @@ const matchO = ( } }); -const matchAll = ( +const matchAll = Effect.fnUntraced(function* ( graph: FalkorDBQueryGraph, out: [string, string, string][], limit: number, -): Effect.Effect => - Effect.gen(function* () { +) { const litRows = yield* queryRows( graph, "match-all-literal", @@ -416,14 +407,13 @@ const matchAll = ( } }); -const queryTriplesEffect = ( +const queryTriplesEffect = Effect.fn("FalkorDBTriplesQuery.queryTriplesInternal")(function* ( getConnection: () => Effect.Effect, s: Term | undefined, p: Term | undefined, o: Term | undefined, limit: number, -): Effect.Effect, FalkorDBTriplesQueryError> => - Effect.gen(function* () { +) { const { graph } = yield* getConnection(); const sv = termToValue(s); const pv = termToValue(p); diff --git a/ts/packages/flow/src/storage/triples/falkordb.ts b/ts/packages/flow/src/storage/triples/falkordb.ts index 576b7f37..39cec4b1 100644 --- a/ts/packages/flow/src/storage/triples/falkordb.ts +++ b/ts/packages/flow/src/storage/triples/falkordb.ts @@ -164,10 +164,9 @@ const resolveFalkorDBStoreConfig = Effect.fn("FalkorDBTriplesStore.resolveConfig }; }); -const connectFalkorDBTriplesStore = ( +const connectFalkorDBTriplesStore = Effect.fn("FalkorDBTriplesStore.connect")(function* ( config: FalkorDBConfig, -): Effect.Effect => - Effect.gen(function* () { +) { const { url, database } = yield* resolveFalkorDBStoreConfig(config); const clientFactory = config.clientFactory; const graphFactory = config.graphFactory;