import './paths-2M_UxD_H.js';
import { C as getLifecycleStatus, D as recordStageProgress } from './tasks-CnwUAUXf.js';
import './query-ops-BDMaTdYw.js';
import 'node:fs';
import 'node:path';
import 'node:os';
import 'node:events';
import 'node:diagnostics_channel';
import 'fs';
import 'events';
import 'util';
import 'path';
import 'assert';
import 'worker_threads';
import 'module';
import 'node:url';
import 'url';
import 'buffer';
import 'node:module';
import 'node:child_process';
import 'node:crypto';
import 'node:process';
import 'node:async_hooks';
import './data-accessor-CVbz8X_7.js';
import './conduit-Ca_OFWR_.js';
import './indexes-aYlULWG3.js';
import './utils-BvHPJOVk.js';
import './unique-constraint-BM-Apx1H.js';
import './chunk-DDP5xfzh.js';
import './sqlite-Dsbe0wec.js';
import './dual-scope-db-ATrwq0LH.js';
import './memory-schema-Bi7cChwo.js';
import './agent-registry-BtE5uhMO.js';
import './nexus-sqlite2-DgTuv9BQ.js';
import './nexus-schema2-BEd-ol6e.js';
import './logger-ChCwlV5k.js';
import 'node:sqlite';
import './lock-BoHF25mx.js';
import './index-IVoIz4D5.js';
import 'constants';
import 'stream';
import 'node:fs/promises';
import 'jsonc-parser';
import '@cleocode/cant';
import 'node:util';
import 'node:buffer';
import 'child_process';
import './branch-lock-qP1EkZ7p.js';
import './src2-DK8DKufK.js';
import 'llmtxt/identity';
import './sessions-j73dkbCI.js';
import './registry2-BSyCTA3q.js';
import './index-Ca4C2M45.js';
import './mvi-helpers-BNsJ8ZpQ.js';
import './session-store-OwQWMSf_.js';
import './session-manifest-ZHrj54LR.js';
import './storage-B9UA3BHR.js';
import './config-B0nEjgSh.js';
import './json-DXl7iDYg.js';
import './data-safety-central-vmfu_Y4J.js';
import './sqlite-data-accessor-C59wZ0zp.js';
import './cross-db-cleanup-C_FLyd-6.js';
import 'node:net';

//#endregion
//#region ../core/dist/orchestrate/lifecycle-ops.js
/**
* Orchestrate Lifecycle Operations
*
* Startup, bootstrap, criticalPath, unblockOpportunities, check,
* skillInject, and parallel wrappers migrated from
* packages/cleo/src/dispatch/engines/orchestrate-engine.ts.
*
* @task T1570
* @task T4478
* @task T4632
* @task T1634 — LOOM auto-init helper
*/
/**
* Idempotently initialize the LOOM (RCASD-IVTR) lifecycle pipeline for an
* epic at the 'research' stage.
*
* This is the canonical LOOM-init primitive shared by `orchestrateStartup`
* (called via `cleo orchestrate start`) and the `addTask` epic creation hook
* (T1634 — LOOM auto-init for new epics). Extracted to eliminate duplication
* and ensure a single source of truth for the initialization invariant.
*
* Behaviour:
* - If no pipeline exists for `epicId`, creates one at 'research/in_progress'.
* - If a pipeline already exists, this is a no-op — returns `{ initialized: false }`.
* - Never throws; failures are swallowed so callers (especially fire-and-forget hooks)
*   can treat this as best-effort. Errors are returned via the result shape.
*
* @param epicId - Epic task ID to initialize LOOM for.
* @param projectRoot - Project root path for DB resolution.
* @returns Result indicating whether LOOM was freshly initialized.
* @task T1634
*/
async function initLoomForEpic(epicId, projectRoot) {
	try {
		if ((await getLifecycleStatus(projectRoot, { epicId })).initialized) return {
			initialized: false,
			alreadyInitialized: true
		};
		await recordStageProgress(projectRoot, {
			taskId: epicId,
			stage: "research",
			status: "in_progress"
		});
		return {
			initialized: true,
			alreadyInitialized: false
		};
	} catch (err) {
		return {
			initialized: false,
			alreadyInitialized: false,
			error: err.message
		};
	}
}

export { initLoomForEpic };
//# sourceMappingURL=lifecycle-ops2-C-a3bc8k.js.map
