@runeditrun/rer 0.2.80 → 0.2.81

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 (57) hide show
  1. package/cli/deploy-needs.mjs +4 -2
  2. package/cli/export.mjs +1 -1
  3. package/cli/ledger-refusal.mjs +18 -0
  4. package/cli/portability-migrations.mjs +30 -11
  5. package/cli/portability-worker.mjs +3 -1
  6. package/cli/portability.mjs +2 -0
  7. package/cli/release.mjs +4 -4
  8. package/cli/site-hosting.mjs +90 -0
  9. package/cli/site-render.mjs +3 -2
  10. package/cli/site.mjs +5 -2
  11. package/edition-authoring/base-copies.mjs +9 -0
  12. package/edition-authoring/runtime-dependencies.mjs +108 -0
  13. package/global/CHANGELOG.md +12 -0
  14. package/modules/demo/README.md +8 -0
  15. package/modules/demo/navigation.mjs +131 -15
  16. package/modules/dependencies/auth.mjs +2 -2
  17. package/modules/deploy-kit/owner.mjs +8 -1
  18. package/modules/import-kit/src/d1/apply-effects.ts +33 -0
  19. package/modules/import-kit/src/d1/apply.ts +38 -10
  20. package/modules/import-kit/src/types.ts +3 -1
  21. package/modules/operator-auth/README.md +92 -3
  22. package/modules/operator-auth/accounts/admin.mjs +52 -20
  23. package/modules/operator-auth/accounts/audit.mjs +24 -0
  24. package/modules/operator-auth/accounts/business-team.mjs +91 -0
  25. package/modules/operator-auth/accounts/domain-audit.mjs +24 -0
  26. package/modules/operator-auth/accounts/native.mjs +3 -1
  27. package/modules/operator-auth/accounts/settings-page.mjs +15 -2
  28. package/modules/operator-auth/accounts/status.mjs +7 -2
  29. package/modules/operator-auth/accounts/store.mjs +32 -6
  30. package/modules/operator-auth/business-settings.mjs +40 -0
  31. package/modules/operator-auth/identity/email-link/index.mjs +1 -1
  32. package/modules/operator-auth/identity/oidc/admin-audit.mjs +31 -0
  33. package/modules/operator-auth/identity/oidc/index.mjs +12 -5
  34. package/modules/operator-auth/identity/oidc/store.mjs +2 -0
  35. package/modules/operator-auth/index.d.mts +40 -1
  36. package/modules/operator-auth/routes.mjs +11 -6
  37. package/modules/operator-auth/service.mjs +8 -3
  38. package/modules/operator-auth/signin/index.mjs +1 -1
  39. package/modules/portability/README.md +82 -1
  40. package/modules/portability/export.mjs +6 -4
  41. package/modules/portability/format.mjs +5 -0
  42. package/modules/portability/index.d.mts +10 -2
  43. package/modules/portability/index.mjs +3 -2
  44. package/modules/portability/ledgers.mjs +27 -4
  45. package/modules/release/README.md +74 -2
  46. package/modules/release/sign.mjs +4 -2
  47. package/modules/release/signature.mjs +14 -7
  48. package/modules/release/signing-cli.mjs +2 -1
  49. package/modules/release/statement.mjs +2 -2
  50. package/modules/release/vectors/generate.mjs +1 -0
  51. package/modules/release/vectors/publisher-projects.mjs +133 -0
  52. package/modules/release/vectors/release-signature-vectors.json +5195 -0
  53. package/modules/release/verify.mjs +5 -1
  54. package/onboarding/schema/SETUP.schema.json +43 -1
  55. package/onboarding/schema/business-field-inputs.mjs +0 -1
  56. package/onboarding/schema/setup-validation.mjs +3 -0
  57. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  // Shared release authentication: dependency-free, with one WebCrypto code path.
2
2
  export const PAYLOAD_TYPE = 'application/vnd.runeditrun.release-statement.v1+json';
3
3
  export const ENROLMENT_TYPE = 'application/vnd.runeditrun.key-enrolment.v1+json';
4
- export const LIMITS = Object.freeze({ envelopeBytes: 65536, files: 256, fileBytes: 1073741824 });
4
+ export const LIMITS = Object.freeze({ envelopeBytes: 65536, files: 256, fileBytes: 1073741824, projectsPerKey: 1024 });
5
5
  const encoder = new TextEncoder();
6
6
  const trusted = new WeakMap();
