@uns-kit/core 3.0.28 → 3.0.30

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 (103) hide show
  1. package/MIGRATIONS.md +100 -0
  2. package/README.md +10 -0
  3. package/dist/config/app-config.d.ts +14 -0
  4. package/dist/config/app-config.d.ts.map +1 -1
  5. package/dist/config/app-config.js.map +1 -1
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/runtime/configuration-group-authorization.d.ts +50 -0
  11. package/dist/runtime/configuration-group-authorization.d.ts.map +1 -0
  12. package/dist/runtime/configuration-group-authorization.js +113 -0
  13. package/dist/runtime/configuration-group-authorization.js.map +1 -0
  14. package/dist/runtime/configuration-group-contract.d.ts +75 -0
  15. package/dist/runtime/configuration-group-contract.d.ts.map +1 -0
  16. package/dist/runtime/configuration-group-contract.js +233 -0
  17. package/dist/runtime/configuration-group-contract.js.map +1 -0
  18. package/dist/runtime/process-group-authorization.d.ts +2 -0
  19. package/dist/runtime/process-group-authorization.d.ts.map +1 -1
  20. package/dist/runtime/process-group-authorization.js +34 -12
  21. package/dist/runtime/process-group-authorization.js.map +1 -1
  22. package/dist/runtime/process-group-backup-contract.d.ts +22 -0
  23. package/dist/runtime/process-group-backup-contract.d.ts.map +1 -0
  24. package/dist/runtime/process-group-backup-contract.js +20 -0
  25. package/dist/runtime/process-group-backup-contract.js.map +1 -0
  26. package/dist/runtime/process-group-backup-contract.json +7 -0
  27. package/dist/runtime/process-group-configured-upgrade.d.ts +4 -0
  28. package/dist/runtime/process-group-configured-upgrade.d.ts.map +1 -0
  29. package/dist/runtime/process-group-configured-upgrade.js +107 -0
  30. package/dist/runtime/process-group-configured-upgrade.js.map +1 -0
  31. package/dist/runtime/process-group-generation.d.ts +166 -0
  32. package/dist/runtime/process-group-generation.d.ts.map +1 -0
  33. package/dist/runtime/process-group-generation.js +278 -0
  34. package/dist/runtime/process-group-generation.js.map +1 -0
  35. package/dist/runtime/process-group-inspection.d.ts +2 -0
  36. package/dist/runtime/process-group-inspection.d.ts.map +1 -1
  37. package/dist/runtime/process-group-inspection.js +120 -40
  38. package/dist/runtime/process-group-inspection.js.map +1 -1
  39. package/dist/runtime/process-group-resources.d.ts +1 -0
  40. package/dist/runtime/process-group-resources.d.ts.map +1 -1
  41. package/dist/runtime/process-group-resources.js +8 -0
  42. package/dist/runtime/process-group-resources.js.map +1 -1
  43. package/dist/runtime/process-group-runtime-selection.d.ts +14 -0
  44. package/dist/runtime/process-group-runtime-selection.d.ts.map +1 -0
  45. package/dist/runtime/process-group-runtime-selection.js +29 -0
  46. package/dist/runtime/process-group-runtime-selection.js.map +1 -0
  47. package/dist/runtime/process-group-snapshot.mjs +60 -8
  48. package/dist/runtime/process-group-staging.d.ts +2 -2
  49. package/dist/runtime/process-group-staging.d.ts.map +1 -1
  50. package/dist/runtime/process-group-staging.js +6 -4
  51. package/dist/runtime/process-group-staging.js.map +1 -1
  52. package/dist/runtime/process-group-supervision.d.ts +2 -2
  53. package/dist/runtime/process-group-supervision.d.ts.map +1 -1
  54. package/dist/runtime/process-group-supervision.js +3 -2
  55. package/dist/runtime/process-group-supervision.js.map +1 -1
  56. package/dist/runtime/process-group-upgrade.d.ts +76 -6
  57. package/dist/runtime/process-group-upgrade.d.ts.map +1 -1
  58. package/dist/runtime/process-group-upgrade.js +7 -1
  59. package/dist/runtime/process-group-upgrade.js.map +1 -1
  60. package/dist/uns/uns-interfaces.d.ts +3 -0
  61. package/dist/uns/uns-interfaces.d.ts.map +1 -1
  62. package/dist/uns/uns-interfaces.js.map +1 -1
  63. package/dist/uns/uns-proxy-process.d.ts.map +1 -1
  64. package/dist/uns/uns-proxy-process.js +3 -0
  65. package/dist/uns/uns-proxy-process.js.map +1 -1
  66. package/dist/uns-config/config-schema.d.ts +16 -0
  67. package/dist/uns-config/config-schema.d.ts.map +1 -1
  68. package/dist/uns-config/mqtt-channel.d.ts +1 -1
  69. package/dist/uns-config/mqtt-channel.d.ts.map +1 -1
  70. package/dist/uns-config/mqtt-channel.js +3 -0
  71. package/dist/uns-config/mqtt-channel.js.map +1 -1
  72. package/dist/uns-config/uns-core-schema.d.ts +137 -0
  73. package/dist/uns-config/uns-core-schema.d.ts.map +1 -1
  74. package/dist/uns-config/uns-core-schema.js +6 -1
  75. package/dist/uns-config/uns-core-schema.js.map +1 -1
  76. package/dist/uns-mqtt/mqtt-interfaces.d.ts +5 -0
  77. package/dist/uns-mqtt/mqtt-interfaces.d.ts.map +1 -1
  78. package/dist/uns-mqtt/mqtt-interfaces.js.map +1 -1
  79. package/dist/uns-mqtt/mqtt-proxy.d.ts +3 -0
  80. package/dist/uns-mqtt/mqtt-proxy.d.ts.map +1 -1
  81. package/dist/uns-mqtt/mqtt-proxy.js +26 -1
  82. package/dist/uns-mqtt/mqtt-proxy.js.map +1 -1
  83. package/dist/uns-mqtt/mqtt-worker.d.ts +3 -1
  84. package/dist/uns-mqtt/mqtt-worker.d.ts.map +1 -1
  85. package/dist/uns-mqtt/mqtt-worker.js +45 -8
  86. package/dist/uns-mqtt/mqtt-worker.js.map +1 -1
  87. package/dist/uns-mqtt/publish-queue-contract.d.ts +33 -0
  88. package/dist/uns-mqtt/publish-queue-contract.d.ts.map +1 -0
  89. package/dist/uns-mqtt/publish-queue-contract.js +18 -0
  90. package/dist/uns-mqtt/publish-queue-contract.js.map +1 -0
  91. package/dist/uns-mqtt/publish-queue-store.d.ts +33 -0
  92. package/dist/uns-mqtt/publish-queue-store.d.ts.map +1 -0
  93. package/dist/uns-mqtt/publish-queue-store.js +177 -0
  94. package/dist/uns-mqtt/publish-queue-store.js.map +1 -0
  95. package/dist/uns-mqtt/publish-queue.d.ts +43 -0
  96. package/dist/uns-mqtt/publish-queue.d.ts.map +1 -0
  97. package/dist/uns-mqtt/publish-queue.js +235 -0
  98. package/dist/uns-mqtt/publish-queue.js.map +1 -0
  99. package/dist/uns-mqtt/uns-mqtt-proxy.d.ts +7 -0
  100. package/dist/uns-mqtt/uns-mqtt-proxy.d.ts.map +1 -1
  101. package/dist/uns-mqtt/uns-mqtt-proxy.js +98 -5
  102. package/dist/uns-mqtt/uns-mqtt-proxy.js.map +1 -1
  103. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-group-generation.js","sourceRoot":"","sources":["../../src/runtime/process-group-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iCAAiC,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACvH,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,8BAA8B,IAAI,IAAI,EACtC,wBAAwB,IAAI,IAAI,EAChC,MAAM,GACP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAGpH,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC;KAC/C,YAAY,CAAC;IACZ,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7B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,EAAE,WAAW,CAAC,MAAM;QACpC,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC3C,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC3C,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS;QAChC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS;QAChC,qBAAqB,EAAE,CAAC,CAAC,SAAS,CAAC,qBAAqB;QACxD,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ;QAC9B,OAAO;QACP,aAAa,EAAE,CAAC,CAAC,SAAS;QAC1B,aAAa,EAAE,CAAC,CAAC,SAAS;QAC1B,QAAQ,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,8BAA8B,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE;QACtG,eAAe,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpC,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,YAAY,EAAE,CAAC,CAAC,aAAa;YAC7B,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,CAAE,CAAC,aAAa;YAC7F,SAAS,EAAE,CAAC,CAAC,SAAS;SACvB,CAAC,CAAC;KACJ,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;AAClF,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport { configurationGroupJournalContract, configurationGroupJournalSchema } from \"./configuration-group-contract.js\";\nimport { authorizeProcessGroupRuntime } from \"./process-group-authorization.js\";\nimport { processGroupManifestSchema } from \"./process-group-authorization.js\";\nimport {\n processGroupJournalContract,\n processGroupJournalSchema,\n processGroupSourceIdentity,\n resolvedProcessGroupChannels,\n} from \"./process-group-contract.js\";\nimport { groupPlacementSchema, placementKey } from \"./process-group-control-contract.js\";\nimport {\n groupArtifactHash,\n groupChannelsHash,\n configurationAuthorizationHash as hash,\n readProcessGroupResource as read,\n sha256,\n} from \"./process-group-resources.js\";\nimport { normalizeRuntimeProcessGroup, selectedProcessGroupDescriptor } from \"./process-group-runtime-selection.js\";\nimport type { GroupVersionUpgradeReview, PreparedGroupUpgrade, UpgradeConfiguration, UpgradeConfigurations } from \"./process-group-upgrade.js\";\n\nconst pair = z.strictObject({ publisher: groupPlacementSchema, receiver: groupPlacementSchema });\nexport const processGroupGenerationInputSchema = z\n .strictObject({\n protocolVersion: z.literal(2),\n source: pair,\n target: pair,\n acknowledgeInputPause: z.literal(true),\n acknowledgeResourceReview: z.literal(true),\n acknowledgePossibleReplay: z.literal(true),\n })\n .superRefine((v, c) => {\n const all = [v.source.publisher, v.source.receiver, v.target.publisher, v.target.receiver];\n if (\n new Set(all.map(placementKey)).size !== 4 ||\n all.some((p) => p.controller !== all[0]!.controller || p.rttNode !== all[0]!.rttNode) ||\n v.source.publisher.version !== v.source.receiver.version ||\n v.target.publisher.version !== v.target.receiver.version\n )\n c.addIssue({ code: \"custom\", message: \"Four distinct paired placements on one package/controller required\" });\n });\nexport type ProcessGroupGenerationInput = z.infer<typeof processGroupGenerationInputSchema>;\nexport type GenerationJournalReference = {\n directory: string;\n journalId: string;\n journalContractSha256: string;\n generationId: string;\n groupSha256?: string;\n contractVersion: 1 | 2;\n maxRecords: number;\n maxBytes: number;\n minFreeBytes: number;\n profiles: Array<{ processName: string; mappingSha256: string; dataGroup: string }>;\n};\nexport type GroupGenerationReview = Omit<GroupVersionUpgradeReview, \"protocolVersion\"> & {\n protocolVersion: 2;\n sourcePolicyFile: string;\n sourceJournal: GenerationJournalReference;\n targetJournal: GenerationJournalReference;\n delivery: { inputPausePossible: true; retainedBrokerSessionMayReplay: true; exactlyOnceOutput: false };\n resourceChanges: Array<{ processName: string; beforeSha256: string; afterSha256: string; dataGroup: string }>;\n};\n\n/** Bounded read-only storage evidence; no initializer, rewriting or replay. */\nexport function inspectGenerationJournal(reference: GenerationJournalReference) {\n const file = path.join(reference.directory, \"admission.sqlite\"),\n stat = fs.lstatSync(file);\n if (\n fs.realpathSync(file) !== file ||\n !stat.isFile() ||\n stat.nlink !== 1 ||\n stat.uid !== process.getuid?.() ||\n (stat.mode & 0o077) !== 0 ||\n stat.size > 512 * 1024 * 1024\n )\n throw Error(\"Private retained generation journal required\");\n const { DatabaseSync } = createRequire(import.meta.url)(\"node:sqlite\") as typeof import(\"node:sqlite\");\n const db = new DatabaseSync(file, { readOnly: true });\n try {\n db.exec(\"PRAGMA query_only=ON; PRAGMA busy_timeout=1000; BEGIN\");\n const meta = Object.fromEntries(\n db\n .prepare(\"SELECT key,value FROM metadata WHERE key IN ('id','contract')\")\n .all()\n .map((r) => [r[\"key\"], r[\"value\"]]),\n );\n if (\n meta[\"id\"] !== reference.journalId ||\n typeof meta[\"contract\"] !== \"string\" ||\n meta[\"contract\"].length > 1048576 ||\n sha256(meta[\"contract\"]) !== reference.journalContractSha256\n )\n throw Error(\"Reviewed journal generation changed\");\n const rows = db.prepare(\"SELECT name,contract,completed,last_seq FROM profiles ORDER BY name\").all();\n if (rows.length !== reference.profiles.length) throw Error(\"Journal profile set differs\");\n for (const profile of reference.profiles) {\n const row = rows.find((r) => r[\"name\"] === profile.processName),\n binding = row ? JSON.parse(String(row[\"contract\"])) : null;\n if (\n !binding ||\n binding.processName !== profile.processName ||\n binding.dataGroup !== profile.dataGroup ||\n binding[reference.contractVersion === 1 ? \"mappingSha256\" : \"resourceSha256\"] !== profile.mappingSha256\n )\n throw Error(\"Journal resource binding differs\");\n }\n const usage = db.prepare(\"SELECT records,bytes,admitted FROM usage WHERE id=1\").get();\n const actual = db.prepare(\"SELECT count(*) records,coalesce(sum(bytes),0) bytes FROM tasks\").get();\n const numbers = [usage?.[\"records\"], usage?.[\"bytes\"], usage?.[\"admitted\"], ...rows.flatMap((r) => [r[\"completed\"], r[\"last_seq\"]])];\n const completed = rows.reduce((n, r) => n + Number(r[\"completed\"]), 0);\n if (\n !usage ||\n !actual ||\n numbers.some((n) => typeof n !== \"number\" || !Number.isSafeInteger(n) || n < 0) ||\n usage[\"records\"] !== actual[\"records\"] ||\n usage[\"bytes\"] !== actual[\"bytes\"] ||\n !Number.isSafeInteger(completed) ||\n Number(usage[\"admitted\"]) !== completed + Number(usage[\"records\"]) ||\n rows.some((r) => (r[\"completed\"] === 0) !== (r[\"last_seq\"] === 0)) ||\n Number(usage[\"records\"]) > reference.maxRecords ||\n Number(usage[\"bytes\"]) > reference.maxBytes\n )\n throw Error(\"Journal usage is unconfirmed\");\n return {\n records: Number(usage[\"records\"]),\n bytes: Number(usage[\"bytes\"]),\n admitted: Number(usage[\"admitted\"]),\n completed,\n lastSequence: rows.reduce((n, r) => Math.max(n, Number(r[\"last_seq\"])), 0),\n };\n } finally {\n try {\n db.exec(\"ROLLBACK\");\n } finally {\n db.close();\n }\n }\n}\n\n/** Recheck immediately before the first launch; initialization is never silently reused. */\nexport function inspectPristineGenerationJournal(reference: GenerationJournalReference) {\n const status = inspectGenerationJournal(reference);\n if (status.records || status.bytes || status.admitted || status.completed || status.lastSequence)\n throw Error(\"Target generation is not pristine; inspect the existing initialization outcome\");\n return status;\n}\n\n/** Data-only normalized revision and immutable journal contract shared by reviewed transitions. */\nexport function describeInstalledProcessGroupGeneration(c: UpgradeConfiguration) {\n const d = selectedProcessGroupDescriptor(c.packageRoot, c.raw);\n if (!d) throw Error(\"Declared process group required\");\n const normalized = normalizeRuntimeProcessGroup(c.raw, d);\n if (!normalized.matches) throw Error(\"Runtime selector differs\");\n const channels = resolvedProcessGroupChannels(c.resolved),\n sourceIdentity = processGroupSourceIdentity(channels[1]!);\n if (d.protocolVersion === 2) {\n const snapshot = normalized.configurationSnapshot!;\n const journal = configurationGroupJournalSchema.parse(normalized.journal);\n const contract = configurationGroupJournalContract(\n snapshot,\n sourceIdentity,\n journal,\n snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup })),\n );\n return {\n d,\n normalized,\n channels,\n id: snapshot.group.id,\n processName: snapshot.group.processName,\n receiverProcessName: snapshot.group.receiverProcessName,\n inputTopic: snapshot.group.inputTopic,\n reference: {\n directory: journal.directory,\n journalId: journal.journalId!,\n generationId: journal.generationId,\n groupSha256: snapshot.sha256,\n contractVersion: 2 as const,\n journalContractSha256: sha256(contract),\n maxRecords: journal.maxRecords,\n maxBytes: journal.maxBytes,\n minFreeBytes: journal.minFreeBytes,\n profiles: snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, mappingSha256: resourceSha256, dataGroup })),\n },\n };\n }\n const journal = processGroupJournalSchema.parse(normalized.journal);\n if (!d.manifests.some((m) => m.file === journal.groupManifest)) throw Error(\"Registered file group required\");\n const group = processGroupManifestSchema.parse(JSON.parse(read(path.resolve(c.packageRoot, journal.groupManifest)).toString()));\n const contract = processGroupJournalContract(sourceIdentity, journal, group.profiles);\n return {\n d,\n normalized,\n channels,\n id: group.id,\n processName: group.processName,\n receiverProcessName: group.processName + \"-admission\",\n inputTopic: group.inputTopic,\n reference: {\n directory: journal.directory,\n journalId: journal.journalId!,\n generationId: group.id,\n contractVersion: 1 as const,\n journalContractSha256: sha256(contract),\n maxRecords: journal.maxRecords,\n maxBytes: journal.maxBytes,\n minFreeBytes: journal.minFreeBytes,\n profiles: group.profiles.map(({ processName, mappingSha256, dataGroup }) => ({ processName, mappingSha256, dataGroup })),\n },\n };\n}\n\n/** Operator reviews opaque before/after digests; business equivalence is application-owned. */\nexport function reviewInstalledProcessGroupGeneration(\n configs: UpgradeConfigurations,\n controllerName: string,\n stateRoot: string,\n excludedUnsFields: readonly string[] = [],\n): PreparedGroupUpgrade {\n const context = (c: UpgradeConfiguration) => ({\n packageRoot: c.packageRoot,\n instanceDirectory: c.instanceDirectory,\n rawConfiguration: c.raw,\n channels: resolvedProcessGroupChannels(c.resolved),\n controllerName,\n stateRoot,\n });\n const a = describeInstalledProcessGroupGeneration(configs.source.publisher),\n b = describeInstalledProcessGroupGeneration(configs.target.publisher);\n if (\n b.d.protocolVersion !== 2 ||\n a.d.namespace !== b.d.namespace ||\n a.id !== b.id ||\n a.processName !== b.processName ||\n a.receiverProcessName !== b.receiverProcessName ||\n a.inputTopic !== b.inputTopic ||\n a.reference.directory === b.reference.directory ||\n !a.reference.journalId ||\n !b.reference.journalId ||\n a.reference.journalId === b.reference.journalId ||\n a.reference.maxRecords !== b.reference.maxRecords ||\n a.reference.maxBytes !== b.reference.maxBytes ||\n a.reference.minFreeBytes !== b.reference.minFreeBytes\n )\n throw Error(\"Distinct bounded generations with the same process/input identity required\");\n const policyFiles = {} as Record<\"source\" | \"target\", string>,\n policies = {} as Record<\"source\" | \"target\", Buffer>;\n const members: GroupVersionUpgradeReview[\"members\"] = [];\n const portable = (raw: Record<string, unknown>, d: typeof a.d) => {\n const copy = structuredClone(raw),\n uns = { ...(copy[\"uns\"] as Record<string, unknown>) };\n for (const key of excludedUnsFields) delete uns[key];\n copy[\"uns\"] = uns;\n for (const keys of [d.publisherPath, d.journalPath, d.runtimeRolePath]) {\n let node = copy;\n let present = true;\n for (const key of keys.slice(0, -1)) {\n const child = node[key];\n if (child === undefined) {\n present = false;\n break;\n }\n if (!child || typeof child !== \"object\" || Array.isArray(child)) throw Error(\"Invalid resource selector parent\");\n node = child as Record<string, unknown>;\n }\n if (present) delete node[keys.at(-1)!];\n }\n return hash(copy);\n };\n for (const side of [\"source\", \"target\"] as const)\n for (const role of [\"publisher\", \"receiver\"] as const) {\n const c = configs[side][role],\n g = describeInstalledProcessGroupGeneration(c),\n expected = side === \"source\" ? a : b,\n proof = authorizeProcessGroupRuntime(context(c));\n if (\n proof.role !== (role === \"publisher\" ? \"target\" : \"receiver\") ||\n proof.directory !== expected.reference.directory ||\n proof.journalId !== expected.reference.journalId ||\n hash(g.reference) !== hash(expected.reference) ||\n g.normalized.uns[\"processName\"] !== (role === \"publisher\" ? g.processName : g.receiverProcessName) ||\n (role === \"receiver\"\n ? g.normalized.runtimeRole !== \"admission\"\n : g.normalized.runtimeRole !== undefined && g.normalized.runtimeRole !== \"publisher\")\n )\n throw Error(\"Exact reviewed generation pair required\");\n const pkg = JSON.parse(read(path.join(c.packageRoot, \"package.json\")).toString());\n if (\n pkg.name !== JSON.parse(read(path.join(configs.source.publisher.packageRoot, \"package.json\")).toString()).name ||\n portable(c.raw, g.d) !== portable(configs.source[role].raw, a.d) ||\n groupChannelsHash(g.channels) !== groupChannelsHash(a.channels)\n )\n throw Error(\"Configuration or broker identity changed outside the reviewed resources\");\n if (policyFiles[side] && policyFiles[side] !== proof.file) throw Error(\"Pair policies differ\");\n policyFiles[side] = proof.file;\n policies[side] = read(proof.file, true);\n members.push({\n side,\n role,\n processName: String(g.normalized.uns[\"processName\"]),\n configurationSha256: hash(c.raw),\n artifactSha256: groupArtifactHash(c.packageRoot),\n });\n }\n if (policyFiles.source === policyFiles.target) throw Error(\"Each generation requires its own retained policy\");\n const profiles = a.reference.profiles;\n if (\n profiles.length !== b.reference.profiles.length ||\n profiles.some((p) => !b.reference.profiles.some((q) => q.processName === p.processName && q.dataGroup === p.dataGroup))\n )\n throw Error(\"Logical profile identities or data groups changed\");\n inspectGenerationJournal(a.reference);\n inspectPristineGenerationJournal(b.reference);\n if (sha256(read(policyFiles.source, true)) !== sha256(policies.source) || sha256(read(policyFiles.target, true)) !== sha256(policies.target))\n throw Error(\"Reviewed policies changed\");\n const review: GroupGenerationReview = {\n protocolVersion: 2,\n namespace: b.d.namespace,\n groupId: b.id,\n policyFile: policyFiles.target,\n sourcePolicyFile: policyFiles.source,\n sourcePolicySha256: sha256(policies.source),\n targetPolicySha256: sha256(policies.target),\n journalId: b.reference.journalId,\n directory: b.reference.directory,\n journalContractSha256: b.reference.journalContractSha256,\n profiles: b.reference.profiles,\n members,\n sourceJournal: a.reference,\n targetJournal: b.reference,\n delivery: { inputPausePossible: true, retainedBrokerSessionMayReplay: true, exactlyOnceOutput: false },\n resourceChanges: profiles.map((p) => ({\n processName: p.processName,\n beforeSha256: p.mappingSha256,\n afterSha256: b.reference.profiles.find((q) => q.processName === p.processName)!.mappingSha256,\n dataGroup: p.dataGroup,\n })),\n };\n return { review, sourcePolicy: policies.source, targetPolicy: policies.target };\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  export interface ProcessGroupConfigurationEvidence {
