@tokenoftrust/storefront-runner 3.10.1 → 3.10.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -79,7 +79,9 @@ export function schemaCheckVerdict({ count, stale, orphans, foldGate }) {
|
|
|
79
79
|
|
|
80
80
|
async function check() {
|
|
81
81
|
const { files, stale, orphans } = await findSchemaDrift();
|
|
82
|
-
const
|
|
82
|
+
const phase = process.env.TOT_GATE_PHASE;
|
|
83
|
+
const foldGate = process.env.TOT_FOLD_GATE === "1" || phase === "fold" || phase === "prefold";
|
|
84
|
+
const verdict = schemaCheckVerdict({ count: files.size, stale, orphans, foldGate });
|
|
83
85
|
for (const line of verdict.lines) (verdict.ok ? console.log : console.error)(line);
|
|
84
86
|
if (!verdict.ok) process.exitCode = 1;
|
|
85
87
|
}
|
|
@@ -1,25 +1,49 @@
|
|
|
1
|
-
// The CPU budget of the check step this process runs in.
|
|
2
|
-
//
|
|
3
|
-
// TOT_STEP_CPUS
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// The CPU budget of the check step this process runs in.
|
|
2
|
+
//
|
|
3
|
+
// TOT_STEP_CPUS, when set, is that budget. tot-gate does not set it: while TOT_GATE_PHASE is
|
|
4
|
+
// set and TOT_STEP_CPUS is unset, the budget is the cgroup v2 cpu.max limit (the same quota
|
|
5
|
+
// tot-gate uses for its slot count), or null when the cgroup sets no limit. A hand run, with
|
|
6
|
+
// neither set, leaves every pool at its own default.
|
|
6
7
|
//
|
|
7
8
|
// CommonJS so the in-memory `.cts` vitest configs can require it as well as ESM can import it.
|
|
8
9
|
"use strict";
|
|
9
10
|
|
|
11
|
+
const { readFileSync } = require("node:fs");
|
|
12
|
+
|
|
10
13
|
const STEP_CPUS_ENV = "TOT_STEP_CPUS";
|
|
11
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The CPU count a cgroup v2 cpu.max allows ("<quota> <period>", or "max <period>"), or null
|
|
17
|
+
* when it sets no limit. Same arithmetic as tot-gate's cgroupCpuLimit.
|
|
18
|
+
* @param {string | null | undefined} cpuMax
|
|
19
|
+
* @returns {number | null}
|
|
20
|
+
*/
|
|
21
|
+
function cgroupCpuLimit(cpuMax) {
|
|
22
|
+
const match = /^(\d+|max)\s+(\d+)\s*$/.exec((cpuMax ?? "").trim());
|
|
23
|
+
if (!match || match[1] === "max" || Number(match[2]) === 0) return null;
|
|
24
|
+
return Math.max(1, Math.ceil(Number(match[1]) / Number(match[2])));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function readCpuMax() {
|
|
28
|
+
try { return readFileSync("/sys/fs/cgroup/cpu.max", "utf8"); } catch { return null; }
|
|
29
|
+
}
|
|
30
|
+
|
|
12
31
|
/**
|
|
13
32
|
* The step's CPU budget, or null outside a budgeted step.
|
|
33
|
+
* `cpuMax` overrides the cgroup file (tests); omit it to read `/sys/fs/cgroup/cpu.max`.
|
|
14
34
|
* @param {NodeJS.ProcessEnv} [env]
|
|
35
|
+
* @param {string | null} [cpuMax]
|
|
15
36
|
* @returns {number | null}
|
|
16
37
|
*/
|
|
17
|
-
function stepCpus(env = process.env) {
|
|
38
|
+
function stepCpus(env = process.env, cpuMax) {
|
|
18
39
|
const raw = env[STEP_CPUS_ENV];
|
|
19
|
-
if (raw
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
if (raw !== undefined && raw !== "") {
|
|
41
|
+
const cpus = Number(raw);
|
|
42
|
+
if (!Number.isInteger(cpus) || cpus < 1) throw new Error(`${STEP_CPUS_ENV} must be a positive integer, got "${raw}"`);
|
|
43
|
+
return cpus;
|
|
44
|
+
}
|
|
45
|
+
if (!env.TOT_GATE_PHASE) return null;
|
|
46
|
+
return cgroupCpuLimit(cpuMax === undefined ? readCpuMax() : cpuMax);
|
|
23
47
|
}
|
|
24
48
|
|
|
25
49
|
/**
|
|
@@ -45,4 +69,4 @@ function nodeTestFlags(flags, env = process.env) {
|
|
|
45
69
|
return [...flags, `--test-concurrency=${cpus}`];
|
|
46
70
|
}
|
|
47
71
|
|
|
48
|
-
module.exports = { STEP_CPUS_ENV, stepCpus, stepWorkers, nodeTestFlags };
|
|
72
|
+
module.exports = { STEP_CPUS_ENV, cgroupCpuLimit, stepCpus, stepWorkers, nodeTestFlags };
|