import { m as makeSchemaMetaTable } from './memory-schema-Bi7cChwo.js';
export { A as AGENT_REGISTRY_AGENT_STATUSES, a as AGENT_REGISTRY_USER_ROLES, b as agentRegistryAccounts, c as agentRegistryAgentCapabilities, d as agentRegistryAgentConnections, e as agentRegistryAgentSkills, f as agentRegistryAgents, g as agentRegistryCapabilities, h as agentRegistryClaimCodes, i as agentRegistryOrgAgentKeys, j as agentRegistryOrganization, k as agentRegistrySessions, l as agentRegistrySkills, m as agentRegistryUsers, n as agentRegistryVerifications } from './agent-registry-BtE5uhMO.js';
export { m as modelsCatalog } from './models-catalog-DG3aPok8.js';
export { p as providers } from './providers-CmIcBfg-.js';
export { s as sessionManifest } from './session-manifest-ZHrj54LR.js';
export { S as SERVICE_CONNECTION_STATUSES, a as agentServiceGrants, s as serviceConfigs, b as serviceConnections } from './services-Dlf3Gefq.js';
export { B as BRAIN_BACKFILL_KINDS, a as BRAIN_DECISION_CONFIRMATION_STATES, b as BRAIN_DECISION_DECIDED_BY, c as BRAIN_EDGE_PLASTICITY_CLASSES, d as BRAIN_PLASTICITY_KINDS, e as BRAIN_STAGING_ACTIONS, f as BRAIN_STAGING_VALIDATION_STATUSES, g as BRAIN_TRANSCRIPT_ROLES, h as brainAttention, i as brainBackfillRuns, j as brainConsolidationEvents, k as brainDecisions, l as brainDeriverQueue, m as brainLearnings, n as brainMemoryColumns, o as brainMemoryLinks, p as brainMemoryTrees, q as brainModulators, r as brainObservations, s as brainObservationsStaging, t as brainPageEdges, u as brainPageNodes, v as brainPatterns, w as brainPlasticityEvents, x as brainPromotionLog, y as brainRetrievalLog, z as brainSchemaMeta, A as brainSessionNarrative, C as brainStickyNotes, D as brainStickyTags, E as brainTranscriptEvents, F as brainUsageLog, G as brainWeightHistory } from './cleo-shared-CG3TSIBu.js';
import { s as sqliteTable, t as text, i as integer, a as index, r as real } from './indexes-aYlULWG3.js';
import { u as unique } from './unique-constraint-BM-Apx1H.js';
import { s as sql } from './utils-BvHPJOVk.js';
import './chunk-DDP5xfzh.js';
import 'node:module';
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:child_process';
import 'node:crypto';
import 'node:process';
import 'node:async_hooks';

