@mark1russell7/harness 0.16.9 → 0.16.11
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/README.md +2 -0
- package/build/{image-YlflAajQ.js → image-BE9H5gIv.js} +61 -4
- package/build/{image-YlflAajQ.js.map → image-BE9H5gIv.js.map} +1 -1
- package/build/index.d.ts +12 -10
- package/build/index.js +4 -18
- package/build/index.js.map +1 -1
- package/build/layers.d.ts +54 -0
- package/build/layers.js +159 -0
- package/build/layers.js.map +1 -0
- package/build/schema.js +1 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ A **cell** (`cell.ts`) is all that one measurement needs, as data:
|
|
|
33
33
|
- An injector sidecar in the namespace of the target, with NET_ADMIN. Thus the image of the target stays stock.
|
|
34
34
|
- The manifest of each environment gives the HZ of its kernel, from /proc/config.gz. A host without that file (a hosted runner) gets HZ from two readings of /proc/timer_list, one second apart: its jiffies against the time of the kernel (`hzOf`). `hzFrom` tells which.
|
|
35
35
|
- The manifest of each environment holds a `substrate` block (`substrate.ts`). It gives the layer, the cloud, the vendor, the kernel, HZ, KVM and the image of the runner. GitHub can schedule one image on Azure or on AWS. Thus the cloud comes from the DMI vendor, not from the name of the kernel. No statistic pools two substrates (`comparable`). A record from before the block reads through `substrateOf`, and nothing rewrites it.
|
|
36
|
+
- The layers ([`docs/S7.md`](../../docs/S7.md)) are data in the entry `@mark1russell7/harness/layers`, which imports no `node:` module. `LAYER_FACTS` gives each layer its texts from the table of S7, the faults that its cells inject and the limits that their load fills. The faults of E2 are the triggers of `@mark1russell7/kind`. `layerOf` gives the layer of a lab from its topology.
|
|
36
37
|
- The prober ([`@mark1russell7/prober`](https://www.npmjs.com/package/@mark1russell7/prober)): a privileged container that loads the kernel program. It watches the namespace of the client, of the target and of each hop. Each run keeps its records from its start to its end. A run whose records the prober lost is void.
|
|
37
38
|
|
|
38
39
|
Each command is an argv array.
|
|
@@ -222,6 +223,7 @@ These rules keep a build the same in each run:
|
|
|
222
223
|
- A pinned image names its digest. A tag alone can move.
|
|
223
224
|
- Each `FROM` of the Dockerfile of a build names a digest, an earlier stage, or `scratch`.
|
|
224
225
|
- Each `package.json` and `Cargo.toml` of a build has a lockfile in its folder or in a folder above it.
|
|
226
|
+
- The npm lockfile in the folder of each `package.json` satisfies it: the lock holds each direct dependency, at a version in its range. `npm ci` refuses a pair that does not agree, thus the plan refuses it first and names each dependency. `npmDrift(manifest, lock)` gives the same lines.
|
|
225
227
|
- Each path of a build stays in its context.
|
|
226
228
|
- The tag of a build is its name, then 12 digits of a sha256. The sha256 reads the path of the Dockerfile, and the path and the content of each file. Thus a changed program cannot operate as an old one.
|
|
227
229
|
|
|
@@ -8,6 +8,7 @@ import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpa
|
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { isDeepStrictEqual } from "node:util";
|
|
11
|
+
import semver from "semver";
|
|
11
12
|
// src/cell.ts
|
|
12
13
|
/** These are the capabilities that a client image can get. */
|
|
13
14
|
const CLIENT_CAPABILITIES = [
|
|
@@ -69,6 +70,34 @@ const npmVersions = (lock) => {
|
|
|
69
70
|
}
|
|
70
71
|
return found;
|
|
71
72
|
};
|
|
73
|
+
/** These are the fields of a package.json that `npm ci` installs from the lock. */
|
|
74
|
+
const NPM_DEPENDENCY_FIELDS = [
|
|
75
|
+
"dependencies",
|
|
76
|
+
"optionalDependencies",
|
|
77
|
+
"devDependencies"
|
|
78
|
+
];
|
|
79
|
+
/** These ranges match each version for npm, a pre-release too. */
|
|
80
|
+
const ANY_VERSION = /* @__PURE__ */ new Set(["*", ""]);
|
|
81
|
+
/**
|
|
82
|
+
* This function gives a line for each direct dependency of a package.json that the npm lockfile
|
|
83
|
+
* beside it does not satisfy. The lock does not hold the dependency, or its locked version is out
|
|
84
|
+
* of the range of the manifest. `npm ci` refuses such a pair. The test is the test of npm: a loose
|
|
85
|
+
* semver match, and `*` matches each version. A range that is not semver (a tag, a URL, a path, an
|
|
86
|
+
* alias) is not read, and a lock of lockfileVersion 1 has no `packages`: neither gives a line.
|
|
87
|
+
*/
|
|
88
|
+
const npmDrift = (manifest, lock) => {
|
|
89
|
+
const declared = JSON.parse(manifest);
|
|
90
|
+
const packages = JSON.parse(lock).packages;
|
|
91
|
+
if (packages === void 0) return [];
|
|
92
|
+
const lines = [];
|
|
93
|
+
for (const field of NPM_DEPENDENCY_FIELDS) for (const [name, range] of Object.entries(declared[field] ?? {})) {
|
|
94
|
+
if (semver.validRange(range, true) === null) continue;
|
|
95
|
+
const version = packages[`node_modules/${name}`]?.version;
|
|
96
|
+
if (version === void 0) lines.push(`${name} ${range} is not in the lock`);
|
|
97
|
+
else if (!ANY_VERSION.has(range.trim()) && !semver.satisfies(version, range, true)) lines.push(`${name} ${range} has ${version} in the lock`);
|
|
98
|
+
}
|
|
99
|
+
return lines;
|
|
100
|
+
};
|
|
72
101
|
/** This function gives the packages of a Cargo.lock: the name, the version and the dependencies of each. */
|
|
73
102
|
const cargoPackages = (lock) => lock.split(/^\[\[package\]\]\s*$/m).slice(1).flatMap((block) => {
|
|
74
103
|
const name = /^name = "([^"]+)"$/m.exec(block)?.[1];
|
|
@@ -469,6 +498,28 @@ const unlockedManifests = (paths) => {
|
|
|
469
498
|
return true;
|
|
470
499
|
});
|
|
471
500
|
};
|
|
501
|
+
/** These are the npm lockfiles of a package.json in its folder, in the order of npm. The harness copies `npm-lock.json` to `package-lock.json` in a Dockerfile. */
|
|
502
|
+
const NPM_LOCKS = [
|
|
503
|
+
"npm-shrinkwrap.json",
|
|
504
|
+
"package-lock.json",
|
|
505
|
+
"npm-lock.json"
|
|
506
|
+
];
|
|
507
|
+
/**
|
|
508
|
+
* This function gives a line for each package.json of a context that the npm lockfile in its folder
|
|
509
|
+
* does not satisfy (`npmDrift`). `npm ci` refuses such a pair in the build. A lockfile in a folder
|
|
510
|
+
* above, as of a workspace, is not read here.
|
|
511
|
+
*/
|
|
512
|
+
const driftedManifests = (files) => {
|
|
513
|
+
const byPath = new Map(files.map((each) => [each.at, each.file]));
|
|
514
|
+
return files.flatMap(({ file, at }) => {
|
|
515
|
+
if (posix.basename(at) !== "package.json") return [];
|
|
516
|
+
const folder = posix.dirname(at);
|
|
517
|
+
const lockAt = NPM_LOCKS.map((name) => folder === "." ? name : `${folder}/${name}`).find((path) => byPath.has(path));
|
|
518
|
+
if (lockAt === void 0) return [];
|
|
519
|
+
const lines = npmDrift(readFileSync(file, "utf8"), readFileSync(byPath.get(lockAt), "utf8"));
|
|
520
|
+
return lines.length === 0 ? [] : [`${at} and ${lockAt} do not agree (${lines.join(", ")}): make the lock again with npm install --package-lock-only`];
|
|
521
|
+
});
|
|
522
|
+
};
|
|
472
523
|
/**
|
|
473
524
|
* This function gives each file under a path, in a stable sequence, but not the output of a local build. The disk
|
|
474
525
|
* tier uses it for the digest of a subject folder (`openDiskLab`). The index does not export it.
|
|
@@ -510,7 +561,8 @@ const shippedPlans = /* @__PURE__ */ new Map();
|
|
|
510
561
|
* Thus a changed program cannot operate as an old one.
|
|
511
562
|
*
|
|
512
563
|
* A build fails before it starts on a problem of its source. It also fails on a `FROM` that no
|
|
513
|
-
* digest pins, and on a manifest of packages without a lockfile.
|
|
564
|
+
* digest pins, and on a manifest of packages without a lockfile. A package.json that the npm
|
|
565
|
+
* lockfile in its folder does not satisfy also stops it.
|
|
514
566
|
*/
|
|
515
567
|
const planOf = (source) => {
|
|
516
568
|
if (typeof source === "string") return {
|
|
@@ -535,7 +587,12 @@ const planOf = (source) => {
|
|
|
535
587
|
const bases = basesOf(readFileSync(docker.file, "utf8"));
|
|
536
588
|
const unpinned = bases.filter((image) => !PINNED.test(image));
|
|
537
589
|
const unlocked = unlockedManifests(files.map((each) => each.at));
|
|
538
|
-
|
|
590
|
+
const drifted = driftedManifests(files);
|
|
591
|
+
if (unpinned.length > 0 || unlocked.length > 0 || drifted.length > 0) throw new Error(`${labelOf(source)}: ${[
|
|
592
|
+
...unpinned.map((image) => `the base ${image} is not pinned by digest`),
|
|
593
|
+
...unlocked.map((path) => `${path} has no lockfile`),
|
|
594
|
+
...drifted
|
|
595
|
+
].join(", ")}`);
|
|
539
596
|
const hash = createHash("sha256");
|
|
540
597
|
hash.update(dockerfile);
|
|
541
598
|
const read = [];
|
|
@@ -697,6 +754,6 @@ const grpcClientImage = () => imageOf(shipped("grpc"));
|
|
|
697
754
|
const targetSourceOf = (target) => target.subject ?? target.image;
|
|
698
755
|
/** This function gives the image that a target operates: the image of its subject, or its stock image. */
|
|
699
756
|
const targetImageOf = (target) => imageOf(targetSourceOf(target));
|
|
700
|
-
export { targetSourceOf as A,
|
|
757
|
+
export { targetSourceOf as A, versionsOf as B, programOf as C, subjectClient as D, sources as E, goVersions as F, requestFirst as G, environmentProblems as H, jarVersions as I, locksOf as L, unpinnedBases as M, LOCK_NAMES as N, subjectProblems as O, cargoVersions as P, npmDrift as R, planOf as S, shippedSource as T, isHopPlace as U, CLIENT_CAPABILITIES as V, latestEndOf as W, kafkaClientImage as _, SHIPPED_NAMES as a, nodeHttpImage as b, buildRecordOf as c, harnessImage as d, harnessVersion as f, inContext as g, imageProblems as h, SHIPPED_CLIENTS as i, unlockedManifests as j, targetImageOf as k, goHttpImage as l, imageOf as m, PINNED as n, amqpClientImage as o, hikariClientImage as p, REPOSITORY as r, basesOf as s, CLIENT_NAMES as t, grpcClientImage as u, mongoClientImage as v, routerImage as w, pgClientImage as x, nodeClientImage as y, npmVersions as z };
|
|
701
758
|
|
|
702
|
-
//# sourceMappingURL=image-
|
|
759
|
+
//# sourceMappingURL=image-BE9H5gIv.js.map
|