From a34b0233c82dd4299dbe242d7c8e97f29eafe428 Mon Sep 17 00:00:00 2001 From: Greg Konush <12027037+gregkonush@users.noreply.github.com> Date: Sun, 9 Aug 2026 17:26:38 -0700 Subject: [PATCH 1/3] build(bayn): make Effect TSGo the typecheck --- .github/workflows/bayn-ci.yml | 2 +- .../scripts/src/bayn/bayn-release-workflow.test.ts | 2 +- services/bayn/README.md | 3 +++ services/bayn/package.json | 3 +-- services/bayn/src/composition.ts | 9 +++++---- services/bayn/src/observe-composition.test.ts | 11 ++++++++--- services/bayn/tsconfig.json | 2 ++ 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/bayn-ci.yml b/.github/workflows/bayn-ci.yml index e43b61f63c..508100ec95 100644 --- a/.github/workflows/bayn-ci.yml +++ b/.github/workflows/bayn-ci.yml @@ -111,7 +111,7 @@ jobs: lint-command: bunx oxfmt --check services/bayn argocd/applications/bayn argocd/applications/torghut/clickhouse/bayn-sealed-secret.yaml argocd/applications/torghut/clickhouse/clickhouse-cluster.yaml oxlint-command: bun run --cwd services/bayn lint:oxlint oxlint-type-command: bun run --cwd services/bayn lint:oxlint:type - test-command: bun run --cwd services/bayn tsc && bun run --cwd services/bayn lint:effect && bun run --cwd services/bayn test && bun test packages/scripts/src/bayn + test-command: bun run --cwd services/bayn tsc && bun run --cwd services/bayn test && bun test packages/scripts/src/bayn build-command: bun run --cwd services/bayn build secrets: inherit diff --git a/packages/scripts/src/bayn/bayn-release-workflow.test.ts b/packages/scripts/src/bayn/bayn-release-workflow.test.ts index 5c6e080c28..2d2d4f6d73 100644 --- a/packages/scripts/src/bayn/bayn-release-workflow.test.ts +++ b/packages/scripts/src/bayn/bayn-release-workflow.test.ts @@ -35,7 +35,7 @@ test('keeps the existing Bayn PR gate aggregation', () => { expect(baynCiWorkflow).toContain(check) } expect(baynCiWorkflow).toContain( - 'test-command: bun run --cwd services/bayn tsc && bun run --cwd services/bayn lint:effect && bun run --cwd services/bayn test && bun test packages/scripts/src/bayn', + 'test-command: bun run --cwd services/bayn tsc && bun run --cwd services/bayn test && bun test packages/scripts/src/bayn', ) expect(baynCiWorkflow).not.toContain('verify-release-review') }) diff --git a/services/bayn/README.md b/services/bayn/README.md index 738cd75d17..0abd359fc7 100644 --- a/services/bayn/README.md +++ b/services/bayn/README.md @@ -161,6 +161,9 @@ credentials and writes no dossier. Later PREPARE/SUBMIT/CANCEL/RECOVER work rema ## Validation +`tsc` invokes the pinned Effect TSGo compiler directly, so TypeScript and configured Effect diagnostics run once and +share one failing exit boundary. + ```sh bun run --filter @proompteng/bayn test bun run --filter @proompteng/bayn tsc diff --git a/services/bayn/package.json b/services/bayn/package.json index fdb5694e58..96acaf060b 100644 --- a/services/bayn/package.json +++ b/services/bayn/package.json @@ -9,14 +9,13 @@ "forward:performance": "BAYN_PROVENANCE_MODE=development node dist/forward-performance-command.js", "start": "BAYN_PROVENANCE_MODE=development node dist/index.js", "lint": "bun ../../node_modules/oxfmt/bin/oxfmt --check src", - "lint:effect": "find ../../node_modules/.bun -path '*/@effect/tsgo-*/lib/tsc*' -type f ! -name '*.json' -exec chmod +x {} + 2>/dev/null || true; bun node_modules/@effect/tsgo/dist/effect-tsgo.js diagnostics --project tsconfig.json --format text --severity error", "lint:oxlint": "bun ../../node_modules/oxlint/bin/oxlint --config ../../.oxlintrc.json .", "lint:oxlint:type": "bun ../../node_modules/oxlint/bin/oxlint --config ../../.oxlintrc.json --type-aware --tsconfig ./tsconfig.json .", "test": "bun test", "test:broker-sandbox": "bun test src/broker-sandbox-contract.test.ts", "test:effect-runtime": "bun test src/clickhouse-patch.test.ts src/effect-runtime-compatibility.test.ts", "test:postgres": "bun test src/db/cycle-observability.integration.test.ts && bun test src/db/evidence-store.integration.test.ts && bun test src/db/paper-store.integration.test.ts && bun test src/db/cycle-store/integration.test.ts", - "tsc": "bun node_modules/typescript/bin/tsc --noEmit" + "tsc": "find ../../node_modules/.bun -path '*/@effect/tsgo-*/lib/tsc*' -type f ! -name '*.json' -exec chmod +x {} + 2>/dev/null || true; \"$(bun node_modules/@effect/tsgo/dist/effect-tsgo.js get-exe-path)\" --noEmit --project tsconfig.json" }, "dependencies": { "@clickhouse/client": "1.23.1", diff --git a/services/bayn/src/composition.ts b/services/bayn/src/composition.ts index 411fc274c7..d3a4f3ea35 100644 --- a/services/bayn/src/composition.ts +++ b/services/bayn/src/composition.ts @@ -167,6 +167,9 @@ export const BrokerSessionResourceLive = (config: Extract + Layer.merge(HttpServerLive(config), NodeHttpClient.layerNodeHttp) + const SignalMarketDataLive = (plan: ApplicationIdentity) => { const clickHouse = sqlResource(ClickHouseClientResourceLive(plan.config)) return MarketDataResourceLive(plan).pipe(Layer.provide(clickHouse)) @@ -178,24 +181,22 @@ const PostgresAuthorityLive = (config: LoadedRuntimeConfig) => export const BrokerlessApplicationResourcesLive = (plan: ApplicationPlanFor<'BrokerlessService'>) => { const postgres = PostgresAuthorityLive(plan.config) return Layer.mergeAll( - HttpServerLive(plan.config), SignalMarketDataLive(plan), postgres, JournalResourceLive(plan.config), CycleObservabilityResourceLive.pipe(Layer.provide(postgres)), - ).pipe(Layer.provideMerge(ApplicationPlatformLive)) + ).pipe(Layer.provideMerge(HttpApplicationPlatformLive(plan.config))) } export const AutonomousApplicationResourcesLive = (plan: ApplicationPlanFor<'AutonomousService'>) => { const postgres = PostgresAuthorityLive(plan.config) const journal = JournalResourceLive(plan.config) return Layer.mergeAll( - HttpServerLive(plan.config), SignalMarketDataLive(plan), postgres, journal, CycleObservabilityResourceLive.pipe(Layer.provide(postgres)), - ).pipe(Layer.provideMerge(ApplicationPlatformLive)) + ).pipe(Layer.provideMerge(HttpApplicationPlatformLive(plan.config))) } export const AutonomousRuntimeResourcesLive = (plan: ApplicationPlanFor<'AutonomousService'>) => { diff --git a/services/bayn/src/observe-composition.test.ts b/services/bayn/src/observe-composition.test.ts index 4272b941a1..80f1ed62c1 100644 --- a/services/bayn/src/observe-composition.test.ts +++ b/services/bayn/src/observe-composition.test.ts @@ -4693,16 +4693,21 @@ describe('OBSERVE runtime composition', () => { executionProgram, }) - const failure = await Effect.runPromise( - Effect.flip( + const exit = await Effect.runPromise( + Effect.exit( startup({ qualificationRunId: 'c'.repeat(64), recordPass: () => Effect.void, }), ), ) + expect(Exit.isFailure(exit)).toBe(true) + if (Exit.isSuccess(exit)) throw new Error('mismatched mutation startup unexpectedly succeeded') + const failure = Cause.findErrorOption(exit.cause) + expect(Option.isSome(failure)).toBe(true) + if (Option.isNone(failure)) throw new Error('mismatched mutation startup failed without a typed cause') - expect(failure).toMatchObject({ + expect(failure.value).toMatchObject({ _tag: 'OperationalError', component: 'config', operation: 'cycle-loop', diff --git a/services/bayn/tsconfig.json b/services/bayn/tsconfig.json index a2a137150d..5974576fee 100644 --- a/services/bayn/tsconfig.json +++ b/services/bayn/tsconfig.json @@ -9,6 +9,8 @@ "name": "@effect/language-service", "diagnostics": true, "includeSuggestionsInTsc": false, + "ignoreEffectErrorsInTscExitCode": false, + "ignoreEffectWarningsInTscExitCode": false, "diagnosticSeverity": { "anyUnknownInErrorContext": "error", "globalDateInEffect": "error", From 2f349d0c562306c268710974572c2a44d2bd76f7 Mon Sep 17 00:00:00 2001 From: Greg Konush <12027037+gregkonush@users.noreply.github.com> Date: Sun, 9 Aug 2026 17:34:48 -0700 Subject: [PATCH 2/3] fix(bayn): retain Node platform services --- services/bayn/src/composition.test.ts | 11 ++++++++++- services/bayn/src/composition.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/services/bayn/src/composition.test.ts b/services/bayn/src/composition.test.ts index 92833346fc..ec68c1db13 100644 --- a/services/bayn/src/composition.test.ts +++ b/services/bayn/src/composition.test.ts @@ -1,9 +1,10 @@ import { describe, expect, test } from 'bun:test' -import { Deferred, Effect, Fiber, Ref, Result } from 'effect' +import { Context, Deferred, Effect, Fiber, FileSystem, Layer, Ref, Result } from 'effect' import { TestClock } from 'effect/testing' import { + ApplicationPlatformLive, closedCycleReceiptEmissionAllowed, finalizePaperEpisode, paperReceiptFinalizationWindowOpen, @@ -55,6 +56,14 @@ const researchRequest = Result.getOrThrow( }), ) +describe('Bayn application platform', () => { + test('provides filesystem access for TLS-backed PostgreSQL acquisition', async () => { + const context = await Effect.runPromise(Effect.scoped(Layer.build(ApplicationPlatformLive))) + + expect(Context.get(context, FileSystem.FileSystem)).toBeDefined() + }) +}) + describe('Bayn PAPER receipt retry boundary', () => { test('does not bind a generation receipt before its PAPER entry cutoff', () => { const cutoffAt = '2026-08-03T12:00:00.000Z' diff --git a/services/bayn/src/composition.ts b/services/bayn/src/composition.ts index d3a4f3ea35..7ef8d7188b 100644 --- a/services/bayn/src/composition.ts +++ b/services/bayn/src/composition.ts @@ -168,7 +168,7 @@ export const BrokerSessionResourceLive = (config: Extract - Layer.merge(HttpServerLive(config), NodeHttpClient.layerNodeHttp) + Layer.merge(HttpServerLive(config), ApplicationPlatformLive) const SignalMarketDataLive = (plan: ApplicationIdentity) => { const clickHouse = sqlResource(ClickHouseClientResourceLive(plan.config)) From 23bf989641a48575f5c6e67b0e47d91187d1139a Mon Sep 17 00:00:00 2001 From: Greg Konush <12027037+gregkonush@users.noreply.github.com> Date: Sun, 9 Aug 2026 17:38:09 -0700 Subject: [PATCH 3/3] fix(bayn): bind TSGo dependency closures --- nix/images/bayn.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/images/bayn.nix b/nix/images/bayn.nix index e48996ac58..eb89cbcd6a 100644 --- a/nix/images/bayn.nix +++ b/nix/images/bayn.nix @@ -21,8 +21,8 @@ let buildDefine = name: value: "--define ${name}=${lib.escapeShellArg (builtins.toJSON value)}"; dependencySource = import ./bun-workspace-deps-source.nix { inherit lib repoRoot; }; depsHash = { - x86_64-linux = "sha256-ScfYBRqXqLq2oXmpPqAYcB+uJOQsFN5gQ9cdf4Gtlzo="; - aarch64-linux = "sha256-QaszirC/VC17YOcUYIaQnXaxdpCz7rijSZTnL9YtY8M="; + x86_64-linux = "sha256-jaeixE6zSL/K3OhIM9lo4FljP+ANiCI1LFkfTkSTr3E="; + aarch64-linux = "sha256-pnehq1SsO8bj40GoJJ5sDIgYTXwDTL4Qtnu9aIbnLdE="; }; buildCommands = [ "bun --cwd=services/bayn run tsc"