{
  "schema": "aaes/capability-pack/1",
  "provider": "postgres",
  "version": "1.0.0",
  "description": "PostgreSQL: query invoices, customer records and audit logs, and insert, update or delete invoice rows through an allowlisted SQL adapter.",
  "notes": "Read operations are registered at R0, inserts and updates at R2, and deletion at R3. On supported AAES-mediated execution paths, delete requires approval by an authorized person; bypass and observation-only paths are outside that guarantee.\n\nThe SQL connector uses query or exec as its method vocabulary, rather than HTTP methods. It rejects operations outside that vocabulary. The domain layer requires registration of the operation.\n\nExact statements are controlled by the deployment's driver adapter allowlist, rather than this package. Review that allowlist and the database role's GRANTs before enabling writes. A capability named row.insert identifies an intended operation; the adapter must enforce the corresponding statement restriction.",
  "credential": {
    "secret_ref_id": "secret-ref-postgres-role",
    "custody": "customer_vault",
    "inject": "header",
    "inject_name": "Authorization",
    "note": "A dedicated least-privilege database role held in the client's own secret manager. The SQL adapter presents the resolved material to the database as its rail requires, and never interpolates it into a statement. The role's GRANTs, and the driver's statement allowlist, are the two things to review before enabling."
  },
  "capabilities": [
    {
      "capability_id": "postgres.invoices.query",
      "version": "1.0.0",
      "kind": "tool",
      "risk_tier": "R0",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN",
      "data_class": "internal",
      "egress_allowlist": [
        "DB_HOST:5432"
      ],
      "endpoint": "postgres://DB_HOST:5432/DB_NAME",
      "method": "query",
      "connector": "sql",
      "custody": "customer_vault",
      "secret_ref_id": "secret-ref-postgres-role",
      "inject": "header",
      "inject_name": "Authorization",
      "actions": [
        "read"
      ],
      "resource_id": "postgres-invoices",
      "description": "Run an allowlisted SELECT against the invoices table. DB_HOST and DB_NAME are placeholders.",
      "requires_review": true
    },
    {
      "capability_id": "postgres.customers.query",
      "version": "1.0.0",
      "kind": "tool",
      "risk_tier": "R0",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN",
      "data_class": "pii",
      "egress_allowlist": [
        "DB_HOST:5432"
      ],
      "endpoint": "postgres://DB_HOST:5432/DB_NAME",
      "method": "query",
      "connector": "sql",
      "custody": "customer_vault",
      "secret_ref_id": "secret-ref-postgres-role",
      "inject": "header",
      "inject_name": "Authorization",
      "actions": [
        "read"
      ],
      "resource_id": "postgres-customers",
      "description": "Run an allowlisted SELECT against the customers table (public.customers, the postgres-customers resource), which holds personal data.",
      "requires_review": true
    },
    {
      "capability_id": "postgres.audit_log.query",
      "version": "1.0.0",
      "kind": "tool",
      "risk_tier": "R0",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN",
      "data_class": "internal",
      "egress_allowlist": [
        "DB_HOST:5432"
      ],
      "endpoint": "postgres://DB_HOST:5432/DB_NAME",
      "method": "query",
      "connector": "sql",
      "custody": "customer_vault",
      "secret_ref_id": "secret-ref-postgres-role",
      "inject": "header",
      "inject_name": "Authorization",
      "actions": [
        "read"
      ],
      "resource_id": "postgres-audit-log",
      "description": "Run an allowlisted SELECT against the audit_log table.",
      "requires_review": true
    },
    {
      "version": "1.0.0",
      "kind": "tool",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN",
      "data_class": "internal",
      "egress_allowlist": [
        "DB_HOST:5432"
      ],
      "endpoint": "postgres://DB_HOST:5432/DB_NAME",
      "connector": "sql",
      "custody": "customer_vault",
      "secret_ref_id": "secret-ref-postgres-role",
      "inject": "header",
      "inject_name": "Authorization",
      "capability_id": "postgres.row.insert",
      "risk_tier": "R2",
      "method": "exec",
      "actions": [
        "create"
      ],
      "resource_id": "postgres-invoices",
      "description": "Run an allowlisted INSERT against invoices. The deployment's SQL adapter must allow the exact statement; the capability registration names the operation and does not supply that statement control.",
      "requires_review": true
    },
    {
      "version": "1.0.0",
      "kind": "tool",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN",
      "data_class": "internal",
      "egress_allowlist": [
        "DB_HOST:5432"
      ],
      "endpoint": "postgres://DB_HOST:5432/DB_NAME",
      "connector": "sql",
      "custody": "customer_vault",
      "secret_ref_id": "secret-ref-postgres-role",
      "inject": "header",
      "inject_name": "Authorization",
      "capability_id": "postgres.row.update",
      "risk_tier": "R2",
      "method": "exec",
      "actions": [
        "update"
      ],
      "resource_id": "postgres-invoices",
      "description": "Run an allowlisted UPDATE against invoices. Registered at the R2 minimum tier for update. Changes to financial records may be irreversible in practice; assess that risk separately and enforce the adapter's statement allowlist.",
      "requires_review": true
    },
    {
      "version": "1.0.0",
      "kind": "tool",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN",
      "data_class": "internal",
      "egress_allowlist": [
        "DB_HOST:5432"
      ],
      "endpoint": "postgres://DB_HOST:5432/DB_NAME",
      "connector": "sql",
      "custody": "customer_vault",
      "secret_ref_id": "secret-ref-postgres-role",
      "inject": "header",
      "inject_name": "Authorization",
      "capability_id": "postgres.row.delete",
      "risk_tier": "R3",
      "method": "exec",
      "actions": [
        "delete"
      ],
      "resource_id": "postgres-invoices",
      "description": "Run an allowlisted DELETE against the invoices table. Delete is one of the designated actions requiring human approval, so the operator approval gate applies.\n\nOn supported AAES-mediated execution paths, irreversible actions require approval by an authorized person; this does not prevent calls through bypass or observation-only paths.",
      "requires_review": true
    }
  ],
  "resources": [
    {
      "resource_id": "postgres-invoices",
      "kind": "table",
      "locator": "postgres://DB_HOST:5432/DB_NAME/public.invoices",
      "data_class": "internal",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN"
    },
    {
      "resource_id": "postgres-customers",
      "kind": "table",
      "locator": "postgres://DB_HOST:5432/DB_NAME/public.customers",
      "data_class": "pii",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN"
    },
    {
      "resource_id": "postgres-audit-log",
      "kind": "table",
      "locator": "postgres://DB_HOST:5432/DB_NAME/public.audit_log",
      "data_class": "internal",
      "owner": "REPLACE-WITH-ACCOUNTABLE-HUMAN"
    }
  ],
  "review": {
    "state": "library",
    "date": "2026-10-22",
    "sources": [
      "https://www.postgresql.org/docs/current/protocol-overview.html (retrieved 2026-09-20)",
      "https://www.postgresql.org/docs/current/protocol-flow.html (retrieved 2026-09-20)"
    ],
    "reviewer_id": "owner-delegated"
  }
}
