/** * SQLite schema definition for sudocode * Shared between CLI and server packages */ export declare const SCHEMA_VERSION = "1.0"; /** * Database configuration SQL */ export declare const DB_CONFIG = "\n-- Enable WAL mode for better concurrency\nPRAGMA journal_mode=WAL;\n\n-- Enforce foreign keys\nPRAGMA foreign_keys=ON;\n\n-- Optimize for performance\nPRAGMA synchronous=NORMAL;\nPRAGMA temp_store=MEMORY;\nPRAGMA mmap_size=30000000000;\nPRAGMA page_size=4096;\nPRAGMA cache_size=10000;\n"; /** * Core table schemas */ export declare const SPECS_TABLE = "\nCREATE TABLE IF NOT EXISTS specs (\n id TEXT PRIMARY KEY,\n uuid TEXT NOT NULL UNIQUE,\n title TEXT NOT NULL CHECK(length(title) <= 500),\n file_path TEXT NOT NULL,\n content TEXT NOT NULL DEFAULT '',\n priority INTEGER NOT NULL DEFAULT 2 CHECK(priority >= 0 AND priority <= 4),\n archived INTEGER NOT NULL DEFAULT 0 CHECK(archived IN (0, 1)),\n archived_at DATETIME,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n parent_id TEXT,\n parent_uuid TEXT,\n external_links TEXT,\n FOREIGN KEY (parent_id) REFERENCES specs(id) ON DELETE SET NULL,\n FOREIGN KEY (parent_uuid) REFERENCES specs(uuid) ON DELETE SET NULL\n);\n"; export declare const ISSUES_TABLE = "\nCREATE TABLE IF NOT EXISTS issues (\n id TEXT PRIMARY KEY,\n uuid TEXT NOT NULL UNIQUE,\n title TEXT NOT NULL CHECK(length(title) <= 500),\n content TEXT NOT NULL DEFAULT '',\n status TEXT NOT NULL DEFAULT 'open',\n priority INTEGER NOT NULL DEFAULT 2 CHECK(priority >= 0 AND priority <= 4),\n assignee TEXT,\n archived INTEGER NOT NULL DEFAULT 0 CHECK(archived IN (0, 1)),\n archived_at DATETIME,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n closed_at DATETIME,\n parent_id TEXT,\n parent_uuid TEXT,\n external_links TEXT,\n FOREIGN KEY (parent_id) REFERENCES issues(id) ON DELETE SET NULL,\n FOREIGN KEY (parent_uuid) REFERENCES issues(uuid) ON DELETE SET NULL\n);\n"; export declare const RELATIONSHIPS_TABLE = "\nCREATE TABLE IF NOT EXISTS relationships (\n from_id TEXT NOT NULL,\n from_uuid TEXT NOT NULL,\n from_type TEXT NOT NULL,\n to_id TEXT NOT NULL,\n to_uuid TEXT NOT NULL,\n to_type TEXT NOT NULL,\n relationship_type TEXT NOT NULL,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n metadata TEXT,\n PRIMARY KEY (from_id, from_type, to_id, to_type, relationship_type)\n);\n"; export declare const TAGS_TABLE = "\nCREATE TABLE IF NOT EXISTS tags (\n entity_id TEXT NOT NULL,\n entity_uuid TEXT NOT NULL,\n entity_type TEXT NOT NULL,\n tag TEXT NOT NULL,\n PRIMARY KEY (entity_id, entity_type, tag)\n);\n"; export declare const EVENTS_TABLE = "\nCREATE TABLE IF NOT EXISTS events (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n entity_id TEXT NOT NULL,\n entity_uuid TEXT NOT NULL,\n entity_type TEXT NOT NULL,\n event_type TEXT NOT NULL,\n actor TEXT NOT NULL,\n old_value TEXT,\n new_value TEXT,\n comment TEXT,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n git_commit_sha TEXT,\n source TEXT\n);\n"; export declare const ISSUE_FEEDBACK_TABLE = "\nCREATE TABLE IF NOT EXISTS issue_feedback (\n id TEXT PRIMARY KEY,\n from_id TEXT,\n from_uuid TEXT,\n to_id TEXT NOT NULL,\n to_uuid TEXT NOT NULL,\n feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),\n content TEXT NOT NULL,\n agent TEXT,\n anchor TEXT,\n dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n"; export declare const EXECUTIONS_TABLE = "\nCREATE TABLE IF NOT EXISTS executions (\n id TEXT PRIMARY KEY,\n issue_id TEXT,\n issue_uuid TEXT,\n\n -- Execution mode and configuration\n mode TEXT CHECK(mode IN ('worktree', 'local')),\n prompt TEXT,\n config TEXT,\n\n -- Process information (legacy + new)\n agent_type TEXT,\n session_id TEXT,\n workflow_execution_id TEXT,\n\n -- Git/branch information\n target_branch TEXT NOT NULL,\n branch_name TEXT NOT NULL,\n before_commit TEXT,\n after_commit TEXT,\n worktree_path TEXT,\n\n -- Status (unified - supports both old and new statuses)\n status TEXT NOT NULL CHECK(status IN (\n 'preparing', 'pending', 'running', 'paused',\n 'completed', 'failed', 'cancelled', 'stopped'\n )),\n\n -- Timing (consistent with other tables)\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n started_at DATETIME,\n completed_at DATETIME,\n cancelled_at DATETIME,\n\n -- Results and metadata\n exit_code INTEGER,\n error_message TEXT,\n error TEXT,\n model TEXT,\n summary TEXT,\n files_changed TEXT,\n\n -- Relationships\n parent_execution_id TEXT,\n\n -- Multi-step workflow support (future extension)\n step_type TEXT,\n step_index INTEGER,\n step_config TEXT,\n\n FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE SET NULL,\n FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE SET NULL,\n FOREIGN KEY (parent_execution_id) REFERENCES executions(id) ON DELETE SET NULL\n);\n"; export declare const PROMPT_TEMPLATES_TABLE = "\nCREATE TABLE IF NOT EXISTS prompt_templates (\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n description TEXT,\n type TEXT NOT NULL CHECK(type IN ('issue', 'spec', 'custom')),\n template TEXT NOT NULL,\n variables TEXT NOT NULL,\n is_default INTEGER NOT NULL DEFAULT 0 CHECK(is_default IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n"; export declare const EXECUTION_LOGS_TABLE = "\nCREATE TABLE IF NOT EXISTS execution_logs (\n execution_id TEXT PRIMARY KEY,\n raw_logs TEXT,\n normalized_entry TEXT,\n byte_size INTEGER NOT NULL DEFAULT 0,\n line_count INTEGER NOT NULL DEFAULT 0,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (execution_id) REFERENCES executions(id) ON DELETE CASCADE,\n CHECK (raw_logs IS NOT NULL OR normalized_entry IS NOT NULL)\n);\n"; export declare const WORKFLOWS_TABLE = "\nCREATE TABLE IF NOT EXISTS workflows (\n id TEXT PRIMARY KEY,\n title TEXT NOT NULL,\n source TEXT NOT NULL, -- JSON (WorkflowSource: spec, issues, root_issue, or goal)\n status TEXT NOT NULL DEFAULT 'pending' CHECK(status IN (\n 'pending', 'running', 'paused',\n 'completed', 'failed', 'cancelled'\n )),\n steps TEXT NOT NULL DEFAULT '[]', -- JSON array (WorkflowStep[])\n worktree_path TEXT,\n branch_name TEXT,\n base_branch TEXT NOT NULL,\n current_step_index INTEGER NOT NULL DEFAULT 0,\n orchestrator_execution_id TEXT,\n orchestrator_session_id TEXT,\n config TEXT NOT NULL, -- JSON (WorkflowConfig)\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n started_at DATETIME,\n completed_at DATETIME,\n FOREIGN KEY (orchestrator_execution_id) REFERENCES executions(id) ON DELETE SET NULL\n);\n"; export declare const WORKFLOW_EVENTS_TABLE = "\nCREATE TABLE IF NOT EXISTS workflow_events (\n id TEXT PRIMARY KEY,\n workflow_id TEXT NOT NULL,\n type TEXT NOT NULL, -- WorkflowEventType (step_completed, workflow_paused, etc.)\n step_id TEXT,\n execution_id TEXT,\n payload TEXT NOT NULL DEFAULT '{}', -- JSON (event-specific data)\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n processed_at DATETIME, -- When orchestrator processed this event\n FOREIGN KEY (workflow_id) REFERENCES workflows(id) ON DELETE CASCADE,\n FOREIGN KEY (execution_id) REFERENCES executions(id) ON DELETE SET NULL\n);\n"; /** * Index definitions */ export declare const SPECS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_specs_uuid ON specs(uuid);\nCREATE INDEX IF NOT EXISTS idx_specs_priority ON specs(priority);\nCREATE INDEX IF NOT EXISTS idx_specs_parent_id ON specs(parent_id);\nCREATE INDEX IF NOT EXISTS idx_specs_parent_uuid ON specs(parent_uuid);\nCREATE INDEX IF NOT EXISTS idx_specs_archived ON specs(archived);\nCREATE INDEX IF NOT EXISTS idx_specs_created_at ON specs(created_at);\nCREATE INDEX IF NOT EXISTS idx_specs_updated_at ON specs(updated_at);\n"; export declare const ISSUES_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_issues_uuid ON issues(uuid);\nCREATE INDEX IF NOT EXISTS idx_issues_status ON issues(status);\nCREATE INDEX IF NOT EXISTS idx_issues_priority ON issues(priority);\nCREATE INDEX IF NOT EXISTS idx_issues_assignee ON issues(assignee);\nCREATE INDEX IF NOT EXISTS idx_issues_parent_id ON issues(parent_id);\nCREATE INDEX IF NOT EXISTS idx_issues_parent_uuid ON issues(parent_uuid);\nCREATE INDEX IF NOT EXISTS idx_issues_archived ON issues(archived);\nCREATE INDEX IF NOT EXISTS idx_issues_created_at ON issues(created_at);\nCREATE INDEX IF NOT EXISTS idx_issues_updated_at ON issues(updated_at);\nCREATE INDEX IF NOT EXISTS idx_issues_closed_at ON issues(closed_at);\n"; export declare const RELATIONSHIPS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_rel_from_id ON relationships(from_id, from_type);\nCREATE INDEX IF NOT EXISTS idx_rel_from_uuid ON relationships(from_uuid, from_type);\nCREATE INDEX IF NOT EXISTS idx_rel_to_id ON relationships(to_id, to_type);\nCREATE INDEX IF NOT EXISTS idx_rel_to_uuid ON relationships(to_uuid, to_type);\nCREATE INDEX IF NOT EXISTS idx_rel_type ON relationships(relationship_type);\nCREATE INDEX IF NOT EXISTS idx_rel_created_at ON relationships(created_at);\n"; export declare const TAGS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_tags_entity_id ON tags(entity_id, entity_type);\nCREATE INDEX IF NOT EXISTS idx_tags_entity_uuid ON tags(entity_uuid, entity_type);\nCREATE INDEX IF NOT EXISTS idx_tags_tag ON tags(tag);\n"; export declare const EVENTS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_events_entity_id ON events(entity_id, entity_type);\nCREATE INDEX IF NOT EXISTS idx_events_entity_uuid ON events(entity_uuid, entity_type);\nCREATE INDEX IF NOT EXISTS idx_events_type ON events(event_type);\nCREATE INDEX IF NOT EXISTS idx_events_actor ON events(actor);\nCREATE INDEX IF NOT EXISTS idx_events_created_at ON events(created_at);\nCREATE INDEX IF NOT EXISTS idx_events_git_commit ON events(git_commit_sha);\n"; export declare const ISSUE_FEEDBACK_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_feedback_from_id ON issue_feedback(from_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_from_uuid ON issue_feedback(from_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_to_id ON issue_feedback(to_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_to_uuid ON issue_feedback(to_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);\nCREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);\nCREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);\n"; export declare const EXECUTIONS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_executions_issue_id ON executions(issue_id);\nCREATE INDEX IF NOT EXISTS idx_executions_issue_uuid ON executions(issue_uuid);\nCREATE INDEX IF NOT EXISTS idx_executions_status ON executions(status);\nCREATE INDEX IF NOT EXISTS idx_executions_session_id ON executions(session_id);\nCREATE INDEX IF NOT EXISTS idx_executions_parent ON executions(parent_execution_id);\nCREATE INDEX IF NOT EXISTS idx_executions_created_at ON executions(created_at);\nCREATE INDEX IF NOT EXISTS idx_executions_workflow ON executions(workflow_execution_id);\nCREATE INDEX IF NOT EXISTS idx_executions_workflow_step ON executions(workflow_execution_id, step_index);\nCREATE INDEX IF NOT EXISTS idx_executions_step_type ON executions(step_type);\n"; export declare const PROMPT_TEMPLATES_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_templates_type ON prompt_templates(type);\nCREATE INDEX IF NOT EXISTS idx_templates_default ON prompt_templates(is_default);\n"; export declare const EXECUTION_LOGS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_execution_logs_updated_at ON execution_logs(updated_at);\nCREATE INDEX IF NOT EXISTS idx_execution_logs_byte_size ON execution_logs(byte_size);\nCREATE INDEX IF NOT EXISTS idx_execution_logs_line_count ON execution_logs(line_count);\n"; export declare const WORKFLOWS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_workflows_status ON workflows(status);\nCREATE INDEX IF NOT EXISTS idx_workflows_orchestrator ON workflows(orchestrator_execution_id);\nCREATE INDEX IF NOT EXISTS idx_workflows_created_at ON workflows(created_at);\nCREATE INDEX IF NOT EXISTS idx_workflows_updated_at ON workflows(updated_at);\nCREATE INDEX IF NOT EXISTS idx_workflows_base_branch ON workflows(base_branch);\n"; export declare const WORKFLOW_EVENTS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_workflow_events_workflow_id ON workflow_events(workflow_id);\nCREATE INDEX IF NOT EXISTS idx_workflow_events_type ON workflow_events(type);\nCREATE INDEX IF NOT EXISTS idx_workflow_events_execution_id ON workflow_events(execution_id);\nCREATE INDEX IF NOT EXISTS idx_workflow_events_processed ON workflow_events(processed_at);\nCREATE INDEX IF NOT EXISTS idx_workflow_events_created_at ON workflow_events(created_at);\nCREATE INDEX IF NOT EXISTS idx_workflow_events_unprocessed ON workflow_events(workflow_id, processed_at) WHERE processed_at IS NULL;\n"; /** * View definitions */ export declare const READY_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS ready_issues AS\nSELECT i.*\nFROM issues i\nWHERE i.status = 'open'\n AND i.archived = 0\n AND NOT EXISTS (\n SELECT 1 FROM relationships r\n JOIN issues blocker ON (\n (r.relationship_type = 'blocks' AND r.from_id = blocker.id AND r.from_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND r.to_id = blocker.id AND r.to_type = 'issue')\n )\n WHERE (\n (r.relationship_type = 'blocks' AND r.to_id = i.id AND r.to_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND r.from_id = i.id AND r.from_type = 'issue')\n )\n AND blocker.status IN ('open', 'in_progress', 'blocked')\n );\n"; export declare const BLOCKED_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS blocked_issues AS\nSELECT\n i.*,\n COUNT(DISTINCT blocker.id) as blocked_by_count,\n GROUP_CONCAT(DISTINCT blocker.id) as blocked_by_ids\nFROM issues i\nJOIN relationships r ON (\n (r.relationship_type = 'blocks' AND i.id = r.to_id AND r.to_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND i.id = r.from_id AND r.from_type = 'issue')\n)\nJOIN issues blocker ON (\n (r.relationship_type = 'blocks' AND r.from_id = blocker.id AND r.from_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND r.to_id = blocker.id AND r.to_type = 'issue')\n)\nWHERE i.status IN ('open', 'in_progress', 'blocked')\n AND i.archived = 0\n AND blocker.status IN ('open', 'in_progress', 'blocked')\nGROUP BY i.id;\n"; /** * Combined schema initialization */ export declare const ALL_TABLES: string[]; export declare const ALL_INDEXES: string[]; export declare const ALL_VIEWS: string[]; //# sourceMappingURL=schema.d.ts.map