7
7
  const codes = new Set(('SIGNATURE_MISSING INPUT_TOO_LARGE ENVELOPE_INVALID KEY_TEST_REFUSED KEY_UNKNOWN SIGNATURE_INVALID STATEMENT_NOT_CANONICAL STATEMENT_INVALID PUBLISHER_MISMATCH KEY_OUTSIDE_VALIDITY KEY_RETIRED KEY_REVOKED ISSUED_IN_FUTURE SUBJECT_MISMATCH FILE_MISSING FILE_UNDECLARED DIGEST_MISMATCH PATH_UNSAFE VERSION_ROLLBACK VERSION_REUSED ANCHORS_INVALID ANCHORS_STALE').split(' '));
@@ -110,11 +110,13 @@ const filePattern = /^(public-source\.tar|release-receipt\.json|publish-check\.j
110
110
  function safePath(path) {
111
111
  return validRelativePath(path) && matches(path, filePattern);
112
112
  }
113
- export function validateStatement(s) {
113
+ // V1 anchors retain their original namespace/schema refusal. V2 separates
114
+ // project grammar from the signing key's reviewed authority below.
115
+ export function validateStatement(s, anchorsVersion = 1) {
114
116
  try {
115
117
  if (!shape(s, ['schemaVersion', 'publisher', 'project', 'version', 'tag', 'repository', 'publicCommit', 'publicTree', 'tagObject', 'files', 'issuedAt', 'keyId'])
116
118
  || s.schemaVersion !== 1 || !matches(s.publisher, namespace) || !validProject(s.project)
117
- || !s.project.startsWith(s.publisher + '/') || !version(s.version) || s.tag !== 'v' + s.version
119
+ || (anchorsVersion === 1 && !s.project.startsWith(s.publisher + '/')) || !version(s.version) || s.tag !== 'v' + s.version
118
120
  || !matches(s.repository, repositoryPattern) || ['.', '..'].includes(s.repository.split('/')[4])
119
121
  || !matches(s.publicCommit, hex40) || !matches(s.publicTree, hex40) || !matches(s.tagObject, hex40)
120
122
  || !instant(s.issuedAt) || !matches(s.keyId, keyPattern) || !Array.isArray(s.files)) refuse('STATEMENT_INVALID');
@@ -173,17 +175,21 @@ export async function loadAnchors(raw, environment = 'production', options = {})
173
175
  || (Object.hasOwn(options, 'minimumSerial') && (!Number.isSafeInteger(options.minimumSerial) || options.minimumSerial < 0))) refuse('ANCHORS_INVALID');
174
176
  const anchors = raw instanceof Uint8Array ? parseJSON(raw, 'ANCHORS_INVALID')
175
177
  : typeof raw === 'string' ? JSON.parse(raw) : JSON.parse(canonical(raw));
176
- if (!shape(anchors, ['schemaVersion', 'environment', 'serial', 'legacyUnsigned', 'keys']) || anchors.schemaVersion !== 1
178
+ if (!shape(anchors, ['schemaVersion', 'environment', 'serial', 'legacyUnsigned', 'keys']) || ![1, 2].includes(anchors.schemaVersion)
177
179
  || anchors.environment !== environment || !Number.isSafeInteger(anchors.serial) || anchors.serial < 1
178
180
  || !Array.isArray(anchors.keys) || !floors(anchors.legacyUnsigned)) refuse('ANCHORS_INVALID');
179
181
  const lookup = new Map(), owners = new Map();
180
182
  for (const k of anchors.keys) {
181
- if (!shape(k, ['keyId', 'publicKey', 'publisher', 'githubOwner', 'notBefore', 'notAfter', 'status', 'enrolment', 'review'], ['retiredAt', 'compromisedAt', 'keepStatements'])
183
+ const projectFields = anchors.schemaVersion === 2 ? ['projects'] : [];
184
+ if (!shape(k, ['keyId', 'publicKey', 'publisher', 'githubOwner', 'notBefore', 'notAfter', 'status', 'enrolment', 'review', ...projectFields], ['retiredAt', 'compromisedAt', 'keepStatements'])
182
185
  || !matches(k.keyId, keyPattern) || lookup.has(k.keyId) || !matches(k.publisher, namespace)
183
186
  || !shape(k.githubOwner, ['login', 'id']) || !matches(k.githubOwner.login, namespace)
184
187
  || !Number.isSafeInteger(k.githubOwner.id) || k.githubOwner.id <= 0 || !ascii(k.review)
185
188
  || !instant(k.notBefore) || !instant(k.notAfter) || k.notBefore >= k.notAfter
186
189
  || !['active', 'retired', 'compromised'].includes(k.status)) refuse('ANCHORS_INVALID');
190
+ if (anchors.schemaVersion === 2 && (!Array.isArray(k.projects) || k.projects.length < 1
191
+ || k.projects.length > LIMITS.projectsPerKey || !k.projects.every(validProject)
192
+ || new Set(k.projects).size !== k.projects.length)) refuse('ANCHORS_INVALID');
187
193
  const maximum = new Date(k.notBefore); maximum.setUTCFullYear(maximum.getUTCFullYear() + 2);
188
194
  if (Date.parse(k.notAfter) > maximum.getTime()) refuse('ANCHORS_INVALID');
189
195
  if ((k.status === 'retired' && !Object.hasOwn(k, 'retiredAt'))
@@ -315,10 +321,11 @@ export async function verifyRelease(envelopeBytes, loadedAnchors, input = {}) {
315
321
  if (!found) refuse('KEY_UNKNOWN');
316
322
  await checkSignature(found.publicKey, PAYLOAD_TYPE, parts.payload, parts.signature);
317
323
  const statement = canonicalPayload(parts.payload);
318
- validateStatement(statement);
324
+ validateStatement(statement, loadedAnchors.schemaVersion);
319
325
  if (statement.keyId !== parts.keyid) refuse('STATEMENT_INVALID');
320
326
  const anchor = found.anchor;
321
- if (statement.publisher !== anchor.publisher || statement.repository.split('/')[3] !== anchor.githubOwner.login) refuse('PUBLISHER_MISMATCH');
327
+ if (statement.publisher !== anchor.publisher || statement.repository.split('/')[3] !== anchor.githubOwner.login
328
+ || (loadedAnchors.schemaVersion === 2 && !anchor.projects.includes(statement.project))) refuse('PUBLISHER_MISMATCH');
322
329
  const statementSha256 = await sha256(parts.payload);
323
330
  const now = context.now === undefined ? Date.now() : context.now;
324
331
  if (!Number.isSafeInteger(now) || Math.abs(now) > 8640000000000000) refuse('STATEMENT_INVALID');
@@ -4,7 +4,7 @@ const semver = '(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)';
4
4
  const versionOK = value => new RegExp(`^${semver}$`).test(value) && value.split('.').every(part => Number.isSafeInteger(Number(part)));
5
5
  const dateOK = value => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value.replace('Z', '.000Z');
6
6
  function parse(verb, args) {
7
- const fields = { sign: ['artifact', 'key-file', 'scope'], receipt: ['artifact', 'anchors', 'environment', 'after'],
7
+ const fields = { sign: ['artifact', 'key-file', 'scope', 'publisher'], receipt: ['artifact', 'anchors', 'environment', 'after'],
8
8
  keygen: ['scope', 'publisher', 'github-owner', 'github-owner-id', 'anchor-out', 'not-before', 'not-after', 'unsigned-through'] }[verb];
9
9
  const options = { unsignedThrough: {} };
10
10
  const invalid = () => { throw new TypeError('ARGUMENT_INVALID'); };
@@ -23,6 +23,7 @@ function parse(verb, args) {
23
23
  if (options.scope !== undefined && !['test', 'rer'].includes(options.scope)) invalid();
24
24
  if (verb === 'receipt' && (!options.artifact || !options.anchors || (options.environment !== undefined && options.environment !== 'test') || (options.after && (!new RegExp(`^${semver}:[a-f0-9]{64}$`).test(options.after) || !versionOK(options.after.split(':')[0]))))) invalid();
25
25
  if (verb === 'sign' && (!options.artifact || Boolean(options['key-file']) === Boolean(options['key-stdin']))) invalid();
26
+ if (verb === 'sign' && options.publisher !== undefined && !/^[a-z0-9][a-z0-9-]{0,38}$/.test(options.publisher)) invalid();
26
27
  if (verb === 'keygen') {
27
28
  if (!options.scope || !options['anchor-out'] || !/^[a-z0-9][a-z0-9-]{0,38}$/.test(options.publisher ?? '') || !/^[a-z0-9][a-z0-9-]{0,38}$/.test(options['github-owner'] ?? '') || !/^[1-9]\d*$/.test(options['github-owner-id'] ?? '') || !Number.isSafeInteger(Number(options['github-owner-id']))) invalid();
28
29
  for (const name of ['not-before', 'not-after']) if (options[name] !== undefined && !dateOK(options[name])) invalid();
@@ -77,8 +77,8 @@ export async function readArtifact(directory) {
77
77
  return { root, receipt, subject, files, entries };
78
78
  }
79
79
 
80
- export function statementFor(artifact, keyId, issuedAt) {
80
+ export function statementFor(artifact, keyId, issuedAt, anchorsVersion = 1) {
81
81
  const statement = { schemaVersion: 1, ...artifact.subject, files: artifact.entries, issuedAt, keyId };
82
- validateStatement(statement);
82
+ validateStatement(statement, anchorsVersion);
83
83
  return statement;
84
84
  }
@@ -379,3 +379,4 @@ add('unsigned release outside every legacy floor', false, testAnchors,
379
379
  const output = new URL('./release-signature-vectors.json', import.meta.url);
380
380
  writeFileSync(output, JSON.stringify(vectors, null, 2) + '\n');
381
381
  console.log(`Wrote ${vectors.length} public release-signature vectors.`);
382
+ await import('./publisher-projects.mjs');
@@ -0,0 +1,133 @@
1
+ // Regenerate only the appended publisher-project vectors; historical v1 bytes stay intact.
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
+ import { generateKeyPairSync } from 'node:crypto';
4
+ import { publicEntry, envelope } from '../signing-key.mjs';
5
+ import { b64, canonicalBytes, ENROLMENT_TYPE, PAYLOAD_TYPE, sha256 } from '../signature.mjs';
6
+
7
+ const output = new URL('./release-signature-vectors.json', import.meta.url);
8
+ const original = readFileSync(output, 'utf8');
9
+ const historical = JSON.parse(original).filter(row => !/^(v2 |anchors v1 )/.test(row.name));
10
+ const template = historical[0];
11
+ const baseStatement = JSON.parse(Buffer.from(JSON.parse(Buffer.from(template.envelope, 'base64')).payload, 'base64'));
12
+ const copy = value => structuredClone(value);
13
+ const issuedAt = baseStatement.issuedAt;
14
+ const repository = 'https://github.com/just-every/run-beam';
15
+ const publisher = 'just-every';
16
+ const githubOwner = { login: 'just-every', id: 71005 };
17
+
18
+ async function ephemeralKey() {
19
+ // EPHEMERAL TEST-SCOPE ONLY: private keys stay in memory and are never serialized.
20
+ const { privateKey } = generateKeyPairSync('ed25519');
21
+ const entry = await publicEntry(privateKey, {
22
+ scope: 'test', publisher, githubOwner,
23
+ notBefore: '2026-10-01T00:00:00Z', notAfter: '2028-10-01T00:00:00Z',
24
+ issuedAt: '2026-10-01T00:00:00Z', unsignedThrough: { 'just-every/beam': '1.1.0' },
25
+ });
26
+ return { privateKey, entry: { ...entry, review: 'public synthetic conformance vector', projects: ['learning/beam', 'just-every/beam'] } };
27
+ }
28
+
29
+ const key = await ephemeralKey();
30
+ const otherKey = await ephemeralKey();
31
+ const anchors = {
32
+ schemaVersion: 2, environment: 'test', serial: 1,
33
+ legacyUnsigned: { 'never-enrolled/app': '0.1.0' }, keys: [key.entry],
34
+ };
35
+ function statement(project = 'learning/beam', fields = {}) {
36
+ return { ...copy(baseStatement), publisher, project, repository, keyId: key.entry.keyId, ...fields };
37
+ }
38
+ function signed(project, fields = {}) {
39
+ return b64(Buffer.from(JSON.stringify(envelope(key.privateKey, key.entry.keyId, PAYLOAD_TYPE, statement(project, fields)))));
40
+ }
41
+ function context(project = 'learning/beam') {
42
+ return { ...copy(template.context), expect: { ...template.context.expect, project, repository } };
43
+ }
44
+ function changedAnchor(change) {
45
+ const result = copy(anchors);
46
+ change(result.keys[0], result);
47
+ return result;
48
+ }
49
+ const rows = [];
50
+ function add(name, expected, { project = 'learning/beam', anchorSet = anchors, payload = signed(project), ctx = context(project) } = {}) {
51
+ rows.push({ name, envelope: payload, anchors: copy(anchorSet), context: copy(ctx), expected });
52
+ }
53
+
54
+ add('v2 listed external learning/beam signed by just-every', 'VERIFIED');
55
+ add('v2 listed own namespace', 'VERIFIED', { project: 'just-every/beam' });
56
+ for (const project of ['learning/not-listed', 'just-every/not-listed', 'learning/Beam']) {
57
+ add(`v2 unlisted exact project ${project}`, 'PUBLISHER_MISMATCH', { project });
58
+ }
59
+ add('v2 malformed statement trailing slash', 'STATEMENT_INVALID', { project: 'learning/beam/' });
60
+ add('v2 another key with same publisher and owner cannot widen signing key projects', 'PUBLISHER_MISMATCH', {
61
+ project: 'learning/not-listed',
62
+ anchorSet: { ...copy(anchors), keys: [copy(key.entry), { ...copy(otherKey.entry), projects: ['learning/not-listed'] }] },
63
+ });
64
+ add('v2 one project is sufficient', 'VERIFIED', { anchorSet: changedAnchor(entry => { entry.projects = ['learning/beam']; }) });
65
+ const maximumProjects = ['learning/beam', ...Array.from({ length: 1023 }, (_, i) => `learning/project-${i}`)];
66
+ add('v2 1024 projects allowed', 'VERIFIED', { anchorSet: changedAnchor(entry => { entry.projects = maximumProjects; }) });
67
+ for (const [label, projects] of [
68
+ ['duplicate', ['learning/beam', 'learning/beam']], ['empty list', []], ['empty string', ['']],
69
+ ['malformed project', ['learning/beam/extra']], ['trailing slash', ['learning/beam/']],
70
+ ['number member', [42]], ['null member', [null]], ['object member', [{}]], ['array member', [[]]],
71
+ ['number list', 42], ['null list', null], ['object list', {}], ['string list', 'learning/beam'],
72
+ ['1025 projects', [...maximumProjects, 'learning/overflow']],
73
+ ]) {
74
+ add(`v2 invalid projects ${label}`, 'ANCHORS_INVALID', {
75
+ anchorSet: changedAnchor(entry => { entry.projects = projects; }), payload: null,
76
+ });
77
+ }
78
+ add('v2 missing projects', 'ANCHORS_INVALID', { anchorSet: changedAnchor(entry => { delete entry.projects; }), payload: null });
79
+ add('v2 unknown top projects', 'ANCHORS_INVALID', { anchorSet: { ...copy(anchors), projects: ['learning/beam'] }, payload: null });
80
+ add('v2 unknown key field', 'ANCHORS_INVALID', { anchorSet: changedAnchor(entry => { entry.unreviewed = true; }), payload: null });
81
+ add('v2 unknown githubOwner field', 'ANCHORS_INVALID', { anchorSet: changedAnchor(entry => { entry.githubOwner.unreviewed = true; }), payload: null });
82
+ for (const [label, extra] of [['unknown field', { unreviewed: true }], ['projects field', { projects: ['learning/beam'] }]]) {
83
+ const claim = JSON.parse(Buffer.from(key.entry.enrolment.payload, 'base64'));
84
+ add(`v2 enrolment claim ${label} correctly signed`, 'ANCHORS_INVALID', {
85
+ anchorSet: changedAnchor(entry => { entry.enrolment = envelope(key.privateKey, key.entry.keyId, ENROLMENT_TYPE, { ...claim, ...extra }); }), payload: null,
86
+ });
87
+ }
88
+ add('v2 unknown enrolment envelope field', 'ANCHORS_INVALID', { anchorSet: changedAnchor(entry => { entry.enrolment.unreviewed = true; }), payload: null });
89
+ const extraEnvelope = JSON.parse(Buffer.from(signed(), 'base64'));
90
+ extraEnvelope.unreviewed = true;
91
+ add('v2 unknown release envelope field', 'ENVELOPE_INVALID', { payload: b64(Buffer.from(JSON.stringify(extraEnvelope))) });
92
+
93
+ const v1 = changedAnchor((entry, set) => { delete entry.projects; set.schemaVersion = 1; });
94
+ add('anchors v1 retains external prefix statement refusal', 'STATEMENT_INVALID', { anchorSet: v1 });
95
+ add('anchors v1 retains own namespace authority', 'VERIFIED', { anchorSet: v1, project: 'just-every/not-listed' });
96
+ add('anchors v1 refuses key projects', 'ANCHORS_INVALID', { anchorSet: { ...copy(anchors), schemaVersion: 1 }, payload: null });
97
+ add('anchors v1 refuses top projects', 'ANCHORS_INVALID', { anchorSet: { ...copy(v1), projects: ['learning/beam'] }, payload: null });
98
+
99
+ add('v2 compromised key without reviewed keep digest', 'KEY_REVOKED', { anchorSet: changedAnchor(entry => { Object.assign(entry, { status: 'compromised', compromisedAt: issuedAt, keepStatements: [] }); }) });
100
+ const statementDigest = await sha256(canonicalBytes(statement()));
101
+ add('v2 compromised key with reviewed keep digest', 'VERIFIED', { anchorSet: changedAnchor(entry => { Object.assign(entry, { status: 'compromised', compromisedAt: issuedAt, keepStatements: [statementDigest] }); }) });
102
+ for (const [label, retiredAt, expected] of [
103
+ ['before retirement', '2026-10-13T00:00:01Z', 'VERIFIED'], ['at retirement', issuedAt, 'KEY_RETIRED'],
104
+ ]) {
105
+ add(`v2 retired key ${label}`, expected, { anchorSet: changedAnchor(entry => { Object.assign(entry, { status: 'retired', retiredAt }); }) });
106
+ }
107
+ add('v2 statement before validity', 'KEY_OUTSIDE_VALIDITY', { payload: signed(undefined, { issuedAt: '2026-09-30T23:59:59Z' }) });
108
+ add('v2 statement at expiry', 'KEY_OUTSIDE_VALIDITY', { payload: signed(undefined, { issuedAt: key.entry.notAfter }), ctx: { ...context(), now: Date.parse(key.entry.notAfter) } });
109
+ add('v2 statement in future', 'ISSUED_IN_FUTURE', { payload: signed(undefined, { issuedAt: '2027-10-13T00:00:00Z' }) });
110
+ add('v2 environment mismatch', 'ANCHORS_INVALID', { anchorSet: { ...copy(anchors), environment: 'production' }, payload: null });
111
+ add('v2 production anchors refuse test key', 'ANCHORS_INVALID', { anchorSet: { ...copy(anchors), environment: 'production' }, payload: null, ctx: { environment: 'production' } });
112
+ add('v2 test key refused by production verifier', 'KEY_TEST_REFUSED', { anchorSet: { ...copy(anchors), environment: 'production', keys: [] }, ctx: { environment: 'production', now: template.context.now } });
113
+ add('v2 stale serial equal', 'ANCHORS_STALE', { ctx: { ...context(), minimumSerial: 1 }, payload: null });
114
+ add('v2 stale serial older', 'ANCHORS_STALE', { ctx: { ...context(), minimumSerial: 2 }, payload: null });
115
+ add('v2 legacy floor cannot overlap enrolled publisher', 'ANCHORS_INVALID', { anchorSet: { ...copy(anchors), legacyUnsigned: { 'just-every/beam': '1.1.0' } }, payload: null });
116
+ for (const [label, project, version, expected] of [
117
+ ['enrolled floor', 'just-every/beam', '1.1.0', 'UNSIGNED_LEGACY'],
118
+ ['above enrolled floor', 'just-every/beam', '1.2.0', 'SIGNATURE_MISSING'],
119
+ ['legacy floor', 'never-enrolled/app', '0.1.0', 'UNSIGNED_LEGACY'],
120
+ ['above legacy floor', 'never-enrolled/app', '0.2.0', 'SIGNATURE_MISSING'],
121
+ ['listing creates no unsigned floor', 'learning/beam', '1.1.0', 'SIGNATURE_MISSING'],
122
+ ]) {
123
+ add(`v2 unsigned ${label} unchanged`, expected, { payload: false, ctx: {
124
+ environment: 'test', now: template.context.now, expect: { project, version, tag: `v${version}` }, unsigned: { project, version },
125
+ } });
126
+ }
127
+
128
+ // Keep the historical JSON prefix verbatim, adding only its separating comma.
129
+ const generatedStart = original.search(/\n \{\n "name": "(?:v2 |anchors v1 )/);
130
+ const prefix = generatedStart < 0 ? original.slice(0, original.lastIndexOf('\n]')) : original.slice(0, generatedStart).replace(/,$/, '');
131
+ if (JSON.stringify(JSON.parse(prefix + '\n]')) !== JSON.stringify(historical)) throw new Error('Generated rows must follow all historical vectors.');
132
+ writeFileSync(output, prefix + ',' + JSON.stringify(rows, null, 2).slice(1, -1) + ']\n');
133
+ console.log(`Appended ${rows.length} publisher-project vectors.`);