{"version":3,"file":"mission-executor.d.ts","sourceRoot":"","sources":["../../../src/core/mission-domain/mission-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,KAAK,aAAa,EAA8B,MAAM,qBAAqB,CAAC;AAErF,+EAA+E;AAC/E,MAAM,WAAW,2BAA2B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,qBAAqB,GAC9B;IACA,IAAI,EAAE,iBAAiB,GAAG,0BAA0B,GAAG,mBAAmB,CAAC;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,2BAA2B,CAAC;CACxC,GACD;IACA,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,WAAW,GAAG,kBAAkB,CAAC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,2BAA2B,CAAC;CACxC,GACD;IACA,IAAI,EAAE,qBAAqB,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,2BAA2B,CAAC;IACzC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACnD,CAAC;AAEL,MAAM,WAAW,wBAAwB;IACxC,OA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,OAAO,CACZ,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACzD,OAAO,CAAC,aAAa,CAAC,CAIxB;IAED;;;;;OAKG;IACG,WAAW,CAChB,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACzD,OAAO,CAAC,aAAa,EAAE,CAAC,CAQ1B;IAED;;;;;;;;OAQG;IACG,YAAY,CACjB,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACzD,OAAO,CAAC,aAAa,EAAE,CAAC,CAU1B;CACD","sourcesContent":["/**\n * First-Class Mission Executor contract (2.3.0).\n *\n * The executor seam decouples mission identity from any execution mechanism.\n * Executors accept a canonical MissionRequest, produce a canonical\n * MissionHandle, and resolve a canonical MissionResult. Nothing in this file\n * references Node ChildProcess, a provider client, a CLI parser, or UI.\n */\n\nimport type { MissionHandle } from \"./mission-handle.js\";\nimport type { MissionRequest } from \"./mission-request.js\";\nimport { type MissionResult, shouldContinueMissionChain } from \"./mission-result.js\";\n\n/** Stable correlation carried by execution observers and remote transports. */\nexport interface MissionExecutionCorrelation {\n\tmissionId: string;\n\tassignmentId?: string;\n\tattemptId?: string;\n\texecutionId?: string;\n\tsessionId?: string;\n}\n\nexport type MissionExecutionEvent =\n\t| {\n\t\t\ttype: \"attempt_started\" | \"execution_launch_started\" | \"execution_started\";\n\t\t\teventId: string;\n\t\t\tatMs: number;\n\t\t\tcorrelation: MissionExecutionCorrelation;\n\t  }\n\t| {\n\t\t\ttype: \"execution_retry\";\n\t\t\teventId: string;\n\t\t\tatMs: number;\n\t\t\tretryClass: \"execution\" | \"remote_execution\";\n\t\t\tretryIndex: number;\n\t\t\treason: string;\n\t\t\tcorrelation: MissionExecutionCorrelation;\n\t  }\n\t| {\n\t\t\ttype: \"execution_completed\" | \"execution_failed\" | \"execution_cancelled\";\n\t\t\teventId: string;\n\t\t\tatMs: number;\n\t\t\tcorrelation: MissionExecutionCorrelation;\n\t\t\tstate: MissionResult[\"state\"];\n\t\t\texecutionOutcome: MissionResult[\"executionOutcome\"];\n\t  };\n\nexport interface MissionExecutionObserver {\n\tonEvent: (event: MissionExecutionEvent) => void;\n}\n\nexport interface MissionLaunchOptions {\n\tsignal?: AbortSignal;\n\t/**\n\t * Execution fencing identity (leaseId + fencingToken) carried into the\n\t * executor launch so a remote substrate can correlate its result back to the\n\t * authoritative owner. The durable coordinator remains the only authority\n\t * that accepts/rejects the terminal commit; this field is correlation, not\n\t * authorization.\n\t */\n\tfencing?: { leaseId: string; fencingToken: number };\n\t/** Authoritative attempt identity for runtime correlation. */\n\texecutionId?: string;\n\tattemptId?: string;\n\t/** One-based attempt number; >1 identifies an actual execution retry. */\n\tattemptNumber?: number;\n\tassignmentId?: string;\n\tsessionId?: string;\n}\n\nexport interface MissionExecutor {\n\t/**\n\t * Stable executor identity (e.g. \"process\", \"in-process\", \"remote\"). Used to\n\t * select an executor and to tag executor diagnostics.\n\t */\n\treadonly executorId: string;\n\n\t/** Launch a mission and return a handle immediately (or after the child is started). */\n\tlaunch(request: MissionRequest, options?: MissionLaunchOptions): Promise<MissionHandle>;\n\n\t/** Resolve a launched mission to its final MissionResult. */\n\tawaitResult(handle: MissionHandle, options?: { signal?: AbortSignal }): Promise<MissionResult>;\n\n\t/** Request cancellation of a launched mission. Idempotent. */\n\tcancel(handle: MissionHandle, reason?: string): Promise<void>;\n}\n\n// =============================================================================\n// MissionExecutionService\n// =============================================================================\n\nexport class MissionExecutionService {\n\tprivate readonly _executors = new Map<string, MissionExecutor>();\n\tprivate _defaultExecutorId = \"process\";\n\n\tregister(executor: MissionExecutor): void {\n\t\tthis._executors.set(executor.executorId, executor);\n\t}\n\n\t/** Set the executor used when no explicit executorId is supplied. */\n\tsetDefaultExecutorId(executorId: string): void {\n\t\tthis._defaultExecutorId = executorId;\n\t}\n\n\texecutor(executorId: string): MissionExecutor {\n\t\tconst executor = this._executors.get(executorId);\n\t\tif (!executor) throw new Error(`Unknown mission executor: ${executorId}`);\n\t\treturn executor;\n\t}\n\n\t/**\n\t * Launch + await a single mission, producing a MissionResult. The caller\n\t * reasons in domain terms; executor-specific machinery stays behind the seam.\n\t */\n\tasync execute(\n\t\trequest: MissionRequest,\n\t\toptions: { executorId?: string; signal?: AbortSignal } = {},\n\t): Promise<MissionResult> {\n\t\tconst executor = this.executor(options.executorId ?? this._defaultExecutorId);\n\t\tconst handle = await executor.launch(request, { signal: options.signal });\n\t\treturn executor.awaitResult(handle, { signal: options.signal });\n\t}\n\n\t/**\n\t * Execute several missions concurrently and return their individual\n\t * MissionResults in request order. Aggregation is the caller's concern\n\t * (see `aggregateMissionResults`); this method never collapses failures into\n\t * a scalar success boolean.\n\t */\n\tasync executeMany(\n\t\trequests: readonly MissionRequest[],\n\t\toptions: { executorId?: string; signal?: AbortSignal } = {},\n\t): Promise<MissionResult[]> {\n\t\tconst executor = this.executor(options.executorId ?? this._defaultExecutorId);\n\t\treturn Promise.all(\n\t\t\trequests.map(async (request) => {\n\t\t\t\tconst handle = await executor.launch(request, { signal: options.signal });\n\t\t\t\treturn executor.awaitResult(handle, { signal: options.signal });\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Execute missions sequentially. The transitional runtime uses an\n\t * execution-compatible chain policy: a child that SUCCEEDED (verified) or\n\t * PARTIAL (execution completed normally but unverified) allows the next\n\t * dependent child to run; a hard failure (FAILED / CANCELLED / TIMED_OUT /\n\t * CRASHED) stops the chain. Returns the results produced up to and\n\t * including the stopping child. Callers aggregate with\n\t * `aggregateMissionResults` for a structured final verdict.\n\t */\n\tasync executeChain(\n\t\trequests: readonly MissionRequest[],\n\t\toptions: { executorId?: string; signal?: AbortSignal } = {},\n\t): Promise<MissionResult[]> {\n\t\tconst executor = this.executor(options.executorId ?? this._defaultExecutorId);\n\t\tconst results: MissionResult[] = [];\n\t\tfor (const request of requests) {\n\t\t\tconst handle = await executor.launch(request, { signal: options.signal });\n\t\t\tconst result = await executor.awaitResult(handle, { signal: options.signal });\n\t\t\tresults.push(result);\n\t\t\tif (!shouldContinueMissionChain(result)) break;\n\t\t}\n\t\treturn results;\n\t}\n}\n"]}