/** * Lex Error Codes Catalog * * Stable error codes for AXError responses. * Per AX Contract v0.1 ยง2.3, all AI-facing errors should use these codes. * * Error codes follow UPPER_SNAKE_CASE format and are organized by category. * * @module shared/errors/error-codes */ /** * Configuration Errors (CONFIG_*) * * Errors related to loading and parsing configuration files. */ export declare const CONFIG_ERROR_CODES: { /** lex.yaml not found after workspace is initialized */ readonly CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND"; /** lex.yaml exists but has invalid YAML syntax */ readonly CONFIG_PARSE_ERROR: "CONFIG_PARSE_ERROR"; /** lex.yaml exists but fails schema validation */ readonly CONFIG_INVALID: "CONFIG_INVALID"; }; /** * Policy Errors (POLICY_*) * * Errors related to policy files and validation. */ export declare const POLICY_ERROR_CODES: { /** No policy file found in any search path */ readonly POLICY_NOT_FOUND: "POLICY_NOT_FOUND"; /** Policy file exists but has invalid JSON */ readonly POLICY_PARSE_ERROR: "POLICY_PARSE_ERROR"; /** Policy file fails schema validation */ readonly POLICY_INVALID: "POLICY_INVALID"; /** Policy module ID not found */ readonly POLICY_MODULE_NOT_FOUND: "POLICY_MODULE_NOT_FOUND"; }; /** * Database/Store Errors (DB_*, FRAME_*, STORE_*) * * Errors related to database operations and frame storage. */ export declare const STORE_ERROR_CODES: { /** Database connection failed */ readonly DB_CONNECTION_FAILED: "DB_CONNECTION_FAILED"; /** Database query failed */ readonly DB_QUERY_FAILED: "DB_QUERY_FAILED"; /** Database migration failed */ readonly DB_MIGRATION_FAILED: "DB_MIGRATION_FAILED"; /** Frame not found by ID */ readonly FRAME_NOT_FOUND: "FRAME_NOT_FOUND"; /** Frame validation failed */ readonly FRAME_INVALID: "FRAME_INVALID"; /** Frame save operation failed */ readonly FRAME_SAVE_FAILED: "FRAME_SAVE_FAILED"; /** Store initialization failed */ readonly STORE_INIT_FAILED: "STORE_INIT_FAILED"; }; /** * Prompt Errors (PROMPT_*) * * Errors related to prompt loading and rendering. */ export declare const PROMPT_ERROR_CODES: { /** Prompt file not found in any search path */ readonly PROMPT_NOT_FOUND: "PROMPT_NOT_FOUND"; /** Prompt template has invalid syntax */ readonly PROMPT_INVALID: "PROMPT_INVALID"; /** Prompt rendering failed (missing variables, etc.) */ readonly PROMPT_RENDER_FAILED: "PROMPT_RENDER_FAILED"; }; /** * Schema Errors (SCHEMA_*) * * Errors related to schema loading and validation. */ export declare const SCHEMA_ERROR_CODES: { /** Schema file not found */ readonly SCHEMA_NOT_FOUND: "SCHEMA_NOT_FOUND"; /** Schema file has invalid JSON */ readonly SCHEMA_PARSE_ERROR: "SCHEMA_PARSE_ERROR"; /** Data failed schema validation */ readonly SCHEMA_VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED"; }; /** * Instructions Errors (INSTRUCTIONS_*) * * Errors related to instruction generation and management. */ export declare const INSTRUCTIONS_ERROR_CODES: { /** Canonical instruction file not found */ readonly INSTRUCTIONS_CANONICAL_NOT_FOUND: "INSTRUCTIONS_CANONICAL_NOT_FOUND"; /** Target file already exists (without --force) */ readonly INSTRUCTIONS_TARGET_EXISTS: "INSTRUCTIONS_TARGET_EXISTS"; /** Invalid projection target specified */ readonly INSTRUCTIONS_INVALID_TARGET: "INSTRUCTIONS_INVALID_TARGET"; /** Instruction projections out of sync */ readonly INSTRUCTIONS_OUT_OF_SYNC: "INSTRUCTIONS_OUT_OF_SYNC"; }; /** * Git Errors (GIT_*) * * Errors related to git operations. */ export declare const GIT_ERROR_CODES: { /** Not in a git repository */ readonly GIT_NOT_REPO: "GIT_NOT_REPO"; /** Git command failed */ readonly GIT_COMMAND_FAILED: "GIT_COMMAND_FAILED"; /** Git branch not found */ readonly GIT_BRANCH_NOT_FOUND: "GIT_BRANCH_NOT_FOUND"; }; /** * LexSona Errors (LEXSONA_*) * * Errors related to behavioral rules and persona management. */ export declare const LEXSONA_ERROR_CODES: { /** Rule not found by ID */ readonly LEXSONA_RULE_NOT_FOUND: "LEXSONA_RULE_NOT_FOUND"; /** Correction could not be recorded */ readonly LEXSONA_CORRECTION_FAILED: "LEXSONA_CORRECTION_FAILED"; /** Persona not found */ readonly LEXSONA_PERSONA_NOT_FOUND: "LEXSONA_PERSONA_NOT_FOUND"; }; /** * Validation Errors (VALIDATION_*) * * Generic validation errors. */ export declare const VALIDATION_ERROR_CODES: { /** Required field is missing */ readonly VALIDATION_REQUIRED_FIELD: "VALIDATION_REQUIRED_FIELD"; /** Field has invalid type */ readonly VALIDATION_INVALID_TYPE: "VALIDATION_INVALID_TYPE"; /** Field value is out of range */ readonly VALIDATION_OUT_OF_RANGE: "VALIDATION_OUT_OF_RANGE"; /** Module ID format is invalid */ readonly VALIDATION_INVALID_MODULE_ID: "VALIDATION_INVALID_MODULE_ID"; }; /** * All Lex error codes combined */ export declare const LEX_ERROR_CODES: { /** Required field is missing */ readonly VALIDATION_REQUIRED_FIELD: "VALIDATION_REQUIRED_FIELD"; /** Field has invalid type */ readonly VALIDATION_INVALID_TYPE: "VALIDATION_INVALID_TYPE"; /** Field value is out of range */ readonly VALIDATION_OUT_OF_RANGE: "VALIDATION_OUT_OF_RANGE"; /** Module ID format is invalid */ readonly VALIDATION_INVALID_MODULE_ID: "VALIDATION_INVALID_MODULE_ID"; /** Rule not found by ID */ readonly LEXSONA_RULE_NOT_FOUND: "LEXSONA_RULE_NOT_FOUND"; /** Correction could not be recorded */ readonly LEXSONA_CORRECTION_FAILED: "LEXSONA_CORRECTION_FAILED"; /** Persona not found */ readonly LEXSONA_PERSONA_NOT_FOUND: "LEXSONA_PERSONA_NOT_FOUND"; /** Not in a git repository */ readonly GIT_NOT_REPO: "GIT_NOT_REPO"; /** Git command failed */ readonly GIT_COMMAND_FAILED: "GIT_COMMAND_FAILED"; /** Git branch not found */ readonly GIT_BRANCH_NOT_FOUND: "GIT_BRANCH_NOT_FOUND"; /** Canonical instruction file not found */ readonly INSTRUCTIONS_CANONICAL_NOT_FOUND: "INSTRUCTIONS_CANONICAL_NOT_FOUND"; /** Target file already exists (without --force) */ readonly INSTRUCTIONS_TARGET_EXISTS: "INSTRUCTIONS_TARGET_EXISTS"; /** Invalid projection target specified */ readonly INSTRUCTIONS_INVALID_TARGET: "INSTRUCTIONS_INVALID_TARGET"; /** Instruction projections out of sync */ readonly INSTRUCTIONS_OUT_OF_SYNC: "INSTRUCTIONS_OUT_OF_SYNC"; /** Schema file not found */ readonly SCHEMA_NOT_FOUND: "SCHEMA_NOT_FOUND"; /** Schema file has invalid JSON */ readonly SCHEMA_PARSE_ERROR: "SCHEMA_PARSE_ERROR"; /** Data failed schema validation */ readonly SCHEMA_VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED"; /** Prompt file not found in any search path */ readonly PROMPT_NOT_FOUND: "PROMPT_NOT_FOUND"; /** Prompt template has invalid syntax */ readonly PROMPT_INVALID: "PROMPT_INVALID"; /** Prompt rendering failed (missing variables, etc.) */ readonly PROMPT_RENDER_FAILED: "PROMPT_RENDER_FAILED"; /** Database connection failed */ readonly DB_CONNECTION_FAILED: "DB_CONNECTION_FAILED"; /** Database query failed */ readonly DB_QUERY_FAILED: "DB_QUERY_FAILED"; /** Database migration failed */ readonly DB_MIGRATION_FAILED: "DB_MIGRATION_FAILED"; /** Frame not found by ID */ readonly FRAME_NOT_FOUND: "FRAME_NOT_FOUND"; /** Frame validation failed */ readonly FRAME_INVALID: "FRAME_INVALID"; /** Frame save operation failed */ readonly FRAME_SAVE_FAILED: "FRAME_SAVE_FAILED"; /** Store initialization failed */ readonly STORE_INIT_FAILED: "STORE_INIT_FAILED"; /** No policy file found in any search path */ readonly POLICY_NOT_FOUND: "POLICY_NOT_FOUND"; /** Policy file exists but has invalid JSON */ readonly POLICY_PARSE_ERROR: "POLICY_PARSE_ERROR"; /** Policy file fails schema validation */ readonly POLICY_INVALID: "POLICY_INVALID"; /** Policy module ID not found */ readonly POLICY_MODULE_NOT_FOUND: "POLICY_MODULE_NOT_FOUND"; /** lex.yaml not found after workspace is initialized */ readonly CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND"; /** lex.yaml exists but has invalid YAML syntax */ readonly CONFIG_PARSE_ERROR: "CONFIG_PARSE_ERROR"; /** lex.yaml exists but fails schema validation */ readonly CONFIG_INVALID: "CONFIG_INVALID"; }; /** * Type for any valid Lex error code */ export type LexErrorCode = (typeof LEX_ERROR_CODES)[keyof typeof LEX_ERROR_CODES]; /** * Check if a string is a valid Lex error code */ export declare function isLexErrorCode(code: string): code is LexErrorCode; /** * Standard next actions for common error scenarios * * Use these to provide consistent recovery suggestions. */ export declare const STANDARD_NEXT_ACTIONS: { /** Suggest running lex init */ readonly INIT_WORKSPACE: "Run \"lex init\" to create a workspace"; /** Suggest running lex policy check */ readonly CHECK_POLICY: "Run \"lex policy check\" to validate policy"; /** Suggest running lex timeline */ readonly VIEW_TIMELINE: "Run \"lex timeline\" to see recent Frames"; /** Suggest checking file path */ readonly CHECK_FILE_PATH: "Verify the file path exists and is readable"; /** Suggest checking config */ readonly CHECK_CONFIG: "Check lex.yaml configuration for errors"; /** Suggest using --force flag */ readonly USE_FORCE: "Use --force flag to overwrite existing files"; /** Suggest retrying */ readonly RETRY: "Retry the operation"; /** Suggest checking logs */ readonly CHECK_LOGS: "Check logs for more details"; };