@fuzdev/fuz_app 0.65.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +65 -86
- package/dist/actions/action_codegen.d.ts +1 -1
- package/dist/actions/action_codegen.js +1 -1
- package/dist/actions/action_event_data.d.ts +1 -1
- package/dist/auth/CLAUDE.md +83 -104
- package/dist/auth/audit_log_schema.js +2 -2
- package/dist/auth/daemon_token_middleware.d.ts +15 -5
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +24 -15
- package/dist/auth/invite_queries.d.ts +17 -7
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +19 -8
- package/dist/auth/signup_routes.d.ts +47 -1
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +103 -52
- package/dist/env/resolve.d.ts +44 -7
- package/dist/env/resolve.d.ts.map +1 -1
- package/dist/env/resolve.js +94 -27
- package/dist/http/CLAUDE.md +47 -52
- package/dist/http/jsonrpc.d.ts +23 -7
- package/dist/http/jsonrpc.d.ts.map +1 -1
- package/dist/http/jsonrpc.js +19 -3
- package/dist/http/surface.d.ts +9 -2
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/runtime/mock.d.ts +1 -1
- package/dist/runtime/mock.js +1 -1
- package/dist/testing/CLAUDE.md +659 -511
- package/dist/testing/admin_integration.d.ts +5 -5
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +95 -39
- package/dist/testing/app_server.d.ts +16 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +18 -3
- package/dist/testing/audit_completeness.d.ts +7 -5
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +5 -9
- package/dist/testing/bootstrap_success.js +2 -2
- package/dist/testing/cross_backend/backend_config.d.ts +113 -0
- package/dist/testing/cross_backend/backend_config.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_config.js +1 -0
- package/dist/testing/cross_backend/bench/bench_report.d.ts +46 -0
- package/dist/testing/cross_backend/bench/bench_report.d.ts.map +1 -0
- package/dist/testing/cross_backend/bench/bench_report.js +83 -0
- package/dist/testing/cross_backend/bench/run_cross_impl_bench.d.ts +44 -0
- package/dist/testing/cross_backend/bench/run_cross_impl_bench.d.ts.map +1 -0
- package/dist/testing/cross_backend/bench/run_cross_impl_bench.js +38 -0
- package/dist/testing/cross_backend/bench/scenario.d.ts +57 -0
- package/dist/testing/cross_backend/bench/scenario.d.ts.map +1 -0
- package/dist/testing/cross_backend/bench/scenario.js +28 -0
- package/dist/testing/cross_backend/bootstrap_backend.d.ts +41 -0
- package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -0
- package/dist/testing/cross_backend/bootstrap_backend.js +34 -0
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +24 -0
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -0
- package/dist/testing/cross_backend/build_test_backend_paths.js +33 -0
- package/dist/testing/cross_backend/capabilities.d.ts +3 -2
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.d.ts +122 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -0
- package/dist/testing/cross_backend/default_backend_configs.js +111 -0
- package/dist/testing/cross_backend/default_secrets.d.ts +40 -0
- package/dist/testing/cross_backend/default_secrets.d.ts.map +1 -0
- package/dist/testing/cross_backend/default_secrets.js +39 -0
- package/dist/testing/cross_backend/default_spine_surface.d.ts +64 -0
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -0
- package/dist/testing/cross_backend/default_spine_surface.js +121 -0
- package/dist/testing/cross_backend/setup.d.ts +270 -34
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +495 -15
- package/dist/testing/cross_backend/spawn_backend.d.ts +58 -0
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -0
- package/dist/testing/cross_backend/spawn_backend.js +229 -0
- package/dist/testing/cross_backend/spine_stub_backend_config.d.ts +66 -0
- package/dist/testing/cross_backend/spine_stub_backend_config.d.ts.map +1 -0
- package/dist/testing/cross_backend/spine_stub_backend_config.js +49 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +37 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -0
- package/dist/testing/cross_backend/sse_round_trip.js +137 -0
- package/dist/testing/cross_backend/standard.d.ts +96 -0
- package/dist/testing/cross_backend/standard.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard.js +49 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +171 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_reset_actions.js +213 -0
- package/dist/testing/cross_backend/testing_server_bun.d.ts +5 -0
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_server_bun.js +59 -0
- package/dist/testing/cross_backend/testing_server_core.d.ts +140 -0
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_server_core.js +68 -0
- package/dist/testing/cross_backend/testing_server_deno.d.ts +5 -0
- package/dist/testing/cross_backend/testing_server_deno.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_server_deno.js +37 -0
- package/dist/testing/cross_backend/testing_server_node.d.ts +5 -0
- package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_server_node.js +50 -0
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +72 -0
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -0
- package/dist/testing/cross_backend/ts_spine_backend_config.js +112 -0
- package/dist/testing/cross_backend/ws_round_trip.d.ts +35 -0
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -0
- package/dist/testing/cross_backend/ws_round_trip.js +113 -0
- package/dist/testing/data_exposure.d.ts +4 -6
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +1 -5
- package/dist/testing/db_entities.d.ts +18 -7
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +18 -7
- package/dist/testing/integration.d.ts +27 -6
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +93 -58
- package/dist/testing/round_trip.d.ts +4 -5
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +1 -5
- package/dist/testing/rpc_helpers.d.ts +10 -4
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +1 -1
- package/dist/testing/rpc_round_trip.d.ts +5 -5
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +1 -5
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +1 -68
- package/dist/testing/standard.d.ts +4 -5
- package/dist/testing/standard.d.ts.map +1 -1
- package/dist/testing/stubs.d.ts +10 -3
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +9 -2
- package/dist/testing/testing_rate_limiter.d.ts +59 -0
- package/dist/testing/testing_rate_limiter.d.ts.map +1 -0
- package/dist/testing/testing_rate_limiter.js +74 -0
- package/dist/testing/transports/bootstrap.d.ts +52 -0
- package/dist/testing/transports/bootstrap.d.ts.map +1 -0
- package/dist/testing/transports/bootstrap.js +70 -0
- package/dist/testing/transports/fetch_transport.d.ts +81 -0
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -0
- package/dist/testing/transports/fetch_transport.js +74 -0
- package/dist/testing/transports/sse_frame_reader.d.ts +41 -0
- package/dist/testing/transports/sse_frame_reader.d.ts.map +1 -0
- package/dist/testing/transports/sse_frame_reader.js +84 -0
- package/dist/testing/transports/sse_transport.d.ts +54 -0
- package/dist/testing/transports/sse_transport.d.ts.map +1 -0
- package/dist/testing/transports/sse_transport.js +51 -0
- package/dist/testing/transports/ws_client.d.ts +108 -0
- package/dist/testing/transports/ws_client.d.ts.map +1 -0
- package/dist/testing/transports/ws_client.js +56 -0
- package/dist/testing/transports/ws_transport.d.ts +43 -0
- package/dist/testing/transports/ws_transport.d.ts.map +1 -0
- package/dist/testing/transports/ws_transport.js +169 -0
- package/dist/testing/ws_round_trip.d.ts +21 -103
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +42 -40
- package/dist/ui/CLAUDE.md +5 -3
- package/dist/ui/MenuLink.svelte +16 -16
- package/dist/ui/MenuLink.svelte.d.ts +13 -4
- package/dist/ui/MenuLink.svelte.d.ts.map +1 -1
- package/package.json +20 -3
- package/dist/testing/transports/surface_source.d.ts +0 -51
- package/dist/testing/transports/surface_source.d.ts.map +0 -1
- package/dist/testing/transports/surface_source.js +0 -19
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import '../../assert_dev_env.js';
|
|
2
|
+
import { type BenchmarkComparison } from '@fuzdev/fuz_util/benchmark_stats.js';
|
|
3
|
+
import type { CrossImplBenchResult } from './run_cross_impl_bench.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reporting adapters over a `CrossImplBenchResult` — all built on fuz_util's
|
|
6
|
+
* formatters + Welch comparison. Markdown for human eyeballs, a per-scenario
|
|
7
|
+
* TS-vs-reference significance verdict, and a self-describing JSON artifact.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** Per-scenario markdown table (one row per backend), each under an `###` heading. */
|
|
12
|
+
export declare const format_cross_impl_markdown: (result: CrossImplBenchResult) => string;
|
|
13
|
+
/** One backend's result compared against the reference backend, per scenario. */
|
|
14
|
+
export interface CrossImplComparisonEntry {
|
|
15
|
+
readonly scenario: string;
|
|
16
|
+
/** The reference backend (`a` side of the comparison). */
|
|
17
|
+
readonly reference: string;
|
|
18
|
+
/** The compared backend (`b` side). */
|
|
19
|
+
readonly backend: string;
|
|
20
|
+
readonly comparison: BenchmarkComparison;
|
|
21
|
+
}
|
|
22
|
+
export interface CompareCrossImplOptions {
|
|
23
|
+
/** Backend to compare every other backend against. Defaults to `result.backends[0]`. */
|
|
24
|
+
readonly reference?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Welch-test verdict for every non-reference backend vs the reference, per
|
|
28
|
+
* scenario. With deno + node + rust and `reference: 'deno'` you get
|
|
29
|
+
* `node vs deno` and `rust vs deno` for each scenario.
|
|
30
|
+
*/
|
|
31
|
+
export declare const compare_cross_impl: (result: CrossImplBenchResult, options?: CompareCrossImplOptions) => Array<CrossImplComparisonEntry>;
|
|
32
|
+
/**
|
|
33
|
+
* Render the comparison entries as one line each. The prefix lists the
|
|
34
|
+
* reference first to match `benchmark_stats_compare`'s "First" (= the `a`
|
|
35
|
+
* arg = reference) / "Second" (= the `b` arg = backend) in the
|
|
36
|
+
* recommendation text — `compare_cross_impl` passes `(reference, backend)`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const format_cross_impl_comparison: (entries: ReadonlyArray<CrossImplComparisonEntry>) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Self-describing JSON artifact: one entry per backend × scenario with the
|
|
41
|
+
* percentiles (raw-sample tail), the resolved budget, and iteration count.
|
|
42
|
+
* Diffable and reviewable without a TS runtime; the seed for the deferred
|
|
43
|
+
* static-docs comparison surface.
|
|
44
|
+
*/
|
|
45
|
+
export declare const format_cross_impl_json: (result: CrossImplBenchResult) => string;
|
|
46
|
+
//# sourceMappingURL=bench_report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bench_report.d.ts","sourceRoot":"../src/lib/","sources":["../../../../src/lib/testing/cross_backend/bench/bench_report.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAEpE;;;;;;GAMG;AAEH,sFAAsF;AACtF,eAAO,MAAM,0BAA0B,GAAI,QAAQ,oBAAoB,KAAG,MAM3D,CAAC;AAEhB,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;CACzC;AAED,MAAM,WAAW,uBAAuB;IACvC,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC9B,QAAQ,oBAAoB,EAC5B,UAAU,uBAAuB,KAC/B,KAAK,CAAC,wBAAwB,CAoBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,aAAa,CAAC,wBAAwB,CAAC,KAC9C,MAGU,CAAC;AAEd;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,oBAAoB,KAAG,MA4BpE,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import '../../assert_dev_env.js';
|
|
2
|
+
import { benchmark_format_markdown } from '@fuzdev/fuz_util/benchmark_format.js';
|
|
3
|
+
import { benchmark_stats_compare, } from '@fuzdev/fuz_util/benchmark_stats.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reporting adapters over a `CrossImplBenchResult` — all built on fuz_util's
|
|
6
|
+
* formatters + Welch comparison. Markdown for human eyeballs, a per-scenario
|
|
7
|
+
* TS-vs-reference significance verdict, and a self-describing JSON artifact.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** Per-scenario markdown table (one row per backend), each under an `###` heading. */
|
|
12
|
+
export const format_cross_impl_markdown = (result) => result.scenarios
|
|
13
|
+
.map((scenario) => {
|
|
14
|
+
const results = result.entries.filter((e) => e.scenario === scenario).map((e) => e.result);
|
|
15
|
+
return `### ${scenario}\n\n${benchmark_format_markdown(results)}`;
|
|
16
|
+
})
|
|
17
|
+
.join('\n\n');
|
|
18
|
+
/**
|
|
19
|
+
* Welch-test verdict for every non-reference backend vs the reference, per
|
|
20
|
+
* scenario. With deno + node + rust and `reference: 'deno'` you get
|
|
21
|
+
* `node vs deno` and `rust vs deno` for each scenario.
|
|
22
|
+
*/
|
|
23
|
+
export const compare_cross_impl = (result, options) => {
|
|
24
|
+
const reference = options?.reference ?? result.backends[0];
|
|
25
|
+
if (reference === undefined)
|
|
26
|
+
return [];
|
|
27
|
+
const out = [];
|
|
28
|
+
for (const scenario of result.scenarios) {
|
|
29
|
+
const ref_entry = result.entries.find((e) => e.scenario === scenario && e.backend === reference);
|
|
30
|
+
if (!ref_entry)
|
|
31
|
+
continue;
|
|
32
|
+
for (const e of result.entries) {
|
|
33
|
+
if (e.scenario !== scenario || e.backend === reference)
|
|
34
|
+
continue;
|
|
35
|
+
out.push({
|
|
36
|
+
scenario,
|
|
37
|
+
reference,
|
|
38
|
+
backend: e.backend,
|
|
39
|
+
comparison: benchmark_stats_compare(ref_entry.result.stats, e.result.stats),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Render the comparison entries as one line each. The prefix lists the
|
|
47
|
+
* reference first to match `benchmark_stats_compare`'s "First" (= the `a`
|
|
48
|
+
* arg = reference) / "Second" (= the `b` arg = backend) in the
|
|
49
|
+
* recommendation text — `compare_cross_impl` passes `(reference, backend)`.
|
|
50
|
+
*/
|
|
51
|
+
export const format_cross_impl_comparison = (entries) => entries
|
|
52
|
+
.map((e) => `${e.scenario}: ${e.reference} vs ${e.backend} — ${e.comparison.recommendation}`)
|
|
53
|
+
.join('\n');
|
|
54
|
+
/**
|
|
55
|
+
* Self-describing JSON artifact: one entry per backend × scenario with the
|
|
56
|
+
* percentiles (raw-sample tail), the resolved budget, and iteration count.
|
|
57
|
+
* Diffable and reviewable without a TS runtime; the seed for the deferred
|
|
58
|
+
* static-docs comparison surface.
|
|
59
|
+
*/
|
|
60
|
+
export const format_cross_impl_json = (result) => JSON.stringify({
|
|
61
|
+
generated_at: new Date().toISOString(),
|
|
62
|
+
backends: result.backends,
|
|
63
|
+
scenarios: result.scenarios,
|
|
64
|
+
entries: result.entries.map((e) => ({
|
|
65
|
+
backend: e.backend,
|
|
66
|
+
scenario: e.scenario,
|
|
67
|
+
iterations: e.result.iterations,
|
|
68
|
+
budget: e.result.budget,
|
|
69
|
+
stats: {
|
|
70
|
+
mean_ns: e.result.stats.mean_ns,
|
|
71
|
+
p50_ns: e.result.stats.p50_ns,
|
|
72
|
+
p90_ns: e.result.stats.p90_ns,
|
|
73
|
+
p95_ns: e.result.stats.p95_ns,
|
|
74
|
+
p99_ns: e.result.stats.p99_ns,
|
|
75
|
+
min_ns: e.result.stats.min_ns,
|
|
76
|
+
max_ns: e.result.stats.max_ns,
|
|
77
|
+
std_dev_ns: e.result.stats.std_dev_ns,
|
|
78
|
+
ops_per_second: e.result.stats.ops_per_second,
|
|
79
|
+
outlier_ratio: e.result.stats.outlier_ratio,
|
|
80
|
+
sample_size: e.result.stats.sample_size,
|
|
81
|
+
},
|
|
82
|
+
})),
|
|
83
|
+
}, null, 2);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import '../../assert_dev_env.js';
|
|
2
|
+
import type { BenchmarkConfig, BenchmarkResult } from '@fuzdev/fuz_util/benchmark_types.js';
|
|
3
|
+
import type { BootstrappedBackendHandle } from '../setup.js';
|
|
4
|
+
import type { BenchScenario } from './scenario.js';
|
|
5
|
+
/**
|
|
6
|
+
* Drive identical wire scenarios across several spawned backends and time each
|
|
7
|
+
* round trip, so a TS impl and a Rust impl can be compared apples-to-apples
|
|
8
|
+
* (both cross-process over real HTTP). The reusable cross-impl measurement
|
|
9
|
+
* primitive.
|
|
10
|
+
*
|
|
11
|
+
* fuz_util's benchmark library is the engine — `Benchmark` runs each scenario
|
|
12
|
+
* as a task and `BenchmarkResult.stats` carries the percentiles; this module
|
|
13
|
+
* is the thin scenario→task→tagged-result adapter. Reporting (markdown,
|
|
14
|
+
* TS-vs-Rust verdict, JSON artifact) lives in `bench_report.ts`.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
/** One backend × one scenario, with its timing result. */
|
|
19
|
+
export interface CrossImplBenchEntry {
|
|
20
|
+
readonly backend: string;
|
|
21
|
+
readonly scenario: string;
|
|
22
|
+
readonly result: BenchmarkResult;
|
|
23
|
+
}
|
|
24
|
+
/** Full sweep across the supplied backends and scenarios. */
|
|
25
|
+
export interface CrossImplBenchResult {
|
|
26
|
+
/** Backend names, in the order they were run. */
|
|
27
|
+
readonly backends: ReadonlyArray<string>;
|
|
28
|
+
/** Scenario names that ran on at least one backend. */
|
|
29
|
+
readonly scenarios: ReadonlyArray<string>;
|
|
30
|
+
readonly entries: ReadonlyArray<CrossImplBenchEntry>;
|
|
31
|
+
}
|
|
32
|
+
export interface RunCrossImplBenchOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Already-bootstrapped backends to benchmark. Each one's `keeper_transport`
|
|
35
|
+
* is the pre-authed transport scenarios fire against — bootstrap once, then
|
|
36
|
+
* hammer; no per-iteration reset.
|
|
37
|
+
*/
|
|
38
|
+
readonly handles: ReadonlyArray<BootstrappedBackendHandle>;
|
|
39
|
+
readonly scenarios: ReadonlyArray<BenchScenario>;
|
|
40
|
+
/** Overrides merged over the network-tuned defaults below. */
|
|
41
|
+
readonly config?: Partial<BenchmarkConfig>;
|
|
42
|
+
}
|
|
43
|
+
export declare const run_cross_impl_bench: (options: RunCrossImplBenchOptions) => Promise<CrossImplBenchResult>;
|
|
44
|
+
//# sourceMappingURL=run_cross_impl_bench.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_cross_impl_bench.d.ts","sourceRoot":"../src/lib/","sources":["../../../../src/lib/testing/cross_backend/bench/run_cross_impl_bench.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,qCAAqC,CAAC;AAE1F,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAC,aAAa,EAAuB,MAAM,eAAe,CAAC;AAEvE;;;;;;;;;;;;GAYG;AAEH,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CACjC;AAED,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACpC,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,wBAAwB;IACxC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC3D,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACjD,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CAC3C;AAeD,eAAO,MAAM,oBAAoB,GAChC,SAAS,wBAAwB,KAC/B,OAAO,CAAC,oBAAoB,CAwB9B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import '../../assert_dev_env.js';
|
|
2
|
+
import { Benchmark } from '@fuzdev/fuz_util/benchmark.js';
|
|
3
|
+
/**
|
|
4
|
+
* Network-tuned defaults — fuz_util's micro-benchmark defaults (warmup 10,
|
|
5
|
+
* min 30, duration 1000ms) are sized for sub-microsecond functions. RPC round
|
|
6
|
+
* trips are millisecond-scale and IO-bound, so warm the connection more and
|
|
7
|
+
* collect a higher sample floor for stable tail percentiles.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_BENCH_CONFIG = {
|
|
10
|
+
warmup_iterations: 20,
|
|
11
|
+
min_iterations: 100,
|
|
12
|
+
duration_ms: 3000,
|
|
13
|
+
cooldown_ms: 100,
|
|
14
|
+
};
|
|
15
|
+
export const run_cross_impl_bench = async (options) => {
|
|
16
|
+
const config = { ...DEFAULT_BENCH_CONFIG, ...options.config };
|
|
17
|
+
const entries = [];
|
|
18
|
+
for (const handle of options.handles) {
|
|
19
|
+
const ctx = {
|
|
20
|
+
transport: handle.keeper_transport,
|
|
21
|
+
rpc_path: handle.config.rpc_path,
|
|
22
|
+
capabilities: handle.config.capabilities,
|
|
23
|
+
};
|
|
24
|
+
for (const scenario of options.scenarios) {
|
|
25
|
+
if (scenario.requires && !scenario.requires(handle.config.capabilities))
|
|
26
|
+
continue;
|
|
27
|
+
// One task per Benchmark, named by the backend so the report tables
|
|
28
|
+
// read as backend rows under a per-scenario heading.
|
|
29
|
+
const bench = new Benchmark(config);
|
|
30
|
+
bench.add({ name: handle.config.name, fn: () => scenario.run(ctx), async: true });
|
|
31
|
+
const [result] = await bench.run();
|
|
32
|
+
entries.push({ backend: handle.config.name, scenario: scenario.name, result: result });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const backends = options.handles.map((h) => h.config.name);
|
|
36
|
+
const scenarios = [...new Set(entries.map((e) => e.scenario))];
|
|
37
|
+
return { backends, scenarios, entries };
|
|
38
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import '../../assert_dev_env.js';
|
|
2
|
+
import type { FetchTransport } from '../../transports/fetch_transport.js';
|
|
3
|
+
import type { BackendCapabilities } from '../capabilities.js';
|
|
4
|
+
/**
|
|
5
|
+
* Context handed to a `BenchScenario.run`. Carries a ready, pre-authed
|
|
6
|
+
* transport (the bootstrapped keeper's, by default) plus the resolved RPC
|
|
7
|
+
* path and the backend's declared capabilities. A scenario fires one round
|
|
8
|
+
* trip (or a small fixed *idempotent* sequence) against it — no per-call
|
|
9
|
+
* `_testing_reset`, which is the correctness-test model and would dominate
|
|
10
|
+
* the timing.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
export interface BenchScenarioContext {
|
|
15
|
+
/** Pre-authed transport — the bootstrapped keeper's session cookie jar. */
|
|
16
|
+
readonly transport: FetchTransport;
|
|
17
|
+
/** RPC endpoint path, e.g. `'/api/rpc'`. */
|
|
18
|
+
readonly rpc_path: string;
|
|
19
|
+
/** Declared capabilities of the backend this context targets. */
|
|
20
|
+
readonly capabilities: BackendCapabilities;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One benchmarkable wire scenario. The `run` body is the `Benchmark` task fn:
|
|
24
|
+
* it must `throw` on a non-success response so the benchmark records a failed
|
|
25
|
+
* iteration rather than timing an error path as if it succeeded.
|
|
26
|
+
*
|
|
27
|
+
* Scenarios should be **idempotent** — they run thousands of times against a
|
|
28
|
+
* single bootstrapped backend with no reset between iterations. Prefer reads;
|
|
29
|
+
* a mutating scenario must not accumulate unbounded state.
|
|
30
|
+
*/
|
|
31
|
+
export interface BenchScenario {
|
|
32
|
+
/** Scenario name (groups the per-backend results in the report). */
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/**
|
|
35
|
+
* Optional capability gate — return `false` to skip this scenario on a
|
|
36
|
+
* backend that can't serve it (e.g. a WS scenario needs `capabilities.ws`).
|
|
37
|
+
*/
|
|
38
|
+
readonly requires?: (capabilities: BackendCapabilities) => boolean;
|
|
39
|
+
/** The timed body. Throws on a non-success response. */
|
|
40
|
+
readonly run: (ctx: BenchScenarioContext) => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Starter cross-impl scenarios — all on the standard spine surface, so they
|
|
44
|
+
* run on every backend (TS Hono, Rust spine), and all reads, so they're safe
|
|
45
|
+
* to repeat against one bootstrapped keeper without state accumulation.
|
|
46
|
+
*
|
|
47
|
+
* - `account_verify` — the dispatch + auth-resolve floor (no real query work).
|
|
48
|
+
* - `account_session_list` — an authed DB read.
|
|
49
|
+
* - `audit_log_list` — an admin paginated read (the keeper holds `ROLE_ADMIN`).
|
|
50
|
+
*
|
|
51
|
+
* `login` is deliberately omitted: the cross-process test binaries wire a
|
|
52
|
+
* fast `TestingArgon2idHasher`, so a login scenario would measure dispatch
|
|
53
|
+
* rather than real Argon2 cost — misleading without its own clearly-labeled
|
|
54
|
+
* tier.
|
|
55
|
+
*/
|
|
56
|
+
export declare const default_bench_scenarios: ReadonlyArray<BenchScenario>;
|
|
57
|
+
//# sourceMappingURL=scenario.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenario.d.ts","sourceRoot":"../src/lib/","sources":["../../../../src/lib/testing/cross_backend/bench/scenario.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACpC,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC3C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,OAAO,CAAC;IACnE,wDAAwD;IACxD,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAcD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,aAAa,CAIhE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import '../../assert_dev_env.js';
|
|
2
|
+
import { rpc_call } from '../../rpc_helpers.js';
|
|
3
|
+
/** Fire one authed JSON-RPC call; throw on a non-success envelope. */
|
|
4
|
+
const rpc_scenario = (method, params) => async (ctx) => {
|
|
5
|
+
const result = await rpc_call({ app: ctx.transport, path: ctx.rpc_path, method, params });
|
|
6
|
+
if (!result.ok) {
|
|
7
|
+
throw new Error(`bench scenario '${method}' failed: ${result.error.code} ${result.error.message}`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Starter cross-impl scenarios — all on the standard spine surface, so they
|
|
12
|
+
* run on every backend (TS Hono, Rust spine), and all reads, so they're safe
|
|
13
|
+
* to repeat against one bootstrapped keeper without state accumulation.
|
|
14
|
+
*
|
|
15
|
+
* - `account_verify` — the dispatch + auth-resolve floor (no real query work).
|
|
16
|
+
* - `account_session_list` — an authed DB read.
|
|
17
|
+
* - `audit_log_list` — an admin paginated read (the keeper holds `ROLE_ADMIN`).
|
|
18
|
+
*
|
|
19
|
+
* `login` is deliberately omitted: the cross-process test binaries wire a
|
|
20
|
+
* fast `TestingArgon2idHasher`, so a login scenario would measure dispatch
|
|
21
|
+
* rather than real Argon2 cost — misleading without its own clearly-labeled
|
|
22
|
+
* tier.
|
|
23
|
+
*/
|
|
24
|
+
export const default_bench_scenarios = [
|
|
25
|
+
{ name: 'account_verify', run: rpc_scenario('account_verify') },
|
|
26
|
+
{ name: 'account_session_list', run: rpc_scenario('account_session_list') },
|
|
27
|
+
{ name: 'audit_log_list', run: rpc_scenario('audit_log_list', { limit: 20 }) },
|
|
28
|
+
];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* One-call spawn + bootstrap helper.
|
|
4
|
+
*
|
|
5
|
+
* Composes `spawn_backend(config)` and `bootstrap({transport, config})` so a
|
|
6
|
+
* consumer's vitest `globalSetup` reduces to a single await:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import {bootstrap_backend} from '@fuzdev/fuz_app/testing/cross_backend/bootstrap_backend.js';
|
|
10
|
+
*
|
|
11
|
+
* export default async function ({provide}) {
|
|
12
|
+
* const bootstrapped = await bootstrap_backend(deno_backend_config());
|
|
13
|
+
* provide('backend_handle', bootstrapped);
|
|
14
|
+
* return async () => {
|
|
15
|
+
* await bootstrapped.teardown();
|
|
16
|
+
* };
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* If `bootstrap()` throws — typically a bad token, port collision, or
|
|
21
|
+
* keeper-username mismatch — the spawned binary is torn down before the
|
|
22
|
+
* error propagates so vitest doesn't strand the port.
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
import type { BackendConfig } from './backend_config.js';
|
|
27
|
+
import type { BootstrappedBackendHandle } from './setup.js';
|
|
28
|
+
/**
|
|
29
|
+
* Spawn the test binary described by `config`, bootstrap a keeper, and
|
|
30
|
+
* return the enriched handle.
|
|
31
|
+
*
|
|
32
|
+
* The keeper transport is constructed against `config.base_url` with no
|
|
33
|
+
* initial cookies; `bootstrap()` populates its jar with the session
|
|
34
|
+
* cookie returned by `POST {config.bootstrap_path}`. Subsequent calls
|
|
35
|
+
* against `bootstrapped.keeper_transport` are authenticated as keeper.
|
|
36
|
+
*
|
|
37
|
+
* Mirrors the composition `default_cross_process_setup`'s caller would
|
|
38
|
+
* otherwise hand-roll in every consumer's `globalSetup`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const bootstrap_backend: (config: BackendConfig) => Promise<BootstrappedBackendHandle>;
|
|
41
|
+
//# sourceMappingURL=bootstrap_backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap_backend.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/bootstrap_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAIvD,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,YAAY,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,KACnB,OAAO,CAAC,yBAAyB,CAgBnC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import { spawn_backend } from './spawn_backend.js';
|
|
3
|
+
import { bootstrap } from '../transports/bootstrap.js';
|
|
4
|
+
import { create_fetch_transport } from '../transports/fetch_transport.js';
|
|
5
|
+
/**
|
|
6
|
+
* Spawn the test binary described by `config`, bootstrap a keeper, and
|
|
7
|
+
* return the enriched handle.
|
|
8
|
+
*
|
|
9
|
+
* The keeper transport is constructed against `config.base_url` with no
|
|
10
|
+
* initial cookies; `bootstrap()` populates its jar with the session
|
|
11
|
+
* cookie returned by `POST {config.bootstrap_path}`. Subsequent calls
|
|
12
|
+
* against `bootstrapped.keeper_transport` are authenticated as keeper.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors the composition `default_cross_process_setup`'s caller would
|
|
15
|
+
* otherwise hand-roll in every consumer's `globalSetup`.
|
|
16
|
+
*/
|
|
17
|
+
export const bootstrap_backend = async (config) => {
|
|
18
|
+
const handle = await spawn_backend(config);
|
|
19
|
+
try {
|
|
20
|
+
const keeper_transport = create_fetch_transport({ base_url: config.base_url });
|
|
21
|
+
const keeper = await bootstrap({ transport: keeper_transport, config });
|
|
22
|
+
return {
|
|
23
|
+
...handle,
|
|
24
|
+
keeper_transport,
|
|
25
|
+
keeper_account: keeper.account,
|
|
26
|
+
keeper_actor: keeper.actor,
|
|
27
|
+
keeper_cookies: keeper.cookies,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
await handle.teardown();
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generic per-backend paths every cross-process test binary needs.
|
|
4
|
+
* Consumers extend this with their own domain paths.
|
|
5
|
+
*
|
|
6
|
+
* - `root` — the per-backend subtree under `os.tmpdir()`. Compose
|
|
7
|
+
* consumer-specific paths under here.
|
|
8
|
+
* - `bootstrap_token_path` — `FUZ_BOOTSTRAP_TOKEN_PATH`; harness writes
|
|
9
|
+
* the bootstrap token here before spawn.
|
|
10
|
+
* - `daemon_token_path` — where `init_daemon_token` (Rust) and the TS
|
|
11
|
+
* server's daemon-token writer land the token (under `{root}/run/`).
|
|
12
|
+
*/
|
|
13
|
+
export interface TestBackendPaths {
|
|
14
|
+
readonly root: string;
|
|
15
|
+
readonly bootstrap_token_path: string;
|
|
16
|
+
readonly daemon_token_path: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build the generic path layout for a cross-process test backend.
|
|
20
|
+
* `prefix` is typically the `BackendConfig.name` (e.g. `'deno'`,
|
|
21
|
+
* `'rust'`, `'spine_stub'`).
|
|
22
|
+
*/
|
|
23
|
+
export declare const build_test_backend_paths: (prefix: string) => TestBackendPaths;
|
|
24
|
+
//# sourceMappingURL=build_test_backend_paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_test_backend_paths.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/build_test_backend_paths.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,MAAM,KAAG,gBASzD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Per-backend filesystem layout under `os.tmpdir()` for cross-process
|
|
4
|
+
* tests.
|
|
5
|
+
*
|
|
6
|
+
* Isolation matters because vitest projects can run in parallel — a
|
|
7
|
+
* shared `root` would mix daemon tokens across concurrently-running
|
|
8
|
+
* backends. Each backend gets its own subtree via the `prefix` arg
|
|
9
|
+
* (typically the `BackendConfig.name`).
|
|
10
|
+
*
|
|
11
|
+
* Consumers compose: take the generic paths from
|
|
12
|
+
* `build_test_backend_paths(name)`, add domain-specific dirs (e.g.
|
|
13
|
+
* `zzz_dir`, `scoped_dir`) under the returned `root`.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import { tmpdir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
/**
|
|
20
|
+
* Build the generic path layout for a cross-process test backend.
|
|
21
|
+
* `prefix` is typically the `BackendConfig.name` (e.g. `'deno'`,
|
|
22
|
+
* `'rust'`, `'spine_stub'`).
|
|
23
|
+
*/
|
|
24
|
+
export const build_test_backend_paths = (prefix) => {
|
|
25
|
+
const root = join(tmpdir(), prefix);
|
|
26
|
+
return {
|
|
27
|
+
root,
|
|
28
|
+
bootstrap_token_path: join(root, 'bootstrap_token'),
|
|
29
|
+
// `init_daemon_token` (Rust) and the TS server's daemon-token
|
|
30
|
+
// writer both land the token at `{root}/run/daemon_token`.
|
|
31
|
+
daemon_token_path: join(root, 'run', 'daemon_token'),
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -30,8 +30,9 @@ export interface BackendCapabilities {
|
|
|
30
30
|
readonly ws: boolean;
|
|
31
31
|
/**
|
|
32
32
|
* SSE transport is reachable end-to-end. Gates the cross-process SSE
|
|
33
|
-
*
|
|
34
|
-
* `on_audit_event` hook and
|
|
33
|
+
* suite (`describe_cross_process_sse_tests` — connect, audit data frame,
|
|
34
|
+
* close-on-revoke); in-process SSE uses the `on_audit_event` hook and
|
|
35
|
+
* ignores this flag.
|
|
35
36
|
*/
|
|
36
37
|
readonly sse: boolean;
|
|
37
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAmB9B;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAmB9B;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CAClC;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,mBAOpC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,EAAE,IAAI,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAG,IAMrF,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Family-shared `BackendConfig` builders for cross-process test backends.
|
|
4
|
+
*
|
|
5
|
+
* Two consumer-facing factories — {@link make_default_ts_backend_config}
|
|
6
|
+
* and {@link make_default_rust_backend_config} — own the common shape
|
|
7
|
+
* for the JS-runtime (Deno/Node on V8) and Rust families respectively.
|
|
8
|
+
* Per-backend factories in consumer projects compose a small
|
|
9
|
+
* declaration against one of these and add consumer-specific env vars
|
|
10
|
+
* via `extra_env`.
|
|
11
|
+
*
|
|
12
|
+
* Defaults baked in by family:
|
|
13
|
+
*
|
|
14
|
+
* - **TS** — `'memory://'` PGlite, 30s startup window, capabilities
|
|
15
|
+
* without trusted_proxy/login_rate_limit. The TS canonical path
|
|
16
|
+
* leaves these limiters null in test mode.
|
|
17
|
+
* - **Rust** — caller-supplied real Postgres URL (PGlite isn't reachable
|
|
18
|
+
* from `tokio-postgres`), 120s startup window (cargo first-build cost),
|
|
19
|
+
* capabilities including trusted_proxy + login_rate_limit + the
|
|
20
|
+
* `FUZ_TESTING_RESET_DB_ON_STARTUP=true` self-wipe gate.
|
|
21
|
+
*
|
|
22
|
+
* Both builders default `port_env_var` to `'PORT'`. Consumers whose
|
|
23
|
+
* binary reads a different name (e.g. zzz's `ZZZ_PORT`) override.
|
|
24
|
+
*
|
|
25
|
+
* Common across both families: `/api/rpc`, `/api/ws`, `/health`,
|
|
26
|
+
* `/api/account/bootstrap`, `cookie_name: 'fuz_session'`, the standard
|
|
27
|
+
* bootstrap block keyed off `default_test_*` constants. Builders call
|
|
28
|
+
* `build_test_backend_paths(name)` internally when the optional `paths`
|
|
29
|
+
* is omitted.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
import type { BackendBootstrapConfig, BackendConfig } from './backend_config.js';
|
|
34
|
+
import type { BackendCapabilities } from './capabilities.js';
|
|
35
|
+
import { type TestBackendPaths } from './build_test_backend_paths.js';
|
|
36
|
+
/**
|
|
37
|
+
* Capabilities shared by TS-family backends — same canonical
|
|
38
|
+
* implementation, same feature set. No trusted-proxy phase (the test
|
|
39
|
+
* binary doesn't enable proxy parsing) and no per-account login rate
|
|
40
|
+
* limit (the TS canonical path leaves the limiter null in test mode).
|
|
41
|
+
*/
|
|
42
|
+
export declare const ts_default_capabilities: BackendCapabilities;
|
|
43
|
+
/**
|
|
44
|
+
* Capabilities for the Rust family. Adds `trusted_proxy: true` (the
|
|
45
|
+
* Rust spine's client-IP middleware is always wired; the env-gate just
|
|
46
|
+
* controls whether XFF is consulted vs the TCP peer IP) and
|
|
47
|
+
* `login_rate_limit: true` (env-gated bucket on `/login` + `/password`).
|
|
48
|
+
*/
|
|
49
|
+
export declare const rust_default_capabilities: BackendCapabilities;
|
|
50
|
+
export interface MakeDefaultTsBackendConfigOptions {
|
|
51
|
+
/** Diagnostic label; also used as the tmpdir prefix when `paths` is omitted. */
|
|
52
|
+
readonly name: string;
|
|
53
|
+
/** TCP port the binary listens on. */
|
|
54
|
+
readonly port: number;
|
|
55
|
+
/** argv passed to the spawn (first entry is the binary). */
|
|
56
|
+
readonly start_command: ReadonlyArray<string>;
|
|
57
|
+
/** Defaults to `'memory://'` (in-memory PGlite). */
|
|
58
|
+
readonly database_url?: string;
|
|
59
|
+
/** Merged on top of the generic env baseline; later keys win. */
|
|
60
|
+
readonly extra_env?: Readonly<Record<string, string>>;
|
|
61
|
+
/** Defaults to `ts_default_capabilities`. */
|
|
62
|
+
readonly capabilities?: BackendCapabilities;
|
|
63
|
+
/** Pre-computed paths; defaults to `build_test_backend_paths(name)`. */
|
|
64
|
+
readonly paths?: TestBackendPaths;
|
|
65
|
+
/** Override individual bootstrap fields (username/password/token). */
|
|
66
|
+
readonly bootstrap_overrides?: Partial<BackendBootstrapConfig>;
|
|
67
|
+
/**
|
|
68
|
+
* Env-var name the binary reads for its port. Defaults to `'PORT'`.
|
|
69
|
+
* Consumers whose binary reads a different name (e.g. `'ZZZ_PORT'`)
|
|
70
|
+
* override.
|
|
71
|
+
*/
|
|
72
|
+
readonly port_env_var?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Shared builder for TS-family backends (Deno + Node). Owns the common
|
|
76
|
+
* env baseline (NODE_ENV, HOST, PORT, in-memory PGlite, cookie keys,
|
|
77
|
+
* bootstrap token path) so per-backend factories only declare what
|
|
78
|
+
* genuinely differs.
|
|
79
|
+
*/
|
|
80
|
+
export declare const make_default_ts_backend_config: (opts: MakeDefaultTsBackendConfigOptions) => BackendConfig;
|
|
81
|
+
export interface MakeDefaultRustBackendConfigOptions {
|
|
82
|
+
/** Diagnostic label; also used as the tmpdir prefix when `paths` is omitted. */
|
|
83
|
+
readonly name: string;
|
|
84
|
+
/** TCP port the binary listens on. */
|
|
85
|
+
readonly port: number;
|
|
86
|
+
/** argv passed to the spawn (first entry is the binary). */
|
|
87
|
+
readonly start_command: ReadonlyArray<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Required — Rust needs real Postgres (PGlite isn't reachable from
|
|
90
|
+
* `tokio-postgres`). Consumers typically supply
|
|
91
|
+
* `'postgres://localhost/{repo}_test_{name}'`.
|
|
92
|
+
*/
|
|
93
|
+
readonly database_url: string;
|
|
94
|
+
/** Merged on top of the generic env baseline; later keys win. */
|
|
95
|
+
readonly extra_env?: Readonly<Record<string, string>>;
|
|
96
|
+
/** Defaults to `rust_default_capabilities`. */
|
|
97
|
+
readonly capabilities?: BackendCapabilities;
|
|
98
|
+
/** Pre-computed paths; defaults to `build_test_backend_paths(name)`. */
|
|
99
|
+
readonly paths?: TestBackendPaths;
|
|
100
|
+
/** Override individual bootstrap fields (username/password/token). */
|
|
101
|
+
readonly bootstrap_overrides?: Partial<BackendBootstrapConfig>;
|
|
102
|
+
/**
|
|
103
|
+
* Env-var name the binary reads for its port. Defaults to `'PORT'`.
|
|
104
|
+
* Consumers whose binary reads a different name (e.g. `'ZZZ_PORT'`)
|
|
105
|
+
* override.
|
|
106
|
+
*/
|
|
107
|
+
readonly port_env_var?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Initial value for `RUST_LOG`. Defaults to `'info'`. Consumers pass
|
|
110
|
+
* their binary-specific module filter
|
|
111
|
+
* (e.g. `'info,zzz_server=info,testing_zzz_server=info'`).
|
|
112
|
+
*/
|
|
113
|
+
readonly rust_log?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Shared builder for Rust-family backends. Owns the common env baseline
|
|
117
|
+
* (RUST_LOG, HOST, port, real Postgres, cookie keys, bootstrap token
|
|
118
|
+
* path, the `FUZ_TESTING_RESET_DB_ON_STARTUP=true` self-wipe gate) plus
|
|
119
|
+
* the 120s startup window for cargo's first-run build cost.
|
|
120
|
+
*/
|
|
121
|
+
export declare const make_default_rust_backend_config: (opts: MakeDefaultRustBackendConfigOptions) => BackendConfig;
|
|
122
|
+
//# sourceMappingURL=default_backend_configs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default_backend_configs.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/default_backend_configs.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAC,sBAAsB,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAA2B,KAAK,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAQ9F;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,mBAOpC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAOtC,CAAC;AAeH,MAAM,WAAW,iCAAiC;IACjD,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,oDAAoD;IACpD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAC5C,wEAAwE;IACxE,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,sEAAsE;IACtE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,GAC1C,MAAM,iCAAiC,KACrC,aAmCF,CAAC;AAEF,MAAM,WAAW,mCAAmC;IACnD,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,+CAA+C;IAC/C,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAC5C,wEAAwE;IACxE,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,sEAAsE;IACtE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,mCAAmC,KACvC,aA2CF,CAAC"}
|