import { g as getTasksDb } from './connections2-D22b0xbS.js';
import './dual-scope-db-ATrwq0LH.js';
import './paths-2M_UxD_H.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 './indexes-aYlULWG3.js';
import './utils-BvHPJOVk.js';
import './dist4-CiQ5cizO.js';
import './adapters-D2gEs_5L.js';
import './registry2-BSyCTA3q.js';
import './data-accessor-CVbz8X_7.js';
import './tasks-CnwUAUXf.js';
import './conduit-Ca_OFWR_.js';
import './unique-constraint-BM-Apx1H.js';
import './chunk-DDP5xfzh.js';
import './sqlite-Dsbe0wec.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 './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 './query-ops-BDMaTdYw.js';
import 'node:net';
import './src3-CMSGYxDI.js';
import './local-model-fit2-J1xCIhC_.js';
import './credential-pool-B04qO8at.js';
import './catalog-model-resolver2-Cexk2TN0.js';
import './role-resolver-DF9BQ_U6.js';
import './identity2-DeAB5RXE.js';
import './role-executor-C4-3bmgC.js';
import 'node:stream';
import 'crypto';
import 'os';
import 'node:http2';
import 'fs/promises';
import './models-catalog-DG3aPok8.js';
import './catalog-resolver2-c0qfF34B.js';
import './providers-CmIcBfg-.js';
import './brain-maintenance-bSR6GwAG.js';
import './graph-auto-populate2-DYsUNGSL.js';
import './temporal-supersession-BZ46j30w.js';
import './typed-query-l1D_QElt.js';
import './llm-backend-resolver-BPbvttS4.js';
import '@ai-sdk/provider-utils';
import './observer-reflector2-D8nxuglX.js';
import './learnings2-2m2p7lzT.js';
import './memory-accessor2-BzlgmY-Z.js';
import './quality-scoring-CCPuRQmJ.js';
import './patterns2-DYKfsbwN.js';
import './graph-memory-bridge2-C7Y32Mk4.js';
import './sigil2-DftKm7Um.js';
import './services-Dlf3Gefq.js';
import './audit4-S87oN-BC.js';
import 'process';
import './cleo-home-BCqJ5rg1.js';

//#region src/routes/tasks/pipeline/+page.server.ts
/**
* Pipeline page server load — tasks grouped by pipeline_stage for kanban.
*
* Column taxonomy:
*   - Intermediate RCASD-IVTR+C stages (research → release) mirror
*     `TASK_PIPELINE_STAGES` in `@cleocode/core`.
*   - `done` is the display bucket for any task with `status='done'` OR
*     `pipeline_stage IN ('contribution','done')`. This is the T871 fix:
*     completed tasks now always appear here, not lingering in
*     research/implementation/release.
*   - `cancelled` is the display bucket for any task with
*     `status='cancelled'` OR `pipeline_stage='cancelled'`.
*   - `unassigned` catches NULL pipeline_stage rows.
*
* @task T873
* @epic T870
*/
/**
* Ordered canonical pipeline column IDs. Mirrors the RCASD-IVTR+C chain
* from `@cleocode/core` with terminal display buckets appended.
*
* NOTE: stays in string form (not imported from core) because the
* SvelteKit server runtime must not pull CLI-only packages.
*/
var PIPELINE_STAGES = [
	"research",
	"consensus",
	"architecture_decision",
	"specification",
	"decomposition",
	"implementation",
	"validation",
	"testing",
	"release",
	"done",
	"cancelled"
];
/** Terminal pipeline-stage names (match `TERMINAL_PIPELINE_STAGES` in core). */
var TERMINAL_DONE_STAGES = new Set(["contribution", "done"]);
var TERMINAL_CANCELLED_STAGES = new Set(["cancelled"]);
/**
* Human-readable column labels (override default Title Case where needed).
*
* T880: `architecture_decision` now renders as "Design / ADR" per owner
* directive. Internal enum stays `architecture_decision` (backend, CLI,
* tests) — only the display label in Studio changes. This avoids a
* schema migration while keeping the UI owner-friendly.
*/
var COLUMN_LABELS = {
	research: "Research",
	consensus: "Consensus",
	architecture_decision: "Design / ADR",
	specification: "Specification",
	decomposition: "Decomposition",
	implementation: "Implementation",
	validation: "Validation",
	testing: "Testing",
	release: "Release",
	contribution: "Contribution",
	done: "Done",
	cancelled: "Cancelled",
	unassigned: "Unassigned"
};
/**
* Decide which column a row belongs in, honouring `status` as the
* authoritative signal for terminal tasks. This prevents the long-standing
* drift where a `status=done` task with `pipeline_stage='research'` would
* show up in the RESEARCH column instead of DONE.
*/
function resolveColumnId(row) {
	if (row.status === "done") return "done";
	if (row.status === "cancelled") return "cancelled";
	if (row.pipeline_stage && TERMINAL_DONE_STAGES.has(row.pipeline_stage)) return "done";
	if (row.pipeline_stage && TERMINAL_CANCELLED_STAGES.has(row.pipeline_stage)) return "cancelled";
	if (row.pipeline_stage && PIPELINE_STAGES.includes(row.pipeline_stage)) return row.pipeline_stage;
	return "unassigned";
}
var load = ({ locals }) => {
	const db = getTasksDb(locals.projectCtx);
	if (!db) return { columns: [] };
	try {
		const rows = db.prepare(`SELECT id, title, status, priority, type, parent_id, size,
                pipeline_stage, verification_json
         FROM tasks
         WHERE status != 'archived'
         ORDER BY
           CASE priority WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 ELSE 3 END,
           created_at DESC`).all();
		const buckets = {};
		for (const stage of [...PIPELINE_STAGES, "unassigned"]) buckets[stage] = [];
		for (const row of rows) {
			const target = buckets[resolveColumnId(row)] ?? buckets["unassigned"];
			const { pipeline_stage: _, ...rest } = row;
			target.push(rest);
		}
		const columns = [...PIPELINE_STAGES].map((s) => ({
			id: s,
			label: COLUMN_LABELS[s] ?? s.charAt(0).toUpperCase() + s.slice(1),
			count: buckets[s].length,
			tasks: buckets[s]
		}));
		if (buckets["unassigned"].length > 0) columns.push({
			id: "unassigned",
			label: COLUMN_LABELS["unassigned"],
			count: buckets["unassigned"].length,
			tasks: buckets["unassigned"]
		});
		return { columns };
	} catch {
		return { columns: [] };
	}
};
/**
* Exported for tests (T873, T880).
* Pure router used by `load` — unit-testable without a DB connection.
*/
var __testing__ = {
	resolveColumnId,
	PIPELINE_STAGES,
	COLUMN_LABELS
};

