@rightkit/release 0.6.8 → 0.6.10

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.
Files changed (52) hide show
  1. package/README.md +25 -9
  2. package/admission-files.mjs +1 -1
  3. package/app-check.mjs +94 -20
  4. package/assemble-app-command.mjs +151 -0
  5. package/assembled-app.mjs +445 -0
  6. package/bin/darwin/rightkit-swap +0 -0
  7. package/bin/darwin/rightkit-swap.sign.json +6 -0
  8. package/bin/rightkit-gate.mjs +928 -82
  9. package/build-launch.mjs +88 -0
  10. package/build-ownership.mjs +1231 -0
  11. package/build-release.mjs +2 -1
  12. package/cargo-contract.mjs +3 -1
  13. package/cargo-target-shim.mjs +166 -0
  14. package/class-a-launch-guard.mjs +126 -0
  15. package/cli/right-release.mjs +3 -1
  16. package/codesign-shim.mjs +11 -1
  17. package/deterministic-scans.mjs +807 -56
  18. package/development-signing.mjs +4 -1
  19. package/development.mjs +110 -20
  20. package/door-policy.mjs +61 -6
  21. package/gate-executor.mjs +14 -2
  22. package/gate-stages.mjs +15 -5
  23. package/heavy-command.mjs +3 -2
  24. package/install-app.mjs +11 -2
  25. package/install-assembled-app.mjs +423 -0
  26. package/ios-dev.mjs +70 -3
  27. package/linux-artifacts.mjs +93 -0
  28. package/local-publish.mjs +161 -26
  29. package/managed-cargo.mjs +47 -5
  30. package/managed-root-guard.mjs +34 -0
  31. package/native-helpers.mjs +355 -0
  32. package/package-recipe-targets.mjs +52 -7
  33. package/package.json +4 -3
  34. package/pipeline-receipts.mjs +302 -302
  35. package/project-type.mjs +2 -2
  36. package/provenance-verify.mjs +115 -0
  37. package/publish-cargo.mjs +8 -6
  38. package/qa-admission-policy.json +10 -1
  39. package/recipe-build.mjs +73 -5
  40. package/release-config.mjs +1 -1
  41. package/release.mjs +15 -5
  42. package/rightkit-versions.json +13 -7
  43. package/snapshot-check.mjs +306 -0
  44. package/snapshot-git.mjs +166 -0
  45. package/snapshot-request.mjs +161 -0
  46. package/snapshot-root-config.mjs +76 -0
  47. package/snapshot.mjs +856 -0
  48. package/stage-commands.mjs +60 -0
  49. package/stage-sidecar.mjs +57 -7
  50. package/test-command.mjs +17 -4
  51. package/unit-gate.mjs +259 -0
  52. package/web-build.mjs +38 -6
