{
  "schemaVersion": 1,
  "tool": {
    "name": "skewcheck",
    "version": "0.1.0"
  },
  "executionId": "example-K-table-removed",
  "project": "fixture/K-table-removed",
  "createdAt": "2026-10-24T18:30:08.893Z",
  "baselineRevision": "shop-v1",
  "candidateRevision": "K-table-removed",
  "database": {
    "serverVersion": "16.15 (Debian 16.15-1.pgdg12+2)"
  },
  "proposedMigrations": [
    "002_move_orders.sql"
  ],
  "experiment": [
    "control: old application (shop-v1) × baseline schema (1 migrations)",
    "candidate ×2: old application (shop-v1) × proposed schema (2 migrations)"
  ],
  "verdict": "UNSAFE",
  "blocking": true,
  "exitCode": 1,
  "summary": "The previous application version reproducibly fails against the proposed schema, and the failure is linked to a specific schema change.",
  "reasons": [
    "test/orders.test.js: SQLSTATE 42P01 (undefined_table) linked to table_removed:orders by R2 undefined_table ↔ removed/renamed relation."
  ],
  "recommendedAction": "Make the migration backward compatible (expand/contract: keep the old shape until the old version is retired), then re-run the gate.",
  "complete": true,
  "findings": [
    {
      "kind": "regression",
      "test": "test/orders.test.js",
      "facts": [
        "test/orders.test.js passes on the baseline schema and fails in all 2 candidate runs.",
        "New in every candidate run, absent from the control run: SQLSTATE 42P01 (undefined_table): relation \"orders\" does not exist — statement: INSERT INTO orders (customer_id, total_cents) VALUES ($1, $2) RETURNING id, status"
      ],
      "interpretation": "The statement references relation \"orders\", which the proposed schema removed.",
      "sqlstate": "42P01",
      "changeIds": [
        "table_removed:orders"
      ],
      "rule": "R2 undefined_table ↔ removed/renamed relation",
      "strength": "strong",
      "error": {
        "run": "cand1",
        "test": "test/orders.test.js",
        "sqlstate": "42P01",
        "message": "relation \"orders\" does not exist",
        "detail": null,
        "statement": "INSERT INTO orders (customer_id, total_cents) VALUES ($1, $2) RETURNING id, status",
        "fingerprint": "insert into orders ( customer_id , total_cents ) values ( ? ) returning id , status",
        "key": "42P01|relation \"orders\" does not exist|insert into orders ( customer_id , total_cents ) values ( ? ) returning id , status",
        "severity": "ERROR",
        "objects": {
          "relation": "orders"
        }
      }
    }
  ],
  "schemaChanges": [
    {
      "id": "table_removed:orders",
      "kind": "table_removed",
      "risk": "breaking",
      "schema": "public",
      "table": "orders",
      "before": "table"
    },
    {
      "id": "table_added:purchase_orders",
      "kind": "table_added",
      "risk": "inert",
      "schema": "public",
      "table": "purchase_orders",
      "after": "table"
    }
  ],
  "coverage": [
    {
      "changeId": "table_removed:orders",
      "target": "orders",
      "risk": "breaking",
      "required": true,
      "exercised": true,
      "statementCount": 4,
      "tests": [
        "test/orders.test.js"
      ],
      "staticReferences": [
        "src/orders.js:5",
        "src/orders.js:12",
        "src/orders.js:16",
        "test/orders.test.js:5",
        "test/orders.test.js:9"
      ]
    },
    {
      "changeId": "table_added:purchase_orders",
      "target": "purchase_orders",
      "risk": "inert",
      "required": false,
      "exercised": false,
      "statementCount": 0,
      "tests": [],
      "staticReferences": []
    }
  ],
  "coverageSummary": "1 of 1 risk-bearing schema change(s) were exercised by the old application's tests in the control run.",
  "runs": [
    {
      "id": "ctl",
      "label": "control (old app × baseline schema)",
      "app": "baseline",
      "schema": "baseline",
      "database": "sc_ctl",
      "revision": "shop-v1",
      "completed": true,
      "migrations": [
        {
          "file": "001_init.sql",
          "ok": true
        }
      ],
      "tests": [
        {
          "test": "test/customers.test.js",
          "outcome": "pass",
          "exitCode": 0,
          "durationMs": 100,
          "outputTail": "TAP version 13\n# Subtest: signs up a customer and finds them by email\nok 1 - signs up a customer and finds them by email\n  ---\n  duration_ms: 10.34792\n  ...\n1..1\n# tests 1\n# suites 0\n# pass 1\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 72.809733\n"
        },
        {
          "test": "test/orders.test.js",
          "outcome": "pass",
          "exitCode": 0,
          "durationMs": 102,
          "outputTail": "TAP version 13\n# Subtest: new orders start in status \"new\" and can be shipped\nok 1 - new orders start in status \"new\" and can be shipped\n  ---\n  duration_ms: 14.007167\n  ...\n1..1\n# tests 1\n# suites 0\n# pass 1\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 74.468733\n"
        }
      ],
      "errors": [],
      "statements": 7
    },
    {
      "id": "cand1",
      "label": "candidate #1 (old app × proposed schema)",
      "app": "baseline",
      "schema": "candidate",
      "database": "sc_cand1",
      "revision": "shop-v1",
      "completed": true,
      "migrations": [
        {
          "file": "001_init.sql",
          "ok": true
        },
        {
          "file": "002_move_orders.sql",
          "ok": true
        }
      ],
      "tests": [
        {
          "test": "test/customers.test.js",
          "outcome": "pass",
          "exitCode": 0,
          "durationMs": 102,
          "outputTail": "TAP version 13\n# Subtest: signs up a customer and finds them by email\nok 1 - signs up a customer and finds them by email\n  ---\n  duration_ms: 10.365885\n  ...\n1..1\n# tests 1\n# suites 0\n# pass 1\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 71.481263\n"
        },
        {
          "test": "test/orders.test.js",
          "outcome": "fail",
          "exitCode": 1,
          "durationMs": 99,
          "outputTail": "TAP version 13\n# Subtest: new orders start in status \"new\" and can be shipped\nnot ok 1 - new orders start in status \"new\" and can be shipped\n  ---\n  duration_ms: 10.575096\n  location: '<app>/test/orders.test.js:9:1'\n  failureType: 'testCodeFailure'\n  error: 'relation \"orders\" does not exist'\n  code: '42P01'\n  name: 'error'\n  stack: |-\n    <skewcheck>/node_modules/pg-pool/index.js:45:11\n    process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    async createOrder (<app>/src/orders.js:4:13)\n    async TestContext.<anonymous> (<app>/test/orders.test.js:11:13)\n    async Test.run (node:internal/test_runner/test:935:9)\n    async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)\n  ...\n1..1\n# tests 1\n# suites 0\n# pass 0\n# fail 1\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 71.714733\n"
        }
      ],
      "errors": [
        {
          "run": "cand1",
          "test": "test/orders.test.js",
          "sqlstate": "42P01",
          "message": "relation \"orders\" does not exist",
          "detail": null,
          "statement": "INSERT INTO orders (customer_id, total_cents) VALUES ($1, $2) RETURNING id, status",
          "fingerprint": "insert into orders ( customer_id , total_cents ) values ( ? ) returning id , status",
          "key": "42P01|relation \"orders\" does not exist|insert into orders ( customer_id , total_cents ) values ( ? ) returning id , status",
          "severity": "ERROR",
          "objects": {
            "relation": "orders"
          }
        }
      ],
      "statements": 3
    },
    {
      "id": "cand2",
      "label": "candidate #2 (old app × proposed schema)",
      "app": "baseline",
      "schema": "candidate",
      "database": "sc_cand2",
      "revision": "shop-v1",
      "completed": true,
      "migrations": [
        {
          "file": "001_init.sql",
          "ok": true
        },
        {
          "file": "002_move_orders.sql",
          "ok": true
        }
      ],
      "tests": [
        {
          "test": "test/customers.test.js",
          "outcome": "pass",
          "exitCode": 0,
          "durationMs": 104,
          "outputTail": "TAP version 13\n# Subtest: signs up a customer and finds them by email\nok 1 - signs up a customer and finds them by email\n  ---\n  duration_ms: 11.353022\n  ...\n1..1\n# tests 1\n# suites 0\n# pass 1\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 72.402716\n"
        },
        {
          "test": "test/orders.test.js",
          "outcome": "fail",
          "exitCode": 1,
          "durationMs": 99,
          "outputTail": "TAP version 13\n# Subtest: new orders start in status \"new\" and can be shipped\nnot ok 1 - new orders start in status \"new\" and can be shipped\n  ---\n  duration_ms: 10.524903\n  location: '<app>/test/orders.test.js:9:1'\n  failureType: 'testCodeFailure'\n  error: 'relation \"orders\" does not exist'\n  code: '42P01'\n  name: 'error'\n  stack: |-\n    <skewcheck>/node_modules/pg-pool/index.js:45:11\n    process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    async createOrder (<app>/src/orders.js:4:13)\n    async TestContext.<anonymous> (<app>/test/orders.test.js:11:13)\n    async Test.run (node:internal/test_runner/test:935:9)\n    async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)\n  ...\n1..1\n# tests 1\n# suites 0\n# pass 0\n# fail 1\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 72.055365\n"
        }
      ],
      "errors": [
        {
          "run": "cand2",
          "test": "test/orders.test.js",
          "sqlstate": "42P01",
          "message": "relation \"orders\" does not exist",
          "detail": null,
          "statement": "INSERT INTO orders (customer_id, total_cents) VALUES ($1, $2) RETURNING id, status",
          "fingerprint": "insert into orders ( customer_id , total_cents ) values ( ? ) returning id , status",
          "key": "42P01|relation \"orders\" does not exist|insert into orders ( customer_id , total_cents ) values ( ? ) returning id , status",
          "severity": "ERROR",
          "objects": {
            "relation": "orders"
          }
        }
      ],
      "statements": 3
    }
  ],
  "skippedChecks": [
    "Current application × proposed schema (no current app configured).",
    "Performance / lock-time analysis (out of scope)."
  ],
  "limitations": [
    "Skewcheck only observes code paths that the old application's tests execute; untested paths are reported as coverage gaps, not as safe.",
    "Coverage is identifier-level: a statement \"touches\" a changed object when it names the table (and column, or uses *). It is not a SQL parser.",
    "Correlation between an error and a schema change uses a fixed set of deterministic rules (R1–R6). Anything else is reported as ADVISORY, never UNSAFE.",
    "Performance, locking and migration runtime on production-sized data are not evaluated.",
    "Test files of one run share a database and run sequentially; ordering effects are identical across runs but are not isolated.",
    "Data-only migration effects are detected only when a test asserts on the affected data."
  ],
  "policy": {
    "advisory": "warn",
    "noEvidence": "block",
    "inconclusive": "block",
    "candidateRepeats": 2,
    "testTimeoutMs": 60000,
    "maxBaselineFailureRatio": 0.5,
    "protectedPaths": [],
    "repairBranchPrefixes": [
      "skewcheck-repair/"
    ]
  }
}