@rightkit/ci 0.3.0 → 0.3.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/manifest.test.mjs DELETED
@@ -1,535 +0,0 @@
1
- import test from "node:test";
2
- import assert from "node:assert/strict";
3
- import { validateManifest } from "./manifest.mjs";
4
-
5
- const VALID_MINIMAL = {
6
- schemaVersion: 1,
7
- compile: "github-actions-only",
8
- lanes: ["ci"],
9
- matrix: { os: ["ubuntu-latest"], node: ["22.13"] },
10
- packageManager: "pnpm@11.24.0",
11
- templateVersion: "1.0.0",
12
- };
13
-
14
- test("requires GitHub Actions only compilation", () => {
15
- assert.equal(validateManifest({ ...VALID_MINIMAL, compile: undefined }).valid, false);
16
- assert.equal(validateManifest({ ...VALID_MINIMAL, compile: "local" }).valid, false);
17
- });
18
-
19
- test("accepts a minimal valid manifest", () => {
20
- const { valid, errors } = validateManifest(VALID_MINIMAL);
21
- assert.equal(valid, true);
22
- assert.deepEqual(errors, []);
23
- });
24
-
25
- test("ownership scan registration is explicit and supports nested package roots", () => {
26
- assert.equal(validateManifest({ ...VALID_MINIMAL, ownership: { roots: ["engine", "apps/client"] } }).valid, true);
27
- for (const roots of [[], ["../outside"], ["src\\escape"], [""], ["engine", "engine"]]) {
28
- assert.equal(validateManifest({ ...VALID_MINIMAL, ownership: { roots } }).valid, false, JSON.stringify(roots));
29
- }
30
- });
31
-
32
- test("rust-hybrid supports ci plus a configured unsigned release-candidate lane", () => {
33
- const valid = { ...VALID_MINIMAL, profile: "rust-hybrid", gate: { path: "scripts/gate.sh" } };
34
- assert.equal(validateManifest(valid).valid, true);
35
- for (const path of ["/tmp/gate.sh", "../gate.sh", "scripts/gate sh", "${{ secrets.X }}", "scripts/gate;sh"]) {
36
- assert.equal(validateManifest({ ...valid, gate: { path } }).valid, false, path);
37
- }
38
- assert.equal(validateManifest({ ...valid, lanes: ["ci", "qualification"] }).valid, false);
39
- const candidate = {
40
- ...valid,
41
- lanes: ["ci", "release-candidate"],
42
- candidate: {
43
- buildScript: "ci:candidate",
44
- checkScript: "ci:candidate-check",
45
- admissionScript: "release:admit",
46
- stageSummaryScript: "release:stage-summary",
47
- artifactRoot: "legion-unsigned",
48
- os: ["ubuntu-latest"],
49
- },
50
- };
51
- assert.equal(validateManifest(candidate).valid, true);
52
- assert.equal(validateManifest({ ...candidate, candidate: { ...candidate.candidate, signWindows: true } }).valid, false);
53
- assert.equal(validateManifest({ ...candidate, candidate: { ...candidate.candidate, signMacos: true } }).valid, false);
54
- const windowsCandidate = { ...candidate, matrix: { ...candidate.matrix, os: ["ubuntu-latest", "windows-2025"] }, candidate: { ...candidate.candidate, os: ["windows-2025"], signWindows: true } };
55
- assert.equal(validateManifest(windowsCandidate).valid, true);
56
- assert.equal(validateManifest({ ...windowsCandidate, candidate: { ...windowsCandidate.candidate, signWindows: "yes" } }).valid, false);
57
- const macCandidate = { ...candidate, matrix: { ...candidate.matrix, os: ["ubuntu-latest", "macos-15"] }, candidate: { ...candidate.candidate, os: ["macos-15"], signMacos: true } };
58
- assert.equal(validateManifest(macCandidate).valid, true);
59
- assert.equal(validateManifest({ ...macCandidate, candidate: { ...macCandidate.candidate, signMacos: "yes" } }).valid, false);
60
- assert.equal(validateManifest({ ...macCandidate, matrix: { ...macCandidate.matrix, node: ["22", "24"] } }).valid, false);
61
- assert.equal(validateManifest({ ...candidate, candidate: { ...candidate.candidate, buildScript: "echo unsafe" } }).valid, false);
62
- assert.equal(validateManifest({ ...candidate, candidate: { ...candidate.candidate, artifactRoot: "../escape" } }).valid, false);
63
- assert.equal(validateManifest({ ...candidate, candidate: { ...candidate.candidate, os: ["windows-latest"] } }).valid, false);
64
-
65
- const releaseChain = {
66
- ...windowsCandidate,
67
- candidate: {
68
- ...windowsCandidate.candidate,
69
- releaseChain: {
70
- evidenceVerificationScript: "release:verify-evidence",
71
- windowsFinalizeScript: "release:finalize:win",
72
- installedQualificationScript: "release:qualify:installed",
73
- publishScript: "release:publish:qualified",
74
- qualificationRunnerVariable: "QUALIFICATION_RUNNER_LABEL",
75
- publishSecrets: ["CLOUDFLARE_API_TOKEN"],
76
- },
77
- },
78
- };
79
- assert.equal(validateManifest(releaseChain).valid, true);
80
- assert.equal(validateManifest({ ...releaseChain, candidate: { ...releaseChain.candidate, signWindows: false } }).valid, false);
81
- assert.equal(validateManifest({ ...releaseChain, candidate: { ...releaseChain.candidate, releaseChain: { ...releaseChain.candidate.releaseChain, publishScript: "echo unsafe" } } }).valid, false);
82
- assert.equal(validateManifest({ ...releaseChain, candidate: { ...releaseChain.candidate, releaseChain: { ...releaseChain.candidate.releaseChain, qualificationRunnerVariable: "${{ secrets.X }}" } } }).valid, false);
83
- assert.equal(validateManifest({ ...releaseChain, candidate: { ...releaseChain.candidate, releaseChain: { ...releaseChain.candidate.releaseChain, publishSecrets: ["TOKEN", "TOKEN"] } } }).valid, false);
84
- });
85
-
86
- // Part B fix: admissionScript & stageSummaryScript were moved OUT of the
87
- // optional candidate.releaseChain object and onto candidate directly,
88
- // because the admission job and the candidate job's stage-summary
89
- // init/finalize steps are unconditional parts of the rendered
90
- // release-candidate template — present for every release-candidate lane,
91
- // signed or not. This test proves each is independently required with a
92
- // specific, actionable error, and that the full releaseChain contract
93
- // (now minus those two promoted fields) is validated key-by-key.
94
- test("rust-hybrid release-candidate requires admissionScript & stageSummaryScript independent of signing", () => {
95
- const base = {
96
- ...VALID_MINIMAL,
97
- profile: "rust-hybrid",
98
- gate: { path: "scripts/gate.sh" },
99
- lanes: ["ci", "release-candidate"],
100
- candidate: {
101
- buildScript: "ci:candidate",
102
- checkScript: "ci:candidate-check",
103
- admissionScript: "release:admit",
104
- stageSummaryScript: "release:stage-summary",
105
- artifactRoot: "widgets-unsigned",
106
- os: ["ubuntu-latest"],
107
- },
108
- };
109
- assert.equal(validateManifest(base).valid, true, JSON.stringify(validateManifest(base).errors));
110
-
111
- const { admissionScript, ...withoutAdmission } = base.candidate;
112
- const missingAdmission = validateManifest({ ...base, candidate: withoutAdmission });
113
- assert.equal(missingAdmission.valid, false);
114
- assert.ok(missingAdmission.errors.includes("candidate.admissionScript must be one safe package script name"));
115
-
116
- const { stageSummaryScript, ...withoutStageSummary } = base.candidate;
117
- const missingStageSummary = validateManifest({ ...base, candidate: withoutStageSummary });
118
- assert.equal(missingStageSummary.valid, false);
119
- assert.ok(missingStageSummary.errors.includes("candidate.stageSummaryScript must be one safe package script name"));
120
-
121
- // Neither field is accepted inside releaseChain any more.
122
- const windows = {
123
- ...base,
124
- matrix: { ...base.matrix, os: ["ubuntu-latest", "windows-2025"] },
125
- candidate: { ...base.candidate, os: ["windows-2025"], signWindows: true },
126
- };
127
- const misplaced = validateManifest({
128
- ...windows,
129
- candidate: {
130
- ...windows.candidate,
131
- releaseChain: {
132
- admissionScript: "release:admit",
133
- evidenceVerificationScript: "release:verify-evidence",
134
- windowsFinalizeScript: "release:finalize:win",
135
- installedQualificationScript: "release:qualify:installed",
136
- publishScript: "release:publish:qualified",
137
- qualificationRunnerVariable: "QUALIFICATION_RUNNER_LABEL",
138
- },
139
- },
140
- });
141
- assert.equal(misplaced.valid, false);
142
- assert.ok(misplaced.errors.includes("unknown candidate.releaseChain field: admissionScript"));
143
- });
144
-
145
- // Part B fix: evidenceVerificationScript is the one new script that DOES
146
- // stay inside releaseChain (it runs in the `publish` job, verifying
147
- // aggregated same-run evidence before the publish step) — required
148
- // whenever releaseChain is configured, with its own specific error.
149
- test("candidate.releaseChain requires evidenceVerificationScript with a specific error", () => {
150
- const windows = {
151
- ...VALID_MINIMAL,
152
- profile: "rust-hybrid",
153
- gate: { path: "scripts/gate.sh" },
154
- lanes: ["ci", "release-candidate"],
155
- matrix: { ...VALID_MINIMAL.matrix, os: ["ubuntu-latest", "windows-2025"] },
156
- candidate: {
157
- buildScript: "ci:candidate",
158
- checkScript: "ci:candidate-check",
159
- admissionScript: "release:admit",
160
- stageSummaryScript: "release:stage-summary",
161
- artifactRoot: "widgets-unsigned",
162
- os: ["windows-2025"],
163
- signWindows: true,
164
- releaseChain: {
165
- windowsFinalizeScript: "release:finalize:win",
166
- installedQualificationScript: "release:qualify:installed",
167
- publishScript: "release:publish:qualified",
168
- qualificationRunnerVariable: "QUALIFICATION_RUNNER_LABEL",
169
- },
170
- },
171
- };
172
- const result = validateManifest(windows);
173
- assert.equal(result.valid, false);
174
- assert.ok(result.errors.includes("candidate.releaseChain.evidenceVerificationScript must be one safe package script name"));
175
-
176
- const fixed = {
177
- ...windows,
178
- candidate: { ...windows.candidate, releaseChain: { ...windows.candidate.releaseChain, evidenceVerificationScript: "release:verify-evidence" } },
179
- };
180
- assert.equal(validateManifest(fixed).valid, true, JSON.stringify(validateManifest(fixed).errors));
181
- });
182
-
183
- test("candidate targets permit native multi-architecture matrices independent of normal CI runners", () => {
184
- const multiArchitecture = {
185
- ...VALID_MINIMAL,
186
- profile: "rust-hybrid",
187
- gate: { path: "scripts/gate.sh" },
188
- lanes: ["ci", "release-candidate"],
189
- candidate: {
190
- buildScript: "ci:candidate",
191
- checkScript: "ci:candidate-check",
192
- admissionScript: "release:admit",
193
- stageSummaryScript: "release:stage-summary",
194
- artifactRoot: "widgets-unsigned",
195
- os: ["windows-2025", "windows-11-arm", "macos-15", "macos-15-intel"],
196
- targets: [
197
- { os: "windows-2025", platform: "windows", architecture: "x86_64" },
198
- { os: "windows-11-arm", platform: "windows", architecture: "arm64" },
199
- { os: "macos-15", platform: "macos", architecture: "arm64" },
200
- { os: "macos-15-intel", platform: "macos", architecture: "x86_64" },
201
- ],
202
- signWindows: true,
203
- signMacos: true,
204
- },
205
- };
206
- assert.equal(validateManifest(multiArchitecture).valid, true, JSON.stringify(validateManifest(multiArchitecture).errors));
207
- assert.equal(validateManifest({ ...multiArchitecture, candidate: { ...multiArchitecture.candidate, targets: [{ os: "windows-2025", platform: "windows", architecture: "riscv64" }] } }).valid, false);
208
- assert.equal(validateManifest({ ...multiArchitecture, candidate: { ...multiArchitecture.candidate, targets: [{ os: "windows-11-arm", platform: "windows", architecture: "x86_64" }] } }).valid, false);
209
- assert.equal(validateManifest({ ...multiArchitecture, candidate: { ...multiArchitecture.candidate, targets: [{ os: "ubuntu-24.04", platform: "windows", architecture: "x86_64" }] } }).valid, false);
210
- const xcodeRunner = { ...multiArchitecture, candidate: { ...multiArchitecture.candidate, os: ["xcode-27"], targets: [{ os: "xcode-27", platform: "macos", architecture: "arm64" }], signWindows: false } };
211
- assert.equal(validateManifest(xcodeRunner).valid, true, JSON.stringify(validateManifest(xcodeRunner).errors));
212
- assert.equal(validateManifest({ ...multiArchitecture, candidate: { ...multiArchitecture.candidate, os: ["ubuntu-24.04"], targets: [{ os: "ubuntu-24.04", platform: "macos", architecture: "arm64" }] } }).valid, false);
213
- assert.equal(validateManifest({ ...multiArchitecture, candidate: { ...multiArchitecture.candidate, targets: [{ os: "${{ secrets.X }}", platform: "windows", architecture: "x86_64" }] } }).valid, false);
214
- assert.equal(validateManifest({ ...multiArchitecture, candidate: { ...multiArchitecture.candidate, releaseChain: { windowsFinalizeScript: "release:finalize:win", macosFinalizeScript: "release:finalize:mac", installedQualificationScript: "release:qualify", publishScript: "release:publish", qualificationRunnerVariable: "QUALIFICATION_RUNNER_LABEL" } } }).valid, false);
215
- });
216
-
217
- test("rejects non-object input", () => {
218
- for (const bad of [null, undefined, "not an object", 42, ["array"]]) {
219
- const { valid, errors } = validateManifest(bad);
220
- assert.equal(valid, false);
221
- assert.ok(errors.length > 0);
222
- }
223
- });
224
-
225
- test("rejects an unknown top-level field", () => {
226
- const { valid, errors } = validateManifest({ ...VALID_MINIMAL, extra: true });
227
- assert.equal(valid, false);
228
- assert.ok(errors.some((e) => e.includes("unknown top-level field: extra")));
229
- });
230
-
231
- test("rejects schemaVersion other than 1", () => {
232
- const { valid, errors } = validateManifest({ ...VALID_MINIMAL, schemaVersion: 2 });
233
- assert.equal(valid, false);
234
- assert.ok(errors.some((e) => e.includes("schemaVersion")));
235
- });
236
-
237
- test("rejects an empty or unknown lane list", () => {
238
- assert.equal(validateManifest({ ...VALID_MINIMAL, lanes: [] }).valid, false);
239
- assert.equal(validateManifest({ ...VALID_MINIMAL, lanes: ["not-a-real-lane"] }).valid, false);
240
- assert.equal(validateManifest({ ...VALID_MINIMAL, lanes: ["ci", "ci"] }).valid, false);
241
- });
242
-
243
- test("rejects a malformed matrix", () => {
244
- assert.equal(validateManifest({ ...VALID_MINIMAL, matrix: { os: [] , node: ["22.13"] } }).valid, false);
245
- assert.equal(validateManifest({ ...VALID_MINIMAL, matrix: { os: ["ubuntu-latest"] } }).valid, false);
246
- assert.equal(validateManifest({ ...VALID_MINIMAL, matrix: "ubuntu-latest" }).valid, false);
247
- });
248
-
249
- test("rejects a malformed packageManager or templateVersion", () => {
250
- assert.equal(validateManifest({ ...VALID_MINIMAL, packageManager: "pnpm" }).valid, false);
251
- assert.equal(validateManifest({ ...VALID_MINIMAL, packageManager: "bun@1.0.0" }).valid, false);
252
- assert.equal(validateManifest({ ...VALID_MINIMAL, templateVersion: "v1" }).valid, false);
253
- });
254
-
255
- test("publish-npm lane requires publish.npm with oidc true", () => {
256
- assert.equal(validateManifest({ ...VALID_MINIMAL, lanes: ["publish-npm"] }).valid, false);
257
- assert.equal(
258
- validateManifest({ ...VALID_MINIMAL, lanes: ["publish-npm"], publish: { npm: { oidc: false, provenance: true } } }).valid,
259
- false,
260
- );
261
- assert.equal(
262
- validateManifest({ ...VALID_MINIMAL, lanes: ["publish-npm"], publish: { npm: { oidc: true, provenance: true } } }).valid,
263
- true,
264
- );
265
- });
266
-
267
- test("publish-package-managers lane requires both homebrew and winget config", () => {
268
- const base = { ...VALID_MINIMAL, lanes: ["publish-package-managers"] };
269
- assert.equal(validateManifest(base).valid, false);
270
- assert.equal(
271
- validateManifest({ ...base, publish: { homebrew: { tap: "acme/tap", formulaName: "widgets" } } }).valid,
272
- false,
273
- );
274
- assert.equal(
275
- validateManifest({
276
- ...base,
277
- publish: {
278
- homebrew: { tap: "acme/tap", formulaName: "widgets" },
279
- winget: { packageIdentifier: "Acme.Widgets" },
280
- },
281
- }).valid,
282
- true,
283
- );
284
- });
285
-
286
- test("rejects a malformed homebrew tap (must be owner/repo)", () => {
287
- const result = validateManifest({
288
- ...VALID_MINIMAL,
289
- lanes: ["publish-package-managers"],
290
- publish: {
291
- homebrew: { tap: "not-owner-slash-repo", formulaName: "widgets" },
292
- winget: { packageIdentifier: "Acme.Widgets" },
293
- },
294
- });
295
- assert.equal(result.valid, false);
296
- });
297
-
298
- // F15 fix: manifest fields (homebrew.tap, homebrew.formulaName,
299
- // winget.packageIdentifier, matrix.os/node) flow verbatim into rendered
300
- // workflow YAML via render.mjs's literal string substitution, which does no
301
- // escaping. The re-validation proved a hostile `formulaName` containing
302
- // GitHub Actions expression syntax survived into rendered output — a
303
- // workflow-expression injection, not a cosmetic bug. Every property below
304
- // is checked against a FAMILY of hostile payloads (expression syntax,
305
- // command substitution, backticks, statement separators, newlines/CRLF —
306
- // not just the report's one literal example — because a fix that only
307
- // blocks that exact string would be exactly the failure this suite must
308
- // catch. Each field must reject every payload in the family.
309
- const HOSTILE_PAYLOADS = [
310
- "${{ secrets.APPLE_CERTIFICATE }}",
311
- "widgets${{secrets.X}}",
312
- "`whoami`",
313
- "$(whoami)",
314
- "widgets; rm -rf /",
315
- "widgets\nsteps:\n - run: exit 1",
316
- "widgets\r\nrun: curl evil.io",
317
- 'widgets"; secrets: ${{ secrets.X }}',
318
- "widgets & echo pwned",
319
- "widgets|echo pwned",
320
- ];
321
-
322
- test("F15: publish.homebrew.formulaName rejects a family of injection payloads", () => {
323
- for (const payload of HOSTILE_PAYLOADS) {
324
- const result = validateManifest({
325
- ...VALID_MINIMAL,
326
- lanes: ["publish-package-managers"],
327
- publish: {
328
- homebrew: { tap: "acme/tap", formulaName: payload },
329
- winget: { packageIdentifier: "Acme.Widgets" },
330
- },
331
- });
332
- assert.equal(result.valid, false, `formulaName payload should be rejected: ${JSON.stringify(payload)}`);
333
- }
334
- });
335
-
336
- test("F15: publish.homebrew.tap rejects a family of injection payloads", () => {
337
- for (const payload of HOSTILE_PAYLOADS) {
338
- const result = validateManifest({
339
- ...VALID_MINIMAL,
340
- lanes: ["publish-package-managers"],
341
- publish: {
342
- homebrew: { tap: `acme/${payload}`, formulaName: "widgets" },
343
- winget: { packageIdentifier: "Acme.Widgets" },
344
- },
345
- });
346
- assert.equal(result.valid, false, `tap payload should be rejected: ${JSON.stringify(payload)}`);
347
- }
348
- });
349
-
350
- test("F15: publish.winget.packageIdentifier rejects a family of injection payloads", () => {
351
- for (const payload of HOSTILE_PAYLOADS) {
352
- const result = validateManifest({
353
- ...VALID_MINIMAL,
354
- lanes: ["publish-package-managers"],
355
- publish: {
356
- homebrew: { tap: "acme/tap", formulaName: "widgets" },
357
- winget: { packageIdentifier: payload },
358
- },
359
- });
360
- assert.equal(result.valid, false, `winget packageIdentifier payload should be rejected: ${JSON.stringify(payload)}`);
361
- }
362
- });
363
-
364
- test("F15: matrix.os and matrix.node reject a family of injection payloads", () => {
365
- for (const payload of HOSTILE_PAYLOADS) {
366
- assert.equal(
367
- validateManifest({ ...VALID_MINIMAL, matrix: { os: [payload], node: ["22.13"] } }).valid,
368
- false,
369
- `matrix.os payload should be rejected: ${JSON.stringify(payload)}`,
370
- );
371
- assert.equal(
372
- validateManifest({ ...VALID_MINIMAL, matrix: { os: ["ubuntu-latest"], node: [payload] } }).valid,
373
- false,
374
- `matrix.node payload should be rejected: ${JSON.stringify(payload)}`,
375
- );
376
- }
377
- });
378
-
379
- // Non-regression: realistic, legitimate values using the characters real
380
- // GitHub/Homebrew/WinGet identifiers and runner/version labels actually use
381
- // must keep passing — the allowlist must not be so strict it breaks normal
382
- // configuration.
383
- test("F15 non-regression: realistic homebrew/winget/matrix values still validate", () => {
384
- const result = validateManifest({
385
- ...VALID_MINIMAL,
386
- lanes: ["publish-package-managers"],
387
- matrix: { os: ["ubuntu-latest", "self-hosted-linux"], node: ["22.13", "lts/*", "20.x"] },
388
- publish: {
389
- homebrew: { tap: "acme-inc/homebrew-tap", formulaName: "widgets++" },
390
- winget: { packageIdentifier: "Acme.Widgets.Beta" },
391
- },
392
- });
393
- assert.equal(result.valid, true, JSON.stringify(result.errors));
394
- });
395
-
396
- test("qaEvidencePath and qaEvidenceRetentionDays are optional, rust-hybrid only, and charset-checked", () => {
397
- const valid = { ...VALID_MINIMAL, profile: "rust-hybrid", gate: { path: "scripts/gate.sh" } };
398
- assert.equal(validateManifest({ ...valid, qaEvidencePath: "pulse-hub-qa" }).valid, true);
399
- assert.equal(validateManifest({ ...valid, qaEvidencePath: "pulse-hub-qa", qaEvidenceRetentionDays: 30 }).valid, true);
400
- for (const qaEvidencePath of ["/abs", "../up", "pulse hub", "${{ runner.temp }}/x", "a;b", "", null]) {
401
- assert.equal(validateManifest({ ...valid, qaEvidencePath }).valid, false, String(qaEvidencePath));
402
- }
403
- for (const qaEvidenceRetentionDays of [0, 91, 1.5, "7"]) {
404
- assert.equal(validateManifest({ ...valid, qaEvidencePath: "pulse-hub-qa", qaEvidenceRetentionDays }).valid, false, String(qaEvidenceRetentionDays));
405
- }
406
- assert.equal(validateManifest({ ...valid, qaEvidenceRetentionDays: 7 }).valid, false, "retention requires a path");
407
- assert.equal(validateManifest({ ...VALID_MINIMAL, qaEvidencePath: "pulse-hub-qa" }).valid, false, "node profile rejects qaEvidencePath");
408
- });
409
-
410
- test("ciAllOs is an optional boolean, rust-hybrid only", () => {
411
- const valid = { ...VALID_MINIMAL, profile: "rust-hybrid", gate: { path: "scripts/gate.sh" } };
412
- assert.equal(validateManifest(valid).valid, true);
413
- assert.equal(validateManifest({ ...valid, ciAllOs: true }).valid, true);
414
- assert.equal(validateManifest({ ...valid, ciAllOs: false }).valid, true);
415
- for (const ciAllOs of ["true", 1, null]) {
416
- assert.equal(validateManifest({ ...valid, ciAllOs }).valid, false, String(ciAllOs));
417
- }
418
- assert.equal(validateManifest({ ...VALID_MINIMAL, ciAllOs: true }).valid, false, "node profile rejects ciAllOs true");
419
- assert.equal(validateManifest({ ...VALID_MINIMAL, ciAllOs: false }).valid, true, "false is accepted for any profile");
420
- });
421
-
422
- test("ciIncremental is an optional boolean, rust-hybrid only", () => {
423
- const valid = { ...VALID_MINIMAL, profile: "rust-hybrid", lanes: ["ci"], gate: { path: "scripts/gate.sh" } };
424
- assert.equal(validateManifest({ ...valid, ciIncremental: true }).valid, true);
425
- assert.equal(validateManifest({ ...valid, ciIncremental: false }).valid, true);
426
- assert.equal(validateManifest({ ...valid, ciIncremental: "yes" }).valid, false);
427
- assert.equal(validateManifest({ ...VALID_MINIMAL, ciIncremental: true }).valid, false);
428
- });
429
-
430
- test("devArtifact validates keys, paths, and runner coverage", () => {
431
- const base = {
432
- ...VALID_MINIMAL,
433
- profile: "rust-hybrid",
434
- lanes: ["ci"],
435
- gate: { path: "scripts/gate.sh" },
436
- matrix: { os: ["xcode-27", "windows-2025"], node: ["26.8.1"] },
437
- ciAllOs: true,
438
- };
439
- const full = { mac: "sign", windows: "unsigned", macAppPath: "target/release/bundle/macos/Pulse.app", windowsGlob: "target/release/*.exe", retentionDays: 7 };
440
- assert.equal(validateManifest({ ...base, devArtifact: full }).valid, true);
441
- assert.equal(validateManifest({ ...base, devArtifact: { windows: "unsigned", windowsGlob: "dist/*.exe" } }).valid, true);
442
-
443
- const bad = (devArtifact, manifest = base) => validateManifest({ ...manifest, devArtifact }).valid;
444
- assert.equal(bad({ mac: "none", windows: "none" }), false, "needs at least one active target");
445
- assert.equal(bad({ ...full, macAppPath: undefined }), false, "mac sign needs macAppPath");
446
- assert.equal(bad({ ...full, windowsGlob: undefined }), false, "windows needs windowsGlob");
447
- assert.equal(bad({ ...full, macAppPath: "../Pulse.app" }), false);
448
- assert.equal(bad({ ...full, macAppPath: "target/Pulse" }), false, "must end in .app");
449
- assert.equal(bad({ ...full, macAppPath: "a;b.app" }), false);
450
- assert.equal(bad({ ...full, windowsGlob: "${{ x }}" }), false);
451
- assert.equal(bad({ ...full, retentionDays: 0 }), false);
452
- assert.equal(bad({ ...full, retentionDays: 91 }), false);
453
- assert.equal(bad({ ...full, mac: "staple" }), false);
454
- assert.equal(validateManifest({ ...base, devArtifact: { ...full, mac: "notarize" } }).valid, true, "notarize is a signed mac mode");
455
- assert.equal(bad({ ...full, extra: 1 }), false);
456
- assert.equal(bad({ windows: "unsigned", windowsGlob: "a/*.exe", macAppPath: "x.app" }), false, "macAppPath requires mac sign");
457
- assert.equal(bad(full, { ...base, ciAllOs: false }), false, "single windows runner cannot build the mac app");
458
- assert.equal(bad(full, { ...VALID_MINIMAL, devArtifact: full }), false);
459
- assert.equal(validateManifest({ ...VALID_MINIMAL, devArtifact: full }).valid, false, "node profile rejects devArtifact");
460
-
461
- // mac 'unsigned' uploads the bare app; dispatch is allowed only for unsigned legs.
462
- const unsigned = { ...full, mac: "unsigned" };
463
- assert.equal(validateManifest({ ...base, devArtifact: unsigned }).valid, true);
464
- assert.equal(validateManifest({ ...base, devArtifact: { ...unsigned, dispatch: true } }).valid, true);
465
- assert.equal(validateManifest({ ...base, devArtifact: { mac: "unsigned", macAppPath: "target/Pulse.app" } }).valid, true, "mac unsigned alone");
466
- assert.equal(bad({ ...unsigned, macAppPath: undefined }), false, "mac unsigned needs macAppPath");
467
- assert.equal(bad({ ...unsigned, macEntitlements: "build/x.entitlements" }), false, "entitlements require mac sign");
468
- assert.equal(bad(unsigned, { ...base, ciAllOs: false }), false, "mac unsigned needs a macOS runner");
469
- assert.equal(bad({ ...full, dispatch: false }), false, "dispatch must be true when present");
470
- assert.equal(bad({ mac: "sign", macAppPath: "target/Pulse.app", dispatch: true }), false, "dispatch never reaches the signing leg");
471
- assert.equal(validateManifest({ ...base, devArtifact: { ...full, dispatch: true } }).valid, true, "dispatch with a windows unsigned leg beside mac sign");
472
- });
473
-
474
- test("checkout is an optional object with boolean longPaths and safe sparse directories", () => {
475
- assert.equal(validateManifest({ ...VALID_MINIMAL, checkout: { longPaths: true, sparse: ["packages/", "examples/SliceApp"] } }).valid, true);
476
- assert.equal(validateManifest({ ...VALID_MINIMAL, checkout: {} }).valid, true);
477
- for (const checkout of [null, [], "x", { longPaths: "yes" }, { sparse: [] }, { sparse: ["../x"] }, { sparse: ["/abs"] }, { sparse: ["a b"] }, { sparse: ["${{ x }}"] }, { sparse: ["a", "a"] }, { other: 1 }]) {
478
- assert.equal(validateManifest({ ...VALID_MINIMAL, checkout }).valid, false, JSON.stringify(checkout));
479
- }
480
- });
481
-
482
- test("defaultBranch is an optional safe branch name", () => {
483
- assert.equal(validateManifest({ ...VALID_MINIMAL, defaultBranch: "master" }).valid, true);
484
- for (const defaultBranch of ["", "a/b", "a b", "..x", "${{ x }}", 1, null]) {
485
- assert.equal(validateManifest({ ...VALID_MINIMAL, defaultBranch }).valid, false, String(defaultBranch));
486
- }
487
- });
488
-
489
- // Orthic-Labs/rightkit#107: candidate.devQualification and the QA-surface guard.
490
- const DEV_QUAL_BASE = {
491
- ...VALID_MINIMAL,
492
- profile: "rust-hybrid",
493
- gate: { path: "scripts/gate.sh" },
494
- lanes: ["ci", "release-candidate"],
495
- candidate: {
496
- buildScript: "ci:candidate",
497
- checkScript: "ci:candidate-check",
498
- admissionScript: "release:admit",
499
- stageSummaryScript: "release:stage-summary",
500
- artifactRoot: "widgets-unsigned",
501
- os: ["ubuntu-latest"],
502
- },
503
- };
504
-
505
- test("candidate.devQualification validates build and journey scripts", () => {
506
- const withDev = (devQualification) => ({ ...DEV_QUAL_BASE, candidate: { ...DEV_QUAL_BASE.candidate, devQualification } });
507
- const ok = validateManifest(withDev({ buildScript: "build:dev-qualification", journeyScript: "qa:journeys" }));
508
- assert.equal(ok.valid, true, JSON.stringify(ok.errors));
509
- for (const bad of [
510
- null,
511
- [],
512
- {},
513
- { buildScript: "build:dev" },
514
- { journeyScript: "qa:journeys" },
515
- { buildScript: "echo unsafe", journeyScript: "qa:journeys" },
516
- { buildScript: "build:dev", journeyScript: "qa journeys" },
517
- { buildScript: "build:dev", journeyScript: "qa:journeys", extra: "x" },
518
- ]) {
519
- assert.equal(validateManifest(withDev(bad)).valid, false, JSON.stringify(bad));
520
- }
521
- const same = validateManifest(withDev({ buildScript: "ci:candidate", journeyScript: "qa:journeys" }));
522
- assert.equal(same.valid, false);
523
- assert.ok(same.errors.some((error) => error.includes("must differ from candidate.buildScript") && error.includes("#107")));
524
- });
525
-
526
- test("candidate scripts named after a QA surface are refused and point at dev-qualification", () => {
527
- for (const name of ["build:qa-native", "ci:qa-control", "build:dev-native", "build:dev-inspect", "ci:test-mode"]) {
528
- for (const key of ["buildScript", "checkScript"]) {
529
- const result = validateManifest({ ...DEV_QUAL_BASE, candidate: { ...DEV_QUAL_BASE.candidate, [key]: name } });
530
- assert.equal(result.valid, false, `${key}=${name}`);
531
- assert.ok(result.errors.some((error) => error.includes(`candidate.${key}`) && error.includes("#107") && error.includes("devQualification")), `${key}=${name}`);
532
- }
533
- }
534
- assert.equal(validateManifest(DEV_QUAL_BASE).valid, true);
535
- });
package/orkflows.test.mjs DELETED
File without changes
@@ -1,20 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { normalizeRepositoryIdentity, protectedOwnershipRoots } from "./ownership-registration.mjs";
4
-
5
- test("repository identity normalization collapses HTTPS, SSH, and SCP GitHub remotes", () => {
6
- const expected = "https://github.com/bogusyogi/coderight";
7
- for (const remote of ["https://github.com/bogusyogi/CodeRight.git", "ssh://git@github.com/bogusyogi/coderight.git", "git@github.com:bogusyogi/coderight.git"]) {
8
- assert.equal(normalizeRepositoryIdentity(remote), expected);
9
- }
10
- assert.throws(() => normalizeRepositoryIdentity("https://user:secret@github.com/a/b.git"), /credential-bearing/);
11
- });
12
-
13
- test("protected registry is authoritative for exact nested roots and visibility", () => {
14
- const trust = { repositories: [{ repositoryIdentity: "https://github.com/bogusyogi/coderight", roots: ["engine", "apps/ui"], visibility: "private" }] };
15
- assert.deepEqual(protectedOwnershipRoots(trust, { repositoryIdentity: "git@github.com:bogusyogi/coderight.git", scanRoot: "C:/repo/engine", repoRoot: "C:/repo" }), {
16
- repositoryIdentity: "https://github.com/bogusyogi/coderight", visibility: "private", roots: ["engine", "apps/ui"],
17
- });
18
- assert.throws(() => protectedOwnershipRoots(trust, { repositoryIdentity: "https://github.com/bogusyogi/coderight", scanRoot: "C:/repo/src", repoRoot: "C:/repo" }), /not registered/);
19
- assert.throws(() => protectedOwnershipRoots({ repositories: [] }, { repositoryIdentity: "https://github.com/a/b", scanRoot: ".", repoRoot: "." }), /not registered/);
20
- });
@@ -1,55 +0,0 @@
1
- // BLOCK-recurrence guard: the only test that catches a `files`-allowlist
2
- // omission in package.json is one that actually packs the tarball npm would
3
- // publish and runs the extracted bin with `node` — `node --test` run from
4
- // the source tree never notices a missing directory because the source
5
- // tree has every file regardless of what `files` declares. This test packs
6
- // for real (pnpm pack), extracts to a temp dir, and executes the built bin's
7
- // --help and --version from inside that extracted tree only.
8
- import assert from "node:assert/strict";
9
- import { spawnSync } from "node:child_process";
10
- import { mkdtempSync, readdirSync, rmSync } from "node:fs";
11
- import os from "node:os";
12
- import path from "node:path";
13
- import { fileURLToPath } from "node:url";
14
- import test from "node:test";
15
-
16
- const packageRoot = path.dirname(fileURLToPath(import.meta.url));
17
-
18
- function run(command, args, options) {
19
- const result = spawnSync(command, args, { encoding: "utf8", ...options });
20
- if (result.error) throw result.error;
21
- return result;
22
- }
23
-
24
- test("packaged tarball: right-git --help and --version run clean from the published files only", () => {
25
- const workDir = mkdtempSync(path.join(os.tmpdir(), "rightkit-git-pack-"));
26
- try {
27
- // shell:true resolves pnpm.cmd on Windows; args are fixed literals.
28
- const packResult = run("pnpm", ["pack", "--pack-destination", workDir], { cwd: packageRoot, shell: true });
29
- assert.equal(packResult.status, 0, `pnpm pack failed: ${packResult.stderr}`);
30
- const archive = readdirSync(workDir).find((name) => name.endsWith(".tgz"));
31
- assert.ok(archive, `pnpm pack did not create a tarball: ${packResult.stdout}`);
32
-
33
- // Run tar FROM the temp dir on the bare filename so no absolute "C:\..."
34
- // path reaches tar — that colon is the only reason GNU tar's --force-local
35
- // was ever needed, and avoiding it keeps this portable to bsdtar (the
36
- // Windows built-in) and any CI host, not just a GNU-tar toolchain.
37
- const extractResult = run("tar", ["-xzf", archive], { cwd: workDir });
38
- assert.equal(extractResult.status, 0, `tar extract failed: ${extractResult.stderr}`);
39
- // npm tarballs always nest content under a top-level "package/" directory.
40
- const extractedPackageDir = path.join(workDir, "package");
41
- const bin = path.join(extractedPackageDir, "cli", "right-git.mjs");
42
-
43
- const helpResult = run("node", [bin, "--help"], { cwd: extractedPackageDir });
44
- assert.equal(helpResult.status, 0, `--help exited non-zero: ${helpResult.stderr}`);
45
- assert.ok(!/ERR_MODULE_NOT_FOUND/.test(helpResult.stderr ?? ""), helpResult.stderr);
46
- assert.ok(/right-git/i.test(helpResult.stdout));
47
-
48
- const versionResult = run("node", [bin, "--version"], { cwd: extractedPackageDir });
49
- assert.equal(versionResult.status, 0, `--version exited non-zero: ${versionResult.stderr}`);
50
- assert.ok(!/ERR_MODULE_NOT_FOUND/.test(versionResult.stderr ?? ""), versionResult.stderr);
51
- assert.match(versionResult.stdout, /\d+\.\d+\.\d+/);
52
- } finally {
53
- rmSync(workDir, { recursive: true, force: true });
54
- }
55
- });