Normalize flow service runtime entrypoints

This commit is contained in:
elpresidank 2026-06-02 01:13:40 -05:00
parent 0da0df81c4
commit ba64fc5add
5 changed files with 51 additions and 23 deletions

View file

@ -12,14 +12,14 @@ Verified source roots:
- 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 KnowledgeCore
ref-backed state slice:
Current signal counts from `ts/packages` after the 2026-06-02
flow-manager/librarian runtime normalization slice:
| Signal | Count |
| --- | ---: |
| `Effect.runPromise` | 200 |
| `Map<` | 72 |
| `WebSocket` | 51 |
| `Effect.runPromise` | 198 |
| `Map<` | 71 |
| `WebSocket` | 47 |
| `new Map` | 53 |
| `toPromiseRequestor` | 0 |
| `makeAsyncProcessor` | 19 |
@ -196,6 +196,25 @@ Notes:
- `cd ts && bun run build`
- `cd 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.ts` and
`ts/packages/flow/src/librarian/service.ts` now expose `runMain()` through
`NodeRuntime.runMain`.
- Their legacy `run()` Promise facades now use `ManagedRuntime` instead of
directly owning `Effect.runPromise`.
- `ts/scripts/run-flow-manager.ts` and `ts/scripts/run-librarian.ts` now
delegate to `runMain()` instead of wrapping startup with local
`.catch(console.error/process.exit)` handlers.
- Verification:
- `bun run --cwd ts/packages/flow build`
- `cd ts && bun run check`
- `cd ts && bun run build`
- `cd ts && bun run test`
- `git diff --check`
## Subagent Findings To Preserve
- MCP/workbench:
@ -206,10 +225,11 @@ Notes:
- MCP env is now Config-backed; continue that policy for future MCP settings.
- Flow stateful services:
- Config service and KnowledgeCore service ref-backed state are complete.
Librarian and flow-manager still have mutable poller service objects.
These remain good
candidates for `Context` services,
scoped layers, `Ref`/`SynchronizedRef`, `Schedule`, and managed
Librarian and flow-manager now have native Effect module startup
(`NodeRuntime.runMain` with `ManagedRuntime` compatibility facades), but
they still have mutable poller service objects. These remain good
candidates for `Context` services, scoped layers,
`Ref`/`SynchronizedRef`, `Schedule`, and managed
persistence.
- Persistence IO should move toward `FileSystem` or `KeyValueStore` where
the installed beta has the needed provider surface.

View file

@ -26,7 +26,8 @@ import {
} from "@trustgraph/base";
import { makeProcessorProgram } from "@trustgraph/base";
import type { Message } from "@trustgraph/base";
import { Context, Duration, Effect, Option } from "effect";
import { NodeRuntime } from "@effect/platform-node";
import { Context, Duration, Effect, Layer, ManagedRuntime, Option } from "effect";
import * as S from "effect/Schema";
// ---------- Internal state types ----------
@ -885,6 +886,12 @@ export const program = makeProcessorProgram({
make: (config) => makeFlowManagerService(config),
});
const flowManagerRuntime = ManagedRuntime.make(Layer.empty);
export function run(): Promise<void> {
return Effect.runPromise(program);
return flowManagerRuntime.runPromise(program);
}
export function runMain(): void {
NodeRuntime.runMain(program);
}

View file

@ -25,7 +25,8 @@ import {
type ProcessingMetadata,
} from "@trustgraph/base";
import type { Message } from "@trustgraph/base";
import { Clock, Config, Context, DateTime, Duration, Effect, Random } from "effect";
import { NodeRuntime } from "@effect/platform-node";
import { Clock, Config, Context, DateTime, Duration, Effect, Layer, ManagedRuntime, Random } from "effect";
import * as S from "effect/Schema";
import { makeCollectionManager } from "./collection-manager.js";
import {
@ -1349,6 +1350,12 @@ export const program = makeProcessorProgram({
make: (config) => makeLibrarianService(config),
});
const librarianRuntime = ManagedRuntime.make(Layer.empty);
export function run(): Promise<void> {
return Effect.runPromise(program);
return librarianRuntime.runPromise(program);
}
export function runMain(): void {
NodeRuntime.runMain(program);
}

View file

@ -6,9 +6,6 @@
* Env:
* NATS_URL (default: nats://localhost:4222)
*/
import { run } from "../packages/flow/src/flow-manager/service.js";
import { runMain } from "../packages/flow/src/flow-manager/service.js";
run().catch((err) => {
console.error("Flow manager failed:", err);
process.exit(1);
});
runMain();

View file

@ -7,9 +7,6 @@
* NATS_URL (default: nats://localhost:4222)
* LIBRARIAN_DATA_DIR (optional, e.g., ./data/librarian)
*/
import { run } from "../packages/flow/src/librarian/service.js";
import { runMain } from "../packages/flow/src/librarian/service.js";
run().catch((err) => {
console.error("Librarian service failed:", err);
process.exit(1);
});
runMain();