@wildo-ai/saas-minions-lib 1.1.7 → 1.1.9
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/esm/base-classes/services/services/minion-scoped-services-registry-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/minion-scoped-services-registry-handler.backend.service.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/inject/models/container.d.ts.map +1 -1
- package/dist/esm/inject/models/container.js.map +1 -1
- package/dist/esm/inject/models/service-types.d.ts.map +1 -1
- package/dist/esm/inject/models/service-types.js.map +1 -1
- package/dist/esm/runtime/queue/minion-tick-consumer.backend.service.d.ts +5 -1
- package/dist/esm/runtime/queue/minion-tick-consumer.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/queue/minion-tick-consumer.backend.service.js +24 -9
- package/dist/esm/runtime/queue/minion-tick-consumer.backend.service.js.map +1 -1
- package/dist/esm/runtime/services/define-minion-init.d.ts.map +1 -1
- package/dist/esm/runtime/services/define-minion-init.js.map +1 -1
- package/dist/esm/runtime/services/own-schedule-reader.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/services/own-schedule-reader.backend.service.js.map +1 -1
- package/dist/esm/runtime/services/start-minion-application.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/services/start-minion-application.backend.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/runtime/queue/__tests__/minion-tick-consumer.backend.service.test.ts +63 -14
- package/src/runtime/queue/minion-tick-consumer.backend.service.ts +23 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-minion-application.backend.service.js","sourceRoot":"","sources":["../../../../src/runtime/services/start-minion-application.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAGL,yBAAyB,EACzB,MAAM,EACN,UAAU,EAKV,kBAAkB,EACmB,mBAAm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AW;YACxC,YAAY,EAAE,eAAe,CAAC,YAAY;YAC1C,YAAY,EAAE,qBAAqB;YACnC,sBAAsB,EAAE,+BAA+B;YACvD,GAAG,CAAC,sBAAsB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,4BAA4B,EAAE,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,CAAC;YAC5H,mBAAmB,EAAE,eAAe,CAAC,mBAAmB;YACxD,qBAAqB,EAAE,eAAe,CAAC,qBAAqB;YAC5D,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,KAAK;SACN,CAAC;IACJ,CAAC;CACF,CAAA;AApXY,oCAAoC;IADhD,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAElD,WAAA,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAE3C,WAAA,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,CAAA;IAE5D,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAEjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAElD,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAE9C,WAAA,MAAM,CAAC,0BAA0B,CAAC,wBAAwB,CAAC,CAAA;yDAP7B,gCAAgC;GATtD,oCAAoC,CAoXhD","sourcesContent":["import {\n type AppConfiguration,\n type AppConfigurationService,\n ApplicationRuntimeProfile,\n inject,\n injectable,\n type LoggerService,\n type ProviderRuntimeArtifact,\n type RuntimePrincipalBackendService,\n type SystemAccessBackendService,\n SAAS_SERVICE_TYPES,\n type StartApplicationBackendService, describeCaughtError } from '@wildo-ai/saas-backend-lib';\nimport { ErrorCustomMessageReference, ErrorType, type ScheduledRecoveryPolicy } from '@wildo-ai/saas-models';\nimport { assertProviderRuntimeEnvInSync } from '@wildo-ai/platform-config-lib';\nimport { MinionScopedServicesRegistryHandlerBackendService } from '../../base-classes/services/services/minion-scoped-services-registry-handler.backend.service';\nimport { SAAS_MINIONS_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { OwnScheduleReaderBackendService } from './own-schedule-reader.backend.service';\nimport {\n MinionTickConsumerBackendService,\n type MinionTickHandler,\n} from '../queue/minion-tick-consumer.backend.service';\nimport type {\n MinionInitializationConfig,\n MinionProviderRuntimeArtifact,\n MinionTickAuthorHandler,\n MinionTickContext,\n MinionTickReconciliationHandler,\n} from './define-minion-init';\n\ntype MinionAwareAppConfiguration = AppConfiguration & {\n minions?: Record<string, MinionRuntimeConfig>;\n};\n\ntype MinionRuntimeConfig = NonNullable<NonNullable<AppConfiguration['minions']>[string]>;\n\n@injectable()\nexport class StartMinionApplicationBackendService {\n private tickConsumerStarted = false;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.StartApplicationService)\n private readonly startApplicationService: StartApplicationBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService)\n private readonly appConfigService: AppConfigurationService,\n @inject(SAAS_MINIONS_SERVICE_TYPES.MinionTickConsumerService)\n private readonly tickConsumer: MinionTickConsumerBackendService,\n @inject(SAAS_SERVICE_TYPES.Logger)\n private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.RuntimePrincipalService)\n private readonly runtimePrincipal: RuntimePrincipalBackendService,\n @inject(SAAS_SERVICE_TYPES.SystemAccessService)\n private readonly systemAccess: SystemAccessBackendService,\n @inject(SAAS_MINIONS_SERVICE_TYPES.OwnScheduleReaderService)\n private readonly ownScheduleReader: OwnScheduleReaderBackendService,\n ) {}\n\n public async initialize(config: MinionInitializationConfig): Promise<void> {\n const {\n minionName,\n serviceIdentifier,\n onTick,\n tickRecovery,\n reconcileTick,\n ...startupConfig\n } = config;\n // Declare WHO this process is before anything can perform a privileged access.\n //\n // Established here, in framework-owned minion startup, rather than left to each\n // minion author — attribution that an author can forget is attribution that will\n // be missing exactly when an auditor needs it. Every minion therefore carries its\n // identity structurally, by virtue of being a minion.\n //\n // Attribution only: this grants nothing. A minion's operations are governed by its\n // role and its `resourceAccess` whitelist; its cross-tenant reach comes from the\n // system-access door. See `.claude/plans/minion-runtime-scope.md` (D9).\n //\n // assurance-control: WILDO.AUDIT.SECURITY_EVENT — privileged access by a non-human\n // background runtime is attributable to that runtime.\n this.runtimePrincipal.initialize({\n runtimeProfile: ApplicationRuntimeProfile.MINION,\n runtimeKey: minionName,\n serviceIdentifier: serviceIdentifier ?? `minions.${minionName}`,\n });\n\n const normalizedProviderRuntime = this.normalizeProviderRuntime(\n startupConfig.providerRuntime,\n minionName,\n );\n\n // Boot-time fail-closed reconciliation between the typed\n // `wildo-provider-runtime.generated.ts` artifact and the\n // `.wildo-providers.env` file mounted into this process. Catches\n // stale-sync drift (operator regenerated one surface but not the\n // other) BEFORE the registry filter would silently boot with\n // mismatched topology.\n //\n // Skipped when:\n // - the artifact is absent (host authored zero providers AND no\n // scope block in `wildo.saas.config.ts`); or\n // - the artifact has zero `providerRefs` (host authored an\n // explicit empty scope `providers: {}`). The CLI emitter\n // deliberately does NOT write `.wildo-providers.env` in that\n // case, so the env-vars are absent — running the assertion\n // would raise a false-positive fail-closed.\n // Defensive `?? []` — the schema marks `providerRefs` optional, so\n // a hand-crafted artifact (test fixture / future format drift)\n // could omit it. Without the fallback `.length` would TypeError\n // before fail-closed produced its actionable message. Production\n // CLI emit always defaults to `[]`, so this is hardening only.\n const projectedProviderRefs = normalizedProviderRuntime?.providerRefs ?? [];\n if (normalizedProviderRuntime && projectedProviderRefs.length > 0) {\n assertProviderRuntimeEnvInSync({\n artifactProviderRefs: projectedProviderRefs,\n artifactSourceDigest: normalizedProviderRuntime.sourceDigest,\n hostKind: 'minion',\n hostKey: minionName,\n });\n }\n\n await this.startApplicationService.initialize({\n ...startupConfig,\n providerRuntime: normalizedProviderRuntime,\n headlessMode: true,\n skipCronSync: true,\n // A minion reuses the full backend startup lifecycle but is NOT a job\n // worker for the shared application queues — it consumes ONLY its own\n // `minion-tick.<name>` queue (subscribed below via `startTickConsumer`).\n // Skipping the shared job consumers keeps RabbitMQ from round-robining\n // scheduled-cron ticks onto this process (which would dead-letter every\n // tick it can't interpret). The broker connection itself is still made,\n // because the tick consumer depends on it.\n skipJobConsumers: true,\n serviceIdentifier: serviceIdentifier ?? `minions.${minionName}`,\n afterResourcesRegistryInitialized: async ({\n appConfig,\n resourcesRegistryService,\n errorBuilder,\n }) => {\n const minionConfig = this.getMinionRuntimeConfig(\n appConfig as MinionAwareAppConfiguration,\n minionName,\n errorBuilder,\n );\n const resourceAccess = minionConfig.resourceAccess;\n const knownResourceTypes = new Set(resourcesRegistryService.getResourceTypes());\n const unknownResourceTypes = [\n ...(resourceAccess?.read ?? []),\n ...(resourceAccess?.write ?? []),\n ].filter((resourceType, index, all) => (\n resourceType !== '*'\n && !knownResourceTypes.has(resourceType)\n && all.indexOf(resourceType) === index\n ));\n\n if (unknownResourceTypes.length > 0) {\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, undefined, {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message:\n `Minion '${minionName}' references unknown resources in resourceAccess: `\n + `[${unknownResourceTypes.join(', ')}].`,\n minionName,\n unknownResourceTypes,\n },\n });\n }\n },\n servicesRegistryDecoratorFactory: (registry, { appConfig, errorBuilder }) => (\n new MinionScopedServicesRegistryHandlerBackendService(\n registry as any,\n minionName,\n this.getMinionRuntimeConfig(\n appConfig as MinionAwareAppConfiguration,\n minionName,\n errorBuilder,\n ).resourceAccess,\n ).asDecoratedRegistry()\n ),\n });\n\n // KD-12 auto-wiring: every minion subscribes to its dedicated tick\n // queue (`wildo.queue.<appId>.minion-tick.<minionName>`). Cron-mode\n // minions receive ticks from `platform-crontabs-batches-manager`;\n // always-up minions receive nothing on this queue under normal\n // operation but the subscription is harmless (no message ⇒ no\n // dispatch) and keeps the runtime contract symmetric across modes.\n await this.startTickConsumer(minionName, onTick, tickRecovery, reconcileTick);\n }\n\n public async shutdown(): Promise<void> {\n if (this.tickConsumerStarted) {\n try {\n await this.tickConsumer.stop();\n } catch (error) {\n this.logger.warn('Failed to stop minion tick consumer cleanly', {\n error: describeCaughtError(error),\n });\n } finally {\n this.tickConsumerStarted = false;\n }\n }\n await this.startApplicationService.shutdown();\n }\n\n public isApplicationInitialized(): boolean {\n return this.startApplicationService.isApplicationInitialized();\n }\n\n private async startTickConsumer(\n minionName: string,\n onTick: MinionTickAuthorHandler | undefined,\n tickRecovery: Partial<ScheduledRecoveryPolicy> | undefined,\n reconcileTick: MinionTickReconciliationHandler | undefined,\n ): Promise<void> {\n // The surface the handler is ALLOWED to work with, assembled once at the tick\n // boundary. Handed to the author rather than left for them to resolve from the\n // container: `systemAccess` here is already contained by this minion's\n // `resourceAccess` ACL, because startup rebinds the services registry to the\n // scoped decorator before any tick can be delivered. An author who resolved the\n // door themselves could bypass that; an author handed this one cannot.\n const context: Omit<MinionTickContext, 'scheduledAttempt'> = {\n systemAccess: this.systemAccess,\n minionName,\n // Same reasoning as `systemAccess`: handed to the author rather than left\n // to be resolved from the container. A reader an author constructs is a\n // reader an author could construct with a different identity; this one is\n // bound to the process's own attested principal and cannot be pointed\n // elsewhere.\n ownSchedule: this.ownScheduleReader,\n };\n\n // Missing handlers stay absent: the durable coordinator records REVIEW instead of\n // treating an unimplemented tick as successful work.\n const handler: MinionTickHandler | undefined = onTick\n ? async (token, scheduledAttempt) => onTick(token, { ...context, scheduledAttempt })\n : undefined;\n\n const evidencePolicies = this.appConfigService.config?.scheduledEvidence?.minions;\n for (const configuredName of Object.keys(evidencePolicies ?? {})) {\n if (!Object.hasOwn(this.appConfigService.config.minions ?? {}, configuredName)) {\n this.logger.warn('Scheduled evidence policy names an undeclared minion; no evidence will be collected for this key', { minionName: configuredName });\n }\n }\n await this.tickConsumer.start({\n applicationId: this.appConfigService.applicationId,\n minionName,\n handler,\n recoveryPolicy: tickRecovery,\n evidencePolicy: evidencePolicies && Object.hasOwn(evidencePolicies, minionName) ? evidencePolicies[minionName] : undefined,\n reconcile: reconcileTick\n ? async (token, scheduledAttempt) => reconcileTick(token, { ...context, scheduledAttempt })\n : undefined,\n });\n this.tickConsumerStarted = true;\n }\n\n private getMinionRuntimeConfig(\n appConfig: MinionAwareAppConfiguration,\n minionName: string,\n errorBuilder?: {\n buildError: (\n errorType: ErrorType,\n executionContext: undefined,\n options: {\n customMessageReference?: ErrorCustomMessageReference;\n context?: Record<string, unknown>;\n },\n ) => unknown;\n },\n ): MinionRuntimeConfig {\n const minionConfig = appConfig.minions?.[minionName];\n if (minionConfig) {\n return minionConfig;\n }\n\n if (!errorBuilder) {\n throw new Error(`Minion '${minionName}' is missing from appConfig.minions.`);\n }\n\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, undefined, {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message:\n `Minion '${minionName}' is not declared in the managed runtime config. `\n + 'Re-sync the application bootstrap material before starting the minion.',\n minionName,\n },\n });\n }\n\n /**\n * Bridge the per-minion materialized provider runtime artifact into the\n * `ProviderRuntimeArtifact` shape consumed by `StartApplicationBackendService`\n * (and ultimately filtered by `BackendProviderRegistryBackendService`).\n *\n * Three accepted input shapes:\n *\n * 1. `{ artifactKind: 'backend', scope: ... }` — already projected to a\n * backend-shaped single-scope artifact (e.g. produced by an\n * embedding host that pre-selected the scope).\n * 2. `{ artifactKind: 'minions', scope: ..., scopes: undefined }` —\n * what `wildo config sync` writes to each minion's\n * `src/generated/wildo-provider-runtime.generated.ts`. The CLI calls\n * `selectScopedProviderRuntimeArtifact(artifacts.minions, minionKey)`\n * so the file already carries only this minion's scope. We unwrap\n * it here to the canonical backend-shaped artifact.\n * 3. `{ artifactKind: 'minions', scopes: { [name]: ... } }` —\n * multi-scope minion artifact (legacy / non-CLI-driven hosts that\n * pass the unscoped artifact). We resolve `scopes[minionName]`.\n *\n * Anything else fails fast with a clear locator. Each minion process\n * must only see its own scope — there is no fallback to other scopes,\n * no merging across minions, and no silent recovery from a missing\n * scope.\n */\n private normalizeProviderRuntime(\n providerRuntime: MinionInitializationConfig['providerRuntime'],\n minionName: string,\n ): ProviderRuntimeArtifact | undefined {\n if (!providerRuntime) {\n return undefined;\n }\n if (providerRuntime.artifactKind === 'backend') {\n return providerRuntime;\n }\n const artifactKind = providerRuntime.artifactKind;\n if (artifactKind !== 'minions') {\n throw new Error(\n `Unsupported provider runtime artifactKind '${artifactKind}' for minion '${minionName}'.`,\n );\n }\n\n return this.selectMinionProviderRuntimeScope(providerRuntime, minionName);\n }\n\n private selectMinionProviderRuntimeScope(\n providerRuntime: MinionProviderRuntimeArtifact,\n minionName: string,\n ): ProviderRuntimeArtifact {\n const preScopedScope = (providerRuntime as MinionProviderRuntimeArtifact & {\n scope?: ProviderRuntimeArtifact['scope'];\n }).scope;\n const scopes = providerRuntime.scopes as\n | Record<string, ProviderRuntimeArtifact['scope']>\n | undefined;\n\n let scope: ProviderRuntimeArtifact['scope'] | undefined;\n\n if (preScopedScope && (!scopes || Object.keys(scopes).length === 0)) {\n // Shape 2 — the CLI-emitted per-minion module.\n scope = preScopedScope;\n } else if (scopes) {\n // Shape 3 — unscoped multi-scope artifact.\n scope = scopes[minionName];\n if (!scope) {\n throw new Error(\n `Provider runtime artifact does not contain a scope for minion '${minionName}'. `\n + `Re-run \\`wildo config sync\\` and verify the minion is declared in `\n + `wildo.saas.config.ts \\`providers.scopes.minions\\`.`,\n );\n }\n }\n\n if (!scope) {\n throw new Error(\n `Provider runtime artifact for minion '${minionName}' is missing both a `\n + `pre-scoped \\`scope\\` and a multi-scope \\`scopes\\` map. The artifact is malformed.`,\n );\n }\n\n // Recompute `providerRefs` from the projected per-host scope, NOT\n // from the multi-scope union the parent artifact carries. The\n // `buildMultiScopeArtifactMetadata` upstream computes\n // `providerRefs` as the union across all hosts; preserving that\n // here would make the boot-time `assertProviderRuntimeEnvInSync`\n // guard treat sibling-scope refs as \"this host has providers\" and\n // mistakenly run reconciliation on hosts whose own scope is empty.\n // Mirrors `selectScopedProviderRuntimeArtifact` in\n // `provider-runtime-artifacts.ts`.\n const projectedProviderRefs = Object.keys(scope.providers ?? {}).sort();\n // Narrowed with the refs, for the same reason (#330): the import map on a multi-scope artifact\n // is the union across every host, and handing this host a sibling's package specifiers would\n // tell it that it may load something it never declared.\n const projectedProviderRuntimeImports = Object.fromEntries(\n Object.entries(\n providerRuntime.providerRuntimeImports ?? {},\n ).filter(([providerRef]) => projectedProviderRefs.includes(providerRef)),\n );\n // Narrowed with the refs as well (#1672): a host applies augmentations only to providers it declares, and a\n // sibling's opt-in must not load a package into this process.\n const projectedAugmentations = Object.entries(providerRuntime.providerRuntimeAugmentations ?? {})\n .filter(([providerRef]) => projectedProviderRefs.includes(providerRef));\n\n return {\n __AUTOGENERATED__: providerRuntime.__AUTOGENERATED__,\n generatedBy: providerRuntime.generatedBy,\n generatedAt: providerRuntime.generatedAt,\n sourceDigest: providerRuntime.sourceDigest,\n providerRefs: projectedProviderRefs,\n providerRuntimeImports: projectedProviderRuntimeImports,\n ...(projectedAugmentations.length === 0 ? {} : { providerRuntimeAugmentations: Object.fromEntries(projectedAugmentations) }),\n providerGraphDigest: providerRuntime.providerGraphDigest,\n lockfileSectionDigest: providerRuntime.lockfileSectionDigest,\n artifactKind: 'backend',\n modules: providerRuntime.modules,\n scope,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"start-minion-application.backend.service.js","sourceRoot":"","sources":["../../../../../src/runtime/services/start-minion-application.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAGL,yBAAyB,EACzB,MAAM,EACN,UAAU,EAKV,kBAAkB,EACmB,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAgC,MAAM,uBAAuB,CAAC;AAC7G,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,iDAAi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,CAAC,CAAC,EAAE,4BAA4B,EAAE,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,CAAC;YAC5H,mBAAmB,EAAE,eAAe,CAAC,mBAAmB;YACxD,qBAAqB,EAAE,eAAe,CAAC,qBAAqB;YAC5D,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,KAAK;SACN,CAAC;IACJ,CAAC;CACF,CAAA;AApXY,oCAAoC;IADhD,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAElD,WAAA,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAE3C,WAAA,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,CAAA;IAE5D,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAEjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAElD,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAE9C,WAAA,MAAM,CAAC,0BAA0B,CAAC,wBAAwB,CAAC,CAAA;yDAP7B,gCAAgC;GATtD,oCAAoC,CAoXhD","sourcesContent":["import {\n type AppConfiguration,\n type AppConfigurationService,\n ApplicationRuntimeProfile,\n inject,\n injectable,\n type LoggerService,\n type ProviderRuntimeArtifact,\n type RuntimePrincipalBackendService,\n type SystemAccessBackendService,\n SAAS_SERVICE_TYPES,\n type StartApplicationBackendService, describeCaughtError } from '@wildo-ai/saas-backend-lib';\nimport { ErrorCustomMessageReference, ErrorType, type ScheduledRecoveryPolicy } from '@wildo-ai/saas-models';\nimport { assertProviderRuntimeEnvInSync } from '@wildo-ai/platform-config-lib';\nimport { MinionScopedServicesRegistryHandlerBackendService } from '../../base-classes/services/services/minion-scoped-services-registry-handler.backend.service';\nimport { SAAS_MINIONS_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { OwnScheduleReaderBackendService } from './own-schedule-reader.backend.service';\nimport {\n MinionTickConsumerBackendService,\n type MinionTickHandler,\n} from '../queue/minion-tick-consumer.backend.service';\nimport type {\n MinionInitializationConfig,\n MinionProviderRuntimeArtifact,\n MinionTickAuthorHandler,\n MinionTickContext,\n MinionTickReconciliationHandler,\n} from './define-minion-init';\n\ntype MinionAwareAppConfiguration = AppConfiguration & {\n minions?: Record<string, MinionRuntimeConfig>;\n};\n\ntype MinionRuntimeConfig = NonNullable<NonNullable<AppConfiguration['minions']>[string]>;\n\n@injectable()\nexport class StartMinionApplicationBackendService {\n private tickConsumerStarted = false;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.StartApplicationService)\n private readonly startApplicationService: StartApplicationBackendService,\n @inject(SAAS_SERVICE_TYPES.AppConfigService)\n private readonly appConfigService: AppConfigurationService,\n @inject(SAAS_MINIONS_SERVICE_TYPES.MinionTickConsumerService)\n private readonly tickConsumer: MinionTickConsumerBackendService,\n @inject(SAAS_SERVICE_TYPES.Logger)\n private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.RuntimePrincipalService)\n private readonly runtimePrincipal: RuntimePrincipalBackendService,\n @inject(SAAS_SERVICE_TYPES.SystemAccessService)\n private readonly systemAccess: SystemAccessBackendService,\n @inject(SAAS_MINIONS_SERVICE_TYPES.OwnScheduleReaderService)\n private readonly ownScheduleReader: OwnScheduleReaderBackendService,\n ) {}\n\n public async initialize(config: MinionInitializationConfig): Promise<void> {\n const {\n minionName,\n serviceIdentifier,\n onTick,\n tickRecovery,\n reconcileTick,\n ...startupConfig\n } = config;\n // Declare WHO this process is before anything can perform a privileged access.\n //\n // Established here, in framework-owned minion startup, rather than left to each\n // minion author — attribution that an author can forget is attribution that will\n // be missing exactly when an auditor needs it. Every minion therefore carries its\n // identity structurally, by virtue of being a minion.\n //\n // Attribution only: this grants nothing. A minion's operations are governed by its\n // role and its `resourceAccess` whitelist; its cross-tenant reach comes from the\n // system-access door. See `.claude/plans/minion-runtime-scope.md` (D9).\n //\n // assurance-control: WILDO.AUDIT.SECURITY_EVENT — privileged access by a non-human\n // background runtime is attributable to that runtime.\n this.runtimePrincipal.initialize({\n runtimeProfile: ApplicationRuntimeProfile.MINION,\n runtimeKey: minionName,\n serviceIdentifier: serviceIdentifier ?? `minions.${minionName}`,\n });\n\n const normalizedProviderRuntime = this.normalizeProviderRuntime(\n startupConfig.providerRuntime,\n minionName,\n );\n\n // Boot-time fail-closed reconciliation between the typed\n // `wildo-provider-runtime.generated.ts` artifact and the\n // `.wildo-providers.env` file mounted into this process. Catches\n // stale-sync drift (operator regenerated one surface but not the\n // other) BEFORE the registry filter would silently boot with\n // mismatched topology.\n //\n // Skipped when:\n // - the artifact is absent (host authored zero providers AND no\n // scope block in `wildo.saas.config.ts`); or\n // - the artifact has zero `providerRefs` (host authored an\n // explicit empty scope `providers: {}`). The CLI emitter\n // deliberately does NOT write `.wildo-providers.env` in that\n // case, so the env-vars are absent — running the assertion\n // would raise a false-positive fail-closed.\n // Defensive `?? []` — the schema marks `providerRefs` optional, so\n // a hand-crafted artifact (test fixture / future format drift)\n // could omit it. Without the fallback `.length` would TypeError\n // before fail-closed produced its actionable message. Production\n // CLI emit always defaults to `[]`, so this is hardening only.\n const projectedProviderRefs = normalizedProviderRuntime?.providerRefs ?? [];\n if (normalizedProviderRuntime && projectedProviderRefs.length > 0) {\n assertProviderRuntimeEnvInSync({\n artifactProviderRefs: projectedProviderRefs,\n artifactSourceDigest: normalizedProviderRuntime.sourceDigest,\n hostKind: 'minion',\n hostKey: minionName,\n });\n }\n\n await this.startApplicationService.initialize({\n ...startupConfig,\n providerRuntime: normalizedProviderRuntime,\n headlessMode: true,\n skipCronSync: true,\n // A minion reuses the full backend startup lifecycle but is NOT a job\n // worker for the shared application queues — it consumes ONLY its own\n // `minion-tick.<name>` queue (subscribed below via `startTickConsumer`).\n // Skipping the shared job consumers keeps RabbitMQ from round-robining\n // scheduled-cron ticks onto this process (which would dead-letter every\n // tick it can't interpret). The broker connection itself is still made,\n // because the tick consumer depends on it.\n skipJobConsumers: true,\n serviceIdentifier: serviceIdentifier ?? `minions.${minionName}`,\n afterResourcesRegistryInitialized: async ({\n appConfig,\n resourcesRegistryService,\n errorBuilder,\n }) => {\n const minionConfig = this.getMinionRuntimeConfig(\n appConfig as MinionAwareAppConfiguration,\n minionName,\n errorBuilder,\n );\n const resourceAccess = minionConfig.resourceAccess;\n const knownResourceTypes = new Set(resourcesRegistryService.getResourceTypes());\n const unknownResourceTypes = [\n ...(resourceAccess?.read ?? []),\n ...(resourceAccess?.write ?? []),\n ].filter((resourceType, index, all) => (\n resourceType !== '*'\n && !knownResourceTypes.has(resourceType)\n && all.indexOf(resourceType) === index\n ));\n\n if (unknownResourceTypes.length > 0) {\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, undefined, {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message:\n `Minion '${minionName}' references unknown resources in resourceAccess: `\n + `[${unknownResourceTypes.join(', ')}].`,\n minionName,\n unknownResourceTypes,\n },\n });\n }\n },\n servicesRegistryDecoratorFactory: (registry, { appConfig, errorBuilder }) => (\n new MinionScopedServicesRegistryHandlerBackendService(\n registry as any,\n minionName,\n this.getMinionRuntimeConfig(\n appConfig as MinionAwareAppConfiguration,\n minionName,\n errorBuilder,\n ).resourceAccess,\n ).asDecoratedRegistry()\n ),\n });\n\n // KD-12 auto-wiring: every minion subscribes to its dedicated tick\n // queue (`wildo.queue.<appId>.minion-tick.<minionName>`). Cron-mode\n // minions receive ticks from `platform-crontabs-batches-manager`;\n // always-up minions receive nothing on this queue under normal\n // operation but the subscription is harmless (no message ⇒ no\n // dispatch) and keeps the runtime contract symmetric across modes.\n await this.startTickConsumer(minionName, onTick, tickRecovery, reconcileTick);\n }\n\n public async shutdown(): Promise<void> {\n if (this.tickConsumerStarted) {\n try {\n await this.tickConsumer.stop();\n } catch (error) {\n this.logger.warn('Failed to stop minion tick consumer cleanly', {\n error: describeCaughtError(error),\n });\n } finally {\n this.tickConsumerStarted = false;\n }\n }\n await this.startApplicationService.shutdown();\n }\n\n public isApplicationInitialized(): boolean {\n return this.startApplicationService.isApplicationInitialized();\n }\n\n private async startTickConsumer(\n minionName: string,\n onTick: MinionTickAuthorHandler | undefined,\n tickRecovery: Partial<ScheduledRecoveryPolicy> | undefined,\n reconcileTick: MinionTickReconciliationHandler | undefined,\n ): Promise<void> {\n // The surface the handler is ALLOWED to work with, assembled once at the tick\n // boundary. Handed to the author rather than left for them to resolve from the\n // container: `systemAccess` here is already contained by this minion's\n // `resourceAccess` ACL, because startup rebinds the services registry to the\n // scoped decorator before any tick can be delivered. An author who resolved the\n // door themselves could bypass that; an author handed this one cannot.\n const context: Omit<MinionTickContext, 'scheduledAttempt'> = {\n systemAccess: this.systemAccess,\n minionName,\n // Same reasoning as `systemAccess`: handed to the author rather than left\n // to be resolved from the container. A reader an author constructs is a\n // reader an author could construct with a different identity; this one is\n // bound to the process's own attested principal and cannot be pointed\n // elsewhere.\n ownSchedule: this.ownScheduleReader,\n };\n\n // Missing handlers stay absent: the durable coordinator records REVIEW instead of\n // treating an unimplemented tick as successful work.\n const handler: MinionTickHandler | undefined = onTick\n ? async (token, scheduledAttempt) => onTick(token, { ...context, scheduledAttempt })\n : undefined;\n\n const evidencePolicies = this.appConfigService.config?.scheduledEvidence?.minions;\n for (const configuredName of Object.keys(evidencePolicies ?? {})) {\n if (!Object.hasOwn(this.appConfigService.config.minions ?? {}, configuredName)) {\n this.logger.warn('Scheduled evidence policy names an undeclared minion; no evidence will be collected for this key', { minionName: configuredName });\n }\n }\n await this.tickConsumer.start({\n applicationId: this.appConfigService.applicationId,\n minionName,\n handler,\n recoveryPolicy: tickRecovery,\n evidencePolicy: evidencePolicies && Object.hasOwn(evidencePolicies, minionName) ? evidencePolicies[minionName] : undefined,\n reconcile: reconcileTick\n ? async (token, scheduledAttempt) => reconcileTick(token, { ...context, scheduledAttempt })\n : undefined,\n });\n this.tickConsumerStarted = true;\n }\n\n private getMinionRuntimeConfig(\n appConfig: MinionAwareAppConfiguration,\n minionName: string,\n errorBuilder?: {\n buildError: (\n errorType: ErrorType,\n executionContext: undefined,\n options: {\n customMessageReference?: ErrorCustomMessageReference;\n context?: Record<string, unknown>;\n },\n ) => unknown;\n },\n ): MinionRuntimeConfig {\n const minionConfig = appConfig.minions?.[minionName];\n if (minionConfig) {\n return minionConfig;\n }\n\n if (!errorBuilder) {\n throw new Error(`Minion '${minionName}' is missing from appConfig.minions.`);\n }\n\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, undefined, {\n customMessageReference: ErrorCustomMessageReference.CONFIGURATION,\n context: {\n message:\n `Minion '${minionName}' is not declared in the managed runtime config. `\n + 'Re-sync the application bootstrap material before starting the minion.',\n minionName,\n },\n });\n }\n\n /**\n * Bridge the per-minion materialized provider runtime artifact into the\n * `ProviderRuntimeArtifact` shape consumed by `StartApplicationBackendService`\n * (and ultimately filtered by `BackendProviderRegistryBackendService`).\n *\n * Three accepted input shapes:\n *\n * 1. `{ artifactKind: 'backend', scope: ... }` — already projected to a\n * backend-shaped single-scope artifact (e.g. produced by an\n * embedding host that pre-selected the scope).\n * 2. `{ artifactKind: 'minions', scope: ..., scopes: undefined }` —\n * what `wildo config sync` writes to each minion's\n * `src/generated/wildo-provider-runtime.generated.ts`. The CLI calls\n * `selectScopedProviderRuntimeArtifact(artifacts.minions, minionKey)`\n * so the file already carries only this minion's scope. We unwrap\n * it here to the canonical backend-shaped artifact.\n * 3. `{ artifactKind: 'minions', scopes: { [name]: ... } }` —\n * multi-scope minion artifact (legacy / non-CLI-driven hosts that\n * pass the unscoped artifact). We resolve `scopes[minionName]`.\n *\n * Anything else fails fast with a clear locator. Each minion process\n * must only see its own scope — there is no fallback to other scopes,\n * no merging across minions, and no silent recovery from a missing\n * scope.\n */\n private normalizeProviderRuntime(\n providerRuntime: MinionInitializationConfig['providerRuntime'],\n minionName: string,\n ): ProviderRuntimeArtifact | undefined {\n if (!providerRuntime) {\n return undefined;\n }\n if (providerRuntime.artifactKind === 'backend') {\n return providerRuntime;\n }\n const artifactKind = providerRuntime.artifactKind;\n if (artifactKind !== 'minions') {\n throw new Error(\n `Unsupported provider runtime artifactKind '${artifactKind}' for minion '${minionName}'.`,\n );\n }\n\n return this.selectMinionProviderRuntimeScope(providerRuntime, minionName);\n }\n\n private selectMinionProviderRuntimeScope(\n providerRuntime: MinionProviderRuntimeArtifact,\n minionName: string,\n ): ProviderRuntimeArtifact {\n const preScopedScope = (providerRuntime as MinionProviderRuntimeArtifact & {\n scope?: ProviderRuntimeArtifact['scope'];\n }).scope;\n const scopes = providerRuntime.scopes as\n | Record<string, ProviderRuntimeArtifact['scope']>\n | undefined;\n\n let scope: ProviderRuntimeArtifact['scope'] | undefined;\n\n if (preScopedScope && (!scopes || Object.keys(scopes).length === 0)) {\n // Shape 2 — the CLI-emitted per-minion module.\n scope = preScopedScope;\n } else if (scopes) {\n // Shape 3 — unscoped multi-scope artifact.\n scope = scopes[minionName];\n if (!scope) {\n throw new Error(\n `Provider runtime artifact does not contain a scope for minion '${minionName}'. `\n + `Re-run \\`wildo config sync\\` and verify the minion is declared in `\n + `wildo.saas.config.ts \\`providers.scopes.minions\\`.`,\n );\n }\n }\n\n if (!scope) {\n throw new Error(\n `Provider runtime artifact for minion '${minionName}' is missing both a `\n + `pre-scoped \\`scope\\` and a multi-scope \\`scopes\\` map. The artifact is malformed.`,\n );\n }\n\n // Recompute `providerRefs` from the projected per-host scope, NOT\n // from the multi-scope union the parent artifact carries. The\n // `buildMultiScopeArtifactMetadata` upstream computes\n // `providerRefs` as the union across all hosts; preserving that\n // here would make the boot-time `assertProviderRuntimeEnvInSync`\n // guard treat sibling-scope refs as \"this host has providers\" and\n // mistakenly run reconciliation on hosts whose own scope is empty.\n // Mirrors `selectScopedProviderRuntimeArtifact` in\n // `provider-runtime-artifacts.ts`.\n const projectedProviderRefs = Object.keys(scope.providers ?? {}).sort();\n // Narrowed with the refs, for the same reason (#330): the import map on a multi-scope artifact\n // is the union across every host, and handing this host a sibling's package specifiers would\n // tell it that it may load something it never declared.\n const projectedProviderRuntimeImports = Object.fromEntries(\n Object.entries(\n providerRuntime.providerRuntimeImports ?? {},\n ).filter(([providerRef]) => projectedProviderRefs.includes(providerRef)),\n );\n // Narrowed with the refs as well (#1672): a host applies augmentations only to providers it declares, and a\n // sibling's opt-in must not load a package into this process.\n const projectedAugmentations = Object.entries(providerRuntime.providerRuntimeAugmentations ?? {})\n .filter(([providerRef]) => projectedProviderRefs.includes(providerRef));\n\n return {\n __AUTOGENERATED__: providerRuntime.__AUTOGENERATED__,\n generatedBy: providerRuntime.generatedBy,\n generatedAt: providerRuntime.generatedAt,\n sourceDigest: providerRuntime.sourceDigest,\n providerRefs: projectedProviderRefs,\n providerRuntimeImports: projectedProviderRuntimeImports,\n ...(projectedAugmentations.length === 0 ? {} : { providerRuntimeAugmentations: Object.fromEntries(projectedAugmentations) }),\n providerGraphDigest: providerRuntime.providerGraphDigest,\n lockfileSectionDigest: providerRuntime.lockfileSectionDigest,\n artifactKind: 'backend',\n modules: providerRuntime.modules,\n scope,\n };\n }\n}\n"]}
|