var _page_server_ts = /*#__PURE__*/Object.freeze({
	__proto__: null,
	__testing__: __testing__,
	load: load
});

const index = 29;
let component_cache;
const component = async () => component_cache ??= (await import('./_page.svelte-_rOJIxhL.js')).default;
const server_id = "src/routes/tasks/pipeline/+page.server.ts";
const imports = ["_app/immutable/nodes/29.Dc9A0SFC.js","_app/immutable/chunks/DyGQ_VXC.js","_app/immutable/chunks/DrKWWDpL.js","_app/immutable/chunks/BgPpRtmk.js","_app/immutable/chunks/BrUKpZTl.js","_app/immutable/chunks/DsQIgu-4.js","_app/immutable/chunks/Bcuvp8aL.js","_app/immutable/chunks/DnOaYask.js","_app/immutable/chunks/Cjus22ap.js","_app/immutable/chunks/DOqzs8kl2.js","_app/immutable/chunks/DTkg6Mnx.js","_app/immutable/chunks/DIQmuJJZ.js","_app/immutable/chunks/D7w7HllH.js","_app/immutable/chunks/DB5ifLM-.js","_app/immutable/chunks/CxlOpib82.js","_app/immutable/chunks/BKc98lKx.js","_app/immutable/chunks/DsanjglN.js","_app/immutable/chunks/CbGRcr-D.js","_app/immutable/chunks/CX8DOZuw2.js","_app/immutable/chunks/djL6V-tr.js","_app/immutable/chunks/CQCxd1p9.js","_app/immutable/chunks/JPJd4fEI.js","_app/immutable/chunks/RptFUp2P.js","_app/immutable/chunks/CEqOYim7.js","_app/immutable/chunks/CqF5Lomf.js","_app/immutable/chunks/wI_OOyoh.js"];
const stylesheets = ["_app/immutable/assets/StatBlock.DX6OXz7z.css","_app/immutable/assets/no-face-up.BlswZ73M.css","_app/immutable/assets/Tabs.CU9_rsWl.css","_app/immutable/assets/ui.CH-9N9-0.css","_app/immutable/assets/tasks.BZWJL4jq.css","_app/immutable/assets/HeroHeader.ByXNeezk.css","_app/immutable/assets/29.DRNLnKHe.css"];
const fonts = [];

export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
//# sourceMappingURL=29-CkDxBUWE.js.map
