cursedops 0.9.1 → 0.9.2
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/package.json +1 -1
- package/src/workerDeploy.ts +55 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedops",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "The build-and-ops answers this generation's apps wrote independently and identically: finding a generation's roots — and printing a command that runs when pasted — without knowing a path, the generation's whole-tree laws run over one repo from a checkout or a worktree, macOS launchd agent install/replace/remove and the live port a job serves, the scaffolding and verdicts of a deployed smoke (origin probe, the smoke's own environment, a network that lies about DNS, a settled version), the static-serving helpers eight apps copied — the path-traversal guard among them — the API floor that keeps an unmatched /api/... from ever being answered with the app shell, the commit and dirty flag a checkout-served process reports, the Cloudflare Worker deploy toolkit four apps copied (the deploy sequence, exact-set secrets over a pipe, origin-first rollback, the curl edge fetch, the row-for-row D1 import proof, the billed-CPU tail check around a deploy's walk and smoke, and each app's worker:secrets and worker:smoke main as one function of its data), the Worker import-graph and await-port checks every Worker app's suite runs over its own source, and the public-surface ratchet three published libraries each carried a forked copy of. Mechanism only — no app knows its name from here. Bun, zero runtime dependencies (typescript is an optional peer, for public-surface only), ships source.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
package/src/workerDeploy.ts
CHANGED
|
@@ -243,8 +243,11 @@ export interface DeployDeps {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
export interface DeployResult {
|
|
246
|
-
/**
|
|
247
|
-
|
|
246
|
+
/**
|
|
247
|
+
* 0 shipped and smoked; 1 refused or failed — the step says where; {@link TAIL_UNATTACHED_EXIT}
|
|
248
|
+
* shipped and smoked green with its Worker CPU UNMEASURED (step `cpu-unmeasured`).
|
|
249
|
+
*/
|
|
250
|
+
code: 0 | 1 | typeof TAIL_UNATTACHED_EXIT;
|
|
248
251
|
/** The step it stopped at, or `"done"`. */
|
|
249
252
|
step: string;
|
|
250
253
|
/** Why it stopped, or the success line. */
|
|
@@ -280,6 +283,8 @@ export function runWorkerDeploy(spec: WorkerDeploySpec, deps: DeployDeps): Deplo
|
|
|
280
283
|
return { code: 1, step, detail, commit, dirty };
|
|
281
284
|
};
|
|
282
285
|
const step = (message: string): void => log(`\n▸ ${message}`);
|
|
286
|
+
/** What passed under a CPU tail that never attached — decision 6 of the CPU check. */
|
|
287
|
+
const unmeasured: string[] = [];
|
|
283
288
|
|
|
284
289
|
if (!commit) return stop("head", "this checkout has no readable HEAD — there is no commit to stamp, so nothing could prove the deploy.");
|
|
285
290
|
if (spec.env === "production" && dirty) {
|
|
@@ -297,7 +302,9 @@ export function runWorkerDeploy(spec: WorkerDeploySpec, deps: DeployDeps): Deplo
|
|
|
297
302
|
for (const walk of spec.stageWalk ?? []) {
|
|
298
303
|
const command = spec.cpuTail ? underCpuTail(spec.cpuTail, "stage", walk) : [...walk];
|
|
299
304
|
step(`walk the stage signed in${spec.cpuTail ? ", under a CPU tail" : ""}: ${command.join(" ")}`);
|
|
300
|
-
|
|
305
|
+
const walked = deps.run(command, {});
|
|
306
|
+
if (spec.cpuTail && walked === TAIL_UNATTACHED_EXIT) unmeasured.push("the stage walk");
|
|
307
|
+
else if (walked !== 0) return stop("stage", `\`${command.join(" ")}\` failed — production was NOT touched.`);
|
|
301
308
|
}
|
|
302
309
|
}
|
|
303
310
|
if (spec.build) {
|
|
@@ -329,7 +336,9 @@ export function runWorkerDeploy(spec: WorkerDeploySpec, deps: DeployDeps): Deplo
|
|
|
329
336
|
if (spec.smoke) {
|
|
330
337
|
step(`smoke every address this deployment answers on${spec.cpuTail ? ", under a CPU tail" : ""}`);
|
|
331
338
|
const smoke = spec.cpuTail ? underCpuTail(spec.cpuTail, spec.env, spec.smoke) : spec.smoke;
|
|
332
|
-
|
|
339
|
+
const smoked = deps.run(smoke, {});
|
|
340
|
+
if (spec.cpuTail && smoked === TAIL_UNATTACHED_EXIT) unmeasured.push("the smoke");
|
|
341
|
+
else if (smoked !== 0) {
|
|
333
342
|
return stop(
|
|
334
343
|
"smoke",
|
|
335
344
|
"the Worker is deployed and its smoke FAILED. Nothing was rolled back: `bunx wrangler rollback` puts the previous version back in one command.",
|
|
@@ -337,6 +346,13 @@ export function runWorkerDeploy(spec: WorkerDeploySpec, deps: DeployDeps): Deplo
|
|
|
337
346
|
}
|
|
338
347
|
}
|
|
339
348
|
const detail = `${spec.workerName} deployed${spec.secrets ? ", attached" : ""}${spec.smoke ? " and smoked" : ""} @ ${commit.slice(0, 8)}.`;
|
|
349
|
+
if (unmeasured.length > 0) {
|
|
350
|
+
const why =
|
|
351
|
+
`${detail} Worker CPU UNMEASURED — the tail never attached around ${unmeasured.join(" and ")}, which PASSED. ` +
|
|
352
|
+
"Nothing is wrong with the deployment and nothing needs rolling back; rerun the smoke under the app's CPU wrapper to measure it.";
|
|
353
|
+
error(`\n🟡 ${tag} ${why}`);
|
|
354
|
+
return { code: TAIL_UNATTACHED_EXIT, step: "cpu-unmeasured", detail: why, commit, dirty };
|
|
355
|
+
}
|
|
340
356
|
log(`\n✅ ${detail}`);
|
|
341
357
|
return { code: 0, step: "done", detail, commit, dirty };
|
|
342
358
|
}
|
|
@@ -400,6 +416,12 @@ export function runWorkerDeploy(spec: WorkerDeploySpec, deps: DeployDeps): Deplo
|
|
|
400
416
|
* excused by production's traffic on a shared tail, or the reverse.
|
|
401
417
|
* 5. **A tail that never connects is a failure, never an empty pass**; neither is a runtime that
|
|
402
418
|
* stops reporting `cpuTime` (`recordTailTraces` skips it; the empty report is `no-samples`).
|
|
419
|
+
* 6. 🔴 **…but it is not the COMMAND failing (0.9.2, task 2157).** A tail that does not attach is
|
|
420
|
+
* restarted ONCE with a fresh marker; if the second never attaches either, the command still
|
|
421
|
+
* runs (unmeasured, so the deploy is still smoked) and the result is {@link TAIL_UNATTACHED_EXIT},
|
|
422
|
+
* which {@link runWorkerDeploy} reports as "CPU unmeasured", never "smoke FAILED". Measured
|
|
423
|
+
* 2026-09-24: collections' production tail never delivered its marker within 60 s, the deploy
|
|
424
|
+
* said the smoke failed, and the same smoke rerun two minutes later passed 30 checks.
|
|
403
425
|
*
|
|
404
426
|
* ## How it knows the tail is listening, and that it has heard everything
|
|
405
427
|
*
|
|
@@ -682,11 +704,21 @@ export interface WorkerCpuTailSpec extends Omit<JudgeOpts, "scriptName"> {
|
|
|
682
704
|
markerWaitMs?: number;
|
|
683
705
|
}
|
|
684
706
|
|
|
707
|
+
/**
|
|
708
|
+
* The exit code of a CPU tail that never attached, twice, around a command that PASSED (`EX_UNAVAILABLE`):
|
|
709
|
+
* nothing was measured, and nothing was wrong with the deployment. Distinct from the command's own
|
|
710
|
+
* codes so {@link runWorkerDeploy} can say which of the two happened — decision 6.
|
|
711
|
+
*/
|
|
712
|
+
export const TAIL_UNATTACHED_EXIT = 69;
|
|
713
|
+
|
|
685
714
|
export interface WorkerCpuTailResult {
|
|
686
|
-
/**
|
|
715
|
+
/**
|
|
716
|
+
* 0 green; the command's own code when it failed; {@link TAIL_UNATTACHED_EXIT} when the command
|
|
717
|
+
* passed and the tail never attached; 1 for any other CPU or tail failure.
|
|
718
|
+
*/
|
|
687
719
|
code: number;
|
|
688
|
-
/** Where it stopped: `
|
|
689
|
-
step: "
|
|
720
|
+
/** Where it stopped: `unmeasured`, `command`, `drain`, `budget` or `done`. */
|
|
721
|
+
step: "unmeasured" | "command" | "drain" | "budget" | "done";
|
|
690
722
|
verdict: TailVerdict | null;
|
|
691
723
|
}
|
|
692
724
|
|
|
@@ -700,7 +732,7 @@ export async function runWorkerCpuTail(spec: WorkerCpuTailSpec, deps: WorkerCpuD
|
|
|
700
732
|
const base = spec.base.replace(/\/$/, "");
|
|
701
733
|
|
|
702
734
|
deps.log(`\n▸ ${tag} Worker CPU: tailing ${spec.workerName} around \`${spec.command.join(" ")}\``);
|
|
703
|
-
|
|
735
|
+
let tail = deps.startTail(spec.workerName, spec.cwd, spec.credential);
|
|
704
736
|
|
|
705
737
|
/** Send the marker until the tail has carried it back, or give up. */
|
|
706
738
|
const awaitMarker = async (marker: string, withinMs: number): Promise<boolean> => {
|
|
@@ -718,16 +750,27 @@ export async function runWorkerCpuTail(spec: WorkerCpuTailSpec, deps: WorkerCpuD
|
|
|
718
750
|
return false;
|
|
719
751
|
};
|
|
720
752
|
|
|
721
|
-
|
|
753
|
+
// Decision 6: a tail that never attaches is restarted ONCE, with a fresh marker, before anything is judged.
|
|
754
|
+
let attached = await awaitMarker(nonce, connectMs);
|
|
755
|
+
let marker = nonce;
|
|
756
|
+
if (!attached) {
|
|
757
|
+
tail.stop();
|
|
758
|
+
deps.error(`🟡 ${tag} wrangler tail never delivered a request from ${base} within ${Math.round(connectMs / 1000)}s — restarting it once.\n${tail.errors()}`);
|
|
759
|
+
marker = `${nonce}r`;
|
|
760
|
+
tail = deps.startTail(spec.workerName, spec.cwd, spec.credential);
|
|
761
|
+
attached = await awaitMarker(marker, connectMs);
|
|
762
|
+
}
|
|
763
|
+
if (!attached) {
|
|
722
764
|
tail.stop();
|
|
723
765
|
deps.error(
|
|
724
|
-
`🔴 ${tag} wrangler tail never
|
|
766
|
+
`🔴 ${tag} wrangler tail never attached, twice, within ${Math.round(connectMs / 1000)}s each — the command runs UNMEASURED.\n${tail.errors()}`,
|
|
725
767
|
);
|
|
726
|
-
|
|
768
|
+
const ran = deps.run(spec.command, spec.cwd);
|
|
769
|
+
return { code: ran !== 0 ? ran : TAIL_UNATTACHED_EXIT, step: ran !== 0 ? "command" : "unmeasured", verdict: null };
|
|
727
770
|
}
|
|
728
771
|
|
|
729
772
|
const ran = deps.run(spec.command, spec.cwd);
|
|
730
|
-
const drained = await awaitMarker(`${
|
|
773
|
+
const drained = await awaitMarker(`${marker}-end`, drainMs);
|
|
731
774
|
// Traces are not strictly ordered; a moment more lets a straggler behind the end marker land.
|
|
732
775
|
await deps.sleep(2_000);
|
|
733
776
|
tail.stop();
|