@uns-kit/core 3.0.27 → 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.
- package/MIGRATIONS.md +122 -0
- package/README.md +10 -0
- package/dist/config/app-config.d.ts +14 -0
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/configuration-group-authorization.d.ts +50 -0
- package/dist/runtime/configuration-group-authorization.d.ts.map +1 -0
- package/dist/runtime/configuration-group-authorization.js +113 -0
- package/dist/runtime/configuration-group-authorization.js.map +1 -0
- package/dist/runtime/configuration-group-contract.d.ts +75 -0
- package/dist/runtime/configuration-group-contract.d.ts.map +1 -0
- package/dist/runtime/configuration-group-contract.js +233 -0
- package/dist/runtime/configuration-group-contract.js.map +1 -0
- package/dist/runtime/process-group-authorization.d.ts +6 -0
- package/dist/runtime/process-group-authorization.d.ts.map +1 -1
- package/dist/runtime/process-group-authorization.js +56 -16
- package/dist/runtime/process-group-authorization.js.map +1 -1
- package/dist/runtime/process-group-backup-contract.d.ts +22 -0
- package/dist/runtime/process-group-backup-contract.d.ts.map +1 -0
- package/dist/runtime/process-group-backup-contract.js +20 -0
- package/dist/runtime/process-group-backup-contract.js.map +1 -0
- package/dist/runtime/process-group-backup-contract.json +7 -0
- package/dist/runtime/process-group-configured-upgrade.d.ts +4 -0
- package/dist/runtime/process-group-configured-upgrade.d.ts.map +1 -0
- package/dist/runtime/process-group-configured-upgrade.js +107 -0
- package/dist/runtime/process-group-configured-upgrade.js.map +1 -0
- package/dist/runtime/process-group-generation.d.ts +166 -0
- package/dist/runtime/process-group-generation.d.ts.map +1 -0
- package/dist/runtime/process-group-generation.js +278 -0
- package/dist/runtime/process-group-generation.js.map +1 -0
- package/dist/runtime/process-group-inspection.d.ts +2 -0
- package/dist/runtime/process-group-inspection.d.ts.map +1 -1
- package/dist/runtime/process-group-inspection.js +120 -40
- package/dist/runtime/process-group-inspection.js.map +1 -1
- package/dist/runtime/process-group-resources.d.ts +1 -0
- package/dist/runtime/process-group-resources.d.ts.map +1 -1
- package/dist/runtime/process-group-resources.js +8 -0
- package/dist/runtime/process-group-resources.js.map +1 -1
- package/dist/runtime/process-group-runtime-selection.d.ts +14 -0
- package/dist/runtime/process-group-runtime-selection.d.ts.map +1 -0
- package/dist/runtime/process-group-runtime-selection.js +29 -0
- package/dist/runtime/process-group-runtime-selection.js.map +1 -0
- package/dist/runtime/process-group-snapshot.mjs +60 -8
- package/dist/runtime/process-group-staging.d.ts +2 -2
- package/dist/runtime/process-group-staging.d.ts.map +1 -1
- package/dist/runtime/process-group-staging.js +6 -4
- package/dist/runtime/process-group-staging.js.map +1 -1
- package/dist/runtime/process-group-supervision.d.ts +2 -2
- package/dist/runtime/process-group-supervision.d.ts.map +1 -1
- package/dist/runtime/process-group-supervision.js +5 -3
- package/dist/runtime/process-group-supervision.js.map +1 -1
- package/dist/runtime/process-group-upgrade.d.ts +195 -0
- package/dist/runtime/process-group-upgrade.d.ts.map +1 -0
- package/dist/runtime/process-group-upgrade.js +262 -0
- package/dist/runtime/process-group-upgrade.js.map +1 -0
- package/dist/uns/uns-interfaces.d.ts +3 -0
- package/dist/uns/uns-interfaces.d.ts.map +1 -1
- package/dist/uns/uns-interfaces.js.map +1 -1
- package/dist/uns/uns-proxy-process.d.ts.map +1 -1
- package/dist/uns/uns-proxy-process.js +3 -0
- package/dist/uns/uns-proxy-process.js.map +1 -1
- package/dist/uns-config/config-schema.d.ts +16 -0
- package/dist/uns-config/config-schema.d.ts.map +1 -1
- package/dist/uns-config/mqtt-channel.d.ts +1 -1
- package/dist/uns-config/mqtt-channel.d.ts.map +1 -1
- package/dist/uns-config/mqtt-channel.js +3 -0
- package/dist/uns-config/mqtt-channel.js.map +1 -1
- package/dist/uns-config/uns-core-schema.d.ts +137 -0
- package/dist/uns-config/uns-core-schema.d.ts.map +1 -1
- package/dist/uns-config/uns-core-schema.js +6 -1
- package/dist/uns-config/uns-core-schema.js.map +1 -1
- package/dist/uns-mqtt/mqtt-interfaces.d.ts +5 -0
- package/dist/uns-mqtt/mqtt-interfaces.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-interfaces.js.map +1 -1
- package/dist/uns-mqtt/mqtt-proxy.d.ts +3 -0
- package/dist/uns-mqtt/mqtt-proxy.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-proxy.js +26 -1
- package/dist/uns-mqtt/mqtt-proxy.js.map +1 -1
- package/dist/uns-mqtt/mqtt-worker.d.ts +3 -1
- package/dist/uns-mqtt/mqtt-worker.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-worker.js +45 -8
- package/dist/uns-mqtt/mqtt-worker.js.map +1 -1
- package/dist/uns-mqtt/publish-queue-contract.d.ts +33 -0
- package/dist/uns-mqtt/publish-queue-contract.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue-contract.js +18 -0
- package/dist/uns-mqtt/publish-queue-contract.js.map +1 -0
- package/dist/uns-mqtt/publish-queue-store.d.ts +33 -0
- package/dist/uns-mqtt/publish-queue-store.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue-store.js +177 -0
- package/dist/uns-mqtt/publish-queue-store.js.map +1 -0
- package/dist/uns-mqtt/publish-queue.d.ts +43 -0
- package/dist/uns-mqtt/publish-queue.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue.js +235 -0
- package/dist/uns-mqtt/publish-queue.js.map +1 -0
- package/dist/uns-mqtt/uns-mqtt-proxy.d.ts +7 -0
- package/dist/uns-mqtt/uns-mqtt-proxy.d.ts.map +1 -1
- package/dist/uns-mqtt/uns-mqtt-proxy.js +98 -5
- package/dist/uns-mqtt/uns-mqtt-proxy.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-inspection.js","sourceRoot":"","sources":["../../src/run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AG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;aAC1D;SACF,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,SAAS,CAAC,WAAW,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,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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AC,CAAC,UAAU,CAAC,CAAC;IACrB,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IAC1B,IAAI,UAAU;QAAE,UAAU,CAAC,qBAAqB,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC;IACtE,OAAO;QACL,WAAW,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,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,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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,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 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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,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"]}
|
|
@@ -4,7 +4,16 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { DatabaseSync, backup } from "node:sqlite";
|
|
6
6
|
|
|
7
|
-
const [root, output] = process.argv.slice(2);
|
|
7
|
+
const [root, output, suppliedContract] = process.argv.slice(2);
|
|
8
|
+
// The host passes the fixed SDK contract, never request-controlled limits. Legacy
|
|
9
|
+
// two-argument callers retain their historical nine-journal bound.
|
|
10
|
+
const limits = suppliedContract === undefined
|
|
11
|
+
? {schemaVersion:1,maximumJournals:9,maximumManifestBytes:262144,maximumSnapshotBytes:536870912,maximumCapsuleBytes:1073741824}
|
|
12
|
+
: JSON.parse(suppliedContract);
|
|
13
|
+
if (JSON.stringify(Object.keys(limits).sort()) !== JSON.stringify(["schemaVersion","maximumJournals","maximumManifestBytes","maximumSnapshotBytes","maximumCapsuleBytes"].sort()) ||
|
|
14
|
+
limits.schemaVersion !== 1 || !Number.isSafeInteger(limits.maximumJournals) || limits.maximumJournals < 1 || limits.maximumJournals > 128 ||
|
|
15
|
+
limits.maximumManifestBytes !== 262144 || limits.maximumSnapshotBytes !== 536870912 || limits.maximumCapsuleBytes !== 1073741824)
|
|
16
|
+
throw Error("Unsupported fixed snapshot contract");
|
|
8
17
|
const hash = (b) => crypto.createHash("sha256").update(b).digest("hex");
|
|
9
18
|
const fileHash = (p) => {
|
|
10
19
|
const h = crypto.createHash("sha256"),
|
|
@@ -83,9 +92,9 @@ for (const namespace of namespaces) {
|
|
|
83
92
|
}
|
|
84
93
|
check(admittedRoot, true);
|
|
85
94
|
const groups = fs.readdirSync(admittedRoot).sort();
|
|
86
|
-
if (groups.length >
|
|
95
|
+
if (groups.length > limits.maximumJournals) fail();
|
|
87
96
|
for (const group of groups) {
|
|
88
|
-
if (!/^[a-z][a-z0-9-]{0,99}$/.test(group) || capturedGroups.has(group) || capturedGroups.size >=
|
|
97
|
+
if (!/^[a-z][a-z0-9-]{0,99}$/.test(group) || capturedGroups.has(group) || capturedGroups.size >= limits.maximumJournals) fail();
|
|
89
98
|
capturedGroups.add(group);
|
|
90
99
|
const source = path.join(admittedRoot, group);
|
|
91
100
|
check(source, true);
|
|
@@ -102,7 +111,7 @@ for (const namespace of namespaces) {
|
|
|
102
111
|
}
|
|
103
112
|
}, 0);
|
|
104
113
|
capturedBytes += sourceSize;
|
|
105
|
-
if (capturedBytes >
|
|
114
|
+
if (capturedBytes > limits.maximumSnapshotBytes) fail();
|
|
106
115
|
const space = fs.statfsSync(output, { bigint: true });
|
|
107
116
|
if (space.bavail * space.bsize < BigInt(sourceSize * 2 + 64 * 1024 * 1024)) fail();
|
|
108
117
|
const target = path.join(output, group);
|
|
@@ -123,7 +132,7 @@ for (const namespace of namespaces) {
|
|
|
123
132
|
space = fs.statfsSync(output, { bigint: true });
|
|
124
133
|
if (
|
|
125
134
|
!Number.isSafeInteger(bytes) ||
|
|
126
|
-
bytes >
|
|
135
|
+
bytes > limits.maximumSnapshotBytes - snapshotBytes ||
|
|
127
136
|
space.bavail * space.bsize < BigInt(bytes + 64 * 1024 * 1024)
|
|
128
137
|
)
|
|
129
138
|
fail();
|
|
@@ -148,7 +157,45 @@ for (const namespace of namespaces) {
|
|
|
148
157
|
if (!/^[0-9a-f-]{36}$/.test(meta.id ?? "")) fail();
|
|
149
158
|
const contract = JSON.parse(meta.contract);
|
|
150
159
|
const profiles = snap.prepare("SELECT name,contract,completed,last_seq FROM profiles ORDER BY name").all();
|
|
151
|
-
if (
|
|
160
|
+
if (
|
|
161
|
+
profiles.length < 1 ||
|
|
162
|
+
profiles.length > 19 ||
|
|
163
|
+
![1, 2].includes(contract.version) ||
|
|
164
|
+
!Array.isArray(contract.profiles) ||
|
|
165
|
+
contract.profiles.length !== profiles.length
|
|
166
|
+
)
|
|
167
|
+
fail();
|
|
168
|
+
if (contract.version === 2) {
|
|
169
|
+
if (
|
|
170
|
+
contract.generationId !== group ||
|
|
171
|
+
!/^[a-f0-9]{64}$/.test(contract.groupSha256 ?? "") ||
|
|
172
|
+
!/^[a-f0-9]{64}$/.test(contract.sourceIdentity ?? "") ||
|
|
173
|
+
profiles.length < 2 ||
|
|
174
|
+
profiles.length > 16 ||
|
|
175
|
+
new Set(contract.profiles.map((p) => p.processName)).size !== profiles.length ||
|
|
176
|
+
!Number.isSafeInteger(contract.maxRecords) ||
|
|
177
|
+
contract.maxRecords < 1 ||
|
|
178
|
+
contract.maxRecords > 100000 ||
|
|
179
|
+
!Number.isSafeInteger(contract.maxBytes) ||
|
|
180
|
+
contract.maxBytes < 1024 ||
|
|
181
|
+
contract.maxBytes > 256 * 1024 * 1024
|
|
182
|
+
)
|
|
183
|
+
fail();
|
|
184
|
+
for (const row of profiles) {
|
|
185
|
+
const binding = JSON.parse(row.contract),
|
|
186
|
+
expected = contract.profiles.find((p) => p.processName === row.name);
|
|
187
|
+
if (
|
|
188
|
+
!expected ||
|
|
189
|
+
!/^[a-z][a-z0-9-]{0,99}$/.test(row.name) ||
|
|
190
|
+
!/^[a-f0-9]{64}$/.test(expected.resourceSha256 ?? "") ||
|
|
191
|
+
!/^[a-z][a-z0-9-]{0,99}$/.test(expected.dataGroup ?? "") ||
|
|
192
|
+
binding.processName !== row.name ||
|
|
193
|
+
binding.resourceSha256 !== expected.resourceSha256 ||
|
|
194
|
+
binding.dataGroup !== expected.dataGroup
|
|
195
|
+
)
|
|
196
|
+
fail();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
152
199
|
const usage = snap.prepare("SELECT records,bytes,admitted FROM usage WHERE id=1").get();
|
|
153
200
|
const actual = snap.prepare("SELECT count(*) records,coalesce(sum(bytes),0) bytes FROM tasks").get();
|
|
154
201
|
if (
|
|
@@ -162,6 +209,9 @@ for (const namespace of namespaces) {
|
|
|
162
209
|
info = {
|
|
163
210
|
group,
|
|
164
211
|
namespace,
|
|
212
|
+
...(contract.version === 2
|
|
213
|
+
? { journalContractVersion: 2, generationId: contract.generationId, configurationGroupSha256: contract.groupSha256 }
|
|
214
|
+
: {}),
|
|
165
215
|
journalId: meta.id,
|
|
166
216
|
clientId: namespace + "-admission-" + meta.id,
|
|
167
217
|
contractSha256: hash(meta.contract),
|
|
@@ -187,7 +237,7 @@ for (const namespace of namespaces) {
|
|
|
187
237
|
fs.closeSync(fd);
|
|
188
238
|
}
|
|
189
239
|
snapshotBytes += fs.statSync(p).size;
|
|
190
|
-
if (snapshotBytes >
|
|
240
|
+
if (snapshotBytes > limits.maximumSnapshotBytes) fail();
|
|
191
241
|
info[name === "admission.sqlite" ? "admissionSha256" : "ownershipSha256"] = fileHash(p);
|
|
192
242
|
}
|
|
193
243
|
manifest.groups.push(info);
|
|
@@ -195,5 +245,7 @@ for (const namespace of namespaces) {
|
|
|
195
245
|
}
|
|
196
246
|
const remaining = fs.statfsSync(output, { bigint: true });
|
|
197
247
|
if (remaining.bavail * remaining.bsize < BigInt(snapshotBytes + 64 * 1024 * 1024)) fail();
|
|
198
|
-
|
|
248
|
+
const manifestBytes = JSON.stringify(manifest) + "\n";
|
|
249
|
+
if (Buffer.byteLength(manifestBytes) > limits.maximumManifestBytes) fail();
|
|
250
|
+
fs.writeFileSync(path.join(output, "manifest.json"), manifestBytes, { mode: 0o600, flag: "wx" });
|
|
199
251
|
// No source payloads, credentials, paths or process metadata on stdout/stderr.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RuntimeGroupDescriptor } from "./process-group-runtime-selection.js";
|
|
2
2
|
export declare const stagedJournalFile = "process-group-staged-journal.json";
|
|
3
3
|
/** An explicit, config-bound declaration, not permission to initialize or run. */
|
|
4
|
-
export declare function refreshProcessGroupStagedJournal(instanceDir: string, stopped: boolean, descriptor:
|
|
4
|
+
export declare function refreshProcessGroupStagedJournal(instanceDir: string, stopped: boolean, descriptor: RuntimeGroupDescriptor | undefined): void;
|
|
5
5
|
//# sourceMappingURL=process-group-staging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-staging.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-staging.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-group-staging.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-staging.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,sBAAsB,EAAgC,MAAM,sCAAsC,CAAC;AAEjH,eAAO,MAAM,iBAAiB,sCAAsC,CAAC;AACrE,kFAAkF;AAClF,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,GAAG,SAAS,GAAG,IAAI,CAoD5I"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { configurationGroupJournalSchema } from "./configuration-group-contract.js";
|
|
5
|
+
import { normalizeRuntimeProcessGroup } from "./process-group-runtime-selection.js";
|
|
5
6
|
export const stagedJournalFile = "process-group-staged-journal.json";
|
|
6
7
|
/** An explicit, config-bound declaration, not permission to initialize or run. */
|
|
7
8
|
export function refreshProcessGroupStagedJournal(instanceDir, stopped, descriptor) {
|
|
@@ -14,13 +15,14 @@ export function refreshProcessGroupStagedJournal(instanceDir, stopped, descripto
|
|
|
14
15
|
throw new Error("Staged configuration must be a bounded regular file.");
|
|
15
16
|
const raw = fs.readFileSync(configFile);
|
|
16
17
|
const config = JSON.parse(raw.toString("utf8"));
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
: undefined;
|
|
18
|
+
const selected = descriptor ? normalizeRuntimeProcessGroup(config, descriptor) : undefined;
|
|
19
|
+
const journal = selected?.journal;
|
|
20
20
|
if (!stopped || !journal || journal.journalId !== undefined) {
|
|
21
21
|
fs.rmSync(marker, { force: true });
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
+
if (selected?.configurationSnapshot && configurationGroupJournalSchema.parse(journal).groupSha256 !== selected.configurationSnapshot.sha256)
|
|
25
|
+
throw Error("Staged journal differs from its configured resource snapshot");
|
|
24
26
|
if (typeof journal.directory !== "string" || !path.isAbsolute(journal.directory) || path.normalize(journal.directory) !== journal.directory)
|
|
25
27
|
throw new Error("Staged journal requires a normalized absolute directory.");
|
|
26
28
|
// Existing/unknown data must never be declared uninitialized, including links.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-staging.js","sourceRoot":"","sources":["../../src/runtime/process-group-staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,
|
|
1
|
+
{"version":3,"file":"process-group-staging.js","sourceRoot":"","sources":["../../src/runtime/process-group-staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAA+B,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEjH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AACrE,kFAAkF;AAClF,MAAM,UAAU,gCAAgC,CAAC,WAAmB,EAAE,OAAgB,EAAE,UAA8C;IACpI,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO;IACvC,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,CAAC,IAAI,CAAC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AC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAC7C,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { configurationGroupJournalSchema } from \"./configuration-group-contract.js\";\nimport { type RuntimeGroupDescriptor, normalizeRuntimeProcessGroup } from \"./process-group-runtime-selection.js\";\n\nexport const stagedJournalFile = \"process-group-staged-journal.json\";\n/** An explicit, config-bound declaration, not permission to initialize or run. */\nexport function refreshProcessGroupStagedJournal(instanceDir: string, stopped: boolean, descriptor: RuntimeGroupDescriptor | undefined): void {\n const marker = path.join(instanceDir, stagedJournalFile);\n const configFile = path.join(instanceDir, \"config.json\");\n if (!fs.existsSync(configFile)) return;\n const stat = fs.lstatSync(configFile);\n if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1024 * 1024) throw new Error(\"Staged configuration must be a bounded regular file.\");\n const raw = fs.readFileSync(configFile);\n const config = JSON.parse(raw.toString(\"utf8\")) as Record<string, unknown>;\n const selected = descriptor ? normalizeRuntimeProcessGroup(config, descriptor) : undefined;\n const journal = selected?.journal as { directory?: unknown; journalId?: unknown } | undefined;\n if (!stopped || !journal || journal.journalId !== undefined) {\n fs.rmSync(marker, { force: true });\n return;\n }\n if (selected?.configurationSnapshot && configurationGroupJournalSchema.parse(journal).groupSha256 !== selected.configurationSnapshot.sha256)\n throw Error(\"Staged journal differs from its configured resource snapshot\");\n if (typeof journal.directory !== \"string\" || !path.isAbsolute(journal.directory) || path.normalize(journal.directory) !== journal.directory)\n throw new Error(\"Staged journal requires a normalized absolute directory.\");\n // Existing/unknown data must never be declared uninitialized, including links.\n for (let dir = journal.directory; dir !== path.dirname(dir); dir = path.dirname(dir)) {\n try {\n const stat = fs.lstatSync(dir);\n if (stat.isSymbolicLink() || dir === journal.directory) throw new Error(\"Existing journal cannot be marked uninitialized.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n }\n if (fs.existsSync(path.join(instanceDir, \"handover-source-guard.json.launch\")))\n throw new Error(\"A previously launched instance requires journal review.\");\n const temporary = marker + \".\" + randomUUID() + \".tmp\";\n const fd = fs.openSync(temporary, \"wx\", 0o600);\n try {\n fs.writeFileSync(\n fd,\n JSON.stringify({\n schemaVersion: 1,\n kind: \"uns-process-group-staged-journal\",\n configurationSha256: createHash(\"sha256\").update(raw).digest(\"hex\"),\n directory: journal.directory,\n }) + \"\\n\",\n );\n fs.fsyncSync(fd);\n } finally {\n fs.closeSync(fd);\n }\n fs.renameSync(temporary, marker);\n const parent = fs.openSync(instanceDir, \"r\");\n try {\n fs.fsyncSync(parent);\n } finally {\n fs.closeSync(parent);\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RuntimeGroupDescriptor } from "./process-group-runtime-selection.js";
|
|
2
2
|
/** SDK receiver contract; host launchers translate these neutral settings to PM2/systemd. */
|
|
3
|
-
export declare function processGroupReceiverSupervision(raw: Record<string, unknown>, descriptor:
|
|
3
|
+
export declare function processGroupReceiverSupervision(raw: Record<string, unknown>, descriptor: RuntimeGroupDescriptor | undefined, instanceDirectory: string, capabilities: {
|
|
4
4
|
supervised: boolean;
|
|
5
5
|
persistent: boolean;
|
|
6
6
|
authorized: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-supervision.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-supervision.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-group-supervision.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-supervision.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,sBAAsB,EAAgC,MAAM,sCAAsC,CAAC;AAEjH,6FAA6F;AAC7F,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,UAAU,EAAE,sBAAsB,GAAG,SAAS,EAC9C,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,EAC/E,UAAU,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAAC,kBAAkB,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACjH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA0BzB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isUnsupportedLegacyReceiver } from "./compatibility/energenti-descriptor-v1.js";
|
|
2
|
-
import { isLocalPilotPath
|
|
2
|
+
import { isLocalPilotPath } from "./process-group-contract.js";
|
|
3
|
+
import { normalizeRuntimeProcessGroup } from "./process-group-runtime-selection.js";
|
|
3
4
|
/** SDK receiver contract; host launchers translate these neutral settings to PM2/systemd. */
|
|
4
5
|
export function processGroupReceiverSupervision(raw, descriptor, instanceDirectory, capabilities, supervisor) {
|
|
5
6
|
if (!descriptor) {
|
|
@@ -7,7 +8,7 @@ export function processGroupReceiverSupervision(raw, descriptor, instanceDirecto
|
|
|
7
8
|
throw Error("Installed package has no supported receiver contract");
|
|
8
9
|
return {};
|
|
9
10
|
}
|
|
10
|
-
const c =
|
|
11
|
+
const c = normalizeRuntimeProcessGroup(raw, descriptor);
|
|
11
12
|
if (c.runtimeRole !== "admission")
|
|
12
13
|
return {};
|
|
13
14
|
if (!c.matches || !c.journal || (!isLocalPilotPath(instanceDirectory) && !capabilities.authorized))
|
|
@@ -24,7 +25,8 @@ export function processGroupReceiverSupervision(raw, descriptor, instanceDirecto
|
|
|
24
25
|
throw Error("Admission supervisor memory limit must be 128–4096 MiB");
|
|
25
26
|
return {
|
|
26
27
|
autorestart: true,
|
|
27
|
-
|
|
28
|
+
// Successful standalone/guarded shutdown and explicit contract refusal are terminal.
|
|
29
|
+
stop_exit_codes: [0, 78],
|
|
28
30
|
min_uptime: 10000,
|
|
29
31
|
max_restarts: 5,
|
|
30
32
|
exp_backoff_restart_delay: 1000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-supervision.js","sourceRoot":"","sources":["../../src/runtime/process-group-supervision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,
|
|
1
|
+
{"version":3,"file":"process-group-supervision.js","sourceRoot":"","sources":["../../src/runtime/process-group-supervision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAA+B,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEjH,6FAA6F;AAC7F,MAAM,UAAU,+BAA+B,CAC7C,GAA4B,EAC5B,UAA8C,EAC9C,iBAAyB,EACzB,YAA+E,EAC/E,UAAkH;IAElH,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,2BAA2B,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1G,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,CAAC,GAAG,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACxD,IAAI,CAAC,CAAC,WAAW,KAAK,WAAW;QAAE,OAAO,EAAE,CAAC;IAC7C,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QAChG,MAAM,KAAK,CAAC,sEAAsE,CAAC,CAAC;IACtF,IAAI,CAAC,YAAY,CAAC,UAAU;QAAE,MAAM,KAAK,CAAC,kEAAkE,CAAC,CAAC;IAC9G,MAAM,SAAS,GAAI,CAAC,CAAC,OAAmC,CAAC,WAAW,CAAC,CAAC;IACtE,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU;QAC3F,MAAM,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACnF,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,IAAI,UAAU,CAAC,kBAAkB;QACnF,MAAM,KAAK,CAAC,+FAA+F,CAAC,CAAC;IAC/G,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,IAAI,GAAG,CAAC;IAC1C,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,IAAI;QAAE,MAAM,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACnG,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,qFAAqF;QACrF,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACxB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,CAAC;QACf,yBAAyB,EAAE,IAAI;QAC/B,kBAAkB,EAAE,GAAG,GAAG,GAAG;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { isUnsupportedLegacyReceiver } from \"./compatibility/energenti-descriptor-v1.js\";\nimport { isLocalPilotPath } from \"./process-group-contract.js\";\nimport { type RuntimeGroupDescriptor, normalizeRuntimeProcessGroup } from \"./process-group-runtime-selection.js\";\n\n/** SDK receiver contract; host launchers translate these neutral settings to PM2/systemd. */\nexport function processGroupReceiverSupervision(\n raw: Record<string, unknown>,\n descriptor: RuntimeGroupDescriptor | undefined,\n instanceDirectory: string,\n capabilities: { supervised: boolean; persistent: boolean; authorized: boolean },\n supervisor: { enabled: boolean; restartOnExit: boolean; restartOnUnhealthy: boolean; maxMemoryMb?: number | null },\n): Record<string, unknown> {\n if (!descriptor) {\n if (isUnsupportedLegacyReceiver(raw)) throw Error(\"Installed package has no supported receiver contract\");\n return {};\n }\n const c = normalizeRuntimeProcessGroup(raw, descriptor);\n if (c.runtimeRole !== \"admission\") return {};\n if (!c.matches || !c.journal || (!isLocalPilotPath(instanceDirectory) && !capabilities.authorized))\n throw Error(\"Admission supervision requires an explicit reviewed journal instance\");\n if (!capabilities.supervised) throw Error(\"Installed package does not support the supervised admission role\");\n const directory = (c.journal as Record<string, unknown>)[\"directory\"];\n if (typeof directory === \"string\" && !isLocalPilotPath(directory) && !capabilities.persistent)\n throw Error(\"Installed package does not support persistent admission ownership\");\n if (!supervisor.enabled || !supervisor.restartOnExit || supervisor.restartOnUnhealthy)\n throw Error(\"Admission requires restart-on-exit supervision; generic MQTT unhealthy restart is unsupported\");\n const max = supervisor.maxMemoryMb ?? 256;\n if (max < 128 || max > 4096) throw Error(\"Admission supervisor memory limit must be 128–4096 MiB\");\n return {\n autorestart: true,\n // Successful standalone/guarded shutdown and explicit contract refusal are terminal.\n stop_exit_codes: [0, 78],\n min_uptime: 10000,\n max_restarts: 5,\n exp_backoff_restart_delay: 1000,\n max_memory_restart: `${max}M`,\n };\n}\n"]}
|