@wildo-ai/wildo-cli 1.1.12 → 1.1.13
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/dist/src/commands/config/sync.command.d.ts.map +1 -1
- package/dist/src/commands/config/sync.command.js +1 -0
- package/dist/src/commands/config/sync.command.js.map +1 -1
- package/dist/src/commands/context/journey.command.d.ts.map +1 -1
- package/dist/src/commands/context/journey.command.js +8 -0
- package/dist/src/commands/context/journey.command.js.map +1 -1
- package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
- package/dist/src/commands/creation/drive.command.js +2 -0
- package/dist/src/commands/creation/drive.command.js.map +1 -1
- package/dist/src/commands/fwk/publish-all.command.d.ts.map +1 -1
- package/dist/src/commands/fwk/publish-all.command.js +8 -0
- package/dist/src/commands/fwk/publish-all.command.js.map +1 -1
- package/dist/src/commands/local/dev.command.d.ts +68 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +216 -8
- package/dist/src/commands/local/dev.command.js.map +1 -1
- package/dist/src/commands/local/doctor.command.d.ts +22 -9
- package/dist/src/commands/local/doctor.command.d.ts.map +1 -1
- package/dist/src/commands/local/doctor.command.js +45 -42
- package/dist/src/commands/local/doctor.command.js.map +1 -1
- package/dist/src/commands/providers/connect.command.d.ts.map +1 -1
- package/dist/src/commands/providers/connect.command.js +11 -1
- package/dist/src/commands/providers/connect.command.js.map +1 -1
- package/dist/src/commands/seal/currency.command.d.ts +13 -0
- package/dist/src/commands/seal/currency.command.d.ts.map +1 -0
- package/dist/src/commands/seal/currency.command.js +52 -0
- package/dist/src/commands/seal/currency.command.js.map +1 -0
- package/dist/src/commands/seal/seal-admin-door.utils.d.ts.map +1 -1
- package/dist/src/commands/seal/seal-admin-door.utils.js +2 -0
- package/dist/src/commands/seal/seal-admin-door.utils.js.map +1 -1
- package/dist/src/commands/seal/verify.command.d.ts +5 -0
- package/dist/src/commands/seal/verify.command.d.ts.map +1 -1
- package/dist/src/commands/seal/verify.command.js +26 -2
- package/dist/src/commands/seal/verify.command.js.map +1 -1
- package/dist/src/services/application/content-guardrail-classifier.service.d.ts +19 -0
- package/dist/src/services/application/content-guardrail-classifier.service.d.ts.map +1 -1
- package/dist/src/services/application/content-guardrail-classifier.service.js +75 -11
- package/dist/src/services/application/content-guardrail-classifier.service.js.map +1 -1
- package/dist/src/services/application/local-provider-doubles.service.d.ts +98 -0
- package/dist/src/services/application/local-provider-doubles.service.d.ts.map +1 -0
- package/dist/src/services/application/local-provider-doubles.service.js +214 -0
- package/dist/src/services/application/local-provider-doubles.service.js.map +1 -0
- package/dist/src/services/application/system-of-record-simulators.service.d.ts +21 -2
- package/dist/src/services/application/system-of-record-simulators.service.d.ts.map +1 -1
- package/dist/src/services/application/system-of-record-simulators.service.js +21 -12
- package/dist/src/services/application/system-of-record-simulators.service.js.map +1 -1
- package/dist/src/services/companion/creation-drive.service.d.ts +32 -2
- package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
- package/dist/src/services/companion/creation-drive.service.js +61 -4
- package/dist/src/services/companion/creation-drive.service.js.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.d.ts +6 -0
- package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.js +7 -1
- package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js +11 -3
- package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
- package/dist/src/services/data-services/data-services.schemas.d.ts +9 -0
- package/dist/src/services/data-services/data-services.schemas.d.ts.map +1 -1
- package/dist/src/services/data-services/data-services.schemas.js +9 -0
- package/dist/src/services/data-services/data-services.schemas.js.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +7 -2
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.d.ts.map +1 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.js +22 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.js.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.js +1 -0
- package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
- package/dist/src/services/environment/authored-infra-member-authority.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-member-authority.js +5 -0
- package/dist/src/services/environment/authored-infra-member-authority.js.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.js +6 -3
- package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts +6 -0
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +24 -1
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/environment/environment-hydration.utils.d.ts.map +1 -1
- package/dist/src/services/environment/environment-hydration.utils.js +1 -0
- package/dist/src/services/environment/environment-hydration.utils.js.map +1 -1
- package/dist/src/services/environment/environment.schemas.d.ts +7 -1
- package/dist/src/services/environment/environment.schemas.d.ts.map +1 -1
- package/dist/src/services/environment/environment.schemas.js.map +1 -1
- package/dist/src/services/environment/runtime-bootstrap.service.d.ts +2 -0
- package/dist/src/services/environment/runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/environment/runtime-bootstrap.service.js +4 -0
- package/dist/src/services/environment/runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.d.ts +13 -0
- package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.js +24 -7
- package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
- package/dist/src/services/registry/provider-connect.service.d.ts +57 -1
- package/dist/src/services/registry/provider-connect.service.d.ts.map +1 -1
- package/dist/src/services/registry/provider-connect.service.js +63 -2
- package/dist/src/services/registry/provider-connect.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/scripts/app-dependency-alignment/propagated-engine-overrides.json +1 -1
- package/wildo-framework.info.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-session-lease.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-session-lease.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-dev-session-lease.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-session-lease.service.ts"],"names":[],"mappings":"AAwBA,UAAU,yBAAyB;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,qBAAa,iCAAkC,SAAQ,KAAK;aAC9B,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,IAAI;CAQvF;AAED;;;;;;;GAOG;AACH,qBAAa,2BAA2B;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C;IACjD,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,4BAA4B,CA4C/B"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, } from 'fs';
|
|
2
2
|
import { dirname, resolve } from 'path';
|
|
3
3
|
import { randomUUID } from 'crypto';
|
|
4
|
+
import { uptime } from 'os';
|
|
4
5
|
const LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION = 1;
|
|
5
6
|
const DEFAULT_HEARTBEAT_INTERVAL_MS = 5_000;
|
|
6
7
|
const DEFAULT_STALE_AFTER_MS = 120_000;
|
|
8
|
+
/**
|
|
9
|
+
* How much earlier than this boot an owner's `acquiredAt` must be before it is read as a previous boot's. The boot
|
|
10
|
+
* instant is derived from the uptime, to the second, and a clock may be stepped by NTP just after boot, so a lease taken
|
|
11
|
+
* in the first moments of a boot is never mistaken for an older one.
|
|
12
|
+
*/
|
|
13
|
+
const PREVIOUS_BOOT_MARGIN_MS = 60_000;
|
|
7
14
|
export class LocalDevSessionLeaseConflictError extends Error {
|
|
8
15
|
leasePath;
|
|
9
16
|
constructor(leasePath, owner) {
|
|
@@ -160,7 +167,7 @@ function acquireLeasePath(leasePath, ownerBase, staleAfterMs) {
|
|
|
160
167
|
continue;
|
|
161
168
|
throw error;
|
|
162
169
|
}
|
|
163
|
-
const ownerLiveness = owner ? probeProcessLiveness(owner.pid) : 'unknown';
|
|
170
|
+
const ownerLiveness = owner ? (acquiredBeforeThisBoot(owner) ? 'dead' : probeProcessLiveness(owner.pid)) : 'unknown';
|
|
164
171
|
// A delayed heartbeat is not proof that a live owner is abandoned. The
|
|
165
172
|
// CLI can legitimately block in Docker/platform startup longer than the
|
|
166
173
|
// stale window, so PID liveness always wins. Age-based recovery is only
|
|
@@ -223,6 +230,20 @@ function releaseLeasePath(leasePath, instanceId) {
|
|
|
223
230
|
throw error;
|
|
224
231
|
}
|
|
225
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Was this lease acquired before the machine last booted (#3204)? Then its owner is dead whatever its pid now names: a
|
|
235
|
+
* process does not survive a reboot, and after one the pid is free for any other process to hold, which
|
|
236
|
+
* {@link probeProcessLiveness} would report as alive. Measured on the reference runner: a run's lease (pid 6331) outlived
|
|
237
|
+
* a power-off, and the next run's `wildo local dev` refused to start because pid 6331 was now someone else's.
|
|
238
|
+
* Decided from `acquiredAt`, which every lease already records, so a lease written before this check is judged too.
|
|
239
|
+
*/
|
|
240
|
+
function acquiredBeforeThisBoot(owner) {
|
|
241
|
+
const acquiredAtMs = Date.parse(owner.acquiredAt);
|
|
242
|
+
if (!Number.isFinite(acquiredAtMs))
|
|
243
|
+
return false;
|
|
244
|
+
const bootedAtMs = Date.now() - uptime() * 1000;
|
|
245
|
+
return acquiredAtMs < bootedAtMs - PREVIOUS_BOOT_MARGIN_MS;
|
|
246
|
+
}
|
|
226
247
|
function probeProcessLiveness(pid) {
|
|
227
248
|
try {
|
|
228
249
|
process.kill(pid, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-session-lease.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-session-lease.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,IAAI,CAAC;AAC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,iFAAiF,GAAG,yCAAyC;kBAClI,sFAAsF;SAC3F,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,oBAAoB,CAAC,OAAO,EAAE,CAAC;QAClD,OAAO;YACL,MAAM,EAAE,oBAAoB,CAAC,MAAM;YACnC,KAAK;YACL,OAAO,EAAE,8EAA8E,GAAG,KAAK;kBAC3F,2FAA2F;SAChG,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACxB,OAAO;YACL,MAAM,EAAE,oBAAoB,CAAC,MAAM;YACnC,KAAK;YACL,OAAO,EAAE,8EAA8E,GAAG,aAAa;kBACnG,sGAAsG;kBACtG,qCAAqC;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,oBAAoB,CAAC,MAAM;QACnC,KAAK;QACL,OAAO,EAAE,iDAAiD,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,OAAO,wCAAwC;KAC9H,CAAC;AACJ,CAAC","sourcesContent":["import {\n chmodSync,\n existsSync,\n mkdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'fs';\nimport { dirname, resolve } from 'path';\nimport { randomUUID } from 'crypto';\n\nconst LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION = 1;\nconst DEFAULT_HEARTBEAT_INTERVAL_MS = 5_000;\nconst DEFAULT_STALE_AFTER_MS = 120_000;\n\ninterface LocalDevSessionLeaseOwner {\n readonly schemaVersion: number;\n readonly instanceId: string;\n readonly pid: number;\n readonly appRoot: string;\n readonly frameworkRoot: string | null;\n readonly ownsPlatform: boolean;\n readonly acquiredAt: string;\n readonly heartbeatAt: string;\n}\n\nexport interface LocalDevSessionLease {\n readonly instanceId: string;\n readonly leasePaths: readonly string[];\n release(): Promise<void>;\n}\n\nexport class LocalDevSessionLeaseConflictError extends Error {\n constructor(public readonly leasePath: string, owner: LocalDevSessionLeaseOwner | null) {\n super(\n owner\n ? `Another wildo local dev owner is active (pid ${owner.pid}, acquired ${owner.acquiredAt}).`\n : 'Another wildo local dev owner is active and its lease metadata is unavailable.',\n );\n this.name = 'LocalDevSessionLeaseConflictError';\n }\n}\n\n/**\n * Atomic ownership boundary for `wildo local dev`.\n *\n * Every invocation owns its app lease. An invocation that starts the shared\n * platform additionally owns the framework lease, preventing a second app from\n * cleaning or replacing that shared generation. Lease directories are acquired\n * in lexical path order, so multi-root acquisition cannot deadlock.\n */\nexport class LocalDevSessionLeaseService {\n static acquire(input: {\n saasRoot: string;\n frameworkRoot: string | null;\n ownsPlatform: boolean;\n heartbeatIntervalMs?: number;\n staleAfterMs?: number;\n onCompromised?: (error: Error) => void;\n }): LocalDevSessionLease {\n const instanceId = `${process.pid}-${Date.now()}-${randomUUID()}`;\n const acquiredAt = new Date().toISOString();\n const ownerBase = {\n schemaVersion: LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION,\n instanceId,\n pid: process.pid,\n appRoot: resolve(input.saasRoot),\n frameworkRoot: input.frameworkRoot ? resolve(input.frameworkRoot) : null,\n ownsPlatform: input.ownsPlatform,\n acquiredAt,\n };\n const leasePaths = resolveLocalDevSessionLeasePaths(input).sort();\n const acquiredPaths: string[] = [];\n const staleAfterMs = input.staleAfterMs ?? DEFAULT_STALE_AFTER_MS;\n\n try {\n for (const leasePath of leasePaths) {\n acquireLeasePath(leasePath, ownerBase, staleAfterMs);\n acquiredPaths.push(leasePath);\n }\n } catch (error) {\n for (const leasePath of acquiredPaths.reverse()) {\n releaseLeasePath(leasePath, instanceId);\n }\n throw error;\n }\n\n let compromised = false;\n const publishHeartbeat = () => {\n if (compromised) return;\n try {\n for (const leasePath of leasePaths) {\n const currentOwner = readLeaseOwner(leasePath);\n if (!currentOwner || currentOwner.instanceId !== instanceId) {\n throw new Error(`Local-dev lease ownership was replaced at '${leasePath}'.`);\n }\n writeLeaseOwner(leasePath, { ...ownerBase, heartbeatAt: new Date().toISOString() });\n }\n } catch (error) {\n compromised = true;\n clearInterval(heartbeat);\n try {\n input.onCompromised?.(error instanceof Error ? error : new Error(String(error)));\n } catch {\n // The timer boundary must never surface an uncaught exception. The\n // lease remains compromised and heartbeats stay stopped even if the\n // coordinator callback itself cannot report the failure.\n }\n }\n };\n const heartbeat = setInterval(publishHeartbeat, input.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS);\n heartbeat.unref();\n let released = false;\n\n return {\n instanceId,\n leasePaths,\n async release() {\n if (released) return;\n released = true;\n clearInterval(heartbeat);\n for (const leasePath of [...leasePaths].reverse()) {\n releaseLeasePath(leasePath, instanceId);\n }\n },\n };\n }\n}\n\n/** The live owner of the shared platform, as read from the framework-root platform lease. */\nexport interface LiveLocalDevPlatformOwner {\n readonly pid: number;\n readonly appRoot: string;\n readonly acquiredAt: string;\n readonly heartbeatAt: string;\n}\n\n/**\n * Who currently OWNS the shared local platform, or `null` when nobody live does.\n *\n * This is the predicate every lane that would CONVERGE shared substrate must consult before writing\n * (issue #50): the platform reconciliation in `local init`, the backing-container compose-up in\n * `local dev`, and the platform-service env regeneration in `config sync` each destroyed a RUNNING\n * stack on 2026-08-25 because they asserted platform ownership without asking. The lease is\n * heartbeated by the owning `wildo local dev` session every few seconds; an owner whose heartbeat is\n * older than `staleAfterMs` is treated as dead (same staleness window the acquisition path uses), so\n * a crashed owner never wedges initialization.\n */\nexport function readLiveLocalDevPlatformOwner(\n frameworkRoot: string,\n staleAfterMs: number = DEFAULT_STALE_AFTER_MS,\n): LiveLocalDevPlatformOwner | null {\n const leasePath = resolve(frameworkRoot, '.wildo-runtime-signals', 'ownership', 'local-dev-platform.lock');\n if (!existsSync(leasePath)) return null;\n const owner = readLeaseOwner(leasePath);\n if (!owner) return null;\n const heartbeatAtMs = Date.parse(owner.heartbeatAt);\n if (!Number.isFinite(heartbeatAtMs) || Date.now() - heartbeatAtMs >= staleAfterMs) return null;\n return { pid: owner.pid, appRoot: owner.appRoot, acquiredAt: owner.acquiredAt, heartbeatAt: owner.heartbeatAt };\n}\n\nexport function resolveLocalDevSessionLeasePaths(input: {\n saasRoot: string;\n frameworkRoot: string | null;\n ownsPlatform: boolean;\n}): string[] {\n const paths = [resolve(input.saasRoot, '.wildo-saas', 'runtime-signals', 'ownership', 'local-dev.lock')];\n if (input.ownsPlatform) {\n if (!input.frameworkRoot) {\n throw new Error('A platform-owning local-dev session requires a framework root.');\n }\n paths.push(resolve(input.frameworkRoot, '.wildo-runtime-signals', 'ownership', 'local-dev-platform.lock'));\n }\n return paths;\n}\n\nfunction acquireLeasePath(\n leasePath: string,\n ownerBase: Omit<LocalDevSessionLeaseOwner, 'heartbeatAt'>,\n staleAfterMs: number,\n): void {\n mkdirSync(dirname(leasePath), { recursive: true, mode: 0o700 });\n chmodSync(dirname(leasePath), 0o700);\n\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n mkdirSync(leasePath, { mode: 0o700 });\n try {\n chmodSync(leasePath, 0o700);\n writeLeaseOwner(leasePath, { ...ownerBase, heartbeatAt: new Date().toISOString() });\n return;\n } catch (error) {\n rmSync(leasePath, { recursive: true, force: true });\n throw error;\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n }\n\n const owner = readLeaseOwner(leasePath);\n let ageMs: number;\n try {\n ageMs = Date.now() - statSync(leasePath).mtimeMs;\n } catch (error) {\n // A previous owner may release between our EEXIST and metadata read.\n // Retry the atomic mkdir instead of turning that normal hand-off race\n // into a false startup failure.\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n const ownerLiveness = owner ? probeProcessLiveness(owner.pid) : 'unknown';\n // A delayed heartbeat is not proof that a live owner is abandoned. The\n // CLI can legitimately block in Docker/platform startup longer than the\n // stale window, so PID liveness always wins. Age-based recovery is only\n // permitted when metadata is unavailable; a confirmed-dead owner can be\n // reclaimed immediately.\n if ((owner && ownerLiveness !== 'dead') || (!owner && ageMs <= staleAfterMs)) {\n throw new LocalDevSessionLeaseConflictError(leasePath, owner);\n }\n\n const stalePath = `${leasePath}.stale-${process.pid}-${randomUUID()}`;\n try {\n renameSync(leasePath, stalePath);\n rmSync(stalePath, { recursive: true, force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n }\n throw new LocalDevSessionLeaseConflictError(leasePath, readLeaseOwner(leasePath));\n}\n\nfunction writeLeaseOwner(leasePath: string, owner: LocalDevSessionLeaseOwner): void {\n const ownerPath = resolve(leasePath, 'owner.json');\n const temporaryPath = `${ownerPath}.tmp-${process.pid}-${randomUUID()}`;\n writeFileSync(temporaryPath, `${JSON.stringify(owner, null, 2)}\\n`, { encoding: 'utf-8', mode: 0o600 });\n renameSync(temporaryPath, ownerPath);\n chmodSync(ownerPath, 0o600);\n}\n\nfunction readLeaseOwner(leasePath: string): LocalDevSessionLeaseOwner | null {\n try {\n const owner = JSON.parse(readFileSync(resolve(leasePath, 'owner.json'), 'utf-8')) as LocalDevSessionLeaseOwner;\n if (\n owner?.schemaVersion !== LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION\n || typeof owner.instanceId !== 'string'\n || !Number.isInteger(owner.pid) || owner.pid <= 0\n || typeof owner.appRoot !== 'string'\n || (owner.frameworkRoot !== null && typeof owner.frameworkRoot !== 'string')\n || typeof owner.ownsPlatform !== 'boolean'\n || typeof owner.acquiredAt !== 'string'\n || typeof owner.heartbeatAt !== 'string'\n ) {\n return null;\n }\n return owner;\n } catch {\n return null;\n }\n}\n\nfunction releaseLeasePath(leasePath: string, instanceId: string): void {\n if (!existsSync(leasePath)) return;\n const owner = readLeaseOwner(leasePath);\n if (!owner || owner.instanceId !== instanceId) return;\n const retiredPath = `${leasePath}.retired-${process.pid}-${randomUUID()}`;\n try {\n renameSync(leasePath, retiredPath);\n rmSync(retiredPath, { recursive: true, force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n}\n\nfunction probeProcessLiveness(pid: number): 'alive' | 'dead' | 'unknown' {\n try {\n process.kill(pid, 0);\n return 'alive';\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === 'EPERM') return 'alive';\n if (code === 'ESRCH') return 'dead';\n return 'unknown';\n }\n}\n\n/**\n * What a lane intends to do to the SHARED local platform. It is the only input that decides how a\n * foreign owner is treated, so a new lane declares its intent rather than re-deriving the policy.\n */\nexport enum SharedPlatformIntent {\n /**\n * Bring the shared containers up and leave them there — `local up`, `dev start`, the `local dev`\n * readiness converge. Harmless when nobody else is running, and a substrate swap when somebody is.\n */\n CONVERGE = 'converge',\n /**\n * Recreate, stop or destroy the shared containers — `local down`, `local reset` (and `local up\n * --rebuild`'s force-recreate until #2988 removed it). Never safe under a foreign owner at any running state.\n */\n DISRUPT = 'disrupt',\n}\n\n/** What a lane may do to the shared platform right now. */\nexport enum SharedPlatformAccess {\n /** Nobody else owns it. Proceed exactly as the lane would have without this check. */\n PROCEED = 'proceed',\n /** A foreign session owns it and its containers are up: use them, converge nothing. */\n ATTACH = 'attach',\n /** A foreign session owns it and this lane must not touch it. */\n REFUSE = 'refuse',\n}\n\nexport interface SharedPlatformAccessDecision {\n readonly access: SharedPlatformAccess;\n /** The owning session, when one is live and is a different app root. */\n readonly owner: LiveLocalDevPlatformOwner | null;\n /** Ready-to-print explanation for ATTACH and REFUSE. Absent for PROCEED. */\n readonly message?: string;\n}\n\n/**\n * Whether this lane may converge or disrupt the shared local platform right now.\n *\n * ## Why this is a function rather than a check each lane writes\n *\n * The platform stack is deliberately ONE-APP-AT-A-TIME: every application renders its compose under\n * the same project name with the same `wildo-*` container names and its OWN `local_data/` bind\n * mounts, and `--remove-orphans` is what stops a converge from leaving the previous app's extra\n * services running on the previous app's data (measured 2026-09-03 — a half-migrated stack with 18\n * cron jobs pointing at a vhost that existed only in the other app's broker state). So switching\n * applications re-homes the stack ON PURPOSE. What must not happen is re-homing it out from under a\n * session that is still using it.\n *\n * {@link readLiveLocalDevPlatformOwner} has answered that since issue #50, and its own docstring\n * named the three lanes that must consult it. **It was reached from three of the SEVEN lanes that\n * mutate the shared stack** — measured 2026-09-15 (#1126): `local up`, `local up --rebuild`,\n * `local down`, `local reset` and `dev start` all converged or tore down without asking. The\n * observed cost was a running `wildo local dev` losing `wildo-postgresql`, `wildo-clamav`,\n * `wildo-immudb` and `wildo-otel-collector` to another application's `wildo local up`, and then\n * failing to boot with an error naming neither the other application nor the deletion. `local\n * reset`'s `down -v` would have taken the volumes.\n *\n * That is `.claude/rules/invariant-call-site-enumeration.md`'s defect shape exactly — the invariant\n * applied at some of its sites — so the remedy is the one that rule prefers: ONE predicate every\n * lane declares its intent to, rather than the same condition hand-written six more times.\n *\n * @param infraRunning Whether the shared containers are currently up. Only consulted for\n * {@link SharedPlatformIntent.CONVERGE}: an owner whose containers are gone cannot be attached to,\n * and starting them from this app root is the substrate swap the check exists to prevent.\n * @param acknowledgedForeignOwner The operator has stated, on this invocation, that they intend to\n * take the shared platform from its current owner. The refusal is the DEFAULT and the door is\n * explicit, narrow and per-invocation — `design-philosophy.md`, \"immutability needs a paired\n * mutation path\". A lane that offers no such flag passes `false`.\n */\nexport function decideSharedPlatformAccess(input: {\n frameworkRoot: string | null;\n saasRoot: string;\n intent: SharedPlatformIntent;\n infraRunning: boolean;\n acknowledgedForeignOwner?: boolean;\n staleAfterMs?: number;\n}): SharedPlatformAccessDecision {\n const owner = input.frameworkRoot\n ? readLiveLocalDevPlatformOwner(input.frameworkRoot, input.staleAfterMs)\n : null;\n // An owner at THIS app root is this application's own session: converging its own substrate is\n // what it is for, and re-homing is not in question.\n if (!owner || resolve(owner.appRoot) === resolve(input.saasRoot)) {\n return { access: SharedPlatformAccess.PROCEED, owner: null };\n }\n\n const who = `pid ${owner.pid}, app ${owner.appRoot}`;\n if (input.acknowledgedForeignOwner === true) {\n return {\n access: SharedPlatformAccess.PROCEED,\n owner,\n message: `Taking the shared platform from the \\`wildo local dev\\` session that owns it (${who}), as acknowledged on this invocation. `\n + 'That session\\'s processes are now running against a substrate this app root defines.',\n };\n }\n\n if (input.intent === SharedPlatformIntent.DISRUPT) {\n return {\n access: SharedPlatformAccess.REFUSE,\n owner,\n message: `The shared local platform is owned by another \\`wildo local dev\\` session (${who}). `\n + 'Refusing to recreate or stop its containers from this app root — stop that session first.',\n };\n }\n\n if (!input.infraRunning) {\n return {\n access: SharedPlatformAccess.REFUSE,\n owner,\n message: `The shared local platform is owned by another \\`wildo local dev\\` session (${who}), but its `\n + 'infrastructure containers are not running. Refusing to start shared containers from this app root — '\n + 'start them from the owning session.',\n };\n }\n\n return {\n access: SharedPlatformAccess.ATTACH,\n owner,\n message: `Attaching to the shared platform owned by pid ${owner.pid} (${owner.appRoot}); infrastructure convergence skipped.`,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"local-dev-session-lease.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-session-lease.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,MAAM,sCAAsC,GAAG,CAAC,CAAC;AACjD,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAC5C,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAmBvC,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAC9B;IAA5B,YAA4B,SAAiB,EAAE,KAAuC;QACpF,KAAK,CACH,KAAK;YACH,CAAC,CAAC,gDAAgD,KAAK,CAAC,GAAG,cAAc,KAAK,CAAC,UAAU,IAAI;YAC7F,CAAC,CAAC,gFAAgF,CACrF,CAAC;QALwB,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yCAAyC;kBAClI,sFAAsF;SAC3F,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,oBAAoB,CAAC,OAAO,EAAE,CAAC;QAClD,OAAO;YACL,MAAM,EAAE,oBAAoB,CAAC,MAAM;YACnC,KAAK;YACL,OAAO,EAAE,8EAA8E,GAAG,KAAK;kBAC3F,2FAA2F;SAChG,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACxB,OAAO;YACL,MAAM,EAAE,oBAAoB,CAAC,MAAM;YACnC,KAAK;YACL,OAAO,EAAE,8EAA8E,GAAG,aAAa;kBACnG,sGAAsG;kBACtG,qCAAqC;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,oBAAoB,CAAC,MAAM;QACnC,KAAK;QACL,OAAO,EAAE,iDAAiD,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,OAAO,wCAAwC;KAC9H,CAAC;AACJ,CAAC","sourcesContent":["import {\n chmodSync,\n existsSync,\n mkdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'fs';\nimport { dirname, resolve } from 'path';\nimport { randomUUID } from 'crypto';\nimport { uptime } from 'os';\n\nconst LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION = 1;\nconst DEFAULT_HEARTBEAT_INTERVAL_MS = 5_000;\nconst DEFAULT_STALE_AFTER_MS = 120_000;\n/**\n * How much earlier than this boot an owner's `acquiredAt` must be before it is read as a previous boot's. The boot\n * instant is derived from the uptime, to the second, and a clock may be stepped by NTP just after boot, so a lease taken\n * in the first moments of a boot is never mistaken for an older one.\n */\nconst PREVIOUS_BOOT_MARGIN_MS = 60_000;\n\ninterface LocalDevSessionLeaseOwner {\n readonly schemaVersion: number;\n readonly instanceId: string;\n readonly pid: number;\n readonly appRoot: string;\n readonly frameworkRoot: string | null;\n readonly ownsPlatform: boolean;\n readonly acquiredAt: string;\n readonly heartbeatAt: string;\n}\n\nexport interface LocalDevSessionLease {\n readonly instanceId: string;\n readonly leasePaths: readonly string[];\n release(): Promise<void>;\n}\n\nexport class LocalDevSessionLeaseConflictError extends Error {\n constructor(public readonly leasePath: string, owner: LocalDevSessionLeaseOwner | null) {\n super(\n owner\n ? `Another wildo local dev owner is active (pid ${owner.pid}, acquired ${owner.acquiredAt}).`\n : 'Another wildo local dev owner is active and its lease metadata is unavailable.',\n );\n this.name = 'LocalDevSessionLeaseConflictError';\n }\n}\n\n/**\n * Atomic ownership boundary for `wildo local dev`.\n *\n * Every invocation owns its app lease. An invocation that starts the shared\n * platform additionally owns the framework lease, preventing a second app from\n * cleaning or replacing that shared generation. Lease directories are acquired\n * in lexical path order, so multi-root acquisition cannot deadlock.\n */\nexport class LocalDevSessionLeaseService {\n static acquire(input: {\n saasRoot: string;\n frameworkRoot: string | null;\n ownsPlatform: boolean;\n heartbeatIntervalMs?: number;\n staleAfterMs?: number;\n onCompromised?: (error: Error) => void;\n }): LocalDevSessionLease {\n const instanceId = `${process.pid}-${Date.now()}-${randomUUID()}`;\n const acquiredAt = new Date().toISOString();\n const ownerBase = {\n schemaVersion: LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION,\n instanceId,\n pid: process.pid,\n appRoot: resolve(input.saasRoot),\n frameworkRoot: input.frameworkRoot ? resolve(input.frameworkRoot) : null,\n ownsPlatform: input.ownsPlatform,\n acquiredAt,\n };\n const leasePaths = resolveLocalDevSessionLeasePaths(input).sort();\n const acquiredPaths: string[] = [];\n const staleAfterMs = input.staleAfterMs ?? DEFAULT_STALE_AFTER_MS;\n\n try {\n for (const leasePath of leasePaths) {\n acquireLeasePath(leasePath, ownerBase, staleAfterMs);\n acquiredPaths.push(leasePath);\n }\n } catch (error) {\n for (const leasePath of acquiredPaths.reverse()) {\n releaseLeasePath(leasePath, instanceId);\n }\n throw error;\n }\n\n let compromised = false;\n const publishHeartbeat = () => {\n if (compromised) return;\n try {\n for (const leasePath of leasePaths) {\n const currentOwner = readLeaseOwner(leasePath);\n if (!currentOwner || currentOwner.instanceId !== instanceId) {\n throw new Error(`Local-dev lease ownership was replaced at '${leasePath}'.`);\n }\n writeLeaseOwner(leasePath, { ...ownerBase, heartbeatAt: new Date().toISOString() });\n }\n } catch (error) {\n compromised = true;\n clearInterval(heartbeat);\n try {\n input.onCompromised?.(error instanceof Error ? error : new Error(String(error)));\n } catch {\n // The timer boundary must never surface an uncaught exception. The\n // lease remains compromised and heartbeats stay stopped even if the\n // coordinator callback itself cannot report the failure.\n }\n }\n };\n const heartbeat = setInterval(publishHeartbeat, input.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS);\n heartbeat.unref();\n let released = false;\n\n return {\n instanceId,\n leasePaths,\n async release() {\n if (released) return;\n released = true;\n clearInterval(heartbeat);\n for (const leasePath of [...leasePaths].reverse()) {\n releaseLeasePath(leasePath, instanceId);\n }\n },\n };\n }\n}\n\n/** The live owner of the shared platform, as read from the framework-root platform lease. */\nexport interface LiveLocalDevPlatformOwner {\n readonly pid: number;\n readonly appRoot: string;\n readonly acquiredAt: string;\n readonly heartbeatAt: string;\n}\n\n/**\n * Who currently OWNS the shared local platform, or `null` when nobody live does.\n *\n * This is the predicate every lane that would CONVERGE shared substrate must consult before writing\n * (issue #50): the platform reconciliation in `local init`, the backing-container compose-up in\n * `local dev`, and the platform-service env regeneration in `config sync` each destroyed a RUNNING\n * stack on 2026-08-25 because they asserted platform ownership without asking. The lease is\n * heartbeated by the owning `wildo local dev` session every few seconds; an owner whose heartbeat is\n * older than `staleAfterMs` is treated as dead (same staleness window the acquisition path uses), so\n * a crashed owner never wedges initialization.\n */\nexport function readLiveLocalDevPlatformOwner(\n frameworkRoot: string,\n staleAfterMs: number = DEFAULT_STALE_AFTER_MS,\n): LiveLocalDevPlatformOwner | null {\n const leasePath = resolve(frameworkRoot, '.wildo-runtime-signals', 'ownership', 'local-dev-platform.lock');\n if (!existsSync(leasePath)) return null;\n const owner = readLeaseOwner(leasePath);\n if (!owner) return null;\n const heartbeatAtMs = Date.parse(owner.heartbeatAt);\n if (!Number.isFinite(heartbeatAtMs) || Date.now() - heartbeatAtMs >= staleAfterMs) return null;\n return { pid: owner.pid, appRoot: owner.appRoot, acquiredAt: owner.acquiredAt, heartbeatAt: owner.heartbeatAt };\n}\n\nexport function resolveLocalDevSessionLeasePaths(input: {\n saasRoot: string;\n frameworkRoot: string | null;\n ownsPlatform: boolean;\n}): string[] {\n const paths = [resolve(input.saasRoot, '.wildo-saas', 'runtime-signals', 'ownership', 'local-dev.lock')];\n if (input.ownsPlatform) {\n if (!input.frameworkRoot) {\n throw new Error('A platform-owning local-dev session requires a framework root.');\n }\n paths.push(resolve(input.frameworkRoot, '.wildo-runtime-signals', 'ownership', 'local-dev-platform.lock'));\n }\n return paths;\n}\n\nfunction acquireLeasePath(\n leasePath: string,\n ownerBase: Omit<LocalDevSessionLeaseOwner, 'heartbeatAt'>,\n staleAfterMs: number,\n): void {\n mkdirSync(dirname(leasePath), { recursive: true, mode: 0o700 });\n chmodSync(dirname(leasePath), 0o700);\n\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n mkdirSync(leasePath, { mode: 0o700 });\n try {\n chmodSync(leasePath, 0o700);\n writeLeaseOwner(leasePath, { ...ownerBase, heartbeatAt: new Date().toISOString() });\n return;\n } catch (error) {\n rmSync(leasePath, { recursive: true, force: true });\n throw error;\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n }\n\n const owner = readLeaseOwner(leasePath);\n let ageMs: number;\n try {\n ageMs = Date.now() - statSync(leasePath).mtimeMs;\n } catch (error) {\n // A previous owner may release between our EEXIST and metadata read.\n // Retry the atomic mkdir instead of turning that normal hand-off race\n // into a false startup failure.\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;\n throw error;\n }\n const ownerLiveness = owner ? (acquiredBeforeThisBoot(owner) ? 'dead' : probeProcessLiveness(owner.pid)) : 'unknown';\n // A delayed heartbeat is not proof that a live owner is abandoned. The\n // CLI can legitimately block in Docker/platform startup longer than the\n // stale window, so PID liveness always wins. Age-based recovery is only\n // permitted when metadata is unavailable; a confirmed-dead owner can be\n // reclaimed immediately.\n if ((owner && ownerLiveness !== 'dead') || (!owner && ageMs <= staleAfterMs)) {\n throw new LocalDevSessionLeaseConflictError(leasePath, owner);\n }\n\n const stalePath = `${leasePath}.stale-${process.pid}-${randomUUID()}`;\n try {\n renameSync(leasePath, stalePath);\n rmSync(stalePath, { recursive: true, force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n }\n throw new LocalDevSessionLeaseConflictError(leasePath, readLeaseOwner(leasePath));\n}\n\nfunction writeLeaseOwner(leasePath: string, owner: LocalDevSessionLeaseOwner): void {\n const ownerPath = resolve(leasePath, 'owner.json');\n const temporaryPath = `${ownerPath}.tmp-${process.pid}-${randomUUID()}`;\n writeFileSync(temporaryPath, `${JSON.stringify(owner, null, 2)}\\n`, { encoding: 'utf-8', mode: 0o600 });\n renameSync(temporaryPath, ownerPath);\n chmodSync(ownerPath, 0o600);\n}\n\nfunction readLeaseOwner(leasePath: string): LocalDevSessionLeaseOwner | null {\n try {\n const owner = JSON.parse(readFileSync(resolve(leasePath, 'owner.json'), 'utf-8')) as LocalDevSessionLeaseOwner;\n if (\n owner?.schemaVersion !== LOCAL_DEV_SESSION_LEASE_SCHEMA_VERSION\n || typeof owner.instanceId !== 'string'\n || !Number.isInteger(owner.pid) || owner.pid <= 0\n || typeof owner.appRoot !== 'string'\n || (owner.frameworkRoot !== null && typeof owner.frameworkRoot !== 'string')\n || typeof owner.ownsPlatform !== 'boolean'\n || typeof owner.acquiredAt !== 'string'\n || typeof owner.heartbeatAt !== 'string'\n ) {\n return null;\n }\n return owner;\n } catch {\n return null;\n }\n}\n\nfunction releaseLeasePath(leasePath: string, instanceId: string): void {\n if (!existsSync(leasePath)) return;\n const owner = readLeaseOwner(leasePath);\n if (!owner || owner.instanceId !== instanceId) return;\n const retiredPath = `${leasePath}.retired-${process.pid}-${randomUUID()}`;\n try {\n renameSync(leasePath, retiredPath);\n rmSync(retiredPath, { recursive: true, force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n}\n\n/**\n * Was this lease acquired before the machine last booted (#3204)? Then its owner is dead whatever its pid now names: a\n * process does not survive a reboot, and after one the pid is free for any other process to hold, which\n * {@link probeProcessLiveness} would report as alive. Measured on the reference runner: a run's lease (pid 6331) outlived\n * a power-off, and the next run's `wildo local dev` refused to start because pid 6331 was now someone else's.\n * Decided from `acquiredAt`, which every lease already records, so a lease written before this check is judged too.\n */\nfunction acquiredBeforeThisBoot(owner: LocalDevSessionLeaseOwner): boolean {\n const acquiredAtMs = Date.parse(owner.acquiredAt);\n if (!Number.isFinite(acquiredAtMs)) return false;\n const bootedAtMs = Date.now() - uptime() * 1000;\n return acquiredAtMs < bootedAtMs - PREVIOUS_BOOT_MARGIN_MS;\n}\n\nfunction probeProcessLiveness(pid: number): 'alive' | 'dead' | 'unknown' {\n try {\n process.kill(pid, 0);\n return 'alive';\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === 'EPERM') return 'alive';\n if (code === 'ESRCH') return 'dead';\n return 'unknown';\n }\n}\n\n/**\n * What a lane intends to do to the SHARED local platform. It is the only input that decides how a\n * foreign owner is treated, so a new lane declares its intent rather than re-deriving the policy.\n */\nexport enum SharedPlatformIntent {\n /**\n * Bring the shared containers up and leave them there — `local up`, `dev start`, the `local dev`\n * readiness converge. Harmless when nobody else is running, and a substrate swap when somebody is.\n */\n CONVERGE = 'converge',\n /**\n * Recreate, stop or destroy the shared containers — `local down`, `local reset` (and `local up\n * --rebuild`'s force-recreate until #2988 removed it). Never safe under a foreign owner at any running state.\n */\n DISRUPT = 'disrupt',\n}\n\n/** What a lane may do to the shared platform right now. */\nexport enum SharedPlatformAccess {\n /** Nobody else owns it. Proceed exactly as the lane would have without this check. */\n PROCEED = 'proceed',\n /** A foreign session owns it and its containers are up: use them, converge nothing. */\n ATTACH = 'attach',\n /** A foreign session owns it and this lane must not touch it. */\n REFUSE = 'refuse',\n}\n\nexport interface SharedPlatformAccessDecision {\n readonly access: SharedPlatformAccess;\n /** The owning session, when one is live and is a different app root. */\n readonly owner: LiveLocalDevPlatformOwner | null;\n /** Ready-to-print explanation for ATTACH and REFUSE. Absent for PROCEED. */\n readonly message?: string;\n}\n\n/**\n * Whether this lane may converge or disrupt the shared local platform right now.\n *\n * ## Why this is a function rather than a check each lane writes\n *\n * The platform stack is deliberately ONE-APP-AT-A-TIME: every application renders its compose under\n * the same project name with the same `wildo-*` container names and its OWN `local_data/` bind\n * mounts, and `--remove-orphans` is what stops a converge from leaving the previous app's extra\n * services running on the previous app's data (measured 2026-09-03 — a half-migrated stack with 18\n * cron jobs pointing at a vhost that existed only in the other app's broker state). So switching\n * applications re-homes the stack ON PURPOSE. What must not happen is re-homing it out from under a\n * session that is still using it.\n *\n * {@link readLiveLocalDevPlatformOwner} has answered that since issue #50, and its own docstring\n * named the three lanes that must consult it. **It was reached from three of the SEVEN lanes that\n * mutate the shared stack** — measured 2026-09-15 (#1126): `local up`, `local up --rebuild`,\n * `local down`, `local reset` and `dev start` all converged or tore down without asking. The\n * observed cost was a running `wildo local dev` losing `wildo-postgresql`, `wildo-clamav`,\n * `wildo-immudb` and `wildo-otel-collector` to another application's `wildo local up`, and then\n * failing to boot with an error naming neither the other application nor the deletion. `local\n * reset`'s `down -v` would have taken the volumes.\n *\n * That is `.claude/rules/invariant-call-site-enumeration.md`'s defect shape exactly — the invariant\n * applied at some of its sites — so the remedy is the one that rule prefers: ONE predicate every\n * lane declares its intent to, rather than the same condition hand-written six more times.\n *\n * @param infraRunning Whether the shared containers are currently up. Only consulted for\n * {@link SharedPlatformIntent.CONVERGE}: an owner whose containers are gone cannot be attached to,\n * and starting them from this app root is the substrate swap the check exists to prevent.\n * @param acknowledgedForeignOwner The operator has stated, on this invocation, that they intend to\n * take the shared platform from its current owner. The refusal is the DEFAULT and the door is\n * explicit, narrow and per-invocation — `design-philosophy.md`, \"immutability needs a paired\n * mutation path\". A lane that offers no such flag passes `false`.\n */\nexport function decideSharedPlatformAccess(input: {\n frameworkRoot: string | null;\n saasRoot: string;\n intent: SharedPlatformIntent;\n infraRunning: boolean;\n acknowledgedForeignOwner?: boolean;\n staleAfterMs?: number;\n}): SharedPlatformAccessDecision {\n const owner = input.frameworkRoot\n ? readLiveLocalDevPlatformOwner(input.frameworkRoot, input.staleAfterMs)\n : null;\n // An owner at THIS app root is this application's own session: converging its own substrate is\n // what it is for, and re-homing is not in question.\n if (!owner || resolve(owner.appRoot) === resolve(input.saasRoot)) {\n return { access: SharedPlatformAccess.PROCEED, owner: null };\n }\n\n const who = `pid ${owner.pid}, app ${owner.appRoot}`;\n if (input.acknowledgedForeignOwner === true) {\n return {\n access: SharedPlatformAccess.PROCEED,\n owner,\n message: `Taking the shared platform from the \\`wildo local dev\\` session that owns it (${who}), as acknowledged on this invocation. `\n + 'That session\\'s processes are now running against a substrate this app root defines.',\n };\n }\n\n if (input.intent === SharedPlatformIntent.DISRUPT) {\n return {\n access: SharedPlatformAccess.REFUSE,\n owner,\n message: `The shared local platform is owned by another \\`wildo local dev\\` session (${who}). `\n + 'Refusing to recreate or stop its containers from this app root — stop that session first.',\n };\n }\n\n if (!input.infraRunning) {\n return {\n access: SharedPlatformAccess.REFUSE,\n owner,\n message: `The shared local platform is owned by another \\`wildo local dev\\` session (${who}), but its `\n + 'infrastructure containers are not running. Refusing to start shared containers from this app root — '\n + 'start them from the owning session.',\n };\n }\n\n return {\n access: SharedPlatformAccess.ATTACH,\n owner,\n message: `Attaching to the shared platform owned by pid ${owner.pid} (${owner.appRoot}); infrastructure convergence skipped.`,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-config.utils.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA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AmB,GAC1B,qBAAqB,CAAC,UAAU,CAAC,CAMnC;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CAAC,UAAU,CAAC,CAenC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,
|
|
1
|
+
{"version":3,"file":"authored-infra-config.utils.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAOL,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAMjG,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,uHAAuH;AACvH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAExF;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAE9C;AAED,0FAA0F;AAC1F,MAAM,WAAW,iCAAkC,SAAQ,4BAA4B;IACrF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8EAA8E;AAC9E,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,iCAAiC,GAAG,gCAAgC,CAAC;AAEjH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAcjH;AAED,oGAAoG;AACpG,wBAAsB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iCAAiC,EAAE,CAAC,CAOnH;AAED;;;;;GAKG;AACH,wBAAgB,0CAA0C,CACxD,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,mBAAmB,GAClC,MAAM,GAAG,IAAI,CAiBf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CAAC,UAAU,CAAC,CAMnC;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CAAC,UAAU,CAAC,CAenC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAsEpG"}
|
|
@@ -221,6 +221,7 @@ export function buildConfigJsonFromInfraEnvConfig(config) {
|
|
|
221
221
|
observability: config.observability,
|
|
222
222
|
providerSelection: config.providerSelection,
|
|
223
223
|
email: config.email,
|
|
224
|
+
agentContentGuardrails: config.agentContentGuardrails,
|
|
224
225
|
ownershipDnsStandIn: config.ownershipDnsStandIn,
|
|
225
226
|
applicationCreationVerification: config.applicationCreationVerification,
|
|
226
227
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-config.utils.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAE7C,OAAO,EACL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AAE,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK;gBAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,2CAA2C,CAAC,MAAM;aAC9E;YACD,UAAU,EAAE;gBACV,QAAQ,EAAE,UAAU,EAAE,QAAQ,IAAI,yCAAyC,CAAC,QAAQ;gBACpF,OAAO,EAAE,yCAAyC,CAAC,QAAQ;aAC5D;SACF;QACD,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC3B,CAAC,CAAC;gBACE,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;gBACtC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY;gBAC5C,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;aACrC;YACH,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,+BAA+B,EAAE,MAAM,CAAC,+BAA+B;KACxE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * authored-infra-config.utils — shared helpers for reading the authored\n * `wildo.infra.<env>.config.ts` descriptor and projecting it into the\n * platform-level `PlatformEnvConfigJson` shape.\n *\n * Originally lived as private helpers inside `commands/config/sync.command.ts`.\n * Extracted so the new runtime-bootstrap surface (used by `wildo local up`\n * pre-flight) can reuse the exact same projection — single source of truth\n * keeps the runtime artifacts written by `local up` byte-identical to the\n * ones `wildo config sync --domain manifest` would produce later.\n */\n\nimport { existsSync, readdirSync } from 'fs';\n\nimport {\n BackingServiceSource,\n DatabaseEngine,\n resolveApplicationDatabaseEngine,\n loadInfraEnvConfig,\n resolveAppLayout,\n resolveInfraEnvConfigPath,\n type WildoInfraEnvConfig,\n} from '@wildo-ai/platform-config-lib';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION,\n DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION,\n} from '~wildo-cli/services/data-services/data-services.schemas';\n\nexport interface LoadedAuthoredInfraEnvConfig {\n path: string;\n config: WildoInfraEnvConfig;\n}\n\n/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */\nexport function resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument\n * order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file\n * through the shared loader.\n */\nexport async function loadAuthoredInfraEnvConfig(\n envName: string,\n saasRoot: string,\n): Promise<LoadedAuthoredInfraEnvConfig | null> {\n return loadInfraEnvConfig(saasRoot, envName);\n}\n\n/** One authored environment: the directory name it lives under, and its loaded config. */\nexport interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {\n envName: string;\n}\n\n/** An environment directory whose authored config failed to load, and why. */\nexport interface UnreadableAuthoredInfraEnvConfig {\n readonly envName: string;\n readonly error: unknown;\n}\n\n/**\n * One environment directory as {@link settleAllAuthoredInfraEnvConfigs} found it: loaded, or failing to load. Told apart\n * with `'error' in`, which narrows whether or not the compiling package checks nulls strictly.\n */\nexport type SettledAuthoredInfraEnvConfig = LoadedNamedAuthoredInfraEnvConfig | UnreadableAuthoredInfraEnvConfig;\n\n/**\n * Every environment the application authors: each directory of its infrastructure home that carries an authored\n * `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is\n * not an environment and is skipped. Empty when the application has no infrastructure home.\n *\n * The ONE enumeration of an application's environments: the lockfile projections and the `config sync` servability\n * preflight (`loadAuthoredInfraEnvSelections`, #1693) and the schema planner's default adapter (#2708) all judge this\n * same population, so no reader can count one environment another misses. The dev companion cannot import this module\n * and restates the same walk for the same question (`assessApplicationSchemaPlanObligation`, #2724: is a baseline owed?);\n * change one, change both.\n *\n * SETTLED rather than thrown, so a reader that can still answer with the environments that did load decides that for\n * itself: the schema planner refuses only when an unreadable environment could change its answer.\n * {@link loadAllAuthoredInfraEnvConfigs} is the throwing form.\n */\nexport async function settleAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<SettledAuthoredInfraEnvConfig[]> {\n const infraDir = resolveAppLayout(saasRoot).authoredInfrastructureHome;\n if (!existsSync(infraDir)) return [];\n const settled: SettledAuthoredInfraEnvConfig[] = [];\n for (const entry of readdirSync(infraDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n try {\n const authored = await loadAuthoredInfraEnvConfig(entry.name, saasRoot);\n if (authored) settled.push({ envName: entry.name, ...authored });\n } catch (error) {\n settled.push({ envName: entry.name, error });\n }\n }\n return settled;\n}\n\n/** {@link settleAllAuthoredInfraEnvConfigs}, throwing the first environment that failed to load. */\nexport async function loadAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<LoadedNamedAuthoredInfraEnvConfig[]> {\n const loaded: LoadedNamedAuthoredInfraEnvConfig[] = [];\n for (const environment of await settleAllAuthoredInfraEnvConfigs(saasRoot)) {\n if ('error' in environment) throw environment.error;\n loaded.push(environment);\n }\n return loaded;\n}\n\n/**\n * Reason string when the authored infra config cannot serve as a config.json\n * fallback (currently: Atlas-backed environments require generated config.json\n * because authored infra config does not include Atlas API metadata or\n * external Mongo connection endpoints).\n */\nexport function getUnsupportedAuthoredConfigFallbackReason(\n envName: string,\n authoredConfigPath: string,\n authoredConfig: WildoInfraEnvConfig,\n): string | null {\n // Slice 4.B.0 (2026-05-07): Atlas detection now uses (source=MANAGED,\n // provider='atlas') instead of the legacy `source: ATLAS` enum value.\n // Same operational meaning — operator authored a managed Mongo whose\n // brand is Atlas; the generated config.json carries the Atlas API\n // metadata + external endpoints that the authored infra descriptor\n // doesn't include.\n const mongo = authoredConfig.backingServices.mongodb;\n if (mongo?.source === BackingServiceSource.MANAGED && mongo.provider === 'atlas') {\n return (\n `Cannot regenerate config for '${envName}' from authored infra descriptor at ${authoredConfigPath}: `\n + 'Atlas-backed environments require generated config.json because authored infra config '\n + 'does not include Atlas API metadata or external Mongo connection endpoints.'\n );\n }\n\n return null;\n}\n\n/**\n * Resolve the platform's database engine for an authored environment.\n *\n * **Precedence: an authored `database` block WINS; the inference below is the fallback.**\n *\n * The inference exists because the engine was historically not authorable at all — it lived only\n * as an answer to an interactive prompt in the machine-local `environments.json`. Every environment\n * predating the authored field relies on it, so it keeps its exact behaviour.\n *\n * What it cannot express, and why the authored field had to exist: the rule is\n * `postgresql && !mongodb`, while a PostgreSQL platform is REQUIRED to also declare\n * `backingServices.mongodb` (the bootstrap plane is Mongo-wired, and both this schema and\n * `env-vars-builder` refuse a PostgreSQL platform that renders no mongod). The intended state is\n * therefore `postgresql && mongodb`, which this function always resolves to MONGODB. It is not a\n * bug in the rule — it is a question the rule cannot be asked.\n *\n * This is the same inexpressibility Phase 5.1 fixed one layer down, where `needsLocalMongoDB` was\n * `engine === MONGODB && source === SELF` and became a union so that \"which containers render\"\n * stopped being collapsed into \"what engine is the platform\". The identical collapse survived here,\n * in \"what engine is the platform\" vs \"which services are declared\".\n *\n * **Deliberately NOT made smarter.** Widening it to \"postgresql present ⇒ PostgreSQL\" would flip\n * every environment that declares PostgreSQL as an APPLICATION-tier substrate — Wonder Todos'\n * `local` does exactly that today — into a PostgreSQL PLATFORM on its next `wildo config sync`.\n * A silent engine change on an existing environment is the worst outcome available here.\n */\nexport function resolveDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n if (config.database) {\n return config.database;\n }\n\n return inferDatabaseChoiceFromInfraConfig(config);\n}\n\n/**\n * The pre-authoring inference. Retained as the fallback for environments that author no `database`\n * block — see {@link resolveDatabaseChoiceFromInfraConfig} for the precedence and for why this\n * cannot express a PostgreSQL platform.\n */\nexport function inferDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n const postgresql = config.backingServices.postgresql;\n const mongodb = config.backingServices.mongodb;\n\n if (postgresql && !mongodb) {\n return {\n engine: DatabaseEngine.POSTGRESQL,\n source: postgresql.source,\n };\n }\n\n return {\n engine: DatabaseEngine.MONGODB,\n source: mongodb?.source ?? BackingServiceSource.SELF,\n };\n}\n\n/**\n * The bytes `config.json` holds: the one serialization every writer of the generated file uses (the local self-heal,\n * `config sync`, and the remote overlay of `loadConfigForSync`), so equal content is equal bytes and a file is\n * rewritten only when its content moves (#2311).\n */\nexport function serializeConfigJson(config: PlatformEnvConfigJson): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\n/**\n * Project a parsed `wildo.infra.<env>.config.ts` into the persisted\n * platform-level `environments/<env>/config.json` shape.\n *\n * `devCompanion` is intentionally NOT persisted here — see Slice 3 deep-review\n * M-5 note in `commands/config/sync.command.ts` for the dual-config-json\n * design rationale.\n */\nexport function buildConfigJsonFromInfraEnvConfig(config: WildoInfraEnvConfig): PlatformEnvConfigJson {\n const storage = config.backingServices.s3;\n const postgresql = config.backingServices.postgresql;\n\n return {\n type: config.locationType,\n runtime: config.runtime,\n runtimeEnvironment: config.runtimeEnvironment,\n /**\n * Always present here, never `undefined`: the authored schema resolves its own default from\n * `locationType` in the transform, so what reaches this projection is the environment's settled\n * answer rather than what the author happened to type.\n */\n localDataStorage: config.localDataStorage,\n /** Always present: the descriptor transform resolves `FULL` when nothing is authored (#2303). */\n serviceProfile: config.serviceProfile,\n database: resolveDatabaseChoiceFromInfraConfig(config),\n /**\n * The APPLICATION's engine — RESOLVED, never inferred and never left absent.\n *\n * Absence means PostgreSQL (`DEFAULT_APPLICATION_DATABASE_ENGINE`, #1571), and it is resolved HERE\n * so `config.json` always carries an explicit engine: every later reader of the file — the\n * bootstrap request, the e2e store probe — then sees the same answer without holding its own copy\n * of the default. Inferring it from which backing services are declared would resurrect exactly\n * the defect the authored field exists to remove, since `postgresql && mongodb` is both the normal\n * state and unresolvable by inference.\n *\n * ⚠️ THIS is the projection that writes `config.json`, not the `transform` in\n * `defineInfraEnvConfig`. Both exist and both must carry a new field: the transform feeds\n * in-process consumers, this one feeds the file every generator later reads. Adding the field to\n * only the transform (2026-08-19) produced a silently ABSENT key here — the reconcile reported\n * success and `applicationDatabase` simply was not in the written file.\n */\n applicationDatabase: { engine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n infrastructure: {\n storage: {\n provider: (storage?.provider ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.PROVIDER) as 'minio',\n useSsl: storage?.endpoint?.startsWith('https://') ?? false,\n bucket: storage?.bucket ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.BUCKET,\n },\n postgresql: {\n database: postgresql?.database ?? DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.DATABASE,\n sslMode: DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.SSL_MODE,\n },\n },\n publicDomain: config.publicDomain,\n serviceHosts: config.serviceHosts,\n cdn: config.cdn,\n platformStorage: config.platformStorage,\n platformKeyManagement: config.platformKeyManagement,\n systemsOfRecord: config.systemsOfRecord,\n kubernetes: config.kubernetes\n ? {\n namespace: config.kubernetes.namespace,\n ingressClass: config.kubernetes.ingressClass,\n services: config.kubernetes.services,\n }\n : undefined,\n remoteProvider: config.remoteProvider,\n infrastructureHost: config.infrastructureHost,\n backingServices: config.backingServices,\n serviceAuth: config.serviceAuth,\n logging: config.logging,\n observability: config.observability,\n providerSelection: config.providerSelection,\n email: config.email,\n ownershipDnsStandIn: config.ownershipDnsStandIn,\n applicationCreationVerification: config.applicationCreationVerification,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"authored-infra-config.utils.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gCAAgC,EAChC,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,2CAA2C,EAC3C,yCAAyC,GAC1C,MAAM,yDAAyD,CAAC;AAOjE,uHAAuH;AACvH,MAAM,UAAU,8BAA8B,CAAC,QAAgB,EAAE,OAAe;IAC9E,OAAO,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAAe,EACf,QAAgB;IAEhB,OAAO,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAmBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,QAAgB;IACrE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC,0BAA0B,CAAC;IACvE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,OAAO,GAAoC,EAAE,CAAC;IACpD,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,C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C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;QACrD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,+BAA+B,EAAE,MAAM,CAAC,+BAA+B;KACxE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * authored-infra-config.utils — shared helpers for reading the authored\n * `wildo.infra.<env>.config.ts` descriptor and projecting it into the\n * platform-level `PlatformEnvConfigJson` shape.\n *\n * Originally lived as private helpers inside `commands/config/sync.command.ts`.\n * Extracted so the new runtime-bootstrap surface (used by `wildo local up`\n * pre-flight) can reuse the exact same projection — single source of truth\n * keeps the runtime artifacts written by `local up` byte-identical to the\n * ones `wildo config sync --domain manifest` would produce later.\n */\n\nimport { existsSync, readdirSync } from 'fs';\n\nimport {\n BackingServiceSource,\n DatabaseEngine,\n resolveApplicationDatabaseEngine,\n loadInfraEnvConfig,\n resolveAppLayout,\n resolveInfraEnvConfigPath,\n type WildoInfraEnvConfig,\n} from '@wildo-ai/platform-config-lib';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION,\n DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION,\n} from '~wildo-cli/services/data-services/data-services.schemas';\n\nexport interface LoadedAuthoredInfraEnvConfig {\n path: string;\n config: WildoInfraEnvConfig;\n}\n\n/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */\nexport function resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument\n * order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file\n * through the shared loader.\n */\nexport async function loadAuthoredInfraEnvConfig(\n envName: string,\n saasRoot: string,\n): Promise<LoadedAuthoredInfraEnvConfig | null> {\n return loadInfraEnvConfig(saasRoot, envName);\n}\n\n/** One authored environment: the directory name it lives under, and its loaded config. */\nexport interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {\n envName: string;\n}\n\n/** An environment directory whose authored config failed to load, and why. */\nexport interface UnreadableAuthoredInfraEnvConfig {\n readonly envName: string;\n readonly error: unknown;\n}\n\n/**\n * One environment directory as {@link settleAllAuthoredInfraEnvConfigs} found it: loaded, or failing to load. Told apart\n * with `'error' in`, which narrows whether or not the compiling package checks nulls strictly.\n */\nexport type SettledAuthoredInfraEnvConfig = LoadedNamedAuthoredInfraEnvConfig | UnreadableAuthoredInfraEnvConfig;\n\n/**\n * Every environment the application authors: each directory of its infrastructure home that carries an authored\n * `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is\n * not an environment and is skipped. Empty when the application has no infrastructure home.\n *\n * The ONE enumeration of an application's environments: the lockfile projections and the `config sync` servability\n * preflight (`loadAuthoredInfraEnvSelections`, #1693) and the schema planner's default adapter (#2708) all judge this\n * same population, so no reader can count one environment another misses. The dev companion cannot import this module\n * and restates the same walk for the same question (`assessApplicationSchemaPlanObligation`, #2724: is a baseline owed?);\n * change one, change both.\n *\n * SETTLED rather than thrown, so a reader that can still answer with the environments that did load decides that for\n * itself: the schema planner refuses only when an unreadable environment could change its answer.\n * {@link loadAllAuthoredInfraEnvConfigs} is the throwing form.\n */\nexport async function settleAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<SettledAuthoredInfraEnvConfig[]> {\n const infraDir = resolveAppLayout(saasRoot).authoredInfrastructureHome;\n if (!existsSync(infraDir)) return [];\n const settled: SettledAuthoredInfraEnvConfig[] = [];\n for (const entry of readdirSync(infraDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n try {\n const authored = await loadAuthoredInfraEnvConfig(entry.name, saasRoot);\n if (authored) settled.push({ envName: entry.name, ...authored });\n } catch (error) {\n settled.push({ envName: entry.name, error });\n }\n }\n return settled;\n}\n\n/** {@link settleAllAuthoredInfraEnvConfigs}, throwing the first environment that failed to load. */\nexport async function loadAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<LoadedNamedAuthoredInfraEnvConfig[]> {\n const loaded: LoadedNamedAuthoredInfraEnvConfig[] = [];\n for (const environment of await settleAllAuthoredInfraEnvConfigs(saasRoot)) {\n if ('error' in environment) throw environment.error;\n loaded.push(environment);\n }\n return loaded;\n}\n\n/**\n * Reason string when the authored infra config cannot serve as a config.json\n * fallback (currently: Atlas-backed environments require generated config.json\n * because authored infra config does not include Atlas API metadata or\n * external Mongo connection endpoints).\n */\nexport function getUnsupportedAuthoredConfigFallbackReason(\n envName: string,\n authoredConfigPath: string,\n authoredConfig: WildoInfraEnvConfig,\n): string | null {\n // Slice 4.B.0 (2026-05-07): Atlas detection now uses (source=MANAGED,\n // provider='atlas') instead of the legacy `source: ATLAS` enum value.\n // Same operational meaning — operator authored a managed Mongo whose\n // brand is Atlas; the generated config.json carries the Atlas API\n // metadata + external endpoints that the authored infra descriptor\n // doesn't include.\n const mongo = authoredConfig.backingServices.mongodb;\n if (mongo?.source === BackingServiceSource.MANAGED && mongo.provider === 'atlas') {\n return (\n `Cannot regenerate config for '${envName}' from authored infra descriptor at ${authoredConfigPath}: `\n + 'Atlas-backed environments require generated config.json because authored infra config '\n + 'does not include Atlas API metadata or external Mongo connection endpoints.'\n );\n }\n\n return null;\n}\n\n/**\n * Resolve the platform's database engine for an authored environment.\n *\n * **Precedence: an authored `database` block WINS; the inference below is the fallback.**\n *\n * The inference exists because the engine was historically not authorable at all — it lived only\n * as an answer to an interactive prompt in the machine-local `environments.json`. Every environment\n * predating the authored field relies on it, so it keeps its exact behaviour.\n *\n * What it cannot express, and why the authored field had to exist: the rule is\n * `postgresql && !mongodb`, while a PostgreSQL platform is REQUIRED to also declare\n * `backingServices.mongodb` (the bootstrap plane is Mongo-wired, and both this schema and\n * `env-vars-builder` refuse a PostgreSQL platform that renders no mongod). The intended state is\n * therefore `postgresql && mongodb`, which this function always resolves to MONGODB. It is not a\n * bug in the rule — it is a question the rule cannot be asked.\n *\n * This is the same inexpressibility Phase 5.1 fixed one layer down, where `needsLocalMongoDB` was\n * `engine === MONGODB && source === SELF` and became a union so that \"which containers render\"\n * stopped being collapsed into \"what engine is the platform\". The identical collapse survived here,\n * in \"what engine is the platform\" vs \"which services are declared\".\n *\n * **Deliberately NOT made smarter.** Widening it to \"postgresql present ⇒ PostgreSQL\" would flip\n * every environment that declares PostgreSQL as an APPLICATION-tier substrate — Wonder Todos'\n * `local` does exactly that today — into a PostgreSQL PLATFORM on its next `wildo config sync`.\n * A silent engine change on an existing environment is the worst outcome available here.\n */\nexport function resolveDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n if (config.database) {\n return config.database;\n }\n\n return inferDatabaseChoiceFromInfraConfig(config);\n}\n\n/**\n * The pre-authoring inference. Retained as the fallback for environments that author no `database`\n * block — see {@link resolveDatabaseChoiceFromInfraConfig} for the precedence and for why this\n * cannot express a PostgreSQL platform.\n */\nexport function inferDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n const postgresql = config.backingServices.postgresql;\n const mongodb = config.backingServices.mongodb;\n\n if (postgresql && !mongodb) {\n return {\n engine: DatabaseEngine.POSTGRESQL,\n source: postgresql.source,\n };\n }\n\n return {\n engine: DatabaseEngine.MONGODB,\n source: mongodb?.source ?? BackingServiceSource.SELF,\n };\n}\n\n/**\n * The bytes `config.json` holds: the one serialization every writer of the generated file uses (the local self-heal,\n * `config sync`, and the remote overlay of `loadConfigForSync`), so equal content is equal bytes and a file is\n * rewritten only when its content moves (#2311).\n */\nexport function serializeConfigJson(config: PlatformEnvConfigJson): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\n/**\n * Project a parsed `wildo.infra.<env>.config.ts` into the persisted\n * platform-level `environments/<env>/config.json` shape.\n *\n * `devCompanion` is intentionally NOT persisted here — see Slice 3 deep-review\n * M-5 note in `commands/config/sync.command.ts` for the dual-config-json\n * design rationale.\n */\nexport function buildConfigJsonFromInfraEnvConfig(config: WildoInfraEnvConfig): PlatformEnvConfigJson {\n const storage = config.backingServices.s3;\n const postgresql = config.backingServices.postgresql;\n\n return {\n type: config.locationType,\n runtime: config.runtime,\n runtimeEnvironment: config.runtimeEnvironment,\n /**\n * Always present here, never `undefined`: the authored schema resolves its own default from\n * `locationType` in the transform, so what reaches this projection is the environment's settled\n * answer rather than what the author happened to type.\n */\n localDataStorage: config.localDataStorage,\n /** Always present: the descriptor transform resolves `FULL` when nothing is authored (#2303). */\n serviceProfile: config.serviceProfile,\n database: resolveDatabaseChoiceFromInfraConfig(config),\n /**\n * The APPLICATION's engine — RESOLVED, never inferred and never left absent.\n *\n * Absence means PostgreSQL (`DEFAULT_APPLICATION_DATABASE_ENGINE`, #1571), and it is resolved HERE\n * so `config.json` always carries an explicit engine: every later reader of the file — the\n * bootstrap request, the e2e store probe — then sees the same answer without holding its own copy\n * of the default. Inferring it from which backing services are declared would resurrect exactly\n * the defect the authored field exists to remove, since `postgresql && mongodb` is both the normal\n * state and unresolvable by inference.\n *\n * ⚠️ THIS is the projection that writes `config.json`, not the `transform` in\n * `defineInfraEnvConfig`. Both exist and both must carry a new field: the transform feeds\n * in-process consumers, this one feeds the file every generator later reads. Adding the field to\n * only the transform (2026-08-19) produced a silently ABSENT key here — the reconcile reported\n * success and `applicationDatabase` simply was not in the written file.\n */\n applicationDatabase: { engine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n infrastructure: {\n storage: {\n provider: (storage?.provider ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.PROVIDER) as 'minio',\n useSsl: storage?.endpoint?.startsWith('https://') ?? false,\n bucket: storage?.bucket ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.BUCKET,\n },\n postgresql: {\n database: postgresql?.database ?? DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.DATABASE,\n sslMode: DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.SSL_MODE,\n },\n },\n publicDomain: config.publicDomain,\n serviceHosts: config.serviceHosts,\n cdn: config.cdn,\n platformStorage: config.platformStorage,\n platformKeyManagement: config.platformKeyManagement,\n systemsOfRecord: config.systemsOfRecord,\n kubernetes: config.kubernetes\n ? {\n namespace: config.kubernetes.namespace,\n ingressClass: config.kubernetes.ingressClass,\n services: config.kubernetes.services,\n }\n : undefined,\n remoteProvider: config.remoteProvider,\n infrastructureHost: config.infrastructureHost,\n backingServices: config.backingServices,\n serviceAuth: config.serviceAuth,\n logging: config.logging,\n observability: config.observability,\n providerSelection: config.providerSelection,\n email: config.email,\n agentContentGuardrails: config.agentContentGuardrails,\n ownershipDnsStandIn: config.ownershipDnsStandIn,\n applicationCreationVerification: config.applicationCreationVerification,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-member-authority.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-member-authority.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpG,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAK/H;;;;;;;;;GASG;AACH,oBAAY,4BAA4B;IACtC;;;OAGG;IACH,UAAU,eAAe;IACzB;;;;OAIG;IACH,wBAAwB,6BAA6B;IACrD,mHAAmH;IACnH,oBAAoB,yBAAyB;IAC7C;;;OAGG;IACH,UAAU,eAAe;IACzB,yDAAyD;IACzD,QAAQ,aAAa;CACtB;AAED,mFAAmF;AACnF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,4BAA4B,CAAC;IACjD,6HAA6H;IAC7H,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,MAAM,qBAAqB,CAAC,EAAE,CAAC;IAClE,yGAAyG;IACzG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,OAAO,yBAAyB,CAAC,CAAC,GAAG,uBAAuB;
|
|
1
|
+
{"version":3,"file":"authored-infra-member-authority.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-member-authority.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpG,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAK/H;;;;;;;;;GASG;AACH,oBAAY,4BAA4B;IACtC;;;OAGG;IACH,UAAU,eAAe;IACzB;;;;OAIG;IACH,wBAAwB,6BAA6B;IACrD,mHAAmH;IACnH,oBAAoB,yBAAyB;IAC7C;;;OAGG;IACH,UAAU,eAAe;IACzB,yDAAyD;IACzD,QAAQ,aAAa;CACtB;AAED,mFAAmF;AACnF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,4BAA4B,CAAC;IACjD,6HAA6H;IAC7H,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,MAAM,qBAAqB,CAAC,EAAE,CAAC;IAClE,yGAAyG;IACzG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,OAAO,yBAAyB,CAAC,CAAC,GAAG,uBAAuB;CAqJhI,CAAC;AAEF,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,mJAAmJ;IACnJ,QAAQ,CAAC,gBAAgB,EAAE,SAAS,CAAC,MAAM,qBAAqB,CAAC,EAAE,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,qBAAqB,EAChC,QAAQ,EAAE,mBAAmB,GAC5B,oBAAoB,CAgBtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAa7H"}
|
|
@@ -136,6 +136,11 @@ export const AUTHORED_INFRA_MEMBER_AUTHORITY = {
|
|
|
136
136
|
configMembers: ['email'],
|
|
137
137
|
reason: 'Projected into `WILDO_INBOUND_EMAIL_SHARED_DOMAIN`; setup\'s snapshot omits it.',
|
|
138
138
|
},
|
|
139
|
+
agentContentGuardrails: {
|
|
140
|
+
authority: AuthoredInfraMemberAuthority.DESCRIPTOR,
|
|
141
|
+
configMembers: ['agentContentGuardrails'],
|
|
142
|
+
reason: 'Projected into `WILDO_AGENT_CONTENT_GUARDRAILS`; setup\'s snapshot omits it.',
|
|
143
|
+
},
|
|
139
144
|
ownershipDnsStandIn: {
|
|
140
145
|
authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,
|
|
141
146
|
reason: 'Refused outside the local environment (#2519): elsewhere a domain owner proves ownership through real DNS.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-member-authority.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-member-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE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CAAC;IAC3D,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACpG,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACjC,gBAAgB,CAAC,eAAe,EAAE,CAAC;IACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport type { INFRA_ENV_FIELD_OWNERSHIP, WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport { PlatformEnvConfigJson_Schema, type PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { buildConfigJsonFromInfraEnvConfig, serializeConfigJson } from '~wildo-cli/services/environment/authored-infra-config.utils';\nimport { EnvironmentPaths } from '~wildo-cli/services/environment/environment-paths.service';\nimport { EnvironmentUtils } from '~wildo-cli/services/environment/environment.service';\n\n/**\n * Where the rendered value of one member of `wildo.infra.<env>.config.ts` comes from, on every lane (#2310).\n *\n * An environment's artifacts (its `.env` files, compose project, Kubernetes Secrets and manifests, CI deploy render)\n * are built from `config.json`. Two writers produce that file: the authored projection\n * (`buildConfigJsonFromInfraEnvConfig`) and the setup-time snapshot (`credentials.service.ts`), which a remote\n * environment keeps. The local lane rewrites `config.json` from the descriptor on every run; the remote lanes read a\n * persisted copy. So each member must say which source wins when the two disagree, or a remote environment renders\n * what an old file says instead of what its descriptor says.\n */\nexport enum AuthoredInfraMemberAuthority {\n /**\n * Only the descriptor decides it. Its projection replaces a persisted copy's value on every lane, and ABSENCE is\n * authoritative: a member removed from the descriptor is removed from the next render.\n */\n DESCRIPTOR = 'descriptor',\n /**\n * The descriptor decides it when it authors it. When it does not, a persisted copy keeps the value setup recorded\n * from the operator's answer, because the projection would otherwise substitute a default or an inference for\n * that answer (a platform database engine flipped by inference is the case this exists for).\n */\n DESCRIPTOR_WHEN_AUTHORED = 'descriptor-when-authored',\n /** Not a `config.json` member: its one consumer reads it straight from the descriptor, so no copy can be stale. */\n READ_FROM_DESCRIPTOR = 'read-from-descriptor',\n /**\n * Only the local lane reads it: the descriptor schema refuses it outside the local environment, or no remote lane\n * projects or reads it.\n */\n LOCAL_ONLY = 'local-only',\n /** Identifies the descriptor; no artifact renders it. */\n IDENTITY = 'identity',\n}\n\n/** One member's authority, the `config.json` members it projects into, and why. */\nexport interface AuthoredInfraMemberRule {\n readonly authority: AuthoredInfraMemberAuthority;\n /** The `config.json` members the projection writes from this descriptor member (DESCRIPTOR and DESCRIPTOR_WHEN_AUTHORED). */\n readonly configMembers?: readonly (keyof PlatformEnvConfigJson)[];\n /** READ_FROM_DESCRIPTOR: the module (relative to the CLI's `src/`) that reads it from the descriptor. */\n readonly consumer?: string;\n readonly reason: string;\n}\n\n/**\n * Every member of the descriptor, and where its rendered value comes from (#2310).\n *\n * Total over the descriptor's shape by TYPE: it is keyed by the same keys as `INFRA_ENV_FIELD_OWNERSHIP`, which\n * platform-config-lib keeps total over `WILDO_INFRA_ENV_CONFIG_SHAPE`. So a member added to the descriptor tomorrow\n * does not compile here until somebody decides how it reaches a remote environment's artifacts, and\n * `authored-infra-member-authority.test.ts` pins each decision against the real projection and the real overlay.\n */\nexport const AUTHORED_INFRA_MEMBER_AUTHORITY: { readonly [K in keyof typeof INFRA_ENV_FIELD_OWNERSHIP]-?: AuthoredInfraMemberRule } = {\n environment: {\n authority: AuthoredInfraMemberAuthority.IDENTITY,\n reason: 'The environment\\'s name: the loader refuses a descriptor whose `environment` differs from its directory.',\n },\n locationType: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['type'],\n reason: 'Always resolved by the descriptor transform, so the descriptor always states it.',\n },\n runtimeEnvironment: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['runtimeEnvironment'],\n reason: 'Optional: unauthored, setup recorded the environment\\'s runtime environment from the environment it created.',\n },\n runtime: { authority: AuthoredInfraMemberAuthority.DESCRIPTOR, configMembers: ['runtime'], reason: 'Required by the descriptor schema.' },\n localDataStorage: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['localDataStorage'],\n reason: 'Always resolved by the descriptor transform from `locationType`; setup never writes it.',\n },\n serviceProfile: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['serviceProfile'],\n reason: 'Always resolved by the descriptor transform (`FULL` when unauthored); setup never writes it (#2303).',\n },\n database: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['database'],\n reason: 'Unauthored, the projection INFERS an engine from the backing services, and that inference must not '\n + 'silently replace the engine setup recorded for an existing platform.',\n },\n applicationDatabase: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['applicationDatabase'],\n reason: 'Absence means PostgreSQL (#1571), resolved by the projection; setup never writes it.',\n },\n publicDomain: { authority: AuthoredInfraMemberAuthority.DESCRIPTOR, configMembers: ['publicDomain'], reason: 'Required by the descriptor schema.' },\n serviceHosts: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['serviceHosts'],\n reason: 'Projected into `WILDO_SERVICE_HOSTS` and the remote runtime endpoints; a removed host must stop addressing its service.',\n },\n kubernetes: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['kubernetes'],\n reason: 'Optional: unauthored, setup recorded the namespace of the cluster it created.',\n },\n remoteProvider: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['remoteProvider'],\n reason: 'Optional: unauthored, setup recorded the registry endpoint the operator answered.',\n },\n deployment: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'commands/config/sync.command.ts',\n reason: 'The CI workflow and the image build read it from the loaded descriptor.',\n },\n backingServices: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n // `infrastructure` (the platform bucket and PostgreSQL database) is derived from the backing services by the\n // projection, and setup writes only its defaults.\n configMembers: ['backingServices', 'infrastructure'],\n reason: 'Required by the descriptor schema; setup never writes it.',\n },\n logging: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['logging'],\n reason: 'Projected into `LOG_LEVEL` and its siblings; setup\\'s snapshot omits it.',\n },\n observability: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['observability'],\n reason: 'Projected into the `OTEL_*` variables; setup\\'s snapshot omits it.',\n },\n providerSelection: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['providerSelection'],\n reason: 'Projected into `WILDO_PROVIDER_SELECTION_OVERRIDES`; setup\\'s snapshot omits it.',\n },\n providerConfigurations: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'commands/config/sync.command.ts',\n reason: 'The provider runtime artifacts are composed from the loaded descriptor.',\n },\n email: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['email'],\n reason: 'Projected into `WILDO_INBOUND_EMAIL_SHARED_DOMAIN`; setup\\'s snapshot omits it.',\n },\n ownershipDnsStandIn: {\n authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,\n reason: 'Refused outside the local environment (#2519): elsewhere a domain owner proves ownership through real DNS.',\n },\n systemsOfRecord: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['systemsOfRecord'],\n reason: 'Where this environment\\'s systems of record live; setup never writes it.',\n },\n documentationSite: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'commands/config/sync.command.ts',\n reason: 'Build-time origins of the documentation image: passed to its build arguments and the CI workflow from '\n + 'the loaded descriptor. No runtime reads them, so they are not a `config.json` member (#2310).',\n },\n applicationCreationVerification: {\n authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,\n reason: 'Refused outside the local environment: the creation lane\\'s evidence directory is on a developer machine.',\n },\n serviceAuth: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['serviceAuth'],\n reason: 'The service-to-service policy; a removed policy must stop applying.',\n },\n csp: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'services/security/csp-sync.service.ts',\n reason: 'The CSP files are rendered from the loaded descriptor.',\n },\n cdn: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['cdn'],\n reason: 'Which frontends a CDN serves; a removed entry must return its route to the ingress.',\n },\n platformStorage: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['platformStorage'],\n reason: 'The platform\\'s storage posture; setup never writes it.',\n },\n platformKeyManagement: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['platformKeyManagement'],\n reason: 'Projected into apps-manager\\'s `PLATFORM_KEY_VAULT_*`; a removed block stops the platform\\'s Vault (#2933).',\n },\n devCompanion: {\n authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,\n reason: 'The dev companion runs on a developer machine; its address is read from the descriptor by the local lane '\n + 'and is never persisted into `config.json` (see `buildConfigJsonFromInfraEnvConfig`).',\n },\n infrastructureHost: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['infrastructureHost'],\n reason: 'The environment\\'s infrastructure owner (#1171): a persisted copy naming the previous owner steers every render.',\n },\n};\n\n/** The result of laying the authored projection over a persisted `config.json`. */\nexport interface AuthoredInfraOverlay {\n readonly config: PlatformEnvConfigJson;\n /** The `config.json` members whose persisted value differed from the descriptor's, sorted: what the persisted copy would have rendered wrongly. */\n readonly correctedMembers: readonly (keyof PlatformEnvConfigJson)[];\n}\n\n/**\n * A persisted `config.json` with every member the descriptor decides taken from the authored projection (#2310).\n *\n * The persisted copy keeps what the descriptor cannot carry (Atlas API metadata, external endpoints, the setup-time\n * provider choices for externally managed services) and the setup answers of a DESCRIPTOR_WHEN_AUTHORED member the\n * descriptor leaves unauthored. Everything else follows {@link AUTHORED_INFRA_MEMBER_AUTHORITY}: a DESCRIPTOR member\n * the descriptor omits is REMOVED, which is what makes a removal reach the next render.\n *\n * Rejected: making the authored projection win wholesale, as the local lane's `config.json` does. A remote\n * `config.json` is the only home of the Atlas metadata and of setup's engine answer, and a projection would erase\n * both (`getUnsupportedAuthoredConfigFallbackReason` already refuses the Atlas case for that reason).\n */\nexport function overlayAuthoredInfraMembers(\n persisted: PlatformEnvConfigJson,\n authored: WildoInfraEnvConfig,\n): AuthoredInfraOverlay {\n const projection = buildConfigJsonFromInfraEnvConfig(authored);\n const config: Record<string, unknown> = { ...persisted };\n const corrected = new Set<keyof PlatformEnvConfigJson>();\n for (const [member, rule] of Object.entries(AUTHORED_INFRA_MEMBER_AUTHORITY) as [keyof WildoInfraEnvConfig, AuthoredInfraMemberRule][]) {\n const decides = rule.authority === AuthoredInfraMemberAuthority.DESCRIPTOR\n || (rule.authority === AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED && authored[member] !== undefined);\n if (!decides) continue;\n for (const configMember of rule.configMembers ?? []) {\n const value = projection[configMember];\n if (JSON.stringify(value) !== JSON.stringify(persisted[configMember])) corrected.add(configMember);\n if (value === undefined) delete config[configMember];\n else config[configMember] = value;\n }\n }\n return { config: config as PlatformEnvConfigJson, correctedMembers: [...corrected].sort() };\n}\n\n/**\n * Write an overlaid `config.json` back to the environment's GENERATED `config.json` (#2310), when its bytes differ.\n *\n * `loadConfigForSync` hands the overlay to the generators it calls directly (Kubernetes Secrets, the CI deploy render),\n * but several readers load the generated file from disk themselves (`loadInfraHydratedConfig(env)` in the env-file\n * and compose lanes). Writing the overlay back is what makes those see the descriptor's answer too, instead of the\n * stale copy the overlay corrected. Validated first: a value the schema refuses is not written, and the refusal is\n * returned for the caller to report (the in-memory overlay still reaches the generators it is handed to).\n */\nexport function persistAuthoredOverlay(envName: string, config: PlatformEnvConfigJson): { written: boolean; refusal?: string } {\n const parsed = PlatformEnvConfigJson_Schema.safeParse(config);\n if (!parsed.success) {\n return { written: false, refusal: parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ') };\n }\n const configDir = EnvironmentPaths.resolveConfigDir(envName);\n const configPath = join(configDir, FILE_NAMES.CONFIG_JSON);\n const bytes = serializeConfigJson(config);\n if (existsSync(configPath) && readFileSync(configPath, 'utf8') === bytes) return { written: false };\n mkdirSync(configDir, { recursive: true });\n writeFileSync(configPath, bytes);\n EnvironmentUtils.invalidateCache();\n return { written: true };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"authored-infra-member-authority.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-member-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAA8B,MAAM,qDAAqD,CAAC;AAC/H,OAAO,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAC;AACrI,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAEvF;;;;;;;;;GASG;AACH,MAAM,CAAN,IAAY,4BAqBX;AArBD,WAAY,4BAA4B;IACtC;;;OAGG;IACH,yDAAyB,CAAA;IACzB;;;;OAIG;IACH,qFAAqD,CAAA;I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IACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport type { INFRA_ENV_FIELD_OWNERSHIP, WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport { PlatformEnvConfigJson_Schema, type PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { buildConfigJsonFromInfraEnvConfig, serializeConfigJson } from '~wildo-cli/services/environment/authored-infra-config.utils';\nimport { EnvironmentPaths } from '~wildo-cli/services/environment/environment-paths.service';\nimport { EnvironmentUtils } from '~wildo-cli/services/environment/environment.service';\n\n/**\n * Where the rendered value of one member of `wildo.infra.<env>.config.ts` comes from, on every lane (#2310).\n *\n * An environment's artifacts (its `.env` files, compose project, Kubernetes Secrets and manifests, CI deploy render)\n * are built from `config.json`. Two writers produce that file: the authored projection\n * (`buildConfigJsonFromInfraEnvConfig`) and the setup-time snapshot (`credentials.service.ts`), which a remote\n * environment keeps. The local lane rewrites `config.json` from the descriptor on every run; the remote lanes read a\n * persisted copy. So each member must say which source wins when the two disagree, or a remote environment renders\n * what an old file says instead of what its descriptor says.\n */\nexport enum AuthoredInfraMemberAuthority {\n /**\n * Only the descriptor decides it. Its projection replaces a persisted copy's value on every lane, and ABSENCE is\n * authoritative: a member removed from the descriptor is removed from the next render.\n */\n DESCRIPTOR = 'descriptor',\n /**\n * The descriptor decides it when it authors it. When it does not, a persisted copy keeps the value setup recorded\n * from the operator's answer, because the projection would otherwise substitute a default or an inference for\n * that answer (a platform database engine flipped by inference is the case this exists for).\n */\n DESCRIPTOR_WHEN_AUTHORED = 'descriptor-when-authored',\n /** Not a `config.json` member: its one consumer reads it straight from the descriptor, so no copy can be stale. */\n READ_FROM_DESCRIPTOR = 'read-from-descriptor',\n /**\n * Only the local lane reads it: the descriptor schema refuses it outside the local environment, or no remote lane\n * projects or reads it.\n */\n LOCAL_ONLY = 'local-only',\n /** Identifies the descriptor; no artifact renders it. */\n IDENTITY = 'identity',\n}\n\n/** One member's authority, the `config.json` members it projects into, and why. */\nexport interface AuthoredInfraMemberRule {\n readonly authority: AuthoredInfraMemberAuthority;\n /** The `config.json` members the projection writes from this descriptor member (DESCRIPTOR and DESCRIPTOR_WHEN_AUTHORED). */\n readonly configMembers?: readonly (keyof PlatformEnvConfigJson)[];\n /** READ_FROM_DESCRIPTOR: the module (relative to the CLI's `src/`) that reads it from the descriptor. */\n readonly consumer?: string;\n readonly reason: string;\n}\n\n/**\n * Every member of the descriptor, and where its rendered value comes from (#2310).\n *\n * Total over the descriptor's shape by TYPE: it is keyed by the same keys as `INFRA_ENV_FIELD_OWNERSHIP`, which\n * platform-config-lib keeps total over `WILDO_INFRA_ENV_CONFIG_SHAPE`. So a member added to the descriptor tomorrow\n * does not compile here until somebody decides how it reaches a remote environment's artifacts, and\n * `authored-infra-member-authority.test.ts` pins each decision against the real projection and the real overlay.\n */\nexport const AUTHORED_INFRA_MEMBER_AUTHORITY: { readonly [K in keyof typeof INFRA_ENV_FIELD_OWNERSHIP]-?: AuthoredInfraMemberRule } = {\n environment: {\n authority: AuthoredInfraMemberAuthority.IDENTITY,\n reason: 'The environment\\'s name: the loader refuses a descriptor whose `environment` differs from its directory.',\n },\n locationType: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['type'],\n reason: 'Always resolved by the descriptor transform, so the descriptor always states it.',\n },\n runtimeEnvironment: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['runtimeEnvironment'],\n reason: 'Optional: unauthored, setup recorded the environment\\'s runtime environment from the environment it created.',\n },\n runtime: { authority: AuthoredInfraMemberAuthority.DESCRIPTOR, configMembers: ['runtime'], reason: 'Required by the descriptor schema.' },\n localDataStorage: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['localDataStorage'],\n reason: 'Always resolved by the descriptor transform from `locationType`; setup never writes it.',\n },\n serviceProfile: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['serviceProfile'],\n reason: 'Always resolved by the descriptor transform (`FULL` when unauthored); setup never writes it (#2303).',\n },\n database: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['database'],\n reason: 'Unauthored, the projection INFERS an engine from the backing services, and that inference must not '\n + 'silently replace the engine setup recorded for an existing platform.',\n },\n applicationDatabase: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['applicationDatabase'],\n reason: 'Absence means PostgreSQL (#1571), resolved by the projection; setup never writes it.',\n },\n publicDomain: { authority: AuthoredInfraMemberAuthority.DESCRIPTOR, configMembers: ['publicDomain'], reason: 'Required by the descriptor schema.' },\n serviceHosts: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['serviceHosts'],\n reason: 'Projected into `WILDO_SERVICE_HOSTS` and the remote runtime endpoints; a removed host must stop addressing its service.',\n },\n kubernetes: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['kubernetes'],\n reason: 'Optional: unauthored, setup recorded the namespace of the cluster it created.',\n },\n remoteProvider: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED,\n configMembers: ['remoteProvider'],\n reason: 'Optional: unauthored, setup recorded the registry endpoint the operator answered.',\n },\n deployment: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'commands/config/sync.command.ts',\n reason: 'The CI workflow and the image build read it from the loaded descriptor.',\n },\n backingServices: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n // `infrastructure` (the platform bucket and PostgreSQL database) is derived from the backing services by the\n // projection, and setup writes only its defaults.\n configMembers: ['backingServices', 'infrastructure'],\n reason: 'Required by the descriptor schema; setup never writes it.',\n },\n logging: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['logging'],\n reason: 'Projected into `LOG_LEVEL` and its siblings; setup\\'s snapshot omits it.',\n },\n observability: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['observability'],\n reason: 'Projected into the `OTEL_*` variables; setup\\'s snapshot omits it.',\n },\n providerSelection: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['providerSelection'],\n reason: 'Projected into `WILDO_PROVIDER_SELECTION_OVERRIDES`; setup\\'s snapshot omits it.',\n },\n providerConfigurations: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'commands/config/sync.command.ts',\n reason: 'The provider runtime artifacts are composed from the loaded descriptor.',\n },\n email: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['email'],\n reason: 'Projected into `WILDO_INBOUND_EMAIL_SHARED_DOMAIN`; setup\\'s snapshot omits it.',\n },\n agentContentGuardrails: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['agentContentGuardrails'],\n reason: 'Projected into `WILDO_AGENT_CONTENT_GUARDRAILS`; setup\\'s snapshot omits it.',\n },\n ownershipDnsStandIn: {\n authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,\n reason: 'Refused outside the local environment (#2519): elsewhere a domain owner proves ownership through real DNS.',\n },\n systemsOfRecord: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['systemsOfRecord'],\n reason: 'Where this environment\\'s systems of record live; setup never writes it.',\n },\n documentationSite: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'commands/config/sync.command.ts',\n reason: 'Build-time origins of the documentation image: passed to its build arguments and the CI workflow from '\n + 'the loaded descriptor. No runtime reads them, so they are not a `config.json` member (#2310).',\n },\n applicationCreationVerification: {\n authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,\n reason: 'Refused outside the local environment: the creation lane\\'s evidence directory is on a developer machine.',\n },\n serviceAuth: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['serviceAuth'],\n reason: 'The service-to-service policy; a removed policy must stop applying.',\n },\n csp: {\n authority: AuthoredInfraMemberAuthority.READ_FROM_DESCRIPTOR,\n consumer: 'services/security/csp-sync.service.ts',\n reason: 'The CSP files are rendered from the loaded descriptor.',\n },\n cdn: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['cdn'],\n reason: 'Which frontends a CDN serves; a removed entry must return its route to the ingress.',\n },\n platformStorage: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['platformStorage'],\n reason: 'The platform\\'s storage posture; setup never writes it.',\n },\n platformKeyManagement: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['platformKeyManagement'],\n reason: 'Projected into apps-manager\\'s `PLATFORM_KEY_VAULT_*`; a removed block stops the platform\\'s Vault (#2933).',\n },\n devCompanion: {\n authority: AuthoredInfraMemberAuthority.LOCAL_ONLY,\n reason: 'The dev companion runs on a developer machine; its address is read from the descriptor by the local lane '\n + 'and is never persisted into `config.json` (see `buildConfigJsonFromInfraEnvConfig`).',\n },\n infrastructureHost: {\n authority: AuthoredInfraMemberAuthority.DESCRIPTOR,\n configMembers: ['infrastructureHost'],\n reason: 'The environment\\'s infrastructure owner (#1171): a persisted copy naming the previous owner steers every render.',\n },\n};\n\n/** The result of laying the authored projection over a persisted `config.json`. */\nexport interface AuthoredInfraOverlay {\n readonly config: PlatformEnvConfigJson;\n /** The `config.json` members whose persisted value differed from the descriptor's, sorted: what the persisted copy would have rendered wrongly. */\n readonly correctedMembers: readonly (keyof PlatformEnvConfigJson)[];\n}\n\n/**\n * A persisted `config.json` with every member the descriptor decides taken from the authored projection (#2310).\n *\n * The persisted copy keeps what the descriptor cannot carry (Atlas API metadata, external endpoints, the setup-time\n * provider choices for externally managed services) and the setup answers of a DESCRIPTOR_WHEN_AUTHORED member the\n * descriptor leaves unauthored. Everything else follows {@link AUTHORED_INFRA_MEMBER_AUTHORITY}: a DESCRIPTOR member\n * the descriptor omits is REMOVED, which is what makes a removal reach the next render.\n *\n * Rejected: making the authored projection win wholesale, as the local lane's `config.json` does. A remote\n * `config.json` is the only home of the Atlas metadata and of setup's engine answer, and a projection would erase\n * both (`getUnsupportedAuthoredConfigFallbackReason` already refuses the Atlas case for that reason).\n */\nexport function overlayAuthoredInfraMembers(\n persisted: PlatformEnvConfigJson,\n authored: WildoInfraEnvConfig,\n): AuthoredInfraOverlay {\n const projection = buildConfigJsonFromInfraEnvConfig(authored);\n const config: Record<string, unknown> = { ...persisted };\n const corrected = new Set<keyof PlatformEnvConfigJson>();\n for (const [member, rule] of Object.entries(AUTHORED_INFRA_MEMBER_AUTHORITY) as [keyof WildoInfraEnvConfig, AuthoredInfraMemberRule][]) {\n const decides = rule.authority === AuthoredInfraMemberAuthority.DESCRIPTOR\n || (rule.authority === AuthoredInfraMemberAuthority.DESCRIPTOR_WHEN_AUTHORED && authored[member] !== undefined);\n if (!decides) continue;\n for (const configMember of rule.configMembers ?? []) {\n const value = projection[configMember];\n if (JSON.stringify(value) !== JSON.stringify(persisted[configMember])) corrected.add(configMember);\n if (value === undefined) delete config[configMember];\n else config[configMember] = value;\n }\n }\n return { config: config as PlatformEnvConfigJson, correctedMembers: [...corrected].sort() };\n}\n\n/**\n * Write an overlaid `config.json` back to the environment's GENERATED `config.json` (#2310), when its bytes differ.\n *\n * `loadConfigForSync` hands the overlay to the generators it calls directly (Kubernetes Secrets, the CI deploy render),\n * but several readers load the generated file from disk themselves (`loadInfraHydratedConfig(env)` in the env-file\n * and compose lanes). Writing the overlay back is what makes those see the descriptor's answer too, instead of the\n * stale copy the overlay corrected. Validated first: a value the schema refuses is not written, and the refusal is\n * returned for the caller to report (the in-memory overlay still reaches the generators it is handed to).\n */\nexport function persistAuthoredOverlay(envName: string, config: PlatformEnvConfigJson): { written: boolean; refusal?: string } {\n const parsed = PlatformEnvConfigJson_Schema.safeParse(config);\n if (!parsed.success) {\n return { written: false, refusal: parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ') };\n }\n const configDir = EnvironmentPaths.resolveConfigDir(envName);\n const configPath = join(configDir, FILE_NAMES.CONFIG_JSON);\n const bytes = serializeConfigJson(config);\n if (existsSync(configPath) && readFileSync(configPath, 'utf8') === bytes) return { written: false };\n mkdirSync(configDir, { recursive: true });\n writeFileSync(configPath, bytes);\n EnvironmentUtils.invalidateCache();\n return { written: true };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-configuration-generator.service.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/env-configuration-generator.service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EAEpB,qCAAqC,EAErC,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AACzH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;
|
|
1
|
+
{"version":3,"file":"env-configuration-generator.service.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/env-configuration-generator.service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EAEpB,qCAAqC,EAErC,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AACzH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAO5G,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAM3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AA6DtD;;;;;;;;;;GAUG;AACH,w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jB,qBAAqB,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,gCAAgC,EACrC,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAoCxC;AAED,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,gCAAgC,EACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,sBAAsB,EACnC,GAAG,EAAE,MAAM,EACX,mBAAmB,CAAC,EAAE,2BAA2B,EAAE,EACnD,aAAa,CAAC,EAAE,0BAA0B,EAAE,EAC5C,oBAAoB,CAAC,EAAE,mCAAmC,EAAE,EAC5D,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,EACjD,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,EACjD,oBAAoB,CAAC,EAAE,4BAA4B,EAAE,EACrD,WAAW,CAAC,EAAE;IACZ;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,GACA,IAAI,CA6PN;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,gCAAgC,EACrC,WAAW,EAAE,sBAAsB,GAClC,MAAM,GAAG,IAAI,CAef"}
|
|
@@ -3,6 +3,7 @@ import { dirname, join, resolve } from 'path';
|
|
|
3
3
|
import { resolveFrameworkLayout, BOOTSTRAP_PLATFORM_SERVICES, ApplicationCreationVerificationEnvKey, WildoLocationType, } from '@wildo-ai/platform-config-lib';
|
|
4
4
|
import { EnvironmentUtils } from '../../services/environment/environment.service.js';
|
|
5
5
|
import { EnvironmentPaths } from '../../services/environment/environment-paths.service.js';
|
|
6
|
+
import { IMMUDB_AUDIT_STATE_LOCAL_DATA_DIR } from '../../services/data-services/data-services.schemas.js';
|
|
6
7
|
import { LOCAL_APPLICATION_BACKEND_LISTEN_HOST } from '../../services/environment/platform-runtime.schemas.js';
|
|
7
8
|
import { resolveContainerHostGatewayListenHost } from '../../services/environment/container-host-gateway-listen-host.js';
|
|
8
9
|
import { InfrastructureHost } from '../../services/environment/infrastructure-host.service.js';
|
|
@@ -59,6 +60,7 @@ function hydrateInfraPostureFromEnv(config, env) {
|
|
|
59
60
|
config.observability = env.observability ?? config.observability;
|
|
60
61
|
config.providerSelection = env.providerSelection ?? config.providerSelection;
|
|
61
62
|
config.email = env.email ?? config.email;
|
|
63
|
+
config.agentContentGuardrails = env.agentContentGuardrails ?? config.agentContentGuardrails;
|
|
62
64
|
// Local-only (#2519): the double answering domain-ownership challenges. Same ordering as `email`.
|
|
63
65
|
config.ownershipDnsStandIn = env.ownershipDnsStandIn ?? config.ownershipDnsStandIn;
|
|
64
66
|
}
|
|
@@ -197,8 +199,9 @@ export function generatePlatformServiceEnvFiles(env, frameworkPath, credentials,
|
|
|
197
199
|
// LOCAL-lane durable trust-anchor dir for the immudb audit provider (cross-restart tamper-evidence).
|
|
198
200
|
// Provision it ONLY when immudb audit is configured (its connection secret is present) and not
|
|
199
201
|
// already pinned by the operator. The value is a host absolute path under the durable local_data
|
|
200
|
-
// tier — preserved by `wildo local down`, wiped by `reset`
|
|
201
|
-
//
|
|
202
|
+
// tier — preserved by `wildo local down`, and wiped by `reset` together with the local immudb's data
|
|
203
|
+
// (`IMMUDB_AUDIT_STATE_LOCAL_DATA_DIR`). An anchor left behind is not harmless: the state-signing key is
|
|
204
|
+
// pinned, and under a pin a fresh ledger below an old anchor is a PROVEN tamper (#3775). This is the
|
|
202
205
|
// LOCAL mechanism ONLY: a host path is meaningless inside a container. REMOTE (staging/production)
|
|
203
206
|
// provisions the anchor on a durable IN-CONTAINER volume instead — the k8s app-backend Deployment
|
|
204
207
|
// mounts a PVC and sets IMMUDB_STATE_DIR (`K8sManifestGenerator.buildForApplication` /
|
|
@@ -208,7 +211,7 @@ export function generatePlatformServiceEnvFiles(env, frameworkPath, credentials,
|
|
|
208
211
|
if (env.locationType === WildoLocationType.LOCAL &&
|
|
209
212
|
credentials.providerEnv?.IMMUDB_HOST &&
|
|
210
213
|
!appEnv['IMMUDB_STATE_DIR']) {
|
|
211
|
-
appEnv['IMMUDB_STATE_DIR'] = EnvironmentPaths.resolveScopedLocalDataServiceDir(app.applicationRoot,
|
|
214
|
+
appEnv['IMMUDB_STATE_DIR'] = EnvironmentPaths.resolveScopedLocalDataServiceDir(app.applicationRoot, IMMUDB_AUDIT_STATE_LOCAL_DATA_DIR);
|
|
212
215
|
}
|
|
213
216
|
writeEnvFile(join(app.applicationRoot, app.relativeDir, FILE_NAMES.DOT_ENV), appEnv);
|
|
214
217
|
appCount++;
|