@@ -0,0 +1,88 @@
1
+ // The one door for the build and test commands RightKit launches for an app or a unit (rightkit#1241): on a broker-managed host
2
+ // every such command is a broker job, so class A admission, the one-build-per-app claim, the in-place freeze and the host's
3
+ // resource limits apply to it as they do to a cargo build; on a host without a broker it runs directly, as before.
4
+ //
5
+ // - pnpm <args> -> <rustright> run rightkit-pnpm -- <args> (the broker's pnpm adapter; compile-flagged on the broker)
6
+ // - node <script> <args> -> <rustright> run rightkit-node -- <script> <args> (a script inside the job's workspace, relative path)
7
+ // - cargo <args> -> <rustright> cargo <args> (by the resolved broker client, whatever path the caller named: a real
8
+ // cargo binary is never launched around the broker)
9
+ // - rustright <args> -> <rustright> <args> (the resolved broker client)
10
+ // - rightkit-qa <args> -> <rustright> run rightkit-qa -- <args> (the whole QA run, its test binaries included, is one broker
11
+ // job holding the app's claim; its own `rustright cargo test --no-run` runs nested under that job)
12
+ // - this package's right-release -> unchanged (same NODE_OPTIONS as this process): it orchestrates, and every build it starts comes back
13
+ // through this door
14
+ // - anything else -> refused on a managed host: no broker adapter runs it yet, and running it directly would bypass the
15
+ // broker (fail closed; the per-app impact is mapped in rightkit#1241)
16
+ // A launch from inside a broker job is routed the same way: the broker attributes it to its parent job by the parent's own
17
+ // capability token (never by an environment marker this module reads), so no launch here decides to skip the broker.
18
+ import { readFileSync } from "node:fs";
19
+ import path from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+ import { resolveExecutor } from "./gate-executor.mjs";
22
+ import { resolveExecutable } from "./admission-host.mjs";
23
+
24
+ export const BUILD_LAUNCH_REFUSED = "RK_BUILD_LAUNCH_REFUSED";
25
+ const OWN_RIGHT_RELEASE = fileURLToPath(new URL("./cli/right-release.mjs", import.meta.url));
26
+ // Node flags that change no code path; everything else before the script (-e, --eval, -p, --import, -r, --require, --loader, …) refuses.
27
+ const NODE_FLAGS = /^--(?:disable-warning=[A-Za-z0-9_-]+|no-experimental-webstorage|no-warnings|enable-source-maps|max-old-space-size=\d+|stack-size=\d+)$/;
28
+ const name = (program) => path.basename(String(program ?? "").replaceAll("\\", "/")).replace(/\.(exe|cmd|bat)$/i, "").toLowerCase();
29
+
30
+ function refuse(message) {
31
+ const error = new Error(message);
32
+ error.code = BUILD_LAUNCH_REFUSED;
33
+ throw error;
34
+ }
35
+
36
+ /**
37
+ * `{ command, args }` to launch for a build or test command, or a refusal. `host` carries env, platform, exists, which and readFile
38
+ * (resolveExecutor's inputs); `which` defaults to a PATH lookup over `env`.
39
+ */
40
+ export function buildLaunch(command, args = [], host = {}) {
41
+ const env = host.env ?? process.env;
42
+ const platform = host.platform ?? process.platform;
43
+ const exists = host.exists;
44
+ const lookup = (cmd) => { const found = resolveExecutable(cmd, { env, hostPlatform: platform, exists: exists ?? (() => false) }); return found ? [found] : []; };
45
+ const executor = resolveExecutor({ env, platform, exists, which: host.which ?? lookup, readFile: host.readFile ?? ((file) => readFileSync(file, "utf8")) });
46
+ if (executor.kind === "refuse") refuse(`${name(command)} ${args.join(" ")}: ${executor.problem}`);
47
+ // A direct (Linux) host: the real toolchain, RustRight shim directories off PATH (`env`, to merge into the launch env); a configured
48
+ // `rustright cargo|rustc|rustdoc …` runs that tool directly; any other `rustright` command has no direct form and is refused.
49
+ if (executor.kind === "direct") {
50
+ const extra = executor.env ? { env: executor.env } : {};
51
+ if (name(command) === "rustright") {
52
+ if (!["cargo", "rustc", "rustdoc"].includes(String(args[0]))) refuse(`rustright ${args.join(" ")}: no broker on this ${platform} host, and only rustright cargo|rustc|rustdoc map to the toolchain`);
53
+ return { command: String(args[0]), args: args.slice(1).map(String), ...extra };
54
+ }
55
+ return { command, args, ...extra };
56
+ }
57
+ const program = name(command);
58
+ const client = () => lookup("rustright")[0] ?? refuse(`rustright is not on PATH: on a broker-managed host ${program} runs only as a broker job`);
59
+ if (program === "cargo") return { command: client(), args: ["cargo", ...args.map(String)] };
60
+ if (program === "rustright") return { command: client(), args: args.map(String) };
61
+ if (program === "rightkit-qa") return { command: client(), args: ["run", "rightkit-qa", "--", ...args.map(String)] };
62
+ if (program === "swift") return { command: client(), args: ["run", "rightkit-swift", "--", ...args.map(String)] };
63
+ // This package's own right-release, run by this very Node binary (not any executable named node), with no startup code added by
64
+ // the caller: NODE_OPTIONS is empty or exactly this process's own string (a hook's env could otherwise --import code that builds
65
+ // outside the broker; reordered tokens can re-pair an option with another value, so nothing short of equality is accepted).
66
+ if (command === process.execPath && path.resolve(String(args[0] ?? "")) === OWN_RIGHT_RELEASE) {
67
+ const options = String(env.NODE_OPTIONS ?? "");
68
+ if (options.trim() !== "" && options !== String(process.env.NODE_OPTIONS ?? "")) refuse(`right-release ${args.slice(1).join(" ")}: NODE_OPTIONS is neither empty nor exactly this process's own; on a broker-managed host the door's own right-release runs with no added startup code (rightkit#1241)`);
69
+ return { command, args };
70
+ }
71
+ if (program === "node") {
72
+ // Leading node flags are limited to ones that change no code path (warnings, web storage, heap/stack size); an eval, import,
73
+ // require or loader flag would run code that is not the script, so it is refused. The adapter takes the script as a path
74
+ // relative to the job's workspace (its cwd); an absolute or escaping path is refused here and by the broker's relpath check.
75
+ const at = args.findIndex((a) => !String(a).startsWith("-"));
76
+ const flags = (at < 0 ? args : args.slice(0, at)).map(String);
77
+ const bad = flags.find((f) => !NODE_FLAGS.test(f));
78
+ if (at < 0 || bad !== undefined) refuse(`node ${args.join(" ")}: ${bad !== undefined ? `node flag ${bad} is not allowed` : "no script"}; on a broker-managed host node runs only a workspace script as a broker job (rightkit-node, rightkit#1241)`);
79
+ const cwd = host.cwd ?? process.cwd();
80
+ const script = path.isAbsolute(String(args[at])) ? path.relative(cwd, String(args[at])) : String(args[at]);
81
+ if (!script || script.startsWith("..") || path.isAbsolute(script)) refuse(`node ${args[0]}: the script is outside the job's workspace (${cwd}); on a broker-managed host node runs only workspace scripts as broker jobs (rightkit-node, rightkit#1241)`);
82
+ return { command: client(), args: ["run", "rightkit-node", "--", ...flags, script.replaceAll("\\", "/"), ...args.slice(at + 1).map(String)] };
83
+ }
84
+ if (program === "pnpm") {
85
+ return { command: client(), args: ["run", "rightkit-pnpm", "--", ...args.map(String)] };
86
+ }
87
+ return refuse(`${program} ${args.join(" ")}: no broker adapter runs this command yet, and on a broker-managed host a build or test command never runs around the broker (rightkit#1241)`);
88
+ }