{
  "schema": 1,
  "sqlstate": "0LP01",
  "condition_name": "invalid_grant_operation",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "invalid_grant_operation",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned disposable target is provisioned."
      ],
      "trigger": "Grant an invalid sequence privilege, then grant USAGE to a disposable role.",
      "assertions": [
        "The selected server diagnostic has the expected SQLSTATE",
        "The selected recovery/probe assertions pass",
        "Runner-owned resources are cleaned up"
      ],
      "repair": "Follow the case-specific repair statements and verify the resulting state.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "invalid_grant_operation",
      "case_id": "invalid_grant_operation",
      "language": "sql",
      "statements": {
        "create_sequence": "CREATE SEQUENCE grant_sequence",
        "invalid": "GRANT INSERT ON SEQUENCE grant_sequence TO role",
        "repair": "GRANT USAGE ON SEQUENCE grant_sequence TO role",
        "verify": "SELECT has_sequence_privilege(role_literal, 'grant_sequence', 'USAGE')"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.0LP01-conn-test-latest.latest",
      "kind": "runtime_observation",
      "run_id": "0LP01-conn-test-latest",
      "target": "latest",
      "status": "passed",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "cases": [
        "invalid_grant_operation"
      ],
      "summary_sha256": "7cd561a0a16c3b4a377ce6d684a8c5929a690b05dc92a64e179a1fad18969885",
      "raw_sha256": "8ca360f063bded4bb4b1c964f030d855b1d05623576ceab7b9f9df82ecaacf54",
      "case_manifest_sha256": "da87dfe02737841ad5fcd3bdcf11a3db4d2d47335fbe3f8710603bc66bc0bb39",
      "snippet_registry": {
        "sha256": "4689f3bc44bd388dbca7965d35b4c04903204e66a0e1c6435dbdf950822f0fda"
      },
      "environment": {
        "target_kind": "latest",
        "server_version": "18.6 (Homebrew)",
        "server_version_num": "180006",
        "machine": "arm64",
        "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
        "libpq_version": "18.6",
        "psycopg_version": "3.3.5",
        "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
        "locale": "en_US.UTF-8",
        "lc_messages": "C",
        "log_destination": "csvlog,jsonlog"
      },
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "InvalidGrantOperation",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "invalid privilege type INSERT for sequence",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "aclchk.c",
          "source_function": "ExecuteGrantStmt",
          "source_line": "587",
          "sqlstate": "0LP01",
          "statement_position": null,
          "table_name": null,
          "text": "invalid privilege type INSERT for sequence"
        },
        "role": "u0lp01_4a1b230fc0",
        "statuses": {
          "after_error": "IDLE",
          "final": "IDLE"
        },
        "valid_privilege": "USAGE"
      },
      "assertions": [
        {
          "expected": "0LP01",
          "name": "grant operation SQLSTATE",
          "observed": "0LP01",
          "passed": true
        },
        {
          "expected": "invalid privilege type INSERT for sequence",
          "name": "grant operation diagnostic",
          "observed": "invalid privilege type INSERT for sequence",
          "passed": true
        },
        {
          "expected": "IDLE, USAGE granted, IDLE",
          "name": "valid sequence privilege repairs path",
          "observed": {
            "after_error": "IDLE",
            "final": "IDLE",
            "granted": true
          },
          "passed": true
        }
      ],
      "cleanup": {
        "case": {
          "errors": [],
          "passed": true
        }
      },
      "limits": "Disposable runner-owned target only; this is a bounded mechanism case, not a guarantee for every client or network path.",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 53952,
          "binary": {
            "bindir": "/opt/homebrew/Cellar/postgresql@18/18.6/bin",
            "pg_config": "/opt/homebrew/bin/pg_config",
            "pg_config_version": "PostgreSQL 18.6 (Homebrew)",
            "postgres": "/opt/homebrew/Cellar/postgresql@18/18.6/bin/postgres"
          },
          "connection_scope": "runner-owned localhost port",
          "current_user": "runner",
          "docker": {},
          "lc_messages": "C",
          "libpq_version": "18.6",
          "locale": "en_US.UTF-8",
          "log_destination": "csvlog,jsonlog",
          "log_error_verbosity": "verbose",
          "log_min_error_statement": "error",
          "log_min_messages": "error",
          "logging_collector": "on",
          "machine": "arm64",
          "max_connections": "100",
          "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
          "psycopg_version": "3.3.5",
          "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
          "server_encoding": "UTF8",
          "server_version": "18.6 (Homebrew)",
          "server_version_num": "180006",
          "target_kind": "latest",
          "wal_level": "logical"
        },
        "cases": [
          {
            "assertions": [
              {
                "expected": "0LP01",
                "name": "grant operation SQLSTATE",
                "observed": "0LP01",
                "passed": true
              },
              {
                "expected": "invalid privilege type INSERT for sequence",
                "name": "grant operation diagnostic",
                "observed": "invalid privilege type INSERT for sequence",
                "passed": true
              },
              {
                "expected": "IDLE, USAGE granted, IDLE",
                "name": "valid sequence privilege repairs path",
                "observed": {
                  "after_error": "IDLE",
                  "final": "IDLE",
                  "granted": true
                },
                "passed": true
              }
            ],
            "case_id": "invalid_grant_operation",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.01,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "InvalidGrantOperation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "invalid privilege type INSERT for sequence",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "aclchk.c",
                "source_function": "ExecuteGrantStmt",
                "source_line": "587",
                "sqlstate": "0LP01",
                "statement_position": null,
                "table_name": null,
                "text": "invalid privilege type INSERT for sequence"
              },
              "role": "u0lp01_4a1b230fc0",
              "statuses": {
                "after_error": "IDLE",
                "final": "IDLE"
              },
              "valid_privilege": "USAGE"
            },
            "schema": "c0lp01_invalid_grant_operation",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.0LP01-conn-test-pg10.pg10",
      "kind": "runtime_observation",
      "run_id": "0LP01-conn-test-pg10",
      "target": "pg10",
      "status": "passed",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "cases": [
        "invalid_grant_operation"
      ],
      "summary_sha256": "dca3d6e0e507a3adbe5bc637b52e8c4f503f6cc813872af135ac542ca1312603",
      "raw_sha256": "948874e5c9479ae408cf528de73c57fb03410e9dc8eb0d3dd8cf8751a6f19c09",
      "case_manifest_sha256": "da87dfe02737841ad5fcd3bdcf11a3db4d2d47335fbe3f8710603bc66bc0bb39",
      "snippet_registry": {
        "sha256": "4689f3bc44bd388dbca7965d35b4c04903204e66a0e1c6435dbdf950822f0fda"
      },
      "environment": {
        "target_kind": "pg10",
        "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
        "server_version_num": "100021",
        "machine": "arm64",
        "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
        "libpq_version": "18.6",
        "psycopg_version": "3.3.5",
        "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
        "locale": "en_US.UTF-8",
        "lc_messages": "en_US.utf8",
        "log_destination": "csvlog"
      },
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "InvalidGrantOperation",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "invalid privilege type INSERT for sequence",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "aclchk.c",
          "source_function": "ExecuteGrantStmt",
          "source_line": "550",
          "sqlstate": "0LP01",
          "statement_position": null,
          "table_name": null,
          "text": "invalid privilege type INSERT for sequence"
        },
        "role": "u0lp01_5cf42727d1",
        "statuses": {
          "after_error": "IDLE",
          "final": "IDLE"
        },
        "valid_privilege": "USAGE"
      },
      "assertions": [
        {
          "expected": "0LP01",
          "name": "grant operation SQLSTATE",
          "observed": "0LP01",
          "passed": true
        },
        {
          "expected": "invalid privilege type INSERT for sequence",
          "name": "grant operation diagnostic",
          "observed": "invalid privilege type INSERT for sequence",
          "passed": true
        },
        {
          "expected": "IDLE, USAGE granted, IDLE",
          "name": "valid sequence privilege repairs path",
          "observed": {
            "after_error": "IDLE",
            "final": "IDLE",
            "granted": true
          },
          "passed": true
        }
      ],
      "cleanup": {
        "case": {
          "errors": [],
          "passed": true
        }
      },
      "limits": "Disposable runner-owned target only; this is a bounded mechanism case, not a guarantee for every client or network path.",
      "image": "postgres:10",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Etc/UTC",
          "backend_pid": 79,
          "binary": {},
          "connection_scope": "runner-owned localhost port",
          "current_user": "postgres",
          "docker": {
            "architecture": "arm64",
            "command": "/usr/local/bin/docker",
            "digest": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "id": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "image": "postgres:10",
            "image_created": "2022-06-23T09:11:18.374607054Z",
            "image_ref": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "log_destination": "csvlog",
            "os": "linux",
            "repo_digests": [
              "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc"
            ]
          },
          "lc_messages": "en_US.utf8",
          "libpq_version": "18.6",
          "locale": "en_US.UTF-8",
          "log_destination": "csvlog",
          "log_error_verbosity": "verbose",
          "log_min_error_statement": "error",
          "log_min_messages": "error",
          "logging_collector": "on",
          "machine": "arm64",
          "max_connections": "100",
          "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
          "psycopg_version": "3.3.5",
          "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
          "server_encoding": "UTF8",
          "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
          "server_version_num": "100021",
          "target_kind": "pg10",
          "wal_level": "logical"
        },
        "cases": [
          {
            "assertions": [
              {
                "expected": "0LP01",
                "name": "grant operation SQLSTATE",
                "observed": "0LP01",
                "passed": true
              },
              {
                "expected": "invalid privilege type INSERT for sequence",
                "name": "grant operation diagnostic",
                "observed": "invalid privilege type INSERT for sequence",
                "passed": true
              },
              {
                "expected": "IDLE, USAGE granted, IDLE",
                "name": "valid sequence privilege repairs path",
                "observed": {
                  "after_error": "IDLE",
                  "final": "IDLE",
                  "granted": true
                },
                "passed": true
              }
            ],
            "case_id": "invalid_grant_operation",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.016,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "InvalidGrantOperation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "invalid privilege type INSERT for sequence",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "aclchk.c",
                "source_function": "ExecuteGrantStmt",
                "source_line": "550",
                "sqlstate": "0LP01",
                "statement_position": null,
                "table_name": null,
                "text": "invalid privilege type INSERT for sequence"
              },
              "role": "u0lp01_5cf42727d1",
              "statuses": {
                "after_error": "IDLE",
                "final": "IDLE"
              },
              "valid_privilege": "USAGE"
            },
            "schema": "c0lp01_invalid_grant_operation",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
