gencow 0.1.269 → 0.1.270
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/lib/cli-command-runner.mjs +15 -2
- package/lib/cloud-target-environment.mjs +124 -0
- package/lib/cloud-targets.mjs +4 -0
- package/lib/db-command.mjs +15 -11
- package/lib/db-migration-command-steps.mjs +5 -2
- package/lib/db-push-command.mjs +14 -1
- package/lib/deploy-app-target.mjs +2 -0
- package/lib/deploy-command.mjs +11 -3
- package/lib/deploy-prod-target.mjs +1 -1
- package/lib/drizzle-generate.mjs +19 -0
- package/lib/env-command.mjs +9 -4
- package/lib/migration-advisory.mjs +2 -0
- package/lib/migration-diagnostic.mjs +33 -6
- package/lib/migration-rollback-cause.mjs +75 -0
- package/lib/migration-schema-load-failure.mjs +31 -0
- package/lib/prod-create-failure.mjs +9 -1
- package/lib/prod-create-region-diagnostic.mjs +86 -0
- package/lib/static-command.mjs +1 -1
- package/package.json +5 -5
- package/runtime/server.mjs +57 -57
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders the public REGION_UNAVAILABLE diagnostic from a create-prod 503.
|
|
3
|
+
* Every field is allow-listed: unknown, oversized or malformed values are
|
|
4
|
+
* dropped rather than echoed, and nothing is inferred when the server omits it.
|
|
5
|
+
* Older servers that send only the code keep the legacy rendering (null here).
|
|
6
|
+
*/
|
|
7
|
+
const STAGES = new Set(["prod_app_create_node_selection", "prod_app_create_node_proxy"]);
|
|
8
|
+
const REASON_TEXT = new Map([
|
|
9
|
+
["capacity_exhausted", "all nodes in this region are at app capacity"],
|
|
10
|
+
["no_active_node", "no active node serves this environment and region"],
|
|
11
|
+
["node_unavailable", "the matching node is not reporting healthy right now"],
|
|
12
|
+
["gateway_unavailable", "the target node's gateway is not ready"],
|
|
13
|
+
["node_config_invalid", "the target node has an invalid internal configuration (Platform-owned)"],
|
|
14
|
+
]);
|
|
15
|
+
const RETRY_CLASSES = new Set(["operator-action", "platform-action", "retryable-infra", "terminal-client"]);
|
|
16
|
+
const MAX_RETRY_AFTER_MS = 600_000;
|
|
17
|
+
// Same pattern the server uses for region slugs (apps-deploy-routes.ts create-prod validation).
|
|
18
|
+
const REGION_SLUG_PATTERN = /^[a-z0-9][a-z0-9-]{0,31}$/u;
|
|
19
|
+
// Same shape as the correlation-ID check in app-response-error.mjs.
|
|
20
|
+
const CORRELATION_ID_PATTERN = /^[A-Za-z0-9_-]{8,128}$/u;
|
|
21
|
+
const STATUS_COMMAND = "gencow deploy status --prod";
|
|
22
|
+
|
|
23
|
+
export function readRegionUnavailableDiagnostic(body, response) {
|
|
24
|
+
if (response?.status !== 503) return null;
|
|
25
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return null;
|
|
26
|
+
if (body.code !== "REGION_UNAVAILABLE") return null;
|
|
27
|
+
|
|
28
|
+
const diagnostic = {
|
|
29
|
+
stage: STAGES.has(body.stage) ? body.stage : null,
|
|
30
|
+
reason: REASON_TEXT.has(body.reason) ? body.reason : null,
|
|
31
|
+
stateUnchanged: body.stateChanged === false,
|
|
32
|
+
retryClass: RETRY_CLASSES.has(body.retryClass) ? body.retryClass : null,
|
|
33
|
+
retryAfterMs:
|
|
34
|
+
Number.isSafeInteger(body.retryAfterMs) && body.retryAfterMs >= 0 && body.retryAfterMs <= MAX_RETRY_AFTER_MS
|
|
35
|
+
? body.retryAfterMs
|
|
36
|
+
: null,
|
|
37
|
+
correlationId:
|
|
38
|
+
typeof body.correlationId === "string" && CORRELATION_ID_PATTERN.test(body.correlationId)
|
|
39
|
+
? body.correlationId
|
|
40
|
+
: null,
|
|
41
|
+
};
|
|
42
|
+
const hasAnyField = Object.entries(diagnostic).some(([key, value]) =>
|
|
43
|
+
key === "stateUnchanged" ? value : value !== null,
|
|
44
|
+
);
|
|
45
|
+
return hasAnyField ? diagnostic : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// The next step follows the server's retryClass; without one the CLI does not guess a retry.
|
|
49
|
+
// The region is echoed only when the user passed a valid --region; otherwise the region came
|
|
50
|
+
// from the dev app, so the user is pointed there.
|
|
51
|
+
function nextStepFor(retryClass, waitHint, requestedRegion) {
|
|
52
|
+
if (retryClass === "retryable-infra") {
|
|
53
|
+
const wait = waitHint ? ` after ${waitHint}` : "";
|
|
54
|
+
return `run \`${STATUS_COMMAND}\` to confirm no prod app was created, then run the same command again${wait}.`;
|
|
55
|
+
}
|
|
56
|
+
if (retryClass === "terminal-client") {
|
|
57
|
+
const regionStep =
|
|
58
|
+
requestedRegion && REGION_SLUG_PATTERN.test(requestedRegion)
|
|
59
|
+
? `check that \`--region ${requestedRegion}\` is available to this account, or pass a different --region`
|
|
60
|
+
: "check the region of your dev app, or pass `--region` with a region available to this account";
|
|
61
|
+
return `${regionStep}, then run the command again. Run \`${STATUS_COMMAND}\` first to see whether a prod app already exists.`;
|
|
62
|
+
}
|
|
63
|
+
if (retryClass === "platform-action") {
|
|
64
|
+
return `do not change your project. Run \`${STATUS_COMMAND}\` to check the current state; if it keeps failing after a few minutes, keep the Correlation ID for a Platform status check.`;
|
|
65
|
+
}
|
|
66
|
+
return `run \`${STATUS_COMMAND}\` to check whether a prod app was created.`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function formatWait(ms) {
|
|
70
|
+
return ms >= 1000 ? `${Math.round(ms / 1000)}s` : `${ms}ms`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function formatRegionUnavailableMessage(diagnostic, fallback, requestedRegion = null) {
|
|
74
|
+
const lines = [`Prod app creation failed: ${fallback}`, "Code: REGION_UNAVAILABLE"];
|
|
75
|
+
if (diagnostic.stage) lines.push(`Stage: ${diagnostic.stage}`);
|
|
76
|
+
if (diagnostic.reason) lines.push(`Reason: ${REASON_TEXT.get(diagnostic.reason)}`);
|
|
77
|
+
if (diagnostic.stateUnchanged) lines.push("Changed: nothing (no prod app was created)");
|
|
78
|
+
const retryable = diagnostic.retryClass === "retryable-infra";
|
|
79
|
+
if (diagnostic.retryClass) lines.push(`Retryable: ${retryable ? "yes" : "no"}`);
|
|
80
|
+
// A wait hint is only meaningful when the server marks the failure retryable.
|
|
81
|
+
const waitHint = retryable && diagnostic.retryAfterMs !== null ? formatWait(diagnostic.retryAfterMs) : null;
|
|
82
|
+
if (waitHint) lines.push(`Retry after: ${waitHint}`);
|
|
83
|
+
lines.push(`Next: ${nextStepFor(diagnostic.retryClass, waitHint, requestedRegion)}`);
|
|
84
|
+
if (diagnostic.correlationId) lines.push(`Correlation ID: ${diagnostic.correlationId}`);
|
|
85
|
+
return lines.join("\n");
|
|
86
|
+
}
|
package/lib/static-command.mjs
CHANGED
|
@@ -135,7 +135,7 @@ async function ensureStaticProductionTarget({
|
|
|
135
135
|
|
|
136
136
|
if (!createProdRes.ok) {
|
|
137
137
|
const errData = await readJsonObjectResponse(createProdRes);
|
|
138
|
-
errorImpl(prodCreateFailureMessage(errData, createProdRes));
|
|
138
|
+
errorImpl(prodCreateFailureMessage(errData, createProdRes, { requestedRegion: region }));
|
|
139
139
|
exitImpl(1);
|
|
140
140
|
return null;
|
|
141
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gencow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.270",
|
|
4
4
|
"description": "Gencow — AI Backend Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dashboard/"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@gencow/migration-contract": "0.1.
|
|
24
|
+
"@gencow/migration-contract": "0.1.22",
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
26
26
|
"drizzle-kit": "1.0.0-rc.4",
|
|
27
27
|
"drizzle-orm": "1.0.0-rc.4",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"better-auth": "1.7.11",
|
|
42
42
|
"postgres": "^3.4.9",
|
|
43
43
|
"@gencow/client": "0.2.8",
|
|
44
|
-
"@gencow/
|
|
44
|
+
"@gencow/server": "0.1.3",
|
|
45
45
|
"@gencow/core": "0.1.47",
|
|
46
|
-
"@gencow/
|
|
47
|
-
"@gencow/
|
|
46
|
+
"@gencow/react": "0.2.8",
|
|
47
|
+
"@gencow/shared": "0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "node scripts/bundle-core.mjs && node scripts/bundle-shared.mjs && node scripts/bundle-server.mjs",
|