Files
pikasTech-HWLAB/web/hwlab-cloud-web/scripts/workbench-fixed-transactional-architecture.test.ts
T
2026-07-14 07:18:51 +02:00

87 lines
3.6 KiB
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
import { fileURLToPath } from "node:url";
const repositoryRoot = fileURLToPath(new URL("../../..", import.meta.url));
const productionFiles = [
"internal/cloud/kafka-event-bridge.ts",
"internal/cloud/server-workbench-realtime-http.ts",
"internal/cloud/server-workbench-facts.ts",
"internal/cloud/server-code-agent-admission-http.ts",
"internal/cloud/server.ts",
"web/hwlab-cloud-web/src/config/runtime.ts",
"web/hwlab-cloud-web/src/api/workbench-events.ts",
"web/hwlab-cloud-web/src/utils/workbench-stream-transport.ts",
"web/hwlab-cloud-web/src/utils/workbench-realtime-runtime.ts",
"web/hwlab-cloud-web/src/stores/workbench.ts",
"web/hwlab-cloud-web/src/stores/workbench-colada-queries.ts",
"web/hwlab-cloud-web/src/stores/workbench-event-reducer.ts",
"web/hwlab-cloud-web/src/stores/workbench-realtime-plan.ts",
"web/hwlab-cloud-web/src/stores/workbench-session.ts",
"web/hwlab-cloud-web/src/stores/workbench-session-messages-read-budget.ts"
];
const forbiddenArchitectureIdentifiers = [
"directPublish",
"liveKafkaSse",
"kafkaRefreshReplay",
"transactionalProjector",
"projectionOutboxRelay",
"projectionRealtime",
"startLiveHwlabKafkaEventBridge",
"handleLiveKafkaWorkbenchRealtimeHttp",
"handleKafkaRefreshReplayWorkbenchRealtimeHttp",
"subscribeLiveHwlabEvents",
"queryHwlabEventRetention",
"WorkbenchRealtimeCapabilities",
"workbenchRealtimeCapabilities",
"workbenchHistoryAuthorityPolicy",
"workbenchRealtimeTransportEnabled",
"workbenchRealtimeTraceIdForCapabilities",
"workbenchProjectionEventStreamPath",
"scheduleSessionListRefresh",
"invalidateSessionList",
"fetchWorkbenchTurnStatus",
"refreshTurnStatusByTraceId",
"refreshMessageProjectionForTrace",
"selectActiveTurnStatusRefreshTraceIds",
"sessionDetailAutoReadDecision",
"projectionMergeCommitSummary",
"forceRead",
"handleWorkbenchSyncHttp",
"/v1/workbench/sync"
];
const obsoleteArchitectureEnv = [
"HWLAB_KAFKA_DIRECT_PUBLISH_ENABLED",
"HWLAB_WORKBENCH_LIVE_KAFKA_SSE_ENABLED",
"HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED",
"HWLAB_KAFKA_TRANSACTIONAL_PROJECTOR_ENABLED",
"HWLAB_KAFKA_PROJECTION_OUTBOX_RELAY_ENABLED",
"HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED"
];
test("Workbench production source has one fixed transactional projection architecture", async () => {
const violations: string[] = [];
for (const relativePath of productionFiles) {
const source = await readFile(`${repositoryRoot}/${relativePath}`, "utf8");
for (const identifier of forbiddenArchitectureIdentifiers) {
if (source.includes(identifier)) violations.push(`${relativePath}: ${identifier}`);
}
}
assert.deepEqual(violations, []);
});
test("production deploy does not render architecture selection env", async () => {
const deploySource = await readFile(`${repositoryRoot}/deploy/deploy.yaml`, "utf8");
const violations = obsoleteArchitectureEnv.filter((name) => deploySource.includes(name));
assert.deepEqual(violations, []);
});
test("raw hwlab Kafka fixtures remain isolated to the explicit debug path", async () => {
const fixtureSource = await readFile(`${repositoryRoot}/web/hwlab-cloud-web/src/stores/workbench-live-kafka-event.ts`, "utf8");
const debugSource = await readFile(`${repositoryRoot}/web/hwlab-cloud-web/src/stores/workbench-isolated-kafka-debug.ts`, "utf8");
assert.match(fixtureSource, /historical hwlab\.event\.debug\.v1 fixtures/u);
assert.match(fixtureSource, /never imported by the product Workbench SSE path/u);
assert.match(debugSource, /workbench-live-kafka-event/u);
});