//#region ../core/dist/store/schema/cleo-global/accounts.js
/**
* Global-scope `cleo.db` — **LLM credential pool** (`accounts`, 1 table).
*
* EP-PROVIDER-VAULT (epic T10410 · task T11709 · saga SG-VAULT-CORE T10409). This
* table is the queryable, `cleo health`-visible home for the **pooled LLM provider
* credentials** that today live as a plaintext JSON blob with no schema, no index,
* and no health surface. Each row is one credential ("account") for one provider —
* an API key or OAuth token pair — plus the rotation / cooldown / health metadata
* the pool runner uses to pick the next live account and to retire dead ones.
*
* ## NOT `agent_registry_accounts` (do not confuse the two)
*
* The consolidated global `cleo.db` ALSO carries `agent_registry_accounts` — the
* better-auth OAuth-account table from the agent-identity tier (the cloud-sync
* `accounts` source, renamed under T11622). That table is a SaaS account record;
* THIS table (`accounts`, bare) is the local machine-wide LLM-credential pool. The
* two never overlap: the physical names differ (`accounts` vs
* `agent_registry_accounts`) and the JS exports differ (`accounts` here vs
* `agentRegistryAccounts`). The bare name `accounts` is the credential pool.
*
* ## Encrypted at rest (global KDF — T11710)
*
* `secretEnc` / `refreshEnc` are ciphertext, NEVER plaintext. They are produced by
* `encryptGlobal()` (packages/core/src/crypto/credentials.ts, T11710) — the
* project-INDEPENDENT KDF `HMAC-SHA256(machine-key || globalSalt, id)` reusing the
* machine-local `getGlobalSalt()` (store/global-salt.ts). The ciphertext keeps the
* versioned `0x01 + 12B IV + 16B authTag` framing. Global (not project-bound)
* encryption is required because an LLM credential must decrypt consistently for
* the same machine regardless of which project's cwd the pool is read from.
*
* ## Active-account pointer (`isActive`)
*
* `isActive` is the per-provider "currently-selected" pointer: AT MOST ONE row per
* `provider` may carry `isActive = 1`. drizzle-orm cannot model a partial-`WHERE`
* unique index, so the one-active-per-provider invariant is enforced by a raw-SQL
* **partial unique index** `ux_accounts_active_provider ON accounts (provider)
* WHERE is_active = 1` emitted in the forward migration (the established repo
* pattern — cf. `_writer_leases.active`, T11627). This module declares only the
* full-column table plus the non-partial `(provider, label)` unique index, which
* drizzle CAN emit.
*
* @task T11709
* @epic T10410
* @saga T10409
* @see ../../../crypto/credentials.ts — `encryptGlobal` / `decryptGlobal` (T11710)
* @see ../../global-salt.ts — `getGlobalSalt` (the reused machine-local salt)
* @see ./agent-registry.ts — `agentRegistryAccounts` (the UNRELATED OAuth-account table)
* @see ../../../../migrations/drizzle-cleo-global — the forward migration (raw partial index)
*/
/**
* Legal `accounts.status` values — the health lifecycle of a pooled credential.
*
* - `ok` — usable; the pool may select it.
* - `exhausted` — rate-limited / quota-hit; usable again after `cooldownResetAt`.
* - `dead` — permanently unusable (revoked key, hard auth failure); never selected.
*
* @task T11709
*/
var ACCOUNT_STATUSES = [
	"ok",
	"exhausted",
	"dead"
];
/**
* `accounts` — the machine-wide pooled-LLM-credential table.
*
* One row per credential ("account") for one provider. Carries the encrypted
* secret/refresh material plus the rotation, cooldown, and health metadata the
* pool runner consults to choose the next live account (highest `priority` among
* `status = 'ok'`) and to retire dead ones. The `(provider, label)` pair is unique;
* `isActive` is the per-provider active pointer (one active row per provider,
* enforced by the raw-SQL partial unique index in the migration).
*
* @task T11709
*/
var accounts = sqliteTable("accounts", {
	id: integer("id").primaryKey(),
	provider: text("provider").notNull(),
	label: text("label").notNull(),
	authType: text("auth_type").notNull(),
	secretEnc: text("secret_enc"),
	refreshEnc: text("refresh_enc"),
	expiresAt: text("expires_at"),
	priority: integer("priority").notNull().default(0),
	source: text("source"),
	status: text("status", { enum: ACCOUNT_STATUSES }).notNull().default("ok"),
	lastErrorCode: text("last_error_code"),
	cooldownResetAt: text("cooldown_reset_at"),
	requestCount: integer("request_count").notNull().default(0),
	metadata: text("metadata").notNull().default("{}"),
	isActive: integer("is_active", { mode: "boolean" }).notNull().default(false),
	createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
	updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`)
}, (table) => [unique("ux_accounts_provider_label").on(table.provider, table.label), index("idx_accounts_provider_status_priority").on(table.provider, table.status, table.priority)]);
//#endregion
//#region ../core/dist/store/schema/cleo-global/nexus.js
/**
* Global-scope `cleo.db` — consolidated **nexus registry/identity** domain (6 tables).
*
* Part of the consolidated GLOBAL-scope `cleo.db` target shape authored for
* SG-DB-SUBSTRATE-V2 (saga T11242, epic T11245/E2, task T11361). Target-shape
* authoring only — physical names carry the `nexus_` domain prefix. The live
* runtime modules `schema/nexus-schema.ts` + `schema/code-index.ts` keep their
* UNPREFIXED / partially-prefixed names until the exodus migration (T11248)
* swaps the substrate to this shape.
*
* ## Nexus code-graph residency move (ADR-090 · T11539 — REMOVED from here)
*
* The four per-project code/knowledge-graph tables — `nexus_nodes`,
* `nexus_relations`, `nexus_contracts`, `nexus_code_index` (ADR-090 "Category A")
* — were REMOVED from this GLOBAL module and now reside in PROJECT scope
* (`../cleo-project/nexus-graph.ts`, T11538), dropping the `project_id` column
* (scope is implicit in which project's `.cleo/cleo.db` is open). This reduces
* the nexus GLOBAL table count from 10 → 6. The six tables retained here are the
* genuinely-global "Category B" registry/identity tables (see below). Exodus
* routes the four graph tables to PROJECT scope per
* `../exodus/table-name-map.ts` (`NEXUS_GRAPH_PROJECT_TABLES`).
*
* ## Idempotent prefixer (AC1)
*
* The six retained tables: `nexus_audit_log` · `nexus_schema_meta` already carry
* the recognized `nexus_` prefix and are NOT double-prefixed. The remaining four
* bare tables gain the domain prefix at exodus: `project_registry` →
* `nexus_project_registry` · `project_id_aliases` → `nexus_project_id_aliases` ·
* `user_profile` → `nexus_user_profile` · `sigils` → `nexus_sigils`.
*
* ## E10 typing applied
*
* - **§4 timestamps (Drizzle-Date non-conformers → TEXT ISO8601):**
*   `nexus_user_profile.{first_observed_at,last_reinforced_at}` and
*   `nexus_sigils.{created_at,updated_at}` were `integer({ mode:'timestamp' })`
*   (the 4 Date non-conformers in §4). They become canonical `text` ISO8601;
*   the matching `CHECK (col GLOB 'YYYY-MM-DD*')` ships as raw DDL at exodus.
* - **§5b enum-like bare TEXT → `{ enum }`:** `nexus_sigils.role` →
*   `{ enum: SIGIL_ROLES }`. The const array below is minted in-module (no
*   cross-package contracts const exists) per §5b — the CHECK list derives from
*   the identifier, never a hand-typed literal. (`nexus_code_index.kind` →
*   `{ enum: CODE_INDEX_KINDS }` moved with the graph tables to
*   `../cleo-project/nexus-graph.ts`.)
*
* ## FK reconciliation to single-file Pattern A (AC4)
*
* The nexus source used soft FKs (plain `text` + `@cross-db` annotations) for
* every cross-table reference; none crossed file boundaries via a real
* `.references()`. Under the consolidated GLOBAL `cleo.db` they remain plain
* `text` soft FKs:
*   - `nexus_project_id_aliases.canonical_id` → `nexus_project_registry` and
*     `nexus_audit_log.project_id` → `nexus_project_registry` stay soft because
*     the source never declared them as enforced FKs.
*   - cross-domain refs (`nexus_audit_log.session_id` → project-scope
*     `tasks_sessions`, `nexus_user_profile.derived_from_message_id` →
*     `conduit_session_messages`) point at the PROJECT-scope `cleo.db`, so they
*     CANNOT be native FKs — they remain soft TEXT, resolved by the nexus
*     accessor. No ATTACH; no cross-file FK.
*
* @task T11361 · T11539 (nexus graph residency removal)
* @epic T11245 · T11535 (nexus residency)
* @saga T11242
* @see ../cleo-project/nexus-graph.ts (the PROJECT-scope home of the 4 graph tables)
* @see docs/migration/sqlite-schema-canonical.md §1 (D1″ · global counts) · §4 · §5b
* @see docs/migration/sqlite-schema-columns.json (per-column affinity SSoT)
* @see ../nexus-schema.ts · ../code-index.ts (the runtime source modules)
* @see cleo docs fetch adr-090-nexus-graph-residency-split
*/
/**
* Legal `nexus_sigils.role` values — the `.cant` agent role taxonomy.
*
* E10 §5b: `sigils.role` was bare `text('role')` (default `''`). The value is
* the `role:` frontmatter field of a `.cant` agent file, parsed by
* `nexus/sigil-sync.ts`. The legal set enumerated from the writer + canonical
* seed roster (`project-orchestrator`, `project-dev-lead`, `project-*-worker`)
* and the parsed-sigil fixtures (`subagent`, `specialist`). `''` is retained
* because the column defaults to empty before a `.cant` role is associated.
*
* @task T11361
*/
var SIGIL_ROLES = [
	"",
	"orchestrator",
	"lead",
	"worker",
	"subagent",
	"specialist",
	"validator"
];
/**
* `nexus_project_registry` — central registry of all CLEO projects known to the
* Nexus (one row per project). Bare `project_registry` → `nexus_project_registry`
* under the AC1 idempotent prefixer.
*
* @task T11361 (target shape) · T5365 / T529 (original)
*/
var nexusProjectRegistry = sqliteTable("nexus_project_registry", {
	projectId: text("project_id").primaryKey(),
	projectHash: text("project_hash").notNull().unique(),
	projectPath: text("project_path").notNull().unique(),
	name: text("name").notNull(),
	registeredAt: text("registered_at").notNull().default(sql`(datetime('now'))`),
	lastSeen: text("last_seen").notNull().default(sql`(datetime('now'))`),
	healthStatus: text("health_status").notNull().default("unknown"),
	healthLastCheck: text("health_last_check"),
	permissions: text("permissions").notNull().default("read"),
	lastSync: text("last_sync").notNull().default(sql`(datetime('now'))`),
	taskCount: integer("task_count").notNull().default(0),
	labelsJson: text("labels_json").notNull().default("[]"),
	brainDbPath: text("brain_db_path"),
	tasksDbPath: text("tasks_db_path"),
	lastIndexed: text("last_indexed"),
	statsJson: text("stats_json").notNull().default("{}")
}, (table) => [
	index("idx_nexus_project_registry_hash").on(table.projectHash),
	index("idx_nexus_project_registry_health").on(table.healthStatus),
	index("idx_nexus_project_registry_name").on(table.name),
	index("idx_nexus_project_registry_last_indexed").on(table.lastIndexed)
]);
/**
* `nexus_project_id_aliases` — maps legacy base64url(path) project IDs to their
* canonical IDs (T9149 W5). Bare `project_id_aliases` → `nexus_project_id_aliases`.
*
* @task T11361 (target shape) · T9149 (original)
*/
var nexusProjectIdAliases = sqliteTable("nexus_project_id_aliases", {
	legacyId: text("legacy_id").primaryKey(),
	canonicalId: text("canonical_id").notNull(),
	createdAt: text("created_at").notNull().default(sql`(datetime('now'))`)
}, (table) => [index("idx_nexus_project_id_aliases_canonical").on(table.canonicalId)]);
/**
* `nexus_audit_log` — append-only audit log for all Nexus operations across
* projects. Already domain-prefixed; the idempotent prefixer is a no-op.
*
* @task T11361 (target shape) · T5365 (original)
*/
var nexusAuditLog = sqliteTable("nexus_audit_log", {
	id: text("id").primaryKey(),
	timestamp: text("timestamp").notNull().default(sql`(datetime('now'))`),
	action: text("action").notNull(),
	projectHash: text("project_hash"),
	projectId: text("project_id"),
	domain: text("domain"),
	operation: text("operation"),
	sessionId: text("session_id"),
	requestId: text("request_id"),
	source: text("source"),
	gateway: text("gateway"),
	success: integer("success"),
	durationMs: integer("duration_ms"),
	detailsJson: text("details_json").default("{}"),
	errorMessage: text("error_message")
}, (table) => [
	index("idx_nexus_audit_timestamp").on(table.timestamp),
	index("idx_nexus_audit_action").on(table.action),
	index("idx_nexus_audit_project_hash").on(table.projectHash),
	index("idx_nexus_audit_project_id").on(table.projectId),
	index("idx_nexus_audit_session").on(table.sessionId)
]);
/**
* `nexus_schema_meta` — key-value schema-version tracking (single-table KV).
* Already domain-prefixed.
*
* @task T11361 (target shape) · T5365 (original)
*/
var nexusSchemaMeta = makeSchemaMetaTable("nexus_schema_meta");
/**
* `nexus_user_profile` — global user identity / preference profile (PSYCHE
* Wave 1, T1077). Bare `user_profile` → `nexus_user_profile`.
*
* E10 §4: `first_observed_at` / `last_reinforced_at` were
* `integer({ mode:'timestamp' })` (Drizzle-Date non-conformers) — now canonical
* TEXT ISO8601.
*
* @task T11361 (target shape) · T1077 (original)
*/
var nexusUserProfile = sqliteTable("nexus_user_profile", {
	traitKey: text("trait_key").primaryKey(),
	traitValue: text("trait_value").notNull(),
	confidence: real("confidence").notNull(),
	source: text("source").notNull(),
	derivedFromMessageId: text("derived_from_message_id"),
	firstObservedAt: text("first_observed_at").notNull(),
	lastReinforcedAt: text("last_reinforced_at").notNull(),
	reinforcementCount: integer("reinforcement_count").notNull().default(1),
	supersededBy: text("superseded_by")
}, (table) => [
	index("idx_nexus_user_profile_confidence").on(table.confidence),
	index("idx_nexus_user_profile_source").on(table.source),
	index("idx_nexus_user_profile_last_reinforced").on(table.lastReinforcedAt),
	index("idx_nexus_user_profile_superseded").on(table.supersededBy)
]);
/**
* `nexus_sigils` — peer-card sigil identity layer for CANT agents (PSYCHE
* Wave 8, T1148). Bare `sigils` → `nexus_sigils`.
*
* E10 §5b: `role` was bare `text('role')` → `{ enum: SIGIL_ROLES }`.
* E10 §4: `created_at` / `updated_at` were `integer({ mode:'timestamp' })`
* (Drizzle-Date non-conformers) — now canonical TEXT ISO8601.
*
* @task T11361 (target shape) · T1148 (original)
*/
var nexusSigils = sqliteTable("nexus_sigils", {
	peerId: text("peer_id").primaryKey(),
	cantFile: text("cant_file"),
	displayName: text("display_name").notNull().default(""),
	role: text("role", { enum: SIGIL_ROLES }).notNull().default(""),
	systemPromptFragment: text("system_prompt_fragment"),
	capabilityFlags: text("capability_flags"),
	createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
	updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`)
}, (table) => [index("idx_nexus_sigils_display_name").on(table.displayName), index("idx_nexus_sigils_role").on(table.role)]);
//#endregion
//#region ../core/dist/store/schema/cleo-global/skills.js
/**
* Global-scope `cleo.db` — consolidated **skills** domain (4 tables).
*
* Part of the consolidated GLOBAL-scope `cleo.db` target shape authored for
* SG-DB-SUBSTRATE-V2 (saga T11242, epic T11245/E2, task T11361). Target-shape
* authoring only — physical names carry the `skills_` domain prefix. The live
* runtime module `schema/skills-schema.ts` keeps its UNPREFIXED names
* (`skills`, `skill_usage`, …) until the exodus migration (T11248) swaps the
* substrate.
*
* ## Idempotent prefixer (AC1)
*
* All four source tables are bare and gain the `skills_` prefix at exodus:
* `skills` → `skills_skills` · `skill_usage` → `skills_skill_usage` ·
* `skill_reviews` → `skills_skill_reviews` · `skill_patches` →
* `skills_skill_patches`.
*
* ## E10 typing applied
*
* The skills source is already E10-clean — no non-conformers to remediate:
*   - **§5a enums:** `source_type` / `lifecycle_state` / `outcome` / `status`
*     already declare `text({ enum })` from in-module named const arrays
*     ({@link SKILL_SOURCE_TYPES} / {@link SKILL_LIFECYCLE_STATES} /
*     {@link SKILL_REVIEW_OUTCOMES} / {@link SKILL_PATCH_STATUSES}); the
*     matching `CHECK (col IN (...))` ships at exodus.
*   - **§3a booleans:** `skills.pinned` / `skills.is_agent_created` already
*     declare `{ mode:'boolean' }`.
*   - **§4 timestamps:** every timestamp is already canonical TEXT ISO8601
*     (`installed_at`, `observed_at`, `reviewed_at`, `proposed_at`, …) — no
*     epoch/Date non-conformer in this domain.
*
* ## FK reconciliation to single-file Pattern A (AC4)
*
* The skills source declares all relationships as LOGICAL (denormalized
* `skill_name` / `review_id` columns, no enforced `.references()`), so nothing
* crossed a file boundary. `skill_usage.task_id` is a cross-domain reference to
* the PROJECT-scope `cleo.db` and therefore stays a plain `text` soft FK
* (resolved by the skill-telemetry accessor; no ATTACH).
*
* @task T11361
* @epic T11245
* @saga T11242
* @see docs/migration/sqlite-schema-canonical.md §1 (D1″ · global counts) · §3a · §5a
* @see docs/migration/sqlite-schema-columns.json (per-column affinity SSoT)
* @see ../skills-schema.ts (the runtime source module)
*/
/**
* Provenance of a skill row (Sphere A canonical vs Sphere B authored).
*
* @architecture SG-CLEO-SKILLS v3 §4 `source_type` enum
* @task T11361 (target shape) · T9651 (original)
*/
var SKILL_SOURCE_TYPES = [
	"canonical",
	"user",
	"community",
	"agent-created"
];
/**
* Lifecycle state of a skill row.
*
* @architecture SG-CLEO-SKILLS v3 §4 `lifecycle_state` enum
* @task T11361 (target shape) · T9651 (original)
*/
var SKILL_LIFECYCLE_STATES = [
	"active",
	"stale",
	"archived"
];
/**
* Skill review outcome (council and/or grade pipelines).
*
* @architecture SG-CLEO-SKILLS v3 §6/§7 (auto-improve)
* @task T11361 (target shape) · T9651 (original)
*/
var SKILL_REVIEW_OUTCOMES = [
	"approved",
	"rejected",
	"needs-changes"
];
/**
* Skill patch application state.
*
* @architecture SG-CLEO-SKILLS v3 §6/§7 (auto-improve)
* @task T11361 (target shape) · T9651 (original)
*/
var SKILL_PATCH_STATUSES = [
	"proposed",
	"applied",
	"reverted",
	"rejected"
];
/**
* `skills_skills` — per-user registry of installed skills (one row per name).
* Bare `skills` → `skills_skills` under the AC1 idempotent prefixer.
*
* @task T11361 (target shape) · T9651 (original)
*/
var skillsSkills = sqliteTable("skills_skills", {
	id: integer("id").primaryKey({ autoIncrement: true }),
	name: text("name").notNull().unique(),
	version: text("version"),
	sourceType: text("source_type", { enum: SKILL_SOURCE_TYPES }).notNull(),
	sourceUrl: text("source_url"),
	installPath: text("install_path").notNull(),
	canonicalPath: text("canonical_path"),
	installedAt: text("installed_at").notNull(),
	lastUpdatedAt: text("last_updated_at"),
	lifecycleState: text("lifecycle_state", { enum: SKILL_LIFECYCLE_STATES }).notNull().default("active"),
	pinned: integer("pinned", { mode: "boolean" }).notNull().default(false),
	isAgentCreated: integer("is_agent_created", { mode: "boolean" }).notNull().default(false),
	archivedAt: text("archived_at"),
	archivedFromPath: text("archived_from_path")
}, (table) => [index("idx_skills_skills_state").on(table.lifecycleState), index("idx_skills_skills_source").on(table.sourceType)]);
/**
* `skills_skill_usage` — per-event telemetry row (load / invoke / error). Bare
* `skill_usage` → `skills_skill_usage`.
*
* @task T11361 (target shape) · T9651 (original)
*/
var skillsSkillUsage = sqliteTable("skills_skill_usage", {
	id: integer("id").primaryKey({ autoIncrement: true }),
	skillName: text("skill_name").notNull(),
	observedAt: text("observed_at").notNull().default(sql`(datetime('now'))`),
	eventKind: text("event_kind").notNull(),
	taskId: text("task_id"),
	projectId: text("project_id"),
	modelId: text("model_id"),
	metadata: text("metadata").notNull().default("{}")
}, (table) => [index("idx_skills_skill_usage_name_observed").on(table.skillName, table.observedAt), index("idx_skills_skill_usage_kind").on(table.eventKind)]);
/**
* `skills_skill_reviews` — council + grade review outcomes (auto-improve quality
* gate). Bare `skill_reviews` → `skills_skill_reviews`.
*
* @task T11361 (target shape) · T9651 (original)
*/
var skillsSkillReviews = sqliteTable("skills_skill_reviews", {
	id: integer("id").primaryKey({ autoIncrement: true }),
	skillName: text("skill_name").notNull(),
	reviewedAt: text("reviewed_at").notNull().default(sql`(datetime('now'))`),
	outcome: text("outcome", { enum: SKILL_REVIEW_OUTCOMES }).notNull(),
	score: integer("score"),
	reviewRunId: text("review_run_id"),
	summary: text("summary")
}, (table) => [index("idx_skills_skill_reviews_name_reviewed").on(table.skillName, table.reviewedAt), index("idx_skills_skill_reviews_outcome").on(table.outcome)]);
/**
* `skills_skill_patches` — auto-improve patch payload (unified diff). Bare
* `skill_patches` → `skills_skill_patches`.
*
* @task T11361 (target shape) · T9651 (original)
*/
var skillsSkillPatches = sqliteTable("skills_skill_patches", {
	id: integer("id").primaryKey({ autoIncrement: true }),
	skillName: text("skill_name").notNull(),
	proposedAt: text("proposed_at").notNull().default(sql`(datetime('now'))`),
	appliedAt: text("applied_at"),
	reviewId: integer("review_id"),
	diff: text("diff").notNull(),
	status: text("status", { enum: SKILL_PATCH_STATUSES }).notNull().default("proposed"),
	revertedByPatchId: integer("reverted_by_patch_id")
}, (table) => [index("idx_skills_skill_patches_name_proposed").on(table.skillName, table.proposedAt), index("idx_skills_skill_patches_status").on(table.status)]);
//#endregion
//#region ../core/dist/store/schema/cleo-global/telemetry.js
/**
* Global-scope `cleo.db` — consolidated **telemetry** domain.
*
* Part of the consolidated GLOBAL-scope `cleo.db` target shape. Per ADR-090 §2.3
* the two telemetry tables (`telemetry_events`, `telemetry_schema_meta`) are
* machine-wide command telemetry — a CROSS-PROJECT signal — so they reside in the
* GLOBAL `cleo.db` (`$XDG_DATA_HOME/cleo/cleo.db`), not the per-project file. They
* were relocated here from `cleo-project/telemetry.ts` by T11540 (the deferred
* residency move recorded in ADR-090 §2.3); the physical DDL is unchanged so the
* exodus cutover (T11248) emits zero drift versus the prior project-scope shape.
*
* Physical names carry the `telemetry_` domain prefix (already present in the
* source, so the idempotent prefixer is a no-op here: a table already carrying a
* recognized domain prefix is NOT double-prefixed, per AC1). The live runtime
* module `schema/telemetry-schema.ts` (the standalone, already-global
* `telemetry.db`) is unchanged until the exodus migration deploys this shape.
*
* ## E10 typing applied
*
* - **§4 timestamps:** `telemetry_events.timestamp` is the canonical TEXT
*   ISO8601 form (`datetime('now')`); no epoch non-conformer in this domain.
* - **No boolean / enum / JSON columns** — `exit_code` is a numeric LAFS code
*   (not a 0/1 boolean flag), so it stays plain `integer` per the audit.
* - **`telemetry_schema_meta`** is the canonical two-column KV shape, so it is
*   built from the shared {@link makeSchemaMetaTable} factory (T11543) — the
*   single source of the `{ key TEXT PK, value TEXT NOT NULL }` DDL across every
*   domain. The emitted DDL is byte-identical to the prior inline definition.
*
* @task T11540
* @epic T11535
* @saga T11242
* @see .cleo/rcasd/adr-090-nexus-graph-residency-split.md §2.3 (telemetry → GLOBAL)
* @see ../schema-utils.ts — re-exported as {@link makeSchemaMetaTable} (T11543 factory)
* @see docs/migration/sqlite-schema-canonical.md §1 (D1″) · §4
* @see docs/migration/sqlite-schema-columns.json (per-column affinity SSoT)
*/
/**
* `telemetry_events` — one row per command invocation captured by the
* telemetry middleware (anonymous, opt-in). Already domain-prefixed; the
* idempotent prefixer leaves the name as-is.
*
* @task T11540 (residency move · target shape) · T11360 (prior project-scope authoring) · T624 (original)
*/
var telemetryEvents = sqliteTable("telemetry_events", {
	id: text("id").primaryKey(),
	anonymousId: text("anonymous_id").notNull(),
	domain: text("domain").notNull(),
	gateway: text("gateway").notNull(),
	operation: text("operation").notNull(),
	command: text("command").notNull(),
	exitCode: integer("exit_code").notNull().default(0),
	durationMs: integer("duration_ms").notNull(),
	errorCode: text("error_code"),
	timestamp: text("timestamp").notNull().default(sql`(datetime('now'))`)
}, (table) => [
	index("idx_telemetry_command").on(table.command),
	index("idx_telemetry_domain").on(table.domain),
	index("idx_telemetry_exit_code").on(table.exitCode),
	index("idx_telemetry_timestamp").on(table.timestamp),
	index("idx_telemetry_duration").on(table.durationMs)
]);
/**
* `telemetry_schema_meta` — key-value schema-version tracking (single row).
*
* Built from the shared {@link makeSchemaMetaTable} factory (T11543) so the
* canonical `{ key TEXT PRIMARY KEY, value TEXT NOT NULL }` shape never drifts
* across domains; the emitted DDL is identical to the prior inline definition.
*
* @task T11540 (residency move · target shape) · T11543 (factory) · T624 (original)
*/
var telemetrySchemaMeta = makeSchemaMetaTable("telemetry_schema_meta");

export { ACCOUNT_STATUSES, SIGIL_ROLES, SKILL_LIFECYCLE_STATES, SKILL_PATCH_STATUSES, SKILL_REVIEW_OUTCOMES, SKILL_SOURCE_TYPES, accounts, nexusAuditLog, nexusProjectIdAliases, nexusProjectRegistry, nexusSchemaMeta, nexusSigils, nexusUserProfile, skillsSkillPatches, skillsSkillReviews, skillsSkillUsage, skillsSkills, telemetryEvents, telemetrySchemaMeta };
//# sourceMappingURL=cleo-global-CT1A4IY_.js.map
