/**
 * UOK — Unified Orchestration Kernel
 *
 * Purpose: export the complete UOK surface so consumers import from a single
 * module instead of reaching into individual files. This is the public API
 * contract for all UOK functionality.
 *
 * Consumer: auto-dispatch, auto-verification, commands, tests, and any
 * extension that needs orchestration primitives.
 */

// ─── Skills (Repo-local capabilities) ──────────────────────────────────────
export {
	buildSkillRecord,
	discoverAllSkills,
	discoverSkillDirs,
	getModelInvocableSkills,
	getPermittedSkills,
	loadSkills,
	parseSkillFrontmatter,
	readSkillFile,
	SKILL_FILENAME,
	USER_SKILL_DIR,
	validateSkillFrontmatter,
} from "../skills/index.js";
export {
	runAgentLoop,
	runAgentTurn,
	runSwarmTurn,
} from "./agent-runner.js";
// ─── Agent Swarm ───────────────────────────────────────────────────────────
export { AgentSwarm, ManagerType } from "./agent-swarm.js";
export {
	assessAssertionCoverage,
	fulfilledAssertionIdsFromHandoff,
	requiredAssertionIdsFromContract,
} from "./assertion-coverage.js";
// ─── Audit & Observability ─────────────────────────────────────────────────
export { buildAuditEnvelope, emitUokAuditEvent } from "./audit.js";
export {
	isAuditEnvelopeEnabled,
	setAuditEnvelopeEnabled,
} from "./audit-toggle.js";
// ─── Autonomous Dispatch ───────────────────────────────────────────────────
export {
	DISPATCH_RULES,
	enhanceUnitRankingWithMemory,
	extractValidationAttentionPlan,
	formatTaskCompleteFailurePrompt,
	getDispatchRuleNames,
	getRewriteCount,
	getUatCount,
	incrementUatCount,
	isVerificationNotApplicable,
	resolveDispatch,
	setRewriteCount,
} from "./auto-dispatch.js";
// ─── Runaway Guard ────────────────────────────────────────────────────────
export {
	clearRunawayGuardState,
	collectSessionTokenUsage,
	collectWorktreeFingerprint,
	countChangedFiles,
	DEFAULT_RUNAWAY_CHANGED_FILES_WARNING,
	DEFAULT_RUNAWAY_DIAGNOSTIC_TURNS,
	DEFAULT_RUNAWAY_ELAPSED_MINUTES,
	DEFAULT_RUNAWAY_MIN_INTERVAL_MS,
	DEFAULT_RUNAWAY_TOKEN_WARNING,
	DEFAULT_RUNAWAY_TOOL_CALL_WARNING,
	evaluateRunawayGuard,
	resetRunawayGuardState,
	resolveRunawayGuardConfig,
} from "./auto-runaway-guard.js";
// ─── Unit Closeout ────────────────────────────────────────────────────────
export { closeoutUnit } from "./auto-unit-closeout.js";
// ─── Post-Unit Verification ────────────────────────────────────────────────
export { runPostUnitVerification } from "./auto-verification.js";
// ─── Gates ─────────────────────────────────────────────────────────────────
export { ChaosMonkey, ChaosMonkeyGate } from "./chaos-monkey.js";
// ─── Model Policy ──────────────────────────────────────────────────────────
export {
	buildWorkerContextPackProjection,
	validateWorkerContextPackProjection,
} from "./context-pack-projection.js";
// ─── Contracts & Types ────────────────────────────────────────────────────
export { validateGate } from "./contracts.js";
// ─── Coordination Store ───────────────────────────────────────────────────
export {
	ensureCoordinationSchema,
	UokCoordinationStore,
} from "./coordination-store.js";
export { CostGuardGate } from "./cost-guard-gate.js";
// ─── Diagnostics ───────────────────────────────────────────────────────────
export {
	readUokDiagnostics,
	synthesizeUokDiagnostics,
	writeUokDiagnostics,
} from "./diagnostic-synthesis.js";
// ─── Dispatch Envelope ─────────────────────────────────────────────────────
export { buildDispatchEnvelope, explainDispatch } from "./dispatch-envelope.js";
// ─── Execution Graph ───────────────────────────────────────────────────────
export {
	buildExecutionGraphSnapshot,
	buildSidecarQueueNodes,
	ExecutionGraphScheduler,
	scheduleSidecarQueue,
	selectConflictFreeBatch,
	selectReactiveDispatchBatch,
} from "./execution-graph.js";
// ─── Execution Graph Persistence ───────────────────────────────────────────
export {
	ensureExecutionGraphSchema,
	getGraphProgressStream,
	getGraphStateSummary,
	persistFullGraph,
	persistGraphNode,
	persistGraphSnapshot,
	persistProgressEvent,
	queryTasksByState,
} from "./execution-graph-persist.js";
// ─── Flags & Configuration ─────────────────────────────────────────────────
export { loadUokFlags, resolveUokFlags } from "./flags.js";
// ─── Gate System ───────────────────────────────────────────────────────────
export { enrichGateResultWithMemory, UokGateRunner } from "./gate-runner.js";
// ─── GitOps ────────────────────────────────────────────────────────────────
export {
	writeTurnCloseoutGitRecord,
	writeTurnGitTransaction,
} from "./gitops.js";
// ─── Core Kernel ───────────────────────────────────────────────────────────
export { recordUokKernelTermination, runAutoLoopWithUok } from "./kernel.js";
// ─── Loop Adapter ──────────────────────────────────────────────────────────
export { createTurnObserver } from "./loop-adapter.js";
// ─── Message Bus ───────────────────────────────────────────────────────────
export { AgentInbox, MessageBus } from "./message-bus.js";
// ─── Metrics ───────────────────────────────────────────────────────────────
export {
	buildMetricsText,
	invalidateMetricsCache,
	metricsPath,
	readUokMetrics,
	writeUokMetrics,
} from "./metrics-exposition.js";
export { applyModelPolicyFilter } from "./model-policy.js";
export {
	DEFAULT_MODEL_ROLE_CONSTRAINTS,
	isSameRootVendor,
	ModelRolePolicyValidationError,
	normalizeRolePolicies,
	normalizeRolePolicy,
	rootVendorFor,
	SUPPORTED_MODEL_ROLE_CONSTRAINTS,
	SUPPORTED_MODEL_ROLES,
	validateRolePolicy,
} from "./model-role-policy.js";
export {
	emitModelAutoResolvedEvent,
	modelRoleForUnitType,
} from "./model-route-evidence.js";
export {
	buildModelRouteSnapshot,
	redactModelConfigSecrets,
	sanitizeModelRouteSnapshot,
} from "./model-route-snapshot.js";
export { MultiPackageGate } from "./multi-package-gate.js";
export { OutcomeLearningGate } from "./outcome-learning-gate.js";
export { signalKernelEnter as signalParityEnter } from "./parity-diff-capture.js";
// ─── Parity & Ledger ───────────────────────────────────────────────────────
export {
	checkAndDrainMissingExit,
	parseParityEvents,
	readParityReport,
	resetParityCommitBlock,
	signalKernelEnter,
	summarizeParityHealth,
	UNMATCHED_RUN_STALE_MS,
	writeParityHeartbeat,
	writeParityReport,
} from "./parity-report.js";
// ─── Letta Agent ───────────────────────────────────────────────────────────
export { PersistentAgent } from "./persistent-agent.js";
// ─── Plan v2 ───────────────────────────────────────────────────────────────
export {
	compileUnitGraphFromState,
	EXECUTION_ENTRY_PHASES,
	ensurePlanV2Graph,
	hasFinalizedMilestoneContext,
	isEmptyPlanV2GraphResult,
	isExecutionEntryPhase,
	isMissingFinalizedContextResult,
} from "./plan.js";
export {
	buildUokProgressEvent,
	UOK_PROGRESS_EVENT_TYPES,
	validateUokProgressEvent,
} from "./progress-event.js";
// ─── Scheduler v2 (Background Work) ────────────────────────────────────────
export {
	CancellationToken,
	ExecutionGraphSchedulerV2,
	ProgressStream,
	WorkerPool,
} from "./scheduler.js";
export { SecurityGate } from "./security-gate.js";
// ─── Swarm Dispatch ────────────────────────────────────────────────────────
export { SwarmDispatchLayer, swarmDispatch } from "./swarm-dispatch.js";
// ─── Swarm Roles ───────────────────────────────────────────────────────────
export {
	AdversaryAgent,
	CoordinatorAgent,
	createDefaultSwarm,
	PlannerAgent,
	ReviewerAgent,
	ScoutAgent,
	ScribeAgent,
	VerifierAgent,
	WorkerAgent,
} from "./swarm-roles.js";
// ─── Task State Machine ────────────────────────────────────────────────────
export {
	aggregateTaskStates,
	buildTaskRecord,
	canTransitionTaskState,
	gateOutcomesToTaskState,
	TASK_STATE_TRANSITIONS,
	TASK_STATES,
	TASK_TERMINAL_STATES,
	unitRuntimeToTaskState,
} from "./task-state.js";
export {
	normalizeCommandRegistry,
	normalizeToolCommandRegistry,
	validateCommandRegistry,
	validateToolCommandRegistry,
} from "./tool-command-registry.js";
export {
	normalizeUnitLineage,
	recordUnitLineageEvent,
} from "./unit-lineage.js";
// ─── Unit Runtime ──────────────────────────────────────────────────────────
export {
	clearRunawayRecoveredRuntimeRecords,
	clearUnitRuntimeRecord,
	decideUnitRuntimeDispatch,
	formatExecuteTaskRecoveryStatus,
	getUnitRuntimeState,
	inspectExecuteTaskDurability,
	isSyntheticUnitRuntime,
	isTerminalUnitRuntimeStatus,
	listUnitRuntimeRecords,
	readUnitRuntimeRecord,
	reconcileDurableCompleteUnitRuntimeRecords,
	reconcileStaleCompleteSliceRecords,
	recordUnitOutcomeInMemory,
	UNIT_RUNTIME_STATUSES,
	UNIT_RUNTIME_TERMINAL_STATUSES,
	UNIT_RUNTIME_TRANSITIONS,
	writeUnitRuntimeRecord,
} from "./unit-runtime.js";
// ─── Writer Token ──────────────────────────────────────────────────────────
export {
	acquireWriterToken,
	nextWriteRecord,
	releaseWriterToken,
} from "./writer.js";
