{"version":3,"file":"parent-execution.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/parent-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EACN,yBAAyB,EACzB,KAAK,gCAAgC,EACrC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACN,qBAAqB,EACrB,KAAK,4BAA4B,EAEjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC,oBAA8B,CAAC;AAEjF,MAAM,WAAW,mCAAmC;IACnD,+DAA+D;IAC/D,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,gCAAgC;IAChC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,oEAAoE;IACpE,YAAY,EAAE,mBAAmB,CAAC;IAClC,oEAAoE;IACpE,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,+BAA+B,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,OAAO,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1C,6EAA6E;IAC7E,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,mFAAmF;IACnF,MAAM,CAAC,EAAE,IAAI,CAAC,4BAA4B,EAAE,WAAW,GAAG,QAAQ,GAAG,iBAAiB,CAAC,CAAC;IACxF,wFAAwF;IACxF,WAAW,CAAC,EAAE,wBAAwB,CAAC;IACvC,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,oDAAoD;IACpD,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,MAAM,CAAC;IACzD,6EAA6E;IAC7E,WAAW,CAAC,EAAE,gCAAgC,CAAC;CAC/C;AAED,6EAA6E;AAC7E,MAAM,WAAW,4BAA4B;IAC5C,gEAAgE;IAChE,IAAI,EAAE,+BAA+B,CAAC;IACtC,mDAAmD;IACnD,SAAS,EAAE,8BAA8B,CAAC;IAC1C,oDAAoD;IACpD,QAAQ,EAAE,4BAA4B,CAAC;IACvC,kEAAkE;IAClE,WAAW,EAAE,yBAAyB,CAAC;IACvC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CACjD,OAAO,EAAE,mCAAmC,GAC1C,4BAA4B,CAkD9B","sourcesContent":["/**\n * Parent orchestration execution wiring (2.17.0).\n *\n * The safe production factory for the parent side of the orchestration\n * boundary. It composes the EXISTING parts — nothing is re-implemented:\n *\n *   - `SchedulerWorkerChildExecutionPort` (or an injected\n *     `OrchestrationChildExecutionPort`) — the child execution authority.\n *     It verifies the parent's durable contract and enqueues scheduling\n *     intents; it never launches.\n *   - `OrchestrationLifecycleExecutor` — resolves the parent's named\n *     authority (verified, never defaulted) and drives one launch pass per\n *     materialized node through the port.\n *   - `OrchestrationMissionExecutor` — the durable parent `MissionExecutor`:\n *     it owns no lease and writes no parent state itself; it drives the plan\n *     through the lifecycle/port seams and reports a terminal MissionResult.\n *   - `DurableMissionCoordinator` — owns the parent execution lease, every\n *     authoritative parent lifecycle transition, and the terminal commit.\n *\n * Nothing here bypasses Scheduler -> Assignment -> Worker: the parent\n * executor only enqueues durable scheduling intents through the port; actual\n * child execution remains owned by the scheduler tick and the worker daemon.\n */\n\nimport type { AssignmentControlService } from \"../assignment/assignment-control-service.js\";\nimport {\n\tDurableMissionCoordinator,\n\ttype DurableMissionCoordinatorOptions,\n} from \"../mission-domain/durable-coordinator.js\";\nimport type { DurableMissionStore } from \"../mission-domain/durable-store.js\";\nimport type { MissionRequest } from \"../mission-domain/mission-request.js\";\nimport type { SchedulerControlService } from \"../scheduler/scheduler-control-service.js\";\nimport type { WorkerControlService } from \"../worker-daemon/worker-control-service.js\";\nimport { SchedulerWorkerChildExecutionPort } from \"./child-execution-port.js\";\nimport { OrchestrationLifecycleExecutor } from \"./lifecycle-executor.js\";\nimport { OrchestrationMissionExecutor } from \"./orchestration-mission-executor.js\";\nimport type { OrchestratorService } from \"./orchestrator.js\";\nimport {\n\tSchedulerWorkerDriver,\n\ttype SchedulerWorkerDriverOptions,\n\tSchedulerWorkerTerminalCleanup,\n} from \"./scheduler-worker-driver.js\";\nimport type { OrchestrationChildExecutionPort, OrchestrationStore } from \"./types.js\";\n\n/**\n * Default stable identity of the scheduler/worker child execution authority.\n * A parent's durable contract\n * (`MissionRequest.orchestrationExecution.childExecutionAuthority`) must name\n * exactly this identity for the default port to accept the orchestration.\n */\nexport const DEFAULT_ORCHESTRATION_CHILD_AUTHORITY = \"scheduler-worker\" as const;\n\nexport interface ParentOrchestrationExecutionOptions {\n\t/** Durable mission store (parent contract + child records). */\n\tmissions: DurableMissionStore;\n\t/** Orchestration plan store. */\n\tstore: OrchestrationStore;\n\t/** Reconciliation/materialization service for the parent's plan. */\n\torchestrator: OrchestratorService;\n\t/** Scheduler used by the default child execution authority port. */\n\tscheduler?: SchedulerControlService;\n\t/**\n\t * Child execution authority port. When omitted, a\n\t * `SchedulerWorkerChildExecutionPort` is built over `scheduler` with\n\t * `authority` and `workers`. When present, `authority` and `workers` are\n\t * ignored (the port's own `authority` identity is used).\n\t */\n\tport?: OrchestrationChildExecutionPort;\n\t/**\n\t * Stable identity of the child execution authority for the default port.\n\t * Default: `DEFAULT_ORCHESTRATION_CHILD_AUTHORITY`.\n\t */\n\tauthority?: string;\n\t/** Workers consulted for child status/terminal polling (read-only). */\n\tworkers?: readonly WorkerControlService[];\n\t/** Worker started by the optional bounded local Scheduler -> Worker pump. */\n\tworker?: WorkerControlService;\n\t/** Optional bounded local Scheduler -> Worker pump for application composition. */\n\tdriver?: Omit<SchedulerWorkerDriverOptions, \"scheduler\" | \"worker\" | \"terminalCleanup\">;\n\t/** Existing Assignment authority used for mandatory bounded parent-terminal cleanup. */\n\tassignments?: AssignmentControlService;\n\t/** Executor id for the parent orchestration executor (default \"orchestration\"). */\n\texecutorId?: string;\n\t/** Child status poll cadence for the parent executor (default 250ms). */\n\tpollMs?: number;\n\t/** Parent execution wall-time deadline (default 30 minutes). */\n\tmaxWallTimeMs?: number;\n\t/** Clock for deterministic construction (tests). */\n\tnow?: () => number;\n\t/** Executor-scoped execution id factory (tests). */\n\texecutionIdFactory?: (request: MissionRequest) => string;\n\t/** Coordinator options for the parent (lease duration, heartbeat, owner). */\n\tcoordinator?: DurableMissionCoordinatorOptions;\n}\n\n/** The composed parent execution stack, ready for `coordinator.resume()`. */\nexport interface ParentOrchestrationExecution {\n\t/** The child execution authority in use (injected or built). */\n\tport: OrchestrationChildExecutionPort;\n\t/** Parent lifecycle executor bound to the port. */\n\tlifecycle: OrchestrationLifecycleExecutor;\n\t/** Durable parent orchestration MissionExecutor. */\n\texecutor: OrchestrationMissionExecutor;\n\t/** Coordinator that owns the parent lease and terminal commit. */\n\tcoordinator: DurableMissionCoordinator;\n\t/** Optional bounded Scheduler -> Worker application driver. */\n\tdriver?: SchedulerWorkerDriver;\n}\n\n/**\n * Build the parent orchestration execution stack over the existing\n * stores/services. Construction verifies the port set (a duplicate authority\n * identity is an error) but performs no launches and writes no state: the\n * parent is driven only when `coordinator.resume(parentMissionId)` is called.\n */\nexport function createParentOrchestrationExecution(\n\toptions: ParentOrchestrationExecutionOptions,\n): ParentOrchestrationExecution {\n\tif (!options.port && !options.scheduler)\n\t\tthrow new Error(\"SCHEDULER_REQUIRED: a scheduler is required when no child execution port is provided\");\n\tconst port =\n\t\toptions.port ??\n\t\tnew SchedulerWorkerChildExecutionPort({\n\t\t\tauthority: options.authority ?? DEFAULT_ORCHESTRATION_CHILD_AUTHORITY,\n\t\t\tmissions: options.missions,\n\t\t\tstore: options.store,\n\t\t\tscheduler: options.scheduler!,\n\t\t\tworkers: options.workers ?? (options.worker ? [options.worker] : undefined),\n\t\t\tnow: options.now,\n\t\t});\n\tconst lifecycle = new OrchestrationLifecycleExecutor({\n\t\tmissions: options.missions,\n\t\tstore: options.store,\n\t\tports: [port],\n\t});\n\tconst executor = new OrchestrationMissionExecutor({\n\t\tmissions: options.missions,\n\t\tstore: options.store,\n\t\tlifecycle,\n\t\torchestrator: options.orchestrator,\n\t\texecutorId: options.executorId,\n\t\tpollMs: options.pollMs,\n\t\tmaxWallTimeMs: options.maxWallTimeMs,\n\t\tnow: options.now,\n\t\texecutionIdFactory: options.executionIdFactory,\n\t});\n\tconst coordinator = new DurableMissionCoordinator(options.missions, executor, options.coordinator);\n\tif (options.driver && (!options.scheduler || !options.worker))\n\t\tthrow new Error(\"SCHEDULER_WORKER_DRIVER_INVALID: scheduler and worker are required when driver is configured\");\n\tif (options.driver && (!options.assignments || !options.scheduler))\n\t\tthrow new Error(\"SCHEDULER_WORKER_DRIVER_INVALID: assignments and scheduler are required for terminal cleanup\");\n\tconst terminalCleanup = options.assignments\n\t\t? new SchedulerWorkerTerminalCleanup({\n\t\t\t\tmissions: options.missions,\n\t\t\t\tscheduler: options.scheduler!,\n\t\t\t\tassignments: options.assignments,\n\t\t\t})\n\t\t: undefined;\n\tconst driver = options.driver\n\t\t? new SchedulerWorkerDriver({\n\t\t\t\tscheduler: options.scheduler!,\n\t\t\t\tworker: options.worker!,\n\t\t\t\tterminalCleanup: terminalCleanup!,\n\t\t\t\t...options.driver,\n\t\t\t})\n\t\t: undefined;\n\treturn { port, lifecycle, executor, coordinator, driver };\n}\n"]}