mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 01:19:38 +02:00
32 KiB
32 KiB
TrustGraph Effect-Native Rewrite Opportunity Audit
This is the current backlog snapshot for the playbook in
ts/EFFECT_NATIVE_REWRITE_PLAYBOOK.md. The branch is ts-port-effect-v4.
The unrelated local file .idea/effect.intellij.xml must stay uncommitted.
Inputs
Verified source roots:
- TrustGraph TS port:
/home/elpresidank/YeeBois/dev/trustgraph/ts - Effect v4 subtree:
/home/elpresidank/YeeBois/projects/beep-effect2/.repos/effect-v4 - Installed Effect beta used by this workspace:
ts/node_modules/effect
Current signal counts from ts/packages after the 2026-06-02 Text completion
stream sentinel slice:
| Signal | Count |
|---|---|
Effect.runPromise |
169 |
Map< |
88 |
WebSocket |
72 |
new Map |
62 |
toPromiseRequestor |
0 |
makeAsyncProcessor |
19 |
receive( |
18 |
while ( |
9 |
new Error |
8 |
new Promise |
10 |
JSON.parse |
4 |
localStorage |
8 |
JSON.stringify |
6 |
setTimeout |
4 |
process.env |
3 |
Notes:
- The remaining
process.envhits are inpackages/workbench/playwright.config.ts. - In production
packages/base,packages/cli, andpackages/mcpsources, the strict scans fornew Error,new Promise,setTimeout,JSON.parse,JSON.stringify, and directprocess.envreads are clean. Effect.runPromiseis expected at external Promise compatibility boundaries, but each match should still be audited for avoidable internal runtime ownership.- The
Map<andnew Mapcounts increased in this snapshot because the Librarian slice introduced explicit ref-backed state types and clone helpers while removing the service object's direct mutable maps/handles. - The
Effect.runPromiseandWebSocketcounts dropped in this snapshot becauseEffectRpcClientnow owns its RPC/socket layer withManagedRuntimeand uses Effect's WebSocket constructor layer. - The raw
WebSocketcount increased in this snapshot because the adapter slice added focused tests and typed adapter names; productionwebsocket-adapter.tsis now clean oftry/catch, normalError, and the previous constructor assertions. - The
new Errorcount dropped becausewebsocket-adapter.tsnow throwsS.TaggedErrorClassadapter errors. - The latest client socket slice removed the remaining production
trustgraph-socket.tsnormalError, rawJSON.parse, and listenertry/catchmatches. The remaining client socket modernization signal is the sharednewableFactoryconstructor assertion pattern. - The service entrypoint runtime slice dropped the
Effect.runPromisecount by replacing remaining flow servicerun()program facades withManagedRuntimeand routing localts/scripts/run-*launchers throughrunMain()/NodeRuntime.runMain. - The base processor compatibility runtime slice dropped the
Effect.runPromisecount again by movingAsyncProcessor,Flow, andFlowProcessorPromise compatibility facades ontoManagedRuntime. - The base flow definition schema slice removed hand-rolled
Predicate/object narrowing fromflow-processor.ts; signal counts are unchanged because this was a validation-quality migration. - The text completion stream sentinel slice removed the duplicated
Effect.void as Effect.Effect<undefined>assertions from provider stream unfold branches. Counts are unchanged because this was an Effect diagnostic and type-channel cleanup. Record<string, any>andthrowLibrarianServiceErrorare now clean ints/packages.
Loop Passes
2026-06-02: Base Request/Response Facade
- Status: migrated and verified.
- Completed:
- Request/response startup now owns a scoped Effect runtime handle and maps failures to TrustGraph tagged messaging errors.
- Runtime shutdown is idempotent and uses scoped fibers.
- Tests cover Promise compatibility, tagged timeout errors, and tagged lifecycle errors.
- Verification:
bun run --cwd ts/packages/base testbun run --cwd ts/packages/base buildbun run --cwd ts check:tsgobun run --cwd ts buildbun run --cwd ts test
2026-06-02: Gateway Dispatcher Requestor Cache
- Status: migrated and package-verified.
- Completed:
- Gateway dispatcher caches scoped
EffectRequestResponsehandles instead ofPromise<RequestResponse>values. - Lazy requestor creation is serialized with
SynchronizedRef.modifyEffect. - Streaming final-marker detection is centralized.
- Dispatcher cleanup uses Effect scope/error handling instead of manual
try/catch.
- Gateway dispatcher caches scoped
- Verification:
bun run --cwd ts/packages/flow testbun run --cwd ts/packages/flow buildbun run --cwd ts check:tsgo
2026-06-02: Strict Base, CLI, MCP, And tsgo Slice
- Status: migrated, root-verified, committed, and pushed.
- Completed:
- Base messaging, NATS backend, producer, consumer, subscriber,
request/response, runtime factories, processor programs, flow specs, and
LLM service now use Effect-native boundaries, schema codecs, scoped
cleanup, and
S.TaggedErrorClass.make(...)errors. - CLI commands now run Effect programs at the command boundary, wrap socket
lifecycle with
Effect.acquireUseRelease, encode JSON through Effect Schema, and write output withoutconsole.log. - MCP Effect server now loads env/config through
Config, wraps gateway calls withEffect.tryPromise, constructs schema classes with.make, and uses tagged errors. - MCP stdio compatibility server keeps
createMcpServerandrun, but uses Effect callbacks/tryPromise/schema encoding internally.run()usesManagedRuntime;runMain()usesNodeRuntime.runMain. - Flow stateful service launch sites now pass an explicit
Context.Contextinto the base processor runtime instead of hiding requirements behind assertions.
- Base messaging, NATS backend, producer, consumer, subscriber,
request/response, runtime factories, processor programs, flow specs, and
LLM service now use Effect-native boundaries, schema codecs, scoped
cleanup, and
- Verification:
cd ts && bun run checkcd ts && bun run testcd ts && bun run buildgit diff --check
2026-06-02: ConfigService Ref-Backed State Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/config/service.tsnow models runtime state as aSynchronizedRef<ConfigServiceState>instead of adding mutablestore,version, consumer, and producer fields onto the processor object.- Config operations have Effect-returning handlers with Promise facades only on the exported compatibility methods.
- Request narrowing now uses
effect/Predicaterather than request-record type assertions. - Persistence remains schema-backed and now reads/writes snapshots from the ref-backed state.
- The consume loop now uses
Effect.whileLoop; the remainingconsumer.receive(2000)call is a pubsub boundary for this service. - Service startup now exposes
runMain()throughNodeRuntime.runMain. The legacyrun()Promise facade usesManagedRuntime, andts/scripts/run-config.tsdelegates directly torunMain()instead of owning its own catch/process-exit wrapper. - Config-service tests cover tagged invalid mutation errors, workspace persistence, legacy load, concurrent ref-backed mutations, and push publishing from the stored producer handle.
- Verification:
bun run --cwd ts/packages/flow buildbun run --cwd ts/packages/flow testcd ts && bun run checkcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: RAG And Agent Requestor Bridge Slice
- Status: migrated, root-verified, committed, and pushed.
- Completed:
ts/packages/flow/src/retrieval/graph-rag.tsandts/packages/flow/src/retrieval/document-rag.tsnow acceptEffectRequestResponseclients directly. The engines no longer adapt Effect requestors back to Promise requestors and then wrap those calls inEffect.tryPromise.ts/packages/flow/src/retrieval/graph-rag-service.tsandts/packages/flow/src/retrieval/document-rag-service.tsnow pass native flow requestors directly into the engines.ts/packages/flow/src/agent/react/tools.tsnow acceptsEffectRequestResponseclients directly for graph RAG, document RAG, triples, and MCP tool calls. Tool input narrowing uses Schema andeffect/Predicaterather than local request/response type assertions.ts/packages/flow/src/agent/react/service.tswires default and configured tools with native Effect requestors instead oftoPromiseRequestor.- Graph RAG, document RAG, and agent service startup now expose
runMain()throughNodeRuntime.runMain; their legacyrun()Promise facades useManagedRuntime. ts/scripts/run-graph-rag.ts,ts/scripts/run-document-rag.ts, andts/scripts/run-agent.tsnow delegate torunMain().
- Verification:
bun run --cwd ts/packages/flow buildbun run --cwd ts/packages/flow testcd ts && bun run checkcd ts && bun run buildcd ts && bun run test
2026-06-02: KnowledgeCore Ref-Backed State Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/cores/service.tsnow exposes a typedKnowledgeCoreServiceinstead ofAsyncProcessorRuntime & Record<string, any>.- Runtime state now lives in
SynchronizedRef<KnowledgeCoreServiceState>withkgCores,deCores, the request consumer, and response producer. - Knowledge operations now have Effect-returning handlers with Promise facades only on exported compatibility methods.
- Persistence now decodes legacy and current snapshot shapes with Effect
Schema and encodes JSON through Schema rather than raw
JSON.parse/JSON.stringifyplus assertions. - The consume loop now uses
Effect.whileLoop; the remainingconsumer.receive(2000)call is a pubsub boundary for this service. - The service exposes
runMain()throughNodeRuntime.runMain; legacyrun()usesManagedRuntime, andts/scripts/run-knowledge.tsdelegates torunMain(). ts/packages/base/src/schema/messages.tsnow models legacy hyphenated knowledge request/response aliases so the service can preserve the wire shape without response type assertions.- New knowledge-core tests cover ref-backed mutation, graph embedding alias responses, concurrent state updates, and legacy persistence loading.
- Verification:
bun run --cwd ts/packages/base buildbun run --cwd ts/packages/flow buildbun run --cwd ts/packages/flow testcd ts && bun run checkcd ts && bun run buildcd ts && bun run test
2026-06-02: Flow Manager And Librarian Runtime Normalization
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/flow-manager/service.tsandts/packages/flow/src/librarian/service.tsnow exposerunMain()throughNodeRuntime.runMain.- Their legacy
run()Promise facades now useManagedRuntimeinstead of directly owningEffect.runPromise. ts/scripts/run-flow-manager.tsandts/scripts/run-librarian.tsnow delegate torunMain()instead of wrapping startup with local.catch(console.error/process.exit)handlers.
- Verification:
bun run --cwd ts/packages/flow buildcd ts && bun run checkcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: FlowManager Ref-Backed State Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/flow-manager/service.tsnow exposes a typedFlowManagerServiceinstead ofAsyncProcessorRuntime & Record<string, any>.- Runtime state now lives in
SynchronizedRef<FlowManagerServiceState>withflows,blueprints, the request consumer, response producer, and config request client. - Flow operations now have Effect-returning handlers with Promise facades only on exported compatibility methods.
- Blueprint config loading now narrows runtime values before constructing
Blueprintrecords, replacing the priorparsed as Blueprintshortcut. start-flowandstop-flowmutate the flow map throughSynchronizedRef.modifyEffect, making duplicate checks and map updates atomic.- The consume loop now uses
Effect.whileLoop; the remainingconsumer.receive(2000)call is a pubsub boundary for this service. - New flow-manager tests cover tagged errors, ref-backed flow mutation, config push/delete requests, blueprint narrowing, duplicate concurrent starts, and message-level flow-error responses.
- Verification:
bun run --cwd ts/packages/flow test -- src/__tests__/flow-manager-service.test.tsbun run --cwd ts/packages/flow buildbun run --cwd ts/packages/flow testcd ts && bun run checkcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Librarian Schema And Assertion Cleanup Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/base/src/schema/messages.tsnow models librarian upload and stream request/response fields directly, instead of requiring service-sideas LibrarianResponsecasts for the existing wire protocol.ts/packages/flow/src/librarian/service.tsnow decodes persisted librarian state through a concreteS.fromJsonStringschema instead of a generic JSON decode plusas A.- Document metadata
metadatatriples now narrow through Schema decoding withOptionbefore being included in normalized metadata. - Upload, stream, and complete-upload request/response constructors now rely on the schema-modeled fields instead of local type assertions.
- New librarian tests cover modeled upload fields, concrete persisted-state loading, and schema-backed metadata triple normalization.
- Remaining:
- Resolved by the typed runtime loop and ref-backed state slices below.
- Verification:
bun run --cwd ts/packages/base buildbun run --cwd ts/packages/flow buildbun run --cwd ts/packages/flow test -- src/__tests__/librarian-service.test.tsbun run --cwd ts/packages/flow testcd ts && bun run checkcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Librarian Tagged Operation Helper Slice
- Status: migrated and root-verified.
- Completed:
- Removed the librarian
throwLibrarianServiceErrorhelper. get-document-metadata,list-children,upload-chunk,get-upload-status, andabort-uploadnow dispatch through local Effect-returning helpers that fail withLibrarianServiceError.- Compatibility methods for those operations now return Promise facades
backed by
Effect.runPromise. - The librarian tests now await the Promise compatibility facade for upload status.
- Removed the librarian
- Remaining:
- Resolved by the typed runtime loop and ref-backed state slices below.
- Verification:
bun run --cwd ts/packages/flow test -- src/__tests__/librarian-service.test.tsbun run --cwd ts/packages/flow buildcd ts && bun run checkbun run --cwd ts/packages/flow testcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Librarian Typed Runtime Loop Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/librarian/service.tsnow exposes a typedLibrarianServiceinterface instead ofAsyncProcessorRuntime & Record<string, any>.- Service construction now uses
makeAsyncProcessor<LibrarianServiceError>withrunEffect; the old method-bagrunoverride andas LibrarianServicecast are gone. - The librarian startup poller now uses
Effect.whileLoop. - The local operation helpers retrieve the initialized service through an Effect gate rather than closing over an unsafe partially built value.
- Remaining:
- Resolved by the ref-backed state slice below.
- Verification:
bun run --cwd ts/packages/flow buildcd ts && bun run checkbun run --cwd ts/packages/flow testcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Librarian Ref-Backed State Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/librarian/service.tsnow stores documents, processing records, upload sessions, collection manager, and pubsub handles inSynchronizedRef<LibrarianServiceState>.- Document, processing, upload, collection, persistence, load, and stop paths now read snapshots or mutate cloned maps/managers through the ref instead of writing fields on the service object.
- Upload chunk updates clone nested
UploadSession.chunksbefore replacing the upload map entry, avoiding mutable nested state hidden behind the ref. - Librarian response producers and consumers are read/nullified through ref-backed handles.
- Verification:
bun run --cwd ts/packages/flow buildbun run --cwd ts/packages/flow test -- src/__tests__/librarian-service.test.tscd ts && bun run checkbun run --cwd ts/packages/flow testcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Client RPC Managed Runtime Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/client/src/socket/effect-rpc-client.tsnow builds oneManagedRuntimefrom the RPC client layer instead of manually creating aScope, building the layer, and callingEffect.runPromisefor every operation.- RPC dispatch and stream dispatch continue to expose the existing
Promise-returning
EffectRpcClientfacade, but they run through the managed runtime and close withruntime.dispose(). - The Effect RPC socket path now consumes
Socket.layerWebSocketConstructorGlobalinstead of a duplicate local WebSocket constructor layer. - Dispatch payload construction now uses
DispatchPayload.make(...)so schema classes are not instantiated withnew. - Client socket logging and timestamp creation now use Effect
LoggerandClockinstead of direct console andDate.now()calls in the touched surface.
- Verification:
bun run --cwd ts/packages/client buildcd ts && bun run checkbun run --cwd ts/packages/client testcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Client WebSocket Adapter Error Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/client/src/socket/websocket-adapter.tsnow models host fallback failures withWebSocketAdapterErrorviaS.TaggedErrorClass.- Synchronous
getWebSocketConstructor()andgetRandomValues()facades keep their public signatures while usingResult.tryinstead of localtry/catchblocks. - Runtime predicates now narrow WebSocket constructor modules and crypto modules without the previous constructor/result type assertions.
- New adapter tests cover global WebSocket selection, optional
wsfallback, global crypto, typed crypto failure, and typed adapter errors.
- Verification:
bun run --cwd ts/packages/client buildbun run --cwd ts/packages/client test -- src/__tests__/websocket-adapter.test.tsbun run --cwd ts/packages/client testcd ts && bun run checkcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Client Socket Tagged Error And JSON Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/client/src/socket/trustgraph-socket.tsnow models socket API failures withTrustGraphSocketErrorviaS.TaggedErrorClass.- Flow/blueprint JSON response parsing now uses Schema decoding through
S.UnknownFromJsonStringinstead of rawJSON.parse. - Token-cost config JSON keeps the previous invalid-string fallback behavior while decoding through Schema/Option.
- Connection-state listener isolation now uses
Result.tryand typed socket errors instead of a localtry/catch. - Flow start, row embeddings, collection update, and response-error
failures now reject with tagged socket errors instead of normal
Error. - Flow API tests cover invalid JSON and response-error rejections.
- Verification:
bun run --cwd ts/packages/client buildbun run --cwd ts/packages/client test -- src/__tests__/flows-api.test.tscd ts && bun run checkbun run --cwd ts/packages/client testcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Client Newable Factory Compatibility Decision
- Status: documented no-op for the current loop.
- Evidence:
ts/packages/workbench/src/atoms/workbench.tsconstructsnew BaseApi(...).ts/packages/client/src/__tests__/flows-api.test.tsconstructsnew FlowsApi(...), and sibling API facades expose the same constructor shape.EffectRpcClientandBaseApialso preserve callable factory exports for compatibility with the vendored TrustGraph client shape.
- Decision:
- The remaining
newableFactory(... ) as unknown as NewableFactory<...>assertions in client socket files are TypeScript compatibility boundaries, not Effect error/requirement channel assertions and not replacements for an Effect primitive. - Removing them safely requires a deliberate public API redesign or explicit class implementations for every API facade, not a local Effect-native rewrite.
- The remaining
- Verification:
- Current client/root verification from the tagged error slice covers this no-op decision.
2026-06-02: Service Entrypoint Runtime Slice
- Status: migrated and root-verified.
- Completed:
- Remaining flow service
run(): Promise<void>program facades now useManagedRuntime.make(Layer.empty)instead of directEffect.runPromise(program). - Remaining flow service modules now expose
runMain()throughNodeRuntime.runMain(program). - Local
ts/scripts/run-*launchers for gateway, prompt, chunker, extractor, PDF decoder, embeddings, triples, graph/document embeddings, text-completion providers, and MCP tool service now delegate directly torunMain(). - Direct
Effect.runPromise(program)matches ints/packages/flow/srcare clean. RemainingEffect.runPromisematches are callback/Promise compatibility boundaries for later slices.
- Remaining flow service
- Verification:
bun run --cwd ts/packages/flow buildgit diff --checkcd ts && bun run checkbun run --cwd ts/packages/flow testcd ts && bun run buildcd ts && bun run test
2026-06-02: Base Processor Compatibility Runtime Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/base/src/processor/async-processor.tsnow uses aManagedRuntimefor Promise compatibility methods, signal-shutdown execution, and legacyAsyncProcessor.launch.ts/packages/base/src/processor/flow.tsnow owns a per-flowManagedRuntimeforstart,stop,runInCompatibilityScope, and Promise resource facades.ts/packages/base/src/processor/flow-processor.tsnow uses aManagedRuntimefor the publicstart(context)facade instead of a localEffect.runPromiseWithrunner.ts/packages/base/src/spec/parameter-spec.tsnow routes legacyaddthroughflow.runInCompatibilityScope(...), matching the other specs.- Subagent checks confirmed
NodeRuntimeis process-entrypoint-only here;@trustgraph/baseshould not add an@effect/platform-nodedependency for these compatibility facades.
- Remaining:
- Constructor
as unknown asshims in base processors preserve callable-plus-newable public exports and are compatibility boundaries for this loop. - Typed string lookup casts in
Flowneed a real typed-spec/key redesign;HashMap/MutableHashMapalone cannot inferTfrom a bare string.
- Constructor
- Verification:
bun run --cwd ts/packages/base buildbun run --cwd ts/packages/base testcd ts && bun run checkgit diff --checkcd ts && bun run buildcd ts && bun run test
2026-06-02: Base Flow Definition Schema Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/base/src/processor/flow-processor.tsnow validatesconfig.flowswith Effect Schema instead of localPredicate/object/string-record guards.- Invalid flow definition payloads still log/skip and preserve the existing config-handler and acknowledgement behavior.
ts/packages/base/src/__tests__/flow-processor-runtime.test.tsnow covers an invalid nested flow definition that is acknowledged without starting resources.
- Verification:
bun run --cwd ts/packages/base test -- src/__tests__/flow-processor-runtime.test.tsbun run --cwd ts/packages/base buildcd ts && bun run checkcd ts && bun run buildcd ts && bun run testgit diff --check
2026-06-02: Text Completion Stream Sentinel Slice
- Status: migrated and root-verified.
- Completed:
ts/packages/flow/src/model/text-completion/{ollama,openai,mistral,azure-openai,claude,openai-compatible}.tsnow return theStream.unfoldend sentinel withEffect.as(Effect.void, undefined).- Removed six
Effect.void as Effect.Effect<undefined>assertions without replacing them withEffect.succeed(undefined), which@effect/tsgoflags as a diagnostic.
- Verification:
bun run --cwd ts/packages/flow buildcd ts && bun run checkbun run --cwd ts/packages/flow testcd ts && bun run buildcd ts && bun run testgit diff --check
Subagent Findings To Preserve
- MCP/workbench:
- Make the Effect MCP server the canonical implementation. The old stdio server should remain only as compatibility while parity is needed.
- Workbench BaseApi atoms can move toward
AtomRpcorAtomHttpApiafter the client API is less Promise-first. - MCP env is now Config-backed; continue that policy for future MCP settings.
- Flow stateful services:
- Config service, KnowledgeCore service, FlowManager, and Librarian ref-backed state slices are complete. Follow-up service work should focus on scoped layers, schedules where polling semantics allow, and managed persistence providers rather than direct mutable service fields.
- Flow service startup facades now consistently use
ManagedRuntime, and local scripts should delegate torunMain()instead of adding local.catch(console.error/process.exit)wrappers. - Persistence IO should move toward
FileSystemorKeyValueStorewhere the installed beta has the needed provider surface.
- Base messaging/processors:
- Processor/flow Promise compatibility now uses
ManagedRuntime; keepNodeRuntimeonly for processrunMain()entrypoints. - Subscriber queues/maps and dynamic flow state should continue moving
toward
Queue,Deferred,SynchronizedRef,Schedule, and scoped layers. - Existing constructor shims preserve callable-plus-newable public exports; removing them needs a public API split or real class redesign.
- Typed string registries in
Flowneed schema-backed parameters and typed-spec/key accessors. EffectHashMap/MutableHashMapcan improve lookup ergonomics withOption, but it does not remove the string-key type hole by itself.
- Processor/flow Promise compatibility now uses
- Gateway/client:
EffectRpcClientnow owns its socket/RPC layer withManagedRuntime. Socket errors/JSON parsing now use tagged errors and Schema decoding. The remaining clientnewableFactoryassertions are documented as public API compatibility boundaries for this loop.- Knowledge streams still duplicate legacy end-of-stream handling.
- WebSocket adapter host fallbacks now use
Result.tryand tagged adapter errors while preserving sync exports.
- RAG/providers/storage:
- RAG and agent requestor bridges are complete:
toPromiseRequestorhas no remainingts/packagesmatches. - Provider SDKs and storage clients should become managed resources where they have meaningful lifecycle.
- FalkorDB/Qdrant/Ollama/OpenAI-compatible surfaces still need config, schema, and scope audits.
- RAG and agent requestor bridges are complete:
Ranked Findings
P1: Base Typed Spec Accessors
- TrustGraph evidence:
ts/packages/base/src/processor/flow.tsts/packages/base/src/spec/parameter-spec.tsts/packages/base/src/spec/producer-spec.tsts/packages/base/src/spec/request-response-spec.ts
- Effect primitives:
- Schema-backed registries,
Context,Layer,Effect.fn,Option,Predicate,HashMap/MutableHashMap.
- Schema-backed registries,
- Rewrite shape:
- Add schema-backed generic parameter specs and spec-object accessors such as
flow.parameterEffect(spec), then keep string accessors as compatibility escapes. - Add typed spec-object accessors for producers and requestors so call sites stop spelling generic string lookups.
- Do not add assertions to quiet Effect channel inference problems.
- Add schema-backed generic parameter specs and spec-object accessors such as
- Tests:
cd ts && bun run --cwd packages/base test- Root
cd ts && bun run checkbecause this surface easily pollutes Effect error and requirement channels.
P1: Make SDK, Storage, And Provider Layers Managed Resources
- TrustGraph evidence:
ts/packages/flow/src/storage/triples/falkordb.tsts/packages/flow/src/storage/embeddings/qdrant-graph.tsts/packages/flow/src/storage/embeddings/qdrant-doc.tsts/packages/flow/src/model/text-completion/*.tsts/packages/flow/src/embeddings/ollama.ts
- Effect primitives:
Effect.acquireRelease,Layer.scoped,Config,ConfigProvider,Metric,Logger, Effect AI provider layers.
- Rewrite shape:
- Move env/config reading into
Configloaders and provider-specific layers. - Scope SDK clients that need explicit close/disconnect.
- Move env/config reading into
- Tests:
- Provider config tests with
ConfigProvider.fromMap. - Storage tests with fake clients before changing real resource lifetimes.
- Provider config tests with
P2: Canonicalize MCP Around The Effect Server
- Status:
- First blocker slice complete: MCP now builds under strict tsgo and the stdio server has an Effect-backed compatibility implementation.
- Remaining shape:
- Decide whether the old SDK/Zod stdio compatibility surface should stay as a wrapper or be removed.
- Add parity tests before deleting any public entry point.
- Tests:
cd ts && bun run --cwd packages/mcp build- Root
cd ts && bun run check
P2: Tighten Workbench Platform And Reactivity Usage
- TrustGraph evidence:
ts/packages/workbench/src/atoms/workbench.ts- Remaining direct browser state includes
localStorageand DOM theme inspection.
- Effect primitives:
BrowserKeyValueStore.layerLocalStorage,BrowserKeyValueStore.layerSessionStorage,BrowserHttpClient,Clipboard,AtomRpc,AtomHttpApi,AtomRegistry,AsyncResult,Reactivity.
- Rewrite shape:
- Leave workbench out of the next backend/runtime rewrite wave.
- Move persistent UI state through browser platform services later.
- Tests:
cd ts && bun run workbench:qa
Recommended PR Order
- Base typed spec accessors.
- Gateway RPC callback and client streaming completion cleanup.
- Storage/provider managed resource cleanup.
- MCP parity/deletion decision and workbench platform polish.
No-Op Rules
Do not flag these as rewrite blockers without additional proof:
- Promise-returning CLI actions, MCP SDK callbacks, client compatibility methods, and Fastify route handlers at true external boundaries. Boundary code still must map failures into typed errors or wire errors.
try/catchblocks at host/tool boundaries only when the catch maps into a typed error or a wire-contract error. Internal exception capture should useEffect.try,Effect.tryPromise, orResult.try.S.Class,S.TaggedErrorClass,Context.Service,Rpc.make, andHttpApi.makewhen they are required or idiomatic for the Effect API.- Plain
Mapusage for local pure transformations, such as graph utility construction, unless the state is long-lived mutable service state. - JSON stringification in tests or wire-contract fixtures. Production JSON encode/decode should prefer schema codecs when the encoded form can be preserved.
- Client
newableFactoryassertions that preserve vendored callable-plus-new API facades are compatibility boundaries unless the public constructor API is intentionally redesigned. - Base
AsyncProcessor,Flow, andFlowProcessorcallable-plus-newable export assertions are compatibility boundaries unless the public constructor API is intentionally redesigned.
Acceptance For Final Loop Completion
The overall playbook loop is complete only when:
- All remaining playbook signal matches are migrated or documented as no-op external-boundary cases with concrete evidence.
- No P0/P1/P2 migration item remains in this audit.
cd ts && bun run check,cd ts && bun run build,cd ts && bun run test, andgit diff --checkpass after the final migration slice.