Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bayn-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions nix/images/bayn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/src/bayn/bayn-release-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
3 changes: 3 additions & 0 deletions services/bayn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions services/bayn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion services/bayn/src/composition.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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'
Expand Down
9 changes: 5 additions & 4 deletions services/bayn/src/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export const BrokerSessionResourceLive = (config: Extract<LoadedRuntimeConfig, {

export const ApplicationPlatformLive = Layer.merge(NodeServices.layer, NodeHttpClient.layerNodeHttp)

const HttpApplicationPlatformLive = (config: LoadedRuntimeConfig) =>
Layer.merge(HttpServerLive(config), ApplicationPlatformLive)

const SignalMarketDataLive = (plan: ApplicationIdentity) => {
const clickHouse = sqlResource(ClickHouseClientResourceLive(plan.config))
return MarketDataResourceLive(plan).pipe(Layer.provide(clickHouse))
Expand All @@ -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'>) => {
Expand Down
11 changes: 8 additions & 3 deletions services/bayn/src/observe-composition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions services/bayn/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"name": "@effect/language-service",
"diagnostics": true,
"includeSuggestionsInTsc": false,
"ignoreEffectErrorsInTscExitCode": false,
"ignoreEffectWarningsInTscExitCode": false,
"diagnosticSeverity": {
"anyUnknownInErrorContext": "error",
"globalDateInEffect": "error",
Expand Down
Loading