2
+ configurationGroupSha256?: string;
3
+ generationId?: string;
2
4
  processName: string;
3
5
  configurationChecksum: string;
4
6
  projectionChecksum: string;
@@ -1 +1 @@
1
- {"version":3,"file":"process-group-inspection.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-inspection.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,iCAAiC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,aAAa,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;CACrJ;AA6BD,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,QAA2C,EACzD,OAAO,EAAE;IAAE,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACnG,iCAAiC,CA+InC"}
1
+ {"version":3,"file":"process-group-inspection.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-inspection.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,iCAAiC;IAChD,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,aAAa,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;CACrJ;AA6BD,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,QAA2C,EACzD,OAAO,EAAE;IAAE,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACnG,iCAAiC,CA8GnC"}
@@ -3,7 +3,9 @@ import fs from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
5
5
  import { z } from "zod";
6
+ import { configurationGroupJournalContract, configurationGroupJournalSchema, configurationResourceHash, selectedConfigurationGroup, } from "./configuration-group-contract.js";
6
7
  import { assertProcessGroupStateMount, authorizeConfiguredProcessGroupRuntime, configurationAuthorizationHash, hasProcessGroupAuthorization, processGroupManifestSchema as manifest, } from "./process-group-authorization.js";
8
+ import { readConfigurationSelector } from "./process-group-contract.js";
7
9
  import { isLocalPilotPath, isProcessGroupJournalPath, normalizeProcessGroupConfiguration, processGroupDescriptor, processGroupJournalContract, processGroupJournalSchema, processGroupSourceIdentity, projectProcessGroupConfiguration, resolvedProcessGroupInputChannel, } from "./process-group-contract.js";
