@rightkit/release 0.6.51 → 0.6.54
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 +1 -1
- package/adapter-env.mjs +16 -105
- package/admission-host.mjs +14 -1
- package/bin/darwin/rightkit-swap +0 -0
- package/bin/rightkit-gate.mjs +609 -404
- package/broker-admission.mjs +122 -2
- package/build-launch.mjs +52 -58
- package/build-release.mjs +2 -2
- package/cargo-ledger.mjs +24 -5
- package/cargo-target-shim.mjs +54 -23
- package/cargo-target.mjs +2 -2
- package/carried-adapter-run.mjs +7 -8
- package/carried-cargo-run.mjs +1 -1
- package/ci-compile-admission.mjs +1 -1
- package/clippy-route.mjs +65 -18
- package/compile-inputs.mjs +91 -15
- package/cross-targets.mjs +5 -3
- package/deps-cargo-lock.mjs +1 -1
- package/deterministic-scans.mjs +789 -259
- package/development.mjs +33 -7
- package/direct-receipt.mjs +3 -5
- package/feature-coverage.mjs +45 -9
- package/feature-partition.mjs +204 -0
- package/feature-sets.mjs +113 -0
- package/gate-acceptance.mjs +187 -115
- package/gate-seam.mjs +352 -0
- package/gate-serve.mjs +34 -2
- package/gate-stages.mjs +6 -2
- package/ghsa-audit.mjs +19 -4
- package/heavy-command.mjs +5 -4
- package/install-tauri-authenticode.mjs +73 -4
- package/ios-dev.mjs +3 -3
- package/ios-package-recipe.mjs +6 -6
- package/linux-setup.mjs +3 -2
- package/local-publish.mjs +113 -17
- package/lock-identity.mjs +24 -100
- package/managed-cargo.mjs +3 -3
- package/managed-root-guard.mjs +2 -2
- package/managed-roots.mjs +3 -3
- package/native-adapters.mjs +41 -244
- package/native-helpers.mjs +1 -1
- package/pack-digest.mjs +1 -1
- package/package-recipe-targets.mjs +3 -3
- package/package.json +2 -2
- package/publication-gate.mjs +29 -6
- package/publish-cargo.mjs +4 -5
- package/publish-local-cargo.mjs +77 -1
- package/qualification-verify.mjs +76 -49
- package/receipt-signature.mjs +104 -0
- package/release-switch-registry.json +4 -0
- package/release-switch-scan.mjs +13 -10
- package/rightkit-versions.json +126 -113
- package/scan-digest.mjs +43 -14
- package/seam-broker.mjs +168 -0
- package/snapshot-check.mjs +4 -1
- package/snapshot-dependency-reuse.mjs +1 -1
- package/snapshot-metadata.mjs +24 -35
- package/snapshot.mjs +328 -49
- package/stage-commands.mjs +59 -5
- package/stage-ledger.mjs +2 -2
- package/{carried-cargo.mjs → stage-seam.mjs} +118 -70
- package/stage-sidecar.mjs +3 -3
- package/tauri-bundle-marker.mjs +5 -2
- package/tauri-locked.mjs +1 -1
- package/tool-build.mjs +8 -6
- package/unit-gate.mjs +40 -10
- package/web-build.mjs +6 -0
- package/broker-handshake.mjs +0 -160
- package/broker-wire.mjs +0 -278
- package/build-ownership.mjs +0 -1578
- package/cargo-shapes.mjs +0 -332
- package/cargo-width.mjs +0 -49
- package/carrier-census.mjs +0 -124
- package/clippy-equivalence.mjs +0 -202
- package/freshness-census.mjs +0 -405
- package/handle-revocation.mjs +0 -100
- package/handle-revocation.rust-vector.json +0 -1
- package/handle-revocation.vectors.json +0 -53
- package/legion-freeze-consumer.mjs +0 -241
- package/linux-qualifier.mjs +0 -83
- package/native-tool-planning.mjs +0 -94
- package/owner-process-proof.mjs +0 -14
- package/ownership-mark.mjs +0 -191
- package/ownership-recover.mjs +0 -78
- package/pnpm-adapter-grammar.mjs +0 -226
- package/provenance-verify.mjs +0 -413
- package/snapshot-broker.mjs +0 -808
- package/snapshot-request.mjs +0 -722
- package/unit-list-compile.mjs +0 -356
package/ios-dev.mjs
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
//
|
|
18
18
|
// RA-09 / R3-M02: xcodegen and every xcodebuild call (build, build-for-testing, test-without-building) are typed native adapter jobs of the production runner (build-launch.mjs createNativeRunner,
|
|
19
19
|
// `runIosDevelopmentCommands`): no -derivedDataPath, -resultBundlePath, -archivePath or -exportPath is ever named (the broker owns the output root), and the built .app and the result bundle are READ
|
|
20
|
-
// BACK from the verified receipt's managed output roles (`derived-data`, `result-bundle`). A call the door
|
|
21
|
-
// no managed form
|
|
20
|
+
// BACK from the verified receipt's managed output roles (`derived-data`, `result-bundle`). A call the door cannot map (no runner route, a path outside the step's directory) is refused before anything is launched, and the broker refuses an argv with
|
|
21
|
+
// no managed form at admission (RK_ADAPTER_ARGV_DENIED); there is no spawn fallback. simctl, devicectl and the app's own non-native `prepare` commands stay direct, non-compiling steps.
|
|
22
22
|
import * as nodeFs from "node:fs";
|
|
23
23
|
import os from "node:os";
|
|
24
24
|
import path from "node:path";
|
|
@@ -292,7 +292,7 @@ export function prepareIosUiTests(dev, { root, env = process.env, run = spawnSyn
|
|
|
292
292
|
// ---- running the generated commands ---------------------------------------------------------------------------------
|
|
293
293
|
/**
|
|
294
294
|
* Runs generated commands in order through the production native runner (`native`, build-launch.mjs createNativeRunner): xcodegen and xcodebuild are broker adapter jobs and nothing
|
|
295
|
-
* else runs them. EVERY native command is planned first (the door's launch
|
|
295
|
+
* else runs them. EVERY native command is planned first (the door's launch: tool-to-adapter mapping and relative paths; the broker judges the argv at each call), so a door refusal stops the whole sequence before the first launch.
|
|
296
296
|
* A command that is not a native build tool (the app's own `prepare` commands) goes to `direct(command)` when the caller supplies one and is otherwise refused; it is never given to a
|
|
297
297
|
* native-tool spawn. Returns { steps: [{ name, result }], outputs } where `outputs` is the LAST xcodebuild call's managed mapping and `resultBundle` the test call's `result-bundle` role.
|
|
298
298
|
*/
|
package/ios-package-recipe.mjs
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
// never a spawn of this recipe's own. The broker owns the output root, so the call names neither -derivedDataPath, -archivePath, -exportPath nor -resultBundlePath:
|
|
22
22
|
// the archive and the export directory are READ BACK from the verified receipt's managed output roles (`outputs.byRole.archive` / `.export`), and the export must read
|
|
23
23
|
// the very archive that was verified. The ExportOptions.plist is a regular XML file inside the step directory (the snapshot), not under the receipt directory. Signing stays
|
|
24
|
-
// the provisioned GUI session's (assertGuiSigningSession) with automatic signing and -allowProvisioningUpdates; no alternate signer exists. A missing runner,
|
|
25
|
-
//
|
|
24
|
+
// the provisioned GUI session's (assertGuiSigningSession) with automatic signing and -allowProvisioningUpdates; no alternate signer exists. A missing runner or a call the door cannot map (a path outside the step's directory, a signing-file
|
|
25
|
+
// handoff) is refused BEFORE the first tool is launched; an argv the broker's grammar refuses is refused by the broker at that call (RK_ADAPTER_ARGV_DENIED), not by the gate beforehand. The non-compiling queries (`xcodebuild -version`, `xcodegen --version`,
|
|
26
26
|
// plutil, codesign, security, ditto, git) are this recipe's own direct steps through `deps.run`.
|
|
27
27
|
import { createHash } from "node:crypto";
|
|
28
28
|
import * as nodeFs from "node:fs";
|
|
@@ -41,7 +41,7 @@ export const IOS_DEFAULT_TIMEOUT_MS = 60 * 60 * 1000;
|
|
|
41
41
|
* Codes: IOS_PACKAGE_CONFIG_INVALID, IOS_PACKAGE_HOST_UNSUPPORTED, IOS_PACKAGE_TOOL_MISSING, IOS_PACKAGE_GENERATE_FAILED,
|
|
42
42
|
* IOS_PACKAGE_PREPARE_FAILED, IOS_PACKAGE_ARCHIVE_FAILED, IOS_PACKAGE_SOURCE_CHANGED, IOS_PACKAGE_VERIFY_FAILED,
|
|
43
43
|
* IOS_PACKAGE_EXPORT_FAILED, IOS_PACKAGE_BUILD_NUMBER, IOS_PACKAGE_RECEIPT_FAILED, IOS_PACKAGE_NATIVE_REQUIRED (no production native runner was supplied),
|
|
44
|
-
* IOS_PACKAGE_NATIVE_REFUSED (the door
|
|
44
|
+
* IOS_PACKAGE_NATIVE_REFUSED (the door refused a native call before any launch, or the broker refused it at admission; the message names the code).
|
|
45
45
|
*/
|
|
46
46
|
export class IosPackageError extends Error {
|
|
47
47
|
constructor(code, message, options) { super(message, options); this.name = "IosPackageError"; this.code = code; }
|
|
@@ -576,7 +576,7 @@ export async function runIosPackageRecipe({
|
|
|
576
576
|
if (result.error || result.status !== 0) throw new IosPackageError(code, `${cmd} ${id} failed (${result.status ?? "unavailable"})${result.error ? `: ${result.error.message}` : ""}\n${outputTail(result)}`);
|
|
577
577
|
return result;
|
|
578
578
|
};
|
|
579
|
-
// A compiler-capable call: the production runner only. A refusal (no runner route,
|
|
579
|
+
// A compiler-capable call: the production runner only. A refusal (no runner route, a path the door cannot map, or an argv the broker refuses at admission) happened BEFORE any build ran and names its code.
|
|
580
580
|
const refusedNative = (cmd, refusal) => new IosPackageError("IOS_PACKAGE_NATIVE_REFUSED", `${cmd} was refused before any launch (${refusal.code ?? "refused"}): ${refusal.message}`);
|
|
581
581
|
const planNative = (cmd, args, options = {}) => {
|
|
582
582
|
try { native.plan(cmd, args, { cwd: root, env, ...options }); } catch (error) {
|
|
@@ -601,7 +601,7 @@ export async function runIosPackageRecipe({
|
|
|
601
601
|
return found;
|
|
602
602
|
};
|
|
603
603
|
const nativeEvidence = (result) => ({
|
|
604
|
-
tool: result.tool, adapter: result.adapter,
|
|
604
|
+
tool: result.tool, adapter: result.adapter, carried: result.carried, relativeCwd: result.relativeCwd, requestId: result.requestId, outputDir: result.outputDir,
|
|
605
605
|
outputsSource: result.outputs?.source ?? null, argv: result.argv, outputs: result.outputs?.outputs ?? [],
|
|
606
606
|
});
|
|
607
607
|
const plist = (file) => {
|
|
@@ -625,7 +625,7 @@ export async function runIosPackageRecipe({
|
|
|
625
625
|
|
|
626
626
|
let tempDir;
|
|
627
627
|
try {
|
|
628
|
-
// ---- plan every compiler-capable call
|
|
628
|
+
// ---- plan every compiler-capable call through the door BEFORE the first launch: a missing runner or an unmappable path stops here, with nothing sent (the broker's own argv refusals arrive at the call) ----
|
|
629
629
|
// The export reads an options file of the step directory, so it is written first; the build number is a placeholder here (the real one is drawn from the counter just before the archive).
|
|
630
630
|
const optionsText = exportOptionsPlist(spec);
|
|
631
631
|
fs.mkdirSync(path.dirname(optionsFile), { recursive: true });
|
package/linux-setup.mjs
CHANGED
|
@@ -98,9 +98,10 @@ export function setup({ root, home = homedir(), arch = process.arch, run, fetchT
|
|
|
98
98
|
for (const lr of lockroots) {
|
|
99
99
|
const dir = resolve(root, lr);
|
|
100
100
|
log(`pnpm store: ${lr}`);
|
|
101
|
-
//
|
|
101
|
+
// A throwaway virtual store and modules directory keep `pnpm fetch` from touching the root's node_modules (pnpm 12.16.1
|
|
102
|
+
// prunes it when only --virtual-store-dir points elsewhere).
|
|
102
103
|
const vstore = dryRun ? join(tmpdir(), "rk-vstore") : mkdtempSync(join(tmpdir(), "rk-vstore-"));
|
|
103
|
-
try { sh("pnpm", ["fetch", "--virtual-store-dir", vstore], { cwd: dir }); } finally { if (!dryRun) rmSync(vstore, { recursive: true, force: true }); }
|
|
104
|
+
try { sh("pnpm", ["fetch", "--ignore-scripts", "--virtual-store-dir", vstore, "--modules-dir", join(vstore, "node_modules")], { cwd: dir }); } finally { if (!dryRun) rmSync(vstore, { recursive: true, force: true }); }
|
|
104
105
|
}
|
|
105
106
|
return { pins, lockroots, steps };
|
|
106
107
|
}
|
package/local-publish.mjs
CHANGED
|
@@ -33,7 +33,8 @@ import { recordPublished, stageSourceVersions, workspaceFeedOptions } from "./ri
|
|
|
33
33
|
import { prepareSwapHelper, SWAP_HELPER_CARGO_ARGS, SWAP_HELPER_PACKAGE } from "./swap-helper-bundle.mjs";
|
|
34
34
|
import { exclusionsFor, npmContentDigest } from "./pack-digest.mjs";
|
|
35
35
|
import { requireDoorRun, gateStateDir } from "./gate-stages.mjs";
|
|
36
|
-
import { crossCompileEnv, crossTargetsFor, oneOutput } from "./cross-targets.mjs";
|
|
36
|
+
import { crossCompileEnv, crossTargetsFor, oneOutput, scopedCrossTargets } from "./cross-targets.mjs";
|
|
37
|
+
import { crossFeatureSets, defaultCheckFeatureSets, hostFeatureSets } from "./feature-sets.mjs";
|
|
37
38
|
|
|
38
39
|
export const LOCAL_OPERATOR = "agent (local-build grant)";
|
|
39
40
|
export const LOCAL_HOST_POLICY_REASON = "Adrian 2026-10-14 local-build grant (.rightkit-local-build.json); Windows covered by the next CI run";
|
|
@@ -323,10 +324,11 @@ async function defaultLoadWorkspaceModules(workspaceRoot) {
|
|
|
323
324
|
* include `--all-features` needs none. `checkFeatureSets` (ci/gate.config.json) lists them explicitly for
|
|
324
325
|
* crates with mutually exclusive features; otherwise one `--all-features` check runs. Mirrored in scripts/ci/gate.mjs.
|
|
325
326
|
*/
|
|
326
|
-
export function allFeatureCheckSets(entry = {}) {
|
|
327
|
-
|
|
327
|
+
export function allFeatureCheckSets(entry = {}, platform = undefined, crate = "<crate>") {
|
|
328
|
+
// The sets this host plans (feature-sets.mjs): a set scoped to other hosts is neither tested nor checked here.
|
|
329
|
+
const tested = hostFeatureSets(entry, platform, "featureSets", crate) ?? [[]];
|
|
328
330
|
if (tested.some((features) => features.includes("--all-features"))) return [];
|
|
329
|
-
return entry
|
|
331
|
+
return hostFeatureSets(entry, platform, "checkFeatureSets", crate) ?? defaultCheckFeatureSets(entry, crate);
|
|
330
332
|
}
|
|
331
333
|
|
|
332
334
|
const CONSUMER_ROW_KEYS = new Set(["manifestPath", "args", "kind", "targets", "locked"]);
|
|
@@ -447,7 +449,9 @@ export function localTestPlan({ kind, unit, dir, config, manifest, batch = false
|
|
|
447
449
|
// gate.config.json names hosts "macos" and "windows" (scripts/ci/gate.mjs HOST).
|
|
448
450
|
const gateHost = platform === "win32" ? "windows" : "macos";
|
|
449
451
|
if (entry.os && !entry.os.includes(gateHost)) refuse(`${unit} is restricted to ${entry.os.join(", ")} by ci/gate.config.json; it cannot be qualified on this ${platform === "win32" ? "Windows host" : "Mac"}`);
|
|
450
|
-
const featureSets = entry
|
|
452
|
+
const featureSets = hostFeatureSets(entry, platform, "featureSets", unit) ?? [[]];
|
|
453
|
+
// The sets also linted for the other OSes' targets: a host-scoped set is a native-host set and has no cross-target row (feature-sets.mjs).
|
|
454
|
+
const crossSets = crossFeatureSets(entry, platform, "featureSets", unit) ?? [[]];
|
|
451
455
|
// Stream Cargo artifact records to the broker; libtest summaries remain plain text for ResultScanner.
|
|
452
456
|
const steps = [];
|
|
453
457
|
for (const features of featureSets) {
|
|
@@ -459,18 +463,20 @@ export function localTestPlan({ kind, unit, dir, config, manifest, batch = false
|
|
|
459
463
|
if (!batch) for (const features of featureSets) steps.push({ command: "cargo", args: ["clippy", "-p", unit, "--message-format=json-render-diagnostics", "--no-deps", "--all-targets", ...features, "--", "-D", "warnings"], test: false });
|
|
460
464
|
// Every crate is checked for the other two OS targets too, every tested feature set, -D warnings (CROSS_TARGETS). Batch mode
|
|
461
465
|
// lints them with the batch's own clippy (batchClippyInvocations crossTargetsOf).
|
|
462
|
-
|
|
463
|
-
|
|
466
|
+
// A crate scoped to some OSes (ci/gate.config.json platforms) is checked only for those OSes' targets, as planScans does (scopedCrossTargets).
|
|
467
|
+
if (!batch) for (const target of scopedCrossTargets(entry, platform)) {
|
|
468
|
+
for (const features of crossSets) {
|
|
464
469
|
const env = crossCompileEnv(target);
|
|
465
470
|
// GC-A14: a host without the zig C toolchain fails the check, never skips it.
|
|
466
471
|
if (!env) refuse(`RK_CROSS_CC_UNPROVISIONED: the zig C toolchain for ${target} is not provisioned; run node scripts/ci/provision-zig.mjs <managed data root>/zig (or set RIGHTKIT_CROSS_CC_DIR)`);
|
|
467
472
|
steps.push({ command: "cargo", args: ["clippy", "-p", unit, "--message-format=json-render-diagnostics", "--no-deps", "--all-targets", "--target", target, ...features, "--", "-D", "warnings"], test: false, ...(env ? { env } : {}) });
|
|
468
473
|
}
|
|
469
474
|
}
|
|
470
|
-
|
|
475
|
+
const checkSets = allFeatureCheckSets(entry, platform, unit);
|
|
476
|
+
for (const features of checkSets) steps.push({ command: "cargo", args: ["check", "-p", unit, "--message-format=json-render-diagnostics", "--all-targets", ...features], test: false });
|
|
471
477
|
// rustdoc with -D warnings, for the tested and the checked feature sets: the same rows the CI shards (scripts/ci/gate.mjs) and
|
|
472
478
|
// publish.yml's native verify run, so a broken or private intra-doc link fails this unit stage instead of a later verify.
|
|
473
|
-
const docSets = [...new Map([...featureSets, ...
|
|
479
|
+
const docSets = [...new Map([...featureSets, ...checkSets].map((features) => [JSON.stringify(features), features])).values()];
|
|
474
480
|
for (const features of docSets) steps.push({ command: "cargo", args: ["doc", "-p", unit, "--message-format=json-render-diagnostics", "--no-deps", ...features], test: false, env: { RUSTDOCFLAGS: "-D warnings" } });
|
|
475
481
|
// Consumer rows (separate Cargo workspaces) gate only this crate: they come from this crate's own entry.
|
|
476
482
|
const consumers = consumerRows(unit, entry);
|
|
@@ -514,6 +520,95 @@ export function compileRequirements({ kind, unit, dir, config, manifest, platfor
|
|
|
514
520
|
};
|
|
515
521
|
}
|
|
516
522
|
|
|
523
|
+
// ---- A unit-list run's publisher requirements (reset plan step 5: moved from unit-list-compile.mjs, the grouped publisher scheduler, which is deleted) ----------
|
|
524
|
+
// The scheduling (union plan, coalescing, serial admission, lockstep) is gone: deterministic-scans.mjs planUnitListScans / judgeUnitList plan and judge the
|
|
525
|
+
// same requirements over runScans' own class B grouping. What stays here has no planScans replacement: the requirements themselves, the file-only secret scan,
|
|
526
|
+
// and the proof that a narrow package-selected invocation may run at its workspace root.
|
|
527
|
+
const bodyOf = ({ workspace, cwd, executable, internal, argv, env, phase }) => ({ workspace, cwd, executable, ...(internal === undefined ? {} : { internal }), argv, env, phase });
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
/** Prove that moving a narrow package-selected Cargo invocation to its workspace root preserves discovery. */
|
|
531
|
+
export function proveWorkspaceCwd({ requirement: r, snapshot, checkout, toolchainOf, exists = fs.existsSync }) {
|
|
532
|
+
const no = (reason) => ({ cwd: r.cwd, normalized: false, reason });
|
|
533
|
+
const testRow = r.phase === "test" && r.argv[0] === "test";
|
|
534
|
+
if (r.executable !== "cargo" || !(r.phase === "compile" ? ["check", "clippy", "doc"].includes(r.argv[0]) : testRow) || r.workspace === r.cwd) return no("not a movable Cargo check, clippy, doc or test");
|
|
535
|
+
const workspace = path.resolve(snapshot, r.workspace); const cwd = path.resolve(snapshot, r.cwd);
|
|
536
|
+
const relative = path.relative(workspace, cwd);
|
|
537
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return no("working directory is outside workspace");
|
|
538
|
+
// Only the publisher's package-selected, path-free shape can move. Cargo's configuration and toolchain
|
|
539
|
+
// lookups depend on cwd; inspect every intermediate directory in both trees, including crate itself.
|
|
540
|
+
// A test row's arguments after `--` go to its test executables, which run in their own package directory (CARGO_MANIFEST_DIR), never the cargo cwd: plain flags only.
|
|
541
|
+
const cut = testRow ? r.argv.indexOf("--") : -1;
|
|
542
|
+
if (cut >= 0 && !r.argv.slice(cut + 1).every((a) => /^--[a-z][a-z0-9-]*(?:=[0-9]+)?$/.test(a))) return no("unproven test executable argument");
|
|
543
|
+
const args = cut >= 0 ? r.argv.slice(0, cut) : r.argv; let packages = 0;
|
|
544
|
+
for (let i = 1; i < args.length; i += 1) {
|
|
545
|
+
const a = args[i];
|
|
546
|
+
if (a === "-p") { if (!/^[a-zA-Z0-9_-]+$/.test(args[++i] ?? "")) return no("invalid package selector"); packages += 1; }
|
|
547
|
+
else if (["--target", "--jobs", "--profile", "-D"].includes(a)) { if (!/^[a-zA-Z0-9_.-]+$/.test(args[++i] ?? "")) return no("cwd-sensitive argument"); }
|
|
548
|
+
else if (!["--", "--no-deps", "--no-fail-fast", "--all-targets", "--all-features", "--no-default-features", "--locked", "--frozen", "--offline", "--message-format=json-render-diagnostics"].includes(a)) return no(`unproven argument ${a}`);
|
|
549
|
+
}
|
|
550
|
+
if (packages !== 1) return no("requires exactly one package selector");
|
|
551
|
+
for (const [key, value] of Object.entries(r.env)) {
|
|
552
|
+
if (typeof value !== "string") return no(`non-string environment ${key}`);
|
|
553
|
+
if (/^(?:PATH|Path)$/.test(key) && value.split(path.delimiter).some((part) => !path.isAbsolute(part))) return no(`cwd-sensitive environment ${key}`);
|
|
554
|
+
if (/^(?:RUSTFLAGS|RUSTDOCFLAGS|CARGO_ENCODED_RUSTFLAGS|CARGO_TARGET_.*_RUSTFLAGS)$/.test(key) && value && !/^(?:-D\s*warnings|-A\s*warnings)$/.test(value.trim())) return no(`unproven compiler flags in ${key}`);
|
|
555
|
+
if (/^(?:CARGO_|RUST|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|PKG_CONFIG)/.test(key) && (/[\\/]/.test(value) && !path.isAbsolute(value) || /(?:^|\s)\.{1,2}[\\/]/.test(value))) return no(`cwd-sensitive environment ${key}`);
|
|
556
|
+
}
|
|
557
|
+
for (const root of [snapshot, checkout]) {
|
|
558
|
+
let at = path.resolve(root, r.workspace);
|
|
559
|
+
for (const part of relative.split(path.sep)) {
|
|
560
|
+
at = path.join(at, part);
|
|
561
|
+
for (const file of [".cargo/config", ".cargo/config.toml", "rust-toolchain", "rust-toolchain.toml"]) if (exists(path.join(at, file))) return no(`cwd override ${path.relative(root, path.join(at, file))}`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (typeof toolchainOf !== "function") return no("effective toolchain is unverified");
|
|
565
|
+
let toolchains;
|
|
566
|
+
try { toolchains = [snapshot, checkout].flatMap((root) => [r.workspace, r.cwd].map((dir) => toolchainOf(path.resolve(root, dir)))); } catch { return no("effective toolchain probe failed"); }
|
|
567
|
+
const locations = ["snapshot workspace", "snapshot unit", "checkout workspace", "checkout unit"];
|
|
568
|
+
for (const [i, probe] of toolchains.entries()) if (!(typeof probe === "string" ? probe : probe?.toolchain)) return no(`effective toolchain unavailable at ${locations[i]} (${typeof probe?.error === "string" && /^(?:spawn-error|exit-(?:\d+|unknown))$/.test(probe.error) ? probe.error : "empty-result"})`);
|
|
569
|
+
if (new Set(toolchains.map((probe) => typeof probe === "string" ? probe : probe.toolchain)).size !== 1) return no("effective toolchain differs across workspace and unit");
|
|
570
|
+
return { cwd: r.workspace, normalized: true, reason: "matching Cargo config and effective toolchain" };
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Run the publisher's own file-only crate scan against the guarded snapshot. */
|
|
574
|
+
export async function runPublisherSecretRequirement({ requirement, snapshot, commit, tree, verifySnapshot }) {
|
|
575
|
+
if (requirement?.internal !== "scanCrateForSecrets" || requirement.phase !== "check" || requirement.executable !== null || requirement.argv?.length !== 1 || requirement.argv[0] !== requirement.cwd || sha256(JSON.stringify(bodyOf(requirement))) !== requirement.coverageKey || !/^crates\/rightkit-[a-z0-9-]+$/.test(requirement.cwd) || typeof verifySnapshot !== "function" || !/^[0-9a-f]{40,64}$/.test(commit ?? "") || !/^[0-9a-f]{40,64}$/.test(tree ?? "")) throw new Error("invalid publisher secret scan or snapshot binding");
|
|
576
|
+
const root = fs.realpathSync(snapshot); const directory = fs.realpathSync(path.join(root, requirement.cwd));
|
|
577
|
+
if (!directory.startsWith(`${root}${path.sep}`)) throw new Error("crate secret scan escapes the snapshot");
|
|
578
|
+
if (await verifySnapshot() !== true) throw new Error("snapshot verification failed before secret scan");
|
|
579
|
+
const findings = scanCrateForSecrets(directory);
|
|
580
|
+
if (await verifySnapshot() !== true) throw new Error("snapshot verification failed after secret scan");
|
|
581
|
+
const evidence = { id: requirement.id, coverageKey: requirement.coverageKey, commit, tree, status: findings.length ? "fail" : "pass", findings };
|
|
582
|
+
return { ...evidence, evidenceHash: sha256(JSON.stringify(evidence)) };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/** Build publisher requirements from one verified snapshot and its Cargo/npm discovery results. */
|
|
586
|
+
export function publisherRequirementsForUnits({ selected, snapshot, rustUnits, npmUnits, platform, env }) {
|
|
587
|
+
if (!Array.isArray(selected) || !Array.isArray(rustUnits) || !Array.isArray(npmUnits)) throw new Error("verified unit discovery is required");
|
|
588
|
+
const readJson = (file) => JSON.parse(fs.readFileSync(path.join(snapshot, file), "utf8"));
|
|
589
|
+
const config = readJson("ci/gate.config.json");
|
|
590
|
+
const assetGated = readJson("ci/asset-gated.json");
|
|
591
|
+
const out = [];
|
|
592
|
+
for (const row of selected) {
|
|
593
|
+
const cargo = /^cargo:(rightkit-[a-z0-9-]+)$/.exec(row.selector);
|
|
594
|
+
const npm = /^npm:(@rightkit\/[a-z0-9-]+)$/.exec(row.selector);
|
|
595
|
+
if (!cargo && !npm) throw new Error(`unsupported selector ${row.selector}`);
|
|
596
|
+
const kind = cargo ? "cargo" : "npm"; const unit = (cargo ?? npm)[1];
|
|
597
|
+
const dir = cargo ? `crates/${unit}` : `packages/${unit.slice("@rightkit/".length)}`;
|
|
598
|
+
if (row.dir !== dir) throw new Error(`${row.selector}: selected directory differs from canonical directory`);
|
|
599
|
+
const discovered = (cargo ? rustUnits : npmUnits).find((u) => u.dir === dir);
|
|
600
|
+
if (!discovered) throw new Error(`${row.selector}: selected unit is absent from authenticated workspace discovery`);
|
|
601
|
+
if (cargo && (discovered.crate ?? discovered.name) !== unit) throw new Error(`${row.selector}: discovered Cargo identity differs`);
|
|
602
|
+
const manifest = npm ? readJson(`${dir}/package.json`) : null;
|
|
603
|
+
if (npm && manifest?.name !== unit) throw new Error(`${row.selector}: npm manifest identity differs`);
|
|
604
|
+
if (npm && manifest.private === true && !manifest.scripts?.build && !manifest.scripts?.test) throw new Error(`${row.selector}: private unit has no own build or test script; recursive workspace build cannot prove its coverage`);
|
|
605
|
+
// Class A's full pass (rustfmt over every Rust file of this snapshot) precedes these requirements in the same run: no per-crate fmt (GC-A24).
|
|
606
|
+
const planned = compileRequirements({ kind, unit, dir, config, manifest, platform, workspace: cargo ? discovered.cargoDir : ".", env, assetGated, formatProven: true });
|
|
607
|
+
out.push({ selector: row.selector, dir, ...planned });
|
|
608
|
+
}
|
|
609
|
+
return out;
|
|
610
|
+
}
|
|
611
|
+
|
|
517
612
|
/**
|
|
518
613
|
* The clippy invocations that replace each crate's own `cargo clippy -p <crate> --no-deps --all-targets
|
|
519
614
|
* <features> -- -D warnings`: same flags and lint level, so the same lints on the same code. RightKit is one Cargo
|
|
@@ -526,7 +621,7 @@ export function compileRequirements({ kind, unit, dir, config, manifest, platfor
|
|
|
526
621
|
* a group share the invocation's verdict through the batch receipt, and each crate's tested/check/doc steps still
|
|
527
622
|
* run per crate in its own publish flow.
|
|
528
623
|
*/
|
|
529
|
-
export function batchClippyInvocations(layer, { featuresOf = () => [], featureSetsOf = (unit) => [featuresOf(unit)], assetGatedOf = () => false, crossTargetsOf = () => [], workspaceOf = () => "." } = {}) {
|
|
624
|
+
export function batchClippyInvocations(layer, { featuresOf = () => [], featureSetsOf = (unit) => [featuresOf(unit)], crossSetsOf = featureSetsOf, assetGatedOf = () => false, crossTargetsOf = () => [], workspaceOf = () => "." } = {}) {
|
|
530
625
|
const invocations = [];
|
|
531
626
|
const groups = new Map(); // group key -> invocation being built (its index in `invocations` stays at first sight)
|
|
532
627
|
const namesFeatures = (features) => features.some((f) => f === "--features" || f === "-F" || f.startsWith("--features=") || /^-F.+/.test(f));
|
|
@@ -548,10 +643,12 @@ export function batchClippyInvocations(layer, { featuresOf = () => [], featureSe
|
|
|
548
643
|
// Every tested feature set of a crate is linted, in order; identical sets of one crate collapse to one run.
|
|
549
644
|
const sets = featureSetsOf(unit) ?? [[]];
|
|
550
645
|
const unique = sets.filter((set, index) => sets.findIndex((other) => JSON.stringify(other ?? []) === JSON.stringify(set ?? [])) === index);
|
|
646
|
+
// Only the sets crossSetsOf names are also linted for foreign targets: a host-scoped set is a native-host set (feature-sets.mjs).
|
|
647
|
+
const crossKeys = new Set((crossSetsOf(unit) ?? sets).map((set) => JSON.stringify(set ?? [])));
|
|
551
648
|
for (const set of unique) {
|
|
552
649
|
const features = set ?? [];
|
|
553
650
|
add(unit, features, null);
|
|
554
|
-
for (const target of crossTargetsOf(unit)) add(unit, features, target);
|
|
651
|
+
if (crossKeys.has(JSON.stringify(features))) for (const target of crossTargetsOf(unit)) add(unit, features, target);
|
|
555
652
|
}
|
|
556
653
|
}
|
|
557
654
|
return invocations;
|
|
@@ -734,10 +831,8 @@ async function* publishUnitStages(parsed, deps, batch) {
|
|
|
734
831
|
// Every pnpm step goes through the one door for build and test launches (build-launch.mjs): a rightkit-pnpm broker job on a
|
|
735
832
|
// managed host (refused, never run directly, when the broker is unreachable), direct on a host without one. A run headed to release
|
|
736
833
|
// then also has the signed receipt each stage owes (stage-commands.mjs). Other commands (cargo is already a broker job) are unchanged.
|
|
737
|
-
//
|
|
738
|
-
//
|
|
739
|
-
// runCarriedAdapter), and each derives its per-call nonce from the stage nonce (snapshot-broker.mjs carryBrokerAdapter and carryBrokerCargo,
|
|
740
|
-
// rightkit#1301 B8), so nothing is given the stage nonce itself and no step sets RUSTRIGHT_ATTEST_NONCE.
|
|
834
|
+
// Every pnpm and Cargo step of a snapshot stage is a seam call of its own (build-launch.mjs routes pnpm to the stage adapter runner, stage-seam.mjs
|
|
835
|
+
// runStageAdapter); the client mints each call's nonce, so no step is given one and none sets RUSTRIGHT_ATTEST_NONCE.
|
|
741
836
|
const run = (command, args, options) => {
|
|
742
837
|
const target = command === "pnpm" ? buildLaunch(command, args, { env: options?.env ?? process.env, platform: deps.platform ?? process.platform, exists: fs.existsSync }) : { command, args };
|
|
743
838
|
const result = launch(target.command, target.args, options);
|
|
@@ -1096,9 +1191,10 @@ async function runLocalPublishBatch(parsed, deps) {
|
|
|
1096
1191
|
const scanText = `scanCrateForSecrets ${crates.map((unit) => `crates/${unit}`).join(" ")}`;
|
|
1097
1192
|
checks.push({ name: "secret-scan", command: scanText, ok: true, ...stamp, crates });
|
|
1098
1193
|
commands.push(scanText);
|
|
1099
|
-
const featureSetsOf = (unit) => gateConfig?.rust?.[unit]
|
|
1194
|
+
const featureSetsOf = (unit) => hostFeatureSets(gateConfig?.rust?.[unit], platform, "featureSets", unit) ?? [[]];
|
|
1195
|
+
const crossSetsOf = (unit) => crossFeatureSets(gateConfig?.rust?.[unit], platform, "featureSets", unit) ?? [[]];
|
|
1100
1196
|
for (const layer of layers) {
|
|
1101
|
-
for (const invocation of batchClippyInvocations(layer, { featureSetsOf, assetGatedOf: isAssetGated, crossTargetsOf: (unit) =>
|
|
1197
|
+
for (const invocation of batchClippyInvocations(layer, { featureSetsOf, crossSetsOf, assetGatedOf: isAssetGated, crossTargetsOf: (unit) => scopedCrossTargets(gateConfig?.rust?.[unit], platform), workspaceOf: (unit) => workspaces[unit] })) {
|
|
1102
1198
|
await batchCheck("clippy", "cargo", invocation.args, invocation.crates, { ...testEnv(deps, invocation.assetGated), ...(invocation.env ?? {}) }, invocation.workspace);
|
|
1103
1199
|
}
|
|
1104
1200
|
}
|
package/lock-identity.mjs
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
// Process identity for
|
|
2
|
-
// background-process.mjs only)
|
|
3
|
-
//
|
|
4
|
-
// meaning: a holder is dead only when its pid is gone, or the pid now runs a process that started at another time, or the host rebooted.
|
|
1
|
+
// Process liveness and identity for a lock a coordinator keeps (scripts/ci/rk-pipeline.mjs acquireLock): pid + start time + boot time. A LEAF module (node builtins and
|
|
2
|
+
// background-process.mjs only). A holder is dead only when its pid is gone, or the pid now runs a process that started at another time, or the host rebooted. This is the
|
|
3
|
+
// minimum any such lock needs; the gate's snapshot lock names its holder by the birth identity of gate-seam.mjs `processIdentity` instead, which the broker compares.
|
|
5
4
|
import fs from "node:fs";
|
|
6
5
|
import { spawnSync } from "./background-process.mjs";
|
|
7
6
|
|
|
8
|
-
/** Two start times of one pid are one process when they agree to within this (ps prints whole seconds). Same figure as build-ownership.mjs. */
|
|
9
|
-
export const LOCK_SAME_START_MS = 3000;
|
|
10
|
-
|
|
11
7
|
/** An absolute path for a system tool (a child of the gate may hold no PATH): the first candidate that exists, else the bare name. */
|
|
12
8
|
const systemTool = (name, candidates) => candidates.find((c) => { try { return fs.statSync(c).isFile(); } catch { return false; } }) ?? name;
|
|
13
9
|
const PS = () => systemTool("ps", ["/bin/ps", "/usr/bin/ps"]);
|
|
14
10
|
const SYSCTL = () => systemTool("sysctl", ["/usr/sbin/sysctl", "/sbin/sysctl"]);
|
|
15
|
-
const PERL = () => systemTool("perl", ["/usr/bin/perl"]);
|
|
16
11
|
const run = (spawn, command, args, env = {}) => spawn(command, args, { encoding: "utf8", env: { ...process.env, ...env }, timeout: 30_000, maxBuffer: 1 << 20 });
|
|
17
12
|
|
|
18
|
-
/** This
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
/** This host's boot time in epoch ms (Linux btime, macOS kern.boottime, Windows LastBootUpTime); throws when it cannot be read, so a caller never treats a guess as a boot. */
|
|
14
|
+
export function lockBootTimeMs({ platform = process.platform, readFile = fs.readFileSync, spawn = spawnSync } = {}) {
|
|
15
|
+
if (platform === "linux") {
|
|
16
|
+
const m = /^btime (\d+)$/m.exec(String(readFile("/proc/stat", "utf8")));
|
|
17
|
+
if (!m) throw new Error("no btime in /proc/stat");
|
|
18
|
+
return Number(m[1]) * 1000;
|
|
19
|
+
}
|
|
20
|
+
if (platform === "darwin") {
|
|
21
|
+
const r = run(spawn, SYSCTL(), ["-n", "kern.boottime"]);
|
|
22
|
+
const m = /sec = (\d+)/.exec(String(r.stdout ?? ""));
|
|
23
|
+
if (r.error || r.status !== 0 || !m) throw new Error("cannot read kern.boottime");
|
|
24
|
+
return Number(m[1]) * 1000;
|
|
25
|
+
}
|
|
26
|
+
if (platform === "win32") {
|
|
27
|
+
const script = "'BOOT:' + ([DateTimeOffset](Get-CimInstance Win32_OperatingSystem).LastBootUpTime).ToUnixTimeMilliseconds()";
|
|
28
|
+
const r = run(spawn, "powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")]);
|
|
29
|
+
const m = /BOOT:(\d+)/.exec(String(r.stdout ?? ""));
|
|
30
|
+
if (r.error || r.status !== 0 || !m) throw new Error("cannot read the boot time");
|
|
31
|
+
return Number(m[1]);
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`no boot time on ${platform}`);
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -55,84 +60,3 @@ export function lockProcessIdentity(pid, { platform = process.platform, spawn =
|
|
|
55
60
|
if (!Number.isFinite(startedMs)) throw new Error(`cannot read the start time of pid ${pid} (${text})`);
|
|
56
61
|
return { alive: true, startedMs };
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
/** This process's identity as a lock holder records it. Cached: a process's start never changes. */
|
|
60
|
-
let cachedSelf = null;
|
|
61
|
-
export function selfLockIdentity(options = {}) {
|
|
62
|
-
if (options.fresh !== true && cachedSelf) return cachedSelf;
|
|
63
|
-
const id = lockProcessIdentity(process.pid, options);
|
|
64
|
-
const self = { pid: process.pid, startedMs: id.startedMs, bootId: lockBootId(options) };
|
|
65
|
-
if (options.fresh !== true) cachedSelf = self;
|
|
66
|
-
return self;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ---- the gate's identity as RustRight reads it (BROKER-CONTRACT section 16, GB-76) ----
|
|
70
|
-
// The carrier owner record names the gate by `{ pid, startTimeMs }`, and the broker judges it with `rustright_process::identity_state`: the recorded start time must EQUAL what RustRight reads
|
|
71
|
-
// for that pid (Same), or the pid is `Reused`. The lock identity above tolerates a few seconds; this does not, so it computes RustRight's own figure on each platform:
|
|
72
|
-
// Linux `/proc/<pid>/stat` field 22 (start ticks since boot) and `/proc/stat` btime: `btime * 1000 + ticks * 1000 / CLK_TCK` (integer division)
|
|
73
|
-
// macOS the process's kernel start timeval (kinfo_proc's first field, `sysctl -b kern.proc.pid.<pid>`: int64 seconds, int32 microseconds), `(sec * 1e6 + usec) / 1000` floored
|
|
74
|
-
// Windows GetProcessTimes' creation time as UNIX milliseconds (`Process.StartTime`, floored to a millisecond)
|
|
75
|
-
// `null` when the figure cannot be read: the owner record then carries null and the broker keeps the carrier for ever (unverifiable), never retires it.
|
|
76
|
-
|
|
77
|
-
/** Linux: the start time in epoch ms from a `/proc/<pid>/stat` text, `/proc/stat` text and CLK_TCK, or null. The command name may hold spaces and parentheses: fields count from the LAST `)`. */
|
|
78
|
-
export function linuxStartTimeMs(stat, procStat, hz) {
|
|
79
|
-
const close = String(stat).lastIndexOf(")");
|
|
80
|
-
if (close < 0) return null;
|
|
81
|
-
const ticks = Number(String(stat).slice(close + 1).trim().split(/\s+/)[19]);
|
|
82
|
-
const boot = Number(/^btime\s+(\d+)/m.exec(String(procStat))?.[1]);
|
|
83
|
-
if (!Number.isInteger(ticks) || ticks < 0 || !Number.isInteger(boot) || !Number.isFinite(hz) || hz <= 0) return null;
|
|
84
|
-
return boot * 1000 + Math.floor((ticks * 1000) / hz);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** macOS: the start time in epoch ms from the bytes `sysctl -b kern.proc.pid.<pid>` prints (the start timeval leads kinfo_proc), or null. */
|
|
88
|
-
export function darwinStartTimeMs(bytes) {
|
|
89
|
-
if (!Buffer.isBuffer(bytes) || bytes.length < 12) return null;
|
|
90
|
-
const sec = bytes.readBigInt64LE(0); const usec = bytes.readInt32LE(8);
|
|
91
|
-
if (sec <= 0n || usec < 0 || usec >= 1_000_000) return null;
|
|
92
|
-
return Number((sec * 1_000_000n + BigInt(usec)) / 1000n);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Prints the `kinfo_proc` row of the pid in $ARGV[0] (sysctl [CTL_KERN=1, KERN_PROC=14, KERN_PROC_PID=1, pid] through SYS___sysctl, 202), or exits 1 printing nothing. */
|
|
96
|
-
const DARWIN_KINFO_PERL = [
|
|
97
|
-
'my $mib = pack("i4", 1, 14, 1, $ARGV[0]); my $buf = "\\0" x 1024; my $len = pack("Q", 1024);',
|
|
98
|
-
"syscall(202, $mib, 4, $buf, $len, 0, 0) == 0 or exit 1;",
|
|
99
|
-
'binmode STDOUT; print substr($buf, 0, unpack("Q", $len));',
|
|
100
|
-
].join(" ");
|
|
101
|
-
|
|
102
|
-
/** `pid`'s start time as RustRight's `start_time_ms` reads it, or null when it cannot be read (gone, denied, an unknown platform). `readFile`, `spawn` and `hz` are seams for a simulated host. */
|
|
103
|
-
export function processStartTimeMs(pid, { platform = process.platform, readFile = fs.readFileSync, spawn = spawnSync, hz = null } = {}) {
|
|
104
|
-
try {
|
|
105
|
-
if (!Number.isInteger(pid) || pid <= 0) return null;
|
|
106
|
-
if (platform === "linux") {
|
|
107
|
-
let clock = hz;
|
|
108
|
-
if (clock === null) { const r = run(spawn, "getconf", ["CLK_TCK"]); const n = Number(String(r.stdout ?? "").trim()); clock = !r.error && r.status === 0 && Number.isInteger(n) && n > 0 ? n : 100; }
|
|
109
|
-
return linuxStartTimeMs(readFile(`/proc/${pid}/stat`, "utf8"), readFile("/proc/stat", "utf8"), clock);
|
|
110
|
-
}
|
|
111
|
-
if (platform === "darwin") {
|
|
112
|
-
const options = { env: { ...process.env, LC_ALL: "C" }, timeout: 30_000, maxBuffer: 1 << 20 };
|
|
113
|
-
const read = (r) => (r.error || r.status !== 0 ? null : darwinStartTimeMs(Buffer.isBuffer(r.stdout) ? r.stdout : Buffer.from(String(r.stdout ?? ""), "latin1")));
|
|
114
|
-
const named = read(spawn(SYSCTL(), ["-b", `kern.proc.pid.${pid}`], options));
|
|
115
|
-
if (named !== null) return named;
|
|
116
|
-
// macOS 27's sysctl(8) no longer resolves `kern.proc.pid.<pid>` by name ("unknown oid"), so the row is read through the numeric MIB
|
|
117
|
-
// [CTL_KERN, KERN_PROC, KERN_PROC_PID, pid] (the one RustRight reads, rustright-process macos.rs) by the system perl: the same bytes, the same figure.
|
|
118
|
-
return read(spawn(PERL(), ["-e", DARWIN_KINFO_PERL, String(pid)], options));
|
|
119
|
-
}
|
|
120
|
-
if (platform === "win32") {
|
|
121
|
-
const script = `$p = Get-Process -Id ${Number(pid)} -ErrorAction SilentlyContinue; if ($p) { 'START:' + ([DateTimeOffset]$p.StartTime).ToUnixTimeMilliseconds() } else { 'GONE' }`;
|
|
122
|
-
const r = run(spawn, "powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")]);
|
|
123
|
-
if (r.error || r.status !== 0) return null;
|
|
124
|
-
const m = /START:(\d+)/.exec(String(r.stdout ?? ""));
|
|
125
|
-
return m ? Number(m[1]) : null;
|
|
126
|
-
}
|
|
127
|
-
} catch { /* unreadable: null */ }
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** This process's own start time as RustRight reads it. Cached: a process's start never changes. A null (unreadable) is retried on the next call. */
|
|
132
|
-
let cachedSelfStart = null;
|
|
133
|
-
export function selfStartTimeMs(options = {}) {
|
|
134
|
-
if (options.fresh !== true && cachedSelfStart !== null) return cachedSelfStart;
|
|
135
|
-
const ms = processStartTimeMs(process.pid, options);
|
|
136
|
-
if (options.fresh !== true && ms !== null) cachedSelfStart = ms;
|
|
137
|
-
return ms;
|
|
138
|
-
}
|
package/managed-cargo.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { homedir, userInfo } from "node:os";
|
|
|
4
4
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { spawn as spawnProcess, spawnSync } from "./background-process.mjs";
|
|
7
|
-
import { CARRIER_MISSING_CODE, carriedCargoMapOf,
|
|
7
|
+
import { CARRIER_MISSING_CODE, carriedCargoMapOf, runStageCargo } from "./stage-seam.mjs";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Linux, and any host that is neither Mac nor Windows, never uses the RustRight broker: WSL2, a VM, a cloud or CI runner, Linux hosted on
|
|
@@ -254,7 +254,7 @@ export function managedHost(env, platform = process.platform) {
|
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* The carried seam (rightkit#1301): on a broker host, a call made by a child of a snapshot door stage, which the gate started with the
|
|
257
|
-
* stage's carrier map in its environment, goes through that carrier (
|
|
257
|
+
* stage's carrier map in its environment, goes through that carrier (stage-seam.mjs: one seam call per call, filed in the stage's ledger, from the
|
|
258
258
|
* manifest's directory, output directory from the receipt). A map that cannot be read refuses the call; it is never run uncarried.
|
|
259
259
|
* A direct Linux host never has a carrier; a Linux host that declared a broker route has the same one. A call made with no carrier in its environment keeps the managed client route as before; refusing a
|
|
260
260
|
* carrier-less compile that comes from a snapshot stage is RustRight's side (rightkit#1301 step 3).
|
|
@@ -264,7 +264,7 @@ function carriedSeam(args, options, { platform, spawn }) {
|
|
|
264
264
|
const carried = carriedCargoMapOf(options.env ?? process.env);
|
|
265
265
|
if (!carried) return null;
|
|
266
266
|
if (carried.error) return { status: 101, signal: null, stdout: "", stderr: `rightkit-gate: ${CARRIER_MISSING_CODE}: ${carried.error}\n`, error: Object.assign(new Error(`${CARRIER_MISSING_CODE}: ${carried.error}`), { code: CARRIER_MISSING_CODE }) };
|
|
267
|
-
return
|
|
267
|
+
return runStageCargo(args, options, { map: carried.map, spawn });
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/**
|
package/managed-root-guard.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The managed-root guard (item 5, signed item5-sage-decisions-2.md D4 rule 1): the gate never creates the host's managed root, and on
|
|
2
|
-
// the Mac never accepts one on the boot volume. It lives
|
|
3
|
-
//
|
|
2
|
+
// the Mac never accepts one on the boot volume. It lives in its own leaf module so a caller that only needs the guard imports no snapshot code;
|
|
3
|
+
// snapshot.mjs re-exports both names.
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
|
|
6
6
|
export class SnapshotError extends Error {
|
package/managed-roots.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export const envNamed = (env, name) => {
|
|
|
20
20
|
* path, `runtimeRoot` (`RUSTRIGHT_RUNTIME_ROOT`, else RustRight's per-platform default) and `liveRuntime` = `<runtimeRoot>/runtime`, which supersedes it.
|
|
21
21
|
*
|
|
22
22
|
* `legacyRoot` is the pre-rename Mac/Windows location the shared fixtures pin on every platform; it is never a default for a host that is neither: a Linux (or
|
|
23
|
-
* other) host that names no data root gets `<home>/.local/state/rightkit` (the account's own state directory, where its runs
|
|
23
|
+
* other) host that names no data root gets `<home>/.local/state/rightkit` (the account's own state directory, where its runs and snapshots
|
|
24
24
|
* already live), never `/Volumes/D/.rightkit-managed`, a Mac volume that a Linux gate would otherwise create as root. Everything else is RustRight's order:
|
|
25
25
|
* the data root is named by the same env, `controlRoot` = `dataRoot` off Mac, so a host that names its roots (every declared Linux broker, whose installer sets
|
|
26
26
|
* RUSTRIGHT_DATA_ROOT / RUSTRIGHT_CONTROL_ROOT) resolves exactly as `rustright-config::managed_roots` does. RustRight resolves a host with NO environment the same
|
|
@@ -87,7 +87,7 @@ export function detectLayout(options = {}) {
|
|
|
87
87
|
* diagnostics): RIGHTKIT_SCRATCH_ROOT, else `<data root>/runs`. A managed Mac or Windows host has a data root, and so does any host
|
|
88
88
|
* that names one in the environment. A direct (Linux and other) host with none used to fall to the Mac data volume,
|
|
89
89
|
* `/Volumes/D/.rightkit-managed/runs`, and create it; its data root now defaults to the account's own state directory
|
|
90
|
-
* (resolveManagedRoots: `~/.local/state/rightkit`), beside the snapshots
|
|
90
|
+
* (resolveManagedRoots: `~/.local/state/rightkit`), beside the snapshots, so its runs are `~/.local/state/rightkit/runs`.
|
|
91
91
|
*/
|
|
92
92
|
export function gateRunsRoot({ env = process.env, platform = process.platform, home = homedir() } = {}) {
|
|
93
93
|
if (env.RIGHTKIT_SCRATCH_ROOT) return env.RIGHTKIT_SCRATCH_ROOT;
|
|
@@ -176,7 +176,7 @@ function declaredLinuxBrokerClient(env, exists, { realpath = (file) => realpathS
|
|
|
176
176
|
/**
|
|
177
177
|
* The installed RustRight client, selected in ONE order everywhere (doctor, carry, status, lease and dispatch all call this): the live runtime at its final RustRight path
|
|
178
178
|
* (`<runtimeRoot>/runtime`), the control root's `runtime` (the shared fixtures' `runtimeCurrent`), and only then the legacy `runtime-current` link of a host not yet cut over. The
|
|
179
|
-
* Windows client is the native `rustright.exe`, never a `.cmd` shim; the caller probes the exact client returned before it marks any work
|
|
179
|
+
* Windows client is the native `rustright.exe`, never a `.cmd` shim; the caller probes the exact client returned before it marks any work.
|
|
180
180
|
*/
|
|
181
181
|
export function managedRuntimeClient(env = process.env, platform = process.platform, exists = existsSync, ops = {}) {
|
|
182
182
|
if (platform !== 'darwin' && platform !== 'win32') return declaredLinuxBrokerClient(env, exists, ops); // a direct (Linux) host has a broker client only by declaring one
|