gencow 0.1.298 → 0.2.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/bin/gencow.mjs +0 -6
- package/core/index.js +261 -1447
- package/core/package.json +1 -1
- package/dashboard/assets/{index-BnBn8uo4.js → index-DYqUzCmS.js} +3 -3
- package/dashboard/assets/index-OH2xW1ZG.css +2 -0
- package/dashboard/index.html +2 -2
- package/docs/packaging.md +14 -4
- package/lib/cli-artifact-guard.mjs +53 -3
- package/lib/cli-command-runner.d.mts +11 -0
- package/lib/cli-dev-runtime.mjs +1 -0
- package/lib/cli-project-runtime.mjs +26 -14
- package/lib/codegen-command.mjs +16 -0
- package/lib/coding-guardrails.mjs +2 -0
- package/lib/component-readme.mjs +4 -4
- package/lib/dashboard-artifact.mjs +65 -0
- package/lib/dashboard-assets.mjs +20 -0
- package/lib/db-command.mjs +121 -80
- package/lib/db-migration-command-steps.mjs +19 -16
- package/lib/db-push-command.mjs +1 -1
- package/lib/deploy-codegen-preflight.mjs +1 -0
- package/lib/deploy-cron-manifest-diagnostic.mjs +93 -0
- package/lib/deploy-failure-diagnostic.mjs +4 -43
- package/lib/deploy-route-target-rejection-diagnostic.mjs +43 -0
- package/lib/dev-cloud-command.mjs +1 -1
- package/lib/dev-local-command.mjs +19 -56
- package/lib/document-local-converter.mjs +11 -0
- package/lib/jobs-command.mjs +33 -1
- package/lib/local-dashboard-plan.mjs +60 -0
- package/lib/local-database-commands.mjs +127 -0
- package/lib/local-development-migrations.mjs +157 -0
- package/lib/local-drizzle-database.config.mjs +10 -0
- package/lib/local-runtime-features.mjs +12 -0
- package/lib/rag-selection.mjs +7 -0
- package/lib/readme-codegen.mjs +2 -2
- package/lib/runtime-local-worker.mjs +116 -0
- package/lib/runtime-mode.mjs +3 -0
- package/lib/standalone-codegen-adapter.mjs +91 -0
- package/lib/ts-codegen-import-extension.mjs +228 -19
- package/package.json +16 -9
- package/runtime/config.mjs +218 -2
- package/runtime/dependency-lock.mjs +5 -1
- package/runtime/engine/chunk-2HA4CUMS.mjs +90 -0
- package/runtime/engine/chunk-2JLO3KMM.mjs +305 -0
- package/runtime/engine/chunk-2SR2M7SR.mjs +1045 -0
- package/runtime/engine/chunk-3D7MHEUC.mjs +253 -0
- package/runtime/engine/chunk-3R7COBWG.mjs +309 -0
- package/runtime/engine/chunk-3ZKA54UW.mjs +1560 -0
- package/runtime/engine/chunk-45I4YR2J.mjs +9 -0
- package/runtime/engine/chunk-4MLRXO7F.mjs +74 -0
- package/runtime/engine/chunk-5575APCJ.mjs +215 -0
- package/runtime/engine/chunk-5GUJZQF3.mjs +114 -0
- package/runtime/engine/chunk-5MXY3T75.mjs +428 -0
- package/runtime/engine/chunk-5TACQ2US.mjs +44 -0
- package/runtime/engine/chunk-66G4YEDT.mjs +3104 -0
- package/runtime/engine/chunk-67YO53WW.mjs +1426 -0
- package/runtime/engine/chunk-6GQRM7XY.mjs +87 -0
- package/runtime/engine/chunk-6JO72SPP.mjs +68 -0
- package/runtime/engine/chunk-6W653LXI.mjs +13 -0
- package/runtime/engine/chunk-7ITSMI3S.mjs +69 -0
- package/runtime/engine/chunk-7KUJ2H2S.mjs +128 -0
- package/runtime/engine/chunk-A5BMQ5IC.mjs +45 -0
- package/runtime/engine/chunk-ADF3UR6L.mjs +428 -0
- package/runtime/engine/chunk-AEBW7XZJ.mjs +4510 -0
- package/runtime/engine/chunk-AGPQ5XIV.mjs +156 -0
- package/runtime/engine/chunk-CPU4OZSX.mjs +753 -0
- package/runtime/engine/chunk-CSWPPWBL.mjs +50 -0
- package/runtime/engine/chunk-DPWXSMWO.mjs +53 -0
- package/runtime/engine/chunk-EAIELFKU.mjs +151 -0
- package/runtime/engine/chunk-EDU5CBKT.mjs +10 -0
- package/runtime/engine/chunk-EQCTAET7.mjs +173 -0
- package/runtime/engine/chunk-EQCXDF2Z.mjs +70 -0
- package/runtime/engine/chunk-F3G4UGV4.mjs +330 -0
- package/runtime/engine/chunk-F62NUNOO.mjs +26 -0
- package/runtime/engine/chunk-FKPNIFRP.mjs +2492 -0
- package/runtime/engine/chunk-FM23RGVI.mjs +81 -0
- package/runtime/engine/chunk-FW5AK4YP.mjs +1041 -0
- package/runtime/engine/chunk-GDWYAGWV.mjs +23 -0
- package/runtime/engine/chunk-GO5PZUYW.mjs +53 -0
- package/runtime/engine/chunk-GOLP7OSG.mjs +340 -0
- package/runtime/engine/chunk-GSLM44EF.mjs +242 -0
- package/runtime/engine/chunk-GYAJ7OX2.mjs +125 -0
- package/runtime/engine/chunk-I3GWR43K.mjs +14 -0
- package/runtime/engine/chunk-IFMOTJNU.mjs +106 -0
- package/runtime/engine/chunk-IKQKBE2G.mjs +128 -0
- package/runtime/engine/chunk-ITH2NEKM.mjs +282 -0
- package/runtime/engine/chunk-J6SDRCG4.mjs +96 -0
- package/runtime/engine/chunk-JODRNM3S.mjs +29596 -0
- package/runtime/engine/chunk-JUDKX53X.mjs +137 -0
- package/runtime/engine/chunk-K2YZVPJ4.mjs +827 -0
- package/runtime/engine/chunk-KEZJUXEE.mjs +151 -0
- package/runtime/engine/chunk-KVLTJFCH.mjs +234 -0
- package/runtime/engine/chunk-KX2PRQPS.mjs +126 -0
- package/runtime/engine/chunk-LEW5ZMLR.mjs +76 -0
- package/runtime/engine/chunk-LINVSJEM.mjs +175 -0
- package/runtime/engine/chunk-M7K2ICSM.mjs +11 -0
- package/runtime/engine/chunk-MZXDXSDC.mjs +292 -0
- package/runtime/engine/chunk-N2TA2IK2.mjs +678 -0
- package/runtime/engine/chunk-N4LTCKJP.mjs +695 -0
- package/runtime/engine/chunk-N6GCLOUX.mjs +13 -0
- package/runtime/engine/chunk-NAG2OXS5.mjs +37 -0
- package/runtime/engine/chunk-NNZ2QJUG.mjs +381 -0
- package/runtime/engine/chunk-NZPPLDNW.mjs +15 -0
- package/runtime/engine/chunk-ODWM57W6.mjs +138 -0
- package/runtime/engine/chunk-P5IIXAIE.mjs +23 -0
- package/runtime/engine/chunk-PBOXB2BV.mjs +6 -0
- package/runtime/engine/chunk-PMOJLN2P.mjs +8 -0
- package/runtime/engine/chunk-PZFMKFHO.mjs +180 -0
- package/runtime/engine/chunk-QL2TQX2N.mjs +114 -0
- package/runtime/engine/chunk-RITT2RSJ.mjs +258 -0
- package/runtime/engine/chunk-RODBVJ5M.mjs +135 -0
- package/runtime/engine/chunk-RW65MPVY.mjs +261 -0
- package/runtime/engine/chunk-S67UYPB6.mjs +25 -0
- package/runtime/engine/chunk-SVJCOUI3.mjs +47 -0
- package/runtime/engine/chunk-TCN3ZASV.mjs +957 -0
- package/runtime/engine/chunk-U2NRG6KC.mjs +32 -0
- package/runtime/engine/chunk-UM3F7HUV.mjs +432 -0
- package/runtime/engine/chunk-VWU7JJ3P.mjs +146 -0
- package/runtime/engine/chunk-WDTKPPMU.mjs +310 -0
- package/runtime/engine/chunk-WJOO4XTB.mjs +31 -0
- package/runtime/engine/chunk-XNFVL2OY.mjs +63 -0
- package/runtime/engine/chunk-XPWJXP2J.mjs +58 -0
- package/runtime/engine/chunk-Y3HSBJ3I.mjs +1132 -0
- package/runtime/engine/chunk-YMH4RYSX.mjs +317 -0
- package/runtime/engine/chunk-YNOMPSGS.mjs +8 -0
- package/runtime/engine/chunk-YRBAYTEZ.mjs +251 -0
- package/runtime/engine/chunk-YRHM272W.mjs +528 -0
- package/runtime/engine/chunk-ZQUZAGIQ.mjs +149 -0
- package/runtime/engine/chunk-ZXMM7QFP.mjs +176 -0
- package/runtime/engine/chunk-ZZJSIPV2.mjs +262 -0
- package/runtime/engine/composition.mjs +325 -0
- package/runtime/engine/document-local.mjs +504 -0
- package/runtime/engine/graph.json +4134 -0
- package/runtime/engine/index.mjs +265 -0
- package/runtime/engine/local-postgres-support.mjs +69 -0
- package/runtime/engine/local.mjs +3275 -0
- package/runtime/engine/pglite-directory-lock.mjs +8 -0
- package/runtime/engine/rag.mjs +11 -0
- package/runtime/engine/search.mjs +18 -0
- package/runtime/framework-migrations/foundation-bootstrap/rag.sql +115 -0
- package/runtime/framework-migrations/foundation-bootstrap/workflow.sql +194 -0
- package/runtime/framework-migrations/journal-bootstrap/migration.sql +26 -0
- package/runtime/framework-migrations/manifest.json +56 -0
- package/runtime/framework-migrations/rag/20261006111509_mushy_warhawk/migration.sql +121 -0
- package/runtime/framework-migrations/rag/20261013234621_rag_v2_lifecycle_markers/migration.sql +6 -0
- package/runtime/framework-migrations/workflow/20261006111508_perpetual_star_brand/migration.sql +31 -0
- package/runtime/runtime-metadata.json +27 -0
- package/runtime/tooling.mjs +10549 -10543
- package/scripts/bundle-runtime-config.mjs +23 -0
- package/scripts/bundle-runtime.mjs +100 -0
- package/scripts/bundle-runtime.test.mjs +33 -0
- package/scripts/bundle-shared.mjs +3 -0
- package/scripts/copy-dashboard.mjs +16 -0
- package/scripts/pre-publish-check.mjs +23 -11
- package/templateFeature/ai/ai-embedding-result.ts +82 -0
- package/templateFeature/ai/ai-facade.ts +24 -7
- package/templateFeature/ai/ai-provider.ts +17 -1
- package/templateFeature/ai/ai.ts +1 -0
- package/templateFeature/ai/manifest.json +4 -3
- package/templateFeature/reranker/manifest.json +1 -1
- package/templateFeature/reranker/reranker.ts +4 -3
- package/templateFeature/sso/sso-auth-callback.tsx +37 -5
- package/templateFeature/tools/manifest.json +2 -1
- package/templateFeature/tools/tools.ts +3 -3
- package/dashboard/assets/index-C6-BpKKR.css +0 -2
- package/runtime/server.mjs +0 -14320
- package/scripts/bundle-server.mjs +0 -223
- package/server/config.js +0 -1
- package/server/index.js +0 -1
- package/server/package.json +0 -6
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
snapshotRuntimeBinding
|
|
3
|
+
} from "./chunk-WDTKPPMU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
admitRuntimeDatabaseSchemaPlan,
|
|
6
|
+
inspectRuntimeDatabaseSchemaPlan
|
|
7
|
+
} from "./chunk-3D7MHEUC.mjs";
|
|
8
|
+
import {
|
|
9
|
+
runtimeDatabaseSetupDeadlineReason,
|
|
10
|
+
runtimeDatabaseSetupError,
|
|
11
|
+
runtimeDatabaseSetupInterrupted
|
|
12
|
+
} from "./chunk-SVJCOUI3.mjs";
|
|
13
|
+
import {
|
|
14
|
+
RuntimeDiagnosticError,
|
|
15
|
+
runtimeDiagnostic
|
|
16
|
+
} from "./chunk-AEBW7XZJ.mjs";
|
|
17
|
+
|
|
18
|
+
// ../runtime/dist/database-setup/coordinator.js
|
|
19
|
+
import { randomUUID } from "node:crypto";
|
|
20
|
+
var proofs = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
function assertRuntimeDatabaseSchemaReady(ready, database, binding, required = []) {
|
|
22
|
+
const proof = proofs.get(ready);
|
|
23
|
+
if (!proof || proof.database !== database || proof.binding.appId !== binding.appId || proof.binding.generationId !== binding.generationId || required.some((expected) => !ready.components.some((actual) => actual.id === expected.id && actual.contractVersion === expected.contractVersion)))
|
|
24
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_COMPONENT_INVALID");
|
|
25
|
+
}
|
|
26
|
+
function runtimeDatabaseSchemaReadyImpact(ready, database, binding) {
|
|
27
|
+
assertRuntimeDatabaseSchemaReady(ready, database, binding);
|
|
28
|
+
return proofs.get(ready).impact;
|
|
29
|
+
}
|
|
30
|
+
function runtimeDatabaseSchemaReadyCorrelation(ready, database, binding) {
|
|
31
|
+
assertRuntimeDatabaseSchemaReady(ready, database, binding);
|
|
32
|
+
return proofs.get(ready).correlationId;
|
|
33
|
+
}
|
|
34
|
+
function createRuntimeDatabaseSchemaCoordinator(input) {
|
|
35
|
+
const plan = admitRuntimeDatabaseSchemaPlan(input.components);
|
|
36
|
+
const binding = snapshotRuntimeBinding(input.binding);
|
|
37
|
+
const database = input.database;
|
|
38
|
+
const parentSignal = input.signal;
|
|
39
|
+
const deadlineMs = input.deadlineMs ?? 3e4;
|
|
40
|
+
if (!Number.isFinite(deadlineMs) || deadlineMs <= 0 || deadlineMs > 3e4)
|
|
41
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_COMPONENT_INVALID");
|
|
42
|
+
const inspect = input.port.inspectOperational.bind(input.port);
|
|
43
|
+
const execute = input.port.withSetupTransaction.bind(input.port);
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const correlationId = randomUUID();
|
|
46
|
+
let closed = false;
|
|
47
|
+
let readiness;
|
|
48
|
+
let readyImpact = "none";
|
|
49
|
+
let pending;
|
|
50
|
+
let deadlineAt = Number.POSITIVE_INFINITY;
|
|
51
|
+
function active(impact = "none") {
|
|
52
|
+
if (performance.now() >= deadlineAt)
|
|
53
|
+
controller.abort(runtimeDatabaseSetupDeadlineReason);
|
|
54
|
+
if (closed || controller.signal.aborted)
|
|
55
|
+
throw runtimeDatabaseSetupInterrupted(controller.signal, impact, correlationId);
|
|
56
|
+
}
|
|
57
|
+
async function prepare() {
|
|
58
|
+
deadlineAt = performance.now() + deadlineMs;
|
|
59
|
+
const abort = () => controller.abort(parentSignal?.reason === runtimeDatabaseSetupDeadlineReason ? runtimeDatabaseSetupDeadlineReason : void 0);
|
|
60
|
+
parentSignal?.addEventListener("abort", abort, { once: true });
|
|
61
|
+
if (parentSignal?.aborted)
|
|
62
|
+
abort();
|
|
63
|
+
const timer = setTimeout(() => controller.abort(runtimeDatabaseSetupDeadlineReason), deadlineMs);
|
|
64
|
+
let impact = "none";
|
|
65
|
+
try {
|
|
66
|
+
active();
|
|
67
|
+
if (plan.components.length) {
|
|
68
|
+
const first = inspectRuntimeDatabaseSchemaPlan(plan, await inspect(plan, controller.signal));
|
|
69
|
+
active();
|
|
70
|
+
if (first.some((component) => component.steps.length)) {
|
|
71
|
+
const receipt = await execute(plan, controller.signal, async (session) => {
|
|
72
|
+
active();
|
|
73
|
+
const locked = inspectRuntimeDatabaseSchemaPlan(plan, await session.inspect());
|
|
74
|
+
for (const entry of locked)
|
|
75
|
+
for (const step of entry.steps) {
|
|
76
|
+
active();
|
|
77
|
+
await session.applyStep(entry.component.id, step.id);
|
|
78
|
+
}
|
|
79
|
+
active();
|
|
80
|
+
if (inspectRuntimeDatabaseSchemaPlan(plan, await session.inspect()).some((entry) => entry.steps.length))
|
|
81
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_ACCESS_UNAVAILABLE", "none", correlationId);
|
|
82
|
+
active();
|
|
83
|
+
}).catch((error) => {
|
|
84
|
+
if (runtimeDiagnostic(error))
|
|
85
|
+
throw error;
|
|
86
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_OUTCOME_UNKNOWN", "unknown", correlationId);
|
|
87
|
+
});
|
|
88
|
+
if (!receipt || receipt.impact !== "none" && receipt.impact !== "committed")
|
|
89
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_OUTCOME_UNKNOWN", "unknown", correlationId);
|
|
90
|
+
impact = receipt.impact;
|
|
91
|
+
active(impact);
|
|
92
|
+
try {
|
|
93
|
+
const operational = inspectRuntimeDatabaseSchemaPlan(plan, receipt.operationalCatalog ?? await inspect(plan, controller.signal));
|
|
94
|
+
if (operational.some((entry) => entry.steps.length))
|
|
95
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_ACCESS_UNAVAILABLE", impact, correlationId);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const diagnostic = runtimeDiagnostic(error);
|
|
98
|
+
if (diagnostic)
|
|
99
|
+
throw new RuntimeDiagnosticError({ ...diagnostic, dataImpact: impact, correlationId });
|
|
100
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_ACCESS_UNAVAILABLE", impact, correlationId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
active(impact);
|
|
105
|
+
readiness = Object.freeze({
|
|
106
|
+
binding,
|
|
107
|
+
components: Object.freeze(plan.components.map(({ id, contractVersion }) => Object.freeze({ id, contractVersion })))
|
|
108
|
+
});
|
|
109
|
+
proofs.set(readiness, { database, binding, impact, correlationId });
|
|
110
|
+
readyImpact = impact;
|
|
111
|
+
return readiness;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
const diagnostic = runtimeDiagnostic(error);
|
|
114
|
+
if (controller.signal.aborted && (!diagnostic || diagnostic.code === "RUNTIME_DATABASE_SETUP_FAILED"))
|
|
115
|
+
throw runtimeDatabaseSetupInterrupted(controller.signal, diagnostic?.dataImpact ?? impact, diagnostic?.correlationId ?? correlationId);
|
|
116
|
+
if (runtimeDiagnostic(error))
|
|
117
|
+
throw error;
|
|
118
|
+
throw runtimeDatabaseSetupError("RUNTIME_DATABASE_SETUP_FAILED", impact, correlationId);
|
|
119
|
+
} finally {
|
|
120
|
+
clearTimeout(timer);
|
|
121
|
+
parentSignal?.removeEventListener("abort", abort);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return Object.freeze({
|
|
125
|
+
plan,
|
|
126
|
+
ready() {
|
|
127
|
+
if (closed)
|
|
128
|
+
return pending ? pending.then(() => {
|
|
129
|
+
throw runtimeDatabaseSetupInterrupted(controller.signal, readyImpact, correlationId);
|
|
130
|
+
}, (error) => {
|
|
131
|
+
throw error;
|
|
132
|
+
}) : Promise.reject(runtimeDatabaseSetupInterrupted(controller.signal, "none", correlationId));
|
|
133
|
+
return pending ??= prepare();
|
|
134
|
+
},
|
|
135
|
+
async close() {
|
|
136
|
+
closed = true;
|
|
137
|
+
controller.abort();
|
|
138
|
+
await pending?.catch(() => {
|
|
139
|
+
});
|
|
140
|
+
if (readiness)
|
|
141
|
+
proofs.delete(readiness);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
assertRuntimeDatabaseSchemaReady,
|
|
148
|
+
runtimeDatabaseSchemaReadyImpact,
|
|
149
|
+
runtimeDatabaseSchemaReadyCorrelation,
|
|
150
|
+
createRuntimeDatabaseSchemaCoordinator
|
|
151
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runtimeWorkflowListReadTaskId
|
|
3
|
+
} from "./chunk-7KUJ2H2S.mjs";
|
|
4
|
+
|
|
5
|
+
// ../runtime/dist/app/private-startup-observation.js
|
|
6
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
|
+
import { performance } from "node:perf_hooks";
|
|
8
|
+
var observations = new AsyncLocalStorage();
|
|
9
|
+
var allowedStages = /* @__PURE__ */ new Set([
|
|
10
|
+
"generation.resolve",
|
|
11
|
+
"application.load",
|
|
12
|
+
"configuration.resolve",
|
|
13
|
+
"provider.prerequisites",
|
|
14
|
+
"auth.artifacts",
|
|
15
|
+
"auth.accessTokenKey",
|
|
16
|
+
"auth.optionsParse",
|
|
17
|
+
"profile.graphAssembly",
|
|
18
|
+
"buildRuntimeComposition",
|
|
19
|
+
"composition.initialize",
|
|
20
|
+
"databaseResourceResolve",
|
|
21
|
+
"databaseSchemaReady",
|
|
22
|
+
"databaseCatalogShape",
|
|
23
|
+
"databaseCatalogAccess",
|
|
24
|
+
"databaseCatalogPrograms",
|
|
25
|
+
"databaseCatalogRelations",
|
|
26
|
+
"databaseCatalogColumns",
|
|
27
|
+
"databaseCatalogConstraints",
|
|
28
|
+
"databaseCatalogIndexes",
|
|
29
|
+
"databaseCatalogSequences",
|
|
30
|
+
"databaseCatalogRelationBehavior",
|
|
31
|
+
"databaseCatalogExtensions",
|
|
32
|
+
"initializeRemainder",
|
|
33
|
+
"composition.startJobs",
|
|
34
|
+
"pgliteWaitReady",
|
|
35
|
+
"pgliteAdapterBootstrap"
|
|
36
|
+
]);
|
|
37
|
+
var catalogDetailStages = /* @__PURE__ */ new Set([
|
|
38
|
+
"databaseCatalogShape",
|
|
39
|
+
"databaseCatalogAccess",
|
|
40
|
+
"databaseCatalogPrograms",
|
|
41
|
+
"databaseCatalogRelations",
|
|
42
|
+
"databaseCatalogColumns",
|
|
43
|
+
"databaseCatalogConstraints",
|
|
44
|
+
"databaseCatalogIndexes",
|
|
45
|
+
"databaseCatalogSequences",
|
|
46
|
+
"databaseCatalogRelationBehavior",
|
|
47
|
+
"databaseCatalogExtensions"
|
|
48
|
+
]);
|
|
49
|
+
var defaultNow = () => performance.now();
|
|
50
|
+
var runtimeStartupObservationMaxRecords = 64;
|
|
51
|
+
var startupRecordPrefix = `[runtime-test] STARTUP ${runtimeWorkflowListReadTaskId}`;
|
|
52
|
+
function currentObservation() {
|
|
53
|
+
try {
|
|
54
|
+
const store = observations.getStore();
|
|
55
|
+
return store?.active.enabled ? store : void 0;
|
|
56
|
+
} catch {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function safeNow(store) {
|
|
61
|
+
try {
|
|
62
|
+
const value = store.now();
|
|
63
|
+
return Number.isFinite(value) ? value : void 0;
|
|
64
|
+
} catch {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function recordElapsed(store, stage, start) {
|
|
69
|
+
if (!store.active.enabled)
|
|
70
|
+
return;
|
|
71
|
+
const end = safeNow(store);
|
|
72
|
+
if (end === void 0 || end < start)
|
|
73
|
+
return;
|
|
74
|
+
const wallMs = Math.round((end - start) * 100) / 100;
|
|
75
|
+
if (!Number.isFinite(wallMs) || wallMs < 0)
|
|
76
|
+
return;
|
|
77
|
+
if (!allowedStages.has(stage))
|
|
78
|
+
return;
|
|
79
|
+
const qualifiedStage = store.slot === 0 ? `${stage}.slot0` : `${stage}.slot1`;
|
|
80
|
+
try {
|
|
81
|
+
store.record(qualifiedStage, wallMs, start, end);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function markRuntimeStartupStage(stage) {
|
|
86
|
+
const store = currentObservation();
|
|
87
|
+
if (!store || !allowedStages.has(stage) || catalogDetailStages.has(stage) && !store.catalogDetails)
|
|
88
|
+
return void 0;
|
|
89
|
+
return safeNow(store);
|
|
90
|
+
}
|
|
91
|
+
function recordRuntimeStartupStage(stage, start) {
|
|
92
|
+
if (start === void 0)
|
|
93
|
+
return;
|
|
94
|
+
const store = currentObservation();
|
|
95
|
+
if (!store || !allowedStages.has(stage) || catalogDetailStages.has(stage) && !store.catalogDetails)
|
|
96
|
+
return;
|
|
97
|
+
recordElapsed(store, stage, start);
|
|
98
|
+
}
|
|
99
|
+
function observeRuntimeStartupSyncStage(stage, operation) {
|
|
100
|
+
const store = currentObservation();
|
|
101
|
+
if (!store || !allowedStages.has(stage))
|
|
102
|
+
return operation();
|
|
103
|
+
const start = safeNow(store);
|
|
104
|
+
if (start === void 0)
|
|
105
|
+
return operation();
|
|
106
|
+
let result;
|
|
107
|
+
try {
|
|
108
|
+
result = operation();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
recordElapsed(store, stage, start);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
recordElapsed(store, stage, start);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
function observeRuntimeStartupStage(stage, operation) {
|
|
117
|
+
const store = currentObservation();
|
|
118
|
+
if (!store || !allowedStages.has(stage) || catalogDetailStages.has(stage) && !store.catalogDetails)
|
|
119
|
+
return operation();
|
|
120
|
+
const start = safeNow(store);
|
|
121
|
+
if (start === void 0)
|
|
122
|
+
return operation();
|
|
123
|
+
let result;
|
|
124
|
+
try {
|
|
125
|
+
result = operation();
|
|
126
|
+
} catch (error) {
|
|
127
|
+
recordElapsed(store, stage, start);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
return Promise.resolve(result).then((value) => {
|
|
131
|
+
recordElapsed(store, stage, start);
|
|
132
|
+
return value;
|
|
133
|
+
}, (error) => {
|
|
134
|
+
recordElapsed(store, stage, start);
|
|
135
|
+
throw error;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function runWithRuntimeStartupObservation(slot, record, operation, now = defaultNow, catalogDetails = false) {
|
|
139
|
+
const active = { enabled: true };
|
|
140
|
+
const store = Object.freeze({ slot, record, now, active, catalogDetails });
|
|
141
|
+
let callbackStarted = false;
|
|
142
|
+
try {
|
|
143
|
+
return observations.run(store, () => {
|
|
144
|
+
callbackStarted = true;
|
|
145
|
+
let result;
|
|
146
|
+
try {
|
|
147
|
+
result = operation();
|
|
148
|
+
} catch (error) {
|
|
149
|
+
active.enabled = false;
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
return Promise.resolve(result).then((value) => {
|
|
153
|
+
active.enabled = false;
|
|
154
|
+
return value;
|
|
155
|
+
}, (error) => {
|
|
156
|
+
active.enabled = false;
|
|
157
|
+
throw error;
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
} catch (error) {
|
|
161
|
+
active.enabled = false;
|
|
162
|
+
if (callbackStarted)
|
|
163
|
+
throw error;
|
|
164
|
+
return Promise.resolve(operation());
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function runWithSelectedRuntimeStartupObservation(options) {
|
|
168
|
+
let selected = false;
|
|
169
|
+
try {
|
|
170
|
+
const environment = options.environment;
|
|
171
|
+
selected = environment.GENCOW_RUNTIME_TEST_TASK_ID === runtimeWorkflowListReadTaskId && typeof environment.GENCOW_RUNTIME_TEST_METRICS_DIR === "string" && environment.GENCOW_RUNTIME_TEST_METRICS_DIR.length > 0;
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
if (!selected)
|
|
175
|
+
return options.operation();
|
|
176
|
+
const records = [];
|
|
177
|
+
let flushed = false;
|
|
178
|
+
const record = (stage, wallMs) => {
|
|
179
|
+
if (records.length >= runtimeStartupObservationMaxRecords)
|
|
180
|
+
return;
|
|
181
|
+
const stageName = stage.endsWith(".slot0") ? stage.slice(0, -".slot0".length) : void 0;
|
|
182
|
+
if (!stageName || !allowedStages.has(stageName))
|
|
183
|
+
return;
|
|
184
|
+
if (typeof wallMs !== "number" || !Number.isFinite(wallMs) || wallMs < 0)
|
|
185
|
+
return;
|
|
186
|
+
const rounded = Math.round(wallMs * 100) / 100;
|
|
187
|
+
if (!Number.isFinite(rounded) || rounded < 0)
|
|
188
|
+
return;
|
|
189
|
+
const duration = String(rounded);
|
|
190
|
+
records.push(`${startupRecordPrefix} stage=${stage} wallMs=${duration}`);
|
|
191
|
+
};
|
|
192
|
+
const flush = () => {
|
|
193
|
+
if (flushed)
|
|
194
|
+
return;
|
|
195
|
+
flushed = true;
|
|
196
|
+
for (const line of records) {
|
|
197
|
+
try {
|
|
198
|
+
const result = options.write(line);
|
|
199
|
+
if (result !== void 0)
|
|
200
|
+
void Promise.resolve(result).catch(() => {
|
|
201
|
+
});
|
|
202
|
+
} catch {
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
let composition;
|
|
207
|
+
let now = defaultNow;
|
|
208
|
+
try {
|
|
209
|
+
now = options.monotonicNow ?? defaultNow;
|
|
210
|
+
} catch {
|
|
211
|
+
now = () => Number.NaN;
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
composition = runWithRuntimeStartupObservation(0, record, options.operation, now);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
flush();
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
return Promise.resolve(composition).then((result) => {
|
|
220
|
+
flush();
|
|
221
|
+
return result;
|
|
222
|
+
}, (error) => {
|
|
223
|
+
flush();
|
|
224
|
+
throw error;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
markRuntimeStartupStage,
|
|
230
|
+
recordRuntimeStartupStage,
|
|
231
|
+
observeRuntimeStartupSyncStage,
|
|
232
|
+
observeRuntimeStartupStage,
|
|
233
|
+
runWithSelectedRuntimeStartupObservation
|
|
234
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// ../runtime/dist/adapters/database/owned-postgres-query-failure.js
|
|
2
|
+
var ownedFailures = /* @__PURE__ */ new WeakSet();
|
|
3
|
+
var ownedRejections = /* @__PURE__ */ new WeakSet();
|
|
4
|
+
var rejectionEvidence = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
var rejectionSqlStates = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
var driverCodes = /* @__PURE__ */ new Set([
|
|
7
|
+
"ERR_POSTGRES_CONNECTION_CLOSED",
|
|
8
|
+
"ERR_POSTGRES_CONNECTION_TIMEOUT",
|
|
9
|
+
"ERR_POSTGRES_CONNECTION_LOST"
|
|
10
|
+
]);
|
|
11
|
+
function markOwnedPostgresQueryFailure(error) {
|
|
12
|
+
if (!isRecord(error) || !hasTransientCode(error))
|
|
13
|
+
return;
|
|
14
|
+
ownedFailures.add(error);
|
|
15
|
+
}
|
|
16
|
+
function markOwnedPostgresQueryRejection(error, evidence, sqlState) {
|
|
17
|
+
if (!isRecord(error))
|
|
18
|
+
return;
|
|
19
|
+
ownedRejections.add(error);
|
|
20
|
+
if (sqlState && /^[0-9A-Z]{5}$/.test(sqlState))
|
|
21
|
+
rejectionSqlStates.set(error, sqlState);
|
|
22
|
+
if (!evidence)
|
|
23
|
+
return;
|
|
24
|
+
const evidenceSet = rejectionEvidence.get(error) ?? /* @__PURE__ */ new Set();
|
|
25
|
+
evidenceSet.add(evidence);
|
|
26
|
+
rejectionEvidence.set(error, evidenceSet);
|
|
27
|
+
}
|
|
28
|
+
function ownedPostgresQueryFailure(error) {
|
|
29
|
+
return hasOwnedMarker(error, ownedFailures);
|
|
30
|
+
}
|
|
31
|
+
function ownedPostgresQueryRejection(error, evidence) {
|
|
32
|
+
const visited = /* @__PURE__ */ new Set();
|
|
33
|
+
let candidate = error;
|
|
34
|
+
for (let depth = 0; isRecord(candidate) && depth < 8 && !visited.has(candidate); depth++) {
|
|
35
|
+
visited.add(candidate);
|
|
36
|
+
if (ownedRejections.has(candidate)) {
|
|
37
|
+
if (!evidence || rejectionEvidence.get(candidate)?.has(evidence))
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
candidate = ownDataValue(candidate, "cause");
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function ownedPostgresQuerySqlState(error, evidence) {
|
|
45
|
+
if (!isRecord(error) || !ownedRejections.has(error))
|
|
46
|
+
return void 0;
|
|
47
|
+
if (evidence && !rejectionEvidence.get(error)?.has(evidence))
|
|
48
|
+
return void 0;
|
|
49
|
+
return rejectionSqlStates.get(error);
|
|
50
|
+
}
|
|
51
|
+
function ownedPostgresQuerySqlStateInCause(error, evidence) {
|
|
52
|
+
const visited = /* @__PURE__ */ new Set();
|
|
53
|
+
let candidate = error;
|
|
54
|
+
for (let depth = 0; isRecord(candidate) && depth < 8 && !visited.has(candidate); depth++) {
|
|
55
|
+
visited.add(candidate);
|
|
56
|
+
const state = ownedPostgresQuerySqlState(candidate, evidence);
|
|
57
|
+
if (state)
|
|
58
|
+
return state;
|
|
59
|
+
candidate = ownDataValue(candidate, "cause");
|
|
60
|
+
}
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
function copyOwnedPostgresQueryRejection(source, target) {
|
|
64
|
+
if (!isRecord(target))
|
|
65
|
+
return;
|
|
66
|
+
const visited = /* @__PURE__ */ new Set();
|
|
67
|
+
let candidate = source;
|
|
68
|
+
for (let depth = 0; isRecord(candidate) && depth < 8 && !visited.has(candidate); depth++) {
|
|
69
|
+
visited.add(candidate);
|
|
70
|
+
if (ownedRejections.has(candidate)) {
|
|
71
|
+
markOwnedPostgresQueryRejection(target, void 0, rejectionSqlStates.get(candidate));
|
|
72
|
+
const evidence = rejectionEvidence.get(candidate);
|
|
73
|
+
if (evidence)
|
|
74
|
+
for (const marker of evidence)
|
|
75
|
+
markOwnedPostgresQueryRejection(target, marker, rejectionSqlStates.get(candidate));
|
|
76
|
+
}
|
|
77
|
+
candidate = ownDataValue(candidate, "cause");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function hasOwnedMarker(error, marker) {
|
|
81
|
+
const visited = /* @__PURE__ */ new Set();
|
|
82
|
+
let candidate = error;
|
|
83
|
+
for (let depth = 0; isRecord(candidate) && depth < 8 && !visited.has(candidate); depth++) {
|
|
84
|
+
visited.add(candidate);
|
|
85
|
+
if (marker.has(candidate))
|
|
86
|
+
return true;
|
|
87
|
+
candidate = ownDataValue(candidate, "cause");
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
function hasTransientCode(error) {
|
|
92
|
+
const visited = /* @__PURE__ */ new Set();
|
|
93
|
+
let candidate = error;
|
|
94
|
+
for (let depth = 0; isRecord(candidate) && depth < 8 && !visited.has(candidate); depth++) {
|
|
95
|
+
visited.add(candidate);
|
|
96
|
+
const code = ownDataValue(candidate, "code");
|
|
97
|
+
const errno = ownDataValue(candidate, "errno");
|
|
98
|
+
const driverCode = ownDataValue(candidate, "driverCode");
|
|
99
|
+
if (code === "08006" || errno === "08006" || // A terminated backend can report admin_shutdown before socket closure.
|
|
100
|
+
code === "57P01" || errno === "57P01" || typeof code === "string" && driverCodes.has(code) || typeof driverCode === "string" && driverCodes.has(driverCode))
|
|
101
|
+
return true;
|
|
102
|
+
candidate = ownDataValue(candidate, "cause");
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
function ownDataValue(value, key) {
|
|
107
|
+
try {
|
|
108
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
109
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
110
|
+
} catch {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function isRecord(value) {
|
|
115
|
+
return typeof value === "object" && value !== null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
markOwnedPostgresQueryFailure,
|
|
120
|
+
markOwnedPostgresQueryRejection,
|
|
121
|
+
ownedPostgresQueryFailure,
|
|
122
|
+
ownedPostgresQueryRejection,
|
|
123
|
+
ownedPostgresQuerySqlState,
|
|
124
|
+
ownedPostgresQuerySqlStateInCause,
|
|
125
|
+
copyOwnedPostgresQueryRejection
|
|
126
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requestContextInputError,
|
|
3
|
+
snapshotRuntimeRls
|
|
4
|
+
} from "./chunk-IKQKBE2G.mjs";
|
|
5
|
+
import {
|
|
6
|
+
RuntimeCapabilityUnavailableError,
|
|
7
|
+
RuntimeDiagnosticError,
|
|
8
|
+
registerSearchFailure,
|
|
9
|
+
searchFailurePresentations
|
|
10
|
+
} from "./chunk-AEBW7XZJ.mjs";
|
|
11
|
+
|
|
12
|
+
// ../runtime/dist/search/errors.js
|
|
13
|
+
var inspect = "Inspect the declared application schema and current target with `pnpm gencow db:check`. Review a new forward migration with `pnpm gencow db:generate` and apply it using the existing target-appropriate app-local CLI flow; never edit applied migrations. Stop a local PGlite owner before manual schema writes. Retry this read only after actual readiness is verified.";
|
|
14
|
+
var RuntimeSearchError = class extends RuntimeDiagnosticError {
|
|
15
|
+
status;
|
|
16
|
+
code;
|
|
17
|
+
constructor(code, correlationId, stage = "request", context = "database") {
|
|
18
|
+
const readiness = [
|
|
19
|
+
"SEARCH_INDEX_NOT_READY",
|
|
20
|
+
"SEARCH_TABLE_UNAVAILABLE",
|
|
21
|
+
"SEARCH_COLUMN_UNAVAILABLE",
|
|
22
|
+
"SEARCH_EXTENSION_NOT_READY",
|
|
23
|
+
"SEARCH_CAPABILITY_DEGRADED"
|
|
24
|
+
].includes(code);
|
|
25
|
+
super({
|
|
26
|
+
code,
|
|
27
|
+
stage,
|
|
28
|
+
capability: code === "RUNTIME_AUTHENTICATION_REQUIRED" ? "auth" : "application",
|
|
29
|
+
servingStarted: "unchanged",
|
|
30
|
+
dataImpact: "none",
|
|
31
|
+
retryable: false,
|
|
32
|
+
retryPrecondition: code === "SEARCH_DATABASE_ACCESS_DENIED" ? "Restore the intended application's read grants and policies before retrying this read." : code === "SEARCH_DATABASE_UNAVAILABLE" || code === "SEARCH_DATABASE_TIMEOUT" ? "Restore the same selected connection and an active read deadline before retrying; inspect enclosing effects separately." : context === "binding" ? "Restore an explicitly admitted implementation for the selected Search mode before retrying." : readiness ? "Verify the selected database, capability and declared schema before repeating this read." : code === "SEARCH_SCOPE_ENDED" ? "Use a fresh active request or inspect the same Workflow; do not replay enclosing writes." : "Correct the documented Search input or authenticate as the intended private owner before repeating this read.",
|
|
33
|
+
nextAction: context === "binding" ? "Restore the trusted Search mode binding and restart the intended app generation. A missing mode cannot borrow another backend or implicitly compose hybrid from lexical/vector; no database write or fallback was admitted." : readiness ? inspect : code === "SEARCH_SCOPE_ENDED" ? "Use a fresh active request. For a Workflow inspect the same run with `workflows.get` through its existing public API; preserve earlier effects and do not blindly restart the mutation or job." : code === "SEARCH_DATABASE_ACCESS_DENIED" ? "Verify the selected application's documented read grants and policies with its trusted database owner. Preserve existing data and do not broaden access or switch to maintenance SQL. Retry this read only after the intended permission is restored." : code === "SEARCH_DATABASE_UNAVAILABLE" || code === "SEARCH_DATABASE_TIMEOUT" ? "Inspect the selected database connection and active request deadline. Restore the same connection or use a fresh active read scope; inspect earlier mutation or Workflow effects before retrying enclosing work. No fallback database was selected." : "Correct the procedure's Search input using the documented fields, scope, filters, paging and tuning. Private ownerUserId must match the signed-in user. No automatic retry is safe before correction.",
|
|
34
|
+
correlationId
|
|
35
|
+
});
|
|
36
|
+
this.name = "RuntimeSearchError";
|
|
37
|
+
this.status = searchFailurePresentations[code][0];
|
|
38
|
+
this.code = code;
|
|
39
|
+
registerSearchFailure(this, code, this.diagnostic);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var RuntimeSearchUnavailableError = class extends RuntimeCapabilityUnavailableError {
|
|
43
|
+
constructor(correlationId, mode = "lexical") {
|
|
44
|
+
super(mode === "vector" ? "vector search" : mode === "hybrid" ? "hybrid search" : "search", {
|
|
45
|
+
correlationId,
|
|
46
|
+
dataImpact: "none",
|
|
47
|
+
retryPrecondition: "Select and explicitly admit Search with its database dependency before restarting.",
|
|
48
|
+
nextAction: "In a CLI project, select localFeatures.search and localFeatures.database, run `pnpm gencow codegen`, and restart with `pnpm gencow dev --local`. Direct Runtime hosts must admit Search and its database in their provider selection and follow their own deployment flow. Verify earlier enclosing effects before retrying work."
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// ../runtime/dist/search/rls-session.js
|
|
54
|
+
var RuntimeSearchRlsContextError = class extends RuntimeDiagnosticError {
|
|
55
|
+
constructor(scope) {
|
|
56
|
+
super({
|
|
57
|
+
...requestContextInputError().diagnostic,
|
|
58
|
+
stage: scope.stage ?? "request",
|
|
59
|
+
correlationId: scope.correlationId
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function snapshotSearchRls(scope) {
|
|
64
|
+
try {
|
|
65
|
+
return snapshotRuntimeRls(scope.rls);
|
|
66
|
+
} catch {
|
|
67
|
+
throw new RuntimeSearchRlsContextError(scope);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
RuntimeSearchRlsContextError,
|
|
73
|
+
snapshotSearchRls,
|
|
74
|
+
RuntimeSearchError,
|
|
75
|
+
RuntimeSearchUnavailableError
|
|
76
|
+
};
|