@percher/core 1.6.0 → 2.0.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/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +3 -0
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +3 -0
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/claim.d.ts.map +1 -1
- package/dist/commands/claim.js +5 -8
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/deploy-repo.d.ts.map +1 -1
- package/dist/commands/deploy-repo.js +10 -12
- package/dist/commands/deploy-repo.js.map +1 -1
- package/dist/commands/diagnose.d.ts +7 -6
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +5 -4
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/doctor-access.d.ts +4 -0
- package/dist/commands/doctor-access.d.ts.map +1 -0
- package/dist/commands/doctor-access.js +32 -0
- package/dist/commands/doctor-access.js.map +1 -0
- package/dist/commands/doctor-auth.d.ts +19 -0
- package/dist/commands/doctor-auth.d.ts.map +1 -0
- package/dist/commands/doctor-auth.js +116 -0
- package/dist/commands/doctor-auth.js.map +1 -0
- package/dist/commands/doctor-build.d.ts +60 -0
- package/dist/commands/doctor-build.d.ts.map +1 -0
- package/dist/commands/doctor-build.js +470 -0
- package/dist/commands/doctor-build.js.map +1 -0
- package/dist/commands/doctor-evidence.d.ts +67 -0
- package/dist/commands/doctor-evidence.d.ts.map +1 -0
- package/dist/commands/doctor-evidence.js +102 -0
- package/dist/commands/doctor-evidence.js.map +1 -0
- package/dist/commands/doctor-observations.d.ts +19 -0
- package/dist/commands/doctor-observations.d.ts.map +1 -0
- package/dist/commands/doctor-observations.js +166 -0
- package/dist/commands/doctor-observations.js.map +1 -0
- package/dist/commands/doctor-route.d.ts +10 -0
- package/dist/commands/doctor-route.d.ts.map +1 -0
- package/dist/commands/doctor-route.js +104 -0
- package/dist/commands/doctor-route.js.map +1 -0
- package/dist/commands/doctor-runtime.d.ts +41 -0
- package/dist/commands/doctor-runtime.d.ts.map +1 -0
- package/dist/commands/doctor-runtime.js +276 -0
- package/dist/commands/doctor-runtime.js.map +1 -0
- package/dist/commands/doctor-state.d.ts +36 -0
- package/dist/commands/doctor-state.d.ts.map +1 -0
- package/dist/commands/doctor-state.js +671 -0
- package/dist/commands/doctor-state.js.map +1 -0
- package/dist/commands/doctor.d.ts +102 -13
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +238 -419
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env-scan.d.ts +1 -1
- package/dist/commands/env-scan.js +2 -2
- package/dist/commands/env-scan.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +17 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/preview-branch.d.ts +2 -0
- package/dist/commands/preview-branch.d.ts.map +1 -1
- package/dist/commands/preview-branch.js +1 -0
- package/dist/commands/preview-branch.js.map +1 -1
- package/dist/commands/publish-anonymous.d.ts +3 -0
- package/dist/commands/publish-anonymous.d.ts.map +1 -1
- package/dist/commands/publish-anonymous.js +6 -3
- package/dist/commands/publish-anonymous.js.map +1 -1
- package/dist/commands/publish-api-error.d.ts.map +1 -1
- package/dist/commands/publish-api-error.js +10 -3
- package/dist/commands/publish-api-error.js.map +1 -1
- package/dist/commands/publish-failure.d.ts +17 -0
- package/dist/commands/publish-failure.d.ts.map +1 -1
- package/dist/commands/publish-failure.js +33 -9
- package/dist/commands/publish-failure.js.map +1 -1
- package/dist/commands/publish-from-repo.d.ts.map +1 -1
- package/dist/commands/publish-from-repo.js +12 -13
- package/dist/commands/publish-from-repo.js.map +1 -1
- package/dist/commands/publish-needs-login.d.ts +13 -0
- package/dist/commands/publish-needs-login.d.ts.map +1 -0
- package/dist/commands/publish-needs-login.js +53 -0
- package/dist/commands/publish-needs-login.js.map +1 -0
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +38 -70
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +20 -3
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/redeploy.d.ts.map +1 -1
- package/dist/commands/redeploy.js +12 -14
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/reproduce.d.ts +3 -0
- package/dist/commands/reproduce.d.ts.map +1 -1
- package/dist/commands/reproduce.js +12 -0
- package/dist/commands/reproduce.js.map +1 -1
- package/dist/commands/restore.d.ts.map +1 -1
- package/dist/commands/restore.js +29 -2
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +2 -0
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/wait-deploy.d.ts +1 -1
- package/dist/commands/wait-deploy.d.ts.map +1 -1
- package/dist/commands/wait-deploy.js +3 -1
- package/dist/commands/wait-deploy.js.map +1 -1
- package/dist/credential-reset.d.ts +38 -0
- package/dist/credential-reset.d.ts.map +1 -0
- package/dist/credential-reset.js +77 -0
- package/dist/credential-reset.js.map +1 -0
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +2 -0
- package/dist/doctor.js.map +1 -0
- package/dist/error-classifier.d.ts +1 -1
- package/dist/error-classifier.d.ts.map +1 -1
- package/dist/error-classifier.js +42 -21
- package/dist/error-classifier.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -6
- package/dist/index.js.map +1 -1
- package/dist/log-excerpt.d.ts +12 -0
- package/dist/log-excerpt.d.ts.map +1 -0
- package/dist/log-excerpt.js +88 -0
- package/dist/log-excerpt.js.map +1 -0
- package/dist/network-budget-recovery.d.ts +16 -0
- package/dist/network-budget-recovery.d.ts.map +1 -0
- package/dist/network-budget-recovery.js +32 -0
- package/dist/network-budget-recovery.js.map +1 -0
- package/dist/plans.d.ts +35 -0
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +20 -0
- package/dist/plans.js.map +1 -1
- package/dist/recovery.d.ts +12 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +42 -16
- package/dist/recovery.js.map +1 -1
- package/dist/security-deployment-failure.d.ts.map +1 -1
- package/dist/security-deployment-failure.js +2 -1
- package/dist/security-deployment-failure.js.map +1 -1
- package/dist/static-docker.d.ts +1 -1
- package/dist/static-docker.js +13 -13
- package/dist/structured-error-codes.d.ts +6 -1
- package/dist/structured-error-codes.d.ts.map +1 -1
- package/dist/structured-error-codes.js +51 -0
- package/dist/structured-error-codes.js.map +1 -1
- package/dist/templates/ai-files/claude-md.d.ts.map +1 -1
- package/dist/templates/ai-files/claude-md.js +8 -1
- package/dist/templates/ai-files/claude-md.js.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.d.ts.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.js +5 -1
- package/dist/templates/ai-files/cursor-percher-mdc.js.map +1 -1
- package/dist/untrusted.d.ts +10 -0
- package/dist/untrusted.d.ts.map +1 -1
- package/dist/untrusted.js +23 -0
- package/dist/untrusted.js.map +1 -1
- package/dist/validation/blocked-names.d.ts +2 -0
- package/dist/validation/blocked-names.d.ts.map +1 -1
- package/dist/validation/blocked-names.js +30 -1
- package/dist/validation/blocked-names.js.map +1 -1
- package/package.json +10 -5
- package/templates/astro/Dockerfile +12 -12
- package/templates/capsule/Dockerfile +12 -15
- package/templates/eleventy/Dockerfile +12 -12
- package/templates/hugo/Dockerfile +12 -12
- package/templates/preact/Dockerfile +12 -12
- package/templates/solid/Dockerfile +12 -12
- package/templates/vite-react/Dockerfile +12 -12
- package/templates/vite-vue/Dockerfile +12 -12
- package/dist/commands/admin-legacy-audit.d.ts +0 -40
- package/dist/commands/admin-legacy-audit.d.ts.map +0 -1
- package/dist/commands/admin-legacy-audit.js +0 -57
- package/dist/commands/admin-legacy-audit.js.map +0 -1
- package/dist/commands/admin-legacy-inventory.d.ts +0 -27
- package/dist/commands/admin-legacy-inventory.d.ts.map +0 -1
- package/dist/commands/admin-legacy-inventory.js +0 -37
- package/dist/commands/admin-legacy-inventory.js.map +0 -1
- package/dist/commands/admin-migrate-networks.d.ts +0 -15
- package/dist/commands/admin-migrate-networks.d.ts.map +0 -1
- package/dist/commands/admin-migrate-networks.js +0 -15
- package/dist/commands/admin-migrate-networks.js.map +0 -1
- package/dist/commands/admin-reconcile-routes.d.ts +0 -18
- package/dist/commands/admin-reconcile-routes.d.ts.map +0 -1
- package/dist/commands/admin-reconcile-routes.js +0 -22
- package/dist/commands/admin-reconcile-routes.js.map +0 -1
- package/templates/capsule/src/lib/ai-client.ts +0 -193
- package/templates/capsule/src/lib/ai.ts +0 -15
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import { recoveryAsk, recoveryDoctor, recoveryNone } from "../recovery.js";
|
|
2
|
+
import { classifyByErrorCode } from "../structured-error-codes.js";
|
|
3
|
+
import { appRef, boundedCount, errorCode, idToken, isoInstant } from "../untrusted.js";
|
|
4
|
+
import { deployEvidence } from "./doctor-build.js";
|
|
5
|
+
import { hasStepCode, responseArrived, routeObservation, routeSentence, stagePhase, stageSentence, } from "./doctor-evidence.js";
|
|
6
|
+
import { runtimeCrashVerdict } from "./doctor-runtime.js";
|
|
7
|
+
import { deploymentFailureRecovery } from "./publish-failure.js";
|
|
8
|
+
/**
|
|
9
|
+
* Suspension kinds `/diagnostics` computes server-side from the moderation
|
|
10
|
+
* columns (`api/src/diagnostics/app-state.ts`). The value arrives in a JSON
|
|
11
|
+
* response, so it is matched against this list before it picks a verdict.
|
|
12
|
+
*/
|
|
13
|
+
const SUSPENSION_KINDS = [
|
|
14
|
+
"security_hold",
|
|
15
|
+
"admin_hold",
|
|
16
|
+
"memory_pressure",
|
|
17
|
+
"disk_pressure",
|
|
18
|
+
"data_cap",
|
|
19
|
+
"failure_loop",
|
|
20
|
+
"inactivity",
|
|
21
|
+
"other",
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* What the API said about holds. `none` only for an explicit null: an API
|
|
25
|
+
* that predates the field omits it, and a value outside the list proves
|
|
26
|
+
* nothing, so both are `unknown`, never "no hold". A legacy
|
|
27
|
+
* `status: "suspended"` is a suspension of kind `other` either way.
|
|
28
|
+
*/
|
|
29
|
+
function holdStatus(vctx) {
|
|
30
|
+
const raw = vctx.suspensionKind;
|
|
31
|
+
if (typeof raw === "string" && SUSPENSION_KINDS.includes(raw)) {
|
|
32
|
+
return raw;
|
|
33
|
+
}
|
|
34
|
+
if (vctx.appStatus === "suspended")
|
|
35
|
+
return "other";
|
|
36
|
+
return raw === null ? "none" : "unknown";
|
|
37
|
+
}
|
|
38
|
+
function suspensionKind(vctx) {
|
|
39
|
+
const hold = holdStatus(vctx);
|
|
40
|
+
return hold === "none" || hold === "unknown" ? null : hold;
|
|
41
|
+
}
|
|
42
|
+
/** Docker's stopped states; "unknown" covers paused, created and failed inspects. */
|
|
43
|
+
const STOPPED_STATES = ["exited", "stopped"];
|
|
44
|
+
/** Wake blockers `/diagnostics` computes with the wake path's own predicates. */
|
|
45
|
+
const WAKE_BLOCKERS = [
|
|
46
|
+
"egress_block",
|
|
47
|
+
"network_pause",
|
|
48
|
+
"redeploy_required",
|
|
49
|
+
"no_live_container",
|
|
50
|
+
];
|
|
51
|
+
/** `none` only for an explicit null; absent (older API) or invalid is `unknown`. */
|
|
52
|
+
function wakeBlocker(vctx) {
|
|
53
|
+
const raw = vctx.wakeBlocker;
|
|
54
|
+
if (typeof raw === "string" && WAKE_BLOCKERS.includes(raw)) {
|
|
55
|
+
return raw;
|
|
56
|
+
}
|
|
57
|
+
return raw === null ? "none" : "unknown";
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Held by an enforced daily network budget pause (app or account): every
|
|
61
|
+
* start, publish, resume and wake is refused until it ends. A security or
|
|
62
|
+
* moderation hold still leads; every other suspension's remedy is refused.
|
|
63
|
+
*/
|
|
64
|
+
export function isNetworkPaused(vctx) {
|
|
65
|
+
const hold = holdStatus(vctx);
|
|
66
|
+
return wakeBlocker(vctx) === "network_pause" && hold !== "security_hold" && hold !== "admin_hold";
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Ordinary sleep, on positive evidence only: status sleeping, the API
|
|
70
|
+
* affirmatively reporting no hold and no wake blocker (so the stopped
|
|
71
|
+
* container is the live deployment's, the one a wake starts), that container
|
|
72
|
+
* present and stopped, and the app's route present in Caddy.
|
|
73
|
+
*/
|
|
74
|
+
export function isExpectedSleep(vctx) {
|
|
75
|
+
return (vctx.appStatus === "sleeping" &&
|
|
76
|
+
holdStatus(vctx) === "none" &&
|
|
77
|
+
wakeBlocker(vctx) === "none" &&
|
|
78
|
+
STOPPED_STATES.includes(vctx.containerState ?? "") &&
|
|
79
|
+
vctx.wakeRoute === "present");
|
|
80
|
+
}
|
|
81
|
+
/** A wake started and not committed: the sleep marker or status with a running container. */
|
|
82
|
+
function isWaking(vctx) {
|
|
83
|
+
return (vctx.containerRunning === true &&
|
|
84
|
+
(vctx.appStatus === "sleeping" ||
|
|
85
|
+
vctx.sleepMarker === "sleeping" ||
|
|
86
|
+
vctx.sleepMarker === "waking"));
|
|
87
|
+
}
|
|
88
|
+
/** The API's crash-loop evidence for the current live deployment. */
|
|
89
|
+
function crashLoopRepeated(vctx) {
|
|
90
|
+
return vctx.crashLoop?.state === "repeated";
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Deploy mode: the recovery a failed deployment's platform `errorCode`
|
|
94
|
+
* determines, through the helper publish/wait use, so both give the same
|
|
95
|
+
* answer for the same code. Null for a code this build does not know; the
|
|
96
|
+
* regex rules then run as before.
|
|
97
|
+
*/
|
|
98
|
+
export function codedDeployFailure(deployment, appName) {
|
|
99
|
+
const code = errorCode(deployment.errorCode);
|
|
100
|
+
// A failed build's message is the API's reading of the build's own output
|
|
101
|
+
// (build-stage.ts), so its words are no account of what happened: the
|
|
102
|
+
// code's fixed explanation stands alone, and the output is the excerpt.
|
|
103
|
+
const raw = code === "BUILD_FAILED" ? "" : (deployment.errorMessage ?? "");
|
|
104
|
+
const classified = code ? classifyByErrorCode(code, raw) : null;
|
|
105
|
+
if (!code || !classified)
|
|
106
|
+
return undefined;
|
|
107
|
+
return {
|
|
108
|
+
errorCode: code,
|
|
109
|
+
title: classified.title,
|
|
110
|
+
explanation: classified.explanation,
|
|
111
|
+
phase: classified.phase,
|
|
112
|
+
cause: classified.cause,
|
|
113
|
+
suggestion: classified.suggestion,
|
|
114
|
+
recovery: deploymentFailureRecovery({
|
|
115
|
+
deployment,
|
|
116
|
+
appName,
|
|
117
|
+
errorClass: classified.errorClass,
|
|
118
|
+
missingEnvVars: classified.missingEnvVars,
|
|
119
|
+
classSource: "code",
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Coded failure in deploy mode. Sits above the regex-driven deploy rules.
|
|
125
|
+
* When the shared mapping itself says "run doctor in deploy mode" (a generic
|
|
126
|
+
* build failure, or a platform class no code confirmed), this is that doctor
|
|
127
|
+
* call, so the rule steps aside and the build-log rules below answer: the
|
|
128
|
+
* same loop-break publish relies on.
|
|
129
|
+
*/
|
|
130
|
+
const DEPLOY_FAILED_CODED = {
|
|
131
|
+
id: "deploy-failed-coded",
|
|
132
|
+
when: ({ vctx }) => vctx.lastDeployStatus === "failed" &&
|
|
133
|
+
vctx.inputMode === "deploy" &&
|
|
134
|
+
!!vctx.codedDeployFailure &&
|
|
135
|
+
(!hasStepCode(vctx.codedDeployFailure.errorCode) || !!vctx.failedStage) &&
|
|
136
|
+
vctx.codedDeployFailure.recovery.nextAction !== "run_doctor",
|
|
137
|
+
verdict: ({ vctx }) => {
|
|
138
|
+
const coded = vctx.codedDeployFailure;
|
|
139
|
+
const deployId = idToken(vctx.lastDeployId);
|
|
140
|
+
const paired = !!vctx.failedStage;
|
|
141
|
+
return {
|
|
142
|
+
status: "needs_action",
|
|
143
|
+
diagnosis: {
|
|
144
|
+
...deployEvidence(vctx, paired ? { ...coded, relevantFiles: [] } : undefined),
|
|
145
|
+
title: paired ? coded.title : "Last deploy failed",
|
|
146
|
+
explanation: paired ? coded.explanation : stageSentence(null),
|
|
147
|
+
reasonCode: coded.recovery.reasonCode,
|
|
148
|
+
phase: stagePhase(vctx.failedStage),
|
|
149
|
+
errorCode: coded.errorCode,
|
|
150
|
+
},
|
|
151
|
+
recovery: coded.errorCode === "PB_PROVISION_FAILED"
|
|
152
|
+
? recoveryAsk({
|
|
153
|
+
prompt: "Percher reported a database provisioning error. Should I check platform status and the diagnostic evidence before trying to publish again?",
|
|
154
|
+
reasonCode: "pb_provision_failed",
|
|
155
|
+
retryable: true,
|
|
156
|
+
})
|
|
157
|
+
: coded.recovery,
|
|
158
|
+
summary: `${deployId ? `Deploy ${deployId}` : "The last deploy"} failed with platform code ${coded.errorCode}. Follow this result's recovery.`,
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
const resumeCommand = (app) => `\`bunx percher resume${app === null ? "" : ` ${app}`}\``;
|
|
163
|
+
/**
|
|
164
|
+
* One fixed verdict per kind. The reason text an operator typed never
|
|
165
|
+
* appears; only the closed kind chooses what is said.
|
|
166
|
+
*/
|
|
167
|
+
const SUSPENSION_VERDICTS = {
|
|
168
|
+
security_hold: {
|
|
169
|
+
title: "App is on a security hold",
|
|
170
|
+
explanation: "Percher stopped this app because its running image has a critical, exploitable vulnerability with an available fix. Resuming cannot lift a security hold; a redeploy whose image scans clean lifts it automatically.",
|
|
171
|
+
reasonCode: "security_blocked",
|
|
172
|
+
prompt: () => "Percher put this app on a security hold: its running image has a critical, exploitable vulnerability with an available fix. Resuming cannot lift the hold; a publish whose image scans clean lifts it automatically. Should I update the vulnerable dependency or base image and publish again?",
|
|
173
|
+
options: ["update the dependency and publish again", "cancel"],
|
|
174
|
+
},
|
|
175
|
+
admin_hold: {
|
|
176
|
+
title: "App is under a moderation hold",
|
|
177
|
+
explanation: "Percher's operators suspended this app. The owner cannot resume it; the notice sent to the account owner explains the reason and whether a fixed publish can lift it.",
|
|
178
|
+
reasonCode: "app_suspended",
|
|
179
|
+
prompt: () => "Percher's operators put this app under a moderation hold, so it cannot be resumed from here. The notice sent to the account owner and the dashboard explain the reason and whether a fixed publish can lift it. How would you like to proceed?",
|
|
180
|
+
},
|
|
181
|
+
memory_pressure: {
|
|
182
|
+
title: "App paused for memory pressure",
|
|
183
|
+
explanation: "Percher paused this app because of its memory use. Its container and data are kept; resuming starts it again.",
|
|
184
|
+
reasonCode: "app_suspended",
|
|
185
|
+
prompt: (app) => `Percher paused this app because of its memory use. Its container and data are kept. Should I resume it with ${resumeCommand(app)}, or first raise [resources].memory in percher.toml and publish again?`,
|
|
186
|
+
options: ["resume", "raise [resources].memory and publish again", "cancel"],
|
|
187
|
+
},
|
|
188
|
+
disk_pressure: {
|
|
189
|
+
title: "App paused: account storage over the plan",
|
|
190
|
+
explanation: "Percher paused the account's apps because their data is above the plan's storage allowance. Data is kept.",
|
|
191
|
+
reasonCode: "quota_exceeded",
|
|
192
|
+
prompt: (app) => `Percher paused this app because the account's data is above the plan's storage allowance. Data is kept. Do you want to free up data or upgrade the plan at https://percher.app/account/billing, then resume with ${resumeCommand(app)}?`,
|
|
193
|
+
options: ["free up data, then resume", "upgrade the plan", "cancel"],
|
|
194
|
+
},
|
|
195
|
+
data_cap: {
|
|
196
|
+
title: "App paused: data over the per-app cap",
|
|
197
|
+
explanation: "Percher paused this app because its data volume exceeded the per-app cap. Data is kept; after resuming, reduce the data so it stays under the cap.",
|
|
198
|
+
reasonCode: "quota_exceeded",
|
|
199
|
+
prompt: (app) => `Percher paused this app because its data exceeded the per-app storage cap. Data is kept. Should I resume it with ${resumeCommand(app)} and then reduce the data it stores?`,
|
|
200
|
+
options: ["resume and reduce the data", "cancel"],
|
|
201
|
+
},
|
|
202
|
+
failure_loop: {
|
|
203
|
+
title: "Publishing suspended after repeated failed deploys",
|
|
204
|
+
explanation: "Percher suspended this app after several failed deploys in a row. A version that was already running keeps serving.",
|
|
205
|
+
reasonCode: "app_suspended",
|
|
206
|
+
prompt: (app) => `Percher suspended this app after several failed deploys in a row. A version that was already running keeps serving. Should I find the cause of the failures first, then clear the block with ${resumeCommand(app)} and publish again?`,
|
|
207
|
+
options: ["find the cause, then resume and publish", "cancel"],
|
|
208
|
+
},
|
|
209
|
+
inactivity: {
|
|
210
|
+
title: "App suspended for inactivity",
|
|
211
|
+
explanation: "Percher suspended this app after a long period without visits. Its data is kept; resuming starts it again.",
|
|
212
|
+
reasonCode: "app_suspended",
|
|
213
|
+
prompt: (app) => `Percher suspended this app after a long period without visits. Its data is kept. Should I resume it with ${resumeCommand(app)}?`,
|
|
214
|
+
options: ["resume", "cancel"],
|
|
215
|
+
},
|
|
216
|
+
other: {
|
|
217
|
+
title: "App is suspended",
|
|
218
|
+
explanation: "This app is suspended. The dashboard shows the reason.",
|
|
219
|
+
reasonCode: "app_suspended",
|
|
220
|
+
prompt: () => "This app is suspended. The dashboard shows the reason and how it can be lifted. How would you like to proceed?",
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* A suspended or held app. Sits above every runtime and sleep rule: a hold
|
|
225
|
+
* also stops the container and sets `status: "sleeping"`
|
|
226
|
+
* (security-hold-service), so it must be named before ordinary sleep or a
|
|
227
|
+
* crash fix can be.
|
|
228
|
+
*/
|
|
229
|
+
const APP_SUSPENDED = {
|
|
230
|
+
id: "app-suspended",
|
|
231
|
+
when: ({ vctx }) => suspensionKind(vctx) !== null,
|
|
232
|
+
verdict: ({ vctx }) => {
|
|
233
|
+
const kind = suspensionKind(vctx) ?? "other";
|
|
234
|
+
const v = SUSPENSION_VERDICTS[kind];
|
|
235
|
+
const app = appRef(vctx.appName);
|
|
236
|
+
return {
|
|
237
|
+
status: "needs_action",
|
|
238
|
+
diagnosis: {
|
|
239
|
+
title: v.title,
|
|
240
|
+
explanation: v.explanation,
|
|
241
|
+
reasonCode: v.reasonCode,
|
|
242
|
+
phase: "infra",
|
|
243
|
+
},
|
|
244
|
+
recovery: recoveryAsk({
|
|
245
|
+
reasonCode: v.reasonCode,
|
|
246
|
+
prompt: v.prompt(app),
|
|
247
|
+
...(v.options ? { options: v.options } : {}),
|
|
248
|
+
}),
|
|
249
|
+
summary: `${vctx.appName ?? "The app"}: ${v.title.toLowerCase()} (${kind}).`,
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
/** The API's resume instant, strictly validated; null: say nothing about the time. */
|
|
254
|
+
function pauseEnd(raw) {
|
|
255
|
+
if (typeof raw !== "string" || raw.length > 40)
|
|
256
|
+
return null;
|
|
257
|
+
return isoInstant(raw, { maxPastMs: 5 * 60_000, maxFutureMs: 25 * 60 * 60_000 });
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The daily network budget pause. Its containment leaves the app asleep with
|
|
261
|
+
* its containers stopped and its route held, and any start is refused with
|
|
262
|
+
* 423, so it sits above the deploy, sleep and runtime rules: none of their
|
|
263
|
+
* remedies (publish, resume, wake, redeploy) can work until it ends. Nothing
|
|
264
|
+
* to do but wait; only a validated instant is interpolated.
|
|
265
|
+
*/
|
|
266
|
+
const APP_NETWORK_PAUSED = {
|
|
267
|
+
id: "app-network-paused",
|
|
268
|
+
when: ({ vctx }) => isNetworkPaused(vctx),
|
|
269
|
+
verdict: ({ vctx }) => {
|
|
270
|
+
const until = pauseEnd(vctx.networkPauseResumesAt);
|
|
271
|
+
return {
|
|
272
|
+
status: "blocked",
|
|
273
|
+
diagnosis: {
|
|
274
|
+
title: until ? `Paused until ${until}` : "Paused: daily network budget reached",
|
|
275
|
+
explanation: `${until ? `Paused until ${until}` : "Paused"}: this app (or its account) reached its daily network budget. It resumes automatically${until ? "" : " when the UTC day ends"}; nothing is deleted. Publishing, redeploying, resuming and waking it are refused until then.`,
|
|
276
|
+
reasonCode: "quota_exceeded",
|
|
277
|
+
phase: "infra",
|
|
278
|
+
},
|
|
279
|
+
recovery: recoveryNone({ reasonCode: "quota_exceeded" }),
|
|
280
|
+
summary: `${vctx.appName ?? "The app"} is paused${until ? ` until ${until}` : ""} by its daily network budget; it resumes automatically.`,
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Managed PocketBase expected but absent. The check fails only for a
|
|
286
|
+
* confirmed `not-provisioned` on a `pocketbase` app; a failed lookup is a
|
|
287
|
+
* warning (unknown), which proves nothing either way.
|
|
288
|
+
*/
|
|
289
|
+
const POCKETBASE_MISSING = {
|
|
290
|
+
id: "pocketbase-missing",
|
|
291
|
+
when: ({ findCheck }) => findCheck("PocketBase")?.status === "fail",
|
|
292
|
+
verdict: ({ vctx }) => ({
|
|
293
|
+
status: "needs_action",
|
|
294
|
+
diagnosis: {
|
|
295
|
+
title: "Managed database is missing",
|
|
296
|
+
explanation: "This app is configured for Percher's managed database (PocketBase), but the platform has no database provisioned for it.",
|
|
297
|
+
reasonCode: "pb_provision_failed",
|
|
298
|
+
phase: "infra",
|
|
299
|
+
},
|
|
300
|
+
recovery: recoveryAsk({
|
|
301
|
+
reasonCode: "pb_provision_failed",
|
|
302
|
+
prompt: "This app is configured for Percher's managed database (PocketBase), but no database is provisioned for it. A successful publish provisions it. Should I publish again, or check whether percher.toml should still use the managed database?",
|
|
303
|
+
options: ["publish again", "check percher.toml", "cancel"],
|
|
304
|
+
}),
|
|
305
|
+
summary: `${vctx.appName ?? "The app"} expects a managed PocketBase database, but none is provisioned.`,
|
|
306
|
+
}),
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* A live app with its own container running whose managed database is
|
|
310
|
+
* stopped. The check alone is a warning (a sleeping app's database is stopped
|
|
311
|
+
* on purpose), and warnings never block `all-healthy`, so this sits above it.
|
|
312
|
+
* With the app container down as well, the runtime rules lead instead.
|
|
313
|
+
*/
|
|
314
|
+
const POCKETBASE_STOPPED = {
|
|
315
|
+
id: "pocketbase-stopped",
|
|
316
|
+
when: ({ vctx }) => vctx.appStatus === "live" &&
|
|
317
|
+
vctx.containerRunning === true &&
|
|
318
|
+
vctx.pocketbaseStatus === "stopped",
|
|
319
|
+
verdict: ({ vctx }) => ({
|
|
320
|
+
status: "needs_action",
|
|
321
|
+
diagnosis: {
|
|
322
|
+
title: "Managed database is stopped",
|
|
323
|
+
explanation: "The app is live, but its managed database (PocketBase) is stopped, so requests that read or write data fail. A running data restore stops it for a while; otherwise a publish starts it again.",
|
|
324
|
+
reasonCode: "app_not_running",
|
|
325
|
+
phase: "runtime",
|
|
326
|
+
},
|
|
327
|
+
recovery: recoveryAsk({
|
|
328
|
+
reasonCode: "app_not_running",
|
|
329
|
+
prompt: "This app is live, but its managed database (PocketBase) is stopped, so requests that need data fail. A running data restore stops it for a while; otherwise publishing again starts it. Should I check whether a data restore is running, and publish again if none is?",
|
|
330
|
+
options: ["check for a running restore, then publish again", "cancel"],
|
|
331
|
+
}),
|
|
332
|
+
summary: `${vctx.appName ?? "The app"} is live, but its managed database is stopped.`,
|
|
333
|
+
}),
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* A live app whose managed database state Percher could not read. Unknown
|
|
337
|
+
* proves neither that it runs nor that it is down, so this is not health, and
|
|
338
|
+
* the agent is not sent to rebuild a database that may be fine.
|
|
339
|
+
*/
|
|
340
|
+
const POCKETBASE_UNKNOWN = {
|
|
341
|
+
id: "pocketbase-unknown",
|
|
342
|
+
when: ({ vctx }) => vctx.appStatus === "live" &&
|
|
343
|
+
vctx.containerRunning === true &&
|
|
344
|
+
vctx.pocketbaseStatus === "unknown",
|
|
345
|
+
verdict: ({ vctx }) => ({
|
|
346
|
+
status: "needs_action",
|
|
347
|
+
diagnosis: {
|
|
348
|
+
title: "Managed database state unknown",
|
|
349
|
+
explanation: "The app is live, but Percher could not read the state of its managed database (PocketBase), so it cannot confirm that requests needing data work. This does not show that the database is down.",
|
|
350
|
+
reasonCode: "unknown",
|
|
351
|
+
phase: "runtime",
|
|
352
|
+
},
|
|
353
|
+
recovery: recoveryAsk({
|
|
354
|
+
reasonCode: "unknown",
|
|
355
|
+
prompt: "Percher could not read the state of this app's managed database (PocketBase). This does not show that the database is down. Should I re-run diagnostics in a minute, and check a page of the app that reads data if it stays this way?",
|
|
356
|
+
options: ["re-run diagnostics in a minute", "cancel"],
|
|
357
|
+
}),
|
|
358
|
+
summary: `${vctx.appName ?? "The app"} is live, but its managed database state could not be read.`,
|
|
359
|
+
}),
|
|
360
|
+
};
|
|
361
|
+
/**
|
|
362
|
+
* A live app whose tracked container is gone (removed, or never recorded). A
|
|
363
|
+
* retry of the probe will not bring it back; without this, the public-route
|
|
364
|
+
* rule called it transient. The container and the public address are two
|
|
365
|
+
* observations, stated separately: neither proves that nothing serves the app.
|
|
366
|
+
*/
|
|
367
|
+
const LIVE_CONTAINER_MISSING = {
|
|
368
|
+
id: "live-container-missing",
|
|
369
|
+
when: ({ vctx }) => vctx.appStatus === "live" && vctx.containerState === "not-found",
|
|
370
|
+
verdict: ({ vctx }) => {
|
|
371
|
+
const observed = routeObservation(vctx);
|
|
372
|
+
const answered = responseArrived(observed);
|
|
373
|
+
return {
|
|
374
|
+
status: "needs_action",
|
|
375
|
+
diagnosis: {
|
|
376
|
+
title: "Tracked live container is missing",
|
|
377
|
+
explanation: `The app is marked live, but Percher could not find the tracked container.${routeSentence(observed)} Publishing again creates a new container.`,
|
|
378
|
+
reasonCode: "runtime_crashed",
|
|
379
|
+
phase: "runtime",
|
|
380
|
+
},
|
|
381
|
+
recovery: recoveryAsk({
|
|
382
|
+
reasonCode: "runtime_crashed",
|
|
383
|
+
prompt: answered
|
|
384
|
+
? "This app is marked live, but Percher could not find the tracked container, although the public-address check received a response. Publishing again creates a new container. Should I re-run diagnostics in a minute, and publish again if the container is still missing?"
|
|
385
|
+
: "This app is marked live, but Percher could not find the tracked container, and waiting will not recreate that container. Publishing again creates a new container. Should I publish again?",
|
|
386
|
+
options: answered
|
|
387
|
+
? ["re-run diagnostics in a minute", "publish again", "cancel"]
|
|
388
|
+
: ["publish again", "cancel"],
|
|
389
|
+
}),
|
|
390
|
+
summary: `${vctx.appName ?? "The app"} is marked live, but its tracked container is missing.`,
|
|
391
|
+
};
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* The monthly fair-use egress cap: wake.ts answers 509 before it wakes or
|
|
396
|
+
* proxies anything, so neither a sleeping nor a live app is reachable until
|
|
397
|
+
* the UTC month rolls over. Not transient, whatever the container shows.
|
|
398
|
+
*/
|
|
399
|
+
const APP_EGRESS_BLOCKED = {
|
|
400
|
+
id: "app-egress-blocked",
|
|
401
|
+
when: ({ vctx }) => suspensionKind(vctx) === null && wakeBlocker(vctx) === "egress_block",
|
|
402
|
+
verdict: ({ vctx }) => ({
|
|
403
|
+
status: "needs_action",
|
|
404
|
+
diagnosis: {
|
|
405
|
+
title: "Monthly bandwidth limit reached",
|
|
406
|
+
explanation: "The app used its monthly bandwidth (egress) allowance. Percher answers every request with 509 until the next UTC month starts.",
|
|
407
|
+
reasonCode: "quota_exceeded",
|
|
408
|
+
phase: "infra",
|
|
409
|
+
},
|
|
410
|
+
recovery: recoveryAsk({
|
|
411
|
+
reasonCode: "quota_exceeded",
|
|
412
|
+
prompt: "This app has used its monthly bandwidth allowance, so Percher refuses its traffic until the next UTC month starts; retrying or waking it will not help. Do you want to wait for the new month, or look at the plan's bandwidth allowance at https://percher.app/account/billing?",
|
|
413
|
+
options: ["wait for the new month", "check the plan", "cancel"],
|
|
414
|
+
}),
|
|
415
|
+
summary: `${vctx.appName ?? "The app"} reached its monthly bandwidth limit.`,
|
|
416
|
+
}),
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* A wake in progress, or one that failed after starting the container. A
|
|
420
|
+
* successful wake commits `status: "live"` and clears the sleep marker in one
|
|
421
|
+
* write (auto-sleep.ts), so a running container under a sleep status or
|
|
422
|
+
* marker is not a completed wake: it outranks every container and health
|
|
423
|
+
* check, and is never `ok`.
|
|
424
|
+
*/
|
|
425
|
+
const APP_WAKING = {
|
|
426
|
+
id: "app-waking",
|
|
427
|
+
when: ({ vctx }) => holdStatus(vctx) === "none" && isWaking(vctx),
|
|
428
|
+
verdict: ({ vctx }) => ({
|
|
429
|
+
status: "in_progress",
|
|
430
|
+
diagnosis: {
|
|
431
|
+
title: "App is waking (not confirmed)",
|
|
432
|
+
explanation: "The app's container is running but its wake has not completed: it is in progress, or it failed after the container started (for example, when its route could not be restored). Percher cannot confirm the app is reachable.",
|
|
433
|
+
reasonCode: "unknown",
|
|
434
|
+
phase: "runtime",
|
|
435
|
+
},
|
|
436
|
+
recovery: recoveryAsk({
|
|
437
|
+
reasonCode: "unknown",
|
|
438
|
+
prompt: "This app's container is running, but its wake has not completed: it is in progress, or it failed after the container started (for example, the route could not be restored). Percher cannot confirm the app is reachable. Should I re-run diagnostics in a minute, and publish again if it stays this way?",
|
|
439
|
+
options: ["re-run diagnostics in a minute", "publish again", "cancel"],
|
|
440
|
+
}),
|
|
441
|
+
summary: `${vctx.appName ?? "The app"} is waking; the wake is not confirmed.`,
|
|
442
|
+
}),
|
|
443
|
+
};
|
|
444
|
+
const WAKE_BLOCKER_VERDICTS = {
|
|
445
|
+
redeploy_required: {
|
|
446
|
+
title: "Sleeping app needs a redeploy to wake",
|
|
447
|
+
explanation: "The app changed owners and must be redeployed; until then Percher refuses to wake it.",
|
|
448
|
+
prompt: "This app changed owners and must be redeployed before it can wake, so a visit will not wake it. Should I publish it again?",
|
|
449
|
+
options: ["publish again", "cancel"],
|
|
450
|
+
},
|
|
451
|
+
no_live_container: {
|
|
452
|
+
title: "Sleeping app has no live deployment to wake",
|
|
453
|
+
explanation: "The app is marked asleep, but no live deployment's container is recorded, so a visit cannot wake it.",
|
|
454
|
+
prompt: "This app is marked asleep, but it has no live deployment whose container a visit could start, so a visit cannot wake it. Publishing again creates one. Should I publish again?",
|
|
455
|
+
options: ["publish again", "cancel"],
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* A sleeping app that is not confirmed to be ordinary sleep. Sits above the
|
|
460
|
+
* PocketBase rule: a hold the API could not report (an older API) may be what
|
|
461
|
+
* removed the database, so the fail-safe wording leads, then the wake
|
|
462
|
+
* blockers, a missing container or route, and finally "unknown".
|
|
463
|
+
*/
|
|
464
|
+
const APP_SLEEP_UNVERIFIED = {
|
|
465
|
+
id: "app-sleep-unverified",
|
|
466
|
+
when: ({ vctx }) => vctx.appStatus === "sleeping" && suspensionKind(vctx) === null && !isExpectedSleep(vctx),
|
|
467
|
+
verdict: ({ vctx }) => {
|
|
468
|
+
const blocker = wakeBlocker(vctx);
|
|
469
|
+
const v = holdStatus(vctx) === "unknown"
|
|
470
|
+
? {
|
|
471
|
+
title: "Sleeping app: hold status unknown",
|
|
472
|
+
explanation: "The app is marked asleep, but the API did not report whether a hold applies, so Percher cannot confirm it is only asleep.",
|
|
473
|
+
reasonCode: "unknown",
|
|
474
|
+
prompt: "This app is marked asleep, but the Percher API did not report whether a hold (security, moderation or resources) applies, so Percher cannot confirm it is only asleep. The dashboard shows whether a hold applies; if it is only asleep, the next visit should wake it. How would you like to proceed?",
|
|
475
|
+
}
|
|
476
|
+
: blocker === "redeploy_required" || blocker === "no_live_container"
|
|
477
|
+
? { ...WAKE_BLOCKER_VERDICTS[blocker], reasonCode: "runtime_crashed" }
|
|
478
|
+
: vctx.containerState === "not-found"
|
|
479
|
+
? {
|
|
480
|
+
title: "Sleeping app has no container",
|
|
481
|
+
explanation: "The app is marked asleep, but its container is missing, so a visit cannot wake it.",
|
|
482
|
+
reasonCode: "runtime_crashed",
|
|
483
|
+
prompt: "This app is marked asleep, but its container is missing, so a visit cannot wake it. Publishing again creates a new container. Should I publish again?",
|
|
484
|
+
options: ["publish again", "cancel"],
|
|
485
|
+
}
|
|
486
|
+
: vctx.wakeRoute === "missing"
|
|
487
|
+
? {
|
|
488
|
+
title: "Sleeping app has no route",
|
|
489
|
+
explanation: "The app is marked asleep, but its route is missing from Caddy, so a visit cannot reach the wake handler.",
|
|
490
|
+
reasonCode: "infra_unavailable",
|
|
491
|
+
prompt: "This app is marked asleep, but its route is missing from Percher's proxy, so a visit cannot reach it to wake it. Publishing again restores the route. Should I publish again?",
|
|
492
|
+
options: ["publish again", "cancel"],
|
|
493
|
+
}
|
|
494
|
+
: vctx.wakeRoute === "stale"
|
|
495
|
+
? {
|
|
496
|
+
title: "Sleeping app's route does not reach the wake handler",
|
|
497
|
+
explanation: "The app is marked asleep, but its route still points somewhere other than the wake handler (for example the stopped container, after a sleep whose route update failed), so a visit cannot wake it.",
|
|
498
|
+
reasonCode: "infra_unavailable",
|
|
499
|
+
prompt: "This app is marked asleep, but its route in Percher's proxy does not lead to the wake handler, so a visit cannot wake it. Publishing again restores the route. Should I publish again?",
|
|
500
|
+
options: ["publish again", "cancel"],
|
|
501
|
+
}
|
|
502
|
+
: {
|
|
503
|
+
title: "Sleep state could not be verified",
|
|
504
|
+
explanation: "The app is marked asleep, but Percher could not confirm its container is stopped and ready to wake, its route is in place, and nothing blocks the wake.",
|
|
505
|
+
reasonCode: "unknown",
|
|
506
|
+
prompt: "This app is marked asleep, but Percher could not confirm it can wake: the container's state, its route or the wake checks could not be read. Should I re-run diagnostics in a minute, and check the dashboard if it stays this way?",
|
|
507
|
+
};
|
|
508
|
+
return {
|
|
509
|
+
status: "needs_action",
|
|
510
|
+
diagnosis: {
|
|
511
|
+
title: v.title,
|
|
512
|
+
explanation: v.explanation,
|
|
513
|
+
reasonCode: v.reasonCode,
|
|
514
|
+
phase: "runtime",
|
|
515
|
+
},
|
|
516
|
+
recovery: recoveryAsk({
|
|
517
|
+
reasonCode: v.reasonCode,
|
|
518
|
+
prompt: v.prompt,
|
|
519
|
+
...("options" in v ? { options: v.options } : {}),
|
|
520
|
+
}),
|
|
521
|
+
summary: `${vctx.appName ?? "The app"}: ${v.title.toLowerCase()}.`,
|
|
522
|
+
};
|
|
523
|
+
},
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Ordinary sleep is the expected state of an idle app, not an outage. The
|
|
527
|
+
* stopped container is rendered as a skip and the public probe is not sent (it
|
|
528
|
+
* would wake the app), so this matches only when nothing else failed. Wake and
|
|
529
|
+
* the public route are untested, and the wording says so.
|
|
530
|
+
*/
|
|
531
|
+
const APP_SLEEPING = {
|
|
532
|
+
id: "app-sleeping",
|
|
533
|
+
when: ({ vctx, verdictChecks }) => isExpectedSleep(vctx) && !verdictChecks.some((c) => c.status === "fail"),
|
|
534
|
+
verdict: ({ vctx }) => ({
|
|
535
|
+
status: "ok",
|
|
536
|
+
diagnosis: {
|
|
537
|
+
title: "App is asleep",
|
|
538
|
+
explanation: "The app is asleep: its stopped container is the live deployment's, its route leads to the wake handler and there is no known blocker, so the next visit should wake it. Capacity and a running data restore are checked only when a visit arrives, and Percher did not send a request (it would wake the app), so the wake itself is untested.",
|
|
539
|
+
reasonCode: "none",
|
|
540
|
+
phase: "runtime",
|
|
541
|
+
},
|
|
542
|
+
recovery: recoveryNone({ reasonCode: "none" }),
|
|
543
|
+
summary: `${vctx.appName ?? "The app"} is asleep; the next visit should wake it (the wake itself is untested).`,
|
|
544
|
+
}),
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* A live app whose current deployment restarted at least the watchdog's
|
|
548
|
+
* restart limit within its window (restarts summed per report).
|
|
549
|
+
* Between restarts every probe can pass, so this sits above `all-healthy`.
|
|
550
|
+
* Auto mode routes to the runtime hop; runtime mode ends there, with the
|
|
551
|
+
* crash-code recovery.
|
|
552
|
+
*/
|
|
553
|
+
const RUNTIME_CRASH_LOOP = {
|
|
554
|
+
id: "runtime-crash-loop",
|
|
555
|
+
when: ({ vctx }) => crashLoopRepeated(vctx) && vctx.appStatus === "live",
|
|
556
|
+
verdict: (ctx) => {
|
|
557
|
+
const { vctx } = ctx;
|
|
558
|
+
const n = boundedCount(vctx.crashLoop?.recentCrashes);
|
|
559
|
+
const minutes = boundedCount(vctx.crashLoop?.windowMinutes);
|
|
560
|
+
const explanation = n !== null && minutes !== null
|
|
561
|
+
? `The current deployment crashed and was restarted ${n} times in the last ${minutes} minutes.`
|
|
562
|
+
: "The current deployment keeps crashing and being restarted.";
|
|
563
|
+
if (vctx.inputMode === "runtime")
|
|
564
|
+
return runtimeCrashVerdict(ctx, explanation, "Crash loop");
|
|
565
|
+
return {
|
|
566
|
+
status: "needs_action",
|
|
567
|
+
diagnosis: {
|
|
568
|
+
title: "Crash loop",
|
|
569
|
+
explanation,
|
|
570
|
+
reasonCode: "runtime_crashed",
|
|
571
|
+
phase: "runtime",
|
|
572
|
+
},
|
|
573
|
+
recovery: recoveryDoctor({
|
|
574
|
+
...(vctx.appName !== undefined ? { app: vctx.appName } : {}),
|
|
575
|
+
mode: "runtime",
|
|
576
|
+
reasonCode: "runtime_crashed",
|
|
577
|
+
}),
|
|
578
|
+
summary: `${vctx.appName ?? "The app"} keeps crashing — run doctor in runtime mode for the crash details.`,
|
|
579
|
+
};
|
|
580
|
+
},
|
|
581
|
+
};
|
|
582
|
+
/** A starting health status is not a failed check; a usable crash report takes precedence. */
|
|
583
|
+
const RUNTIME_STARTING = {
|
|
584
|
+
id: "runtime-starting",
|
|
585
|
+
when: ({ vctx }) => vctx.appStatus === "live" &&
|
|
586
|
+
vctx.containerRunning === true &&
|
|
587
|
+
vctx.containerHealthStatus === "starting" &&
|
|
588
|
+
(boundedCount(vctx.crashLoop?.recentCrashes) === 0 || vctx.inputMode === "runtime") &&
|
|
589
|
+
!vctx.crashReport,
|
|
590
|
+
verdict: ({ vctx }) => {
|
|
591
|
+
const crash = boundedCount(vctx.crashLoop?.recentCrashes);
|
|
592
|
+
const history = crash !== null && crash > 0 ? " Diagnostics recorded a recent crash." : "";
|
|
593
|
+
const report = vctx.inputMode === "runtime" ? " No current crash report is available in this result." : "";
|
|
594
|
+
return {
|
|
595
|
+
status: "in_progress",
|
|
596
|
+
diagnosis: {
|
|
597
|
+
title: "App is still starting",
|
|
598
|
+
explanation: `The container is running and its health status is starting; no health check has passed yet.${history}${report}`,
|
|
599
|
+
reasonCode: "unknown",
|
|
600
|
+
phase: "runtime",
|
|
601
|
+
},
|
|
602
|
+
recovery: recoveryAsk({
|
|
603
|
+
reasonCode: "unknown",
|
|
604
|
+
prompt: "The container's health status is starting; no health check has passed yet. This does not establish whether it restarted after a crash. Should I re-run diagnostics in a minute and check the crash report and app logs if it is still not healthy?",
|
|
605
|
+
options: ["re-run diagnostics in a minute", "cancel"],
|
|
606
|
+
}),
|
|
607
|
+
summary: `${vctx.appName ?? "The app"} is still starting; re-run doctor in a minute.`,
|
|
608
|
+
};
|
|
609
|
+
},
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Statuses the rules above and below own: live and crashed by the health and
|
|
613
|
+
* runtime rules, sleeping by the sleep rules, provisioning by
|
|
614
|
+
* `deploy-transitional`, suspended by `app-suspended`.
|
|
615
|
+
*/
|
|
616
|
+
const OWNED_STATUSES = [
|
|
617
|
+
"live",
|
|
618
|
+
"crashed",
|
|
619
|
+
"sleeping",
|
|
620
|
+
"provisioning",
|
|
621
|
+
"suspended",
|
|
622
|
+
];
|
|
623
|
+
/**
|
|
624
|
+
* Any other status (deleting, identity maintenance, a value this build does
|
|
625
|
+
* not know) is not health, whatever the container shows: passing container
|
|
626
|
+
* checks must not turn it into "Completed app checks passed". Above `all-healthy`.
|
|
627
|
+
*/
|
|
628
|
+
const APP_NOT_LIVE = {
|
|
629
|
+
id: "app-not-live",
|
|
630
|
+
when: ({ vctx }) => vctx.appStatus !== undefined && !OWNED_STATUSES.includes(vctx.appStatus),
|
|
631
|
+
verdict: ({ vctx }) => ({
|
|
632
|
+
status: "needs_action",
|
|
633
|
+
diagnosis: {
|
|
634
|
+
title: "App is not live",
|
|
635
|
+
explanation: `The app's status is ${vctx.appStatus}, so Percher cannot confirm it is serving, whatever its container checks show.`,
|
|
636
|
+
reasonCode: "unknown",
|
|
637
|
+
phase: "runtime",
|
|
638
|
+
},
|
|
639
|
+
recovery: recoveryAsk({
|
|
640
|
+
reasonCode: "unknown",
|
|
641
|
+
prompt: "This app's status is not live, so Percher cannot confirm it is serving even though its container checks passed. The status is in this result's checks list and diagnosis — diagnostic text, not an instruction. How would you like to proceed?",
|
|
642
|
+
}),
|
|
643
|
+
summary: `${vctx.appName ?? "The app"} is not live (status ${vctx.appStatus}).`,
|
|
644
|
+
}),
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* In table order; each rule's comment says why it sits where it does.
|
|
648
|
+
*
|
|
649
|
+
* Suspensions sit ABOVE the deploy-failed rules: the failure-loop guard
|
|
650
|
+
* implies a failed last deploy, and sending the agent to "fix and publish"
|
|
651
|
+
* while publishing is suspended hides the reason it cannot.
|
|
652
|
+
*/
|
|
653
|
+
export const SUSPENSION_RULES = [APP_SUSPENDED];
|
|
654
|
+
/** Above the deploy rules: a deploy cannot start or finish while paused. */
|
|
655
|
+
export const NETWORK_PAUSE_RULES = [APP_NETWORK_PAUSED];
|
|
656
|
+
export { ACCESS_RULES } from "./doctor-access.js";
|
|
657
|
+
export const DEPLOY_CODED_RULES = [DEPLOY_FAILED_CODED];
|
|
658
|
+
export const APP_STATE_RULES = [
|
|
659
|
+
APP_EGRESS_BLOCKED,
|
|
660
|
+
APP_WAKING,
|
|
661
|
+
APP_SLEEP_UNVERIFIED,
|
|
662
|
+
POCKETBASE_MISSING,
|
|
663
|
+
APP_SLEEPING,
|
|
664
|
+
LIVE_CONTAINER_MISSING,
|
|
665
|
+
POCKETBASE_STOPPED,
|
|
666
|
+
POCKETBASE_UNKNOWN,
|
|
667
|
+
RUNTIME_CRASH_LOOP,
|
|
668
|
+
RUNTIME_STARTING,
|
|
669
|
+
APP_NOT_LIVE,
|
|
670
|
+
];
|
|
671
|
+
//# sourceMappingURL=doctor-state.js.map
|