sqlsentinel

    Deterministic SQL risk review and multi-file migration planning, written in MoonBit.

    sql
    linter
    static-analysis
    database
    migration
    ci
    developer-tools
    Download zip
    Author
    Version
    0.16.0
    License
    Apache-2.0
    Last updated
    4 hours ago
    Downloads
    2

    #SQLSentinel

    CI

    Deterministic database change intelligence for SQL, written in MoonBit.

    SQLSentinel is a dependency-light library and CLI for statement-level SQL risk review and project-level migration planning. It is designed for application migrations, analytics pipelines, database change review, CI gates, editor integration, and AI-assisted workflows where teams need deterministic evidence instead of a raw SQL dump.

    SQLSentinel does not connect to a database and does not execute SQL. It lexes source text locally, masks string literals in evidence, and returns stable findings in text, JSON, Markdown, SARIF 2.1.0, or GitHub annotations.

    #Competition acceptance path

    The repository includes a one-command acceptance harness and an explicit mapping to the official MoonBit Hackathon requirements and scoring dimensions:

    .\scripts\acceptance.ps1

    Artifacts are written under _build/acceptance/. See Competition acceptance guide, the five-minute demo, and ecosystem positioning. Release highlights and reproduction commands are collected in release notes.

    #Why this project

    The MoonBit ecosystem already has SQL parsers, ORMs, and SQLite bindings. A general-purpose, database-independent SQL risk review layer remains much less represented. SQLSentinel focuses on a different job:

    • review a migration or query file before execution;
    • explain why a statement is risky;
    • produce a deterministic report suitable for CI;
    • produce a bounded review packet for a human or LLM reviewer.

    This is intentionally not an SQL compatibility checker, query optimizer, or SQL dialect parser. It uses a conservative structural model and only reports patterns that can be explained with a source location.

    The project-level analyzer goes beyond independent rules: it processes an ordered migration set, maintains an evolving in-memory schema, and reports impact, missing objects, incompatible type changes, renames, foreign keys, and supporting indexes.

    #What “conservative structural analysis” means

    SQLSentinel is not a complete SQL parser or a live schema engine. It is a bounded semantic model with five explicit stages:

    1. a context-aware lexer for strings, identifiers, comments, and dollar bodies;
    2. top-level statement splitting;
    3. a structural parser for the documented DDL/query subset;
    4. an ordered schema-state reducer and query-reference layer;
    5. policy evaluation over typed findings.

    Rules inspect parser/state results, not regular expressions over raw SQL. Unsupported procedural blocks, dynamic SQL, and query-plan semantics are ignored rather than guessed. Run sqlsentinel --capabilities for the supported grammar, precision claims, and unsupported layers. See Analysis model.

    #Verifiable parser coverage

    Every migration statement now produces a structured trace with its source span, matched grammar branch, analyzed/ignored status, token count, and reason. Plan, impact, and review JSON expose the traces under coverage (or migration_coverage for impact output), so a reviewer can verify that findings come from supported structural branches rather than fixture-specific matching.

    Use --require-full-coverage in CI to fail when any statement falls outside the documented grammar instead of silently accepting partial coverage:

    moon run --target native cmd/main -- \ --format plan-json \ --require-full-coverage \ --schema examples/plan/schema.json \ examples/plan

    The intentionally unsupported example under examples/coverage/ demonstrates ignored reasons and the strict gate. This is a coverage audit of the bounded model, not a claim of complete SQL grammar support.

    #Rules

    IDSeverityRule
    SQL001errorUPDATE/DELETE without a top-level WHERE or with an always-true predicate
    SQL002errorDestructive DDL such as DROP TABLE, TRUNCATE, or DROP COLUMN
    SQL003warningWildcard projection
    SQL004warningLIMIT without ORDER BY
    SQL005warningLIKE pattern starting with % or _
    SQL006warningComma-separated table list without explicit JOIN
    SQL007warningINSERT without a target-column list
    SQL008warningAdded NOT NULL column without DEFAULT
    SQL100warningMalformed or unreachable SQLSentinel directive
    SQL201warningDestructive operation on a table referenced by another table
    SQL202errorDropping a column used by an index or foreign key
    SQL301warningIn-place existing column type change
    SQL302errorMigration references a missing schema object
    SQL303warningForeign key without a supporting index prefix
    SQL304warningTable or column rename can break external callers
    SQL305warning/errorDownstream query references a changed schema object

    Run sqlsentinel --rules for the complete rationale and remediation guidance. SQL201 and SQL202 run only when a local schema catalog is supplied.

    #Migration plan analysis

    Analyze a multi-file change set as one evolving schema:

    moon run --target native cmd/main -- \ --format plan \ --schema examples/plan/schema.json \ examples/plan

    Machine-readable and review variants use --format plan-json and --format plan-markdown. The plan includes table counts before/after, affected tables, ordered schema changes, breaking changes, and semantic findings. Migration plan analysis documents supported DDL, ordering rules, and the reusable analyze_migrations API.

    The bounded grammar covers PostgreSQL-style ALTER COLUMN ... TYPE and MySQL MODIFY COLUMN / CHANGE COLUMN. A MySQL CHANGE COLUMN can produce both a rename finding and an in-place type-change finding when both behaviors apply.

    #Downstream query impact

    Cross-reference migration changes with application or analytics queries:

    moon run --target native cmd/main -- \ --format impact-json \ --schema examples/plan/schema.json \ examples/plan \ --query examples/impact/queries

    The result maps changed tables and columns to query files and source locations. Drop operations produce error-level SQL305 findings; renames and type changes produce warnings. See Downstream query impact.

    #Unified review packet

    Create one review artifact combining statement findings, migration changes, and downstream impact:

    moon run --target native cmd/main -- \ --format review-markdown \ --schema examples/plan/schema.json \ examples/plan \ --query examples/impact/queries

    review, review-json, and review-markdown report a pass, review, or block verdict with combined metrics and suggested actions. See Unified review packet.

    Use review-sarif to publish the same combined result to GitHub code scanning:

    - uses: Ljh684/sqlsentinel@v0.16.0 with: paths: db/migrations queries: services/**/*.sql schema: .sqlsentinel/schema.json format: review-sarif sarif-file: sqlsentinel-review.sarif - uses: github/codeql-action/upload-sarif@v3 if: always() with: sarif_file: sqlsentinel-review.sarif

    The SARIF report contains statement, migration, and downstream-impact findings in one run, with verdict and parser-coverage metadata in run properties.

    #Quick start

    Requirements:

    CI pins MoonBit 0.10.14+7d59c7ec9 so formatting and compilation checks remain reproducible. Newer toolchains may propose formatter-driven syntax migrations.

    moon update moon run --target native cmd/main -- examples/safe_query.sql

    Review a migration directory:

    moon run --target native cmd/main -- \ --fail-on warning \ db/migrations

    Directory inputs are scanned recursively for files ending in .sql (case insensitive). Explicit file inputs are always scanned regardless of extension. Results are sorted, duplicate files are removed, and the generated/dependency directories .git, _build, .mooncakes, node_modules, and target are skipped.

    Path arguments and configured paths may use *, ?, and ** glob segments:

    moon run --target native cmd/main -- 'db/**/*.sql' moon run --target native cmd/main -- 'queries/query_?.SQL'

    Glob matching is case insensitive and only selects files ending in .sql. Quote patterns in shells that would otherwise expand them.

    #Project configuration

    SQLSentinel automatically loads .sqlsentinel.json from the current directory when present. An explicit path can be selected with --config, while --no-config disables discovery:

    moon run --target native cmd/main -- \ --config examples/sqlsentinel.example.json

    { "paths": ["db/**/*.sql", "queries/**/*.sql"], "format": "text", "failOn": "error", "allowDestructive": false, "styleChecks": true, "ignore": ["SQL008"], "base": "origin/main...HEAD", "dialect": "postgres", "schema": "schema.json", "baseline": ".sqlsentinel/baseline.json", "severityOverrides": { "SQL008": "error", "SQL003": "info" }, "queries": ["services/**/*.sql"] }

    Command paths support *, ?, and ** glob segments. Supported configuration fields are paths, queries, format, failOn, allowDestructive, styleChecks, ignore, base, dialect, schema, baseline, and severityOverrides. Relative paths, including schema, baseline, and query paths, resolve from the config file's directory. Unknown fields and invalid values are errors.

    Command-line values override configuration. Positional paths override paths; --ignore replaces the configured ignore list; --strict-destructive and --style override the corresponding boolean fields. base is used when --changed is enabled.

    #Schema-aware review

    Some risks require knowledge beyond one SQL statement. Supply a small, version-controlled JSON catalog without connecting to a database:

    { "tables": [ { "name": "users", "columns": [ {"name": "id", "nullable": false}, {"name": "email", "nullable": false} ], "indexes": [ {"name": "users_email", "columns": ["email"], "unique": true} ] }, { "name": "orders", "columns": [ {"name": "id", "nullable": false}, {"name": "user_id", "nullable": false} ], "foreignKeys": [ { "name": "orders_user_fk", "columns": ["user_id"], "references": {"table": "users", "columns": ["id"]} } ] } ] }

    name and columns are required; nullable, indexes, foreignKeys, unique, and object names are optional. The loader rejects duplicate tables or columns and validates every index and foreign-key column against the catalog. It remains a local declaration, not a live database introspection result.

    Run the example:

    moon run --target native cmd/main -- \ --schema examples/schema.json \ examples/schema_risks.sql

    This reports SQL201 because orders references users, and SQL202 because users.email is indexed. --no-schema disables a schema selected by the project configuration. The JSON and SARIF reports expose "schema": true, and schema findings are includable in GitHub annotations and suppression audits. See Schema catalog for the complete format and validation behavior, or use the JSON Schema for editor completion.

    #Finding baselines

    Existing review debt can be recorded once so CI only blocks new findings:

    moon run --target native cmd/main -- \ --write-baseline .sqlsentinel/baseline.json \ db/migrations moon run --target native cmd/main -- \ --baseline .sqlsentinel/baseline.json \ --fail-on error \ db/migrations

    Baseline fingerprints use normalized paths, rule IDs, non-reversible token fingerprints, bounded evidence, and occurrence counts. Moving a statement to another line does not invalidate it; changing a literal or adding another identical risky statement still produces a finding. Reports include baseline status and a separate baseline_suppressed count. Use --no-baseline to disable a configured baseline. See Finding baselines for the format and refresh workflow.

    #Severity policy overrides

    Promote or demote individual rules without editing the project source:

    moon run --target native cmd/main -- \ --severity SQL008=error,SQL003=info \ db/migrations

    Supported levels are info, warning, and error. The first CLI option replaces configured overrides, and --no-severity-overrides disables them. Effective severities drive failure thresholds and all report totals; the active override list is recorded in JSON and SARIF. See Severity overrides for precedence and semantics.

    #Browser playground

    The reusable core compiles to a standalone ES module for local browser use:

    bash scripts/build-web.sh python3 -m http.server 8080 --directory web/dist

    Open http://localhost:8080. The page supports SQL input, dialect selection, safe/dangerous/schema examples, an editable schema catalog, schema JSON import and formatting, finding cards, suppression metrics, Markdown copying, and JSON download. Schema validation and SQL201/SQL202 run in the browser through the same MoonBit parser used by the CLI. SQL, schema data, and findings are never sent over the network.

    The static build is committed under web/dist. GitHub Pages deployment is ready in Deploy Playground, but Pages must first be enabled under repository settings. See Pages deployment.

    Generate a Markdown review packet for a pull request or an AI reviewer:

    moon run --target native cmd/main -- \ --format markdown \ --fail-on never \ db/migrations > sql-review.md

    Generate SARIF for GitHub code scanning:

    moon run --target native cmd/main -- \ --format sarif \ --fail-on never \ db/migrations > sqlsentinel.sarif

    Generate GitHub Actions annotations:

    moon run --target native cmd/main -- \ --format github \ db/migrations

    Review only SQL changed from a Git base:

    moon run --target native cmd/main -- --changed moon run --target native cmd/main -- \ --changed \ --base origin/main...HEAD

    --changed defaults to comparing HEAD with staged and unstaged tracked changes. --base can select another safe Git revision or range. Added, copied, modified, and renamed SQL files are considered; deleted files are skipped. Untracked files must be staged before Git can report them.

    Scan an inline statement:

    moon run --target native cmd/main -- \ --format json \ --fail-on never \ --sql "UPDATE users SET active = false;"

    #CLI

    sqlsentinel [options] <file-or-directory>... sqlsentinel --sql "<SQL text>"

    Options:

    • --format text|json|markdown|sarif|github|plan*|impact*|review* selects the output format.
    • --config <path> selects a project configuration file.
    • --no-config disables .sqlsentinel.json discovery.
    • --fail-on never|info|warning|error controls the exit threshold.
    • --dialect auto|postgres|mysql|sqlite selects dialect-sensitive behavior.
    • --schema <path> loads a local JSON table/index/foreign-key catalog.
    • --no-schema disables a schema selected by project configuration.
    • --baseline <path> suppresses findings recorded in a reviewed baseline.
    • --write-baseline <path> writes the current active findings as a baseline.
    • --no-baseline disables a baseline selected by project configuration.
    • --allow-destructive downgrades SQL001 and SQL002 from errors to warnings.
    • --strict-destructive restores SQL001 and SQL002 to errors.
    • --no-style disables SQL003 through SQL008 while retaining destructive checks.
    • --style enables style checks even when disabled in the configuration.
    • --ignore SQL003,SQL005 suppresses specific rules after they have been reviewed.
    • --severity SQL008=error,SQL003=info overrides effective rule severities.
    • --no-severity-overrides disables configured severity overrides.
    • --query <path> adds query sources for impact output formats.
    • --require-full-coverage fails plan/impact/review output on ignored statements.
    • --changed scans only SQL reported by Git as changed.
    • --base <git-ref> selects the Git comparison base; it implies --changed.
    • --rules prints the rule catalog as Markdown.
    • --capabilities prints the semantic pipeline and coverage boundaries.
    • --help and --version provide CLI metadata.

    #Statement-level suppression

    Use a directive comment immediately before the statement whose finding has been reviewed:

    -- sqlsentinel: ignore SQL003 SELECT * FROM legacy_export_view; SELECT * FROM users; -- SQL003 is still reported here

    Multiple rules and block comments are supported:

    /* sqlsentinel: ignore SQL003, SQL004 */ SELECT * FROM legacy_export_view LIMIT 100;

    The directive applies only to the next SQL statement. An unknown rule ID, unsupported command, missing colon, or directive without a following statement produces SQL100, so a typo cannot silently hide a finding.

    Reports always include a suppression audit. Text, JSON, Markdown, and GitHub output show how many findings were suppressed and the count for each rule, so review exceptions remain visible instead of silently accumulating.

    Exit codes:

    • 0: scan completed and no finding reached the fail threshold;
    • 1: at least one finding reached the fail threshold;
    • 2: invalid arguments or file I/O failure.

    #Library API

    let report = @sqlsentinel.scan_sql(
    "DELETE FROM users WHERE disabled_at IS NOT NULL;",
    )

    if report.should_fail(@sqlsentinel.FailLevel::Warning) {
    println(@sqlsentinel.report_to_markdown(report))
    }

    The core API performs no I/O and can be embedded in another MoonBit tool:

    • scan_sql(source);
    • scan_sql_with(source, options);
    • analyze_migrations(inputs, options) for ordered multi-file schema analysis;
    • analyze_change_impact(migrations, queries, options) for cross-source impact;
    • review_packet_to_json/text/markdown(files, migration, impact);
    • SchemaCatalog and ScanOptions::new(schema=...) for embedded schema checks;
    • @schema.parse_schema_json(text, source) for validated JSON catalogs;
    • report_to_json(report);
    • report_to_markdown(report);
    • report_to_text(report);
    • files_to_sarif(files);
    • rule_catalog().

    #Design choices

    Local and deterministic. No network, model API, SQL server, or database driver is required.

    Comments and literals are lexed. Semicolons or keywords inside strings, quoted identifiers, nested block comments, and PostgreSQL-style dollar-quoted strings do not become fake statements.

    Evidence is bounded. String literals are replaced by <literal> in the evidence field, reducing the chance that a report leaks application data.

    Reports are machine-first. Findings have stable rule IDs, source locations, statement indexes, explanations, and remediation text. JSON and SARIF are directly consumable by automation.

    AI is optional. Markdown output gives an LLM a narrow, evidence-backed task: review these findings and the shown SQL excerpt. It does not ask a model to invent a verdict from an entire repository.

    #GitHub Actions

    The repository root is a reusable composite action for Linux, macOS, and Windows runners. It builds the native CLI with a pinned MoonBit toolchain and runs from the consumer repository directory. See GitHub Action usage.

    Minimal usage:

    jobs: sql-review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: Ljh684/sqlsentinel@v0.16.0 with: paths: | db/**/*.sql queries/** fail-on: error

    The project CI also exercises the composite action through uses: ./. See .github/workflows/ci.yml.

    #Current limitations

    • The scanner uses a structural lexer, not a complete dialect-specific parser. Schema-aware checks rely on the supplied JSON catalog and do not introspect a live database.
    • Migration plans are conservative and model common table, column, index, rename, and foreign-key DDL; they do not execute or fully parse procedural SQL.
    • Plan inputs must be ordered. A starting schema catalog is required when the first migration does not create every existing table.
    • GO batch separators and dialect-specific procedural blocks are not yet modeled.
    • Rules avoid claims about table sizes, lock behavior, or query plans that cannot be established from SQL text and the supplied schema metadata.
    • Directory discovery currently includes .sql files only and uses a fixed skip list for common generated/dependency directories.
    • Changed-file mode requires a native binary, Git on PATH, and a Git checkout.

    #Roadmap

    • broader dialect-specific DDL and procedural-block coverage;
    • custom organization policy packs and severity profiles;
    • optional database-dump import for seeded schema catalogs.

    #Development

    moon check --target native moon test --target native moon fmt --check moon run --target native cmd/main -- examples/safe_migration.sql

    Project layout:

    types.mbt public models and rule catalog lexer.mbt SQL-aware tokenization and statement splitting analyzer.mbt structural checks and report aggregation schema_analyzer.mbt schema-aware cross-object checks migration_analyzer.mbt evolving multi-file schema and migration plan analysis impact_analyzer.mbt migration-to-query dependency and impact analysis schema/ shared JSON schema parser and validation render.mbt text, JSON, Markdown, and SARIF renderers cmd/main/ native CLI, baseline loading, and Git integration action.yml reusable composite GitHub Action examples/ safe and intentionally risky SQL files docs/ project plan and review notes

    #License

    Apache-2.0. See LICENSE and NOTICE.

    Additional project material:

    Dialect

    pub(all) enum Dialect {
    Auto
    Postgres
    Mysql
    Sqlite
    } derive(Eq)

    SQL dialect profile used for dialect-sensitive checks.

    Dialect::equal

    fn Dialect::equal(Dialect, Dialect) -> Bool
    automatically derived

    Dialect::label

    fn Dialect::label(self : Dialect) -> String

    Return a stable SQL dialect label.

    Dialect::not_equal

    fn Dialect::not_equal(x : Dialect, y : Dialect) -> Bool
    automatically derived

    Dialect::parse

    fn Dialect::parse(value : String) -> Dialect?

    Parse a SQL dialect from its command-line spelling.

    FailLevel

    pub(all) enum FailLevel {
    Never
    Info
    Warning
    Error
    } derive(Eq)

    Minimum severity that should fail a CI job.

    FailLevel::equal

    fn FailLevel::equal(FailLevel, FailLevel) -> Bool
    automatically derived

    FailLevel::label

    fn FailLevel::label(self : FailLevel) -> String

    Return a lowercase fail-policy label.

    FailLevel::not_equal

    fn FailLevel::not_equal(x : FailLevel, y : FailLevel) -> Bool
    automatically derived

    FailLevel::parse

    fn FailLevel::parse(value : String) -> FailLevel?

    Parse a fail policy from its command-line spelling.

    FileReport

    pub(all) struct FileReport {
    path : String
    report : Report
    }

    A report associated with a file path.

    Finding

    pub(all) struct Finding {
    rule_id : String
    title : String
    severity : Severity
    message : String
    suggestion : String
    statement_index : Int
    line : Int
    column : Int
    evidence : String
    fingerprint : String
    }

    One actionable result from the static analysis.

    ImpactAnalysis

    pub(all) struct ImpactAnalysis {
    references : Array[QueryReference]
    findings : Array[MigrationFinding]
    impacted_tables : Array[String]
    impacted_files : Array[String]
    error_count : Int
    warning_count : Int
    info_count : Int
    migration_coverage : MigrationCoverage
    }

    ImpactAnalysis::should_fail

    fn ImpactAnalysis::should_fail(self : ImpactAnalysis, threshold : FailLevel) -> Bool

    Whether an impact analysis contains a finding at or above a threshold.

    MigrationAnalysis

    pub(all) struct MigrationAnalysis {
    changes : Array[SchemaChange]
    findings : Array[MigrationFinding]
    tables_before : Array[String]
    tables_after : Array[String]
    affected_tables : Array[String]
    breaking_changes : Int
    error_count : Int
    warning_count : Int
    info_count : Int
    coverage : MigrationCoverage
    }

    MigrationAnalysis::should_fail

    fn MigrationAnalysis::should_fail(self : MigrationAnalysis, threshold : FailLevel) -> Bool

    Whether a migration analysis contains a finding at or above a threshold.

    MigrationCoverage

    pub(all) struct MigrationCoverage {
    statement_count : Int
    analyzed_count : Int
    ignored_count : Int
    traces : Array[StatementTrace]
    }

    Statement-level coverage for a migration analysis.

    MigrationCoverage::is_complete

    fn MigrationCoverage::is_complete(self : MigrationCoverage) -> Bool

    Whether every migration statement matched a documented grammar branch.

    MigrationFinding

    pub(all) struct MigrationFinding {
    path : String
    finding : Finding
    }

    MigrationInput

    pub(all) struct MigrationInput {
    path : String
    source : String
    }

    QueryReference

    pub(all) struct QueryReference {
    change_kind : SchemaChangeKind
    table_name : String
    column_name : String
    path : String
    line : Int
    statement_index : Int
    evidence : String
    }

    Report

    pub(all) struct Report {
    statement_count : Int
    findings : Array[Finding]
    error_count : Int
    warning_count : Int
    info_count : Int
    suppressed_count : Int
    suppressions : Array[SuppressedRule]
    dialect : Dialect
    schema_enabled : Bool
    baseline_enabled : Bool
    baseline_suppressed_count : Int
    severity_overrides : Array[SeverityOverride]
    }

    Result of scanning one SQL source string.

    Report::from_parts

    fn Report::from_parts(statement_count : Int, findings : Array[Finding], suppressed_count : Int, suppressions : Array[SuppressedRule], dialect : Dialect, schema_enabled : Bool, baseline_enabled? : Bool, baseline_suppressed_count? : Int, severity_overrides? : Array[SeverityOverride]) -> Report

    Build a report and derive severity counts from the active findings.

    Report::highest_severity

    fn Report::highest_severity(self : Report) -> Severity?

    The highest severity present in a report.

    Report::should_fail

    fn Report::should_fail(self : Report, threshold : FailLevel) -> Bool

    Whether a report contains a finding at or above the selected threshold.

    RuleDefinition

    pub(all) struct RuleDefinition {
    id : String
    title : String
    severity : Severity
    rationale : String
    remediation : String
    }

    Public documentation for a rule.

    ScanOptions

    pub(all) struct ScanOptions {
    allow_destructive : Bool
    style_checks : Bool
    ignored_rules : Array[String]
    dialect : Dialect
    schema : SchemaCatalog
    severity_overrides : Array[SeverityOverride]
    } derive(Eq)

    Policy controls for a scan.

    ScanOptions::default

    fn ScanOptions::default() -> ScanOptions

    Default policy: block destructive statements and fail on errors.

    ScanOptions::equal

    fn ScanOptions::equal(ScanOptions, ScanOptions) -> Bool
    automatically derived

    ScanOptions::new

    fn ScanOptions::new(allow_destructive? : Bool, style_checks? : Bool, ignored_rules? : Array[String], dialect? : Dialect, schema? : SchemaCatalog, severity_overrides? : Array[SeverityOverride]) -> ScanOptions

    Construct explicit scan options.

    ScanOptions::not_equal

    fn ScanOptions::not_equal(x : ScanOptions, y : ScanOptions) -> Bool
    automatically derived

    SchemaCatalog

    pub(all) struct SchemaCatalog {
    tables : Array[SchemaTable]
    } derive(Eq)

    A local schema catalog used by schema-aware checks.

    SchemaCatalog::column_is_referenced

    fn SchemaCatalog::column_is_referenced(self : SchemaCatalog, table_name : String, column_name : String) -> Bool

    Whether another table references this column through a foreign key.

    SchemaCatalog::empty

    SchemaCatalog::equal

    automatically derived

    SchemaCatalog::find_table

    fn SchemaCatalog::find_table(self : SchemaCatalog, name : String) -> SchemaTable?

    SchemaCatalog::not_equal

    fn SchemaCatalog::not_equal(x : SchemaCatalog, y : SchemaCatalog) -> Bool
    automatically derived

    SchemaChange

    pub(all) struct SchemaChange {
    kind : SchemaChangeKind
    table_name : String
    column_name : String
    detail : String
    path : String
    line : Int
    statement_index : Int
    }

    SchemaChangeKind

    pub(all) enum SchemaChangeKind {
    CreateTable
    DropTable
    AddColumn
    DropColumn
    AlterColumnType
    RenameTable
    RenameColumn
    CreateIndex
    AddForeignKey
    } derive(Eq)

    A structural database change discovered across a migration set.

    SchemaChangeKind::equal

    automatically derived

    SchemaChangeKind::label

    fn SchemaChangeKind::label(self : SchemaChangeKind) -> String

    Stable label for a migration-plan change.

    SchemaChangeKind::not_equal

    fn SchemaChangeKind::not_equal(x : SchemaChangeKind, y : SchemaChangeKind) -> Bool
    automatically derived

    SchemaColumn

    pub(all) struct SchemaColumn {
    name : String
    nullable : Bool
    } derive(Eq)

    A declared database column.

    SchemaColumn::equal

    automatically derived

    SchemaColumn::not_equal

    fn SchemaColumn::not_equal(x : SchemaColumn, y : SchemaColumn) -> Bool
    automatically derived

    SchemaForeignKey

    pub(all) struct SchemaForeignKey {
    name : String
    columns : Array[String]
    references_table : String
    references_columns : Array[String]
    } derive(Eq)

    A declared foreign key relationship.

    SchemaForeignKey::equal

    automatically derived

    SchemaForeignKey::not_equal

    fn SchemaForeignKey::not_equal(x : SchemaForeignKey, y : SchemaForeignKey) -> Bool
    automatically derived

    SchemaIndex

    pub(all) struct SchemaIndex {
    name : String
    columns : Array[String]
    unique : Bool
    } derive(Eq)

    A declared index and its ordered columns.

    SchemaIndex::equal

    fn SchemaIndex::equal(SchemaIndex, SchemaIndex) -> Bool
    automatically derived

    SchemaIndex::not_equal

    fn SchemaIndex::not_equal(x : SchemaIndex, y : SchemaIndex) -> Bool
    automatically derived

    SchemaTable

    pub(all) struct SchemaTable {
    name : String
    columns : Array[SchemaColumn]
    indexes : Array[SchemaIndex]
    foreign_keys : Array[SchemaForeignKey]
    } derive(Eq)

    A declared table and its review metadata.

    SchemaTable::column_is_protected

    fn SchemaTable::column_is_protected(self : SchemaTable, name : String) -> Bool

    SchemaTable::equal

    fn SchemaTable::equal(SchemaTable, SchemaTable) -> Bool
    automatically derived

    SchemaTable::has_column

    fn SchemaTable::has_column(self : SchemaTable, name : String) -> Bool

    SchemaTable::not_equal

    fn SchemaTable::not_equal(x : SchemaTable, y : SchemaTable) -> Bool
    automatically derived

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Error
    } derive(Eq)

    Severity assigned to one finding.

    Severity::equal

    fn Severity::equal(Severity, Severity) -> Bool
    automatically derived

    Severity::label

    fn Severity::label(self : Severity) -> String

    Return a lowercase severity label suitable for reports.

    Severity::not_equal

    fn Severity::not_equal(x : Severity, y : Severity) -> Bool
    automatically derived

    Severity::parse

    fn Severity::parse(value : String) -> Severity?

    Parse a rule severity from its command-line spelling.

    Severity::rank

    fn Severity::rank(self : Severity) -> Int

    Return a stable three-level severity rank.

    SeverityOverride

    pub(all) struct SeverityOverride {
    rule_id : String
    severity : Severity
    } derive(Eq)

    A project-specific severity for one built-in rule.

    SeverityOverride::equal

    automatically derived

    SeverityOverride::not_equal

    fn SeverityOverride::not_equal(x : SeverityOverride, y : SeverityOverride) -> Bool
    automatically derived

    StatementAnalysisStatus

    pub(all) enum StatementAnalysisStatus {
    Analyzed
    Ignored
    } derive(Eq)

    StatementAnalysisStatus::equal

    automatically derived

    StatementAnalysisStatus::label

    Stable label for a statement parser result.

    StatementAnalysisStatus::not_equal

    automatically derived

    StatementTrace

    pub(all) struct StatementTrace {
    path : String
    statement_index : Int
    line : Int
    end_line : Int
    token_count : Int
    kind : String
    status : StatementAnalysisStatus
    reason : String
    }

    Provenance for one statement consumed by the bounded migration parser.

    SuppressedRule

    pub(all) struct SuppressedRule {
    rule_id : String
    count : Int
    }

    Number of findings suppressed by one rule.

    analysis_capabilities_markdown

    fn analysis_capabilities_markdown() -> String

    Describe the analysis stages and their intentional semantic boundaries.

    analyze_change_impact

    fn analyze_change_impact(migrations : Array[MigrationInput], queries : Array[MigrationInput], options : ScanOptions) -> ImpactAnalysis

    Cross-reference migration changes with downstream query sources.

    analyze_migrations

    fn analyze_migrations(inputs : Array[MigrationInput], options : ScanOptions) -> MigrationAnalysis

    Analyze an ordered SQL migration set while maintaining an evolving schema.

    files_to_github

    fn files_to_github(files : Array[FileReport]) -> String

    Render file reports as GitHub Actions workflow annotations.

    files_to_json

    fn files_to_json(files : Array[FileReport]) -> String

    Render one or more file reports as a single JSON document.

    files_to_markdown

    fn files_to_markdown(files : Array[FileReport]) -> String

    Render multiple reports as a Markdown document.

    files_to_sarif

    fn files_to_sarif(files : Array[FileReport]) -> String

    Render reports as SARIF 2.1.0 for GitHub code scanning and other Static Analysis Results Interchange Format consumers.

    files_to_text

    fn files_to_text(files : Array[FileReport]) -> String

    Render multiple reports as compact terminal output.

    impact_analysis_to_json

    fn impact_analysis_to_json(analysis : ImpactAnalysis) -> String

    Render cross-migration query impact as stable JSON.

    impact_analysis_to_markdown

    fn impact_analysis_to_markdown(analysis : ImpactAnalysis) -> String

    Render query impact as Markdown.

    impact_analysis_to_text

    fn impact_analysis_to_text(analysis : ImpactAnalysis) -> String

    Render query impact for terminal review.

    migration_analysis_to_json

    fn migration_analysis_to_json(analysis : MigrationAnalysis) -> String

    Render a project-level migration analysis as stable JSON.

    migration_analysis_to_markdown

    fn migration_analysis_to_markdown(analysis : MigrationAnalysis) -> String

    Render a migration analysis as a Markdown review document.

    migration_analysis_to_text

    fn migration_analysis_to_text(analysis : MigrationAnalysis) -> String

    Render a migration analysis for terminal review.

    report_to_github

    fn report_to_github(report : Report, path? : String) -> String

    Render one report as GitHub Actions workflow annotations.

    report_to_json

    fn report_to_json(report : Report) -> String

    Render a single report as stable, machine-readable JSON.

    report_to_markdown

    fn report_to_markdown(report : Report, path? : String) -> String

    Render one report as a Markdown review packet suitable for a pull request comment or an AI code-review prompt.

    report_to_text

    fn report_to_text(report : Report, path? : String) -> String

    Render one report as a compact terminal review.

    review_packet_to_json

    fn review_packet_to_json(files : Array[FileReport], migration : MigrationAnalysis, impact : ImpactAnalysis?) -> String

    Render a unified review packet as JSON.

    review_packet_to_markdown

    fn review_packet_to_markdown(files : Array[FileReport], migration : MigrationAnalysis, impact : ImpactAnalysis?) -> String

    Render a unified review packet as Markdown.

    review_packet_to_text

    fn review_packet_to_text(files : Array[FileReport], migration : MigrationAnalysis, impact : ImpactAnalysis?) -> String

    Render a unified review packet for terminal output.

    review_sarif_to_string

    fn review_sarif_to_string(files : Array[FileReport], migration : MigrationAnalysis, impact : ImpactAnalysis?) -> String

    Render the unified review as SARIF 2.1.0 for GitHub code scanning.

    rule_catalog

    fn rule_catalog() -> Array[RuleDefinition]

    Return every built-in rule and its rationale.

    rule_catalog_markdown

    fn rule_catalog_markdown() -> String

    Render the rule catalog as a Markdown reference.

    scan_sql

    fn scan_sql(source : String) -> Report

    Scan SQL text using the default policy.

    scan_sql_with

    fn scan_sql_with(source : String, options : ScanOptions) -> Report

    Scan SQL text with explicit policy controls.