8
10
  /** Bound reads to installed package/instance resources, never arbitrary paths or symlinks. */
9
11
  function resource(pkg, dir, file, relativeTo) {
@@ -40,6 +42,9 @@ function resource(pkg, dir, file, relativeTo) {
40
42
  const sha = (b) => createHash("sha256").update(b).digest("hex");
41
43
  export function inspectProcessGroupConfiguration(pkg, dir, raw, controllerName = process.env["UNS_CONTROLLER_NAME"] ?? "", options) {
42
44
  const original = JSON.parse(raw);
45
+ const configured = selectedConfigurationGroup(pkg, original);
46
+ if (configured)
47
+ return inspectConfigurationGroup(pkg, dir, raw, original, configured, controllerName, options);
43
48
  const descriptor = processGroupDescriptor(pkg);
44
49
  if (!descriptor)
45
50
  throw Error("Installed package has no supported process-group contract");
@@ -83,46 +88,7 @@ export function inspectProcessGroupConfiguration(pkg, dir, raw, controllerName =
83
88
  if (path.isAbsolute(admission.groupManifest) || admission.groupManifest.includes(".."))
84
89
  throw Error("Admission manifest must be package-relative");
85
90
  const admitted = manifest.parse(JSON.parse(resource(pkg, dir, admission.groupManifest).toString()));
86
- for (let parent = admission.directory; parent !== path.dirname(parent); parent = path.dirname(parent))
87
- if (fs.lstatSync(parent).isSymbolicLink())
88
- throw Error("Admission directory cannot use symbolic links");
89
- const databaseFile = path.join(admission.directory, "admission.sqlite");
90
- if (fs.lstatSync(databaseFile).isSymbolicLink())
91
- throw Error("Admission journal cannot use symbolic links");
92
- const { DatabaseSync } = createRequire(import.meta.url)("node:sqlite");
93
- const journal = new DatabaseSync(databaseFile, { readOnly: true });
94
- try {
95
- journal.exec("PRAGMA busy_timeout=1000");
96
- if (persistent && journal.prepare("SELECT value FROM metadata WHERE key='id'").get()?.["value"] !== admission.journalId)
97
- throw Error("Persistent admission journalId binding differs");
98
- const input = resolvedProcessGroupInputChannel(original);
99
- const sourceIdentity = processGroupSourceIdentity(input);
100
- const expected = processGroupJournalContract(sourceIdentity, admission, admitted.profiles);
101
- const contract = journal.prepare("SELECT value FROM metadata WHERE key='contract'").get()?.["value"];
102
- if (contract !== expected)
103
- throw Error("Durable admission journal contract differs");
104
- const capture = JSON.parse(String(journal.prepare("SELECT value FROM metadata WHERE key='capture'").get()?.["value"] ?? "null"));
105
- if (!capture ||
106
- !["ready", "capacity-blocked"].includes(capture.state) ||
107
- !Number.isSafeInteger(capture.pid) ||
108
- capture.pid <= 0 ||
109
- !Number.isSafeInteger(capture.heartbeat) ||
110
- Date.now() - capture.heartbeat > 5000 ||
111
- capture.heartbeat > Date.now() + 1000)
112
- throw Error("Durable admission receiver is not ready");
113
- process.kill(capture.pid, 0);
114
- if (persistent) {
115
- const namespace = sha(Buffer.from(fs.readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim() + ":" + fs.readlinkSync("/proc/self/ns/pid")));
116
- const stored = journal.prepare("SELECT value FROM metadata WHERE key='runtime_namespace'").get()?.["value"];
117
- const stat = fs.readFileSync(`/proc/${capture.pid}/stat`, "utf8");
118
- const start = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
119
- if (stored !== namespace || !start || capture.runtimeIdentity !== sha(Buffer.from(namespace + ":" + capture.pid + ":" + start)))
120
- throw Error("Admission capture namespace or process identity differs");
121
- }
122
- }
123
- finally {
124
- journal.close();
125
- }
91
+ inspectJournal(admission, persistent, processGroupJournalContract(processGroupSourceIdentity(resolvedProcessGroupInputChannel(original)), admission, admitted.profiles));
126
92
  if (publisher.groupManifest && publisher.groupManifest !== admission.groupManifest)
127
93
  throw Error("Admission and publisher manifests differ");
128
94
  if (!publisher.groupManifest) {
@@ -182,4 +148,118 @@ export function inspectProcessGroupConfiguration(pkg, dir, raw, controllerName =
182
148
  contract: null,
183
149
  };
184
150
  }
151
+ /** Shared read-only receiver/journal evidence for both resource protocols. */
152
+ function inspectJournal(admission, persistent, expected) {
153
+ for (let parent = admission.directory; parent !== path.dirname(parent); parent = path.dirname(parent))
154
+ if (fs.lstatSync(parent).isSymbolicLink())
155
+ throw Error("Admission directory cannot use symbolic links");
156
+ const databaseFile = path.join(admission.directory, "admission.sqlite");
157
+ if (fs.lstatSync(databaseFile).isSymbolicLink())
158
+ throw Error("Admission journal cannot use symbolic links");
159
+ const { DatabaseSync } = createRequire(import.meta.url)("node:sqlite");
160
+ const journal = new DatabaseSync(databaseFile, { readOnly: true });
161
+ try {
162
+ journal.exec("PRAGMA busy_timeout=1000");
163
+ if (persistent && journal.prepare("SELECT value FROM metadata WHERE key='id'").get()?.["value"] !== admission.journalId)
164
+ throw Error("Persistent admission journalId binding differs");
165
+ const contract = journal.prepare("SELECT value FROM metadata WHERE key='contract'").get()?.["value"];
166
+ if (contract !== expected)
167
+ throw Error("Durable admission journal contract differs");
168
+ const capture = JSON.parse(String(journal.prepare("SELECT value FROM metadata WHERE key='capture'").get()?.["value"] ?? "null"));
169
+ if (!capture ||
170
+ !["ready", "capacity-blocked"].includes(capture.state) ||
171
+ !Number.isSafeInteger(capture.pid) ||
172
+ capture.pid <= 0 ||
173
+ !Number.isSafeInteger(capture.heartbeat) ||
174
+ Date.now() - capture.heartbeat > 5000 ||
175
+ capture.heartbeat > Date.now() + 1000)
176
+ throw Error("Durable admission receiver is not ready");
177
+ process.kill(capture.pid, 0);
178
+ if (persistent) {
179
+ const namespace = sha(Buffer.from(fs.readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim() + ":" + fs.readlinkSync("/proc/self/ns/pid")));
180
+ const stored = journal.prepare("SELECT value FROM metadata WHERE key='runtime_namespace'").get()?.["value"];
181
+ const stat = fs.readFileSync(`/proc/${capture.pid}/stat`, "utf8");
182
+ const start = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
183
+ if (stored !== namespace || !start || capture.runtimeIdentity !== sha(Buffer.from(namespace + ":" + capture.pid + ":" + start)))
184
+ throw Error("Admission capture namespace or process identity differs");
185
+ }
186
+ }
187
+ finally {
188
+ journal.close();
189
+ }
190
+ }
191
+ function inspectConfigurationGroup(pkg, dir, raw, original, selected, controllerName, options) {
192
+ const { descriptor: d, snapshot } = selected;
193
+ const uns = { ...original["uns"] };
194
+ const memberId = readConfigurationSelector(original, d.memberPath), role = readConfigurationSelector(original, d.runtimeRolePath);
195
+ const member = memberId === undefined ? undefined : snapshot.profiles.find((p) => p.id === memberId);
196
+ if ((memberId !== undefined && !member) ||
197
+ uns["processName"] !== (member?.processName ?? snapshot.group.processName) ||
198
+ (role !== undefined && role !== "publisher"))
199
+ throw Error("Configured publisher role or identity differs");
200
+ const journal = configurationGroupJournalSchema
201
+ .extend({
202
+ minFreeBytes: configurationGroupJournalSchema.shape.minFreeBytes.unwrap().optional(),
203
+ maxRecords: configurationGroupJournalSchema.shape.maxRecords.unwrap(),
204
+ maxBytes: configurationGroupJournalSchema.shape.maxBytes.unwrap(),
205
+ })
206
+ .parse(readConfigurationSelector(original, d.journalPath));
207
+ const production = !isLocalPilotPath(pkg) || hasProcessGroupAuthorization() ? authorizeConfiguredProcessGroupRuntime(pkg, dir, original, controllerName) : undefined;
208
+ const persistent = !isLocalPilotPath(journal.directory);
209
+ if (production)
210
+ assertProcessGroupStateMount(production, process.env["UNS_PROCESS_GROUP_STATE_ROOT"] ?? "");
211
+ if (path.resolve(journal.directory) !== journal.directory || (production && !persistent))
212
+ throw Error("Configured journal storage differs");
213
+ if (persistent && (!production || !journal.journalId))
214
+ throw Error("Persistent configured journal requires exact reviewed authority and UUID");
215
+ const metadata = JSON.parse(resource(pkg, dir, "package.json").toString()).unsDatahub;
216
+ if (metadata?.processGroupAdmission !== 1 || (persistent && metadata?.processGroupPersistentAdmission !== 1))
217
+ throw Error("Required journal capabilities missing");
218
+ const expected = configurationGroupJournalContract(snapshot, processGroupSourceIdentity(resolvedProcessGroupInputChannel(original)), configurationGroupJournalSchema.parse(journal), snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup })));
219
+ inspectJournal(journal, persistent, expected);
220
+ const checksum = options.configurationChecksum(raw);
221
+ if (!checksum)
222
+ throw Error("Invalid configured group configuration");
223
+ for (const key of [...options.excludedUnsFields, "processName", "instanceMode", "handover", "handoverProtocol"])
224
+ delete uns[key];
225
+ const projection = structuredClone(original);
226
+ projection["uns"] = uns;
227
+ const remove = (keys) => {
228
+ let node = projection;
229
+ for (const key of keys.slice(0, -1)) {
230
+ const child = node[key];
231
+ if (child === undefined)
232
+ return;
233
+ if (!child || typeof child !== "object" || Array.isArray(child))
234
+ throw Error("Invalid selector projection");
235
+ node = child;
236
+ }
237
+ delete node[keys.at(-1)];
238
+ };
239
+ remove(d.memberPath);
240
+ remove(d.runtimeRolePath);
241
+ if (production)
242
+ projection["authorizationSha256"] = production.sha256;
243
+ return {
244
+ processName: String(original["uns"]["processName"]),
245
+ configurationChecksum: checksum,
246
+ projectionChecksum: configurationResourceHash(projection),
247
+ configurationGroupSha256: snapshot.sha256,
248
+ generationId: journal.generationId,
249
+ mappingSha256: member?.resourceSha256 ?? null,
250
+ dataGroup: member?.dataGroup ?? null,
251
+ contract: member
252
+ ? null
253
+ : {
254
+ digest: snapshot.sha256,
255
+ processName: snapshot.group.processName,
256
+ profiles: snapshot.profiles.map(({ id, processName, resourceSha256, dataGroup }) => ({
257
+ id,
258
+ processName,
259
+ mappingSha256: resourceSha256,
260
+ dataGroup,
261
+ })),
262
+ },
263
+ };
264
+ }
185
265
  //# sourceMappingURL=process-group-inspection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-group-inspection.js","sourceRoot":"","sources":["../../src/runtime/process-group-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5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AC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5H,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;IACzD,OAAO;QACL,WAAW;QACX,qBAAqB,EAAE,QAAQ;QAC/B,kBAAkB;QAClB,aAAa,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;QACrE,SAAS,EAAE,CAAC;aACT,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,KAAK,CAAC,SAAS,CAAC,SAAS,IAAI,UAAU,CAAC,gBAAgB,CAAC;QAC5D,QAAQ,EAAE,IAAI;KACf,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport {\n assertProcessGroupStateMount,\n authorizeConfiguredProcessGroupRuntime,\n configurationAuthorizationHash,\n hasProcessGroupAuthorization,\n processGroupManifestSchema as manifest,\n} from \"./process-group-authorization.js\";\nimport {\n isLocalPilotPath,\n isProcessGroupJournalPath,\n normalizeProcessGroupConfiguration,\n processGroupDescriptor,\n processGroupJournalContract,\n processGroupJournalSchema,\n processGroupSourceIdentity,\n projectProcessGroupConfiguration,\n resolvedProcessGroupInputChannel,\n} from \"./process-group-contract.js\";\n\nexport interface ProcessGroupConfigurationEvidence {\n processName: string;\n configurationChecksum: string;\n projectionChecksum: string;\n mappingSha256: string | null;\n dataGroup: string | null;\n contract: { digest: string; processName: string; profiles: { id: string; processName: string; mappingSha256: string; dataGroup: string }[] } | null;\n}\n/** Bound reads to installed package/instance resources, never arbitrary paths or symlinks. */\nfunction resource(pkg: string, dir: string, file: string, relativeTo?: string): Buffer {\n if (file.length > 512) throw Error(\"Group resource path too long\");\n const roots = [fs.realpathSync(pkg), fs.realpathSync(dir)];\n const candidates = relativeTo\n ? [path.resolve(relativeTo, file)]\n : path.isAbsolute(file)\n ? [file]\n : [path.resolve(dir, file), path.resolve(pkg, file)];\n for (const candidate of candidates) {\n if (!fs.existsSync(candidate)) continue;\n const real = fs.realpathSync(candidate);\n if (real !== candidate || !roots.some((root) => real.startsWith(root + path.sep)))\n throw Error(\"Group resource must stay inside installed package or instance\");\n const fd = fs.openSync(real, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n try {\n const s = fs.fstatSync(fd);\n if (!s.isFile() || s.size > 1048576) throw Error(\"Invalid group resource\");\n const b = fs.readFileSync(fd);\n if (b.length > 1048576) throw Error(\"Group resource too large\");\n return b;\n } finally {\n fs.closeSync(fd);\n }\n }\n throw Error(\"Installed group resource is missing\");\n}\nconst sha = (b: Buffer) => createHash(\"sha256\").update(b).digest(\"hex\");\nexport function inspectProcessGroupConfiguration(\n pkg: string,\n dir: string,\n raw: string,\n controllerName = process.env[\"UNS_CONTROLLER_NAME\"] ?? \"\",\n options: { configurationChecksum(raw: string): string | null; excludedUnsFields: readonly string[] },\n): ProcessGroupConfigurationEvidence {\n const original = JSON.parse(raw);\n const descriptor = processGroupDescriptor(pkg);\n if (!descriptor) throw Error(\"Installed package has no supported process-group contract\");\n const c = normalizeProcessGroupConfiguration(original, descriptor),\n uns = { ...c.uns },\n publisher = c.publisher;\n const production =\n c.journal && (!isLocalPilotPath(pkg) || hasProcessGroupAuthorization())\n ? authorizeConfiguredProcessGroupRuntime(pkg, dir, original, controllerName)\n : undefined;\n if (production) assertProcessGroupStateMount(production, process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"] ?? \"\");\n if (!c.matches || (c.runtimeRole !== undefined && c.runtimeRole !== \"publisher\") || !publisher || typeof uns.processName !== \"string\")\n throw Error(\"This runtime has no supported reviewed group configuration\");\n if (c.journal !== undefined) {\n // Readiness requires explicit capacities; their limits come from the shared writer schema.\n const admission = processGroupJournalSchema\n .extend({\n minFreeBytes: processGroupJournalSchema.shape.minFreeBytes.unwrap().optional(),\n maxRecords: processGroupJournalSchema.shape.maxRecords.unwrap(),\n maxBytes: processGroupJournalSchema.shape.maxBytes.unwrap(),\n })\n .parse(c.journal);\n if ((!isLocalPilotPath(pkg) && !production) || path.resolve(admission.directory) !== admission.directory)\n throw Error(\"Durable process-group admission is a same-host local pilot\");\n const persistent = !isLocalPilotPath(admission.directory);\n if (production && !persistent) throw Error(\"Authorized process-group journal requires a permanent mounted state root\");\n if (persistent) {\n const stateRoot = process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!admission.journalId) throw Error(\"Persistent admission needs its initialized journalId binding\");\n if (\n process.platform !== \"linux\" ||\n !stateRoot ||\n path.resolve(stateRoot) !== stateRoot ||\n !isProcessGroupJournalPath(stateRoot, admission.directory, descriptor.namespace)\n )\n throw Error(\"Persistent admission needs the reviewed Linux node-local state root\");\n if (JSON.parse(resource(pkg, dir, \"package.json\").toString()).unsDatahub?.processGroupPersistentAdmission !== 1)\n throw Error(\"Publisher does not support persistent admission ownership\");\n }\n const capability = JSON.parse(resource(pkg, dir, \"package.json\").toString()).unsDatahub?.processGroupAdmission;\n if (capability !== 1) throw Error(\"Publisher does not support durable process-group admission\");\n if (path.isAbsolute(admission.groupManifest) || admission.groupManifest.includes(\"..\"))\n throw Error(\"Admission manifest must be package-relative\");\n const admitted = manifest.parse(JSON.parse(resource(pkg, dir, admission.groupManifest).toString()));\n for (let parent = admission.directory; parent !== path.dirname(parent); parent = path.dirname(parent))\n if (fs.lstatSync(parent).isSymbolicLink()) throw Error(\"Admission directory cannot use symbolic links\");\n const databaseFile = path.join(admission.directory, \"admission.sqlite\");\n if (fs.lstatSync(databaseFile).isSymbolicLink()) throw Error(\"Admission journal cannot use symbolic links\");\n const { DatabaseSync } = createRequire(import.meta.url)(\"node:sqlite\") as typeof import(\"node:sqlite\");\n const journal = new DatabaseSync(databaseFile, { readOnly: true });\n try {\n journal.exec(\"PRAGMA busy_timeout=1000\");\n if (persistent && journal.prepare(\"SELECT value FROM metadata WHERE key='id'\").get()?.[\"value\"] !== admission.journalId)\n throw Error(\"Persistent admission journalId binding differs\");\n const input = resolvedProcessGroupInputChannel(original);\n const sourceIdentity = processGroupSourceIdentity(input);\n const expected = processGroupJournalContract(sourceIdentity, admission, admitted.profiles);\n const contract = journal.prepare(\"SELECT value FROM metadata WHERE key='contract'\").get()?.[\"value\"];\n if (contract !== expected) throw Error(\"Durable admission journal contract differs\");\n const capture = JSON.parse(String(journal.prepare(\"SELECT value FROM metadata WHERE key='capture'\").get()?.[\"value\"] ?? \"null\"));\n if (\n !capture ||\n ![\"ready\", \"capacity-blocked\"].includes(capture.state) ||\n !Number.isSafeInteger(capture.pid) ||\n capture.pid <= 0 ||\n !Number.isSafeInteger(capture.heartbeat) ||\n Date.now() - capture.heartbeat > 5000 ||\n capture.heartbeat > Date.now() + 1000\n )\n throw Error(\"Durable admission receiver is not ready\");\n process.kill(capture.pid, 0);\n if (persistent) {\n const namespace = sha(\n Buffer.from(fs.readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\").trim() + \":\" + fs.readlinkSync(\"/proc/self/ns/pid\")),\n );\n const stored = journal.prepare(\"SELECT value FROM metadata WHERE key='runtime_namespace'\").get()?.[\"value\"];\n const stat = fs.readFileSync(`/proc/${capture.pid}/stat`, \"utf8\");\n const start = stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \")[19];\n if (stored !== namespace || !start || capture.runtimeIdentity !== sha(Buffer.from(namespace + \":\" + capture.pid + \":\" + start)))\n throw Error(\"Admission capture namespace or process identity differs\");\n }\n } finally {\n journal.close();\n }\n if (publisher.groupManifest && publisher.groupManifest !== admission.groupManifest) throw Error(\"Admission and publisher manifests differ\");\n if (!publisher.groupManifest) {\n const member = admitted.profiles.find((p) => p.processName === uns.processName);\n if (\n !member ||\n member.mappingSha256 !== sha(resource(pkg, dir, String(publisher.mappingFile))) ||\n member.dataGroup !== (publisher.dataGroup ?? descriptor.defaultDataGroup)\n )\n throw Error(\"Original publisher differs from admission contract\");\n }\n }\n const checksum = options.configurationChecksum(raw);\n if (!checksum) throw Error(\"Invalid group configuration\");\n const processName = uns.processName;\n for (const k of [...options.excludedUnsFields, \"processName\", \"instanceMode\", \"handover\", \"handoverProtocol\"]) delete uns[k];\n const projectionChecksum = configurationAuthorizationHash(projectProcessGroupConfiguration(original, descriptor, uns, production?.sha256));\n if (typeof publisher.groupManifest === \"string\") {\n if (Object.keys(publisher).some((k) => k !== \"groupManifest\")) throw Error(\"Group selector cannot override member settings\");\n // Installed manifests are package-relative; members resolve relative to that exact file.\n if (path.isAbsolute(publisher.groupManifest) || publisher.groupManifest.includes(\"..\")) throw Error(\"Group manifest must be package-relative\");\n const bytes = resource(pkg, dir, path.resolve(pkg, publisher.groupManifest)),\n m = manifest.parse(JSON.parse(bytes.toString()));\n if (\n m.processName !== processName ||\n new Set(m.profiles.map((p) => p.processName)).size !== m.profiles.length ||\n m.profiles.some((p) => p.processName === processName)\n )\n throw Error(\"Manifest process identities overlap\");\n for (const p of m.profiles)\n if (sha(resource(pkg, dir, p.mappingFile, path.dirname(path.resolve(pkg, publisher.groupManifest)))) !== p.mappingSha256)\n throw Error(\"Manifest member checksum changed\");\n return {\n processName,\n configurationChecksum: checksum,\n projectionChecksum,\n mappingSha256: null,\n dataGroup: null,\n contract: {\n digest: sha(bytes),\n processName,\n profiles: m.profiles.map(({ mappingFile: _, ...p }) => p),\n },\n };\n }\n if (typeof publisher.mappingFile !== \"string\" || Object.keys(publisher).some((k) => ![\"mappingFile\", \"dataGroup\"].includes(k)))\n throw Error(\"Explicit original mapping file required\");\n return {\n processName,\n configurationChecksum: checksum,\n projectionChecksum,\n mappingSha256: sha(resource(pkg, dir, String(publisher.mappingFile))),\n dataGroup: z\n .string()\n .min(1)\n .max(100)\n .parse(publisher.dataGroup ?? descriptor.defaultDataGroup),\n contract: null,\n };\n}\n"]}
1
+ {"version":3,"file":"process-group-inspection.js","sourceRoot":"","sources":["../../src/runtime/process-group-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,iCAAiC,EACjC,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,EACtC,8BAA8B,EAC9B,4BAA4B,EAC5B,0BAA0B,IAAI,QAAQ,GACvC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,6BAA6B,CAAC;AAYrC,8FAA8F;AAC9F,SAAS,QAAQ,CAAC,GAAW,EAAE,GAAW,EAAE,IAAY,EAAE,UAAmB;IAC3E,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG;QAAE,MAAM,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,UAAU;QAC3B,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACrB,CAAC,CAAC,CAAC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AAW,EAAE,MAAM,CAAE,QAAQ,CAAC,KAAK,CAA6B,CAAC,aAAa,CAAC,CAAC;QAChF,qBAAqB,EAAE,QAAQ;QAC/B,kBAAkB,EAAE,yBAAyB,CAAC,UAAU,CAAC;QACzD,wBAAwB,EAAE,QAAQ,CAAC,MAAM;QACzC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,aAAa,EAAE,MAAM,EAAE,cAAc,IAAI,IAAI;QAC7C,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,IAAI;QACpC,QAAQ,EAAE,MAAM;YACd,CAAC,CAAC,IAAI;YACN,CAAC,CAAC;gBACE,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW;gBACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;oBACnF,EAAE;oBACF,WAAW;oBACX,aAAa,EAAE,cAAc;oBAC7B,SAAS;iBACV,CAAC,CAAC;aACJ;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport {\n configurationGroupJournalContract,\n configurationGroupJournalSchema,\n configurationResourceHash,\n selectedConfigurationGroup,\n} from \"./configuration-group-contract.js\";\nimport {\n assertProcessGroupStateMount,\n authorizeConfiguredProcessGroupRuntime,\n configurationAuthorizationHash,\n hasProcessGroupAuthorization,\n processGroupManifestSchema as manifest,\n} from \"./process-group-authorization.js\";\nimport { readConfigurationSelector } from \"./process-group-contract.js\";\nimport {\n isLocalPilotPath,\n isProcessGroupJournalPath,\n normalizeProcessGroupConfiguration,\n processGroupDescriptor,\n processGroupJournalContract,\n processGroupJournalSchema,\n processGroupSourceIdentity,\n projectProcessGroupConfiguration,\n resolvedProcessGroupInputChannel,\n} from \"./process-group-contract.js\";\n\nexport interface ProcessGroupConfigurationEvidence {\n configurationGroupSha256?: string;\n generationId?: string;\n processName: string;\n configurationChecksum: string;\n projectionChecksum: string;\n mappingSha256: string | null;\n dataGroup: string | null;\n contract: { digest: string; processName: string; profiles: { id: string; processName: string; mappingSha256: string; dataGroup: string }[] } | null;\n}\n/** Bound reads to installed package/instance resources, never arbitrary paths or symlinks. */\nfunction resource(pkg: string, dir: string, file: string, relativeTo?: string): Buffer {\n if (file.length > 512) throw Error(\"Group resource path too long\");\n const roots = [fs.realpathSync(pkg), fs.realpathSync(dir)];\n const candidates = relativeTo\n ? [path.resolve(relativeTo, file)]\n : path.isAbsolute(file)\n ? [file]\n : [path.resolve(dir, file), path.resolve(pkg, file)];\n for (const candidate of candidates) {\n if (!fs.existsSync(candidate)) continue;\n const real = fs.realpathSync(candidate);\n if (real !== candidate || !roots.some((root) => real.startsWith(root + path.sep)))\n throw Error(\"Group resource must stay inside installed package or instance\");\n const fd = fs.openSync(real, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n try {\n const s = fs.fstatSync(fd);\n if (!s.isFile() || s.size > 1048576) throw Error(\"Invalid group resource\");\n const b = fs.readFileSync(fd);\n if (b.length > 1048576) throw Error(\"Group resource too large\");\n return b;\n } finally {\n fs.closeSync(fd);\n }\n }\n throw Error(\"Installed group resource is missing\");\n}\nconst sha = (b: Buffer) => createHash(\"sha256\").update(b).digest(\"hex\");\nexport function inspectProcessGroupConfiguration(\n pkg: string,\n dir: string,\n raw: string,\n controllerName = process.env[\"UNS_CONTROLLER_NAME\"] ?? \"\",\n options: { configurationChecksum(raw: string): string | null; excludedUnsFields: readonly string[] },\n): ProcessGroupConfigurationEvidence {\n const original = JSON.parse(raw);\n const configured = selectedConfigurationGroup(pkg, original);\n if (configured) return inspectConfigurationGroup(pkg, dir, raw, original, configured, controllerName, options);\n const descriptor = processGroupDescriptor(pkg);\n if (!descriptor) throw Error(\"Installed package has no supported process-group contract\");\n const c = normalizeProcessGroupConfiguration(original, descriptor),\n uns = { ...c.uns },\n publisher = c.publisher;\n const production =\n c.journal && (!isLocalPilotPath(pkg) || hasProcessGroupAuthorization())\n ? authorizeConfiguredProcessGroupRuntime(pkg, dir, original, controllerName)\n : undefined;\n if (production) assertProcessGroupStateMount(production, process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"] ?? \"\");\n if (!c.matches || (c.runtimeRole !== undefined && c.runtimeRole !== \"publisher\") || !publisher || typeof uns.processName !== \"string\")\n throw Error(\"This runtime has no supported reviewed group configuration\");\n if (c.journal !== undefined) {\n // Readiness requires explicit capacities; their limits come from the shared writer schema.\n const admission = processGroupJournalSchema\n .extend({\n minFreeBytes: processGroupJournalSchema.shape.minFreeBytes.unwrap().optional(),\n maxRecords: processGroupJournalSchema.shape.maxRecords.unwrap(),\n maxBytes: processGroupJournalSchema.shape.maxBytes.unwrap(),\n })\n .parse(c.journal);\n if ((!isLocalPilotPath(pkg) && !production) || path.resolve(admission.directory) !== admission.directory)\n throw Error(\"Durable process-group admission is a same-host local pilot\");\n const persistent = !isLocalPilotPath(admission.directory);\n if (production && !persistent) throw Error(\"Authorized process-group journal requires a permanent mounted state root\");\n if (persistent) {\n const stateRoot = process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!admission.journalId) throw Error(\"Persistent admission needs its initialized journalId binding\");\n if (\n process.platform !== \"linux\" ||\n !stateRoot ||\n path.resolve(stateRoot) !== stateRoot ||\n !isProcessGroupJournalPath(stateRoot, admission.directory, descriptor.namespace)\n )\n throw Error(\"Persistent admission needs the reviewed Linux node-local state root\");\n if (JSON.parse(resource(pkg, dir, \"package.json\").toString()).unsDatahub?.processGroupPersistentAdmission !== 1)\n throw Error(\"Publisher does not support persistent admission ownership\");\n }\n const capability = JSON.parse(resource(pkg, dir, \"package.json\").toString()).unsDatahub?.processGroupAdmission;\n if (capability !== 1) throw Error(\"Publisher does not support durable process-group admission\");\n if (path.isAbsolute(admission.groupManifest) || admission.groupManifest.includes(\"..\"))\n throw Error(\"Admission manifest must be package-relative\");\n const admitted = manifest.parse(JSON.parse(resource(pkg, dir, admission.groupManifest).toString()));\n inspectJournal(\n admission,\n persistent,\n processGroupJournalContract(processGroupSourceIdentity(resolvedProcessGroupInputChannel(original)), admission, admitted.profiles),\n );\n if (publisher.groupManifest && publisher.groupManifest !== admission.groupManifest) throw Error(\"Admission and publisher manifests differ\");\n if (!publisher.groupManifest) {\n const member = admitted.profiles.find((p) => p.processName === uns.processName);\n if (\n !member ||\n member.mappingSha256 !== sha(resource(pkg, dir, String(publisher.mappingFile))) ||\n member.dataGroup !== (publisher.dataGroup ?? descriptor.defaultDataGroup)\n )\n throw Error(\"Original publisher differs from admission contract\");\n }\n }\n const checksum = options.configurationChecksum(raw);\n if (!checksum) throw Error(\"Invalid group configuration\");\n const processName = uns.processName;\n for (const k of [...options.excludedUnsFields, \"processName\", \"instanceMode\", \"handover\", \"handoverProtocol\"]) delete uns[k];\n const projectionChecksum = configurationAuthorizationHash(projectProcessGroupConfiguration(original, descriptor, uns, production?.sha256));\n if (typeof publisher.groupManifest === \"string\") {\n if (Object.keys(publisher).some((k) => k !== \"groupManifest\")) throw Error(\"Group selector cannot override member settings\");\n // Installed manifests are package-relative; members resolve relative to that exact file.\n if (path.isAbsolute(publisher.groupManifest) || publisher.groupManifest.includes(\"..\")) throw Error(\"Group manifest must be package-relative\");\n const bytes = resource(pkg, dir, path.resolve(pkg, publisher.groupManifest)),\n m = manifest.parse(JSON.parse(bytes.toString()));\n if (\n m.processName !== processName ||\n new Set(m.profiles.map((p) => p.processName)).size !== m.profiles.length ||\n m.profiles.some((p) => p.processName === processName)\n )\n throw Error(\"Manifest process identities overlap\");\n for (const p of m.profiles)\n if (sha(resource(pkg, dir, p.mappingFile, path.dirname(path.resolve(pkg, publisher.groupManifest)))) !== p.mappingSha256)\n throw Error(\"Manifest member checksum changed\");\n return {\n processName,\n configurationChecksum: checksum,\n projectionChecksum,\n mappingSha256: null,\n dataGroup: null,\n contract: {\n digest: sha(bytes),\n processName,\n profiles: m.profiles.map(({ mappingFile: _, ...p }) => p),\n },\n };\n }\n if (typeof publisher.mappingFile !== \"string\" || Object.keys(publisher).some((k) => ![\"mappingFile\", \"dataGroup\"].includes(k)))\n throw Error(\"Explicit original mapping file required\");\n return {\n processName,\n configurationChecksum: checksum,\n projectionChecksum,\n mappingSha256: sha(resource(pkg, dir, String(publisher.mappingFile))),\n dataGroup: z\n .string()\n .min(1)\n .max(100)\n .parse(publisher.dataGroup ?? descriptor.defaultDataGroup),\n contract: null,\n };\n}\n\n/** Shared read-only receiver/journal evidence for both resource protocols. */\nfunction inspectJournal(admission: { directory: string; journalId?: string | undefined }, persistent: boolean, expected: string): void {\n for (let parent = admission.directory; parent !== path.dirname(parent); parent = path.dirname(parent))\n if (fs.lstatSync(parent).isSymbolicLink()) throw Error(\"Admission directory cannot use symbolic links\");\n const databaseFile = path.join(admission.directory, \"admission.sqlite\");\n if (fs.lstatSync(databaseFile).isSymbolicLink()) throw Error(\"Admission journal cannot use symbolic links\");\n const { DatabaseSync } = createRequire(import.meta.url)(\"node:sqlite\") as typeof import(\"node:sqlite\");\n const journal = new DatabaseSync(databaseFile, { readOnly: true });\n try {\n journal.exec(\"PRAGMA busy_timeout=1000\");\n if (persistent && journal.prepare(\"SELECT value FROM metadata WHERE key='id'\").get()?.[\"value\"] !== admission.journalId)\n throw Error(\"Persistent admission journalId binding differs\");\n const contract = journal.prepare(\"SELECT value FROM metadata WHERE key='contract'\").get()?.[\"value\"];\n if (contract !== expected) throw Error(\"Durable admission journal contract differs\");\n const capture = JSON.parse(String(journal.prepare(\"SELECT value FROM metadata WHERE key='capture'\").get()?.[\"value\"] ?? \"null\"));\n if (\n !capture ||\n ![\"ready\", \"capacity-blocked\"].includes(capture.state) ||\n !Number.isSafeInteger(capture.pid) ||\n capture.pid <= 0 ||\n !Number.isSafeInteger(capture.heartbeat) ||\n Date.now() - capture.heartbeat > 5000 ||\n capture.heartbeat > Date.now() + 1000\n )\n throw Error(\"Durable admission receiver is not ready\");\n process.kill(capture.pid, 0);\n if (persistent) {\n const namespace = sha(\n Buffer.from(fs.readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\").trim() + \":\" + fs.readlinkSync(\"/proc/self/ns/pid\")),\n );\n const stored = journal.prepare(\"SELECT value FROM metadata WHERE key='runtime_namespace'\").get()?.[\"value\"];\n const stat = fs.readFileSync(`/proc/${capture.pid}/stat`, \"utf8\");\n const start = stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \")[19];\n if (stored !== namespace || !start || capture.runtimeIdentity !== sha(Buffer.from(namespace + \":\" + capture.pid + \":\" + start)))\n throw Error(\"Admission capture namespace or process identity differs\");\n }\n } finally {\n journal.close();\n }\n}\n\nfunction inspectConfigurationGroup(\n pkg: string,\n dir: string,\n raw: string,\n original: Record<string, unknown>,\n selected: NonNullable<ReturnType<typeof selectedConfigurationGroup>>,\n controllerName: string,\n options: { configurationChecksum(raw: string): string | null; excludedUnsFields: readonly string[] },\n): ProcessGroupConfigurationEvidence {\n const { descriptor: d, snapshot } = selected;\n const uns = { ...(original[\"uns\"] as Record<string, unknown>) };\n const memberId = readConfigurationSelector(original, d.memberPath),\n role = readConfigurationSelector(original, d.runtimeRolePath);\n const member = memberId === undefined ? undefined : snapshot.profiles.find((p) => p.id === memberId);\n if (\n (memberId !== undefined && !member) ||\n uns[\"processName\"] !== (member?.processName ?? snapshot.group.processName) ||\n (role !== undefined && role !== \"publisher\")\n )\n throw Error(\"Configured publisher role or identity differs\");\n const journal = configurationGroupJournalSchema\n .extend({\n minFreeBytes: configurationGroupJournalSchema.shape.minFreeBytes.unwrap().optional(),\n maxRecords: configurationGroupJournalSchema.shape.maxRecords.unwrap(),\n maxBytes: configurationGroupJournalSchema.shape.maxBytes.unwrap(),\n })\n .parse(readConfigurationSelector(original, d.journalPath));\n const production =\n !isLocalPilotPath(pkg) || hasProcessGroupAuthorization() ? authorizeConfiguredProcessGroupRuntime(pkg, dir, original, controllerName) : undefined;\n const persistent = !isLocalPilotPath(journal.directory);\n if (production) assertProcessGroupStateMount(production, process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"] ?? \"\");\n if (path.resolve(journal.directory) !== journal.directory || (production && !persistent)) throw Error(\"Configured journal storage differs\");\n if (persistent && (!production || !journal.journalId)) throw Error(\"Persistent configured journal requires exact reviewed authority and UUID\");\n const metadata = JSON.parse(resource(pkg, dir, \"package.json\").toString()).unsDatahub;\n if (metadata?.processGroupAdmission !== 1 || (persistent && metadata?.processGroupPersistentAdmission !== 1))\n throw Error(\"Required journal capabilities missing\");\n const expected = configurationGroupJournalContract(\n snapshot,\n processGroupSourceIdentity(resolvedProcessGroupInputChannel(original)),\n configurationGroupJournalSchema.parse(journal),\n snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup })),\n );\n inspectJournal(journal, persistent, expected);\n const checksum = options.configurationChecksum(raw);\n if (!checksum) throw Error(\"Invalid configured group configuration\");\n for (const key of [...options.excludedUnsFields, \"processName\", \"instanceMode\", \"handover\", \"handoverProtocol\"]) delete uns[key];\n const projection = structuredClone(original);\n projection[\"uns\"] = uns;\n const remove = (keys: readonly string[]) => {\n let node = projection;\n for (const key of keys.slice(0, -1)) {\n const child = node[key];\n if (child === undefined) return;\n if (!child || typeof child !== \"object\" || Array.isArray(child)) throw Error(\"Invalid selector projection\");\n node = child as Record<string, unknown>;\n }\n delete node[keys.at(-1)!];\n };\n remove(d.memberPath);\n remove(d.runtimeRolePath);\n if (production) projection[\"authorizationSha256\"] = production.sha256;\n return {\n processName: String((original[\"uns\"] as Record<string, unknown>)[\"processName\"]),\n configurationChecksum: checksum,\n projectionChecksum: configurationResourceHash(projection),\n configurationGroupSha256: snapshot.sha256,\n generationId: journal.generationId,\n mappingSha256: member?.resourceSha256 ?? null,\n dataGroup: member?.dataGroup ?? null,\n contract: member\n ? null\n : {\n digest: snapshot.sha256,\n processName: snapshot.group.processName,\n profiles: snapshot.profiles.map(({ id, processName, resourceSha256, dataGroup }) => ({\n id,\n processName,\n mappingSha256: resourceSha256,\n dataGroup,\n })),\n },\n };\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  export declare const sha256: (b: string | Buffer) => string;
2
2
  export declare const configurationAuthorizationHash: (v: unknown) => string;
3
+ export declare function assertPrivateProcessGroupDirectory(dir: string): void;
3
4
  export declare function readProcessGroupResource(file: string, privateFile?: boolean): Buffer;
4
5
  /** Pins metadata and compiled JS/JSON modules, not an installed dependency tree. */
5
6
  export declare function groupArtifactHash(root: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"process-group-resources.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-resources.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,GAAG,MAAM,WAAiD,CAAC;AAW3F,eAAO,MAAM,8BAA8B,GAAI,GAAG,OAAO,KAAG,MAA8C,CAAC;AAC3G,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,MAAM,CAelF;AACD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA+BtD;AACD,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAoB7D"}
1
+ {"version":3,"file":"process-group-resources.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-resources.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,GAAG,MAAM,WAAiD,CAAC;AAW3F,eAAO,MAAM,8BAA8B,GAAI,GAAG,OAAO,KAAG,MAA8C,CAAC;AAC3G,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKpE;AACD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,MAAM,CAelF;AACD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA+BtD;AACD,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAoB7D"}
@@ -12,6 +12,14 @@ function canonical(v) {
12
12
  : v;
13
13
  }
14
14
  export const configurationAuthorizationHash = (v) => sha256(JSON.stringify(canonical(v)));
15
+ export function assertPrivateProcessGroupDirectory(dir) {
16
+ for (let p = dir; p !== path.dirname(p); p = path.dirname(p))
17
+ if (fs.lstatSync(p).isSymbolicLink())
18
+ throw Error("Linked policy directory");
19
+ const s = fs.lstatSync(dir);
20
+ if (!s.isDirectory() || s.uid !== process.getuid?.() || (s.mode & 0o077) !== 0)
21
+ throw Error("Insecure policy directory");
22
+ }
15
23
  export function readProcessGroupResource(file, privateFile = false) {
16
24
  if (file.length > 512 || path.resolve(file) !== file)
17
25
  throw Error("Process-group authorization resource path is not normalized");
@@ -1 +1 @@
1
- {"version":3,"file":"process-group-resources.js","sourceRoot":"","sources":["../../src/runtime/process-group-resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3F,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAC/B,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,CAA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G,OAAO,8BAA8B,CACnC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,MAAM,CAAC,GAAG,KAAgC,CAAC;QAC3C,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;YAAE,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC3G,MAAM,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC;QACzC,OAAO;YACL,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YACvD,QAAQ;YACR,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE;YACvB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE;YAC3B,UAAU,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,IAAI;YACnC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,IAAI,IAAI;YACnD,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1D,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;SACjE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport const sha256 = (b: string | Buffer) => createHash(\"sha256\").update(b).digest(\"hex\");\nfunction canonical(v: unknown): unknown {\n if (Array.isArray(v)) return v.map(canonical);\n return v && typeof v === \"object\"\n ? Object.fromEntries(\n Object.entries(v)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, x]) => [k, canonical(x)]),\n )\n : v;\n}\nexport const configurationAuthorizationHash = (v: unknown): string => sha256(JSON.stringify(canonical(v)));\nexport function readProcessGroupResource(file: string, privateFile = false): Buffer {\n if (file.length > 512 || path.resolve(file) !== file) throw Error(\"Process-group authorization resource path is not normalized\");\n for (let p = file; p !== path.dirname(p); p = path.dirname(p))\n if (fs.lstatSync(p).isSymbolicLink()) throw Error(\"Process-group authorization resource cannot contain links\");\n const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n try {\n const s = fs.fstatSync(fd);\n if (!s.isFile() || s.size > 1048576 || s.nlink !== 1 || (privateFile && (s.uid !== process.getuid?.() || (s.mode & 0o077) !== 0)))\n throw Error(\"Process-group authorization resource is not a bounded private regular file\");\n const b = fs.readFileSync(fd);\n if (b.length > 1048576) throw Error(\"Process-group authorization resource too large\");\n return b;\n } finally {\n fs.closeSync(fd);\n }\n}\n/** Pins metadata and compiled JS/JSON modules, not an installed dependency tree. */\nexport function groupArtifactHash(root: string): string {\n const files = [\"package.json\"];\n let total = 0,\n entries = 0;\n const visit = (dir: string, depth = 0) => {\n if (depth > 32) throw Error(\"Process-group artifact directory depth exceeded\");\n const directory = fs.opendirSync(dir);\n try {\n let e;\n while ((e = directory.readSync())) {\n if (++entries > 4096) throw Error(\"Process-group artifact directory budget exceeded\");\n const f = path.join(dir, e.name);\n if (e.isSymbolicLink()) throw Error(\"Process-group artifact cannot contain links\");\n if (e.isDirectory()) visit(f, depth + 1);\n else if (e.isFile() && /\\.(?:[cm]?js|json)$/.test(e.name)) files.push(path.relative(root, f));\n if (files.length > 2048) throw Error(\"Process-group artifact file budget exceeded\");\n }\n } finally {\n directory.closeSync();\n }\n };\n visit(path.join(root, \"dist\"));\n if (files.length < 2) throw Error(\"Process-group compiled artifact is missing\");\n return configurationAuthorizationHash(\n files.sort().map((f) => {\n const b = readProcessGroupResource(path.join(root, f));\n total += b.length;\n if (total > 32 * 1024 * 1024) throw Error(\"Process-group artifact byte budget exceeded\");\n return [f, sha256(b)];\n }),\n );\n}\n/** Endpoint/TLS identity only; credentials never become a policy field or diagnostic. */\nexport function groupChannelsHash(channels: unknown[]): string {\n if (channels.length !== 3) throw Error(\"Process-group requires infra, input and output channel identities\");\n return configurationAuthorizationHash(\n channels.map((value) => {\n const c = value as Record<string, unknown>;\n if (typeof c[\"host\"] !== \"string\" || !c[\"host\"]) throw Error(\"Process-group broker host must be resolved\");\n const protocol = c[\"protocol\"] ?? \"mqtt\";\n return {\n host: c[\"host\"],\n port: c[\"port\"] ?? (protocol === \"mqtts\" ? 8883 : 1883),\n protocol,\n hosts: c[\"hosts\"] ?? [],\n servers: c[\"servers\"] ?? [],\n servername: c[\"servername\"] ?? null,\n rejectUnauthorized: c[\"rejectUnauthorized\"] ?? true,\n ca: c[\"ca\"] === undefined ? null : sha256(String(c[\"ca\"])),\n cert: c[\"cert\"] === undefined ? null : sha256(String(c[\"cert\"])),\n };\n }),\n );\n}\n"]}
1
+ {"version":3,"file":"process-group-resources.js","sourceRoot":"","sources":["../../src/runtime/process-group-resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3F,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9C,OAA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AAO,CAAC,IAAI,EAAE;YACvB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE;YAC3B,UAAU,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,IAAI;YACnC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,IAAI,IAAI;YACnD,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1D,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;SACjE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport const sha256 = (b: string | Buffer) => createHash(\"sha256\").update(b).digest(\"hex\");\nfunction canonical(v: unknown): unknown {\n if (Array.isArray(v)) return v.map(canonical);\n return v && typeof v === \"object\"\n ? Object.fromEntries(\n Object.entries(v)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, x]) => [k, canonical(x)]),\n )\n : v;\n}\nexport const configurationAuthorizationHash = (v: unknown): string => sha256(JSON.stringify(canonical(v)));\nexport function assertPrivateProcessGroupDirectory(dir: string): void {\n for (let p = dir; p !== path.dirname(p); p = path.dirname(p))\n if (fs.lstatSync(p).isSymbolicLink()) throw Error(\"Linked policy directory\");\n const s = fs.lstatSync(dir);\n if (!s.isDirectory() || s.uid !== process.getuid?.() || (s.mode & 0o077) !== 0) throw Error(\"Insecure policy directory\");\n}\nexport function readProcessGroupResource(file: string, privateFile = false): Buffer {\n if (file.length > 512 || path.resolve(file) !== file) throw Error(\"Process-group authorization resource path is not normalized\");\n for (let p = file; p !== path.dirname(p); p = path.dirname(p))\n if (fs.lstatSync(p).isSymbolicLink()) throw Error(\"Process-group authorization resource cannot contain links\");\n const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n try {\n const s = fs.fstatSync(fd);\n if (!s.isFile() || s.size > 1048576 || s.nlink !== 1 || (privateFile && (s.uid !== process.getuid?.() || (s.mode & 0o077) !== 0)))\n throw Error(\"Process-group authorization resource is not a bounded private regular file\");\n const b = fs.readFileSync(fd);\n if (b.length > 1048576) throw Error(\"Process-group authorization resource too large\");\n return b;\n } finally {\n fs.closeSync(fd);\n }\n}\n/** Pins metadata and compiled JS/JSON modules, not an installed dependency tree. */\nexport function groupArtifactHash(root: string): string {\n const files = [\"package.json\"];\n let total = 0,\n entries = 0;\n const visit = (dir: string, depth = 0) => {\n if (depth > 32) throw Error(\"Process-group artifact directory depth exceeded\");\n const directory = fs.opendirSync(dir);\n try {\n let e;\n while ((e = directory.readSync())) {\n if (++entries > 4096) throw Error(\"Process-group artifact directory budget exceeded\");\n const f = path.join(dir, e.name);\n if (e.isSymbolicLink()) throw Error(\"Process-group artifact cannot contain links\");\n if (e.isDirectory()) visit(f, depth + 1);\n else if (e.isFile() && /\\.(?:[cm]?js|json)$/.test(e.name)) files.push(path.relative(root, f));\n if (files.length > 2048) throw Error(\"Process-group artifact file budget exceeded\");\n }\n } finally {\n directory.closeSync();\n }\n };\n visit(path.join(root, \"dist\"));\n if (files.length < 2) throw Error(\"Process-group compiled artifact is missing\");\n return configurationAuthorizationHash(\n files.sort().map((f) => {\n const b = readProcessGroupResource(path.join(root, f));\n total += b.length;\n if (total > 32 * 1024 * 1024) throw Error(\"Process-group artifact byte budget exceeded\");\n return [f, sha256(b)];\n }),\n );\n}\n/** Endpoint/TLS identity only; credentials never become a policy field or diagnostic. */\nexport function groupChannelsHash(channels: unknown[]): string {\n if (channels.length !== 3) throw Error(\"Process-group requires infra, input and output channel identities\");\n return configurationAuthorizationHash(\n channels.map((value) => {\n const c = value as Record<string, unknown>;\n if (typeof c[\"host\"] !== \"string\" || !c[\"host\"]) throw Error(\"Process-group broker host must be resolved\");\n const protocol = c[\"protocol\"] ?? \"mqtt\";\n return {\n host: c[\"host\"],\n port: c[\"port\"] ?? (protocol === \"mqtts\" ? 8883 : 1883),\n protocol,\n hosts: c[\"hosts\"] ?? [],\n servers: c[\"servers\"] ?? [],\n servername: c[\"servername\"] ?? null,\n rejectUnauthorized: c[\"rejectUnauthorized\"] ?? true,\n ca: c[\"ca\"] === undefined ? null : sha256(String(c[\"ca\"])),\n cert: c[\"cert\"] === undefined ? null : sha256(String(c[\"cert\"])),\n };\n }),\n );\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { type ConfigurationGroupDescriptor } from "./configuration-group-contract.js";
2
+ import { type ProcessGroupRuntimeDescriptor } from "./process-group-contract.js";
3
+ export type RuntimeGroupDescriptor = ProcessGroupRuntimeDescriptor | ConfigurationGroupDescriptor;
4
+ /** Pick configuration resources only when explicitly selected; file consumers stay unchanged. */
5
+ export declare function selectedProcessGroupDescriptor(pkg: string, raw: Record<string, unknown>): RuntimeGroupDescriptor | undefined;
6
+ export declare function normalizeRuntimeProcessGroup(raw: Record<string, unknown>, descriptor: RuntimeGroupDescriptor): {
7
+ matches: boolean;
8
+ uns: Record<string, unknown>;
9
+ publisher: Record<string, unknown>;
10
+ journal: unknown;
11
+ runtimeRole: unknown;
12
+ configurationSnapshot: import("./configuration-group-contract.js").ConfigurationGroupSnapshot;
13
+ };
14
+ //# sourceMappingURL=process-group-runtime-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-group-runtime-selection.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-runtime-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAA4D,MAAM,mCAAmC,CAAC;AAChJ,OAAO,EACL,KAAK,6BAA6B,EAInC,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG,4BAA4B,CAAC;AAElG,iGAAiG;AACjG,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,GAAG,SAAS,CAI5H;AAED,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,sBAAsB;;SAW7F,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;eACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;EAKlD"}
@@ -0,0 +1,29 @@
1
+ import { configurationGroupDescriptor, configurationGroupSnapshot } from "./configuration-group-contract.js";
2
+ import { normalizeProcessGroupConfiguration, processGroupDescriptor, readConfigurationSelector, } from "./process-group-contract.js";
3
+ /** Pick configuration resources only when explicitly selected; file consumers stay unchanged. */
4
+ export function selectedProcessGroupDescriptor(pkg, raw) {
5
+ const configured = configurationGroupDescriptor(pkg);
6
+ if (configured && readConfigurationSelector(raw, configured.groupPath) !== undefined)
7
+ return configured;
8
+ return processGroupDescriptor(pkg);
9
+ }
10
+ export function normalizeRuntimeProcessGroup(raw, descriptor) {
11
+ if (descriptor.protocolVersion === 1)
12
+ return { ...normalizeProcessGroupConfiguration(raw, descriptor), configurationSnapshot: undefined };
13
+ const matches = !descriptor.match || readConfigurationSelector(raw, descriptor.match.path) === descriptor.match.value;
14
+ const snapshot = configurationGroupSnapshot(readConfigurationSelector(raw, descriptor.groupPath));
15
+ const runtimeRole = readConfigurationSelector(raw, descriptor.runtimeRolePath);
16
+ const publisher = readConfigurationSelector(raw, descriptor.publisherPath);
17
+ const uns = raw["uns"];
18
+ if (!uns || typeof uns !== "object" || Array.isArray(uns) || !publisher || typeof publisher !== "object" || Array.isArray(publisher))
19
+ throw Error("Explicit process-group publisher and identity required");
20
+ return {
21
+ matches,
22
+ uns: uns,
23
+ publisher: publisher,
24
+ journal: readConfigurationSelector(raw, descriptor.journalPath),
25
+ runtimeRole: runtimeRole === descriptor.receiverRole ? "admission" : runtimeRole,
26
+ configurationSnapshot: snapshot,
27
+ };
28
+ }
29
+ //# sourceMappingURL=process-group-runtime-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-group-runtime-selection.js","sourceRoot":"","sources":["../../src/runtime/process-group-runtime-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAChJ,OAAO,EAEL,kCAAkC,EAClC,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAIrC,iGAAiG;AACjG,MAAM,UAAU,8BAA8B,CAAC,GAAW,EAAE,GAA4B;IACtF,MAAM,UAAU,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,UAAU,IAAI,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IACxG,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,GAA4B,EAAE,UAAkC;IAC3G,IAAI,UAAU,CAAC,eAAe,KAAK,CAAC;QAAE,OAAO,EAAE,GAAG,kCAAkC,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,qBAAqB,EAAE,SAAS,EAAE,CAAC;IAC1I,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,IAAI,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;IACtH,MAAM,QAAQ,GAAG,0BAA0B,CAAC,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAClG,MAAM,WAAW,GAAG,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3E,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAClI,MAAM,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACxE,OAAO;QACL,OAAO;QACP,GAAG,EAAE,GAA8B;QACnC,SAAS,EAAE,SAAoC;QAC/C,OAAO,EAAE,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC;QAC/D,WAAW,EAAE,WAAW,KAAK,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;QAChF,qBAAqB,EAAE,QAAQ;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import { type ConfigurationGroupDescriptor, configurationGroupDescriptor, configurationGroupSnapshot } from \"./configuration-group-contract.js\";\nimport {\n type ProcessGroupRuntimeDescriptor,\n normalizeProcessGroupConfiguration,\n processGroupDescriptor,\n readConfigurationSelector,\n} from \"./process-group-contract.js\";\n\nexport type RuntimeGroupDescriptor = ProcessGroupRuntimeDescriptor | ConfigurationGroupDescriptor;\n\n/** Pick configuration resources only when explicitly selected; file consumers stay unchanged. */\nexport function selectedProcessGroupDescriptor(pkg: string, raw: Record<string, unknown>): RuntimeGroupDescriptor | undefined {\n const configured = configurationGroupDescriptor(pkg);\n if (configured && readConfigurationSelector(raw, configured.groupPath) !== undefined) return configured;\n return processGroupDescriptor(pkg);\n}\n\nexport function normalizeRuntimeProcessGroup(raw: Record<string, unknown>, descriptor: RuntimeGroupDescriptor) {\n if (descriptor.protocolVersion === 1) return { ...normalizeProcessGroupConfiguration(raw, descriptor), configurationSnapshot: undefined };\n const matches = !descriptor.match || readConfigurationSelector(raw, descriptor.match.path) === descriptor.match.value;\n const snapshot = configurationGroupSnapshot(readConfigurationSelector(raw, descriptor.groupPath));\n const runtimeRole = readConfigurationSelector(raw, descriptor.runtimeRolePath);\n const publisher = readConfigurationSelector(raw, descriptor.publisherPath);\n const uns = raw[\"uns\"];\n if (!uns || typeof uns !== \"object\" || Array.isArray(uns) || !publisher || typeof publisher !== \"object\" || Array.isArray(publisher))\n throw Error(\"Explicit process-group publisher and identity required\");\n return {\n matches,\n uns: uns as Record<string, unknown>,\n publisher: publisher as Record<string, unknown>,\n journal: readConfigurationSelector(raw, descriptor.journalPath),\n runtimeRole: runtimeRole === descriptor.receiverRole ? \"admission\" : runtimeRole,\n configurationSnapshot: snapshot,\n };\n}\n"]}